Commit b78707c8 by Olli Etuaho Committed by Commit Bot

Move default-block uniform linking to a separate file

The code is easier to understand when it's encapsulated better. This change is pure refactoring with no functional changes. BUG=angleproject:1442 TEST=angle_end2end_tests Change-Id: I6128fd72c65ca7a87af596cda4866c74c2a66c48 Reviewed-on: https://chromium-review.googlesource.com/452502 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent e14951e6
...@@ -381,7 +381,6 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -381,7 +381,6 @@ class Program final : angle::NonCopyable, public LabeledObject
GLsizei getTransformFeedbackVaryingMaxLength() const; GLsizei getTransformFeedbackVaryingMaxLength() const;
GLenum getTransformFeedbackBufferMode() const; GLenum getTransformFeedbackBufferMode() const;
static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform); static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
void addRef(); void addRef();
...@@ -406,7 +405,12 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -406,7 +405,12 @@ class Program final : angle::NonCopyable, public LabeledObject
} }
const ProgramState &getState() const { return mState; } const ProgramState &getState() const { return mState; }
private: static bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool validatePrecision);
class Bindings final : angle::NonCopyable class Bindings final : angle::NonCopyable
{ {
public: public:
...@@ -421,6 +425,7 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -421,6 +425,7 @@ class Program final : angle::NonCopyable, public LabeledObject
std::unordered_map<std::string, GLuint> mBindings; std::unordered_map<std::string, GLuint> mBindings;
}; };
private:
struct VaryingRef struct VaryingRef
{ {
const sh::Varying *get() const { return vertex ? vertex : fragment; } const sh::Varying *get() const { return vertex ? vertex : fragment; }
...@@ -447,27 +452,12 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -447,27 +452,12 @@ class Program final : angle::NonCopyable, public LabeledObject
bool linkVaryings(InfoLog &infoLog) const; bool linkVaryings(InfoLog &infoLog) const;
bool linkUniforms(InfoLog &infoLog, const Caps &caps, const Bindings &uniformLocationBindings); bool linkUniforms(InfoLog &infoLog, const Caps &caps, const Bindings &uniformLocationBindings);
bool validateVertexAndFragmentUniforms(InfoLog &infoLog) const;
bool indexUniforms(InfoLog &infoLog, const Bindings &uniformLocationBindings);
bool gatherUniformLocationsAndCheckConflicts(InfoLog &infoLog,
const Bindings &uniformLocationBindings,
std::set<GLuint> *reservedLocations,
std::set<GLuint> *ignoredLocations,
int *maxUniformLocation);
void pruneUnusedUniforms();
void updateSamplerBindings(); void updateSamplerBindings();
bool areMatchingInterfaceBlocks(InfoLog &infoLog, bool areMatchingInterfaceBlocks(InfoLog &infoLog,
const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &vertexInterfaceBlock,
const sh::InterfaceBlock &fragmentInterfaceBlock) const; const sh::InterfaceBlock &fragmentInterfaceBlock) const;
static bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool validatePrecision);
static bool linkValidateVaryings(InfoLog &infoLog, static bool linkValidateVaryings(InfoLog &infoLog,
const std::string &varyingName, const std::string &varyingName,
const sh::Varying &vertexVarying, const sh::Varying &vertexVarying,
...@@ -484,43 +474,6 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -484,43 +474,6 @@ class Program final : angle::NonCopyable, public LabeledObject
std::vector<PackedVarying> getPackedVaryings(const MergedVaryings &mergedVaryings) const; std::vector<PackedVarying> getPackedVaryings(const MergedVaryings &mergedVaryings) const;
void linkOutputVariables(); void linkOutputVariables();
bool flattenUniformsAndCheckCapsForShader(const Shader &shader,
GLuint maxUniformComponents,
GLuint maxTextureImageUnits,
const std::string &componentsErrorMessage,
const std::string &samplerErrorMessage,
std::vector<LinkedUniform> &samplerUniforms,
InfoLog &infoLog);
bool flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog);
struct VectorAndSamplerCount
{
VectorAndSamplerCount() : vectorCount(0), samplerCount(0) {}
VectorAndSamplerCount(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator=(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator+=(const VectorAndSamplerCount &other)
{
vectorCount += other.vectorCount;
samplerCount += other.samplerCount;
return *this;
}
unsigned int vectorCount;
unsigned int samplerCount;
};
VectorAndSamplerCount flattenUniform(const sh::Uniform &uniform,
std::vector<LinkedUniform> *samplerUniforms);
// staticUse is given as a separate parameter because it is tracked here at struct granularity.
VectorAndSamplerCount flattenUniformImpl(const sh::ShaderVariable &uniform,
const std::string &fullName,
std::vector<LinkedUniform> *samplerUniforms,
bool markStaticUse,
int binding,
int *location);
void gatherInterfaceBlockInfo(); void gatherInterfaceBlockInfo();
template <typename VarT> template <typename VarT>
void defineUniformBlockMembers(const std::vector<VarT> &fields, void defineUniformBlockMembers(const std::vector<VarT> &fields,
......
//
// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UniformLinker.h: implements link-time checks for default block uniforms, and generates uniform
// locations. Populates data structures related to uniforms so that they can be stored in program
// state.
#ifndef LIBANGLE_UNIFORMLINKER_H_
#define LIBANGLE_UNIFORMLINKER_H_
#include "libANGLE/Program.h"
#include "libANGLE/Uniform.h"
namespace gl
{
class UniformLinker
{
public:
UniformLinker(const ProgramState &state);
bool link(InfoLog &infoLog, const Caps &caps, const Program::Bindings &uniformLocationBindings);
void getResults(std::vector<LinkedUniform> *uniforms,
std::vector<VariableLocation> *uniformLocations);
private:
struct VectorAndSamplerCount
{
VectorAndSamplerCount() : vectorCount(0), samplerCount(0) {}
VectorAndSamplerCount(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator=(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator+=(const VectorAndSamplerCount &other)
{
vectorCount += other.vectorCount;
samplerCount += other.samplerCount;
return *this;
}
unsigned int vectorCount;
unsigned int samplerCount;
};
bool validateVertexAndFragmentUniforms(InfoLog &infoLog) const;
static bool linkValidateUniforms(InfoLog &infoLog,
const std::string &uniformName,
const sh::Uniform &vertexUniform,
const sh::Uniform &fragmentUniform);
bool flattenUniformsAndCheckCapsForShader(const Shader &shader,
GLuint maxUniformComponents,
GLuint maxTextureImageUnits,
const std::string &componentsErrorMessage,
const std::string &samplerErrorMessage,
std::vector<LinkedUniform> &samplerUniforms,
InfoLog &infoLog);
bool flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog);
VectorAndSamplerCount flattenUniform(const sh::Uniform &uniform,
std::vector<LinkedUniform> *samplerUniforms);
// markStaticUse is given as a separate parameter because it is tracked here at struct
// granularity.
VectorAndSamplerCount flattenUniformImpl(const sh::ShaderVariable &uniform,
const std::string &fullName,
std::vector<LinkedUniform> *samplerUniforms,
bool markStaticUse,
int binding,
int *location);
bool indexUniforms(InfoLog &infoLog, const Program::Bindings &uniformLocationBindings);
bool gatherUniformLocationsAndCheckConflicts(InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings,
std::set<GLuint> *reservedLocations,
std::set<GLuint> *ignoredLocations,
int *maxUniformLocation);
void pruneUnusedUniforms();
const ProgramState &mState;
std::vector<LinkedUniform> mUniforms;
std::vector<VariableLocation> mUniformLocations;
};
} // namespace gl
#endif // LIBANGLE_UNIFORMLINKER_H_
...@@ -182,6 +182,8 @@ ...@@ -182,6 +182,8 @@
'libANGLE/TransformFeedback.h', 'libANGLE/TransformFeedback.h',
'libANGLE/Uniform.cpp', 'libANGLE/Uniform.cpp',
'libANGLE/Uniform.h', 'libANGLE/Uniform.h',
'libANGLE/UniformLinker.cpp',
'libANGLE/UniformLinker.h',
'libANGLE/VaryingPacking.cpp', 'libANGLE/VaryingPacking.cpp',
'libANGLE/VaryingPacking.h', 'libANGLE/VaryingPacking.h',
'libANGLE/Version.h', 'libANGLE/Version.h',
......
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