glsl/gs: Fix transform feedback of gl_ClipDistance.
authorPaul Berry <stereotype441@gmail.com>
Wed, 23 Oct 2013 19:55:24 +0000 (12:55 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 25 Oct 2013 04:59:39 +0000 (21:59 -0700)
Since gl_ClipDistance is lowered from an array of floats to an array
of vec4's during compilation, transform feedback has special logic to
keep track of the pre-lowered array size so that attempting to perform
transform feedback on gl_ClipDistance produces a result with the
correct size.

Previously, this special logic always consulted the vertex shader's
size for gl_ClipDistance.  This patch fixes it so that it uses the
geometry shader's size for gl_ClipDistance when a geometry shader is
in use.

Fixes piglit test spec/glsl-1.50/transform-feedback-type-and-size.

v2: Change the type of LastClipDistanceArraySize to "unsigned", and
clarify the comment above it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/link_varyings.cpp
src/glsl/linker.cpp
src/mesa/main/mtypes.h

index 4ba6d8a2057dc2f7d3f9636bd5b8bc5f503f3eb1..c503645fda127b92fc5aa80f29828e1cd6a1ddb6 100644 (file)
@@ -328,7 +328,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
       const unsigned vector_elements =
          this->matched_candidate->type->fields.array->vector_elements;
       unsigned actual_array_size = this->is_clip_distance_mesa ?
-         prog->Vert.ClipDistanceArraySize :
+         prog->LastClipDistanceArraySize :
          this->matched_candidate->type->array_size();
 
       if (this->is_subscripted) {
index b23c31a166b2f4408c108baee4c910f9715ee8db..d8f655c39397b4cbe905afc111ed734e7a5c381c 100644 (file)
@@ -2100,6 +2100,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       validate_vertex_shader_executable(prog, sh);
       if (!prog->LinkStatus)
         goto done;
+      prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;
 
       _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX],
                             sh);
@@ -2132,6 +2133,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       validate_geometry_shader_executable(prog, sh);
       if (!prog->LinkStatus)
         goto done;
+      prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize;
 
       _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
                             sh);
index 6374e8c0d583dc95df8549804dcb48836256ba41..2c5ea4b5d2aa9b0939434882ec679f04104b90f0 100644 (file)
@@ -2476,6 +2476,12 @@ struct gl_shader_program
    unsigned NumUserUniformStorage;
    struct gl_uniform_storage *UniformStorage;
 
+   /**
+    * Size of the gl_ClipDistance array that is output from the last pipeline
+    * stage before the fragment shader.
+    */
+   unsigned LastClipDistanceArraySize;
+
    struct gl_uniform_block *UniformBlocks;
    unsigned NumUniformBlocks;