i965/gen4: Fix sampling from integer textures.
authorEric Anholt <eric@anholt.net>
Thu, 10 Nov 2011 00:07:57 +0000 (16:07 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 17 Nov 2011 16:31:55 +0000 (08:31 -0800)
On original gen4, the surface format didn't determine the return data
type from sampling like it does on g45 and later.

Fixes GL_EXT_texture_integer/texture_integer_glsl130

Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_fs_emit.cpp
src/mesa/drivers/dri/i965/brw_wm_emit.c

index 33492f6966d11f05158b761c27ab0d5d1d41201b..dcb1fc9167815d6a002d2039758c7851793f3826 100644 (file)
@@ -928,7 +928,8 @@ void brw_SAMPLE(struct brw_compile *p,
                GLuint response_length,
                GLuint msg_length,
                GLuint header_present,
-               GLuint simd_mode);
+               GLuint simd_mode,
+               GLuint return_format);
 
 void brw_math_16( struct brw_compile *p,
                  struct brw_reg dest,
index dbb42f4ea76e161de0f7735d23c76df5c2ee35f8..60350caca3f9a1e6586dc71cbd31c10ef0489abb 100644 (file)
@@ -650,7 +650,8 @@ static void brw_set_sampler_message(struct brw_compile *p,
                                     GLuint response_length,
                                     GLuint msg_length,
                                     GLuint header_present,
-                                    GLuint simd_mode)
+                                    GLuint simd_mode,
+                                   GLuint return_format)
 {
    struct brw_context *brw = p->brw;
    struct intel_context *intel = &brw->intel;
@@ -676,7 +677,7 @@ 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 = return_format;
    }
 }
 
@@ -2086,7 +2087,8 @@ void brw_SAMPLE(struct brw_compile *p,
                GLuint response_length,
                GLuint msg_length,
                GLuint header_present,
-               GLuint simd_mode)
+               GLuint simd_mode,
+               GLuint return_format)
 {
    struct intel_context *intel = &p->brw->intel;
    bool need_stall = 0;
@@ -2180,7 +2182,8 @@ void brw_SAMPLE(struct brw_compile *p,
                              response_length, 
                              msg_length,
                              header_present,
-                             simd_mode);
+                             simd_mode,
+                             return_format);
    }
 
    if (need_stall) {
index ad4fae2c3b50ef49b9d29b3330f8bb5fefce3720..1ac215e6f40afc712f198abefda189e82b5bfbde 100644 (file)
@@ -256,6 +256,19 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
    int msg_type = -1;
    int rlen = 4;
    uint32_t simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;
+   uint32_t return_format;
+
+   switch (dst.type) {
+   case BRW_REGISTER_TYPE_D:
+      return_format = BRW_SAMPLER_RETURN_FORMAT_SINT32;
+      break;
+   case BRW_REGISTER_TYPE_UD:
+      return_format = BRW_SAMPLER_RETURN_FORMAT_UINT32;
+      break;
+   default:
+      return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
+      break;
+   }
 
    if (c->dispatch_width == 16)
       simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
@@ -369,7 +382,8 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
              rlen,
              inst->mlen,
              inst->header_present,
-             simd_mode);
+             simd_mode,
+             return_format);
 }
 
 
index a451d56e498fa4e546190438fac768afba55e1ff..b5a4a4f34daba085670fb66aad88e3a592559a16 100644 (file)
@@ -1162,7 +1162,8 @@ void emit_tex(struct brw_wm_compile *c,
              response_length,
              cur_mrf - 1,
              1,
-             simd_mode);
+             simd_mode,
+             BRW_SAMPLER_RETURN_FORMAT_FLOAT32);
 }
 
 
@@ -1240,7 +1241,8 @@ void emit_txb(struct brw_wm_compile *c,
              response_length,
              msgLength,
              1,
-             BRW_SAMPLER_SIMD_MODE_SIMD16);    
+             BRW_SAMPLER_SIMD_MODE_SIMD16,
+             BRW_SAMPLER_RETURN_FORMAT_FLOAT32);
 }