[Mesa-dev] [PATCH 1/2] i965/gs: Add dummy source to prepare_channel_masks instruction.

Matt Turner mattst88 at gmail.com
Wed Apr 9 15:21:22 PDT 2014


The generator uses its destination as a source implicitly, which breaks
some assumptions in dead code elimination. Giving the instruction a
source allows us to reason about it better.

Reviewed-by: Eric Anholt <eric at anholt.net>
---
I can't use the source in the generator because a shl(1) instruction
is emitted from generate_gs_prepare_channel_masks(), so we rely on a
bunch of bits in src being in dst even though we're not writing the
whole register.

 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp  | 2 ++
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 3 ++-
 src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index a74514f..47aac75 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -1221,6 +1221,8 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
       break;
 
    case GS_OPCODE_PREPARE_CHANNEL_MASKS:
+      assert(dst.file == src[0].file &&
+             dst.reg == src[0].reg);
       generate_gs_prepare_channel_masks(dst);
       break;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index 13d6d38..1321a94 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -408,7 +408,8 @@ vec4_gs_visitor::emit_control_data_bits()
          src_reg channel_mask(this, glsl_type::uint_type);
          inst = emit(SHL(dst_reg(channel_mask), one, channel));
          inst->force_writemask_all = true;
-         emit(GS_OPCODE_PREPARE_CHANNEL_MASKS, dst_reg(channel_mask));
+         emit(GS_OPCODE_PREPARE_CHANNEL_MASKS, dst_reg(channel_mask),
+                                               channel_mask);
          emit(GS_OPCODE_SET_CHANNEL_MASKS, mrf_reg, channel_mask);
       }
 
diff --git a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
index b854db5..49e1a97 100644
--- a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
@@ -758,6 +758,8 @@ gen8_vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
       break;
 
    case GS_OPCODE_PREPARE_CHANNEL_MASKS:
+      assert(dst.file == src[0].file &&
+             dst.reg == src[0].reg);
       generate_gs_prepare_channel_masks(dst);
       break;
 
-- 
1.8.3.2



More information about the mesa-dev mailing list