1. There are trailing whitespaces.<br><br>2. I would rather use Negate(Abs(cond)) in case we get negative numbers there.<br><br>-Marek<br><br><div class="gmail_quote">On Mon, Jul 5, 2010 at 10:01 PM, Tom Stellard <span dir="ltr"><<a href="mailto:tstellar@gmail.com">tstellar@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">---<br>
src/gallium/drivers/r300/r300_tgsi_to_rc.c | 2 +-<br>
src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c | 4 ++<br>
.../drivers/dri/r300/compiler/radeon_opcodes.c | 4 ++<br>
.../drivers/dri/r300/compiler/radeon_opcodes.h | 3 ++<br>
.../drivers/dri/r300/compiler/radeon_program_alu.c | 30 ++++++++++++++++++++<br>
.../drivers/dri/r300/compiler/radeon_program_alu.h | 2 +<br>
6 files changed, 44 insertions(+), 1 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c<br>
index 5394e04..d31cf7e 100644<br>
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c<br>
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c<br>
@@ -71,7 +71,7 @@ static unsigned translate_opcode(unsigned opcode)<br>
case TGSI_OPCODE_COS: return RC_OPCODE_COS;<br>
case TGSI_OPCODE_DDX: return RC_OPCODE_DDX;<br>
case TGSI_OPCODE_DDY: return RC_OPCODE_DDY;<br>
- /* case TGSI_OPCODE_KILP: return RC_OPCODE_KILP; */<br>
+ case TGSI_OPCODE_KILP: return RC_OPCODE_KILP;<br>
/* case TGSI_OPCODE_PK2H: return RC_OPCODE_PK2H; */<br>
/* case TGSI_OPCODE_PK2US: return RC_OPCODE_PK2US; */<br>
/* case TGSI_OPCODE_PK4B: return RC_OPCODE_PK4B; */<br>
diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c<br>
index b53571a..32a369b 100644<br>
--- a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c<br>
+++ b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c<br>
@@ -100,6 +100,10 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)<br>
struct emulate_loop_state loop_state;<br>
<br>
rewrite_depth_out(c);<br>
+<br>
+ /* This transformation needs to be done before any of the IF<br>
+ * instructions are modified. */<br>
+ radeonTransformKILP(&c->Base);<br>
<br>
debug_program_log(c, "before compilation");<br>
<br>
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c<br>
index 128745a..04f234f 100644<br>
--- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c<br>
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c<br>
@@ -399,6 +399,10 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {<br>
{<br>
.Opcode = RC_OPCODE_BEGIN_TEX,<br>
.Name = "BEGIN_TEX"<br>
+ },<br>
+ {<br>
+ .Opcode = RC_OPCODE_KILP,<br>
+ .Name = "KILP",<br>
}<br>
};<br>
<br>
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h<br>
index e103ce5..8b9fa07 100644<br>
--- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h<br>
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h<br>
@@ -199,6 +199,9 @@ typedef enum {<br>
* can run simultaneously. */<br>
RC_OPCODE_BEGIN_TEX,<br>
<br>
+ /** Stop execution of the shader (GLSL discard) */<br>
+ RC_OPCODE_KILP,<br>
+<br>
MAX_RC_OPCODE<br>
} rc_opcode;<br>
<br>
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c<br>
index c922d3d..78c2d99 100644<br>
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c<br>
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c<br>
@@ -973,3 +973,33 @@ int radeonTransformDeriv(struct radeon_compiler* c,<br>
<br>
return 1;<br>
}<br>
+<br>
+/**<br>
+ * IF Temp[0].x -\<br>
+ * KILP - > KIL -Temp[0].x<br>
+ * ENDIF -/<br>
+ *<br>
+ * This needs to be done in its own pass, because it modifies the instructions<br>
+ * before and after KILP.<br>
+ */<br>
+int radeonTransformKILP(struct radeon_compiler * c)<br>
+{<br>
+ struct rc_instruction * inst;<br>
+ for(inst = c->Program.Instructions.Next;<br>
+ inst != &c->Program.Instructions; inst = inst->Next){<br>
+<br>
+ struct rc_instruction * inst_cond;<br>
+ if(inst->U.I.Opcode != RC_OPCODE_KILP<br>
+ || inst->Prev->U.I.Opcode != RC_OPCODE_IF<br>
+ || inst->Next->U.I.Opcode != RC_OPCODE_ENDIF){<br>
+ continue;<br>
+ }<br>
+ inst->U.I.Opcode = RC_OPCODE_KIL;<br>
+ inst->U.I.SrcReg[0] = negate(inst->Prev->U.I.SrcReg[0]);<br>
+<br>
+ /* Remove IF */<br>
+ rc_remove_instruction(inst->Prev);<br>
+ /* Remove ENDIF */<br>
+ rc_remove_instruction(inst->Next);<br>
+ }<br>
+}<br>
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.h b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.h<br>
index 77d4444..4aa084f 100644<br>
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.h<br>
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.h<br>
@@ -60,4 +60,6 @@ int radeonTransformDeriv(<br>
struct rc_instruction * inst,<br>
void*);<br>
<br>
+int radeonTransformKILP(struct radeon_compiler * c);<br>
+<br>
#endif /* __RADEON_PROGRAM_ALU_H_ */<br>
<font color="#888888">--<br>
1.7.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br>