summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-11-07 10:59:16 -0800
committerJason Ekstrand <[email protected]>2015-01-15 07:19:01 -0800
commit10adf8fc858c21cd95b3e02a8d6abee563ca1046 (patch)
treed7b29be9ae747f9e991ab9d84132c592f5f6fde4 /src/glsl
parenta76ccbfacf3d8e4ea4ab9c25d279eab480f8702e (diff)
nir: Differentiate between signed and unsigned versions of find_msb
We also make the return types match GLSL. The GLSL spec specifies that findMSB and findLSB return a signed integer. Previously, nir had them return unsigned. This updates nir's behavior to match what GLSL expects. We also update the nir-to-fs generator to take the new instructions. While we're at it, we fix the case where the input to findMSB is zero. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/glsl_to_nir.cpp22
-rw-r--r--src/glsl/nir/nir_opcodes.h5
2 files changed, 22 insertions, 5 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 40cb2448cf8..58721913f74 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -1123,9 +1123,25 @@ nir_visitor::visit(ir_expression *ir)
case ir_unop_bitfield_reverse:
emit(nir_op_bitfield_reverse, dest_size, srcs);
break;
- case ir_unop_bit_count: emit(nir_op_bit_count, dest_size, srcs); break;
- case ir_unop_find_msb: emit(nir_op_find_msb, dest_size, srcs); break;
- case ir_unop_find_lsb: emit(nir_op_find_lsb, dest_size, srcs); break;
+ case ir_unop_bit_count:
+ emit(nir_op_bit_count, dest_size, srcs);
+ break;
+ case ir_unop_find_msb:
+ switch (types[0]) {
+ case GLSL_TYPE_UINT:
+ emit(nir_op_ufind_msb, dest_size, srcs);
+ break;
+ case GLSL_TYPE_INT:
+ emit(nir_op_ifind_msb, dest_size, srcs);
+ break;
+ default:
+ unreachable("Invalid type for findMSB()");
+ }
+ break;
+ case ir_unop_find_lsb:
+ emit(nir_op_find_lsb, dest_size, srcs);
+ break;
+
case ir_unop_noise:
switch (ir->type->vector_elements) {
case 1:
diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
index 9a7a2ab5c30..988f691f8d4 100644
--- a/src/glsl/nir/nir_opcodes.h
+++ b/src/glsl/nir/nir_opcodes.h
@@ -147,8 +147,9 @@ UNOP_HORIZ(unpack_half_2x16_split_y, 1, nir_type_float, 1, nir_type_unsigned)
/*@{*/
UNOP(bitfield_reverse, nir_type_unsigned)
UNOP(bit_count, nir_type_unsigned)
-UNOP(find_msb, nir_type_unsigned)
-UNOP(find_lsb, nir_type_unsigned)
+UNOP_CONVERT(ufind_msb, nir_type_unsigned, nir_type_int)
+UNOP(ifind_msb, nir_type_int)
+UNOP(find_lsb, nir_type_int)
/*@}*/
UNOP_HORIZ(fnoise1_1, 1, nir_type_float, 1, nir_type_float)