Commit 2ea6f557 by Alexis Hetu Committed by Alexis Hétu

Renderbuffer allocation fix for GLES3

According to the ES3 spec, there's no requirement for a renderbuffer to be allocated until it is bound and any non-zero renderbuffer bound must be allocated. Change-Id: Id47083c7ec6e3b3698e176d6feff31121983e446 Reviewed-on: https://swiftshader-review.googlesource.com/4331Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 360361a4
...@@ -1266,6 +1266,8 @@ void Context::bindDrawFramebuffer(GLuint framebuffer) ...@@ -1266,6 +1266,8 @@ void Context::bindDrawFramebuffer(GLuint framebuffer)
void Context::bindRenderbuffer(GLuint renderbuffer) void Context::bindRenderbuffer(GLuint renderbuffer)
{ {
mResourceManager->checkRenderbufferAllocation(renderbuffer);
mState.renderbuffer = getRenderbuffer(renderbuffer); mState.renderbuffer = getRenderbuffer(renderbuffer);
} }
......
...@@ -324,12 +324,6 @@ Renderbuffer *ResourceManager::getRenderbuffer(unsigned int handle) ...@@ -324,12 +324,6 @@ Renderbuffer *ResourceManager::getRenderbuffer(unsigned int handle)
} }
else else
{ {
if (!renderbuffer->second)
{
Renderbuffer *renderbufferObject = new Renderbuffer(handle, new Colorbuffer(0, 0, GL_RGBA4_OES, 0));
mRenderbufferMap[handle] = renderbufferObject;
renderbufferObject->addRef();
}
return renderbuffer->second; return renderbuffer->second;
} }
} }
...@@ -414,6 +408,16 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type) ...@@ -414,6 +408,16 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
} }
} }
void ResourceManager::checkRenderbufferAllocation(GLuint handle)
{
if(handle != 0 && !getRenderbuffer(handle))
{
Renderbuffer *renderbufferObject = new Renderbuffer(handle, new Colorbuffer(0, 0, GL_RGBA4_OES, 0));
mRenderbufferMap[handle] = renderbufferObject;
renderbufferObject->addRef();
}
}
void ResourceManager::checkSamplerAllocation(GLuint sampler) void ResourceManager::checkSamplerAllocation(GLuint sampler)
{ {
if(sampler != 0 && !getSampler(sampler)) if(sampler != 0 && !getSampler(sampler))
......
...@@ -80,6 +80,7 @@ class ResourceManager ...@@ -80,6 +80,7 @@ class ResourceManager
void checkBufferAllocation(unsigned int buffer); void checkBufferAllocation(unsigned int buffer);
void checkTextureAllocation(GLuint texture, TextureType type); void checkTextureAllocation(GLuint texture, TextureType type);
void checkRenderbufferAllocation(GLuint handle);
void checkSamplerAllocation(GLuint sampler); void checkSamplerAllocation(GLuint sampler);
bool isSampler(GLuint sampler); bool isSampler(GLuint sampler);
......
...@@ -509,10 +509,12 @@ void BindRenderbuffer(GLenum target, GLuint renderbuffer) ...@@ -509,10 +509,12 @@ void BindRenderbuffer(GLenum target, GLuint renderbuffer)
if(context) if(context)
{ {
if(renderbuffer != 0 && !context->getRenderbuffer(renderbuffer)) // [OpenGL ES 3.0.4] Section 4.4.2 page 204
// If renderbuffer is not zero, then the resulting renderbuffer object
// is a new state vector, initialized with a zero-sized memory buffer.
if(renderbuffer != 0 && !context->getRenderbuffer(renderbuffer) && (context->getClientVersion() < 3))
{ {
// [OpenGL ES 2.0.25] Section 4.4.3 page 112 // [OpenGL ES 2.0.25] Section 4.4.3 page 112
// [OpenGL ES 3.0.2] Section 4.4.2 page 201
// 'renderbuffer' must be either zero or the name of an existing renderbuffer object of // 'renderbuffer' must be either zero or the name of an existing renderbuffer object of
// type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated. // type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated.
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
......
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