diff options
author | Brian Paul <[email protected]> | 2016-08-15 09:16:05 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2016-09-17 10:09:00 -0600 |
commit | ee5f5e226906ff4e18f34d0e7d41aa82dcf51f70 (patch) | |
tree | 296e3b0072c6bbe485ac4b32e4a95f16c67ba858 /src/gallium/drivers/svga/svga_state_constants.c | |
parent | ce3b34b72702195694ee8fc64c8259d4a16711ab (diff) |
svga: reduce unmapping/remapping of the default constant buffer
Previously, every time we put shader constants into the default constant
buffer we called u_upload_alloc(), which mapped the buffer, and
u_upload_unmap(). We had to unmap the buffer before calling
svga_buffer_handle() to get the winsys handle for the buffer. But we
really only need to do that the first time we reference the const buffer.
Now we try to keep the upload manager's buffer mapped until we fill it or
flush the command buffer.
v2: add additional comment on the buffer unmapping code in
svga_context_flush(), per Charmaine.
Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src/gallium/drivers/svga/svga_state_constants.c')
-rw-r--r-- | src/gallium/drivers/svga/svga_state_constants.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index dc80edf0982..8d6b46a1cae 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -646,15 +646,29 @@ emit_constbuf_vgpu10(struct svga_context *svga, enum pipe_shader_type shader) assert(extra_offset + extra_size <= new_buf_size); memcpy((char *) dst_map + extra_offset, extras, extra_size); } - u_upload_unmap(svga->const0_upload); - /* Issue the SetSingleConstantBuffer command */ - dst_handle = svga_buffer_handle(svga, dst_buffer); - if (!dst_handle) { - pipe_resource_reference(&dst_buffer, NULL); - return PIPE_ERROR_OUT_OF_MEMORY; + /* Get winsys handle for the constant buffer */ + if (svga->state.hw_draw.const0_buffer == dst_buffer && + svga->state.hw_draw.const0_handle) { + /* re-reference already mapped buffer */ + dst_handle = svga->state.hw_draw.const0_handle; + } + else { + /* we must unmap the buffer before getting the winsys handle */ + u_upload_unmap(svga->const0_upload); + + dst_handle = svga_buffer_handle(svga, dst_buffer); + if (!dst_handle) { + pipe_resource_reference(&dst_buffer, NULL); + return PIPE_ERROR_OUT_OF_MEMORY; + } + + /* save the buffer / handle for next time */ + pipe_resource_reference(&svga->state.hw_draw.const0_buffer, dst_buffer); + svga->state.hw_draw.const0_handle = dst_handle; } + /* Issue the SetSingleConstantBuffer command */ assert(new_buf_size % 16 == 0); ret = SVGA3D_vgpu10_SetSingleConstantBuffer(svga->swc, 0, /* index */ |