diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r3 index 0ad8a1f..d5b7c9b 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1297,6 +1297,22 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, real_num_views++; } + uint32_t occupancy_checker = 0; + for (i = 0; i < count; i++) { + if (state->sampler_views[i]) { + if (&state->sampler_views[i]->base == views[i]) { + // this sampler won't be changed, remember its occupied region + uint32_t region = (state->sampler_views[i]->texcache_region) >> 27; + occupancy_checker |= 1< 1) { + //XXX happens with oceans in googleearth and sporadically in ut2004 + fprintf(stderr, "trouble ahead\n"); + //TODO mark this sampler to be changed in the next for(){} + } + //TODO also mark the regions that point to the same cache area + } + } + } for (i = 0; i < count; i++) { if (&state->sampler_views[i]->base != views[i]) { pipe_sampler_view_reference( @@ -1317,12 +1333,73 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, r300_mark_atom_dirty(r300, &r300->fs_rc_constant_state); } - state->sampler_views[i]->texcache_region = - r300_assign_texture_cache_region(view_index, real_num_views); + // don't allow assignment of occupied region + //TODO move here the commentary from r300_assign_texture_cache_region() + unsigned region = real_num_views; + while (region < 32 && occupancy_checker & 1<sampler_views[i]->texcache_region = R300_TX_CACHE(region); + occupancy_checker |= 1<