diff options
author | bunnei <bunneidev@gmail.com> | 2021-07-20 23:35:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 23:35:05 +0200 |
commit | c53b688411d916192820520ef5280ad5e378aa11 (patch) | |
tree | 6b319d4eaa3b7807b9590268f308b1c03fb5d3a1 /src/video_core/renderer_vulkan/vk_buffer_cache.cpp | |
parent | Merge pull request #6658 from Morph1984/render-window-fix (diff) | |
parent | Buffer cache: Fixes, Clang and Feedback. (diff) | |
download | yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar.gz yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar.bz2 yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar.lz yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar.xz yuzu-c53b688411d916192820520ef5280ad5e378aa11.tar.zst yuzu-c53b688411d916192820520ef5280ad5e378aa11.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_buffer_cache.cpp')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 7d4e6ea7b..0def1e769 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -136,6 +136,30 @@ void BufferCacheRuntime::CopyBuffer(VkBuffer dst_buffer, VkBuffer src_buffer, }); } +void BufferCacheRuntime::ClearBuffer(VkBuffer dest_buffer, u32 offset, size_t size, u32 value) { + static constexpr VkMemoryBarrier READ_BARRIER{ + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, + }; + static constexpr VkMemoryBarrier WRITE_BARRIER{ + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + }; + + scheduler.RequestOutsideRenderPassOperationContext(); + scheduler.Record([dest_buffer, offset, size, value](vk::CommandBuffer cmdbuf) { + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, READ_BARRIER); + cmdbuf.FillBuffer(dest_buffer, offset, size, value); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + 0, WRITE_BARRIER); + }); +} + void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, u32 base_vertex, u32 num_indices, VkBuffer buffer, u32 offset, [[maybe_unused]] u32 size) { |