[Mesa-dev] [PATCH 3/6] i965: fs: Add fixup for textureSize on Gen6

Chris Forbes chrisf at ijw.co.nz
Thu Nov 22 04:35:37 PST 2012


Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index b6f7771..0050252 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -975,11 +975,26 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       inst = emit(SHADER_OPCODE_TXD, dst);
       break;
    }
-   case ir_txs:
+   case ir_txs: {
       emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), lod));
       mlen += reg_width;
       inst = emit(SHADER_OPCODE_TXS, dst);
+
+      /* fixup #layers for cube arrays */
+      glsl_type const * type = ir->sampler->variable_referenced()->type;
+      if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&
+            type->sampler_array) {
+         /* emit_math can't cope with immediates. */
+         fs_reg * imm = new (mem_ctx) fs_reg(this, glsl_type::ivec4_type);
+         emit(MOV(*imm, fs_reg(6)));
+
+         fs_reg depth = dst;
+         depth.reg_offset = 2;
+         emit_math(SHADER_OPCODE_INT_QUOTIENT, depth, depth, *imm);
+      }
+
       break;
+   }
    case ir_txf:
       mlen = header_present + 4 * reg_width;
 
-- 
1.8.0



More information about the mesa-dev mailing list