Commit 22049505 by Alexis Hetu Committed by Alexis Hétu

Fixed detaching a buffer

- Quite a few buffers weren't being checked properly when a buffer was getting detached from the current context. - Only current objects (TransformFeedback, VertexArray) should be affected by this. Change-Id: I621c9fa45a951db5634616884cf57d5cb21d9bda Reviewed-on: https://swiftshader-review.googlesource.com/4748Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 1abb6380
......@@ -3690,36 +3690,61 @@ int Context::getSupportedMultisampleCount(int requested)
void Context::detachBuffer(GLuint buffer)
{
// [OpenGL ES 2.0.24] section 2.9 page 22:
// If a buffer object is deleted while it is bound, all bindings to that object in the current context
// (i.e. in the thread that called Delete-Buffers) are reset to zero.
// [OpenGL ES 2.0.24] section 2.9 page 22:
// If a buffer object is deleted while it is bound, all bindings to that object in the current context
// (i.e. in the thread that called Delete-Buffers) are reset to zero.
if(getArrayBufferName() == buffer)
{
mState.arrayBuffer = NULL;
}
if(mState.copyReadBuffer.name() == buffer)
{
mState.copyReadBuffer = nullptr;
}
if(mState.copyWriteBuffer.name() == buffer)
{
mState.copyWriteBuffer = nullptr;
}
for(auto tfIt = mTransformFeedbackMap.begin(); tfIt != mTransformFeedbackMap.end(); tfIt++)
if(mState.pixelPackBuffer.name() == buffer)
{
tfIt->second->detachBuffer(buffer);
mState.pixelPackBuffer = nullptr;
}
for(auto vaoIt = mVertexArrayMap.begin(); vaoIt != mVertexArrayMap.end(); vaoIt++)
if(mState.pixelUnpackBuffer.name() == buffer)
{
VertexArray* vertexArray = vaoIt->second;
if(vertexArray)
mState.pixelUnpackBuffer = nullptr;
}
if(mState.genericUniformBuffer.name() == buffer)
{
mState.genericUniformBuffer = nullptr;
}
if(getArrayBufferName() == buffer)
{
mState.arrayBuffer = nullptr;
}
// Only detach from the current transform feedback
TransformFeedback* currentTransformFeedback = getTransformFeedback();
if(currentTransformFeedback)
{
currentTransformFeedback->detachBuffer(buffer);
}
// Only detach from the current vertex array
VertexArray* currentVertexArray = getCurrentVertexArray();
if(currentVertexArray)
{
currentVertexArray->detachBuffer(buffer);
}
for(int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
{
if(mState.vertexAttribute[attribute].mBoundBuffer.name() == buffer)
{
vertexArray->detachBuffer(buffer);
mState.vertexAttribute[attribute].mBoundBuffer = NULL;
}
}
for(int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
{
if(mState.vertexAttribute[attribute].mBoundBuffer.name() == buffer)
{
mState.vertexAttribute[attribute].mBoundBuffer = NULL;
}
}
}
void Context::detachTexture(GLuint texture)
......
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