From: Alexis Hetu Date: Tue, 5 Apr 2016 21:31:32 +0000 (-0400) Subject: Allow all output to be written to in the vertex shader X-Git-Tag: android-x86-7.1-r1~406 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=144974d54c55c23a0cf7831170d788910b46a33f;p=android-x86%2Fexternal-swiftshader.git 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/5051 Tested-by: Alexis Hétu Reviewed-by: Nicolas Capens --- 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;