diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 359c11d6f..6eb672475 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -350,7 +350,7 @@ private: | |||
| 350 | 350 | ||
| 351 | void NotifyBufferDeletion(); | 351 | void NotifyBufferDeletion(); |
| 352 | 352 | ||
| 353 | [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr) const; | 353 | [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, bool is_written = false) const; |
| 354 | 354 | ||
| 355 | [[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size, | 355 | [[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size, |
| 356 | PixelFormat format); | 356 | PixelFormat format); |
| @@ -725,7 +725,7 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, | |||
| 725 | 725 | ||
| 726 | const auto& cbufs = maxwell3d->state.shader_stages[stage]; | 726 | const auto& cbufs = maxwell3d->state.shader_stages[stage]; |
| 727 | const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset; | 727 | const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset; |
| 728 | storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr); | 728 | storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | template <class P> | 731 | template <class P> |
| @@ -765,7 +765,7 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, | |||
| 765 | 765 | ||
| 766 | const auto& cbufs = launch_desc.const_buffer_config; | 766 | const auto& cbufs = launch_desc.const_buffer_config; |
| 767 | const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset; | 767 | const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset; |
| 768 | compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr); | 768 | compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | template <class P> | 771 | template <class P> |
| @@ -1242,16 +1242,19 @@ void BufferCache<P>::BindHostComputeTextureBuffers() { | |||
| 1242 | 1242 | ||
| 1243 | template <class P> | 1243 | template <class P> |
| 1244 | void BufferCache<P>::DoUpdateGraphicsBuffers(bool is_indexed) { | 1244 | void BufferCache<P>::DoUpdateGraphicsBuffers(bool is_indexed) { |
| 1245 | if (is_indexed) { | 1245 | do { |
| 1246 | UpdateIndexBuffer(); | 1246 | has_deleted_buffers = false; |
| 1247 | } | 1247 | if (is_indexed) { |
| 1248 | UpdateVertexBuffers(); | 1248 | UpdateIndexBuffer(); |
| 1249 | UpdateTransformFeedbackBuffers(); | 1249 | } |
| 1250 | for (size_t stage = 0; stage < NUM_STAGES; ++stage) { | 1250 | UpdateVertexBuffers(); |
| 1251 | UpdateUniformBuffers(stage); | 1251 | UpdateTransformFeedbackBuffers(); |
| 1252 | UpdateStorageBuffers(stage); | 1252 | for (size_t stage = 0; stage < NUM_STAGES; ++stage) { |
| 1253 | UpdateTextureBuffers(stage); | 1253 | UpdateUniformBuffers(stage); |
| 1254 | } | 1254 | UpdateStorageBuffers(stage); |
| 1255 | UpdateTextureBuffers(stage); | ||
| 1256 | } | ||
| 1257 | } while (has_deleted_buffers); | ||
| 1255 | } | 1258 | } |
| 1256 | 1259 | ||
| 1257 | template <class P> | 1260 | template <class P> |
| @@ -1557,6 +1560,8 @@ BufferId BufferCache<P>::CreateBuffer(VAddr cpu_addr, u32 wanted_size) { | |||
| 1557 | const OverlapResult overlap = ResolveOverlaps(cpu_addr, wanted_size); | 1560 | const OverlapResult overlap = ResolveOverlaps(cpu_addr, wanted_size); |
| 1558 | const u32 size = static_cast<u32>(overlap.end - overlap.begin); | 1561 | const u32 size = static_cast<u32>(overlap.end - overlap.begin); |
| 1559 | const BufferId new_buffer_id = slot_buffers.insert(runtime, rasterizer, overlap.begin, size); | 1562 | const BufferId new_buffer_id = slot_buffers.insert(runtime, rasterizer, overlap.begin, size); |
| 1563 | auto& new_buffer = slot_buffers[new_buffer_id]; | ||
| 1564 | runtime.ClearBuffer(new_buffer, 0, new_buffer.SizeBytes(), 0); | ||
| 1560 | for (const BufferId overlap_id : overlap.ids) { | 1565 | for (const BufferId overlap_id : overlap.ids) { |
| 1561 | JoinOverlap(new_buffer_id, overlap_id, !overlap.has_stream_leap); | 1566 | JoinOverlap(new_buffer_id, overlap_id, !overlap.has_stream_leap); |
| 1562 | } | 1567 | } |
| @@ -1831,16 +1836,18 @@ void BufferCache<P>::NotifyBufferDeletion() { | |||
| 1831 | } | 1836 | } |
| 1832 | 1837 | ||
| 1833 | template <class P> | 1838 | template <class P> |
| 1834 | typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr) const { | 1839 | typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, |
| 1840 | bool is_written) const { | ||
| 1835 | const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr); | 1841 | const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr); |
| 1836 | const u32 size = gpu_memory->Read<u32>(ssbo_addr + 8); | 1842 | const u32 size = gpu_memory->Read<u32>(ssbo_addr + 8); |
| 1837 | const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); | 1843 | const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); |
| 1838 | if (!cpu_addr || size == 0) { | 1844 | if (!cpu_addr || size == 0) { |
| 1839 | return NULL_BINDING; | 1845 | return NULL_BINDING; |
| 1840 | } | 1846 | } |
| 1847 | const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, Core::Memory::YUZU_PAGESIZE); | ||
| 1841 | const Binding binding{ | 1848 | const Binding binding{ |
| 1842 | .cpu_addr = *cpu_addr, | 1849 | .cpu_addr = *cpu_addr, |
| 1843 | .size = size, | 1850 | .size = is_written ? size : static_cast<u32>(cpu_end - *cpu_addr), |
| 1844 | .buffer_id = BufferId{}, | 1851 | .buffer_id = BufferId{}, |
| 1845 | }; | 1852 | }; |
| 1846 | return binding; | 1853 | return binding; |