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.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index bfb22bbf02..25e280bc3f 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -34,6 +34,7 @@
#include "shader/prog_instruction.h"
#include "shader/prog_print.h"
#include "shader/prog_statevars.h"
+#include "shader/programopt.h"
#include "texenvprogram.h"
@@ -412,9 +413,9 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
}
-static void release_temps( struct texenv_fragment_program *p )
+static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p )
{
- GLuint max_temp = p->ctx->Const.FragmentProgram.MaxTemps;
+ GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps;
/* KW: To support tex_env_crossbar, don't release the registers in
* temps_output.
@@ -594,7 +595,7 @@ static struct ureg register_const4f( struct texenv_fragment_program *p,
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
&swizzle );
ASSERT(swizzle == SWIZZLE_NOOP);
- return make_ureg(PROGRAM_STATE_VAR, idx);
+ return make_ureg(PROGRAM_CONSTANT, idx);
}
#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
@@ -916,14 +917,14 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
*/
if (alpha_shift || rgb_shift) {
if (rgb_shift == alpha_shift) {
- shift = register_scalar_const(p, 1<<rgb_shift);
+ shift = register_scalar_const(p, (GLfloat)(1<<rgb_shift));
}
else {
shift = register_const4f(p,
- 1<<rgb_shift,
- 1<<rgb_shift,
- 1<<rgb_shift,
- 1<<alpha_shift);
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<rgb_shift),
+ (GLfloat)(1<<alpha_shift));
}
return emit_arith( p, OPCODE_MUL, dest, WRITEMASK_XYZW,
saturate, out, shift, undef );
@@ -952,9 +953,17 @@ 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;
- } else
+
+ p->program->Base.SamplersUsed |= (1 << unit);
+ /* This identity mapping should already be in place
+ * (see _mesa_init_program_struct()) but let's be safe.
+ */
+ p->program->Base.SamplerUnits[unit] = unit;
+ }
+ else
p->src_texture[unit] = get_zero(p);
}
}
@@ -1052,7 +1061,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
p.one = undef;
p.last_tex_stage = 0;
- release_temps(&p);
+ release_temps(ctx, &p);
if (key->enabled_units) {
/* First pass - to support texture_env_crossbar, first identify
@@ -1070,7 +1079,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
if (key->enabled_units & (1<<unit)) {
p.src_previous = emit_texenv( &p, unit );
- release_temps(&p); /* release all temps */
+ release_temps(ctx, &p); /* release all temps */
}
}
@@ -1100,6 +1109,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
* a reduced value and not what is expected in FogOption
*/
p.program->FogOption = ctx->Fog.Mode;
+ p.program->Base.InputsRead |= FRAG_BIT_FOGC; /* XXX new */
} else
p.program->FogOption = GL_NONE;
@@ -1115,15 +1125,21 @@ create_new_program(GLcontext *ctx, struct state_key *key,
ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS);
/* Allocate final instruction array */
- program->Base.Instructions
- = _mesa_alloc_instructions(program->Base.NumInstructions);
- if (!program->Base.Instructions) {
+ p.program->Base.Instructions
+ = _mesa_alloc_instructions(p.program->Base.NumInstructions);
+ if (!p.program->Base.Instructions) {
_mesa_error(ctx, GL_OUT_OF_MEMORY,
"generating tex env program");
return;
}
- _mesa_copy_instructions(program->Base.Instructions, instBuffer,
- program->Base.NumInstructions);
+ _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
+ p.program->Base.NumInstructions);
+
+ if (p.program->FogOption) {
+ _mesa_append_fog_code(ctx, p.program);
+ p.program->FogOption = GL_NONE;
+ }
+
/* Notify driver the fragment program has (actually) changed.
*/
@@ -1174,6 +1190,9 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
* If _MaintainTexEnvProgram is set we'll generate a fragment program that
* implements the current texture env/combine mode.
* This function generates that program and puts it into effect.
+ *
+ * XXX: remove this function. currently only called by some drivers,
+ * not by mesa core. We now handle this properly from inside mesa.
*/
void
_mesa_UpdateTexEnvProgram( GLcontext *ctx )