Revert "gallium: add flag PIPE_TRANSFER_MAP_PERMANENTLY"
[mesa.git] / src / gallium / drivers / r600 / r600_texture.c
index 90edabb719085458afe193e4d8400ba0babeaddf..a5a94d4aee6e22db42b3eda4598e045fbd73773e 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);
 }
 
@@ -489,13 +489,11 @@ static const struct u_resource_vtbl r600_texture_vtbl =
        r600_texture_get_transfer,      /* get_transfer */
        r600_texture_transfer_destroy,  /* transfer_destroy */
        r600_texture_transfer_map,      /* transfer_map */
-       u_default_transfer_flush_region,/* transfer_flush_region */
+       NULL,                           /* transfer_flush_region */
        r600_texture_transfer_unmap,    /* transfer_unmap */
-       u_default_transfer_inline_write /* transfer_inline_write */
+       NULL                            /* transfer_inline_write */
 };
 
-DEBUG_GET_ONCE_BOOL_OPTION(use_surface, "R600_SURF", TRUE);
-
 static struct r600_resource_texture *
 r600_texture_create_object(struct pipe_screen *screen,
                           const struct pipe_resource *base,
@@ -511,13 +509,6 @@ r600_texture_create_object(struct pipe_screen *screen,
        struct r600_screen *rscreen = (struct r600_screen*)screen;
        int r;
 
-       /* FIXME ugly temporary hack to allow to switch btw current code
-        * and common surface allocator code
-        */
-       if (debug_get_option_use_surface()) {
-               rscreen->use_surface = 1;
-       }
-
        rtex = CALLOC_STRUCT(r600_resource_texture);
        if (rtex == NULL)
                return NULL;
@@ -534,7 +525,7 @@ r600_texture_create_object(struct pipe_screen *screen,
        if (!(base->flags & R600_RESOURCE_FLAG_TRANSFER) &&
            ((struct r600_screen*)screen)->chip_class >= EVERGREEN &&
            util_format_is_depth_and_stencil(base->format) &&
-           !rscreen->use_surface) {
+           !rscreen->use_surface_alloc) {
                struct pipe_resource stencil;
                unsigned stencil_pitch_override = 0;
 
@@ -579,7 +570,7 @@ r600_texture_create_object(struct pipe_screen *screen,
                rtex->is_depth = true;
 
        r600_setup_miptree(screen, rtex, array_mode);
-       if (rscreen->use_surface) {
+       if (rscreen->use_surface_alloc) {
                rtex->surface = *surface;
                r = r600_setup_surface(screen, rtex, array_mode, pitch_in_bytes_override);
                if (r) {
@@ -606,7 +597,7 @@ r600_texture_create_object(struct pipe_screen *screen,
                struct pipe_resource *ptex = &rtex->resource.b.b.b;
                unsigned base_align = r600_get_base_alignment(screen, ptex->format, array_mode);
 
-               if (rscreen->use_surface) {
+               if (rscreen->use_surface_alloc) {
                        base_align = rtex->surface.bo_alignment;
                } else if (util_format_is_depth_or_stencil(rtex->real_format)) {
                        /* ugly work around depth buffer need stencil room at end of bo */
@@ -641,7 +632,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
 
        if (!(templ->flags & R600_RESOURCE_FLAG_TRANSFER) &&
            !(templ->bind & PIPE_BIND_SCANOUT)) {
-               if (rscreen->use_surface) {
+               if (rscreen->use_surface_alloc) {
                        if (permit_hardware_blit(screen, templ)) {
                                array_mode = V_038000_ARRAY_2D_TILED_THIN1;
                        }
@@ -799,10 +790,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
        int r;
        boolean use_staging_texture = FALSE;
 
-       if (usage & PIPE_TRANSFER_MAP_PERMANENTLY) {
-          return NULL;
-       }
-
        /* We cannot map a tiled texture directly because the data is
         * in a different order, therefore we do detiling using a blit.
         *
@@ -874,8 +861,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);
@@ -883,7 +870,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. */
@@ -904,11 +891,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) {
@@ -930,8 +917,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;
 
@@ -959,8 +946,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;