r300/compiler: implement TXD and TXL opcodes
authorMarek Olšák <maraeo@gmail.com>
Fri, 6 May 2011 19:59:51 +0000 (21:59 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 7 May 2011 00:51:38 +0000 (02:51 +0200)
src/mesa/drivers/dri/r300/compiler/r500_fragprog.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c

index 140eeed3de33a7376e34a5ca006df477ffff59ff..5e0be6b8881d80488910a2fde561a4e436c3a8ce 100644 (file)
@@ -70,6 +70,8 @@ static int r500_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
        if (opcode == RC_OPCODE_TEX ||
            opcode == RC_OPCODE_TXB ||
            opcode == RC_OPCODE_TXP ||
+           opcode == RC_OPCODE_TXD ||
+           opcode == RC_OPCODE_TXL ||
            opcode == RC_OPCODE_KIL) {
                if (reg.Abs)
                        return 0;
index 5f2588bdfe5e95c06f9082709cd9e8780d2a2a44..c30cd753d15b692197d0f8c1a71c3030149473e7 100644 (file)
@@ -396,6 +396,12 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
        case RC_OPCODE_TXP:
                code->inst[ip].inst1 |= R500_TEX_INST_PROJ;
                break;
+       case RC_OPCODE_TXD:
+               code->inst[ip].inst1 |= R500_TEX_INST_DXDY;
+               break;
+       case RC_OPCODE_TXL:
+               code->inst[ip].inst1 |= R500_TEX_INST_LOD;
+               break;
        default:
                error("emit_tex can't handle opcode %s\n", rc_get_opcode_info(inst->Opcode)->Name);
        }
@@ -413,6 +419,18 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
                | (GET_SWZ(inst->TexSwizzle, 3) << 30)
                ;
 
+       if (inst->Opcode == RC_OPCODE_TXD) {
+               use_temporary(code, inst->SrcReg[1].Index);
+               use_temporary(code, inst->SrcReg[2].Index);
+
+               /* DX and DY parameters are specified in a separate register. */
+               code->inst[ip].inst3 =
+                       R500_DX_ADDR(inst->SrcReg[1].Index) |
+                       (translate_strq_swizzle(inst->SrcReg[1].Swizzle) << 8) |
+                       R500_DY_ADDR(inst->SrcReg[2].Index) |
+                       (translate_strq_swizzle(inst->SrcReg[2].Swizzle) << 24);
+       }
+
        return 1;
 }
 
index e3e498e8fb4f0ec098fbe64f196d0f0c22984296..afd78ad79dd3963fd39ef14ec50dbd84479354ff 100644 (file)
@@ -481,6 +481,7 @@ void rc_compute_sources_for_writemask(
                        break;
                case RC_OPCODE_TXB:
                case RC_OPCODE_TXP:
+               case RC_OPCODE_TXL:
                        srcmasks[0] |= RC_MASK_W;
                        /* Fall through */
                case RC_OPCODE_TEX:
@@ -500,6 +501,33 @@ void rc_compute_sources_for_writemask(
                                        break;
                        }
                        break;
+               case RC_OPCODE_TXD:
+                       switch (inst->U.I.TexSrcTarget) {
+                               case RC_TEXTURE_1D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_Y;
+                                       /* Fall through. */
+                               case RC_TEXTURE_1D:
+                                       srcmasks[0] |= RC_MASK_X;
+                                       srcmasks[1] |= RC_MASK_X;
+                                       srcmasks[2] |= RC_MASK_X;
+                                       break;
+                               case RC_TEXTURE_2D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_Z;
+                                       /* Fall through. */
+                               case RC_TEXTURE_2D:
+                               case RC_TEXTURE_RECT:
+                                       srcmasks[0] |= RC_MASK_XY;
+                                       srcmasks[1] |= RC_MASK_XY;
+                                       srcmasks[2] |= RC_MASK_XY;
+                                       break;
+                               case RC_TEXTURE_3D:
+                               case RC_TEXTURE_CUBE:
+                                       srcmasks[0] |= RC_MASK_XYZ;
+                                       srcmasks[1] |= RC_MASK_XYZ;
+                                       srcmasks[2] |= RC_MASK_XYZ;
+                                       break;
+                       }
+                       break;
                case RC_OPCODE_DST:
                        srcmasks[0] |= RC_MASK_Y | RC_MASK_Z;
                        srcmasks[1] |= RC_MASK_Y | RC_MASK_W;
index 21ea25dbf0dd0cd3601192060c7e9f8e63599e84..5b4fba808732e8c14496389b38ac456670813f4b 100644 (file)
@@ -91,6 +91,8 @@ static void copy_propagate_scan_read(void * data, struct rc_instruction * inst,
                                (inst->U.I.Opcode == RC_OPCODE_TEX ||
                                inst->U.I.Opcode == RC_OPCODE_TXB ||
                                inst->U.I.Opcode == RC_OPCODE_TXP ||
+                               inst->U.I.Opcode == RC_OPCODE_TXD ||
+                               inst->U.I.Opcode == RC_OPCODE_TXL ||
                                inst->U.I.Opcode == RC_OPCODE_KIL)){
                reader_data->Abort = 1;
                return;
index cef448ee4e12f1d6c925700ca305dfab5072f06e..8d16b2cf9ecc92d5c69aaf7d10601db30a6446d8 100644 (file)
@@ -142,6 +142,8 @@ int radeonTransformTEX(
        if (inst->U.I.Opcode != RC_OPCODE_TEX &&
                inst->U.I.Opcode != RC_OPCODE_TXB &&
                inst->U.I.Opcode != RC_OPCODE_TXP &&
+               inst->U.I.Opcode != RC_OPCODE_TXD &&
+               inst->U.I.Opcode != RC_OPCODE_TXL &&
                inst->U.I.Opcode != RC_OPCODE_KIL)
                return 0;