summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-06-10 02:24:12 -0300
committerGravatar ameerj2021-07-22 21:51:35 -0400
commit60a96c49e59e600685b9a79d80b2685318b4fb64 (patch)
tree9bd2a745edac5dfe7352ea314dd1a1321075348e /src/video_core/buffer_cache
parentshader_environment: Add shader_local_memory_crs_size to local memory size (diff)
downloadyuzu-60a96c49e59e600685b9a79d80b2685318b4fb64.tar.gz
yuzu-60a96c49e59e600685b9a79d80b2685318b4fb64.tar.xz
yuzu-60a96c49e59e600685b9a79d80b2685318b4fb64.zip
buffer_cache: Fix copy based uniform bindings tracking
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index ec64f2293..47cb0a47d 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -680,6 +680,9 @@ void BufferCache<P>::SetUniformBuffersState(const std::array<u32, NUM_STAGES>& m
680 const UniformBufferSizes* sizes) { 680 const UniformBufferSizes* sizes) {
681 if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) { 681 if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) {
682 if (enabled_uniform_buffer_masks != mask) { 682 if (enabled_uniform_buffer_masks != mask) {
683 if constexpr (IS_OPENGL) {
684 fast_bound_uniform_buffers.fill(0);
685 }
683 dirty_uniform_buffers.fill(~u32{0}); 686 dirty_uniform_buffers.fill(~u32{0});
684 } 687 }
685 } 688 }
@@ -1020,6 +1023,7 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32
1020 // Fast path for Nvidia 1023 // Fast path for Nvidia
1021 if (!HasFastUniformBufferBound(stage, binding_index)) { 1024 if (!HasFastUniformBufferBound(stage, binding_index)) {
1022 // We only have to bind when the currently bound buffer is not the fast version 1025 // We only have to bind when the currently bound buffer is not the fast version
1026 fast_bound_uniform_buffers[stage] |= 1U << binding_index;
1023 runtime.BindFastUniformBuffer(stage, binding_index, size); 1027 runtime.BindFastUniformBuffer(stage, binding_index, size);
1024 } 1028 }
1025 const auto span = ImmediateBufferWithData(cpu_addr, size); 1029 const auto span = ImmediateBufferWithData(cpu_addr, size);
@@ -1027,8 +1031,9 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32
1027 return; 1031 return;
1028 } 1032 }
1029 } 1033 }
1030 fast_bound_uniform_buffers[stage] |= 1U << binding_index; 1034 if constexpr (IS_OPENGL) {
1031 1035 fast_bound_uniform_buffers[stage] |= 1U << binding_index;
1036 }
1032 // Stream buffer path to avoid stalling on non-Nvidia drivers or Vulkan 1037 // Stream buffer path to avoid stalling on non-Nvidia drivers or Vulkan
1033 const std::span<u8> span = runtime.BindMappedUniformBuffer(stage, binding_index, size); 1038 const std::span<u8> span = runtime.BindMappedUniformBuffer(stage, binding_index, size);
1034 cpu_memory.ReadBlockUnsafe(cpu_addr, span.data(), size); 1039 cpu_memory.ReadBlockUnsafe(cpu_addr, span.data(), size);
@@ -1046,9 +1051,15 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32
1046 // This exists to avoid instances where the fast buffer is bound and a GPU write happens 1051 // This exists to avoid instances where the fast buffer is bound and a GPU write happens
1047 return; 1052 return;
1048 } 1053 }
1049 fast_bound_uniform_buffers[stage] &= ~(1U << binding_index);
1050
1051 const u32 offset = buffer.Offset(cpu_addr); 1054 const u32 offset = buffer.Offset(cpu_addr);
1055 if constexpr (IS_OPENGL) {
1056 // Fast buffer will be unbound
1057 fast_bound_uniform_buffers[stage] &= ~(1U << binding_index);
1058
1059 // Mark the index as dirty if offset doesn't match
1060 const bool is_copy_bind = offset != 0 && !runtime.SupportsNonZeroUniformOffset();
1061 dirty_uniform_buffers[stage] |= (is_copy_bind ? 1U : 0U) << index;
1062 }
1052 if constexpr (NEEDS_BIND_UNIFORM_INDEX) { 1063 if constexpr (NEEDS_BIND_UNIFORM_INDEX) {
1053 runtime.BindUniformBuffer(stage, binding_index, buffer, offset, size); 1064 runtime.BindUniformBuffer(stage, binding_index, buffer, offset, size);
1054 } else { 1065 } else {