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

Juan A. Suarez Romero jasuarez at igalia.com
Tue May 22 16:58:13 UTC 2018


Gently ping to get a review for this patch.


	J.A.


On Thu, 2018-05-10 at 10:59 +0200, Juan A. Suarez Romero wrote:
> 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);
> +         result = nir_bcsel(&b, nir_ieq(&b, srcs[1], nir_imm_int(&b, i)),
> +                            swizzled, result);
> +      }
> +      break;
> +   }
>  
>     case ir_binop_ldexp: result = nir_ldexp(&b, srcs[0], srcs[1]); break;
>     case ir_triop_fma:


More information about the mesa-dev mailing list