Commit 144974d5 by Alexis Hetu Committed by Alexis Hétu

Allow all output to be written to in the vertex shader

For transform feedback, any vertex shader output can be read from and which outputs will be read by transform feedback buffers is not known at compile time. For that reason, any output being written to in the vertex shader code shouldn't be optimized out. Change-Id: Ia4322c43b7e3308ec5d930650e70aacf032dc6ec Reviewed-on: https://swiftshader-review.googlesource.com/5051Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 8be41107
...@@ -1308,6 +1308,8 @@ namespace es2 ...@@ -1308,6 +1308,8 @@ namespace es2
for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); ++output) for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); ++output)
{ {
bool matched = false;
for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); ++input) for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); ++input)
{ {
if(output->name == input->name) if(output->name == input->name)
...@@ -1346,9 +1348,32 @@ namespace es2 ...@@ -1346,9 +1348,32 @@ namespace es2
} }
} }
matched = true;
break; break;
} }
} }
// For openGL ES 3.0, we need to still add the vertex shader outputs for unmatched varyings, for transform feedback.
if(!matched && (egl::getClientVersion() >= 3))
{
int out = output->reg;
int components = VariableRegisterSize(output->type);
int registers = VariableRegisterCount(output->type) * output->size();
if(out >= 0)
{
if(out + registers > MAX_VARYING_VECTORS)
{
appendToInfoLog("Too many varyings");
return false;
}
for(int i = 0; i < registers; i++)
{
vertexBinary->setOutput(out + i, components, sw::Shader::Semantic(sw::Shader::USAGE_COLOR));
}
}
}
} }
return true; return true;
......
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