diff options
author | José Fonseca <[email protected]> | 2013-04-17 10:47:03 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2013-04-17 10:54:08 +0100 |
commit | 50b3fc6204a28881f625605f988cb0866ae6a6a5 (patch) | |
tree | c198f26065d7e2d21858a33d4014205b90f96011 /src/gallium/auxiliary/gallivm | |
parent | f61b7da80e238892b0832ec12b11589fba946b47 (diff) |
gallium: Disambiguate TGSI_OPCODE_IF.
TGSI_OPCODE_IF condition had two possible interpretations:
- src.x != 0.0f
- Mesa statetracker when PIPE_SHADER_CAP_INTEGERS was false either for
vertex and fragment shaders
- gallivm/llvmpipe
- postprocess
- vl state tracker
- vega state tracker
- most old drivers
- old internal state trackers
- many graw examples
- src.x != 0U
- Mesa statetracker when PIPE_SHADER_CAP_INTEGERS was true for both
vertex and fragment shaders
- tgsi_exec/softpipe
- r600
- radeonsi
- nv50
And drivers that use draw module also were a mess (because Mesa would
emit float IFs, but draw module supports native integers so it would
interpret IF arg as integers...)
This sort of works if the source argument is limited to float +0.0f or
+1.0f, integer 0, but would fail if source is float -0.0f, or integer in
the float NaN range. It could also fail if source is integer 1, and
hardware flushes denormalized numbers to zero.
But with this change there are now two opcodes, IF and UIF, with clear
meaning.
Drivers that do not support native integers do not need to worry about
UIF. However, for backwards compatibility with old state trackers and
examples, it is advisable that native integer capable drivers also
support the float IF opcode.
I tried to implement this for r600 and radeonsi based on the surrounding
code. I couldn't do this for nouveau, so I just shunted IF/UIF
together, which matches the current behavior.
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
v2:
- Incorporate Roland's feedback.
- Fix r600_shader.c merge conflict.
- Fix typo in radeon, spotted by Michel Dänzer.
- Incorporte Christoph Bumiller's patch to handle TGSI_OPCODE_IF(float)
properly in nv50/ir.
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 17 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c index c71c1f111bd..e1c362be4a8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c @@ -868,6 +868,7 @@ lp_set_default_actions(struct lp_build_tgsi_context * bld_base) bld_base->op_actions[TGSI_OPCODE_COS].fetch_args = scalar_unary_fetch_args; bld_base->op_actions[TGSI_OPCODE_EX2].fetch_args = scalar_unary_fetch_args; bld_base->op_actions[TGSI_OPCODE_IF].fetch_args = scalar_unary_fetch_args; + bld_base->op_actions[TGSI_OPCODE_UIF].fetch_args = scalar_unary_fetch_args; bld_base->op_actions[TGSI_OPCODE_KIL].fetch_args = kil_fetch_args; bld_base->op_actions[TGSI_OPCODE_KILP].fetch_args = kilp_fetch_args; bld_base->op_actions[TGSI_OPCODE_RCP].fetch_args = scalar_unary_fetch_args; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c index 98bce0eb269..223184d554a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c @@ -837,6 +837,7 @@ lp_emit_instruction_aos( return FALSE; case TGSI_OPCODE_IF: + case TGSI_OPCODE_UIF: return FALSE; case TGSI_OPCODE_BGNLOOP: diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c index 3c79abf7d52..b00aa094d38 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c @@ -389,6 +389,7 @@ analyse_instruction(struct analysis_context *ctx, switch (inst->Instruction.Opcode) { case TGSI_OPCODE_IF: + case TGSI_OPCODE_UIF: case TGSI_OPCODE_ELSE: case TGSI_OPCODE_ENDIF: case TGSI_OPCODE_BGNLOOP: diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 239530de729..73965360e7b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1732,6 +1732,7 @@ near_end_of_shader(struct lp_build_tgsi_soa_context *bld, opcode == TGSI_OPCODE_CAL || opcode == TGSI_OPCODE_CALLNZ || opcode == TGSI_OPCODE_IF || + opcode == TGSI_OPCODE_UIF || opcode == TGSI_OPCODE_BGNLOOP || opcode == TGSI_OPCODE_SWITCH) return FALSE; @@ -2395,6 +2396,21 @@ if_emit( } static void +uif_emit( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + LLVMValueRef tmp; + struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); + struct lp_build_context *uint_bld = &bld_base->uint_bld; + + tmp = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL, + emit_data->args[0], uint_bld->zero); + lp_exec_mask_cond_push(&bld->exec_mask, tmp); +} + +static void bgnloop_emit( const struct lp_build_tgsi_action * action, struct lp_build_tgsi_context * bld_base, @@ -2742,6 +2758,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, bld.bld_base.op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit; bld.bld_base.op_actions[TGSI_OPCODE_ENDSUB].emit = endsub_emit; bld.bld_base.op_actions[TGSI_OPCODE_IF].emit = if_emit; + bld.bld_base.op_actions[TGSI_OPCODE_UIF].emit = uif_emit; bld.bld_base.op_actions[TGSI_OPCODE_KIL].emit = kil_emit; bld.bld_base.op_actions[TGSI_OPCODE_KILP].emit = kilp_emit; bld.bld_base.op_actions[TGSI_OPCODE_NRM].emit = nrm_emit; |