diff options
author | Marek Olšák <[email protected]> | 2017-02-15 20:55:15 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-02-18 01:22:08 +0100 |
commit | 22c34bbc55a4f2db956780221b251731885cd162 (patch) | |
tree | 4f5257cfc1e852c92a6aca89118c998bcfef921f | |
parent | edf6bcf6c633c74f7df6a716ae9ac0d7de054766 (diff) |
gallium/u_suballoc: allow setting pipe_resource::flags
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/util/u_suballoc.c | 22 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_suballoc.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/r600_pipe_common.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 2 |
5 files changed, 24 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/util/u_suballoc.c b/src/gallium/auxiliary/util/u_suballoc.c index 8c463c9fdd0..392bba7d6dd 100644 --- a/src/gallium/auxiliary/util/u_suballoc.c +++ b/src/gallium/auxiliary/util/u_suballoc.c @@ -43,6 +43,7 @@ struct u_suballocator { unsigned size; /* Size of the whole buffer, in bytes. */ unsigned bind; /* Bitmask of PIPE_BIND_* flags. */ enum pipe_resource_usage usage; + unsigned flags; /* pipe_resource::flags */ boolean zero_buffer_memory; /* If the buffer contents should be zeroed. */ struct pipe_resource *buffer; /* The buffer we suballocate from. */ @@ -58,7 +59,7 @@ struct u_suballocator { */ struct u_suballocator * u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind, - enum pipe_resource_usage usage, + enum pipe_resource_usage usage, unsigned flags, boolean zero_buffer_memory) { struct u_suballocator *allocator = CALLOC_STRUCT(u_suballocator); @@ -69,6 +70,7 @@ u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind, allocator->size = size; allocator->bind = bind; allocator->usage = usage; + allocator->flags = flags; allocator->zero_buffer_memory = zero_buffer_memory; return allocator; } @@ -97,9 +99,21 @@ u_suballocator_alloc(struct u_suballocator *allocator, unsigned size, /* Allocate a new buffer. */ pipe_resource_reference(&allocator->buffer, NULL); allocator->offset = 0; - allocator->buffer = - pipe_buffer_create(allocator->pipe->screen, allocator->bind, - allocator->usage, allocator->size); + + struct pipe_resource templ; + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_BUFFER; + templ.format = PIPE_FORMAT_R8_UNORM; + templ.bind = allocator->bind; + templ.usage = allocator->usage; + templ.flags = allocator->flags; + templ.width0 = allocator->size; + templ.height0 = 1; + templ.depth0 = 1; + templ.array_size = 1; + + struct pipe_screen *screen = allocator->pipe->screen; + allocator->buffer = screen->resource_create(screen, &templ); if (!allocator->buffer) goto fail; diff --git a/src/gallium/auxiliary/util/u_suballoc.h b/src/gallium/auxiliary/util/u_suballoc.h index fb08f16fe40..e35382f0437 100644 --- a/src/gallium/auxiliary/util/u_suballoc.h +++ b/src/gallium/auxiliary/util/u_suballoc.h @@ -35,7 +35,7 @@ struct u_suballocator; struct u_suballocator * u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind, - enum pipe_resource_usage usage, + enum pipe_resource_usage usage, unsigned flags, boolean zero_buffer_memory); void diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 5290f40d6cb..1803c265b9e 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -188,8 +188,9 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, r600_context_gfx_flush, rctx); rctx->b.gfx.flush = r600_context_gfx_flush; - rctx->allocator_fetch_shader = u_suballocator_create(&rctx->b.b, 64 * 1024, - 0, PIPE_USAGE_DEFAULT, FALSE); + rctx->allocator_fetch_shader = + u_suballocator_create(&rctx->b.b, 64 * 1024, + 0, PIPE_USAGE_DEFAULT, 0, FALSE); if (!rctx->allocator_fetch_shader) goto fail; diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 53d3dc6935d..8405c5e80f9 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -598,7 +598,7 @@ bool r600_common_context_init(struct r600_common_context *rctx, rctx->allocator_zeroed_memory = u_suballocator_create(&rctx->b, rscreen->info.gart_page_size, - 0, PIPE_USAGE_DEFAULT, true); + 0, PIPE_USAGE_DEFAULT, 0, true); if (!rctx->allocator_zeroed_memory) return false; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 880602745c3..2dc884a63cd 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -205,7 +205,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, sctx->ce_suballocator = u_suballocator_create(&sctx->b.b, 1024 * 1024, - 0, PIPE_USAGE_DEFAULT, false); + 0, PIPE_USAGE_DEFAULT, 0, false); if (!sctx->ce_suballocator) goto fail; } |