aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-29 01:51:42 -0400
committerTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-29 01:51:42 -0400
commite08b40252790eef96337409d7dd606aa7bfa8428 (patch)
treed94274e2c27fa43a99200258558437807a785bd4 /src/video_core/texture_cache
parentae980ab79568c80ed5760f7fd5f452c8a49dc1ab (diff)
video_core: less waiting on the GPU caches' locks
- The texture and buffer caches' mutexes spin briefly before sleeping (Common::SpinRecursiveMutex): the GPU thread, the fencing thread and CPU write traps take them tens of thousands of times a second for microseconds, and a sleeping waiter's wake-up took longer than that. Title 1's GPU thread slept 7.7% of its time there, now 3.7%. - Fences commit and pop texture and buffer downloads separately, and only when there are any (one fence per compute dispatch in Switch 2 titles): the fencing thread no longer holds both caches while it copies buffer downloads. - Inline uploads and pre-draw invalidation take the caches one at a time again: holding one while std::lock waited for the other waited longer.
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/texture_cache.h5
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 13dfbba20e..fb8adef161 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -990,6 +990,11 @@ bool TextureCache<P>::HasUncommittedFlushes() const noexcept {
}
template <class P>
+bool TextureCache<P>::HasAsyncFlushWork() const noexcept {
+ return !uncommitted_downloads.empty() || !uncommitted_async_buffers.empty();
+}
+
+template <class P>
bool TextureCache<P>::ShouldWaitAsyncFlushes() const noexcept {
return !committed_downloads.empty() && !committed_downloads.front().empty();
}
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index 3c96c91a93..11ac8a2421 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -23,6 +23,7 @@
#include <queue>
#include "common/common_types.h"
+#include "common/spin_recursive_mutex.h"
#include "common/hash.h"
#include "common/literals.h"
#include "common/lru_cache.h"
@@ -244,6 +245,9 @@ public:
/// Return true when there are uncommitted images to be downloaded
[[nodiscard]] bool HasUncommittedFlushes() const noexcept;
+ /// Whether CommitAsyncFlushes would commit anything (downloads or their buffers).
+ [[nodiscard]] bool HasAsyncFlushWork() const noexcept;
+
/// Return true when the caller should wait for async downloads
[[nodiscard]] bool ShouldWaitAsyncFlushes() const noexcept;
@@ -276,7 +280,7 @@ public:
/// Prepare an image to be used
void PrepareImage(ImageId image_id, bool is_modification, bool invalidate);
- std::recursive_mutex mutex;
+ Common::SpinRecursiveMutex mutex;
private:
/// Iterate over all page indices in a range