diff options
author | bunnei <bunneidev@gmail.com> | 2020-06-14 06:29:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 06:29:16 +0200 |
commit | 92021a344cc2562496a41e2fc4e4090e49e1c6fb (patch) | |
tree | 02ddce73a3c77c9f6ba72b7ebb36b62de4c0583b | |
parent | Merge pull request #4049 from ReinUsesLisp/separate-samplers (diff) | |
parent | gl_rasterizer: Mark vertex buffers as dirty after buffer cache invalidation (diff) | |
download | yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar.gz yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar.bz2 yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar.lz yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar.xz yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.tar.zst yuzu-92021a344cc2562496a41e2fc4e4090e49e1c6fb.zip |
-rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 16 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 11 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index b88fce2cd..77ae34339 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -110,19 +110,23 @@ public: }); } - void Map(std::size_t max_size) { + /// Prepares the buffer cache for data uploading + /// @param max_size Maximum number of bytes that will be uploaded + /// @return True when a stream buffer invalidation was required, false otherwise + bool Map(std::size_t max_size) { std::lock_guard lock{mutex}; + bool invalidated; std::tie(buffer_ptr, buffer_offset_base, invalidated) = stream_buffer->Map(max_size, 4); buffer_offset = buffer_offset_base; + + return invalidated; } - /// Finishes the upload stream, returns true on bindings invalidation. - bool Unmap() { + /// Finishes the upload stream + void Unmap() { std::lock_guard lock{mutex}; - stream_buffer->Unmap(buffer_offset - buffer_offset_base); - return std::exchange(invalidated, false); } void TickFrame() { @@ -576,8 +580,6 @@ private: std::unique_ptr<StreamBuffer> stream_buffer; BufferType stream_buffer_handle{}; - bool invalidated = false; - u8* buffer_ptr = nullptr; u64 buffer_offset = 0; u64 buffer_offset_base = 0; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 121af9718..2d6c11320 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -617,7 +617,16 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { (Maxwell::MaxConstBufferSize + device.GetUniformBufferAlignment()); // Prepare the vertex array. - buffer_cache.Map(buffer_size); + const bool invalidated = buffer_cache.Map(buffer_size); + + if (invalidated) { + // When the stream buffer has been invalidated, we have to consider vertex buffers as dirty + auto& dirty = gpu.dirty.flags; + dirty[Dirty::VertexBuffers] = true; + for (int index = Dirty::VertexBuffer0; index <= Dirty::VertexBuffer31; ++index) { + dirty[index] = true; + } + } // Prepare vertex array format. SetupVertexFormat(); |