From bc028b7ca6c66ca414db024a294c2b2e7b744b26 Mon Sep 17 00:00:00 2001 From: nikmparis217-ux Date: Wed, 23 Sep 2026 20:34:46 +0300 Subject: [PATCH] video_core: commit the emulated-LDS allocation taken from the stream buffer (#5070) The BufferType::SharedMemory path in Rasterizer::BindBuffers backs a compute shader's LDS with a region of the stream buffer: it calls StreamBuffer::Map, zeroes the bytes and binds them as the storage buffer the recompiler lowered the LDS accesses to. It never called Commit. Map only chooses the region and waits until it is free; Commit is what reserves it. Commit flushes the host writes on non-coherent memory, advances the ring cursor past the mapped bytes and records the completion watch that makes a later wrap wait for the GPU work that used them. Without it the next Map on the same stream buffer hands out the same bytes again, so a streamed upload can overwrite the shader's shared memory while the dispatch that uses it is in flight, and the shader's LDS stores can land in bytes a later upload reads as its source. Every other StreamBuffer::Map in the tree is paired with a Commit; this was the only call site without one. Co-authored-by: nikmparis217-ux <295578344+nikmparis217-ux@users.noreply.github.com> --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 98052d4d2..92947c1e5 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -764,6 +764,7 @@ void Rasterizer::BindBuffers(const Shader::Info& stage, Shader::Backend::Binding const auto lds_size = cs_program.SharedMemSize() * cs_program.NumWorkgroups(); const auto [data, offset] = lds_buffer.Map(lds_size, alignment); std::memset(data, 0, lds_size); + lds_buffer.Commit(); buffer_infos.emplace_back(lds_buffer.Handle(), offset, lds_size); } else { UNREACHABLE_MSG("Unexpected buffer type {}", u32(desc.buffer_type));