summaryrefslogtreecommitdiff
path: root/src/mesa/main/texenvprogram.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/texenvprogram.c')
-rw-r--r--src/mesa/main/texenvprogram.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 6877ef96f2..713ff3d256 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -28,6 +28,7 @@
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "shader/program.h"
#include "shader/prog_parameter.h"
#include "shader/prog_cache.h"
#include "shader/prog_instruction.h"
@@ -36,6 +37,16 @@
#include "shader/programopt.h"
#include "texenvprogram.h"
+
+struct texenvprog_cache_item
+{
+ GLuint hash;
+ void *key;
+ struct gl_fragment_program *data;
+ struct texenvprog_cache_item *next;
+};
+
+
/**
* This MAX is probably a bit generous, but that's OK. There can be
* up to four instructions per texture unit (TEX + 3 for combine),
@@ -59,6 +70,7 @@ struct state_key {
struct {
GLuint enabled:1;
GLuint source_index:3; /* one of TEXTURE_1D/2D/3D/CUBE/RECT_INDEX */
+ GLuint shadow:1;
GLuint ScaleShiftRGB:2;
GLuint ScaleShiftA:2;
@@ -201,8 +213,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
for (i=0;i<MAX_TEXTURE_UNITS;i++) {
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
-
- if (!texUnit->_ReallyEnabled)
+
+ if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
continue;
key->unit[i].enabled = 1;
@@ -210,6 +222,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
key->unit[i].source_index =
translate_tex_src_bit(texUnit->_ReallyEnabled);
+ key->unit[i].shadow = texUnit->_Current->CompareMode == GL_COMPARE_R_TO_TEXTURE;
key->unit[i].NumArgsRGB = texUnit->_CurrentCombine->_NumArgsRGB;
key->unit[i].NumArgsA = texUnit->_CurrentCombine->_NumArgsA;
@@ -479,7 +492,7 @@ emit_op(struct texenv_fragment_program *p,
{
GLuint nr = p->program->Base.NumInstructions++;
struct prog_instruction *inst = &p->program->Base.Instructions[nr];
-
+
assert(nr < MAX_INSTRUCTIONS);
_mesa_init_instructions(inst, 1);
@@ -940,6 +953,10 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
tmp, WRITEMASK_XYZW,
unit, dim, texcoord );
+
+ if (p->state->unit[unit].shadow)
+ p->program->Base.ShadowSamplers |= 1 << unit;
+
p->program->Base.SamplersUsed |= (1 << unit);
/* This identity mapping should already be in place
* (see _mesa_init_program_struct()) but let's be safe.
@@ -1184,11 +1201,14 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx )
/* If a conventional fragment program/shader isn't in effect... */
if (!ctx->FragmentProgram._Enabled &&
(!ctx->Shader.CurrentProgram ||
- !ctx->Shader.CurrentProgram->FragmentProgram) ) {
+ !ctx->Shader.CurrentProgram->FragmentProgram) )
+ {
+ struct gl_fragment_program *newProg;
+
+ newProg = _mesa_get_fixed_func_fragment_program(ctx);
- ctx->FragmentProgram._Current
- = ctx->FragmentProgram._TexEnvProgram
- = _mesa_get_fixed_func_fragment_program(ctx);
+ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, newProg);
+ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, newProg);
}
/* Tell the driver about the change. Could define a new target for