Mesa (7.9): r300/compiler: fix projective mapping of 2D NPOT textures
Marek Olšák
mareko at kemper.freedesktop.org
Tue Sep 28 17:59:54 UTC 2010
Module: Mesa
Branch: 7.9
Commit: 89ed679a9e99fa9b6b5754b6f279d7c34a3f371b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=89ed679a9e99fa9b6b5754b6f279d7c34a3f371b
Author: Marek Olšák <maraeo at gmail.com>
Date: Tue Sep 28 19:48:00 2010 +0200
r300/compiler: fix projective mapping of 2D NPOT textures
NOTE: This is a candidate for the 7.9 branch.
(cherry picked from commit 6f747567ec775f37d43b35d957e72334c511e8bc)
Conflicts:
src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
---
.../drivers/dri/r300/compiler/radeon_program_tex.c | 40 ++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
index ddce590..42c8b59 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
@@ -73,6 +73,39 @@ static void lower_texture_rect(struct r300_fragment_program_compiler *compiler,
}
}
+static void projective_divide(struct r300_fragment_program_compiler *compiler,
+ struct rc_instruction *inst)
+{
+ struct rc_instruction *inst_mul, *inst_rcp;
+
+ unsigned temp = rc_find_free_temporary(&compiler->Base);
+
+ inst_rcp = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+ inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
+ inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_rcp->U.I.DstReg.Index = temp;
+ inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+ inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ /* Because the input can be arbitrarily swizzled,
+ * read the component mapped to W. */
+ inst_rcp->U.I.SrcReg[0].Swizzle =
+ RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
+
+ inst_mul = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+ inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+ inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mul->U.I.DstReg.Index = temp;
+ inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+ inst_mul->U.I.SrcReg[1].Index = temp;
+ inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+
+ reset_srcreg(&inst->U.I.SrcReg[0]);
+ inst->U.I.Opcode = RC_OPCODE_TEX;
+ inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst->U.I.SrcReg[0].Index = temp;
+}
+
/**
* Transform TEX, TXP, TXB, and KIL instructions in the following ways:
* - implement texture compare (shadow extensions)
@@ -206,6 +239,13 @@ int radeonTransformTEX(
}
}
+ /* Divide by W if needed. */
+ if (inst->U.I.Opcode == RC_OPCODE_TXP &&
+ (compiler->state.unit[inst->U.I.TexSrcUnit].wrap_mode == RC_WRAP_REPEAT ||
+ compiler->state.unit[inst->U.I.TexSrcUnit].wrap_mode == RC_WRAP_MIRRORED_REPEAT)) {
+ projective_divide(compiler, inst);
+ }
+
/* Texture wrap modes don't work on NPOT textures or texrects.
*
* The game plan is simple. We have two flags, fake_npot and
More information about the mesa-commit
mailing list