When fetching texels from a multisample surface, the sample index is
provided as an extra argument after the lod, and the actual lod needs
to be hardwired to 0.

The frontend gives us the sample index in the lod parameter, so fix this
up.

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

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 8967a6c..2d757f7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1039,8 +1039,19 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg 
dst, fs_reg coordinate,
    case ir_txf:
       mlen = header_present + 4 * reg_width;
 
-      emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, BRW_REGISTER_TYPE_UD),
-               lod));
+      if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) {
+         /* for multisample samplers, hardwire lod=0 */
+         emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, 
BRW_REGISTER_TYPE_UD),
+                  fs_reg(0)));
+         /* .. and emit the sample index (which the frontend puts where the lod
+          * would normally be */
+         emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), lod));
+         mlen += reg_width;
+      }
+      else {
+         emit(MOV(fs_reg(MRF, base_mrf + mlen - reg_width, 
BRW_REGISTER_TYPE_UD),
+                  lod));
+      }
       inst = emit(SHADER_OPCODE_TXF, dst);
       break;
    }
-- 
1.8.0.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to