From b549f5e6b1dfba42b96d4181116715bf218a66dc Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Mon, 26 Jun 2017 17:24:15 -0600 Subject: svga: pass tobind_flags to svga_buffer_handle This is to prepare for more bind_flags optimization in subsequent patches. Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- src/gallium/drivers/svga/svga_draw.c | 17 +++++++++++------ src/gallium/drivers/svga/svga_pipe_blit.c | 5 +++-- src/gallium/drivers/svga/svga_pipe_streamout.c | 3 ++- src/gallium/drivers/svga/svga_resource_buffer.c | 2 +- src/gallium/drivers/svga/svga_resource_buffer.h | 3 ++- src/gallium/drivers/svga/svga_resource_buffer_upload.c | 3 ++- src/gallium/drivers/svga/svga_resource_texture.c | 2 +- src/gallium/drivers/svga/svga_state_constants.c | 6 ++++-- 8 files changed, 26 insertions(+), 15 deletions(-) (limited to 'src/gallium/drivers/svga') diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index 6a89e661dd7..d6b024d532f 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -201,7 +201,8 @@ draw_vgpu9(struct svga_hwtnl *hwtnl) for (i = 0; i < hwtnl->cmd.vdecl_count; i++) { unsigned j = hwtnl->cmd.vdecl_buffer_index[i]; - handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer.resource); + handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer.resource, + PIPE_BIND_VERTEX_BUFFER); if (!handle) return PIPE_ERROR_OUT_OF_MEMORY; @@ -210,7 +211,8 @@ draw_vgpu9(struct svga_hwtnl *hwtnl) for (i = 0; i < hwtnl->cmd.prim_count; i++) { if (hwtnl->cmd.prim_ib[i]) { - handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i]); + handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i], + PIPE_BIND_INDEX_BUFFER); if (!handle) return PIPE_ERROR_OUT_OF_MEMORY; } @@ -344,7 +346,8 @@ validate_sampler_resources(struct svga_context *svga) if (sv) { if (sv->base.texture->target == PIPE_BUFFER) { - surfaces[i] = svga_buffer_handle(svga, sv->base.texture); + surfaces[i] = svga_buffer_handle(svga, sv->base.texture, + PIPE_BIND_SAMPLER_VIEW); } else { surfaces[i] = svga_texture(sv->base.texture)->handle; @@ -421,7 +424,8 @@ validate_constant_buffers(struct svga_context *svga) unsigned i = u_bit_scan(&enabled_constbufs); buffer = svga_buffer(svga->curr.constbufs[shader][i].buffer); if (buffer) { - handle = svga_buffer_handle(svga, &buffer->b.b); + handle = svga_buffer_handle(svga, &buffer->b.b, + PIPE_BIND_CONSTANT_BUFFER); if (svga->rebind.flags.constbufs) { ret = svga->swc->resource_rebind(svga->swc, @@ -526,7 +530,8 @@ draw_vgpu10(struct svga_hwtnl *hwtnl, if (sbuf) { assert(sbuf->key.flags & SVGA3D_SURFACE_BIND_VERTEX_BUFFER); - vbuffer_handles[i] = svga_buffer_handle(svga, &sbuf->b.b); + vbuffer_handles[i] = svga_buffer_handle(svga, &sbuf->b.b, + PIPE_BIND_VERTEX_BUFFER); if (vbuffer_handles[i] == NULL) return PIPE_ERROR_OUT_OF_MEMORY; vbuffers[i] = &sbuf->b.b; @@ -550,7 +555,7 @@ draw_vgpu10(struct svga_hwtnl *hwtnl, assert(sbuf->key.flags & SVGA3D_SURFACE_BIND_INDEX_BUFFER); (void) sbuf; /* silence unused var warning */ - ib_handle = svga_buffer_handle(svga, ib); + ib_handle = svga_buffer_handle(svga, ib, PIPE_BIND_INDEX_BUFFER); if (!ib_handle) return PIPE_ERROR_OUT_OF_MEMORY; } diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c index 45bad97072f..e98113c3854 100644 --- a/src/gallium/drivers/svga/svga_pipe_blit.c +++ b/src/gallium/drivers/svga/svga_pipe_blit.c @@ -731,9 +731,10 @@ svga_resource_copy_region(struct pipe_context *pipe, struct svga_winsys_surface *src_surf; struct svga_winsys_surface *dst_surf; struct svga_buffer *dbuffer = svga_buffer(dst_tex); + struct svga_buffer *sbuffer = svga_buffer(src_tex); - src_surf = svga_buffer_handle(svga, src_tex); - dst_surf = svga_buffer_handle(svga, dst_tex); + src_surf = svga_buffer_handle(svga, src_tex, sbuffer->bind_flags); + dst_surf = svga_buffer_handle(svga, dst_tex, dbuffer->bind_flags); ret = SVGA3D_vgpu10_BufferCopy(svga->swc, src_surf, dst_surf, src_box->x, dstx, src_box->width); diff --git a/src/gallium/drivers/svga/svga_pipe_streamout.c b/src/gallium/drivers/svga/svga_pipe_streamout.c index 1318b5565ce..18cc804d0c9 100644 --- a/src/gallium/drivers/svga/svga_pipe_streamout.c +++ b/src/gallium/drivers/svga/svga_pipe_streamout.c @@ -282,7 +282,8 @@ svga_set_stream_output_targets(struct pipe_context *pipe, assert(sbuf->key.flags & SVGA3D_SURFACE_BIND_STREAM_OUTPUT); (void) sbuf; - svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer); + svga->so_surfaces[i] = svga_buffer_handle(svga, sot->base.buffer, + PIPE_BIND_STREAM_OUTPUT); svga->so_targets[i] = &sot->base; soBindings[i].offset = sot->base.buffer_offset; diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index 9895719c9c3..4448b7d0308 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -114,7 +114,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe, assert(svga_have_vgpu10(svga)); if (!sbuf->user) { - (void) svga_buffer_handle(svga, resource); + (void) svga_buffer_handle(svga, resource, sbuf->bind_flags); } if (sbuf->dma.pending > 0) { diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h index 05025e963bc..2096a9821cc 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.h +++ b/src/gallium/drivers/svga/svga_resource_buffer.h @@ -325,7 +325,8 @@ svga_buffer_create(struct pipe_screen *screen, */ struct svga_winsys_surface * svga_buffer_handle(struct svga_context *svga, - struct pipe_resource *buf); + struct pipe_resource *buf, + unsigned tobind_flags); void svga_context_flush_buffers(struct svga_context *svga); diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index 89a40e9c899..40429a8dc80 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -776,7 +776,8 @@ svga_buffer_upload_piecewise(struct svga_screen *ss, * if there are mapped ranges and the data is currently in a malloc'ed buffer. */ struct svga_winsys_surface * -svga_buffer_handle(struct svga_context *svga, struct pipe_resource *buf) +svga_buffer_handle(struct svga_context *svga, struct pipe_resource *buf, + unsigned tobind_flags) { struct pipe_screen *screen = svga->pipe.screen; struct svga_screen *ss = svga_screen(screen); diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 39e11d3a616..a24d630cb5e 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -1452,7 +1452,7 @@ svga_texture_transfer_unmap_upload(struct svga_context *svga, /* unmap the texture upload buffer */ u_upload_unmap(svga->tex_upload); - srcsurf = svga_buffer_handle(svga, st->upload.buf); + srcsurf = svga_buffer_handle(svga, st->upload.buf, 0); dstsurf = svga_texture(texture)->handle; assert(dstsurf); diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 31e4be0624c..2e4620c4ce4 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -591,7 +591,8 @@ emit_constbuf_vgpu10(struct svga_context *svga, enum pipe_shader_type shader) /* we must unmap the buffer before getting the winsys handle */ u_upload_unmap(svga->const0_upload); - dst_handle = svga_buffer_handle(svga, dst_buffer); + dst_handle = svga_buffer_handle(svga, dst_buffer, + PIPE_BIND_CONSTANT_BUFFER); if (!dst_handle) { pipe_resource_reference(&dst_buffer, NULL); return PIPE_ERROR_OUT_OF_MEMORY; @@ -660,7 +661,8 @@ emit_consts_vgpu10(struct svga_context *svga, enum pipe_shader_type shader) struct svga_winsys_surface *handle; if (buffer) { - handle = svga_buffer_handle(svga, &buffer->b.b); + handle = svga_buffer_handle(svga, &buffer->b.b, + PIPE_BIND_CONSTANT_BUFFER); enabled_constbufs |= 1 << index; } else { -- cgit v1.2.3