summaryrefslogtreecommitdiffstats
path: root/src/mesa
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/mesa
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/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_nir.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 8c6a5738f84..4dafe771aba 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -876,19 +876,21 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
emit_percomp(CBIT(result, op[0]), instr->dest.write_mask);
break;
- case nir_op_find_msb: {
- fs_reg temp = fs_reg(this, glsl_type::uvec4_type);
- emit_percomp(FBH(temp, op[0]), instr->dest.write_mask);
+ case nir_op_ufind_msb:
+ case nir_op_ifind_msb: {
+ emit_percomp(FBH(retype(result, BRW_REGISTER_TYPE_UD), op[0]),
+ instr->dest.write_mask);
/* FBH counts from the MSB side, while GLSL's findMSB() wants the count
* from the LSB side. If FBH didn't return an error (0xFFFFFFFF), then
* subtract the result from 31 to convert the MSB count into an LSB count.
*/
- emit_percomp(CMP(reg_null_d, temp, fs_reg(~0), BRW_CONDITIONAL_NZ),
+ emit_percomp(CMP(reg_null_d, result, fs_reg(-1), BRW_CONDITIONAL_NZ),
instr->dest.write_mask);
- temp.negate = true;
- fs_inst *inst = ADD(result, temp, fs_reg(31));
+ fs_reg neg_result(result);
+ neg_result.negate = true;
+ fs_inst *inst = ADD(result, neg_result, fs_reg(31));
inst->predicate = BRW_PREDICATE_NORMAL;
emit_percomp(inst, instr->dest.write_mask);
break;