1. It is possible that GL_ACTIVE_ATTRIBUTES value is smaller than
location of attributes. If it happend, crashed due to mVertexInputAttributes.insert call.
To fix this crash issue, make mVertexInputAttributes size relative with location value,
not relative with GL_ACTIVE_ATTRIBUTES.
Also, It will guarantee that attribute's location can be index of it's real attrubutes.
(Since vector.insert operation shift the index, it was depend on the location input order.
and also slow)
2. Ensure the enable of vertex attributes.
Since vertexInputState.attributes generated by Geometry in pipeline-cache system,
Change the attribute's list of geometry at the same shader was not worked.
TODO : Make VAO caching system works well. Currently, VAO doesn't useful.
We should found a way to EnableVertexAttribArray only with shader's information,
not depend on Geometry information.
or, we might need to calculate vertex attribute location list's hash, and use it as key.
Change-Id: I3b309833a0865ad175fabf376913c3ad91e64d4a
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = 100;
break;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = 100;
break;
+ case GL_ACTIVE_ATTRIBUTES:
+ *params = static_cast<GLint>(mAttribLocs.size());
+ break;
mProgramVAOCurrentState = iter->second;
gl.BindVertexArray(iter->second);
}
mProgramVAOCurrentState = iter->second;
gl.BindVertexArray(iter->second);
}
+
+ // We should re-check enable attribute usage because geometry might be changed.
+ // @todo : We can remove this loop if we enable vertex attrib by shader's information.
+ for(const auto& attr : vertexInputState.attributes)
+ {
+ gl.EnableVertexAttribArray(attr.location);
+ }
gl.GenVertexArrays(1, &vao);
gl.BindVertexArray(vao);
mProgramVAOMap[program] = vao;
gl.GenVertexArrays(1, &vao);
gl.BindVertexArray(vao);
mProgramVAOMap[program] = vao;
+
+ // @todo : Enable vertex attrib only by shader's information, not with Geometry.
+ // Currently, vertexInputState.attributes depend on Geometry's VertexBuffer.
for(const auto& attr : vertexInputState.attributes)
{
gl.EnableVertexAttribArray(attr.location);
for(const auto& attr : vertexInputState.attributes)
{
gl.EnableVertexAttribArray(attr.location);
mVertexInputAttributes.clear();
mVertexInputAttributes.resize(nAttribs);
mVertexInputAttributes.clear();
mVertexInputAttributes.resize(nAttribs);
+ int maximumLocation = nAttribs - 1;
+
name = new GLchar[maxLength];
for(int i = 0; i < nAttribs; i++)
{
name = new GLchar[maxLength];
for(int i = 0; i < nAttribs; i++)
{
+ if(maximumLocation < location)
+ {
+ maximumLocation = location;
+ // Increate continer size s.t. we can use maximumLocation as index.
+ mVertexInputAttributes.resize(maximumLocation + 1u);
+ }
+
AttributeInfo attributeInfo;
attributeInfo.location = location;
attributeInfo.name = name;
attributeInfo.format = GetVertexAttributeTypeFormat(type);
AttributeInfo attributeInfo;
attributeInfo.location = location;
attributeInfo.name = name;
attributeInfo.format = GetVertexAttributeTypeFormat(type);
- mVertexInputAttributes.insert(mVertexInputAttributes.begin() + location, attributeInfo);
+ mVertexInputAttributes[location] = std::move(attributeInfo);