virgl: Store mapped hw resource with transfer object.
authorDavid Riley <davidriley@chromium.org>
Wed, 1 May 2019 00:33:59 +0000 (17:33 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Wed, 1 May 2019 22:48:28 +0000 (15:48 -0700)
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_texture.c

index fd00b1748c44b46c9a4b28eca3025c790f871a68..42434752d53a031c59b69121880cc50a5696b5fb 100644 (file)
@@ -38,7 +38,6 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    struct virgl_screen *vs = virgl_screen(ctx->screen);
    struct virgl_resource *vbuf = virgl_resource(resource);
    struct virgl_transfer *trans;
-   void *ptr;
    bool readback;
    bool flush = false;
 
@@ -60,14 +59,14 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    if (readback || flush)
       vs->vws->resource_wait(vs->vws, vbuf->hw_res);
 
-   ptr = vs->vws->resource_map(vs->vws, vbuf->hw_res);
-   if (!ptr) {
+   trans->hw_res_map = vs->vws->resource_map(vs->vws, vbuf->hw_res);
+   if (!trans->hw_res_map) {
       virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
       return NULL;
    }
 
    *transfer = &trans->base;
-   return ptr + trans->offset;
+   return trans->hw_res_map + trans->offset;
 }
 
 static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
index abe8578bd231a553b3bb407f94f0a64298a1ad84..380e145564a6466d25b373c31d102280d428f0f4 100644 (file)
@@ -58,6 +58,7 @@ struct virgl_transfer {
    struct util_range range;
    struct list_head queue_link;
    struct pipe_transfer *resolve_transfer;
+   void *hw_res_map;
 };
 
 void virgl_resource_destroy(struct pipe_screen *screen,
index deb637ee58e86256e886f390b7398fe6127ef801..19ae6ff1d3aeafe7c3db192499eb8bf31f19ce33 100644 (file)
@@ -146,14 +146,14 @@ static void *texture_transfer_map_plain(struct pipe_context *ctx,
    if (readback || flush)
       vws->resource_wait(vws, vtex->hw_res);
 
-   void *ptr = vws->resource_map(vws, vtex->hw_res);
-   if (!ptr) {
+   trans->hw_res_map = vws->resource_map(vws, vtex->hw_res);
+   if (!trans->hw_res_map) {
       virgl_resource_destroy_transfer(&vctx->transfer_pool, trans);
       return NULL;
    }
 
    *transfer = &trans->base;
-   return ptr + trans->offset;
+   return trans->hw_res_map + trans->offset;
 }
 
 static void *texture_transfer_map_resolve(struct pipe_context *ctx,