Mesa (master): r300/compiler: make ARB_shadow_ambient optional

Marek Olšák mareko at kemper.freedesktop.org
Fri Apr 16 20:36:14 UTC 2010


Module: Mesa
Branch: master
Commit: 47265e69c84c78a68102fa727aa80d63f25c0d46
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=47265e69c84c78a68102fa727aa80d63f25c0d46

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Apr 16 22:29:19 2010 +0200

r300/compiler: make ARB_shadow_ambient optional

This saves constant register space for r300g, which doesn't need
this feature.

---

 src/gallium/drivers/r300/r300_emit.c               |    6 ------
 .../drivers/dri/r300/compiler/radeon_compiler.h    |    3 +++
 .../drivers/dri/r300/compiler/radeon_program_tex.c |   19 +++++++++++++------
 src/mesa/drivers/dri/r300/r300_blit.c              |    1 +
 src/mesa/drivers/dri/r300/r300_fragprog_common.c   |    1 +
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 9c4bcfc..19acdab 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -157,12 +157,6 @@ static const float * get_rc_constant_state(
             vec[1] = 1.0 / tex->height0;
             break;
 
-        /* Texture compare-fail value. Shouldn't ever show up, but if
-         * it does, we'll be ready. */
-        case RC_STATE_SHADOW_AMBIENT:
-            vec[3] = 0;
-            break;
-
         case RC_STATE_R300_VIEWPORT_SCALE:
             vec[0] = viewport->xscale;
             vec[1] = viewport->yscale;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
index 934ae28..09794a5 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
@@ -81,7 +81,10 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
 struct r300_fragment_program_compiler {
 	struct radeon_compiler Base;
 	struct rX00_fragment_program_code *code;
+	/* Optional transformations and features. */
 	struct r300_fragment_program_external_state state;
+	unsigned enable_shadow_ambient;
+	/* Hardware specification. */
 	unsigned is_r500;
 	unsigned max_temp_regs;
     /* Register corresponding to the depthbuffer. */
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 967fd74..200c1f7 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
@@ -31,13 +31,20 @@
 
 /* Series of transformations to be done on textures. */
 
-static struct rc_src_register shadow_ambient(struct radeon_compiler * c, int tmu)
+static struct rc_src_register shadow_ambient(struct r300_fragment_program_compiler *compiler,
+											 int tmu)
 {
 	struct rc_src_register reg = { 0, };
 
-	reg.File = RC_FILE_CONSTANT;
-	reg.Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_SHADOW_AMBIENT, tmu);
-	reg.Swizzle = RC_SWIZZLE_WWWW;
+	if (compiler->enable_shadow_ambient) {
+		reg.File = RC_FILE_CONSTANT;
+		reg.Index = rc_constants_add_state(&compiler->Base.Program.Constants,
+										   RC_STATE_SHADOW_AMBIENT, tmu);
+		reg.Swizzle = RC_SWIZZLE_WWWW;
+	} else {
+		reg.File = RC_FILE_NONE;
+		reg.Swizzle = RC_SWIZZLE_0000;
+	}
 	return reg;
 }
 
@@ -102,7 +109,7 @@ int radeonTransformTEX(
 				inst->U.I.SrcReg[0].File = RC_FILE_NONE;
 				inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
 			} else {
-				inst->U.I.SrcReg[0] = shadow_ambient(c, inst->U.I.TexSrcUnit);
+				inst->U.I.SrcReg[0] = shadow_ambient(compiler, inst->U.I.TexSrcUnit);
 			}
 
 			return 1;
@@ -164,7 +171,7 @@ int radeonTransformTEX(
 
 			inst_cmp->U.I.SrcReg[pass].File = RC_FILE_NONE;
 			inst_cmp->U.I.SrcReg[pass].Swizzle = RC_SWIZZLE_1111;
-			inst_cmp->U.I.SrcReg[fail] = shadow_ambient(c, inst->U.I.TexSrcUnit);
+			inst_cmp->U.I.SrcReg[fail] = shadow_ambient(compiler, inst->U.I.TexSrcUnit);
 		}
 	}
 
diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c
index f6c3a85..0865a45 100644
--- a/src/mesa/drivers/dri/r300/r300_blit.c
+++ b/src/mesa/drivers/dri/r300/r300_blit.c
@@ -117,6 +117,7 @@ static void create_fragment_program(struct r300_context *r300)
     compiler.Base.Program.InputsRead = (1 << FRAG_ATTRIB_TEX0);
     compiler.OutputColor[0] = FRAG_RESULT_COLOR;
     compiler.OutputDepth = FRAG_RESULT_DEPTH;
+    compiler.enable_shadow_ambient = GL_TRUE;
     compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515);
     compiler.max_temp_regs = (compiler.is_r500) ? 128 : 32;
     compiler.code = &r300->blit.fp_code;
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
index ba84122..2b7c93a 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
@@ -219,6 +219,7 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
 
 	compiler.code = &fp->code;
 	compiler.state = fp->state;
+	compiler.enable_shadow_ambient = GL_TRUE;
 	compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) ? GL_TRUE : GL_FALSE;
 	compiler.max_temp_regs = (compiler.is_r500) ? 128 : 32;
 	compiler.OutputDepth = FRAG_RESULT_DEPTH;




More information about the mesa-commit mailing list