Commit 910b6b6e by Alexis Hetu Committed by Alexis Hétu

Added location to Attribute

Program now uses Attribute location. Change-Id: I005d64509e4b1e2dd977db38b6b2c41d6ba7ddef Reviewed-on: https://swiftshader-review.googlesource.com/3722Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent fef22a6d
...@@ -91,11 +91,12 @@ namespace glsl ...@@ -91,11 +91,12 @@ namespace glsl
registerIndex = 0; 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->type = type;
this->name = name; this->name = name;
this->arraySize = arraySize; this->arraySize = arraySize;
this->location = location;
this->registerIndex = registerIndex; this->registerIndex = registerIndex;
} }
...@@ -2232,7 +2233,7 @@ namespace glsl ...@@ -2232,7 +2233,7 @@ namespace glsl
ActiveAttributes &activeAttributes = shaderObject->activeAttributes; ActiveAttributes &activeAttributes = shaderObject->activeAttributes;
const char *name = symbol->getSymbol().c_str(); 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));
} }
} }
......
...@@ -47,11 +47,12 @@ namespace glsl ...@@ -47,11 +47,12 @@ namespace glsl
struct Attribute struct Attribute
{ {
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; GLenum type;
std::string name; std::string name;
int arraySize; int arraySize;
int location;
int registerIndex; int registerIndex;
}; };
......
...@@ -1259,7 +1259,7 @@ namespace es2 ...@@ -1259,7 +1259,7 @@ namespace es2
// Link attributes that have a binding location // Link attributes that have a binding location
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute) 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 if(location != -1) // Set by glBindAttribLocation
{ {
...@@ -1288,7 +1288,7 @@ namespace es2 ...@@ -1288,7 +1288,7 @@ namespace es2
// Link attributes that don't have a binding location // Link attributes that don't have a binding location
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute) 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 if(location == -1) // Not set by glBindAttribLocation
{ {
...@@ -1319,11 +1319,16 @@ namespace es2 ...@@ -1319,11 +1319,16 @@ namespace es2
return true; 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++) 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; return location;
} }
......
...@@ -222,7 +222,7 @@ namespace es2 ...@@ -222,7 +222,7 @@ namespace es2
bool gatherTransformFeedbackLinkedVaryings(); bool gatherTransformFeedbackLinkedVaryings();
bool linkAttributes(); bool linkAttributes();
int getAttributeBinding(const std::string &name); int getAttributeBinding(const glsl::Attribute &attribute);
bool linkUniforms(const Shader *shader); bool linkUniforms(const Shader *shader);
bool defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &_name, unsigned int arraySize, int registerIndex); bool defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &_name, unsigned int arraySize, int registerIndex);
......
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