Added location to Attribute Program now uses Attribute location. Change-Id: I005d64509e4b1e2dd977db38b6b2c41d6ba7ddef Reviewed-on: https://swiftshader-review.googlesource.com/3722 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp index 428be87..782d2b0 100644 --- a/src/OpenGL/compiler/OutputASM.cpp +++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -91,11 +91,12 @@ registerIndex = 0; } - Attribute::Attribute(GLenum type, const std::string &name, int arraySize, int registerIndex) + Attribute::Attribute(GLenum type, const std::string &name, int arraySize, int location, int registerIndex) { this->type = type; this->name = name; this->arraySize = arraySize; + this->location = location; this->registerIndex = registerIndex; } @@ -2232,7 +2233,7 @@ ActiveAttributes &activeAttributes = shaderObject->activeAttributes; const char *name = symbol->getSymbol().c_str(); - activeAttributes.push_back(Attribute(glVariableType(type), name, 0, index)); + activeAttributes.push_back(Attribute(glVariableType(type), name, type.getArraySize(), type.getLayoutQualifier().location, index)); } }
diff --git a/src/OpenGL/compiler/OutputASM.h b/src/OpenGL/compiler/OutputASM.h index 5cbf4dd..43b0bd2 100644 --- a/src/OpenGL/compiler/OutputASM.h +++ b/src/OpenGL/compiler/OutputASM.h
@@ -47,11 +47,12 @@ struct Attribute { Attribute(); - Attribute(GLenum type, const std::string &name, int arraySize, int registerIndex); + Attribute(GLenum type, const std::string &name, int arraySize, int location, int registerIndex); GLenum type; std::string name; int arraySize; + int location; int registerIndex; };
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp index 0dc03f5..1cb028a 100644 --- a/src/OpenGL/libGLESv2/Program.cpp +++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -1259,7 +1259,7 @@ // Link attributes that have a binding location for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute) { - int location = getAttributeBinding(attribute->name); + int location = getAttributeBinding(*attribute); if(location != -1) // Set by glBindAttribLocation { @@ -1288,7 +1288,7 @@ // Link attributes that don't have a binding location for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute) { - int location = getAttributeBinding(attribute->name); + int location = getAttributeBinding(*attribute); if(location == -1) // Not set by glBindAttribLocation { @@ -1319,11 +1319,16 @@ return true; } - int Program::getAttributeBinding(const std::string &name) + int Program::getAttributeBinding(const glsl::Attribute &attribute) { + if(attribute.location != -1) + { + return attribute.location; + } + for(int location = 0; location < MAX_VERTEX_ATTRIBS; location++) { - if(attributeBinding[location].find(name) != attributeBinding[location].end()) + if(attributeBinding[location].find(attribute.name.c_str()) != attributeBinding[location].end()) { return location; }
diff --git a/src/OpenGL/libGLESv2/Program.h b/src/OpenGL/libGLESv2/Program.h index 0037e05..48d691d 100644 --- a/src/OpenGL/libGLESv2/Program.h +++ b/src/OpenGL/libGLESv2/Program.h
@@ -222,7 +222,7 @@ bool gatherTransformFeedbackLinkedVaryings(); bool linkAttributes(); - int getAttributeBinding(const std::string &name); + int getAttributeBinding(const glsl::Attribute &attribute); bool linkUniforms(const Shader *shader); bool defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &_name, unsigned int arraySize, int registerIndex);