From 144974d54c55c23a0cf7831170d788910b46a33f Mon Sep 17 00:00:00 2001 From: Alexis Hetu Date: Tue, 5 Apr 2016 17:31:32 -0400 Subject: [PATCH] Allow all output to be written to in the vertex shader MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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/5051 Tested-by: Alexis Hétu Reviewed-by: Nicolas Capens --- src/OpenGL/libGLESv2/Program.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp index 1da918a60..b2d14f758 100644 --- a/src/OpenGL/libGLESv2/Program.cpp +++ b/src/OpenGL/libGLESv2/Program.cpp @@ -1308,6 +1308,8 @@ namespace es2 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) { if(output->name == input->name) @@ -1346,9 +1348,32 @@ namespace es2 } } + matched = true; 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; -- 2.11.0