Commit 73618601 by Jiawei Shao Committed by Commit Bot

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: 's avatarJamie Madill <jmadill@chromium.org>
parent 63ba357c
......@@ -579,7 +579,7 @@ class Program final : angle::NonCopyable, public LabeledObject
GLsizei getTransformFeedbackVaryingMaxLength() const;
GLenum getTransformFeedbackBufferMode() const;
static bool linkValidateInterfaceBlockFields(InfoLog &infoLog,
static bool LinkValidateInterfaceBlockFields(InfoLog &infoLog,
const std::string &uniformName,
const sh::InterfaceBlockField &vertexUniform,
const sh::InterfaceBlockField &fragmentUniform,
......@@ -614,7 +614,7 @@ class Program final : angle::NonCopyable, public LabeledObject
const ProgramState &getState() const { return mState; }
static bool linkValidateVariablesBase(InfoLog &infoLog,
static bool LinkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
......@@ -646,12 +646,13 @@ class Program final : angle::NonCopyable, public LabeledObject
void unlink();
bool linkValidateShaders(const Context *context, InfoLog &infoLog);
bool linkAttributes(const Context *context, InfoLog &infoLog);
bool validateVertexAndFragmentInterfaceBlocks(
static bool ValidateGraphicsInterfaceBlocks(
const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks,
const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks,
InfoLog &infoLog,
bool webglCompatibility) const;
bool webglCompatibility);
bool linkInterfaceBlocks(const Context *context, InfoLog &infoLog);
bool linkVaryings(const Context *context, InfoLog &infoLog) const;
......@@ -663,12 +664,12 @@ class Program final : angle::NonCopyable, public LabeledObject
void updateLinkedShaderStages();
bool areMatchingInterfaceBlocks(InfoLog &infoLog,
const sh::InterfaceBlock &vertexInterfaceBlock,
const sh::InterfaceBlock &fragmentInterfaceBlock,
bool webglCompatibility) const;
static bool AreMatchingInterfaceBlocks(InfoLog &infoLog,
const sh::InterfaceBlock &vertexInterfaceBlock,
const sh::InterfaceBlock &fragmentInterfaceBlock,
bool webglCompatibility);
static bool linkValidateVaryings(InfoLog &infoLog,
static bool LinkValidateVaryings(InfoLog &infoLog,
const std::string &varyingName,
const sh::Varying &vertexVarying,
const sh::Varying &fragmentVarying,
......
......@@ -70,7 +70,7 @@ bool UniformLinker::link(const Context *context,
if (mState.getAttachedVertexShader() && mState.getAttachedFragmentShader())
{
ASSERT(mState.getAttachedComputeShader() == nullptr);
if (!validateVertexAndFragmentUniforms(context, infoLog))
if (!validateGraphicsUniforms(context, infoLog))
{
return false;
}
......@@ -96,11 +96,10 @@ bool UniformLinker::link(const Context *context,
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 @@ bool UniformLinker::validateVertexAndFragmentUniforms(const Context *context,
for (const sh::Uniform &vertexUniform : vertexUniforms)
{
linkedUniforms[vertexUniform.name] = vertexUniform;
linkedUniforms[vertexUniform.name] = &vertexUniform;
}
for (const sh::Uniform &fragmentUniform : fragmentUniforms)
......@@ -116,9 +115,9 @@ bool UniformLinker::validateVertexAndFragmentUniforms(const Context *context,
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 @@ bool UniformLinker::validateVertexAndFragmentUniforms(const Context *context,
}
// 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 @@ bool UniformLinker::linkValidateUniforms(InfoLog &infoLog,
const bool validatePrecision = false;
#endif
if (!Program::linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform,
if (!Program::LinkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform,
validatePrecision))
{
return false;
......
......@@ -78,9 +78,9 @@ class UniformLinker final : angle::NonCopyable
unsigned int atomicCounterCount;
};
bool validateVertexAndFragmentUniforms(const Context *context, InfoLog &infoLog) const;
bool validateGraphicsUniforms(const Context *context, InfoLog &infoLog) const;
static bool linkValidateUniforms(InfoLog &infoLog,
static bool LinkValidateUniforms(InfoLog &infoLog,
const std::string &uniformName,
const sh::Uniform &vertexUniform,
const sh::Uniform &fragmentUniform);
......
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