diff options
author | Charmaine Lee <[email protected]> | 2016-11-11 14:40:57 -0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2017-06-27 07:49:02 -0600 |
commit | 4a79b508a4a7cd608059dd30461e086651ae48b5 (patch) | |
tree | 67d22468579479a0ca24956de50a7d67eff2065a /src | |
parent | ce608784d0739170642d771f2edcd747787040cb (diff) |
svga: pass bind_flags to surface create functions
This is to prepare for other bind_flags optimization
in subsequent patches.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer_upload.c | 34 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer_upload.h | 6 |
3 files changed, 34 insertions, 26 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index 271d0787abb..9895719c9c3 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -224,7 +224,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe, } if (!sbuf->swbuf && !svga_buffer_has_hw_storage(sbuf)) { - if (svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) { + if (svga_buffer_create_hw_storage(ss, sbuf, sbuf->bind_flags) != PIPE_OK) { /* * We can't create a hardware buffer big enough, so create a malloc * buffer instead. @@ -399,6 +399,7 @@ svga_buffer_create(struct pipe_screen *screen, { struct svga_screen *ss = svga_screen(screen); struct svga_buffer *sbuf; + unsigned bind_flags; SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_CREATEBUFFER); @@ -410,21 +411,21 @@ svga_buffer_create(struct pipe_screen *screen, sbuf->b.vtbl = &svga_buffer_vtbl; pipe_reference_init(&sbuf->b.b.reference, 1); sbuf->b.b.screen = screen; - sbuf->bind_flags = template->bind; + bind_flags = template->bind; - if (template->bind & PIPE_BIND_CONSTANT_BUFFER) { + if (bind_flags & PIPE_BIND_CONSTANT_BUFFER) { /* Constant buffers can only have the PIPE_BIND_CONSTANT_BUFFER * flag set. */ if (ss->sws->have_vgpu10) { - sbuf->bind_flags = PIPE_BIND_CONSTANT_BUFFER; + bind_flags = PIPE_BIND_CONSTANT_BUFFER; /* Constant buffer size needs to be in multiples of 16. */ sbuf->b.b.width0 = align(sbuf->b.b.width0, 16); } } - if (svga_buffer_needs_hw_storage(template->bind)) { + if (svga_buffer_needs_hw_storage(bind_flags)) { /* If the buffer will be used for vertex/index/stream data, set all * the flags so that the buffer will be accepted for all those uses. @@ -436,13 +437,13 @@ svga_buffer_create(struct pipe_screen *screen, /* Not a constant buffer. The buffer may be used for vertex data, * indexes or stream-out. */ - sbuf->bind_flags |= (PIPE_BIND_VERTEX_BUFFER | - PIPE_BIND_INDEX_BUFFER); + bind_flags |= (PIPE_BIND_VERTEX_BUFFER | + PIPE_BIND_INDEX_BUFFER); if (ss->sws->have_vgpu10) - sbuf->bind_flags |= PIPE_BIND_STREAM_OUTPUT; + bind_flags |= PIPE_BIND_STREAM_OUTPUT; } - if (svga_buffer_create_host_surface(ss, sbuf) != PIPE_OK) + if (svga_buffer_create_host_surface(ss, sbuf, bind_flags) != PIPE_OK) goto error2; } else { @@ -454,6 +455,7 @@ svga_buffer_create(struct pipe_screen *screen, debug_reference(&sbuf->b.b.reference, (debug_reference_descriptor)debug_describe_resource, 0); + sbuf->bind_flags = bind_flags; sbuf->size = util_resource_size(&sbuf->b.b); ss->hud.total_resource_bytes += sbuf->size; diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index 1b82dbac0d0..89a40e9c899 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -113,13 +113,14 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf) */ enum pipe_error svga_buffer_create_hw_storage(struct svga_screen *ss, - struct svga_buffer *sbuf) + struct svga_buffer *sbuf, + unsigned bind_flags) { assert(!sbuf->user); if (ss->sws->have_gb_objects) { assert(sbuf->handle || !sbuf->dma.pending); - return svga_buffer_create_host_surface(ss, sbuf); + return svga_buffer_create_host_surface(ss, sbuf, bind_flags); } if (!sbuf->hwbuf) { struct svga_winsys_screen *sws = ss->sws; @@ -144,7 +145,8 @@ svga_buffer_create_hw_storage(struct svga_screen *ss, */ enum pipe_error svga_buffer_create_host_surface(struct svga_screen *ss, - struct svga_buffer *sbuf) + struct svga_buffer *sbuf, + unsigned bind_flags) { assert(!sbuf->user); @@ -154,24 +156,24 @@ svga_buffer_create_host_surface(struct svga_screen *ss, sbuf->key.flags = 0; sbuf->key.format = SVGA3D_BUFFER; - if (sbuf->bind_flags & PIPE_BIND_VERTEX_BUFFER) { + if (bind_flags & PIPE_BIND_VERTEX_BUFFER) { sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER; sbuf->key.flags |= SVGA3D_SURFACE_BIND_VERTEX_BUFFER; } - if (sbuf->bind_flags & PIPE_BIND_INDEX_BUFFER) { + if (bind_flags & PIPE_BIND_INDEX_BUFFER) { sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER; sbuf->key.flags |= SVGA3D_SURFACE_BIND_INDEX_BUFFER; } - if (sbuf->bind_flags & PIPE_BIND_CONSTANT_BUFFER) + if (bind_flags & PIPE_BIND_CONSTANT_BUFFER) sbuf->key.flags |= SVGA3D_SURFACE_BIND_CONSTANT_BUFFER; - if (sbuf->bind_flags & PIPE_BIND_STREAM_OUTPUT) + if (bind_flags & PIPE_BIND_STREAM_OUTPUT) sbuf->key.flags |= SVGA3D_SURFACE_BIND_STREAM_OUTPUT; - if (sbuf->bind_flags & PIPE_BIND_SAMPLER_VIEW) + if (bind_flags & PIPE_BIND_SAMPLER_VIEW) sbuf->key.flags |= SVGA3D_SURFACE_BIND_SHADER_RESOURCE; - if (!sbuf->bind_flags && sbuf->b.b.usage == PIPE_USAGE_STAGING) { + if (!bind_flags && sbuf->b.b.usage == PIPE_USAGE_STAGING) { /* This surface is to be used with the * SVGA3D_CMD_DX_TRANSFER_FROM_BUFFER command, and no other * bind flags are allowed to be set for this surface. @@ -191,7 +193,7 @@ svga_buffer_create_host_surface(struct svga_screen *ss, SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n", sbuf->b.b.width0); - sbuf->handle = svga_screen_surface_create(ss, sbuf->b.b.bind, + sbuf->handle = svga_screen_surface_create(ss, bind_flags, sbuf->b.b.usage, &validated, &sbuf->key); if (!sbuf->handle) @@ -626,7 +628,8 @@ svga_buffer_add_range(struct svga_buffer *sbuf, unsigned start, unsigned end) * Copy the contents of the malloc buffer to a hardware buffer. */ static enum pipe_error -svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf) +svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf, + unsigned bind_flags) { assert(!sbuf->user); if (!svga_buffer_has_hw_storage(sbuf)) { @@ -640,7 +643,8 @@ svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf) if (!sbuf->swbuf) return PIPE_ERROR; - ret = svga_buffer_create_hw_storage(svga_screen(sbuf->b.b.screen), sbuf); + ret = svga_buffer_create_hw_storage(svga_screen(sbuf->b.b.screen), sbuf, + bind_flags); if (ret != PIPE_OK) return ret; @@ -789,9 +793,9 @@ svga_buffer_handle(struct svga_context *svga, struct pipe_resource *buf) if (!sbuf->handle) { /* This call will set sbuf->handle */ if (svga_have_gb_objects(svga)) { - ret = svga_buffer_update_hw(svga, sbuf); + ret = svga_buffer_update_hw(svga, sbuf, sbuf->bind_flags); } else { - ret = svga_buffer_create_host_surface(ss, sbuf); + ret = svga_buffer_create_host_surface(ss, sbuf, sbuf->bind_flags); } if (ret != PIPE_OK) return NULL; @@ -804,7 +808,7 @@ svga_buffer_handle(struct svga_context *svga, struct pipe_resource *buf) /* No pending DMA/update commands yet. */ /* Migrate the data from swbuf -> hwbuf if necessary */ - ret = svga_buffer_update_hw(svga, sbuf); + ret = svga_buffer_update_hw(svga, sbuf, sbuf->bind_flags); if (ret == PIPE_OK) { /* Emit DMA or UpdateGBImage commands */ ret = svga_buffer_upload_command(svga, sbuf); diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.h b/src/gallium/drivers/svga/svga_resource_buffer_upload.h index 13d8f3e299b..f718f24c905 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.h +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.h @@ -38,7 +38,8 @@ svga_buffer_add_range(struct svga_buffer *sbuf, enum pipe_error svga_buffer_create_hw_storage(struct svga_screen *ss, - struct svga_buffer *sbuf); + struct svga_buffer *sbuf, + unsigned bind_flags); void svga_buffer_destroy_hw_storage(struct svga_screen *ss, @@ -46,7 +47,8 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, enum pipe_error svga_buffer_create_host_surface(struct svga_screen *ss, - struct svga_buffer *sbuf); + struct svga_buffer *sbuf, + unsigned bind_flags); void svga_buffer_destroy_host_surface(struct svga_screen *ss, |