Commit f11cd721 by Nicolas Capens Committed by Nicolas Capens

Fix initial rbo state.

Renderbuffer objects are defined to have an initial internalformat of GL_RGBA4, but the red/green/blue/alpha bits are 0. This inconsistency is resolved by setting the internalformat to GL_NONE but reporting GL_RGBA4 when queried. Change-Id: Ie9a342c05eaa23f81773b37ebb942ca2e5b1addb Reviewed-on: https://swiftshader-review.googlesource.com/14588Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d95dbb8f
...@@ -402,7 +402,7 @@ RenderbufferStorage::RenderbufferStorage() ...@@ -402,7 +402,7 @@ RenderbufferStorage::RenderbufferStorage()
{ {
mWidth = 0; mWidth = 0;
mHeight = 0; mHeight = 0;
format = GL_RGBA4; format = GL_NONE;
mSamples = 0; mSamples = 0;
} }
......
...@@ -324,7 +324,7 @@ void ResourceManager::checkRenderbufferAllocation(GLuint handle) ...@@ -324,7 +324,7 @@ void ResourceManager::checkRenderbufferAllocation(GLuint handle)
{ {
if(handle != 0 && !getRenderbuffer(handle)) if(handle != 0 && !getRenderbuffer(handle))
{ {
Renderbuffer *renderbufferObject = new Renderbuffer(handle, new Colorbuffer(0, 0, GL_RGBA4_OES, 0)); Renderbuffer *renderbufferObject = new Renderbuffer(handle, new Colorbuffer(0, 0, GL_NONE, 0));
renderbufferObject->addRef(); renderbufferObject->addRef();
mRenderbufferNameSpace.insert(handle, renderbufferObject); mRenderbufferNameSpace.insert(handle, renderbufferObject);
......
...@@ -3349,7 +3349,12 @@ void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) ...@@ -3349,7 +3349,12 @@ void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
{ {
case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getFormat(); break; case GL_RENDERBUFFER_INTERNAL_FORMAT:
{
GLint internalformat = renderbuffer->getFormat();
*params = (internalformat == GL_NONE) ? GL_RGBA4 : internalformat;
}
break;
case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
......
...@@ -1135,6 +1135,11 @@ namespace es2 ...@@ -1135,6 +1135,11 @@ namespace es2
bool IsColorRenderable(GLint internalformat, GLint clientVersion) bool IsColorRenderable(GLint internalformat, GLint clientVersion)
{ {
if(IsCompressed(internalformat, clientVersion))
{
return false;
}
switch(internalformat) switch(internalformat)
{ {
case GL_RGBA4: case GL_RGBA4:
...@@ -1201,6 +1206,11 @@ namespace es2 ...@@ -1201,6 +1206,11 @@ namespace es2
bool IsDepthRenderable(GLint internalformat, GLint clientVersion) bool IsDepthRenderable(GLint internalformat, GLint clientVersion)
{ {
if(IsCompressed(internalformat, clientVersion))
{
return false;
}
switch(internalformat) switch(internalformat)
{ {
case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT24:
...@@ -1267,6 +1277,11 @@ namespace es2 ...@@ -1267,6 +1277,11 @@ namespace es2
bool IsStencilRenderable(GLint internalformat, GLint clientVersion) bool IsStencilRenderable(GLint internalformat, GLint clientVersion)
{ {
if(IsCompressed(internalformat, clientVersion))
{
return false;
}
switch(internalformat) switch(internalformat)
{ {
case GL_STENCIL_INDEX8: case GL_STENCIL_INDEX8:
...@@ -1353,6 +1368,7 @@ namespace es2 ...@@ -1353,6 +1368,7 @@ namespace es2
{ {
switch(internalformat) switch(internalformat)
{ {
case GL_NONE: return 0;
case GL_RGBA4: return 4; case GL_RGBA4: return 4;
case GL_RGB5_A1: return 1; case GL_RGB5_A1: return 1;
case GL_RGB565: return 0; case GL_RGB565: return 0;
...@@ -1392,7 +1408,7 @@ namespace es2 ...@@ -1392,7 +1408,7 @@ namespace es2
case GL_RGBA32UI: return 32; case GL_RGBA32UI: return 32;
case GL_R11F_G11F_B10F: return 0; case GL_R11F_G11F_B10F: return 0;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1401,6 +1417,7 @@ namespace es2 ...@@ -1401,6 +1417,7 @@ namespace es2
{ {
switch(internalformat) switch(internalformat)
{ {
case GL_NONE: return 0;
case GL_RGBA4: return 4; case GL_RGBA4: return 4;
case GL_RGB5_A1: return 5; case GL_RGB5_A1: return 5;
case GL_RGB565: return 5; case GL_RGB565: return 5;
...@@ -1440,7 +1457,7 @@ namespace es2 ...@@ -1440,7 +1457,7 @@ namespace es2
case GL_RGBA32UI: return 32; case GL_RGBA32UI: return 32;
case GL_R11F_G11F_B10F: return 11; case GL_R11F_G11F_B10F: return 11;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1449,6 +1466,7 @@ namespace es2 ...@@ -1449,6 +1466,7 @@ namespace es2
{ {
switch(internalformat) switch(internalformat)
{ {
case GL_NONE: return 0;
case GL_RGBA4: return 4; case GL_RGBA4: return 4;
case GL_RGB5_A1: return 5; case GL_RGB5_A1: return 5;
case GL_RGB565: return 6; case GL_RGB565: return 6;
...@@ -1488,7 +1506,7 @@ namespace es2 ...@@ -1488,7 +1506,7 @@ namespace es2
case GL_RGBA32UI: return 32; case GL_RGBA32UI: return 32;
case GL_R11F_G11F_B10F: return 11; case GL_R11F_G11F_B10F: return 11;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1497,6 +1515,7 @@ namespace es2 ...@@ -1497,6 +1515,7 @@ namespace es2
{ {
switch(internalformat) switch(internalformat)
{ {
case GL_NONE: return 0;
case GL_RGBA4: return 4; case GL_RGBA4: return 4;
case GL_RGB5_A1: return 5; case GL_RGB5_A1: return 5;
case GL_RGB565: return 5; case GL_RGB565: return 5;
...@@ -1536,7 +1555,7 @@ namespace es2 ...@@ -1536,7 +1555,7 @@ namespace es2
case GL_RGBA32UI: return 32; case GL_RGBA32UI: return 32;
case GL_R11F_G11F_B10F: return 10; case GL_R11F_G11F_B10F: return 10;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1553,7 +1572,7 @@ namespace es2 ...@@ -1553,7 +1572,7 @@ namespace es2
case GL_DEPTH24_STENCIL8: return 24; case GL_DEPTH24_STENCIL8: return 24;
case GL_DEPTH32F_STENCIL8: return 32; case GL_DEPTH32F_STENCIL8: return 32;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1570,7 +1589,7 @@ namespace es2 ...@@ -1570,7 +1589,7 @@ namespace es2
case GL_DEPTH24_STENCIL8: return 8; case GL_DEPTH24_STENCIL8: return 8;
case GL_DEPTH32F_STENCIL8: return 8; case GL_DEPTH32F_STENCIL8: return 8;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return 0; return 0;
} }
} }
...@@ -1637,7 +1656,7 @@ namespace es2 ...@@ -1637,7 +1656,7 @@ namespace es2
case GL_RGB9_E5: case GL_RGB9_E5:
return GL_FLOAT; return GL_FLOAT;
default: default:
UNREACHABLE(internalformat); // UNREACHABLE(internalformat);
return GL_NONE; return GL_NONE;
} }
} }
...@@ -2061,6 +2080,7 @@ namespace es2sw ...@@ -2061,6 +2080,7 @@ namespace es2sw
{ {
switch(format) switch(format)
{ {
case GL_NONE: return sw::FORMAT_NULL;
case GL_RGBA4: case GL_RGBA4:
case GL_RGB5_A1: case GL_RGB5_A1:
case GL_RGBA8: return sw::FORMAT_A8B8G8R8; case GL_RGBA8: return sw::FORMAT_A8B8G8R8;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment