[Mesa-dev] [PATCH v2] glsl: Copy propagate in array index function parameters
Lars Hamre
chemecse at gmail.com
Mon May 9 12:59:43 UTC 2016
Reviewed-by: Lars Hamre <chemecse at gmail.com>
On Fri, May 6, 2016 at 11:54 AM, Juan A. Suarez Romero
<jasuarez at igalia.com> wrote:
> Copy propagate is not applied in function parameters when they are out
> or inout.
>
> But if the parameter is an array, we can copy propagate the index array.
>
> This also fixes shaders at out-parameter-indexing piglit tests, that
> exposes a wrong handling of inout function parameters in Mesa.
>
> This commit does not produce any piglit regression, nor any change in
> shader-db results.
>
> v2:
> - Deal with swizzles (jasuarez)
> - Use a loop top peel off all array dereferences (Ilia)
> ---
> src/compiler/glsl/opt_copy_propagation.cpp | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp
> index ae62921..e464de3 100644
> --- a/src/compiler/glsl/opt_copy_propagation.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation.cpp
> @@ -193,6 +193,24 @@ ir_copy_propagation_visitor::visit_enter(ir_call *ir)
> if (sig_param->data.mode != ir_var_function_out
> && sig_param->data.mode != ir_var_function_inout) {
> ir->accept(this);
> + } else {
> + /* Peeling of all array dereferences / swizzles */
> + ir_dereference_array *ir_array;
> + ir_swizzle *ir_swizzle;
> + do {
> + ir_array = ir->as_dereference_array();
> + if (ir_array) {
> + ir_array->array_index->accept(this);
> + ir = ir_array->array;
> + continue;
> + }
> + ir_swizzle = ir->as_swizzle();
> + if (ir_swizzle) {
> + ir = ir_swizzle->val;
> + continue;
> + }
> + ir = NULL;
> + } while (ir);
> }
> }
>
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list