[Mesa-dev] [PATCH 2/3] i965/vs: Properly clear cur_value when propagating direct copies.

Kenneth Graunke kenneth at whitecape.org
Fri Dec 23 20:57:47 PST 2011


Consider the following code:

MOV A.x, B.x
MOV B.x, C.x

After the first line, cur_value[A][0] == B, indicating that A.x's
current value came from register B.

When processing the second line, we update cur_value[B][0] to C.
However, for drect copies, we fail to reset cur_value[A][0] to NULL.
This is necessary because the value of A is no longer the value of B.

This new code is cut and pasted from the non-direct-copy case in order
to make a smaller, more readable patch.  The next commit refactors it.

Fixes Counter-Strike: Source in Wine (where the menu rendered completely
black in DX9 mode), and hopefully the white textures in Civilization V.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42032
Cc: Eric Anholt <eric at anholt.net>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Christopher James Halse Rogers <chalserogers at gmail.com>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 95aa306..3e24903 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -304,6 +304,20 @@ vec4_visitor::opt_copy_propagation()
 	       cur_value[reg][i] = &inst->src[0];
 	    }
 	 }
+
+	 /* For any updated channels, clear tracking of them as a source. */
+	 for (int i = 0; i < virtual_grf_reg_count; i++) {
+	    for (int j = 0; j < 4; j++) {
+	       if (inst->dst.writemask & (1 << j) &&
+		   cur_value[i][j] &&
+		   cur_value[i][j]->file == GRF &&
+		   cur_value[i][j]->reg == inst->dst.reg &&
+		   cur_value[i][j]->reg_offset == inst->dst.reg_offset) {
+		  cur_value[i][j] = NULL;
+	       }
+	    }
+	 }
+
 	 continue;
       }
 
-- 
1.7.7.3



More information about the mesa-dev mailing list