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/14828
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 15129d7..b2bc507 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -822,10 +822,10 @@
return getCurrentVertexArray()->getVertexAttribute(attribNum);
}
-void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
- GLsizei stride, const void *pointer)
+void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
+ 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
diff --git a/src/OpenGL/libGLESv2/Context.h b/src/OpenGL/libGLESv2/Context.h
index a7d2773..e7484ff 100644
--- a/src/OpenGL/libGLESv2/Context.h
+++ b/src/OpenGL/libGLESv2/Context.h
@@ -194,7 +194,7 @@
class VertexAttribute
{
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[1].f = 0.0f;
@@ -301,6 +301,7 @@
GLenum mType;
GLint mSize;
bool mNormalized;
+ bool mPureInteger;
GLsizei mStride; // 0 means natural stride
GLuint mDivisor; // From glVertexAttribDivisor
@@ -525,7 +526,7 @@
void setVertexAttribDivisor(unsigned int attribNum, GLuint divisor);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
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 VertexAttributeArray &getVertexArrayAttributes();
diff --git a/src/OpenGL/libGLESv2/VertexArray.cpp b/src/OpenGL/libGLESv2/VertexArray.cpp
index d52e7ca..64ae221 100644
--- a/src/OpenGL/libGLESv2/VertexArray.cpp
+++ b/src/OpenGL/libGLESv2/VertexArray.cpp
@@ -65,13 +65,14 @@
}
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);
mVertexAttributes[attributeIndex].mBoundBuffer = boundBuffer;
mVertexAttributes[attributeIndex].mSize = size;
mVertexAttributes[attributeIndex].mType = type;
mVertexAttributes[attributeIndex].mNormalized = normalized;
+ mVertexAttributes[attributeIndex].mPureInteger = pureInteger;
mVertexAttributes[attributeIndex].mStride = stride;
mVertexAttributes[attributeIndex].mPointer = pointer;
}
diff --git a/src/OpenGL/libGLESv2/VertexArray.h b/src/OpenGL/libGLESv2/VertexArray.h
index 363cf53..bb0f480 100644
--- a/src/OpenGL/libGLESv2/VertexArray.h
+++ b/src/OpenGL/libGLESv2/VertexArray.h
@@ -38,7 +38,7 @@
void setVertexAttribDivisor(GLuint index, GLuint divisor);
void enableAttribute(unsigned int attributeIndex, bool enabledState);
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; }
void setElementArrayBuffer(Buffer *buffer);
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index f2f6410..ddc23e8 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -4084,22 +4084,7 @@
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if(clientVersion >= 3)
{
- switch(attribState.mType)
- {
- 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;
- }
+ *params = (GLfloat)(attribState.mPureInteger ? GL_TRUE : GL_FALSE);
break;
}
else return error(GL_INVALID_ENUM);
@@ -4158,22 +4143,7 @@
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if(clientVersion >= 3)
{
- switch(attribState.mType)
- {
- 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;
- }
+ *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
break;
}
else return error(GL_INVALID_ENUM);
@@ -6187,7 +6157,7 @@
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);
}
}
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 0e006c3..6c7f7a8 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -2154,7 +2154,7 @@
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 @@
}
break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
- switch(attribState.mType)
- {
- 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;
- }
+ *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
*params = attribState.mDivisor;
@@ -2275,22 +2260,7 @@
}
break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
- switch(attribState.mType)
- {
- 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;
- }
+ *params = (attribState.mPureInteger ? GL_TRUE : GL_FALSE);
break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
*params = attribState.mDivisor;