}
if (tmp->is_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;
+ }
}
endian = r600_colorformat_endian_swap(format);
rctx->have_depth_fb = TRUE;
if (rtex->is_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);
}
/* XXX quite sure for dx10+ hw don't need any offset hacks */
return (struct r600_resource*)r;
}
-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);
/* r600_texture.c texture transfer functions. */
struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
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:
*/
r600_blit_uncompress_depth(ctx, rtex);
- return 0;
}
/* Needs adjustment for pixelformat:
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;
/* We cannot map a tiled texture directly because the data is
*/
/* 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);