r600g: implement 3D transfers
That means we can map and read multiple slices with one transfer_map call.
This commit is contained in:
@@ -70,7 +70,7 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
|
|||||||
struct pipe_resource *texture = transfer->resource;
|
struct pipe_resource *texture = transfer->resource;
|
||||||
struct pipe_box sbox;
|
struct pipe_box sbox;
|
||||||
|
|
||||||
u_box_origin_2d(transfer->box.width, transfer->box.height, &sbox);
|
u_box_3d(0, 0, 0, transfer->box.width, transfer->box.height, transfer->box.depth, &sbox);
|
||||||
|
|
||||||
ctx->resource_copy_region(ctx, texture, transfer->level,
|
ctx->resource_copy_region(ctx, texture, transfer->level,
|
||||||
transfer->box.x, transfer->box.y, transfer->box.z,
|
transfer->box.x, transfer->box.y, transfer->box.z,
|
||||||
@@ -722,7 +722,6 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
|
|||||||
{
|
{
|
||||||
struct r600_context *rctx = (struct r600_context*)ctx;
|
struct r600_context *rctx = (struct r600_context*)ctx;
|
||||||
struct r600_texture *rtex = (struct r600_texture*)texture;
|
struct r600_texture *rtex = (struct r600_texture*)texture;
|
||||||
struct pipe_resource resource;
|
|
||||||
struct r600_transfer *trans;
|
struct r600_transfer *trans;
|
||||||
boolean use_staging_texture = FALSE;
|
boolean use_staging_texture = FALSE;
|
||||||
enum pipe_format format = texture->format;
|
enum pipe_format format = texture->format;
|
||||||
@@ -793,40 +792,51 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
|
|||||||
0, 0);
|
0, 0);
|
||||||
|
|
||||||
trans->transfer.stride = staging_depth->surface.level[level].pitch_bytes;
|
trans->transfer.stride = staging_depth->surface.level[level].pitch_bytes;
|
||||||
|
trans->transfer.layer_stride = staging_depth->surface.level[level].slice_size;
|
||||||
trans->offset = r600_texture_get_offset(staging_depth, level, box->z);
|
trans->offset = r600_texture_get_offset(staging_depth, level, box->z);
|
||||||
trans->staging = (struct r600_resource*)staging_depth;
|
trans->staging = (struct r600_resource*)staging_depth;
|
||||||
} else if (use_staging_texture) {
|
} else if (use_staging_texture) {
|
||||||
resource.target = PIPE_TEXTURE_2D;
|
struct pipe_resource resource;
|
||||||
|
struct r600_texture *staging;
|
||||||
|
|
||||||
|
memset(&resource, 0, sizeof(resource));
|
||||||
resource.format = texture->format;
|
resource.format = texture->format;
|
||||||
resource.width0 = box->width;
|
resource.width0 = box->width;
|
||||||
resource.height0 = box->height;
|
resource.height0 = box->height;
|
||||||
resource.depth0 = 1;
|
resource.depth0 = 1;
|
||||||
resource.array_size = 1;
|
resource.array_size = 1;
|
||||||
resource.last_level = 0;
|
|
||||||
resource.nr_samples = 0;
|
|
||||||
resource.usage = PIPE_USAGE_STAGING;
|
resource.usage = PIPE_USAGE_STAGING;
|
||||||
resource.bind = 0;
|
|
||||||
resource.flags = R600_RESOURCE_FLAG_TRANSFER;
|
resource.flags = R600_RESOURCE_FLAG_TRANSFER;
|
||||||
/* For texture reading, the temporary (detiled) texture is used as
|
|
||||||
* a render target when blitting from a tiled texture. */
|
/* We must set the correct texture target and dimensions if needed for a 3D transfer. */
|
||||||
if (usage & PIPE_TRANSFER_READ) {
|
if (box->depth > 1 && u_max_layer(texture, level) > 0)
|
||||||
resource.bind |= PIPE_BIND_RENDER_TARGET;
|
resource.target = texture->target;
|
||||||
}
|
else
|
||||||
/* For texture writing, the temporary texture is used as a sampler
|
resource.target = PIPE_TEXTURE_2D;
|
||||||
* when blitting into a tiled texture. */
|
|
||||||
if (usage & PIPE_TRANSFER_WRITE) {
|
switch (resource.target) {
|
||||||
resource.bind |= PIPE_BIND_SAMPLER_VIEW;
|
case PIPE_TEXTURE_1D_ARRAY:
|
||||||
|
case PIPE_TEXTURE_2D_ARRAY:
|
||||||
|
case PIPE_TEXTURE_CUBE_ARRAY:
|
||||||
|
resource.array_size = box->depth;
|
||||||
|
break;
|
||||||
|
case PIPE_TEXTURE_3D:
|
||||||
|
resource.depth0 = box->depth;
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create the temporary texture. */
|
/* Create the temporary texture. */
|
||||||
trans->staging = (struct r600_resource*)ctx->screen->resource_create(ctx->screen, &resource);
|
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
|
||||||
if (trans->staging == NULL) {
|
if (staging == NULL) {
|
||||||
R600_ERR("failed to create temporary texture to hold untiled copy\n");
|
R600_ERR("failed to create temporary texture to hold untiled copy\n");
|
||||||
FREE(trans);
|
FREE(trans);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
trans->staging = &staging->resource;
|
||||||
trans->transfer.stride =
|
trans->transfer.stride = staging->surface.level[0].pitch_bytes;
|
||||||
((struct r600_texture *)trans->staging)->surface.level[0].pitch_bytes;
|
trans->transfer.layer_stride = staging->surface.level[0].slice_size;
|
||||||
if (usage & PIPE_TRANSFER_READ) {
|
if (usage & PIPE_TRANSFER_READ) {
|
||||||
r600_copy_to_staging_texture(ctx, trans);
|
r600_copy_to_staging_texture(ctx, trans);
|
||||||
/* Always referenced in the blit. */
|
/* Always referenced in the blit. */
|
||||||
@@ -839,9 +849,9 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trans->staging) {
|
if (trans->staging) {
|
||||||
buf = ((struct r600_resource *)trans->staging)->cs_buf;
|
buf = trans->staging->cs_buf;
|
||||||
} else {
|
} else {
|
||||||
buf = ((struct r600_resource *)texture)->cs_buf;
|
buf = rtex->resource.cs_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtex->is_depth || !trans->staging)
|
if (rtex->is_depth || !trans->staging)
|
||||||
|
Reference in New Issue
Block a user