On 07/13/2013 11:37 PM, Chris Forbes wrote:
We always emit U,V,R coordinates for this message, but the sampler gets
very angry if pass garbage in the R coordinate for at least some
texture formats.

Fill the remaining coordinates with zero instead.

Fixes broken rendering on GM45 in Source games.

NOTE: This is a candidate for stable branches.

Signed-off-by: Chris Forbes <chr...@ijw.co.nz>
---
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index fc7ae58..15d1c6a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -891,6 +891,10 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, 
fs_reg coordinate,
         emit(MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate));
         coordinate.reg_offset++;
        }
+      /* zero the others. */
+      for (int i = ir->coordinate->type->vector_elements; i<3; i++) {
+         emit(MOV(fs_reg(MRF, base_mrf + mlen + i), fs_reg(0.0f)));
+      }
        /* gen4's SIMD8 sampler always has the slots for u,v,r present. */
        mlen += 3;
     } else if (ir->op == ir_txd) {


You tracked this down in record time!

On Gen5+, we sometimes reduce the message length, causing the remaining fields to be treated as zero. But on Gen4, the message length is used to determine what kind of message it is, so we can't do that.

On all generations, there are a bunch of cases where the sampler /should/ ignore components, but doesn't, so zeroing them out is just a really good idea.

Reviewed-by: Kenneth Graunke <kenn...@whitecape.org>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to