Remove the gl::Varying class, and replace all usages with sh::Varying.
TRAC #23746
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index 116cc94..c670fec 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -926,7 +926,7 @@
// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
// Returns the number of used varying registers, or -1 if unsuccesful
-int ProgramBinary::packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader)
+int ProgramBinary::packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader)
{
const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
@@ -934,7 +934,7 @@
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
{
- Varying *varying = &fragmentShader->mVaryings[varyingIndex];
+ sh::Varying *varying = &fragmentShader->mVaryings[varyingIndex];
GLenum transposedType = TransposeMatrixType(varying->type);
int n = VariableRowCount(transposedType) * varying->elementCount();
int m = VariableColumnCount(transposedType);
@@ -1103,7 +1103,7 @@
}
}
-bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying *packing[][4],
+bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader)
{
@@ -1144,12 +1144,12 @@
for (unsigned int fragVaryingIndex = 0; fragVaryingIndex < fragmentShader->mVaryings.size(); fragVaryingIndex++)
{
- Varying *input = &fragmentShader->mVaryings[fragVaryingIndex];
+ sh::Varying *input = &fragmentShader->mVaryings[fragVaryingIndex];
bool matched = false;
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++)
{
- Varying *output = &vertexShader->mVaryings[vertVaryingIndex];
+ sh::Varying *output = &vertexShader->mVaryings[vertVaryingIndex];
if (output->name == input->name)
{
if (output->type != input->type || output->arraySize != input->arraySize || output->interpolation != input->interpolation)
@@ -1301,7 +1301,7 @@
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++)
{
- Varying *varying = &vertexShader->mVaryings[vertVaryingIndex];
+ sh::Varying *varying = &vertexShader->mVaryings[vertVaryingIndex];
if (varying->registerAssigned())
{
for (unsigned int elementIndex = 0; elementIndex < varying->elementCount(); elementIndex++)
@@ -1500,7 +1500,7 @@
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
{
- Varying *varying = &fragmentShader->mVaryings[varyingIndex];
+ sh::Varying *varying = &fragmentShader->mVaryings[varyingIndex];
if (varying->registerAssigned())
{
for (unsigned int elementIndex = 0; elementIndex < varying->elementCount(); elementIndex++)
@@ -1581,7 +1581,7 @@
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
{
- Varying *varying = &fragmentShader->mVaryings[varyingIndex];
+ sh::Varying *varying = &fragmentShader->mVaryings[varyingIndex];
if (varying->registerAssigned())
{
for (unsigned int elementIndex = 0; elementIndex < varying->elementCount(); elementIndex++)
@@ -2004,7 +2004,7 @@
std::string vertexHLSL = vertexShader->getHLSL();
// Map the varyings to the register file
- const Varying *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
+ const sh::ShaderVariable *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
int registers = packVaryings(infoLog, packing, fragmentShader);
if (registers < 0)
@@ -2691,14 +2691,14 @@
return true;
}
-std::string ProgramBinary::generateGeometryShaderHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+std::string ProgramBinary::generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
{
// for now we only handle point sprite emulation
ASSERT(usesPointSpriteEmulation());
return generatePointSpriteHLSL(registers, packing, fragmentShader, vertexShader);
}
-std::string ProgramBinary::generatePointSpriteHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+std::string ProgramBinary::generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
{
ASSERT(registers >= 0);
ASSERT(vertexShader->mUsesPointSize);
diff --git a/src/libGLESv2/ProgramBinary.h b/src/libGLESv2/ProgramBinary.h
index f42a380..dac0294 100644
--- a/src/libGLESv2/ProgramBinary.h
+++ b/src/libGLESv2/ProgramBinary.h
@@ -39,7 +39,6 @@
class VertexShader;
class InfoLog;
class AttributeBindings;
-struct Varying;
class Buffer;
// Struct used for correlating uniforms/elements of uniform arrays to handles
@@ -148,8 +147,8 @@
private:
DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
- int packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader);
- bool linkVaryings(InfoLog &infoLog, int registers, const Varying *packing[][4],
+ int packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader);
+ bool linkVaryings(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader);
std::string generateVaryingHLSL(FragmentShader *fragmentShader, const std::string &varyingSemantic) const;
@@ -173,8 +172,8 @@
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
void defineOutputVariables(FragmentShader *fragmentShader);
- std::string generateGeometryShaderHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
- std::string generatePointSpriteHLSL(int registers, const Varying *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+ std::string generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+ std::string generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
template <typename T>
bool setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp
index a32c6a1..3e0c088 100644
--- a/src/libGLESv2/Shader.cpp
+++ b/src/libGLESv2/Shader.cpp
@@ -221,11 +221,7 @@
{
std::vector<sh::Varying> *activeVaryings;
ShGetInfoPointer(compiler, SH_ACTIVE_VARYINGS_ARRAY, reinterpret_cast<void**>(&activeVaryings));
-
- for (unsigned int varyingIndex = 0; varyingIndex < activeVaryings->size(); varyingIndex++)
- {
- mVaryings.push_back(Varying((*activeVaryings)[varyingIndex]));
- }
+ mVaryings = *activeVaryings;
mUsesMultipleRenderTargets = mHlsl.find("GL_USES_MRT") != std::string::npos;
mUsesFragColor = mHlsl.find("GL_USES_FRAG_COLOR") != std::string::npos;
@@ -414,7 +410,7 @@
};
// true if varying x has a higher priority in packing than y
-bool Shader::compareVarying(const Varying &x, const Varying &y)
+bool Shader::compareVarying(const sh::ShaderVariable &x, const sh::ShaderVariable &y)
{
if (x.type == y.type)
{
diff --git a/src/libGLESv2/Shader.h b/src/libGLESv2/Shader.h
index 0359539..b3096b3 100644
--- a/src/libGLESv2/Shader.h
+++ b/src/libGLESv2/Shader.h
@@ -31,36 +31,6 @@
{
class ResourceManager;
-struct Varying
-{
- Varying(const sh::Varying &shaderVar)
- : interpolation(shaderVar.interpolation),
- type(shaderVar.type),
- name(shaderVar.name),
- arraySize(shaderVar.arraySize),
- registerIndex(GL_INVALID_INDEX),
- elementIndex(GL_INVALID_INDEX)
- {}
-
- sh::InterpolationType interpolation;
- GLenum type;
- std::string name;
- unsigned int arraySize;
-
- bool isArray() const { return arraySize > 0; }
- unsigned int elementCount() const { return std::max(1u, arraySize); }
- bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
-
- void resetRegisterAssignment()
- {
- registerIndex = GL_INVALID_INDEX;
- elementIndex = GL_INVALID_INDEX;
- }
-
- unsigned int registerIndex; // First varying register, assigned during link
- unsigned int elementIndex; // First register element, assigned during link
-};
-
class Shader
{
friend class ProgramBinary;
@@ -106,11 +76,11 @@
void getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer) const;
- static bool compareVarying(const Varying &x, const Varying &y);
+ static bool compareVarying(const sh::ShaderVariable &x, const sh::ShaderVariable &y);
const rx::Renderer *const mRenderer;
- std::vector<Varying> mVaryings;
+ std::vector<sh::Varying> mVaryings;
bool mUsesMultipleRenderTargets;
bool mUsesFragColor;