Commit 6125b66d by Alexis Hetu Committed by Alexis Hétu

Fixed using default attributes

2 issues affected default attributes: 1) The stream type did not match the attributes' internal representation 2) The normalized flag was left uninitialized, meaning it was using whatever had been set in the previous draw call. Change-Id: I25b425944e6f59206bf3ef4db35b56d26ef83168 Reviewed-on: https://swiftshader-review.googlesource.com/8292Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent c018e081
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
mCurrentValue[1].f = 0.0f; mCurrentValue[1].f = 0.0f;
mCurrentValue[2].f = 0.0f; mCurrentValue[2].f = 0.0f;
mCurrentValue[3].f = 1.0f; mCurrentValue[3].f = 1.0f;
mCurrentValueType = ValueUnion::FloatType; mCurrentValueType = GL_FLOAT;
} }
int typeSize() const int typeSize() const
...@@ -217,6 +217,11 @@ public: ...@@ -217,6 +217,11 @@ public:
} }
} }
GLenum currentValueType() const
{
return mCurrentValueType;
}
GLsizei stride() const GLsizei stride() const
{ {
return mStride ? mStride : typeSize(); return mStride ? mStride : typeSize();
...@@ -231,9 +236,9 @@ public: ...@@ -231,9 +236,9 @@ public:
{ {
switch(mCurrentValueType) switch(mCurrentValueType)
{ {
case ValueUnion::FloatType: return mCurrentValue[i].f; case GL_FLOAT: return mCurrentValue[i].f;
case ValueUnion::IntType: return static_cast<float>(mCurrentValue[i].i); case GL_INT: return static_cast<float>(mCurrentValue[i].i);
case ValueUnion::UIntType: return static_cast<float>(mCurrentValue[i].ui); case GL_UNSIGNED_INT: return static_cast<float>(mCurrentValue[i].ui);
default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].f; default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].f;
} }
} }
...@@ -242,9 +247,9 @@ public: ...@@ -242,9 +247,9 @@ public:
{ {
switch(mCurrentValueType) switch(mCurrentValueType)
{ {
case ValueUnion::FloatType: return static_cast<GLint>(mCurrentValue[i].f); case GL_FLOAT: return static_cast<GLint>(mCurrentValue[i].f);
case ValueUnion::IntType: return mCurrentValue[i].i; case GL_INT: return mCurrentValue[i].i;
case ValueUnion::UIntType: return static_cast<GLint>(mCurrentValue[i].ui); case GL_UNSIGNED_INT: return static_cast<GLint>(mCurrentValue[i].ui);
default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].i; default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].i;
} }
} }
...@@ -253,9 +258,9 @@ public: ...@@ -253,9 +258,9 @@ public:
{ {
switch(mCurrentValueType) switch(mCurrentValueType)
{ {
case ValueUnion::FloatType: return static_cast<GLuint>(mCurrentValue[i].f); case GL_FLOAT: return static_cast<GLuint>(mCurrentValue[i].f);
case ValueUnion::IntType: return static_cast<GLuint>(mCurrentValue[i].i); case GL_INT: return static_cast<GLuint>(mCurrentValue[i].i);
case ValueUnion::UIntType: return mCurrentValue[i].ui; case GL_UNSIGNED_INT: return mCurrentValue[i].ui;
default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].ui; default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].ui;
} }
} }
...@@ -266,7 +271,7 @@ public: ...@@ -266,7 +271,7 @@ public:
mCurrentValue[1].f = values[1]; mCurrentValue[1].f = values[1];
mCurrentValue[2].f = values[2]; mCurrentValue[2].f = values[2];
mCurrentValue[3].f = values[3]; mCurrentValue[3].f = values[3];
mCurrentValueType = ValueUnion::FloatType; mCurrentValueType = GL_FLOAT;
} }
inline void setCurrentValue(const GLint *values) inline void setCurrentValue(const GLint *values)
...@@ -275,7 +280,7 @@ public: ...@@ -275,7 +280,7 @@ public:
mCurrentValue[1].i = values[1]; mCurrentValue[1].i = values[1];
mCurrentValue[2].i = values[2]; mCurrentValue[2].i = values[2];
mCurrentValue[3].i = values[3]; mCurrentValue[3].i = values[3];
mCurrentValueType = ValueUnion::IntType; mCurrentValueType = GL_INT;
} }
inline void setCurrentValue(const GLuint *values) inline void setCurrentValue(const GLuint *values)
...@@ -284,7 +289,7 @@ public: ...@@ -284,7 +289,7 @@ public:
mCurrentValue[1].ui = values[1]; mCurrentValue[1].ui = values[1];
mCurrentValue[2].ui = values[2]; mCurrentValue[2].ui = values[2];
mCurrentValue[3].ui = values[3]; mCurrentValue[3].ui = values[3];
mCurrentValueType = ValueUnion::UIntType; mCurrentValueType = GL_UNSIGNED_INT;
} }
// From glVertexAttribPointer // From glVertexAttribPointer
...@@ -307,15 +312,13 @@ public: ...@@ -307,15 +312,13 @@ public:
private: private:
union ValueUnion union ValueUnion
{ {
enum Type { FloatType, IntType, UIntType };
float f; float f;
GLint i; GLint i;
GLuint ui; GLuint ui;
}; };
ValueUnion mCurrentValue[4]; // From glVertexAttrib ValueUnion mCurrentValue[4]; // From glVertexAttrib
ValueUnion::Type mCurrentValueType; GLenum mCurrentValueType;
}; };
typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS];
......
...@@ -212,10 +212,22 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat ...@@ -212,10 +212,22 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
translated[i].vertexBuffer = mCurrentValueBuffer[i]->getResource(); translated[i].vertexBuffer = mCurrentValueBuffer[i]->getResource();
translated[i].type = sw::STREAMTYPE_FLOAT; switch(attrib.currentValueType())
{
case GL_INT:
translated[i].type = sw::STREAMTYPE_INT;
break;
case GL_UNSIGNED_INT:
translated[i].type = sw::STREAMTYPE_UINT;
break;
default:
translated[i].type = sw::STREAMTYPE_FLOAT;
break;
}
translated[i].count = 4; translated[i].count = 4;
translated[i].stride = 0; translated[i].stride = 0;
translated[i].offset = 0; translated[i].offset = 0;
translated[i].normalized = false;
} }
} }
} }
......
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