ES31: Clean up Program::link
This patch intends to solve some structure and coding style issues
in Program::link to make it easier to support linking program with
geometry shader.
1. Move all the shader specific validations to linkValidateShaders.
Geometry shader related link validations can also be added here.
2. Rename functions with "VertexAndFragment" to "Graphics" because
these functions will also be responsible for the validations on
geometry shader.
3. Refer uniforms by pointer when validating uniforms.
4. Re-declare functions to 'static' if we can and capitialize the
first letter of all static functions in Program.h.
BUG=angleproject:1941
Change-Id: I46608e86bddc12d95cbbbf9a85803d07ccf843d8
Reviewed-on: https://chromium-review.googlesource.com/836149
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/ProgramLinkedResources.cpp b/src/libANGLE/ProgramLinkedResources.cpp
index 74dfafa..e1c9ff7 100644
--- a/src/libANGLE/ProgramLinkedResources.cpp
+++ b/src/libANGLE/ProgramLinkedResources.cpp
@@ -70,7 +70,7 @@
if (mState.getAttachedVertexShader() && mState.getAttachedFragmentShader())
{
ASSERT(mState.getAttachedComputeShader() == nullptr);
- if (!validateVertexAndFragmentUniforms(context, infoLog))
+ if (!validateGraphicsUniforms(context, infoLog))
{
return false;
}
@@ -96,11 +96,10 @@
return true;
}
-bool UniformLinker::validateVertexAndFragmentUniforms(const Context *context,
- InfoLog &infoLog) const
+bool UniformLinker::validateGraphicsUniforms(const Context *context, InfoLog &infoLog) const
{
// Check that uniforms defined in the vertex and fragment shaders are identical
- std::map<std::string, sh::Uniform> linkedUniforms;
+ std::map<std::string, const sh::Uniform *> linkedUniforms;
const std::vector<sh::Uniform> &vertexUniforms =
mState.getAttachedVertexShader()->getUniforms(context);
const std::vector<sh::Uniform> &fragmentUniforms =
@@ -108,7 +107,7 @@
for (const sh::Uniform &vertexUniform : vertexUniforms)
{
- linkedUniforms[vertexUniform.name] = vertexUniform;
+ linkedUniforms[vertexUniform.name] = &vertexUniform;
}
for (const sh::Uniform &fragmentUniform : fragmentUniforms)
@@ -116,9 +115,9 @@
auto entry = linkedUniforms.find(fragmentUniform.name);
if (entry != linkedUniforms.end())
{
- const sh::Uniform &linkedUniform = entry->second;
+ const sh::Uniform &linkedUniform = *(entry->second);
const std::string &uniformName = "uniform '" + linkedUniform.name + "'";
- if (!linkValidateUniforms(infoLog, uniformName, linkedUniform, fragmentUniform))
+ if (!LinkValidateUniforms(infoLog, uniformName, linkedUniform, fragmentUniform))
{
return false;
}
@@ -128,7 +127,7 @@
}
// GLSL ES Spec 3.00.3, section 4.3.5.
-bool UniformLinker::linkValidateUniforms(InfoLog &infoLog,
+bool UniformLinker::LinkValidateUniforms(InfoLog &infoLog,
const std::string &uniformName,
const sh::Uniform &vertexUniform,
const sh::Uniform &fragmentUniform)
@@ -139,7 +138,7 @@
const bool validatePrecision = false;
#endif
- if (!Program::linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform,
+ if (!Program::LinkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform,
validatePrecision))
{
return false;