From: Marek Olšák Date: Fri, 19 Mar 2010 00:13:57 +0000 (+0100) Subject: r300g: fix breakage after the gallium-sampler-view merge X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afae0891949b72a2ede2a3b6a01d4d6bcf4ceae0;p=mesa.git r300g: fix breakage after the gallium-sampler-view merge --- diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 5522fb306db..c897df628d2 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1050,9 +1050,11 @@ validate: } /* ...textures... */ for (i = 0; i < texstate->count; i++) { - tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture; - if (!tex || !texstate->sampler_states[i]) + if (!(texstate->tx_enable & (1 << i))) { continue; + } + + tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture; if (!r300_add_texture(r300->rws, tex, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { r300->context.flush(&r300->context, 0, NULL); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index db7844eef0e..bdfe74ed2a0 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -973,6 +973,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); struct r300_textures_state* state = (struct r300_textures_state*)r300->textures_state.state; + struct r300_texture *texture; unsigned i; boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; boolean dirty_tex = FALSE; @@ -984,15 +985,18 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, for (i = 0; i < count; i++) { if (state->fragment_sampler_views[i] != views[i]) { - struct r300_texture *texture; - pipe_sampler_view_reference(&state->fragment_sampler_views[i], views[i]); - dirty_tex = TRUE; - texture = (struct r300_texture *)views[i]->texture; + if (!views[i]) { + continue; + } + + /* A new sampler view (= texture)... */ + dirty_tex = TRUE; /* R300-specific - set the texrect factor in the fragment shader */ + texture = (struct r300_texture *)views[i]->texture; if (!is_r500 && texture->is_npot) { /* XXX It would be nice to re-emit just 1 constant, * XXX not all of them */ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 74663bda514..85947353ee9 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -335,20 +335,25 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) (struct r300_textures_state*)r300->textures_state.state; struct r300_texture_sampler_state *texstate; struct r300_sampler_state *sampler; + struct pipe_sampler_view *view; struct r300_texture *tex; unsigned min_level, max_level, i, size; unsigned count = MIN2(state->texture_count, state->sampler_count); state->tx_enable = 0; + state->count = 0; size = 2; for (i = 0; i < count; i++) { if (state->fragment_sampler_views[i] && state->sampler_states[i]) { state->tx_enable |= 1 << i; - tex = (struct r300_texture *)state->fragment_sampler_views[i]->texture; + view = state->fragment_sampler_views[i]; + tex = (struct r300_texture *)view->texture; sampler = state->sampler_states[i]; + assert(view->format == tex->tex.format); + texstate = &state->regs[i]; memcpy(texstate->format, &tex->state, sizeof(uint32_t)*3); texstate->filter[0] = sampler->filter0; @@ -370,8 +375,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) } else { /* determine min/max levels */ /* the MAX_MIP level is the largest (finest) one */ - max_level = MIN2(sampler->max_lod, tex->tex.last_level); - min_level = MIN2(sampler->min_lod, max_level); + max_level = MIN3(sampler->max_lod, tex->tex.last_level, + view->last_level); + min_level = MIN2(MAX2(sampler->min_lod, view->first_level), + max_level); texstate->format[0] |= R300_TX_NUM_LEVELS(max_level); texstate->filter[0] |= R300_TX_MAX_MIP_LEVEL(min_level); }