Commit 13b63990 by Alexis Hetu Committed by Alexis Hétu

Vertex Array Object crash fix

Vertex array objects are not allocated when generated, but only when bound, so it's legal to have a null vertex array object internally. Change-Id: Ib28a388939e285425c09cfbc9f4efef3f4a8cead Reviewed-on: https://swiftshader-review.googlesource.com/4700Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent d1ec5cb3
...@@ -1536,6 +1536,13 @@ VertexArray *Context::getCurrentVertexArray() const ...@@ -1536,6 +1536,13 @@ VertexArray *Context::getCurrentVertexArray() const
return getVertexArray(mState.vertexArray); return getVertexArray(mState.vertexArray);
} }
bool Context::isVertexArray(GLuint array) const
{
VertexArrayMap::const_iterator vertexArray = mVertexArrayMap.find(array);
return vertexArray != mVertexArrayMap.end();
}
bool Context::hasZeroDivisor() const bool Context::hasZeroDivisor() const
{ {
// Verify there is at least one active attribute with a divisor of zero // Verify there is at least one active attribute with a divisor of zero
...@@ -3642,7 +3649,11 @@ void Context::detachBuffer(GLuint buffer) ...@@ -3642,7 +3649,11 @@ void Context::detachBuffer(GLuint buffer)
for(auto vaoIt = mVertexArrayMap.begin(); vaoIt != mVertexArrayMap.end(); vaoIt++) for(auto vaoIt = mVertexArrayMap.begin(); vaoIt != mVertexArrayMap.end(); vaoIt++)
{ {
vaoIt->second->detachBuffer(buffer); VertexArray* vertexArray = vaoIt->second;
if(vertexArray)
{
vertexArray->detachBuffer(buffer);
}
} }
for(int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++) for(int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
......
...@@ -601,6 +601,7 @@ public: ...@@ -601,6 +601,7 @@ public:
Query *getQuery(GLuint handle) const; Query *getQuery(GLuint handle) const;
VertexArray *getVertexArray(GLuint array) const; VertexArray *getVertexArray(GLuint array) const;
VertexArray *getCurrentVertexArray() const; VertexArray *getCurrentVertexArray() const;
bool isVertexArray(GLuint array) const;
TransformFeedback *getTransformFeedback(GLuint transformFeedback) const; TransformFeedback *getTransformFeedback(GLuint transformFeedback) const;
TransformFeedback *getTransformFeedback() const; TransformFeedback *getTransformFeedback() const;
Sampler *getSampler(GLuint sampler) const; Sampler *getSampler(GLuint sampler) const;
......
...@@ -1743,7 +1743,7 @@ GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array) ...@@ -1743,7 +1743,7 @@ GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array)
if(context) if(context)
{ {
if(!context->getVertexArray(array)) if(!context->isVertexArray(array))
{ {
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