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_vec4_visitor.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 104057c..8aa4b2d 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2088,8 +2088,19 @@ vec4_visitor::visit(ir_texture *ir)
         }
         emit(MOV(dst_reg(MRF, mrf, ir->lod_info.lod->type, writemask), lod));
       } else if (ir->op == ir_txf) {
-        emit(MOV(dst_reg(MRF, param_base, ir->lod_info.lod->type, WRITEMASK_W),
-                 lod));
+         if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) 
{
+            /* for multisample samplers, actual lod is always 0, and the
+             * extra parameter is the sample index */
+            emit(MOV(dst_reg(MRF, param_base, ir->lod_info.lod->type, 
WRITEMASK_W),
+                     src_reg(0)));
+            emit(MOV(dst_reg(MRF, param_base + 1, ir->lod_info.lod->type, 
WRITEMASK_X),
+                     lod));   /* sample_index */
+            inst->mlen++;     /* spilled over into a second reg of args */
+         }
+         else {
+            emit(MOV(dst_reg(MRF, param_base, ir->lod_info.lod->type, 
WRITEMASK_W),
+                     lod));
+         }
       } else if (ir->op == ir_txd) {
         const glsl_type *type = ir->lod_info.grad.dPdx->type;
 
-- 
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