gallium/u_upload_mgr: allow drivers to specify pipe_resource::flags
authorMarek Olšák <marek.olsak@amd.com>
Fri, 1 Dec 2017 02:05:18 +0000 (03:05 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 5 Dec 2017 12:30:35 +0000 (13:30 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/util/u_upload_mgr.c
src/gallium/auxiliary/util/u_upload_mgr.h
src/gallium/drivers/freedreno/a3xx/fd3_context.c
src/gallium/drivers/freedreno/a4xx/fd4_context.c
src/gallium/drivers/freedreno/a5xx/fd5_context.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r600/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/svga/svga_context.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/virgl/virgl_context.c

index 4bb14d6218b31bf23b81ad640a0f4153e6a1d562..f703852be817cdea84a11a683b68d46f77570bd9 100644 (file)
@@ -44,6 +44,7 @@ struct u_upload_mgr {
    unsigned default_size;  /* Minimum size of the upload buffer, in bytes. */
    unsigned bind;          /* Bitmask of PIPE_BIND_* flags. */
    enum pipe_resource_usage usage;
+   unsigned flags;
    unsigned map_flags;     /* Bitmask of PIPE_TRANSFER_* flags. */
    boolean map_persistent; /* If persistent mappings are supported. */
 
@@ -57,7 +58,7 @@ struct u_upload_mgr {
 
 struct u_upload_mgr *
 u_upload_create(struct pipe_context *pipe, unsigned default_size,
-                unsigned bind, enum pipe_resource_usage usage)
+                unsigned bind, enum pipe_resource_usage usage, unsigned flags)
 {
    struct u_upload_mgr *upload = CALLOC_STRUCT(u_upload_mgr);
    if (!upload)
@@ -67,6 +68,7 @@ u_upload_create(struct pipe_context *pipe, unsigned default_size,
    upload->default_size = default_size;
    upload->bind = bind;
    upload->usage = usage;
+   upload->flags = flags;
 
    upload->map_persistent =
       pipe->screen->get_param(pipe->screen,
@@ -94,14 +96,14 @@ u_upload_create_default(struct pipe_context *pipe)
                           PIPE_BIND_VERTEX_BUFFER |
                           PIPE_BIND_INDEX_BUFFER |
                           PIPE_BIND_CONSTANT_BUFFER,
-                          PIPE_USAGE_STREAM);
+                          PIPE_USAGE_STREAM, 0);
 }
 
 struct u_upload_mgr *
 u_upload_clone(struct pipe_context *pipe, struct u_upload_mgr *upload)
 {
    return u_upload_create(pipe, upload->default_size, upload->bind,
-                          upload->usage);
+                          upload->usage, upload->flags);
 }
 
 static void
@@ -169,14 +171,15 @@ u_upload_alloc_buffer(struct u_upload_mgr *upload, unsigned min_size)
    buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
    buffer.bind = upload->bind;
    buffer.usage = upload->usage;
+   buffer.flags = upload->flags;
    buffer.width0 = size;
    buffer.height0 = 1;
    buffer.depth0 = 1;
    buffer.array_size = 1;
 
    if (upload->map_persistent) {
-      buffer.flags = PIPE_RESOURCE_FLAG_MAP_PERSISTENT |
-                     PIPE_RESOURCE_FLAG_MAP_COHERENT;
+      buffer.flags |= PIPE_RESOURCE_FLAG_MAP_PERSISTENT |
+                      PIPE_RESOURCE_FLAG_MAP_COHERENT;
    }
 
    upload->buffer = screen->resource_create(screen, &buffer);
index 536467eb35c696535aa9ea6154c8ea96cf88f53d..875fd9a7bb6cc4399e6ef36c5cee2ca20e4b9302 100644 (file)
@@ -52,7 +52,7 @@ extern "C" {
  */
 struct u_upload_mgr *
 u_upload_create(struct pipe_context *pipe, unsigned default_size,
-                unsigned bind, enum pipe_resource_usage usage);
+                unsigned bind, enum pipe_resource_usage usage, unsigned flags);
 
 /**
  * Create the default uploader for pipe_context. Only pipe_context::screen
index 476d06d43fff8de23c8d314db9158b7e711a283b..3623b9cf77305837d179342a60eb83f0abbd0b18 100644 (file)
@@ -114,7 +114,7 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
        fd3_query_context_init(pctx);
 
        fd3_ctx->border_color_uploader = u_upload_create(pctx, 4096, 0,
-                                                         PIPE_USAGE_STREAM);
+                                                         PIPE_USAGE_STREAM, 0);
 
        return pctx;
 }
index 82ba94a0895cf5aca0c38a69f876382ee37f7e17..1f5546d2368a1b9a324f6b65f7a760b931f09d55 100644 (file)
@@ -114,7 +114,7 @@ fd4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
        fd4_query_context_init(pctx);
 
        fd4_ctx->border_color_uploader = u_upload_create(pctx, 4096, 0,
-                                                         PIPE_USAGE_STREAM);
+                                                         PIPE_USAGE_STREAM, 0);
 
        return pctx;
 }
index 1d086338e9fb21a88ff46efc95370fa656aba5d1..4ebbb971ad8bf0e451ef8b9cba488d6a93b93df9 100644 (file)
@@ -114,7 +114,7 @@ fd5_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
        fd5_query_context_init(pctx);
 
        fd5_ctx->border_color_uploader = u_upload_create(pctx, 4096, 0,
-                                                         PIPE_USAGE_STREAM);
+                                                         PIPE_USAGE_STREAM, 0);
 
        return pctx;
 }
index b55fb63f000b589bbfc6adda832ffa7924ad029b..627ba0c57027fd6ffd5da2e2da8d9f1c04ead79d 100644 (file)
@@ -425,7 +425,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->context.create_video_buffer = vl_video_buffer_create;
 
     r300->uploader = u_upload_create(&r300->context, 1024 * 1024,
-                                     PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM);
+                                     PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM, 0);
     r300->context.stream_uploader = r300->uploader;
     r300->context.const_uploader = r300->uploader;
 
index d44860a2d715da8c43fec347f8971e15d6d841b2..d20d2f4bb043b0f635dd593e491f4d845063f459 100644 (file)
@@ -696,12 +696,12 @@ bool r600_common_context_init(struct r600_common_context *rctx,
                return false;
 
        rctx->b.stream_uploader = u_upload_create(&rctx->b, 1024 * 1024,
-                                                 0, PIPE_USAGE_STREAM);
+                                                 0, PIPE_USAGE_STREAM, 0);
        if (!rctx->b.stream_uploader)
                return false;
 
        rctx->b.const_uploader = u_upload_create(&rctx->b, 128 * 1024,
-                                                0, PIPE_USAGE_DEFAULT);
+                                                0, PIPE_USAGE_DEFAULT, 0);
        if (!rctx->b.const_uploader)
                return false;
 
index 7e7e42f3d6c4629af4219a9e4fd3ead7ad652b83..d85f9f0311032e695ec8bade4bf441b2065f21c4 100644 (file)
@@ -445,12 +445,12 @@ bool si_common_context_init(struct r600_common_context *rctx,
                return false;
 
        rctx->b.stream_uploader = u_upload_create(&rctx->b, 1024 * 1024,
-                                                 0, PIPE_USAGE_STREAM);
+                                                 0, PIPE_USAGE_STREAM, 0);
        if (!rctx->b.stream_uploader)
                return false;
 
        rctx->b.const_uploader = u_upload_create(&rctx->b, 128 * 1024,
-                                                0, PIPE_USAGE_DEFAULT);
+                                                0, PIPE_USAGE_DEFAULT, 0);
        if (!rctx->b.const_uploader)
                return false;
 
index 8640da95e82b9e7ec16db12bec5a7ed23c1e84b9..546b9f48b135575850b3a0fd3c1356f0507738e5 100644 (file)
@@ -144,13 +144,13 @@ svga_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
    svga->pipe.stream_uploader = u_upload_create(&svga->pipe, 1024 * 1024,
                                                 PIPE_BIND_VERTEX_BUFFER |
                                                 PIPE_BIND_INDEX_BUFFER,
-                                                PIPE_USAGE_STREAM);
+                                                PIPE_USAGE_STREAM, 0);
    if (!svga->pipe.stream_uploader)
       goto cleanup;
 
    svga->pipe.const_uploader = u_upload_create(&svga->pipe, 128 * 1024,
                                                PIPE_BIND_CONSTANT_BUFFER,
-                                               PIPE_USAGE_STREAM);
+                                               PIPE_USAGE_STREAM, 0);
    if (!svga->pipe.const_uploader)
       goto cleanup;
 
@@ -231,7 +231,7 @@ svga_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
    svga->const0_upload = u_upload_create(&svga->pipe,
                                          CONST0_UPLOAD_DEFAULT_SIZE,
                                          PIPE_BIND_CONSTANT_BUFFER,
-                                         PIPE_USAGE_STREAM);
+                                         PIPE_USAGE_STREAM, 0);
    if (!svga->const0_upload)
       goto cleanup;
 
index 9e4d6c9fb1847f0b13620fcca82decf840244480..71b8ebe7d4253b7fc87d1dc11018630c9993601d 100644 (file)
@@ -1332,7 +1332,7 @@ boolean
 svga_texture_transfer_map_upload_create(struct svga_context *svga)
 {
    svga->tex_upload = u_upload_create(&svga->pipe, TEX_UPLOAD_DEFAULT_SIZE,
-                                      0, PIPE_USAGE_STAGING);
+                                      0, PIPE_USAGE_STAGING, 0);
    return svga->tex_upload != NULL;
 }
 
index 232d2951c0b324163d9589bc1d177b4b02e641cf..f1b6ef45018e1e07c97d92c4f47f6a3a1d186b60 100644 (file)
@@ -938,7 +938,7 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
 
    vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask);
    vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024,
-                                     PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
+                                     PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM, 0);
    if (!vctx->uploader)
            goto fail;
    vctx->base.stream_uploader = vctx->uploader;