Mesa (master): i965/vs: Properly clear cur_value when propagating direct copies.
Kenneth Graunke
kwg at kemper.freedesktop.org
Tue Dec 27 22:33:29 UTC 2011
Module: Mesa
Branch: master
Commit: 07ee9f374f2946f852896e9264c7fa83eafc3f16
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=07ee9f374f2946f852896e9264c7fa83eafc3f16
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Fri Dec 23 20:24:46 2011 -0800
i965/vs: Properly clear cur_value when propagating direct copies.
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.
Fixes Counter-Strike: Source in Wine (where the menu rendered completely
black in DX9 mode), completely white textures in Civilization V, and the
new Piglit test glsl-vs-copy-propagation-1.shader_test.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42032
Tested-by: Matt Turner <mattst88 at gmail.com>
Tested-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
.../drivers/dri/i965/brw_vec4_copy_propagation.cpp | 28 ++++++++-----------
1 files changed, 12 insertions(+), 16 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..08d8f5b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -297,30 +297,26 @@ vec4_visitor::opt_copy_propagation()
}
/* Track available source registers. */
- if (is_direct_copy(inst)) {
- int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
- for (int i = 0; i < 4; i++) {
- if (inst->dst.writemask & (1 << i)) {
- cur_value[reg][i] = &inst->src[0];
- }
+ const int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
+
+ /* Update our destination's current channel values. For a direct copy,
+ * the value is the newly propagated source. Otherwise, we don't know
+ * the new value, so clear it.
+ */
+ bool direct_copy = is_direct_copy(inst);
+ for (int i = 0; i < 4; i++) {
+ if (inst->dst.writemask & (1 << i)) {
+ cur_value[reg][i] = direct_copy ? &inst->src[0] : NULL;
}
- continue;
}
- /* For any updated channels, clear tracking of them as a source
- * or destination.
+ /* Clear the records for any registers whose current value came from
+ * our destination's updated channels, as the two are no longer equal.
*/
if (inst->dst.file == GRF) {
if (inst->dst.reladdr)
memset(cur_value, 0, sizeof(cur_value));
else {
- int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
-
- for (int i = 0; i < 4; i++) {
- if (inst->dst.writemask & (1 << i))
- cur_value[reg][i] = NULL;
- }
-
for (int i = 0; i < virtual_grf_reg_count; i++) {
for (int j = 0; j < 4; j++) {
if (inst->dst.writemask & (1 << j) &&
More information about the mesa-commit
mailing list