Commit 6f28403a by Alexis Hetu Committed by Alexis Hétu

Fixed GL_VERTEX_ATTRIB_ARRAY_INTEGER queries

Added pureInteger member to VertexAttribute in order to keep track of whether the attrib was set using glVertexAttribIPointer or glVertexAttribPointer and properly return that state when querying GL_VERTEX_ATTRIB_ARRAY_INTEGER. Fixes dEQP-GLES3.functional.state_query.shader.vertex_attrib_integer Change-Id: Ie6cfcd2008f7abb61d457a41124600fe7cea229a Reviewed-on: https://swiftshader-review.googlesource.com/14828Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 125c7dc9
...@@ -822,10 +822,10 @@ const VertexAttribute &Context::getVertexAttribState(unsigned int attribNum) con ...@@ -822,10 +822,10 @@ const VertexAttribute &Context::getVertexAttribState(unsigned int attribNum) con
return getCurrentVertexArray()->getVertexAttribute(attribNum); return getCurrentVertexArray()->getVertexAttribute(attribNum);
} }
void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized, void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
GLsizei stride, const void *pointer) bool normalized, bool pureInteger, GLsizei stride, const void *pointer)
{ {
getCurrentVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, stride, pointer); getCurrentVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
} }
const void *Context::getVertexAttribPointer(unsigned int attribNum) const const void *Context::getVertexAttribPointer(unsigned int attribNum) const
......
...@@ -194,7 +194,7 @@ struct Color ...@@ -194,7 +194,7 @@ struct Color
class VertexAttribute class VertexAttribute
{ {
public: public:
VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mStride(0), mDivisor(0), mPointer(nullptr), mArrayEnabled(false) VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mPureInteger(false), mStride(0), mDivisor(0), mPointer(nullptr), mArrayEnabled(false)
{ {
mCurrentValue[0].f = 0.0f; mCurrentValue[0].f = 0.0f;
mCurrentValue[1].f = 0.0f; mCurrentValue[1].f = 0.0f;
...@@ -301,6 +301,7 @@ public: ...@@ -301,6 +301,7 @@ public:
GLenum mType; GLenum mType;
GLint mSize; GLint mSize;
bool mNormalized; bool mNormalized;
bool mPureInteger;
GLsizei mStride; // 0 means natural stride GLsizei mStride; // 0 means natural stride
GLuint mDivisor; // From glVertexAttribDivisor GLuint mDivisor; // From glVertexAttribDivisor
...@@ -525,7 +526,7 @@ public: ...@@ -525,7 +526,7 @@ public:
void setVertexAttribDivisor(unsigned int attribNum, GLuint divisor); void setVertexAttribDivisor(unsigned int attribNum, GLuint divisor);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const; const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, GLsizei stride, const void *pointer); bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const void *getVertexAttribPointer(unsigned int attribNum) const; const void *getVertexAttribPointer(unsigned int attribNum) const;
const VertexAttributeArray &getVertexArrayAttributes(); const VertexAttributeArray &getVertexArrayAttributes();
......
...@@ -65,13 +65,14 @@ void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState ...@@ -65,13 +65,14 @@ void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState
} }
void VertexArray::setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type, void VertexArray::setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, GLsizei stride, const void *pointer) bool normalized, bool pureInteger, GLsizei stride, const void *pointer)
{ {
ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS); ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS);
mVertexAttributes[attributeIndex].mBoundBuffer = boundBuffer; mVertexAttributes[attributeIndex].mBoundBuffer = boundBuffer;
mVertexAttributes[attributeIndex].mSize = size; mVertexAttributes[attributeIndex].mSize = size;
mVertexAttributes[attributeIndex].mType = type; mVertexAttributes[attributeIndex].mType = type;
mVertexAttributes[attributeIndex].mNormalized = normalized; mVertexAttributes[attributeIndex].mNormalized = normalized;
mVertexAttributes[attributeIndex].mPureInteger = pureInteger;
mVertexAttributes[attributeIndex].mStride = stride; mVertexAttributes[attributeIndex].mStride = stride;
mVertexAttributes[attributeIndex].mPointer = pointer; mVertexAttributes[attributeIndex].mPointer = pointer;
} }
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
void setVertexAttribDivisor(GLuint index, GLuint divisor); void setVertexAttribDivisor(GLuint index, GLuint divisor);
void enableAttribute(unsigned int attributeIndex, bool enabledState); void enableAttribute(unsigned int attributeIndex, bool enabledState);
void setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type, void setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, GLsizei stride, const void *pointer); bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
Buffer *getElementArrayBuffer() const { return mElementArrayBuffer; } Buffer *getElementArrayBuffer() const { return mElementArrayBuffer; }
void setElementArrayBuffer(Buffer *buffer); void setElementArrayBuffer(Buffer *buffer);
......
...@@ -4084,22 +4084,7 @@ void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) ...@@ -4084,22 +4084,7 @@ void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
case GL_VERTEX_ATTRIB_ARRAY_INTEGER: case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if(clientVersion >= 3) if(clientVersion >= 3)
{ {
switch(attribState.mType) *params = (GLfloat)(attribState.mPureInteger ? GL_TRUE : GL_FALSE);
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT:
case GL_FIXED:
*params = (GLfloat)GL_TRUE;
break;
default:
*params = (GLfloat)GL_FALSE;
break;
}
break; break;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
...@@ -4158,22 +4143,7 @@ void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) ...@@ -4158,22 +4143,7 @@ void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
case GL_VERTEX_ATTRIB_ARRAY_INTEGER: case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if(clientVersion >= 3) if(clientVersion >= 3)
{ {
switch(attribState.mType) *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT:
case GL_FIXED:
*params = GL_TRUE;
break;
default:
*params = GL_FALSE;
break;
}
break; break;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
...@@ -6187,7 +6157,7 @@ void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normal ...@@ -6187,7 +6157,7 @@ void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normal
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr); context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), false, stride, ptr);
} }
} }
......
...@@ -2154,7 +2154,7 @@ GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLe ...@@ -2154,7 +2154,7 @@ GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLe
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, stride, pointer); context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, stride, pointer);
} }
} }
...@@ -2204,22 +2204,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLi ...@@ -2204,22 +2204,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLi
} }
break; break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER: case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
switch(attribState.mType) *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT:
case GL_FIXED:
*params = GL_TRUE;
break;
default:
*params = GL_FALSE;
break;
}
break; break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
*params = attribState.mDivisor; *params = attribState.mDivisor;
...@@ -2275,22 +2260,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GL ...@@ -2275,22 +2260,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GL
} }
break; break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER: case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
switch(attribState.mType) *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT:
case GL_FIXED:
*params = GL_TRUE;
break;
default:
*params = GL_FALSE;
break;
}
break; break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
*params = attribState.mDivisor; *params = attribState.mDivisor;
......
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