[Mesa-dev] [PATCH 2/4] mesa/glsl: new compiler option UnrollSamplerArrayDynamicIndexing
Francisco Jerez
currojerez at riseup.net
Tue Jun 9 05:43:54 PDT 2015
Tapani Pälli <tapani.palli at intel.com> writes:
> Patch provides new compiler option for backend to force unroll loops
> that have non-constant expression indexing on sampler arrays.
>
> This makes sure that we can never end up with a shader that uses loop
> induction variable as sampler array index but does not unroll because
> of having too much instructions. This would not work without dynamic
> indexing support.
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/glsl/loop_unroll.cpp | 10 ++++++++++
> src/mesa/main/mtypes.h | 6 ++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp
> index 635e1dd..b9de51d 100644
> --- a/src/glsl/loop_unroll.cpp
> +++ b/src/glsl/loop_unroll.cpp
> @@ -100,6 +100,16 @@ public:
>
> virtual ir_visitor_status visit_enter(ir_dereference_array *ir)
> {
> + /* Force unroll in case of dynamic indexing with sampler arrays. */
> + if (options->UnrollSamplerArrayDynamicIndexing) {
> + if ((ir->array->type->is_array() &&
> + ir->array->type->contains_sampler()) &&
> + !ir->array_index->constant_expression_value()) {
> + unsupported_variable_indexing = true;
> + return visit_continue;
> + }
> + }
> +
> /* Check for arrays variably-indexed by a loop induction variable.
> * Unrolling the loop may convert that access into constant-indexing.
> *
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 1598e2c..61d1dfb 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2896,6 +2896,12 @@ struct gl_shader_compiler_options
> */
> GLboolean OptimizeForAOS;
>
> + /**
> + * Unroll any loops with dynamic indexing to sampler array. This can be used
> + * to force loop unroll from the backend for GLSL <= 1.20 and GLSL ES 1.00.
> + */
> + GLboolean UnrollSamplerArrayDynamicIndexing;
> +
Maybe it would be more consistent with the EmitNoIndirectSomething flags
above to name this flag EmitNoIndirectSampler? Other than that looks
okay to me:
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
> const struct nir_shader_compiler_options *NirOptions;
> };
>
> --
> 2.1.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150609/42b5c122/attachment.sig>
More information about the mesa-dev
mailing list