summaryrefslogtreecommitdiffstats
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2022-02-09 15:00:05 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2023-01-01 22:43:57 +0100
commita5a94f52ffcbf3119d272a9369021a213ea6dad2 (patch)
treeba6d42b142894d0f3f0ac34fb6ce491442bae8fd /src/video_core/buffer_cache
parentMerge pull request #9538 from merryhime/char-concat (diff)
downloadyuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar.gz
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar.bz2
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar.lz
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar.xz
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.tar.zst
yuzu-a5a94f52ffcbf3119d272a9369021a213ea6dad2.zip
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index f1c60d1f3..99abe0edf 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -170,6 +170,9 @@ public:
void BindComputeTextureBuffer(size_t tbo_index, GPUVAddr gpu_addr, u32 size, PixelFormat format,
bool is_written, bool is_image);
+ [[nodiscard]] std::pair<Buffer*, u32> ObtainBuffer(GPUVAddr gpu_addr, u32 size,
+ bool synchronize, bool mark_as_written);
+
void FlushCachedWrites();
/// Return true when there are uncommitted buffers to be downloaded
@@ -791,6 +794,25 @@ void BufferCache<P>::BindComputeTextureBuffer(size_t tbo_index, GPUVAddr gpu_add
}
template <class P>
+std::pair<typename P::Buffer*, u32> BufferCache<P>::ObtainBuffer(GPUVAddr gpu_addr, u32 size,
+ bool synchronize,
+ bool mark_as_written) {
+ const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
+ if (!cpu_addr) {
+ return {&slot_buffers[NULL_BUFFER_ID], 0};
+ }
+ const BufferId buffer_id = FindBuffer(*cpu_addr, size);
+ Buffer& buffer = slot_buffers[buffer_id];
+ if (synchronize) {
+ SynchronizeBuffer(buffer, *cpu_addr, size);
+ }
+ if (mark_as_written) {
+ MarkWrittenBuffer(buffer_id, *cpu_addr, size);
+ }
+ return {&buffer, buffer.Offset(*cpu_addr)};
+}
+
+template <class P>
void BufferCache<P>::FlushCachedWrites() {
for (const BufferId buffer_id : cached_write_buffer_ids) {
slot_buffers[buffer_id].FlushCachedWrites();