Re: [Mesa-dev] [PATCH] state_tracker: Fix bug in conditional discards with native ints.
Brian Paul writes: > On 09/03/2014 03:04 PM, Eric Anholt wrote: >> A bool is 0 or ~0, and KILL_IF takes a float arg that's <0 for discard or >>> = 0 for not. By negating it, we ended up doing a floating point subtract >> of (0 - ~0), which ended up as an inf. To make this actually work, we >> need to convert the bool to a float. >> --- >> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- >> 1 file changed, 12 insertions(+), 2 deletions(-) >> >> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp >> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp >> index dd9c84f..62e4101 100644 >> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp >> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp >> @@ -3091,8 +3091,18 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) >> { >> if (ir->condition) { >> ir->condition->accept(this); >> - this->result.negate = ~this->result.negate; >> - emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, this->result); >> + st_src_reg condition = this->result; >> + >> + /* Convert the bool condition to a float so we can negate. */ >> + if (native_integers) { >> + st_src_reg temp = get_temp(ir->condition->type); >> + emit(ir, TGSI_OPCODE_AND, st_dst_reg(temp), >> + condition, st_src_reg_for_float(1.0)); >> + condition = temp; >> + } >> + >> + condition.negate = ~condition.negate; >> + emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, condition); >> } else { >> /* unconditional kil */ >> emit(ir, TGSI_OPCODE_KILL); >> > > Reviewed-by: Brian Paul > > Tag for stable branches? I don't think there are any releaseable drivers doing native ints without control flow in the stable braches -- GLSL discards just don't work at all if you're hitting this bug. pgp4V4IB75Sv9.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] state_tracker: Fix bug in conditional discards with native ints.
On 09/03/2014 03:04 PM, Eric Anholt wrote: A bool is 0 or ~0, and KILL_IF takes a float arg that's <0 for discard or = 0 for not. By negating it, we ended up doing a floating point subtract of (0 - ~0), which ended up as an inf. To make this actually work, we need to convert the bool to a float. --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index dd9c84f..62e4101 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3091,8 +3091,18 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) { if (ir->condition) { ir->condition->accept(this); - this->result.negate = ~this->result.negate; - emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, this->result); + st_src_reg condition = this->result; + + /* Convert the bool condition to a float so we can negate. */ + if (native_integers) { + st_src_reg temp = get_temp(ir->condition->type); + emit(ir, TGSI_OPCODE_AND, st_dst_reg(temp), + condition, st_src_reg_for_float(1.0)); + condition = temp; + } + + condition.negate = ~condition.negate; + emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, condition); } else { /* unconditional kil */ emit(ir, TGSI_OPCODE_KILL); Reviewed-by: Brian Paul Tag for stable branches? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] state_tracker: Fix bug in conditional discards with native ints.
A bool is 0 or ~0, and KILL_IF takes a float arg that's <0 for discard or >= 0 for not. By negating it, we ended up doing a floating point subtract of (0 - ~0), which ended up as an inf. To make this actually work, we need to convert the bool to a float. --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index dd9c84f..62e4101 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3091,8 +3091,18 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) { if (ir->condition) { ir->condition->accept(this); - this->result.negate = ~this->result.negate; - emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, this->result); + st_src_reg condition = this->result; + + /* Convert the bool condition to a float so we can negate. */ + if (native_integers) { + st_src_reg temp = get_temp(ir->condition->type); + emit(ir, TGSI_OPCODE_AND, st_dst_reg(temp), + condition, st_src_reg_for_float(1.0)); + condition = temp; + } + + condition.negate = ~condition.negate; + emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, condition); } else { /* unconditional kil */ emit(ir, TGSI_OPCODE_KILL); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev