summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 081a574e8..9202e53c7 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -1770,6 +1770,7 @@ template <class P>
1770Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, 1770Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
1771 bool is_written) const { 1771 bool is_written) const {
1772 const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr); 1772 const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
1773 const u32 alignment = runtime.GetStorageBufferAlignment();
1773 const auto size = [&]() { 1774 const auto size = [&]() {
1774 const bool is_nvn_cbuf = cbuf_index == 0; 1775 const bool is_nvn_cbuf = cbuf_index == 0;
1775 // The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size. 1776 // The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size.
@@ -1785,15 +1786,19 @@ Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
1785 const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr)); 1786 const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr));
1786 return std::min(memory_layout_size, static_cast<u32>(8_MiB)); 1787 return std::min(memory_layout_size, static_cast<u32>(8_MiB));
1787 }(); 1788 }();
1788 const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); 1789 const GPUVAddr aligned_gpu_addr = Common::AlignDown(gpu_addr, alignment);
1790 const u32 aligned_size =
1791 Common::AlignUp(static_cast<u32>(gpu_addr - aligned_gpu_addr) + size, alignment);
1792
1793 const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(aligned_gpu_addr);
1789 if (!cpu_addr || size == 0) { 1794 if (!cpu_addr || size == 0) {
1790 LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index); 1795 LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
1791 return NULL_BINDING; 1796 return NULL_BINDING;
1792 } 1797 }
1793 const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, YUZU_PAGESIZE); 1798 const VAddr cpu_end = Common::AlignUp(*cpu_addr + aligned_size, Core::Memory::YUZU_PAGESIZE);
1794 const Binding binding{ 1799 const Binding binding{
1795 .cpu_addr = *cpu_addr, 1800 .cpu_addr = *cpu_addr,
1796 .size = is_written ? size : static_cast<u32>(cpu_end - *cpu_addr), 1801 .size = is_written ? aligned_size : static_cast<u32>(cpu_end - *cpu_addr),
1797 .buffer_id = BufferId{}, 1802 .buffer_id = BufferId{},
1798 }; 1803 };
1799 return binding; 1804 return binding;