diff options
author | Fernando S <fsahmkow27@gmail.com> | 2023-03-05 15:30:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 15:30:47 +0100 |
commit | fdae95efaa84fe1baeab0b4dd1435720cae0f88d (patch) | |
tree | 383070bd0d4a33189f38423ceea9a5692d38ba09 /src/video_core/buffer_cache/buffer_cache.h | |
parent | Merge pull request #9884 from liamwhite/service-cleanup (diff) | |
parent | Engines: Implement Accelerate DMA Texture. (diff) | |
download | yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar.gz yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar.bz2 yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar.lz yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar.xz yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.tar.zst yuzu-fdae95efaa84fe1baeab0b4dd1435720cae0f88d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 06fd40851..2a150ccdc 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -55,6 +55,19 @@ constexpr u32 NUM_STORAGE_BUFFERS = 16; constexpr u32 NUM_TEXTURE_BUFFERS = 16; constexpr u32 NUM_STAGES = 5; +enum class ObtainBufferSynchronize : u32 { + NoSynchronize = 0, + FullSynchronize = 1, + SynchronizeNoDirty = 2, +}; + +enum class ObtainBufferOperation : u32 { + DoNothing = 0, + MarkAsWritten = 1, + DiscardWrite = 2, + MarkQuery = 3, +}; + using UniformBufferSizes = std::array<std::array<u32, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES>; using ComputeUniformBufferSizes = std::array<u32, NUM_COMPUTE_UNIFORM_BUFFERS>; @@ -191,6 +204,10 @@ public: bool DMAClear(GPUVAddr src_address, u64 amount, u32 value); + [[nodiscard]] std::pair<Buffer*, u32> ObtainBuffer(GPUVAddr gpu_addr, u32 size, + ObtainBufferSynchronize sync_info, + ObtainBufferOperation post_op); + /// Return true when a CPU region is modified from the GPU [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); @@ -642,6 +659,42 @@ bool BufferCache<P>::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) { } template <class P> +std::pair<typename P::Buffer*, u32> BufferCache<P>::ObtainBuffer(GPUVAddr gpu_addr, u32 size, + ObtainBufferSynchronize sync_info, + ObtainBufferOperation post_op) { + 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]; + + // synchronize op + switch (sync_info) { + case ObtainBufferSynchronize::FullSynchronize: + SynchronizeBuffer(buffer, *cpu_addr, size); + break; + default: + break; + } + + switch (post_op) { + case ObtainBufferOperation::MarkAsWritten: + MarkWrittenBuffer(buffer_id, *cpu_addr, size); + break; + case ObtainBufferOperation::DiscardWrite: { + IntervalType interval{*cpu_addr, size}; + ClearDownload(interval); + break; + } + default: + break; + } + + return {&buffer, buffer.Offset(*cpu_addr)}; +} + +template <class P> void BufferCache<P>::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size) { const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); |