Mesa (master): i965: vs optimization fix: Check val.{negate, abs} in accumulator_contains()

Paul Berry stereotype441 at kemper.freedesktop.org
Mon Jul 25 18:43:49 UTC 2011


Module: Mesa
Branch: master
Commit: d92463d5dc42aca09a54588c322fc60582cf9131
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d92463d5dc42aca09a54588c322fc60582cf9131

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Fri Jul 22 14:05:52 2011 -0700

i965: vs optimization fix: Check val.{negate,abs} in accumulator_contains()

When emitting a MAC instruction in a vertex shader, brw_vs_emit()
calls accumulator_contains() to determine whether the accumulator
already contains the appropriate addend; if it does, then we can avoid
emitting an unnecessary MOV instruction.

However, accumulator_contains() wasn't checking the val.negate or
val.abs flags.  As a result, if the desired value was the negation, or
the absolute value, of what was already in the accumulator, we would
generate an incorrect shader.

Fixes piglit test vs-refract-vec4-vec4-float.

Tested on Gen5 and Gen6.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/drivers/dri/i965/brw_vs_emit.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index d8cb0f7..674a994 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -1821,6 +1821,9 @@ accumulator_contains(struct brw_vs_compile *c, struct brw_reg val)
    if (val.address_mode != BRW_ADDRESS_DIRECT)
       return GL_FALSE;
 
+   if (val.negate || val.abs)
+      return GL_FALSE;
+
    switch (prev_insn->header.opcode) {
    case BRW_OPCODE_MOV:
    case BRW_OPCODE_MAC:




More information about the mesa-commit mailing list