[Mesa-dev] [RFC PATCH 25/26] i965/fs: emit sample index for txf

Chris Forbes chrisf at ijw.co.nz
Sat Dec 29 04:35:38 PST 2012


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 <chrisf at 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



More information about the mesa-dev mailing list