On 9 November 2011 16:11, Eric Anholt <span dir="ltr">&lt;<a href="mailto:eric@anholt.net">eric@anholt.net</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On original gen4, the surface format didn&#39;t determine the return data<br>
type from sampling like it does on g45 and later.<br>
<br>
Fixes GL_EXT_texture_integer/texture_integer_glsl130<br>
---<br>
<br>
The dst type in your patch has already been smashed to UW for 16-wide,<br>
so it didn&#39;t end up working.<br>
<br>
 src/mesa/drivers/dri/i965/brw_eu.h        |    3 ++-<br>
 src/mesa/drivers/dri/i965/brw_eu_emit.c   |   11 +++++++----<br>
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp |   16 +++++++++++++++-<br>
 src/mesa/drivers/dri/i965/brw_wm_emit.c   |    6 ++++--<br>
 4 files changed, 28 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h<br>
index 33492f6..dcb1fc9 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_eu.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_eu.h<br>
@@ -928,7 +928,8 @@ void brw_SAMPLE(struct brw_compile *p,<br>
                GLuint response_length,<br>
                GLuint msg_length,<br>
                GLuint header_present,<br>
-               GLuint simd_mode);<br>
+               GLuint simd_mode,<br>
+               GLuint return_format);<br>
<br>
 void brw_math_16( struct brw_compile *p,<br>
                  struct brw_reg dest,<br>
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c<br>
index dbb42f4..60350ca 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c<br>
@@ -650,7 +650,8 @@ static void brw_set_sampler_message(struct brw_compile *p,<br>
                                     GLuint response_length,<br>
                                     GLuint msg_length,<br>
                                     GLuint header_present,<br>
-                                    GLuint simd_mode)<br>
+                                    GLuint simd_mode,<br>
+                                   GLuint return_format)<br>
 {<br>
    struct brw_context *brw = p-&gt;brw;<br>
    struct intel_context *intel = &amp;brw-&gt;intel;<br>
@@ -676,7 +677,7 @@ static void brw_set_sampler_message(struct brw_compile *p,<br>
       insn-&gt;bits3.sampler.binding_table_index = binding_table_index;<br>
       insn-&gt;bits3.sampler.sampler = sampler;<br>
       insn-&gt;bits3.sampler.msg_type = msg_type;<br>
-      insn-&gt;bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;<br>
+      insn-&gt;bits3.sampler.return_format = return_format;<br>
    }<br>
 }<br>
<br>
@@ -2086,7 +2087,8 @@ void brw_SAMPLE(struct brw_compile *p,<br>
                GLuint response_length,<br>
                GLuint msg_length,<br>
                GLuint header_present,<br>
-               GLuint simd_mode)<br>
+               GLuint simd_mode,<br>
+               GLuint return_format)<br>
 {<br>
    struct intel_context *intel = &amp;p-&gt;brw-&gt;intel;<br>
    bool need_stall = 0;<br>
@@ -2180,7 +2182,8 @@ void brw_SAMPLE(struct brw_compile *p,<br>
                              response_length,<br>
                              msg_length,<br>
                              header_present,<br>
-                             simd_mode);<br>
+                             simd_mode,<br>
+                             return_format);<br>
    }<br>
<br>
    if (need_stall) {<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
index ad4fae2..1ac215e 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp<br>
@@ -256,6 +256,19 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)<br>
    int msg_type = -1;<br>
    int rlen = 4;<br>
    uint32_t simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;<br>
+   uint32_t return_format;<br>
+<br>
+   switch (dst.type) {<br>
+   case BRW_REGISTER_TYPE_D:<br>
+      return_format = BRW_SAMPLER_RETURN_FORMAT_SINT32;<br>
+      break;<br>
+   case BRW_REGISTER_TYPE_UD:<br>
+      return_format = BRW_SAMPLER_RETURN_FORMAT_UINT32;<br>
+      break;<br>
+   default:<br>
+      return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;<br>
+      break;<br>
+   }<br>
<br>
    if (c-&gt;dispatch_width == 16)<br>
       simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;<br>
@@ -369,7 +382,8 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)<br>
              rlen,<br>
              inst-&gt;mlen,<br>
              inst-&gt;header_present,<br>
-             simd_mode);<br>
+             simd_mode,<br>
+             return_format);<br>
 }<br>
<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c<br>
index a451d56..b5a4a4f 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c<br>
@@ -1162,7 +1162,8 @@ void emit_tex(struct brw_wm_compile *c,<br>
              response_length,<br>
              cur_mrf - 1,<br>
              1,<br>
-             simd_mode);<br>
+             simd_mode,<br>
+             BRW_SAMPLER_RETURN_FORMAT_FLOAT32);<br>
 }<br>
<br>
<br>
@@ -1240,7 +1241,8 @@ void emit_txb(struct brw_wm_compile *c,<br>
              response_length,<br>
              msgLength,<br>
              1,<br>
-             BRW_SAMPLER_SIMD_MODE_SIMD16);<br>
+             BRW_SAMPLER_SIMD_MODE_SIMD16,<br>
+             BRW_SAMPLER_RETURN_FORMAT_FLOAT32);<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
1.7.7<br></font></span></blockquote><div><br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;<br></div></div>