[Piglit] [PATCH 3/4] arb_viewport_array: Fix uses of gl_ViewportIndex in the fragment shader
Ian Romanick
idr at freedesktop.org
Fri Jan 10 14:05:56 PST 2014
From: Ian Romanick <ian.d.romanick at intel.com>
There were two problem here. First, it is illegal in GLSL to redecalre
a built-in variable. Section 3.7 (Identifiers) of the GLSL 4.40 spec
says:
"However, as noted in the specification, there are some cases where
previously declared variables can be redeclared, and predeclared
"gl_" names are allowed to be redeclared in a shader only for these
specific purposes. More generally, it is a compile-time error to
redeclare a variable, including those starting "gl_"."
There is no mention in the spec of any cases where gl_ViewportIndex can
be redeclared.
Second, gl_ViewportIndex does not exist in the fragment shader without
GL_ARB_fragment_layer_viewport or GLSL 4.3. Mesa does not yet support
either.
Instead, manually pass the viewport index from the geometry shader to
the fragment shader.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Jon Ashburn <jon at lunarg.com>
Cc: Courtney Goeltzenleuchter <courtney at LunarG.com>
---
tests/spec/arb_viewport_array/render_depthrange.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/spec/arb_viewport_array/render_depthrange.c b/tests/spec/arb_viewport_array/render_depthrange.c
index f274e3e..4c1e463 100644
--- a/tests/spec/arb_viewport_array/render_depthrange.c
+++ b/tests/spec/arb_viewport_array/render_depthrange.c
@@ -64,10 +64,12 @@ const char *gsSource = {
"layout(triangles) in;\n"
"layout(triangle_strip, max_vertices = 3) out;\n"
"uniform int idx;\n"
+ "flat out int ViewportIndex;\n"
"\n"
"void main()\n"
"{\n"
" gl_ViewportIndex = idx;\n"
+ " ViewportIndex = idx;\n"
" for(int i = 0; i < gl_in.length(); i++) {\n"
" gl_Position = gl_in[i].gl_Position;\n"
" EmitVertex();\n"
@@ -80,9 +82,9 @@ const char *fsSource = {
"#version 150\n"
"#extension GL_ARB_viewport_array : enable\n"
"uniform vec3 color;\n"
- "in int gl_ViewportIndex;\n"
+ "flat in int ViewportIndex;\n"
"void main() {\n"
- " float idx = gl_ViewportIndex / 10.0;\n"
+ " float idx = ViewportIndex / 10.0;\n"
" gl_FragColor = vec4(gl_FragCoord.z, gl_DepthRange.far, idx, 1.0);\n"
"}\n"
};
--
1.8.1.4
More information about the Piglit
mailing list