r600_blitter_end(ctx);
}
-
-
-/* Copy a block of pixels from one surface to another using HW. */
-static void r600_hw_copy_region(struct pipe_context *ctx,
- struct pipe_resource *dst,
- unsigned dst_level,
- unsigned dstx, unsigned dsty, unsigned dstz,
- struct pipe_resource *src,
- unsigned src_level,
- const struct pipe_box *src_box)
-{
- struct r600_context *rctx = (struct r600_context *)ctx;
-
- r600_blitter_begin(ctx, R600_COPY);
- util_blitter_copy_texture(rctx->blitter, dst, dst_level, dstx, dsty, dstz,
- src, src_level, src_box, PIPE_MASK_RGBAZS, TRUE);
- r600_blitter_end(ctx);
-}
-
struct texture_orig_info {
unsigned format;
unsigned width0;
unsigned src_level,
const struct pipe_box *src_box)
{
+ struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_resource_texture *rsrc = (struct r600_resource_texture*)src;
struct texture_orig_info orig_info[2];
struct pipe_box sbox;
}
if (rsrc->depth && !rsrc->is_flushing_texture)
- r600_texture_depth_flush(ctx, src, FALSE);
+ r600_texture_depth_flush(ctx, src);
restore_orig[0] = restore_orig[1] = FALSE;
dsty = util_format_get_nblocksy(orig_info[1].format, dsty);
}
- r600_hw_copy_region(ctx, dst, dst_level, dstx, dsty, dstz,
- src, src_level, psbox);
+ r600_blitter_begin(ctx, R600_COPY);
+ util_blitter_copy_texture(rctx->blitter, dst, dst_level, dstx, dsty, dstz,
+ src, src_level, psbox, PIPE_MASK_RGBAZS, TRUE);
+ r600_blitter_end(ctx);
if (restore_orig[0])
r600_reset_blittable_to_compressed(src, src_level, &orig_info[0]);
}
if (rsrc->depth && !rsrc->is_flushing_texture)
- r600_texture_depth_flush(ctx, info->src.resource, FALSE);
+ r600_texture_depth_flush(ctx, info->src.resource);
r600_blitter_begin(ctx, R600_BLIT);
util_blitter_blit(rctx->blitter, info);
rctx->context.resource_copy_region = r600_resource_copy_region;
rctx->context.blit = si_blit;
}
-
-void r600_blit_push_depth(struct pipe_context *ctx, struct r600_resource_texture *texture)
-{
- struct pipe_box sbox;
-
- sbox.x = sbox.y = sbox.z = 0;
- sbox.width = texture->resource.b.b.width0;
- sbox.height = texture->resource.b.b.height0;
- /* XXX that might be wrong */
- sbox.depth = 1;
-
- r600_hw_copy_region(ctx, (struct pipe_resource *)texture, 0,
- 0, 0, 0,
- (struct pipe_resource *)texture->flushed_depth_texture, 0,
- &sbox);
-}
const struct pipe_resource *base,
struct winsys_handle *whandle);
-int r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture, boolean just_create);
+void r600_init_flushed_depth_texture(struct pipe_context *ctx,
+ struct pipe_resource *texture);
+void r600_texture_depth_flush(struct pipe_context *ctx,
+ struct pipe_resource *texture);
struct r600_context;
struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
struct pipe_resource resource;
struct r600_transfer *trans;
- int r;
boolean use_staging_texture = FALSE;
struct radeon_winsys_cs_handle *buf;
enum pipe_format format = texture->format;
*/
/* XXX: when discard is true, no need to read back from depth texture
*/
- r = r600_texture_depth_flush(ctx, texture, FALSE);
- if (r < 0) {
+ r600_texture_depth_flush(ctx, texture);
+ if (!rtex->flushed_depth_texture) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
pipe_resource_reference(&trans->transfer.resource, NULL);
FREE(trans);
}
if (rtex->depth && !rtex->is_flushing_texture) {
- if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture)
- r600_blit_push_depth(ctx, rtex);
+ if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture) {
+ struct pipe_box sbox;
+
+ sbox.x = sbox.y = sbox.z = 0;
+ sbox.width = texture->width0;
+ sbox.height = texture->height0;
+ /* XXX that might be wrong */
+ sbox.depth = 1;
+
+ ctx->resource_copy_region(ctx, texture, 0, 0, 0, 0,
+ &rtex->flushed_depth_texture->resource.b.b, 0,
+ &sbox);
+ }
}
pipe_resource_reference(&transfer->resource, NULL);
stride, 0, buf, FALSE, &surface);
}
-int r600_texture_depth_flush(struct pipe_context *ctx,
- struct pipe_resource *texture, boolean just_create)
+void r600_init_flushed_depth_texture(struct pipe_context *ctx,
+ struct pipe_resource *texture)
{
struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
struct pipe_resource resource;
if (rtex->flushed_depth_texture)
- goto out;
+ return; /* it's ready */
resource.target = texture->target;
resource.format = texture->format;
rtex->flushed_depth_texture = (struct r600_resource_texture *)ctx->screen->resource_create(ctx->screen, &resource);
if (rtex->flushed_depth_texture == NULL) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- return -ENOMEM;
+ return;
}
((struct r600_resource_texture *)rtex->flushed_depth_texture)->is_flushing_texture = TRUE;
-out:
- if (just_create)
- return 0;
+}
+
+void r600_texture_depth_flush(struct pipe_context *ctx,
+ struct pipe_resource *texture)
+{
+ struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
+
+ r600_init_flushed_depth_texture(ctx, texture);
+
+ if (!rtex->flushed_depth_texture)
+ return; /* error */
/* XXX: only do this if the depth texture has actually changed:
*/
si_blit_uncompress_depth(ctx, rtex);
- return 0;
}
void si_init_surface_functions(struct r600_context *r600)
/* r600_blit.c */
void si_init_blit_functions(struct r600_context *rctx);
void si_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_texture *texture);
-void r600_blit_push_depth(struct pipe_context *ctx, struct r600_resource_texture *texture);
void si_flush_depth_textures(struct r600_context *rctx);
/* r600_buffer.c */
rctx->have_depth_fb = TRUE;
if (rtex->depth && !rtex->is_flushing_texture) {
- r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
+ r600_init_flushed_depth_texture(&rctx->context, state->cbufs[cb]->texture);
rtex = rtex->flushed_depth_texture;
+ assert(rtex);
}
offset = rtex->surface.level[level].offset;
}
if (tmp->depth && !tmp->is_flushing_texture) {
- r600_texture_depth_flush(ctx, texture, TRUE);
+ r600_init_flushed_depth_texture(ctx, texture);
tmp = tmp->flushed_depth_texture;
+ if (!tmp) {
+ FREE(view);
+ return NULL;
+ }
texture = &tmp->resource.b.b;
}