[Mesa-dev] [PATCH] glsl: Add ir_binop_vector_extract in NIR

Eric Anholt eric at anholt.net
Wed May 30 22:10:00 UTC 2018


"Juan A. Suarez Romero" <jasuarez at igalia.com> writes:

> Implement ir_binop_vector_extract using NIR operations. Based on SPIR-V
> to NIR approach.
>
> This fixes:
> dEQP-GLES3.functional.shaders.indexing.moredynamic.with_value_from_indexing_expression_fragment
> Piglit's glsl-fs-vec4-indexing-8.shader_test
>
> Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
> ---
>
> Pending to verify that this also fixes https://bugs.freedesktop.org/show_bug.cgi?id=105438
>
>  src/compiler/glsl/glsl_to_nir.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
> index 8e5e9c34912..5fc420d856f 100644
> --- a/src/compiler/glsl/glsl_to_nir.cpp
> +++ b/src/compiler/glsl/glsl_to_nir.cpp
> @@ -1928,6 +1928,17 @@ nir_visitor::visit(ir_expression *ir)
>              unreachable("not reached");
>        }
>        break;
> +   case ir_binop_vector_extract: {
> +      unsigned swiz[4] = { 0 };
> +      result = nir_swizzle(&b, srcs[0], swiz, 1, true);
> +      for (unsigned i = 1; i < ir->operands[0]->type->vector_elements; i++) {
> +         swiz[0] = i;
> +         nir_ssa_def *swizzled = nir_swizzle(&b, srcs[0], swiz, 1, true);

You could use nir_channel(&b, srcs[0], i) here and above to simplify
(which I think gets the use_fmov argument right, as well).  Other than
that,

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180530/2664fb21/attachment.sig>


More information about the mesa-dev mailing list