summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-12-01 03:05:18 +0100
committerMarek Olšák <[email protected]>2017-12-05 13:30:35 +0100
commitdbad0acfaf2930648d85b49f9795c36e077888f8 (patch)
tree6a373b731c3db7a85102bce1338186144e575a3c /src/gallium/auxiliary/util
parentc7f84f6513f9cc9502b9cf3bdca9b95a6b87c98b (diff)
gallium/u_upload_mgr: allow drivers to specify pipe_resource::flags
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c13
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index 4bb14d6218b..f703852be81 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -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);
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h
index 536467eb35c..875fd9a7bb6 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -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