summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-03-10 15:44:32 -0800
committerEric Anholt <[email protected]>2010-03-12 15:12:01 -0800
commit52cea5090ceb56105464d60b989c2c36ec9c4b16 (patch)
tree089d5980baac460e36d26ea739d44e9e97d7e908 /src/mesa/drivers
parentba541b0769768ffa09562938d3b49690669948b8 (diff)
i965: When doing a swizzled kill pixel, don't do redundant channel compares.
This was obvious when looking at the compiled output of ETQW's shaders.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_emit.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index b1695760174..3a4057bb6b8 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -1110,11 +1110,19 @@ static void emit_kil( struct brw_wm_compile *c,
{
struct brw_compile *p = &c->func;
struct brw_reg r0uw = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
- GLuint i;
-
- /* XXX - usually won't need 4 compares!
- */
+ GLuint i, j;
+
for (i = 0; i < 4; i++) {
+ /* Check if we've already done the comparison for this reg
+ * -- common when someone does KIL TEMP.wwww.
+ */
+ for (j = 0; j < i; j++) {
+ if (memcmp(&arg0[j], &arg0[i], sizeof(arg0[0])) == 0)
+ break;
+ }
+ if (j != i)
+ continue;
+
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0[i], brw_imm_f(0));
brw_set_predicate_control_flag_value(p, 0xff);