glsl_to_nir: fix bitfield_extract with 16-bit operands
authorRob Clark <robdclark@chromium.org>
Sat, 18 Jul 2020 17:02:11 +0000 (10:02 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 5 Aug 2020 22:04:47 +0000 (22:04 +0000)
These are defined to explicitly take 32b values.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073>

src/compiler/glsl/glsl_to_nir.cpp

index 69bcdeeff590a65a2d998bcece32715b309fc799..2dc0df32a93ddb183652d23d3c855aba40dd335c 100644 (file)
@@ -2300,12 +2300,14 @@ nir_visitor::visit(ir_expression *ir)
       result = nir_bcsel(&b, srcs[0], srcs[1], srcs[2]);
       break;
    case ir_triop_bitfield_extract:
-      result = (out_type == GLSL_TYPE_INT) ?
-         nir_ibitfield_extract(&b, srcs[0], srcs[1], srcs[2]) :
-         nir_ubitfield_extract(&b, srcs[0], srcs[1], srcs[2]);
+      result = ir->type->is_int_16_32() ?
+         nir_ibitfield_extract(&b, nir_i2i32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2])) :
+         nir_ubitfield_extract(&b, nir_u2u32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2]));
       break;
    case ir_quadop_bitfield_insert:
-      result = nir_bitfield_insert(&b, srcs[0], srcs[1], srcs[2], srcs[3]);
+      result = nir_bitfield_insert(&b,
+                                   nir_u2u32(&b, srcs[0]), nir_u2u32(&b, srcs[1]),
+                                   nir_i2i32(&b, srcs[2]), nir_i2i32(&b, srcs[3]));
       break;
    case ir_quadop_vector:
       result = nir_vec(&b, srcs, ir->type->vector_elements);