summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
authorNicolai Haehnle <[email protected]>2008-07-27 21:31:49 +0200
committerNicolai Haehnle <[email protected]>2008-07-27 21:31:49 +0200
commitc117d0efd28887069607f405be99fbc09fcb4cab (patch)
treedd49a5be33daa2cb5bfbab1280680714949c5d05 /src/mesa/drivers/dri/r300
parente88be7d375032fbddb34a77debe6604fa029492c (diff)
r300: Implement ARB_shadow_ambient; add STATE_SHADOW_AMBIENT
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c1
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c37
-rw-r--r--src/mesa/drivers/dri/r300/r500_fragprog.c41
3 files changed, 60 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index a9c581b236e..fcf571d2060 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -101,6 +101,7 @@ const struct dri_extension card_extensions[] = {
{"GL_ARB_multitexture", NULL},
{"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
{"GL_ARB_shadow", NULL},
+ {"GL_ARB_shadow_ambient", NULL},
{"GL_ARB_texture_border_clamp", NULL},
{"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
{"GL_ARB_texture_cube_map", NULL},
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index d390de54b8a..453dda74312 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -58,6 +58,20 @@ static void reset_srcreg(struct prog_src_register* reg)
reg->Swizzle = SWIZZLE_NOOP;
}
+static struct prog_src_register shadow_ambient(struct gl_program *program, int tmu)
+{
+ gl_state_index fail_value_tokens[STATE_LENGTH] = {
+ STATE_INTERNAL, STATE_SHADOW_AMBIENT, 0, 0, 0
+ };
+ struct prog_src_register reg = { 0, };
+
+ fail_value_tokens[2] = tmu;
+ reg.File = PROGRAM_STATE_VAR;
+ reg.Index = _mesa_add_state_reference(program->Parameters, fail_value_tokens);
+ reg.Swizzle = SWIZZLE_WWWW;
+ return reg;
+}
+
/**
* Transform TEX, TXP, TXB, and KIL instructions in the following way:
* - premultiply texture coordinates for RECT
@@ -92,8 +106,12 @@ static GLboolean transform_TEX(
tgt->Opcode = OPCODE_MOV;
tgt->DstReg = inst.DstReg;
- tgt->SrcReg[0].File = PROGRAM_BUILTIN;
- tgt->SrcReg[0].Swizzle = comparefunc == GL_ALWAYS ? SWIZZLE_1111 : SWIZZLE_0000;
+ if (comparefunc == GL_ALWAYS) {
+ tgt->SrcReg[0].File = PROGRAM_BUILTIN;
+ tgt->SrcReg[0].Swizzle = SWIZZLE_1111;
+ } else {
+ tgt->SrcReg[0] = shadow_ambient(t->Program, inst.TexSrcUnit);
+ }
return GL_TRUE;
}
@@ -153,6 +171,7 @@ static GLboolean transform_TEX(
GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
GLuint depthmode = compiler->fp->state.unit[inst.TexSrcUnit].depth_texture_mode;
int rcptemp = radeonFindFreeTemporary(t);
+ int pass, fail;
tgt = radeonAppendInstructions(t->Program, 3);
@@ -190,16 +209,18 @@ static GLboolean transform_TEX(
tgt[2].DstReg = orig_inst->DstReg;
tgt[2].SrcReg[0].File = PROGRAM_TEMPORARY;
tgt[2].SrcReg[0].Index = tgt[1].DstReg.Index;
- tgt[2].SrcReg[1].File = PROGRAM_BUILTIN;
- tgt[2].SrcReg[2].File = PROGRAM_BUILTIN;
if (comparefunc == GL_LESS || comparefunc == GL_GREATER) {
- tgt[2].SrcReg[1].Swizzle = SWIZZLE_1111;
- tgt[2].SrcReg[2].Swizzle = SWIZZLE_0000;
+ pass = 1;
+ fail = 2;
} else {
- tgt[2].SrcReg[1].Swizzle = SWIZZLE_0000;
- tgt[2].SrcReg[2].Swizzle = SWIZZLE_1111;
+ pass = 2;
+ fail = 1;
}
+
+ tgt[2].SrcReg[pass].File = PROGRAM_BUILTIN;
+ tgt[2].SrcReg[pass].Swizzle = SWIZZLE_1111;
+ tgt[2].SrcReg[fail] = shadow_ambient(t->Program, inst.TexSrcUnit);
} else if (destredirect) {
tgt = radeonAppendInstructions(t->Program, 1);
diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.c b/src/mesa/drivers/dri/r300/r500_fragprog.c
index 3fbdb30acff..a84ba13c121 100644
--- a/src/mesa/drivers/dri/r300/r500_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r500_fragprog.c
@@ -31,6 +31,20 @@
#include "radeon_program_alu.h"
+static struct prog_src_register shadow_ambient(struct gl_program *program, int tmu)
+{
+ gl_state_index fail_value_tokens[STATE_LENGTH] = {
+ STATE_INTERNAL, STATE_SHADOW_AMBIENT, 0, 0, 0
+ };
+ struct prog_src_register reg = { 0, };
+
+ fail_value_tokens[2] = tmu;
+ reg.File = PROGRAM_STATE_VAR;
+ reg.Index = _mesa_add_state_reference(program->Parameters, fail_value_tokens);
+ reg.Swizzle = SWIZZLE_WWWW;
+ return reg;
+}
+
/**
* Transform TEX, TXP, TXB, and KIL instructions in the following way:
* - premultiply texture coordinates for RECT
@@ -63,11 +77,13 @@ static GLboolean transform_TEX(
tgt = radeonAppendInstructions(t->Program, 1);
tgt->Opcode = OPCODE_MOV;
- tgt->DstReg.File = inst.DstReg.File;
- tgt->DstReg.Index = inst.DstReg.Index;
- tgt->DstReg.WriteMask = inst.DstReg.WriteMask;
- tgt->SrcReg[0].File = PROGRAM_BUILTIN;
- tgt->SrcReg[0].Swizzle = comparefunc == GL_ALWAYS ? SWIZZLE_1111 : SWIZZLE_0000;
+ tgt->DstReg = inst.DstReg;
+ if (comparefunc == GL_ALWAYS) {
+ tgt->SrcReg[0].File = PROGRAM_BUILTIN;
+ tgt->SrcReg[0].Swizzle = SWIZZLE_1111;
+ } else {
+ tgt->SrcReg[0] = shadow_ambient(t->Program, inst.TexSrcUnit);
+ }
return GL_TRUE;
}
@@ -91,6 +107,7 @@ static GLboolean transform_TEX(
GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
GLuint depthmode = compiler->fp->state.unit[inst.TexSrcUnit].depth_texture_mode;
int rcptemp = radeonFindFreeTemporary(t);
+ int pass, fail;
tgt = radeonAppendInstructions(t->Program, 3);
@@ -128,16 +145,18 @@ static GLboolean transform_TEX(
tgt[2].DstReg = orig_inst->DstReg;
tgt[2].SrcReg[0].File = PROGRAM_TEMPORARY;
tgt[2].SrcReg[0].Index = tgt[1].DstReg.Index;
- tgt[2].SrcReg[1].File = PROGRAM_BUILTIN;
- tgt[2].SrcReg[2].File = PROGRAM_BUILTIN;
if (comparefunc == GL_LESS || comparefunc == GL_GREATER) {
- tgt[2].SrcReg[1].Swizzle = SWIZZLE_1111;
- tgt[2].SrcReg[2].Swizzle = SWIZZLE_0000;
+ pass = 1;
+ fail = 2;
} else {
- tgt[2].SrcReg[1].Swizzle = SWIZZLE_0000;
- tgt[2].SrcReg[2].Swizzle = SWIZZLE_1111;
+ pass = 2;
+ fail = 1;
}
+
+ tgt[2].SrcReg[pass].File = PROGRAM_BUILTIN;
+ tgt[2].SrcReg[pass].Swizzle = SWIZZLE_1111;
+ tgt[2].SrcReg[fail] = shadow_ambient(t->Program, inst.TexSrcUnit);
} else if (destredirect) {
tgt = radeonAppendInstructions(t->Program, 1);