Commit 1528e56b by Geoff Lang

Bind native GL attributes to match the locations in gl::Program.

Simplifies a lot of logic when we don't have to maintain mappings between the driver and gl-layer locations. BUG=angleproject:882 BUG=angleproject:1123 Change-Id: Ia94257a322f768fdfa3167000a46a0715820ef4d Reviewed-on: https://chromium-review.googlesource.com/295231Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent a5ef8d89
...@@ -258,7 +258,6 @@ void AttributeBindings::bindAttributeLocation(GLuint index, const char *name) ...@@ -258,7 +258,6 @@ void AttributeBindings::bindAttributeLocation(GLuint index, const char *name)
void Program::bindAttributeLocation(GLuint index, const char *name) void Program::bindAttributeLocation(GLuint index, const char *name)
{ {
mAttributeBindings.bindAttributeLocation(index, name); mAttributeBindings.bindAttributeLocation(index, name);
mProgram->bindAttributeLocation(index, name);
} }
// Links the HLSL code of the vertex and pixel shader by matching up their varyings, // Links the HLSL code of the vertex and pixel shader by matching up their varyings,
......
...@@ -50,8 +50,6 @@ class ProgramImpl : angle::NonCopyable ...@@ -50,8 +50,6 @@ class ProgramImpl : angle::NonCopyable
virtual GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) = 0; virtual GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) = 0;
virtual void bindAttributeLocation(GLuint index, const std::string &name) = 0;
virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0; virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0;
virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0; virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0;
virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0; virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0;
......
...@@ -1175,10 +1175,6 @@ GLboolean ProgramD3D::validate(const gl::Caps &caps, gl::InfoLog *infoLog) ...@@ -1175,10 +1175,6 @@ GLboolean ProgramD3D::validate(const gl::Caps &caps, gl::InfoLog *infoLog)
return validateSamplers(infoLog, caps); return validateSamplers(infoLog, caps);
} }
void ProgramD3D::bindAttributeLocation(GLuint index, const std::string &name)
{
}
void ProgramD3D::initializeUniformStorage() void ProgramD3D::initializeUniformStorage()
{ {
// Compute total default block size // Compute total default block size
......
...@@ -76,8 +76,6 @@ class ProgramD3D : public ProgramImpl ...@@ -76,8 +76,6 @@ class ProgramD3D : public ProgramImpl
GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override;
void bindAttributeLocation(GLuint index, const std::string &name) override;
void initializeUniformStorage(); void initializeUniformStorage();
gl::Error applyUniforms(); gl::Error applyUniforms();
gl::Error applyUniformBuffers(const gl::Data &data); gl::Error applyUniformBuffers(const gl::Data &data);
......
...@@ -74,6 +74,23 @@ LinkResult ProgramGL::link(const gl::Data &data, ...@@ -74,6 +74,23 @@ LinkResult ProgramGL::link(const gl::Data &data,
mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID()); mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID());
mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID()); mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID());
// Bind attribute locations to match the GL layer.
for (const sh::Attribute &attribute : mData.getAttributes())
{
if (!attribute.staticUse)
{
continue;
}
mFunctions->bindAttribLocation(mProgramID, attribute.location, attribute.name.c_str());
int registerCount = gl::VariableRegisterCount(attribute.type);
for (int offset = 0; offset < registerCount; ++offset)
{
mActiveAttributesMask.set(attribute.location + offset);
}
}
// Link and verify // Link and verify
mFunctions->linkProgram(mProgramID); mFunctions->linkProgram(mProgramID);
...@@ -169,37 +186,6 @@ LinkResult ProgramGL::link(const gl::Data &data, ...@@ -169,37 +186,6 @@ LinkResult ProgramGL::link(const gl::Data &data,
} }
} }
for (const sh::Attribute &attribute : mData.getAttributes())
{
if (!attribute.staticUse)
continue;
GLint realLocation = mFunctions->getAttribLocation(mProgramID, attribute.name.c_str());
// Some drivers optimize attributes more aggressively.
if (realLocation == -1)
{
continue;
}
// TODO(jmadill): Fix this
ASSERT(attribute.location == realLocation);
int registerCount = gl::VariableRegisterCount(attribute.type);
if (static_cast<GLint>(mAttributeRealLocations.size()) <
attribute.location + registerCount + 1)
{
mAttributeRealLocations.resize(attribute.location + registerCount + 1, -1);
}
for (int offset = 0; offset < registerCount; ++offset)
{
mActiveAttributesMask.set(attribute.location + offset);
mAttributeRealLocations[attribute.location + offset] = realLocation + offset;
}
}
return LinkResult(true, gl::Error(GL_NO_ERROR)); return LinkResult(true, gl::Error(GL_NO_ERROR));
} }
...@@ -209,11 +195,6 @@ GLboolean ProgramGL::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog ...@@ -209,11 +195,6 @@ GLboolean ProgramGL::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog
return true; return true;
} }
void ProgramGL::bindAttributeLocation(GLuint index, const std::string &name)
{
mFunctions->bindAttribLocation(mProgramID, index, name.c_str());
}
void ProgramGL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) void ProgramGL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
{ {
mStateManager->useProgram(mProgramID); mStateManager->useProgram(mProgramID);
...@@ -378,7 +359,6 @@ void ProgramGL::reset() ...@@ -378,7 +359,6 @@ void ProgramGL::reset()
mSamplerUniformMap.clear(); mSamplerUniformMap.clear();
mSamplerBindings.clear(); mSamplerBindings.clear();
mActiveAttributesMask.reset(); mActiveAttributesMask.reset();
mAttributeRealLocations.clear();
} }
GLuint ProgramGL::getProgramID() const GLuint ProgramGL::getProgramID() const
......
...@@ -45,8 +45,6 @@ class ProgramGL : public ProgramImpl ...@@ -45,8 +45,6 @@ class ProgramGL : public ProgramImpl
GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override;
void bindAttributeLocation(GLuint index, const std::string &name) override;
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override; void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override; void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override; void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override;
...@@ -101,9 +99,6 @@ class ProgramGL : public ProgramImpl ...@@ -101,9 +99,6 @@ class ProgramGL : public ProgramImpl
// An array of the samplers that are used by the program // An array of the samplers that are used by the program
std::vector<SamplerBindingGL> mSamplerBindings; std::vector<SamplerBindingGL> mSamplerBindings;
// Map from GL-layer attribute location to native location.
std::vector<GLint> mAttributeRealLocations;
// Array of attribute locations used by this program // Array of attribute locations used by this program
gl::AttributesMask mActiveAttributesMask; gl::AttributesMask mActiveAttributesMask;
......
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