[Mesa-dev] [PATCH] glsl: Convert TES gl_PatchVerticesIn into a constant when using a TCS.

Marek Olšák maraeo at gmail.com
Sun Oct 25 02:48:03 PDT 2015


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Sun, Oct 25, 2015 at 4:27 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> When a TCS is present, the TES input gl_PatchVerticesIn is actually a
> constant - it's simply the # of output vertices specified by the TCS
> layout qualifiers.  So, we can replace the system value with a constant,
> which may allow further optimization, and will likely be more efficient.
>
> If the TCS is absent, we can't do this optimization.
>
> Cc: Ilia Mirkin <imirkin at alum.mit.edu>
> Cc: Marek Olšák <maraeo at gmail.com>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/glsl/linker.cpp | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> Works for me on i965, but I haven't set up other drivers to test
> them (sorry...)
>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 424b92a..cfd8f81 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -2282,6 +2282,22 @@ resize_tes_inputs(struct gl_context *ctx,
>     foreach_in_list(ir_instruction, ir, tes->ir) {
>        ir->accept(&input_resize_visitor);
>     }
> +
> +   if (tcs) {
> +      /* Convert the gl_PatchVerticesIn system value into a constant, since
> +       * the value is known at this point.
> +       */
> +      foreach_in_list(ir_instruction, ir, tes->ir) {
> +         ir_variable *var = ir->as_variable();
> +         if (var && var->data.mode == ir_var_system_value &&
> +             var->data.location == SYSTEM_VALUE_VERTICES_IN) {
> +            void *mem_ctx = ralloc_parent(var);
> +            var->data.mode = ir_var_auto;
> +            var->data.location = 0;
> +            var->constant_value = new(mem_ctx) ir_constant(num_vertices);
> +         }
> +      }
> +   }
>  }
>
>  /**
> --
> 2.6.2
>


More information about the mesa-dev mailing list