Fixed sampler within struct uniform used as function argument
The sampler was simply not declared in that case, as if the uniform
was unused in the shader, so making sure structures containing
samplers call samplerRegister solves this issue. It was working
properly if the sampler was used anywhere else in the shader, but
failed when the only use in the shader was being passed as an
argument to a function through a containing structure.
Added a unit test since this isn't covered by dEQP.
Fixes 2 WebGL tests:
conformance/glsl/bugs/sampler-array-struct-function-arg.html
conformance/glsl/bugs/sampler-struct-function-arg.html
Change-Id: I81767d7c6415de7aefefecffcc66265d944a94ab
Reviewed-on: https://swiftshader-review.googlesource.com/18628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 8477af2..b6b0eef 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -2859,6 +2859,10 @@
{
return samplerRegister(operand);
}
+ else if(operand->getType().totalSamplerRegisterCount() > 0) // Struct containing a sampler
+ {
+ samplerRegister(operand); // Make sure the sampler is declared
+ }
switch(operand->getQualifier())
{