diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_fp.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_glsl.c | 18 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 40 |
3 files changed, 37 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index c5121266f9..123fe841c3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -1102,6 +1102,7 @@ void brw_wm_pass_fp( struct brw_wm_compile *c ) c->delta_xy = src_undef(); c->pixel_w = src_undef(); c->nr_fp_insns = 0; + c->fp->tex_units_used = 0x0; /* Emit preamble instructions. This is where special instructions such as * WM_CINTERP, WM_LINTERP, WM_PINTERP and WM_WPOSXY are emitted to diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 2a31077a66..7c210abbce 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2623,7 +2623,8 @@ static void emit_txb(struct brw_wm_compile *c, { struct brw_compile *p = &c->func; struct brw_reg dst[4], src[4], payload_reg; - GLuint unit = c->fp->program.Base.SamplerUnits[inst->TexSrcUnit]; + /* Note: TexSrcUnit was already looked up through SamplerTextures[] */ + const GLuint unit = inst->TexSrcUnit; GLuint i; GLuint msg_type; @@ -2648,11 +2649,15 @@ static void emit_txb(struct brw_wm_compile *c, brw_MOV(p, brw_message_reg(3), src[1]); brw_MOV(p, brw_message_reg(4), brw_imm_f(0)); break; - default: + case TEXTURE_3D_INDEX: + case TEXTURE_CUBE_INDEX: brw_MOV(p, brw_message_reg(2), src[0]); brw_MOV(p, brw_message_reg(3), src[1]); brw_MOV(p, brw_message_reg(4), src[2]); break; + default: + /* invalid target */ + abort(); } brw_MOV(p, brw_message_reg(5), src[3]); /* bias */ brw_MOV(p, brw_message_reg(6), brw_imm_f(0)); /* ref (unused?) */ @@ -2685,7 +2690,8 @@ static void emit_tex(struct brw_wm_compile *c, { struct brw_compile *p = &c->func; struct brw_reg dst[4], src[4], payload_reg; - GLuint unit = c->fp->program.Base.SamplerUnits[inst->TexSrcUnit]; + /* Note: TexSrcUnit was already looked up through SamplerTextures[] */ + const GLuint unit = inst->TexSrcUnit; GLuint msg_len; GLuint i, nr; GLuint emit; @@ -2711,10 +2717,14 @@ static void emit_tex(struct brw_wm_compile *c, emit = WRITEMASK_XY; nr = 2; break; - default: + case TEXTURE_3D_INDEX: + case TEXTURE_CUBE_INDEX: emit = WRITEMASK_XYZ; nr = 3; break; + default: + /* invalid target */ + abort(); } msg_len = 1; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 1b604f0713..54a25dfaf0 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1612,10 +1612,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, GLenum type, GLsizei count, GLint elems, const void *values) { - struct gl_program_parameter *param = + const struct gl_program_parameter *param = &program->Parameters->Parameters[index]; - const GLboolean isUniformBool = is_boolean_type(param->DataType); - const GLboolean areIntValues = is_integer_type(type); assert(offset >= 0); assert(elems >= 1); @@ -1633,19 +1631,13 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, if (param->Type == PROGRAM_SAMPLER) { /* This controls which texture unit which is used by a sampler */ + GLboolean changed = GL_FALSE; GLint i; - /* data type for setting samplers must be int */ - if (type != GL_INT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniform(only glUniform1i can be used " - "to set sampler uniforms)"); - return; - } + /* this should have been caught by the compatible_types() check */ + ASSERT(type == GL_INT); - /* XXX arrays of samplers haven't been tested much, but it's not a - * common thing... - */ + /* loop over number of samplers to change */ for (i = 0; i < count; i++) { GLuint sampler = (GLuint) program->Parameters->ParameterValues[index + offset + i][0]; @@ -1664,19 +1656,31 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, _mesa_printf("Set program %p sampler %d '%s' to unit %u\n", program, sampler, param->Name, texUnit); #endif - program->SamplerUnits[sampler] = texUnit; + if (program->SamplerUnits[sampler] != texUnit) { + program->SamplerUnits[sampler] = texUnit; + changed = GL_TRUE; + } } } - _mesa_update_shader_textures_used(program); - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + if (changed) { + /* When a sampler's value changes it usually requires rewriting + * a GPU program's TEX instructions since there may not be a + * sampler->texture lookup table. We signal this with the + * ProgramStringNotify() callback. + */ + FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); + _mesa_update_shader_textures_used(program); + ctx->Driver.ProgramStringNotify(ctx, program->Target, program); + } } else { /* ordinary uniform variable */ - GLsizei k, i; + const GLboolean isUniformBool = is_boolean_type(param->DataType); + const GLboolean areIntValues = is_integer_type(type); const GLint slots = (param->Size + 3) / 4; const GLint typeSize = sizeof_glsl_type(param->DataType); + GLsizei k, i; if (param->Size > typeSize) { /* an array */ |