From 8f37f910bf9c3e34c6afc5a2ec8cc1828f792b16 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 11 Apr 2010 13:52:01 -0700 Subject: r300g: Cleanup fragment program external state setup. --- src/gallium/drivers/r300/r300_fs.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 762cbf27e1..bd9608e504 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -130,20 +130,21 @@ static void allocate_hardware_inputs( } } -static void get_compare_state( +static void get_external_state( struct r300_context* r300, - struct r300_fragment_program_external_state* state, - unsigned shadow_samplers) + struct r300_fragment_program_external_state* state) { - struct r300_textures_state *texstate = - (struct r300_textures_state*)r300->textures_state.state; - - memset(state, 0, sizeof(*state)); + struct r300_textures_state *texstate = r300->textures_state.state; + unsigned i; - for (int i = 0; i < texstate->sampler_state_count; i++) { + for (i = 0; i < texstate->sampler_state_count; i++) { struct r300_sampler_state* s = texstate->sampler_states[i]; - if (s && s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { + if (!s) { + continue; + } + + if (s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { /* XXX Gallium doesn't provide us with any information regarding * this mode, so we are screwed. I'm setting 0 = LUMINANCE. */ state->unit[i].depth_texture_mode = 0; @@ -279,24 +280,21 @@ static void r300_translate_fragment_shader( boolean r300_pick_fragment_shader(struct r300_context* r300) { struct r300_fragment_shader* fs = r300_fs(r300); - struct r300_fragment_program_external_state state; + struct r300_fragment_program_external_state state = {{{ 0 }}}; struct r300_fragment_shader_code* ptr; + get_external_state(r300, &state); + if (!fs->first) { /* Build the fragment shader for the first time. */ fs->first = fs->shader = CALLOC_STRUCT(r300_fragment_shader_code); - /* BTW shadow samplers will be known after the first translation, - * therefore we set ~0, which means it should look at all sampler - * states. This choice doesn't have any impact on the correctness. */ - get_compare_state(r300, &fs->shader->compare_state, ~0); + memcpy(&fs->shader->compare_state, &state, + sizeof(struct r300_fragment_program_external_state)); r300_translate_fragment_shader(r300, fs->shader, fs->state.tokens); - fs->shadow_samplers = fs->shader->shadow_samplers; return TRUE; - } else if (fs->shadow_samplers) { - get_compare_state(r300, &state, fs->shadow_samplers); - + } else { /* Check if the currently-bound shader has been compiled * with the texture-compare state we need. */ if (memcmp(&fs->shader->compare_state, &state, sizeof(state)) != 0) { -- cgit v1.2.3