diff options
-rw-r--r-- | src/gallium/drivers/svga/svga_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_buffer.c | 44 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_resource_texture.c | 2 |
3 files changed, 36 insertions, 13 deletions
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 7b3e9e81f4c..57c0dc49957 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -230,7 +230,8 @@ 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_BIND_CONSTANT_BUFFER | + PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM, 0); if (!svga->const0_upload) goto cleanup; diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index a3e11adfac6..3f37ef692fa 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -42,16 +42,37 @@ /** - * Vertex and index buffers need hardware backing. Constant buffers - * do not. No other types of buffers currently supported. + * Determine what buffers eventually need hardware backing. + * + * Vertex- and index buffers need hardware backing. Constant buffers + * do on vgpu10. Staging texture-upload buffers do when they are + * supported. */ static inline boolean -svga_buffer_needs_hw_storage(unsigned usage) +svga_buffer_needs_hw_storage(const struct svga_screen *ss, + const struct pipe_resource *template) { - return (usage & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER | - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT)) != 0; -} + unsigned bind_mask = (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER | + PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT); + if (ss->sws->have_vgpu10) { + /* + * Driver-created upload const0- and staging texture upload buffers + * tagged with PIPE_BIND_CUSTOM + */ + bind_mask |= PIPE_BIND_CUSTOM; + /* Uniform buffer objects. + * Make sure we don't create hardware storage for state-tracker + * const0 buffers, because we frequently map them for reading. + * They are distinguished by having PIPE_USAGE_STREAM, but not + * PIPE_BIND_CUSTOM. + */ + if (template->usage != PIPE_USAGE_STREAM) + bind_mask |= PIPE_BIND_CONSTANT_BUFFER; + } + + return !!(template->bind & bind_mask); +} /** * Create a buffer transfer. @@ -411,7 +432,7 @@ 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; - bind_flags = template->bind; + bind_flags = template->bind & ~PIPE_BIND_CUSTOM; LIST_INITHEAD(&sbuf->surfaces); @@ -430,7 +451,7 @@ svga_buffer_create(struct pipe_screen *screen, */ sbuf->b.b.width0 = align(sbuf->b.b.width0, 16); - if (svga_buffer_needs_hw_storage(bind_flags)) { + if (svga_buffer_needs_hw_storage(ss, template)) { /* If the buffer is not used for constant buffer, set * the vertex/index bind flags as well so that the buffer will be @@ -442,9 +463,10 @@ svga_buffer_create(struct pipe_screen *screen, * bind flag since streamout buffer is an output buffer and * might have performance implication. */ - if (!(template->bind & PIPE_BIND_CONSTANT_BUFFER)) { - /* Not a constant buffer. The buffer may be used for vertex data - * or indexes. + if (!(template->bind & PIPE_BIND_CONSTANT_BUFFER) && + !(template->bind & PIPE_BIND_CUSTOM)) { + /* Not a constant- or staging buffer. + * The buffer may be used for vertex data or indexes. */ bind_flags |= (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER); diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index c716b66e89f..e9449e8a1ff 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -1335,7 +1335,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_BIND_CUSTOM, PIPE_USAGE_STAGING, 0); return svga->tex_upload != NULL; } |