Commit 23f54d74 by Alexis Hetu Committed by Alexis Hétu

Fix attribute location binding

- Attribute location aliasing was allowed prior to shader version 300, so location aliasing is now possible. - Attribute binding refers to the linked location of attributes, so locations set using glBindAttribLocation() will only be returned by glGetAttribLocation() after the program is linked. Before that, it will return the location allocated during the previous glLinkProgram() call. In order to do that, an extra map was added. "linkedAttributeLocation" represents the attributes' location, as a result of linking a program. "attributeBinding" represents the attributes' future location, when the next program linking occurs. On top of that, the shader's version was not being passed down from TranslatorASM to es2::Shader, or from es2::Shader to Program, so this information also needed to be properly transferred. Fixes all failures in: dEQP-GLES3.functional.attribute_location* Change-Id: I4ba7dc7c2f6d444e805cadeb5445f5ff371c3d95 Reviewed-on: https://swiftshader-review.googlesource.com/14568Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent c61f46b8
......@@ -185,12 +185,14 @@ namespace glsl
virtual sw::Shader *getShader() const = 0;
virtual sw::PixelShader *getPixelShader() const;
virtual sw::VertexShader *getVertexShader() const;
int getShaderVersion() const { return shaderVersion; }
protected:
VaryingList varyings;
ActiveUniforms activeUniforms;
ActiveAttributes activeAttributes;
ActiveUniformBlocks activeUniformBlocks;
int shaderVersion;
};
struct Function
......
......@@ -26,6 +26,7 @@
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
namespace es2
{
......@@ -279,8 +280,9 @@ namespace es2
sw::PixelShader *pixelBinary;
sw::VertexShader *vertexBinary;
std::set<std::string> attributeBinding[MAX_VERTEX_ATTRIBS];
glsl::Attribute linkedAttribute[MAX_VERTEX_ATTRIBS];
std::unordered_map<std::string, GLuint> attributeBinding;
std::unordered_map<std::string, GLuint> linkedAttributeLocation;
std::vector<glsl::Attribute> linkedAttribute;
int attributeStream[MAX_VERTEX_ATTRIBS];
GLuint uniformBlockBindings[MAX_UNIFORM_BUFFER_BINDINGS];
......
......@@ -230,7 +230,7 @@ void Shader::compile()
serial++;
}
int shaderVersion = compiler->getShaderVersion();
shaderVersion = compiler->getShaderVersion();
int clientVersion = es2::getContext()->getClientVersion();
if(shaderVersion >= 300 && clientVersion < 3)
......
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