Mesa (8.0): i965/fs: Take # of components into account in try_rewrite_rhs_to_dst.

Kenneth Graunke kwg at kemper.freedesktop.org
Thu Feb 16 01:21:45 UTC 2012


Module: Mesa
Branch: 8.0
Commit: 0aadb240e191538b07c45733dc2597235a52d274
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0aadb240e191538b07c45733dc2597235a52d274

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Feb 14 12:43:22 2012 -0800

i965/fs: Take # of components into account in try_rewrite_rhs_to_dst.

Commit dc7f449d1ac53a66e6efb56ccf2a5953418a26ca introduced a new method
for avoiding MOVs: try to rewrite the destination of the instruction
that produced the RHS so it writes into the LHS.

Unfortunately, this is not safe for swizzled texturing operations, as
they return a set of four contiguous registers.  Consider the following:

(assign (x)
        (var_ref vec_ctor_x)
        (swiz x (tex vec4 (var_ref m_sampY) (var_ref m_cordY) 0 1 ())))

In this case, the source and destination registers are equal, since
reg_offset is 0 for both.  Yet, this is only a partial move: the texture
operation generates four registers, and the LHS only covers one.

Fixes color distortion in XBMC when using GLSL shaders.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44333
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit 4b274068204c7f0bacaa4639f24feb433353b861)

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 44c9ee8..0632052 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -564,6 +564,12 @@ fs_visitor::try_rewrite_rhs_to_dst(ir_assignment *ir,
        !src.equals(&last_rhs_inst->dst))
       return false;
 
+   /* If last_rhs_inst wrote a different number of components than our LHS,
+    * we can't safely rewrite it.
+    */
+   if (ir->lhs->type->vector_elements != last_rhs_inst->regs_written())
+      return false;
+
    /* Success!  Rewrite the instruction. */
    last_rhs_inst->dst = dst;
 




More information about the mesa-commit mailing list