[Mesa-dev] [PATCH] i965: Set sampler message return format for Broadwater/Crestline.

Kenneth Graunke kenneth at whitecape.org
Tue Nov 8 20:37:44 PST 2011


G45+ determine the data type to return based on the Surface Format, but
the original Gen4 hardware needs a bit more hand-holding.

For convenience, set the return format based on the destination register
type, as we already set that correctly.

Cc: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

Eric,

I wrote this patch a while back thinking I'd need it for textureSize().
I quickly realized my mistake, but kept it around for integer texturing.

You might want to include it in your integer-texture series.  I haven't
bothered to resurrect my Gen4 system to test integer texturing, though.

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index dbb42f4..3c94707 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -642,6 +642,19 @@ brw_set_dp_read_message(struct brw_compile *p,
    }
 }
 
+static uint32_t
+gen4_sampler_return_format(uint32_t dst_reg_type)
+{
+   switch (dst_reg_type) {
+   case BRW_REGISTER_TYPE_UD:
+      return BRW_SAMPLER_RETURN_FORMAT_UINT32;
+   case BRW_REGISTER_TYPE_D:
+      return BRW_SAMPLER_RETURN_FORMAT_SINT32;
+   default:
+      return BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
+   }
+}
+
 static void brw_set_sampler_message(struct brw_compile *p,
                                     struct brw_instruction *insn,
                                     GLuint binding_table_index,
@@ -676,7 +689,8 @@ static void brw_set_sampler_message(struct brw_compile *p,
       insn->bits3.sampler.binding_table_index = binding_table_index;
       insn->bits3.sampler.sampler = sampler;
       insn->bits3.sampler.msg_type = msg_type;
-      insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
+      insn->bits3.sampler.return_format =
+	 gen4_sampler_return_format(insn->bits1.da1.dest_reg_type);
    }
 }
 
-- 
1.7.7.2



More information about the mesa-dev mailing list