<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 24 October 2013 00:13, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Oct 23, 2013 at 01:08:42PM -0700, Paul Berry wrote:<br>
> Since gl_ClipDistance is lowered from an array of floats to an array<br>
> of vec4's during compilation, transform feedback has special logic to<br>
> keep track of the pre-lowered array size so that attempting to perform<br>
> transform feedback on gl_ClipDistance produces a result with the<br>
> correct size.<br>
><br>
> Previously, this special logic always consulted the vertex shader's<br>
> size for gl_ClipDistance.  This patch fixes it so that it uses the<br>
> geometry shader's size for gl_ClipDistance when a geometry shader is<br>
> in use.<br>
><br>
> Fixes piglit test spec/glsl-1.50/transform-feedback-type-and-size.<br>
> ---<br>
>  src/glsl/link_varyings.cpp | 2 +-<br>
>  src/glsl/linker.cpp        | 2 ++<br>
>  src/mesa/main/mtypes.h     | 6 ++++++<br>
>  3 files changed, 9 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp<br>
> index 4ba6d8a..c503645 100644<br>
> --- a/src/glsl/link_varyings.cpp<br>
> +++ b/src/glsl/link_varyings.cpp<br>
> @@ -328,7 +328,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,<br>
>        const unsigned vector_elements =<br>
>           this->matched_candidate->type->fields.array->vector_elements;<br>
>        unsigned actual_array_size = this->is_clip_distance_mesa ?<br>
> -         prog->Vert.ClipDistanceArraySize :<br>
> +         prog->LastClipDistanceArraySize :<br>
>           this->matched_candidate->type->array_size();<br>
><br>
>        if (this->is_subscripted) {<br>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp<br>
> index b23c31a..d8f655c 100644<br>
> --- a/src/glsl/linker.cpp<br>
> +++ b/src/glsl/linker.cpp<br>
> @@ -2100,6 +2100,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)<br>
>        validate_vertex_shader_executable(prog, sh);<br>
>        if (!prog->LinkStatus)<br>
>        goto done;<br>
> +      prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;<br>
><br>
>        _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX],<br>
>                            sh);<br>
> @@ -2132,6 +2133,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)<br>
>        validate_geometry_shader_executable(prog, sh);<br>
>        if (!prog->LinkStatus)<br>
>        goto done;<br>
> +      prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize;<br>
><br>
>        _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_GEOMETRY],<br>
>                            sh);<br>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
> index 6374e8c..bc7dea4 100644<br>
> --- a/src/mesa/main/mtypes.h<br>
> +++ b/src/mesa/main/mtypes.h<br>
> @@ -2476,6 +2476,12 @@ struct gl_shader_program<br>
>     unsigned NumUserUniformStorage;<br>
>     struct gl_uniform_storage *UniformStorage;<br>
><br>
> +   /**<br>
> +    * Size of the gl_ClipDistance array that is output from the last pipeline<br>
> +    * stage before the geometry shader.<br>
<br>
</div></div>Can you explain the "before the geometry shader" part? This is used by the<br>
transform feedback mechanism and hence represents the size of the varying output<br>
by the geometry shader (if present of course), right? This comment in turn<br>
refers to the varying output by vertex shader and _read_ by geometry shader.<br></blockquote><div><br></div><div>Oops.  I meant to say "...output from the last pipeline stage before the fragment shader".  Is that clearer?</div>
<div><br></div><div>In other words, for now, it's the geometry shader (if present), and the vertex shader otherwise.  But in the future, when we add tessellation shaders, it'll be:</div><div><br></div><div>- the size of gl_ClipDistance output by the geometry shader, if present.</div>
<div>- Otherwise, the size of gl_ClipDistance output by the tessellation evaluation shader, if present.</div><div>- Otherwise, the size of gl_ClipDistance output by the tessellation control shader, if present.</div><div>- Otherwise, the size of gl_ClipDistance output by the vertex shader.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> +    */<br>
> +   GLuint LastClipDistanceArraySize;<br>
> +<br>
>     struct gl_uniform_block *UniformBlocks;<br>
>     unsigned NumUniformBlocks;<br>
><br>
> --<br>
> 1.8.4.1<br>
><br>
</div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>