r600g: properly track which textures are depth

This fixes the issue with have_depth_texture never being set to false.
This commit is contained in:
Marek Olšák 2012-07-14 17:06:27 +02:00
parent e5de73cafd
commit 80755ff563
3 changed files with 26 additions and 19 deletions

View File

@ -183,21 +183,23 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
}
static void r600_flush_depth_textures(struct r600_context *rctx,
struct r600_textures_info *textures)
void r600_flush_depth_textures(struct r600_context *rctx,
struct r600_textures_info *textures)
{
unsigned i;
unsigned depth_texture_mask = textures->depth_texture_mask;
for (i = 0; i < textures->n_views; ++i) {
while (depth_texture_mask) {
struct pipe_sampler_view *view;
struct r600_resource_texture *tex;
i = u_bit_scan(&depth_texture_mask);
view = &textures->views[i]->base;
if (!view) continue;
assert(view);
tex = (struct r600_resource_texture *)view->texture;
if (!tex->is_depth || tex->is_flushing_texture)
continue;
assert(tex->is_depth && !tex->is_flushing_texture);
r600_blit_uncompress_depth(&rctx->context, tex, NULL,
view->u.tex.first_level,
@ -207,12 +209,6 @@ static void r600_flush_depth_textures(struct r600_context *rctx,
}
}
void r600_flush_all_depth_textures(struct r600_context *rctx)
{
r600_flush_depth_textures(rctx, &rctx->ps_samplers);
r600_flush_depth_textures(rctx, &rctx->vs_samplers);
}
static void r600_clear(struct pipe_context *ctx, unsigned buffers,
const union pipe_color_union *color,
double depth, unsigned stencil)

View File

@ -238,6 +238,7 @@ struct r600_textures_info {
struct r600_pipe_sampler_view *views[NUM_TEX_UNITS];
struct r600_pipe_sampler_state *samplers[NUM_TEX_UNITS];
unsigned n_views;
uint32_t depth_texture_mask; /* which textures are depth */
unsigned n_samplers;
bool samplers_dirty;
bool is_array_sampler[NUM_TEX_UNITS];
@ -329,7 +330,6 @@ struct r600_context {
struct u_upload_mgr *uploader;
struct util_slab_mempool pool_transfers;
boolean have_depth_texture;
unsigned default_ps_gprs, default_vs_gprs;
@ -451,8 +451,8 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
struct r600_resource_texture *staging,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer);
void r600_flush_all_depth_textures(struct r600_context *rctx);
void r600_flush_depth_textures(struct r600_context *rctx,
struct r600_textures_info *textures);
/* r600_buffer.c */
bool r600_init_resource(struct r600_screen *rscreen,
struct r600_resource *res,

View File

@ -475,8 +475,14 @@ void r600_set_sampler_views(struct r600_context *rctx,
}
if (rviews[i]) {
if (((struct r600_resource_texture *)rviews[i]->base.texture)->is_depth)
rctx->have_depth_texture = true;
struct r600_resource_texture *rtex =
(struct r600_resource_texture*)rviews[i]->base.texture;
if (rtex->is_depth && !rtex->is_flushing_texture) {
dst->depth_texture_mask |= 1 << i;
} else {
dst->depth_texture_mask &= ~(1 << i);
}
/* Changing from array to non-arrays textures and vice
* versa requires updating TEX_ARRAY_OVERRIDE on R6xx-R7xx. */
@ -489,6 +495,7 @@ void r600_set_sampler_views(struct r600_context *rctx,
set_resource(rctx, &rviews[i]->state, i + R600_MAX_CONST_BUFFERS);
} else {
set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS);
dst->depth_texture_mask &= ~(1 << i);
}
pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], views[i]);
@ -892,8 +899,12 @@ static void r600_update_derived_state(struct r600_context *rctx)
unsigned ps_dirty = 0;
if (!rctx->blitter->running) {
if (rctx->have_depth_texture) {
r600_flush_all_depth_textures(rctx);
/* Flush depth textures which need to be flushed. */
if (rctx->vs_samplers.depth_texture_mask) {
r600_flush_depth_textures(rctx, &rctx->vs_samplers);
}
if (rctx->ps_samplers.depth_texture_mask) {
r600_flush_depth_textures(rctx, &rctx->ps_samplers);
}
}