i965: vs: Add fixup for textureSize with cube array samplers
authorChris Forbes <chrisf@ijw.co.nz>
Thu, 22 Nov 2012 08:32:08 +0000 (21:32 +1300)
committerEric Anholt <eric@anholt.net>
Fri, 14 Dec 2012 23:26:31 +0000 (15:26 -0800)
V3: Fixed weird whitespace
V4: Use sampler's type rather than variable's type; otherwise broken
    with arrays of samplers. (Thanks Eric)
v5: Fix a couple more style nits (by anholt)

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 97593d090b145802e32cdfe9ed37c269fd53ab4e..104057cf119babbe810966b21e07ba7df60ba62b 100644 (file)
@@ -2117,6 +2117,19 @@ vec4_visitor::visit(ir_texture *ir)
 
    emit(inst);
 
+   /* fixup num layers (z) for cube arrays: hardware returns faces * layers;
+    * spec requires layers.
+    */
+   if (ir->op == ir_txs) {
+      glsl_type const *type = ir->sampler->type;
+      if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&
+          type->sampler_array) {
+         emit_math(SHADER_OPCODE_INT_QUOTIENT,
+                   with_writemask(inst->dst, WRITEMASK_Z),
+                   src_reg(inst->dst), src_reg(6));
+      }
+   }
+
    swizzle_result(ir, src_reg(inst->dst), sampler);
 }