diff options
author | Bruce Cherniak <[email protected]> | 2017-07-12 15:04:47 -0500 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-07-12 16:56:40 -0500 |
commit | 02735e6cf8821f83e04fb78cd24960a4903ce118 (patch) | |
tree | 0407f33c257975811333cb82e9de6627748efff9 /src/gallium/drivers/swr/swr_state.cpp | |
parent | 1520a06607b58cdcadcf888594b0c2f269ba68b2 (diff) |
swr: Add path to draw directly from client memory without copy.
If size of client memory copy is too large, don't copy. The draw will
access user-buffer directly and then block. This is faster and more
efficient than queuing many large client draws.
Applications that still use large client arrays benefit from this. VMD
is an example.
The threshold for this path defaults to 32KB. This value can be
overridden by setting environment variable SWR_CLIENT_COPY_LIMIT.
v2: Use #define for default value, rather than hard-coded constant.
Reviewed-by: Tim Rowley <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/swr_state.cpp')
-rw-r--r-- | src/gallium/drivers/swr/swr_state.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 4eef60681a7..534f3c59b1c 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1267,12 +1267,20 @@ swr_update_derived(struct pipe_context *pipe, partial_inbounds = 0; min_vertex_index = info.min_index; - /* Copy only needed vertices to scratch space */ size = AlignUp(size, 4); - const void *ptr = (const uint8_t *) vb->buffer.user + base; - ptr = (uint8_t *)swr_copy_to_scratch_space( - ctx, &ctx->scratch->vertex_buffer, ptr, size); - p_data = (const uint8_t *)ptr - base; + /* If size of client memory copy is too large, don't copy. The + * draw will access user-buffer directly and then block. This is + * faster than queuing many large client draws. */ + if (size >= screen->client_copy_limit) { + post_update_dirty_flags |= SWR_LARGE_CLIENT_DRAW; + p_data = (const uint8_t *) vb->buffer.user; + } else { + /* Copy only needed vertices to scratch space */ + const void *ptr = (const uint8_t *) vb->buffer.user + base; + ptr = (uint8_t *)swr_copy_to_scratch_space( + ctx, &ctx->scratch->vertex_buffer, ptr, size); + p_data = (const uint8_t *)ptr - base; + } } swrVertexBuffers[i] = {0}; @@ -1311,12 +1319,19 @@ swr_update_derived(struct pipe_context *pipe, size = info.count * pitch; size = AlignUp(size, 4); - - /* Copy indices to scratch space */ - const void *ptr = info.index.user; - ptr = swr_copy_to_scratch_space( - ctx, &ctx->scratch->index_buffer, ptr, size); - p_data = (const uint8_t *)ptr; + /* If size of client memory copy is too large, don't copy. The + * draw will access user-buffer directly and then block. This is + * faster than queuing many large client draws. */ + if (size >= screen->client_copy_limit) { + post_update_dirty_flags |= SWR_LARGE_CLIENT_DRAW; + p_data = (const uint8_t *) info.index.user; + } else { + /* Copy indices to scratch space */ + const void *ptr = info.index.user; + ptr = swr_copy_to_scratch_space( + ctx, &ctx->scratch->index_buffer, ptr, size); + p_data = (const uint8_t *)ptr; + } } SWR_INDEX_BUFFER_STATE swrIndexBuffer; |