r300/compiler: make ARB_shadow_ambient optional
authorMarek Olšák <maraeo@gmail.com>
Fri, 16 Apr 2010 20:29:19 +0000 (22:29 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 16 Apr 2010 20:35:56 +0000 (22:35 +0200)
This saves constant register space for r300g, which doesn't need
this feature.

src/gallium/drivers/r300/r300_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
src/mesa/drivers/dri/r300/r300_blit.c
src/mesa/drivers/dri/r300/r300_fragprog_common.c

index 9c4bcfc49b137f9dfd93248f5cc343ea90063b55..19acdaba621bbc834fdc4c0d3d79cf0af14032ec 100644 (file)
@@ -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;
index 934ae28da56aef9e0c4bc71eecfc75568eab8b3b..09794a52ad82709ef6efa85371a4d8931c2fb12c 100644 (file)
@@ -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. */
index 967fd74b0037c820bdd00f44303eb294a3121682..200c1f710bacedec9a3daaeae5c0e50a99026bdd 100644 (file)
 
 /* 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);
                }
        }
 
index f6c3a85e51bf66917d3c58b1a31ec92a6ff56bfe..0865a4564430d990af02a674d5f7d59996e56f96 100644 (file)
@@ -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;
index ba841229565621aa0d5ea1f44e295696f7533546..2b7c93a9575ddded61a0b0106fdb9b67ac9f0a8c 100644 (file)
@@ -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;