Move the call to packVaryings outside of linkVaryings.
TRAC #22412
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Author: Jamie Madill
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1784 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index 8e3c376..48b83f4 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -1010,6 +1010,8 @@
{
const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
+ fragmentShader->resetVaryingsRegisterAssignment();
+
for (VaryingList::iterator varying = fragmentShader->mVaryings.begin(); varying != fragmentShader->mVaryings.end(); varying++)
{
int n = VariableRowCount(varying->type) * varying->size;
@@ -1153,35 +1155,15 @@
return registers;
}
-bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::string& vertexHLSL, FragmentShader *fragmentShader, VertexShader *vertexShader)
+bool ProgramBinary::linkVaryings(InfoLog &infoLog, int registers, const Varying *packing[][4],
+ std::string& pixelHLSL, std::string& vertexHLSL,
+ FragmentShader *fragmentShader, VertexShader *vertexShader)
{
if (pixelHLSL.empty() || vertexHLSL.empty())
{
return false;
}
- // Reset the varying register assignments
- for (VaryingList::iterator fragVar = fragmentShader->mVaryings.begin(); fragVar != fragmentShader->mVaryings.end(); fragVar++)
- {
- fragVar->reg = -1;
- fragVar->col = -1;
- }
-
- for (VaryingList::iterator vtxVar = vertexShader->mVaryings.begin(); vtxVar != vertexShader->mVaryings.end(); vtxVar++)
- {
- vtxVar->reg = -1;
- vtxVar->col = -1;
- }
-
- // Map the varyings to the register file
- const Varying *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
- int registers = packVaryings(infoLog, packing, fragmentShader);
-
- if (registers < 0)
- {
- return false;
- }
-
// Write the HLSL input/output declarations
const int shaderModel = mRenderer->getMajorShaderModel();
const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
@@ -1193,6 +1175,8 @@
return false;
}
+ vertexShader->resetVaryingsRegisterAssignment();
+
for (VaryingList::iterator input = fragmentShader->mVaryings.begin(); input != fragmentShader->mVaryings.end(); input++)
{
bool matched = false;
@@ -1801,7 +1785,16 @@
std::string pixelHLSL = fragmentShader->getHLSL();
std::string vertexHLSL = vertexShader->getHLSL();
- if (!linkVaryings(infoLog, pixelHLSL, vertexHLSL, fragmentShader, vertexShader))
+ // Map the varyings to the register file
+ const Varying *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
+ int registers = packVaryings(infoLog, packing, fragmentShader);
+
+ if (registers < 0)
+ {
+ return false;
+ }
+
+ if (!linkVaryings(infoLog, registers, packing, pixelHLSL, vertexHLSL, fragmentShader, vertexShader))
{
return false;
}
diff --git a/src/libGLESv2/ProgramBinary.h b/src/libGLESv2/ProgramBinary.h
index ab91522..e0a3f15 100644
--- a/src/libGLESv2/ProgramBinary.h
+++ b/src/libGLESv2/ProgramBinary.h
@@ -108,7 +108,9 @@
DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
int packVaryings(InfoLog &infoLog, const Varying *packing[][4], FragmentShader *fragmentShader);
- bool linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::string& vertexHLSL, FragmentShader *fragmentShader, VertexShader *vertexShader);
+ bool linkVaryings(InfoLog &infoLog, int registers, const Varying *packing[][4],
+ std::string& pixelHLSL, std::string& vertexHLSL,
+ FragmentShader *fragmentShader, VertexShader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp
index 43d2a1f..5b3ea1c 100644
--- a/src/libGLESv2/Shader.cpp
+++ b/src/libGLESv2/Shader.cpp
@@ -301,6 +301,15 @@
}
}
+void Shader::resetVaryingsRegisterAssignment()
+{
+ for (VaryingList::iterator var = mVaryings.begin(); var != mVaryings.end(); var++)
+ {
+ var->reg = -1;
+ var->col = -1;
+ }
+}
+
// initialize/clean up previous state
void Shader::uncompile()
{
diff --git a/src/libGLESv2/Shader.h b/src/libGLESv2/Shader.h
index 1f5e0e6..5f50b6e 100644
--- a/src/libGLESv2/Shader.h
+++ b/src/libGLESv2/Shader.h
@@ -83,6 +83,7 @@
protected:
void parseVaryings();
+ void resetVaryingsRegisterAssignment();
void compileToHLSL(void *compiler);