summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-11-02 00:00:53 +0100
committerMarek Olšák <[email protected]>2017-11-06 16:23:20 +0100
commit4b0dc098b2561c07c59f7dab2813640a25789bf1 (patch)
treedac245ade98bd4e4dc5ba804d81771c6ef91339d /src/gallium/auxiliary
parenta5d3999c31e2460f690b561b41170bb7bc24fc65 (diff)
gallium/u_threaded: don't map big VRAM buffers for the first upload directly
This improves Paraview "many spheres" performance 4x along with the radeonsi commit. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_threaded_context.c14
-rw-r--r--src/gallium/auxiliary/util/u_threaded_context.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 0f232580532..ccce12b00ce 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1284,6 +1284,20 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
if (usage & tc_flags)
return usage;
+ /* Use the staging upload if it's preferred. */
+ if (usage & (PIPE_TRANSFER_DISCARD_RANGE |
+ PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) &&
+ !(usage & PIPE_TRANSFER_PERSISTENT) &&
+ /* Try not to decrement the counter if it's not positive. Still racy,
+ * but it makes it harder to wrap the counter from INT_MIN to INT_MAX. */
+ tres->max_forced_staging_uploads > 0 &&
+ p_atomic_dec_return(&tres->max_forced_staging_uploads) >= 0) {
+ usage &= ~(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE |
+ PIPE_TRANSFER_UNSYNCHRONIZED);
+
+ return usage | tc_flags | PIPE_TRANSFER_DISCARD_RANGE;
+ }
+
/* Sparse buffers can't be mapped directly and can't be reallocated
* (fully invalidated). That may just be a radeonsi limitation, but
* the threaded context must obey it with radeonsi.
diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h
index 8977b03cd20..ac7bc3dec73 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.h
+++ b/src/gallium/auxiliary/util/u_threaded_context.h
@@ -241,6 +241,12 @@ struct threaded_resource {
* pointers. */
bool is_shared;
bool is_user_ptr;
+
+ /* If positive, prefer DISCARD_RANGE with a staging buffer over any other
+ * method of CPU access when map flags allow it. Useful for buffers that
+ * are too large for the visible VRAM window.
+ */
+ int max_forced_staging_uploads;
};
struct threaded_transfer {