mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
r600g: Update the flushed depth texture after drawing to the corresponding texture.
I know Jerome will probably rewrite the way depth textures work sometime soon. For the time being this should at least make common depth texture usage for shadowing work properly though.
This commit is contained in:
parent
3f0a966807
commit
38b54158b6
5 changed files with 42 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op
|
|||
{
|
||||
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
|
||||
|
||||
rctx->blit = true;
|
||||
r600_context_queries_suspend(&rctx->ctx);
|
||||
|
||||
util_blitter_save_blend(rctx->blitter, rctx->states[R600_PIPE_STATE_BLEND]);
|
||||
|
|
@ -74,6 +75,7 @@ static void r600_blitter_end(struct pipe_context *ctx)
|
|||
{
|
||||
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
|
||||
r600_context_queries_resume(&rctx->ctx);
|
||||
rctx->blit = false;
|
||||
}
|
||||
|
||||
void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_texture *texture)
|
||||
|
|
@ -82,6 +84,9 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_t
|
|||
struct pipe_surface *zsurf, *cbsurf, surf_tmpl;
|
||||
int level = 0;
|
||||
float depth = 1.0f;
|
||||
|
||||
if (texture->flushed) return;
|
||||
|
||||
surf_tmpl.format = texture->resource.base.b.format;
|
||||
surf_tmpl.u.tex.level = level;
|
||||
surf_tmpl.u.tex.first_layer = 0;
|
||||
|
|
@ -102,11 +107,34 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_t
|
|||
r600_blitter_begin(ctx, R600_CLEAR_SURFACE);
|
||||
util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, rctx->custom_dsa_flush, depth);
|
||||
r600_blitter_end(ctx);
|
||||
texture->flushed = true;
|
||||
|
||||
pipe_surface_reference(&zsurf, NULL);
|
||||
pipe_surface_reference(&cbsurf, NULL);
|
||||
}
|
||||
|
||||
void r600_flush_depth_textures(struct r600_pipe_context *rctx)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (rctx->blit) return;
|
||||
|
||||
/* FIXME: This handles fragment shader textures only. */
|
||||
|
||||
for (i = 0; i < rctx->ps_samplers.n_views; ++i) {
|
||||
struct r600_pipe_sampler_view *view;
|
||||
struct r600_resource_texture *tex;
|
||||
|
||||
view = rctx->ps_samplers.views[i];
|
||||
if (!view) continue;
|
||||
|
||||
tex = (struct r600_resource_texture *)view->base.texture;
|
||||
if (!tex->depth) continue;
|
||||
|
||||
r600_blit_uncompress_depth(&rctx->context, tex);
|
||||
}
|
||||
}
|
||||
|
||||
static void r600_clear(struct pipe_context *ctx, unsigned buffers,
|
||||
const float *rgba, double depth, unsigned stencil)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ struct r600_pipe_context {
|
|||
unsigned vb_max_index;
|
||||
struct r600_translate_context tran;
|
||||
struct u_upload_mgr *upload_const;
|
||||
bool blit;
|
||||
};
|
||||
|
||||
struct r600_drawl {
|
||||
|
|
@ -197,6 +198,7 @@ void evergreen_pipe_add_vertex_attrib(struct r600_pipe_context *rctx,
|
|||
/* r600_blit.c */
|
||||
void r600_init_blit_functions(struct r600_pipe_context *rctx);
|
||||
void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_texture *texture);
|
||||
void r600_flush_depth_textures(struct r600_pipe_context *rctx);
|
||||
|
||||
/* r600_buffer.c */
|
||||
struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ struct r600_resource_texture {
|
|||
unsigned depth;
|
||||
unsigned dirty;
|
||||
struct r600_resource_texture *flushed_depth_texture;
|
||||
bool flushed;
|
||||
};
|
||||
|
||||
#define R600_BUFFER_MAGIC 0xabcd1600
|
||||
|
|
|
|||
|
|
@ -496,6 +496,8 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
|
|||
struct r600_drawl draw = {};
|
||||
unsigned prim;
|
||||
|
||||
r600_flush_depth_textures(rctx);
|
||||
|
||||
if (rctx->vertex_elements->incompatible_layout) {
|
||||
r600_begin_vertex_translate(rctx, info->min_index, info->max_index);
|
||||
}
|
||||
|
|
@ -597,6 +599,12 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
|
|||
r600_context_draw(&rctx->ctx, &rdraw);
|
||||
}
|
||||
|
||||
if (rctx->framebuffer.zsbuf)
|
||||
{
|
||||
struct pipe_resource *tex = rctx->framebuffer.zsbuf->texture;
|
||||
((struct r600_resource_texture *)tex)->flushed = false;
|
||||
}
|
||||
|
||||
pipe_resource_reference(&draw.index_buffer, NULL);
|
||||
|
||||
/* delete previous translated vertex elements */
|
||||
|
|
|
|||
|
|
@ -302,6 +302,9 @@ r600_texture_create_object(struct pipe_screen *screen,
|
|||
resource->bo = bo;
|
||||
rtex->pitch_override = pitch_in_bytes_override;
|
||||
|
||||
if (util_format_is_depth_or_stencil(base->format))
|
||||
rtex->depth = 1;
|
||||
|
||||
if (array_mode)
|
||||
rtex->tiled = 1;
|
||||
r600_setup_miptree(screen, rtex, array_mode);
|
||||
|
|
@ -632,7 +635,6 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
|
|||
struct pipe_transfer *transfer)
|
||||
{
|
||||
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
|
||||
struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
|
||||
|
||||
if (rtransfer->staging_texture) {
|
||||
if (transfer->usage & PIPE_TRANSFER_WRITE) {
|
||||
|
|
@ -640,9 +642,6 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
|
|||
}
|
||||
pipe_resource_reference(&rtransfer->staging_texture, NULL);
|
||||
}
|
||||
if (rtex->flushed_depth_texture) {
|
||||
pipe_resource_reference((struct pipe_resource **)&rtex->flushed_depth_texture, NULL);
|
||||
}
|
||||
pipe_resource_reference(&transfer->resource, NULL);
|
||||
FREE(transfer);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue