diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c b/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c index 0676e9721c5..3ec0adea677 100644 --- a/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c +++ b/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c @@ -100,6 +100,12 @@ r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg) if (reg.Abs || reg.Negate) return 0; + /* Texture coordinates can be only read from temporary file, + * input is just a temporary with varying in it. + */ + if (reg.File != RC_FILE_TEMPORARY && reg.File != RC_FILE_INPUT) + return 0; + for (j = 0; j < 4; ++j) { unsigned int swz = GET_SWZ(reg.Swizzle, j); if (swz == RC_SWIZZLE_UNUSED) diff --git a/src/gallium/drivers/r300/compiler/r500_fragprog.c b/src/gallium/drivers/r300/compiler/r500_fragprog.c index 6dccb31f668..698117d5c5c 100644 --- a/src/gallium/drivers/r300/compiler/r500_fragprog.c +++ b/src/gallium/drivers/r300/compiler/r500_fragprog.c @@ -158,6 +158,12 @@ r500_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg) if (reg.Abs) return 0; + /* Texture coordinates can be only read from temporary file, + * input is just a temporary with varying in it. + */ + if (reg.File != RC_FILE_TEMPORARY && reg.File != RC_FILE_INPUT) + return 0; + if (opcode == RC_OPCODE_KIL && (reg.Swizzle != RC_SWIZZLE_XYZW || reg.Negate != RC_MASK_NONE)) return 0; diff --git a/src/gallium/drivers/r300/compiler/radeon_program_tex.c b/src/gallium/drivers/r300/compiler/radeon_program_tex.c index bd3179d37d9..92e01537dfe 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_tex.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_tex.c @@ -267,35 +267,24 @@ radeonTransformTEX(struct radeon_compiler *c, struct rc_instruction *inst, void /* Cannot write texture to output registers or with saturate (all chips), * or with masks (non-r500). */ - if (inst->U.I.Opcode != RC_OPCODE_KIL && - (inst->U.I.DstReg.File != RC_FILE_TEMPORARY || inst->U.I.SaturateMode || - (!c->is_r500 && inst->U.I.DstReg.WriteMask != RC_MASK_XYZW))) { - struct rc_instruction *inst_mov = rc_insert_new_instruction(c, inst); + if (inst->U.I.Opcode != RC_OPCODE_KIL) { + /* We should not be getting saturates on TEX, but assert just to be sure. */ + assert(!inst->U.I.SaturateMode); - inst_mov->U.I.Opcode = RC_OPCODE_MOV; - inst_mov->U.I.SaturateMode = inst->U.I.SaturateMode; - inst_mov->U.I.DstReg = inst->U.I.DstReg; - inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; - inst_mov->U.I.SrcReg[0].Index = rc_find_free_temporary(c); + if (inst->U.I.DstReg.File != RC_FILE_TEMPORARY || inst->U.I.SaturateMode || + (!c->is_r500 && inst->U.I.DstReg.WriteMask != RC_MASK_XYZW)) { + struct rc_instruction *inst_mov = rc_insert_new_instruction(c, inst); - inst->U.I.SaturateMode = 0; - inst->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst->U.I.DstReg.Index = inst_mov->U.I.SrcReg[0].Index; - inst->U.I.DstReg.WriteMask = RC_MASK_XYZW; - } + inst_mov->U.I.Opcode = RC_OPCODE_MOV; + inst_mov->U.I.SaturateMode = inst->U.I.SaturateMode; + inst_mov->U.I.DstReg = inst->U.I.DstReg; + inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; + inst_mov->U.I.SrcReg[0].Index = rc_find_free_temporary(c); - /* Cannot read texture coordinate from constants file */ - if (inst->U.I.SrcReg[0].File != RC_FILE_TEMPORARY && inst->U.I.SrcReg[0].File != RC_FILE_INPUT) { - struct rc_instruction *inst_mov = rc_insert_new_instruction(c, inst->Prev); - - inst_mov->U.I.Opcode = RC_OPCODE_MOV; - inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst_mov->U.I.DstReg.Index = rc_find_free_temporary(c); - inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0]; - - reset_srcreg(&inst->U.I.SrcReg[0]); - inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; - inst->U.I.SrcReg[0].Index = inst_mov->U.I.DstReg.Index; + inst->U.I.DstReg.File = RC_FILE_TEMPORARY; + inst->U.I.DstReg.Index = inst_mov->U.I.SrcReg[0].Index; + inst->U.I.DstReg.WriteMask = RC_MASK_XYZW; + } } return 1;