Commit 3c1da04e by Jamie Madill Committed by Commit Bot

Isolate GlslangWrapper header from most of ANGLE.

Since we might want to use the ANGLE PoolAlloc in the Vulkan back-end, we want to make completely sure that it doesn't show up in any header that might be included with the Glslang headers, since this could cause a conflict. This change moves as much as possible to forward-declaring instead of including headers directly in ProgramLinkedResources.h. This means making several internal Program helper classes external. I.E. instead of Program::Bindings, we have ProgramBindings. It also redeclares a "using" in two places, since it isn't possible to forward declare these, and it seemed overdesigned to put the using in a separate header. Bug: angleproject:2264 Change-Id: Idd08706580c927327dddf46e86acbcd2c4e3286f Reviewed-on: https://chromium-review.googlesource.com/792270Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b944053a
......@@ -169,7 +169,7 @@ HashStream &operator<<(HashStream &stream, const Shader *shader)
return stream;
}
HashStream &operator<<(HashStream &stream, const Program::Bindings &bindings)
HashStream &operator<<(HashStream &stream, const ProgramBindings &bindings)
{
for (const auto &binding : bindings)
{
......
......@@ -324,6 +324,7 @@ void InitShaderStorageBlockLinker(const gl::Context *context,
const char *const g_fakepath = "C:\\fakepath";
// InfoLog implementation.
InfoLog::InfoLog()
{
}
......@@ -393,6 +394,7 @@ void InfoLog::reset()
{
}
// VariableLocation implementation.
VariableLocation::VariableLocation() : arrayIndex(0), index(kUnused), ignored(false)
{
}
......@@ -403,6 +405,7 @@ VariableLocation::VariableLocation(unsigned int arrayIndex, unsigned int index)
ASSERT(arrayIndex != GL_INVALID_INDEX);
}
// SamplerBindings implementation.
SamplerBinding::SamplerBinding(GLenum textureTypeIn, size_t elementCount, bool unreferenced)
: textureType(textureTypeIn), boundTextureUnits(elementCount, 0), unreferenced(unreferenced)
{
......@@ -412,35 +415,37 @@ SamplerBinding::SamplerBinding(const SamplerBinding &other) = default;
SamplerBinding::~SamplerBinding() = default;
Program::Bindings::Bindings()
// ProgramBindings implementation.
ProgramBindings::ProgramBindings()
{
}
Program::Bindings::~Bindings()
ProgramBindings::~ProgramBindings()
{
}
void Program::Bindings::bindLocation(GLuint index, const std::string &name)
void ProgramBindings::bindLocation(GLuint index, const std::string &name)
{
mBindings[name] = index;
}
int Program::Bindings::getBinding(const std::string &name) const
int ProgramBindings::getBinding(const std::string &name) const
{
auto iter = mBindings.find(name);
return (iter != mBindings.end()) ? iter->second : -1;
}
Program::Bindings::const_iterator Program::Bindings::begin() const
ProgramBindings::const_iterator ProgramBindings::begin() const
{
return mBindings.begin();
}
Program::Bindings::const_iterator Program::Bindings::end() const
ProgramBindings::const_iterator ProgramBindings::end() const
{
return mBindings.end();
}
// ImageBinding implementation.
ImageBinding::ImageBinding(size_t count) : boundImageUnits(count, 0)
{
}
......@@ -456,6 +461,7 @@ ImageBinding::ImageBinding(const ImageBinding &other) = default;
ImageBinding::~ImageBinding() = default;
// ProgramState implementation.
ProgramState::ProgramState()
: mLabel(),
mAttachedFragmentShader(nullptr),
......@@ -2046,7 +2052,7 @@ bool Program::linkVaryings(const Context *context, InfoLog &infoLog) const
bool Program::linkUniforms(const Context *context,
InfoLog &infoLog,
const Bindings &uniformLocationBindings)
const ProgramBindings &uniformLocationBindings)
{
UniformLinker linker(mState);
if (!linker.link(context, infoLog, uniformLocationBindings))
......@@ -2627,7 +2633,7 @@ bool Program::linkValidateBuiltInVaryings(const Context *context, InfoLog &infoL
bool Program::linkValidateTransformFeedback(const gl::Context *context,
InfoLog &infoLog,
const Program::MergedVaryings &varyings,
const ProgramMergedVaryings &varyings,
const Caps &caps) const
{
size_t totalComponents = 0;
......@@ -2748,7 +2754,7 @@ bool Program::linkValidateGlobalNames(const Context *context, InfoLog &infoLog)
return true;
}
void Program::gatherTransformFeedbackVaryings(const Program::MergedVaryings &varyings)
void Program::gatherTransformFeedbackVaryings(const ProgramMergedVaryings &varyings)
{
// Gather the linked varyings that are used for transform feedback, they should all exist.
mState.mLinkedTransformFeedbackVaryings.clear();
......@@ -2774,9 +2780,9 @@ void Program::gatherTransformFeedbackVaryings(const Program::MergedVaryings &var
}
}
Program::MergedVaryings Program::getMergedVaryings(const Context *context) const
ProgramMergedVaryings Program::getMergedVaryings(const Context *context) const
{
MergedVaryings merged;
ProgramMergedVaryings merged;
for (const sh::Varying &varying : mState.mAttachedVertexShader->getOutputVaryings(context))
{
......
......@@ -378,6 +378,33 @@ class ProgramState final : angle::NonCopyable
int mNumViews;
};
class ProgramBindings final : angle::NonCopyable
{
public:
ProgramBindings();
~ProgramBindings();
void bindLocation(GLuint index, const std::string &name);
int getBinding(const std::string &name) const;
using const_iterator = std::unordered_map<std::string, GLuint>::const_iterator;
const_iterator begin() const;
const_iterator end() const;
private:
std::unordered_map<std::string, GLuint> mBindings;
};
struct ProgramVaryingRef
{
const sh::Varying *get() const { return vertex ? vertex : fragment; }
const sh::Varying *vertex = nullptr;
const sh::Varying *fragment = nullptr;
};
using ProgramMergedVaryings = std::map<std::string, ProgramVaryingRef>;
class Program final : angle::NonCopyable, public LabeledObject
{
public:
......@@ -593,38 +620,13 @@ class Program final : angle::NonCopyable, public LabeledObject
const sh::Attribute &getInputResource(GLuint index) const;
const sh::OutputVariable &getOutputResource(GLuint index) const;
class Bindings final : angle::NonCopyable
{
public:
Bindings();
~Bindings();
void bindLocation(GLuint index, const std::string &name);
int getBinding(const std::string &name) const;
typedef std::unordered_map<std::string, GLuint>::const_iterator const_iterator;
const_iterator begin() const;
const_iterator end() const;
private:
std::unordered_map<std::string, GLuint> mBindings;
};
const Bindings &getAttributeBindings() const { return mAttributeBindings; }
const Bindings &getUniformLocationBindings() const { return mUniformLocationBindings; }
const Bindings &getFragmentInputBindings() const { return mFragmentInputBindings; }
const ProgramBindings &getAttributeBindings() const { return mAttributeBindings; }
const ProgramBindings &getUniformLocationBindings() const { return mUniformLocationBindings; }
const ProgramBindings &getFragmentInputBindings() const { return mFragmentInputBindings; }
int getNumViews() const { return mState.getNumViews(); }
bool usesMultiview() const { return mState.usesMultiview(); }
struct VaryingRef
{
const sh::Varying *get() const { return vertex ? vertex : fragment; }
const sh::Varying *vertex = nullptr;
const sh::Varying *fragment = nullptr;
};
using MergedVaryings = std::map<std::string, VaryingRef>;
private:
~Program() override;
......@@ -641,7 +643,7 @@ class Program final : angle::NonCopyable, public LabeledObject
bool linkUniforms(const Context *context,
InfoLog &infoLog,
const Bindings &uniformLocationBindings);
const ProgramBindings &uniformLocationBindings);
void linkSamplerAndImageBindings();
bool linkAtomicCounterBuffers();
......@@ -660,13 +662,13 @@ class Program final : angle::NonCopyable, public LabeledObject
bool linkValidateBuiltInVaryings(const Context *context, InfoLog &infoLog) const;
bool linkValidateTransformFeedback(const gl::Context *context,
InfoLog &infoLog,
const MergedVaryings &linkedVaryings,
const ProgramMergedVaryings &linkedVaryings,
const Caps &caps) const;
bool linkValidateGlobalNames(const Context *context, InfoLog &infoLog) const;
void gatherTransformFeedbackVaryings(const MergedVaryings &varyings);
void gatherTransformFeedbackVaryings(const ProgramMergedVaryings &varyings);
MergedVaryings getMergedVaryings(const Context *context) const;
ProgramMergedVaryings getMergedVaryings(const Context *context) const;
void linkOutputVariables(const Context *context);
void setUniformValuesFromBindingQualifiers();
......@@ -707,14 +709,14 @@ class Program final : angle::NonCopyable, public LabeledObject
bool mValidated;
Bindings mAttributeBindings;
ProgramBindings mAttributeBindings;
// Note that this has nothing to do with binding layout qualifiers that can be set for some
// uniforms in GLES3.1+. It is used to pre-set the location of uniforms.
Bindings mUniformLocationBindings;
ProgramBindings mUniformLocationBindings;
// CHROMIUM_path_rendering
Bindings mFragmentInputBindings;
ProgramBindings mFragmentInputBindings;
bool mLinked;
bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use
......
......@@ -34,7 +34,7 @@ LinkedUniform *FindUniform(std::vector<LinkedUniform> &list, const std::string &
return nullptr;
}
int GetUniformLocationBinding(const Program::Bindings &uniformLocationBindings,
int GetUniformLocationBinding(const ProgramBindings &uniformLocationBindings,
const sh::Uniform &uniform)
{
int binding = uniformLocationBindings.getBinding(uniform.name);
......@@ -65,7 +65,7 @@ void UniformLinker::getResults(std::vector<LinkedUniform> *uniforms,
bool UniformLinker::link(const Context *context,
InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings)
const ProgramBindings &uniformLocationBindings)
{
if (mState.getAttachedVertexShader() && mState.getAttachedFragmentShader())
{
......@@ -172,8 +172,7 @@ bool UniformLinker::linkValidateUniforms(InfoLog &infoLog,
return true;
}
bool UniformLinker::indexUniforms(InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings)
bool UniformLinker::indexUniforms(InfoLog &infoLog, const ProgramBindings &uniformLocationBindings)
{
// All the locations where another uniform can't be located.
std::set<GLuint> reservedLocations;
......@@ -270,7 +269,7 @@ bool UniformLinker::indexUniforms(InfoLog &infoLog,
bool UniformLinker::gatherUniformLocationsAndCheckConflicts(
InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings,
const ProgramBindings &uniformLocationBindings,
std::set<GLuint> *reservedLocations,
std::set<GLuint> *ignoredLocations,
int *maxUniformLocation)
......
......@@ -11,16 +11,34 @@
#ifndef LIBANGLE_UNIFORMLINKER_H_
#define LIBANGLE_UNIFORMLINKER_H_
#include "libANGLE/Program.h"
#include "libANGLE/Uniform.h"
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/VaryingPacking.h"
#include <functional>
namespace gl
namespace sh
{
struct BlockMemberInfo;
struct InterfaceBlock;
struct ShaderVariable;
struct Uniform;
}
class UniformLinker
namespace gl
{
struct BufferVariable;
struct Caps;
class Context;
class InfoLog;
struct InterfaceBlock;
struct LinkedUniform;
class ProgramState;
class ProgramBindings;
class Shader;
struct VariableLocation;
class UniformLinker final : angle::NonCopyable
{
public:
UniformLinker(const ProgramState &state);
......@@ -28,7 +46,7 @@ class UniformLinker
bool link(const Context *context,
InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings);
const ProgramBindings &uniformLocationBindings);
void getResults(std::vector<LinkedUniform> *uniforms,
std::vector<VariableLocation> *uniformLocations);
......@@ -140,9 +158,9 @@ class UniformLinker
int offset,
int *location);
bool indexUniforms(InfoLog &infoLog, const Program::Bindings &uniformLocationBindings);
bool indexUniforms(InfoLog &infoLog, const ProgramBindings &uniformLocationBindings);
bool gatherUniformLocationsAndCheckConflicts(InfoLog &infoLog,
const Program::Bindings &uniformLocationBindings,
const ProgramBindings &uniformLocationBindings,
std::set<GLuint> *reservedLocations,
std::set<GLuint> *ignoredLocations,
int *maxUniformLocation);
......
......@@ -273,7 +273,7 @@ void VaryingPacking::insert(unsigned int registerRow,
}
bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
const Program::MergedVaryings &mergedVaryings,
const ProgramMergedVaryings &mergedVaryings,
const std::vector<std::string> &tfVaryings)
{
std::set<std::string> uniqueFullNames;
......
......@@ -16,11 +16,15 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Program.h"
#include <map>
namespace gl
{
class InfoLog;
struct ProgramVaryingRef;
using ProgramMergedVaryings = std::map<std::string, ProgramVaryingRef>;
struct PackedVarying
{
......@@ -138,7 +142,7 @@ class VaryingPacking final : angle::NonCopyable
const std::vector<std::string> &tfVaryings);
bool collectAndPackUserVaryings(gl::InfoLog &infoLog,
const Program::MergedVaryings &mergedVaryings,
const ProgramMergedVaryings &mergedVaryings,
const std::vector<std::string> &tfVaryings);
struct Register
......
......@@ -13,6 +13,7 @@
// But 'None' is also define as a numberic constant 0L in <X11/X.h>.
// So we need to include gtest first to avoid such conflict.
#include "libANGLE/Program.h"
#include "libANGLE/VaryingPacking.h"
using namespace gl;
......
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