Mesa (radeon-rewrite): r300: r500 fragment program fixes

Maciej Cencora osiris at kemper.freedesktop.org
Thu Jun 11 23:11:36 UTC 2009


Module: Mesa
Branch: radeon-rewrite
Commit: 34cb4b6be36ccb03b4c0c76ecc3587984dd284dc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=34cb4b6be36ccb03b4c0c76ecc3587984dd284dc

Author: Maciej Cencora <m.cencora at gmail.com>
Date:   Wed Jun 10 04:09:33 2009 +0200

r300: r500 fragment program fixes

- when rewriting per component negate swizzle, first instruction should get not negated source
- KIL instruction ignores swizzles

TODO:
- tex instructions does not support saturation
- tex instructions cannot read from consant memory

---

 src/mesa/drivers/dri/r300/r500_fragprog.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.c b/src/mesa/drivers/dri/r300/r500_fragprog.c
index 8f0b70a..4d58cf2 100644
--- a/src/mesa/drivers/dri/r300/r500_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r500_fragprog.c
@@ -196,22 +196,20 @@ GLboolean r500FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg)
 		if (reg.Abs)
 			return GL_FALSE;
 
+		if (opcode == OPCODE_KIL && (reg.Swizzle != SWIZZLE_NOOP || reg.Negate != NEGATE_NONE))
+			return GL_FALSE;
+
 		if (reg.Negate)
 			reg.Negate ^= NEGATE_XYZW;
 
-		if (opcode == OPCODE_KIL) {
-			if (reg.Swizzle != SWIZZLE_NOOP)
-				return GL_FALSE;
-		} else {
-			for(i = 0; i < 4; ++i) {
-				GLuint swz = GET_SWZ(reg.Swizzle, i);
-				if (swz == SWIZZLE_NIL) {
-					reg.Negate &= ~(1 << i);
-					continue;
-				}
-				if (swz >= 4)
-					return GL_FALSE;
+		for(i = 0; i < 4; ++i) {
+			GLuint swz = GET_SWZ(reg.Swizzle, i);
+			if (swz == SWIZZLE_NIL) {
+				reg.Negate &= ~(1 << i);
+				continue;
 			}
+			if (swz >= 4)
+				return GL_FALSE;
 		}
 
 		if (reg.Negate)
@@ -273,6 +271,7 @@ void r500FPBuildSwizzle(struct nqssadce_state *s, struct prog_dst_register dst,
 		inst->DstReg = dst;
 		inst->DstReg.WriteMask = negatebase[i];
 		inst->SrcReg[0] = src;
+		inst->SrcReg[0].Negate = (i == 0) ? NEGATE_NONE : NEGATE_XYZW;
 		inst++;
 		s->IP++;
 	}




More information about the mesa-commit mailing list