r600g: cleanup r600_transfer_struct
authorMarek Olšák <maraeo@gmail.com>
Sun, 26 Feb 2012 18:44:45 +0000 (19:44 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 27 Feb 2012 01:03:24 +0000 (02:03 +0100)
Especially rename staging_texture to staging and change its type
to r600_resource. I will reuse it for buffers later.

src/gallium/drivers/r600/r600_resource.h
src/gallium/drivers/r600/r600_texture.c

index a53ecb8d37d25755e588d490e6ee154dd2c26858..425222381d375de682046aded2eb0286c967d15d 100644 (file)
 /* flag to indicate a resource is to be used as a transfer so should not be tiled */
 #define R600_RESOURCE_FLAG_TRANSFER     PIPE_RESOURCE_FLAG_DRV_PRIV
 
-/* Texture transfer. */
 struct r600_transfer {
-       /* Base class. */
        struct pipe_transfer            transfer;
-       /* Buffer transfer. */
-       struct pipe_transfer            *buffer_transfer;
+       struct r600_resource            *staging;
        unsigned                        offset;
-       struct pipe_resource            *staging_texture;
 };
 
 struct r600_resource_texture {
index 54d7c91b5c91c2eb95a17ee08f454f49da5cd55f..4687f7ef3c189a4092209a8672a5cae1521a4670 100644 (file)
@@ -43,7 +43,7 @@ static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct r600_t
        struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer;
        struct pipe_resource *texture = transfer->resource;
 
-       ctx->resource_copy_region(ctx, rtransfer->staging_texture,
+       ctx->resource_copy_region(ctx, &rtransfer->staging->b.b.b,
                                0, 0, 0, 0, texture, transfer->level,
                                &transfer->box);
 }
@@ -63,7 +63,7 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
        sbox.depth = 1;
        ctx->resource_copy_region(ctx, texture, transfer->level,
                                  transfer->box.x, transfer->box.y, transfer->box.z,
-                                 rtransfer->staging_texture,
+                                 &rtransfer->staging->b.b.b,
                                  0, &sbox);
 }
 
@@ -865,8 +865,8 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
                        resource.bind |= PIPE_BIND_SAMPLER_VIEW;
                }
                /* Create the temporary texture. */
-               trans->staging_texture = ctx->screen->resource_create(ctx->screen, &resource);
-               if (trans->staging_texture == NULL) {
+               trans->staging = (struct r600_resource*)ctx->screen->resource_create(ctx->screen, &resource);
+               if (trans->staging == NULL) {
                        R600_ERR("failed to create temporary texture to hold untiled copy\n");
                        pipe_resource_reference(&trans->transfer.resource, NULL);
                        FREE(trans);
@@ -874,7 +874,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
                }
 
                trans->transfer.stride =
-                       ((struct r600_resource_texture *)trans->staging_texture)->pitch_in_bytes[0];
+                       ((struct r600_resource_texture *)trans->staging)->pitch_in_bytes[0];
                if (usage & PIPE_TRANSFER_READ) {
                        r600_copy_to_staging_texture(ctx, trans);
                        /* Always referenced in the blit. */
@@ -895,11 +895,11 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
        struct pipe_resource *texture = transfer->resource;
        struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
 
-       if (rtransfer->staging_texture) {
+       if (rtransfer->staging) {
                if (transfer->usage & PIPE_TRANSFER_WRITE) {
                        r600_copy_from_staging_texture(ctx, rtransfer);
                }
-               pipe_resource_reference(&rtransfer->staging_texture, NULL);
+               pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
        }
 
        if (rtex->is_depth && !rtex->is_flushing_texture) {
@@ -921,8 +921,8 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
        unsigned offset = 0;
        char *map;
 
-       if (rtransfer->staging_texture) {
-               buf = ((struct r600_resource *)rtransfer->staging_texture)->buf;
+       if (rtransfer->staging) {
+               buf = ((struct r600_resource *)rtransfer->staging)->buf;
        } else {
                struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
 
@@ -950,8 +950,8 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx,
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct pb_buffer *buf;
 
-       if (rtransfer->staging_texture) {
-               buf = ((struct r600_resource *)rtransfer->staging_texture)->buf;
+       if (rtransfer->staging) {
+               buf = ((struct r600_resource *)rtransfer->staging)->buf;
        } else {
                struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;