From: Juan A. Suarez Romero Date: Wed, 9 May 2018 15:17:59 +0000 (+0000) Subject: glsl: Add ir_binop_vector_extract in NIR X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cbe4baed1f63db697500db069756750afc9e7609;p=mesa.git glsl: Add ir_binop_vector_extract in NIR 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 CC: mesa-stable@lists.freedesktop.org Signed-off-by: Juan A. Suarez Romero Reviewed-by: Eric Anholt Reviewed-by: Iago Toral --- diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index dc3e822308b..baaa3affed9 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -1940,6 +1940,15 @@ nir_visitor::visit(ir_expression *ir) unreachable("not reached"); } break; + case ir_binop_vector_extract: { + result = nir_channel(&b, srcs[0], 0); + for (unsigned i = 1; i < ir->operands[0]->type->vector_elements; i++) { + nir_ssa_def *swizzled = nir_channel(&b, srcs[0], i); + 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: