summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorRodrigo Locatti <reinuseslisp@airmail.cc>2020-07-21 09:51:05 +0200
committerGitHub <noreply@github.com>2020-07-21 09:51:05 +0200
commit7278c59d70dc1fdd8755f60a878da6d42825c7a0 (patch)
treeea37c477caeec1747ac8b8b1f775da40dd175fa6 /src/video_core/renderer_vulkan
parentMerge pull request #4360 from ReinUsesLisp/glasm-bar (diff)
parentrenderer_{opengl,vulkan}: Clamp shared memory to host's limit (diff)
downloadyuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar.gz
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar.bz2
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar.lz
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar.xz
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.tar.zst
yuzu-7278c59d70dc1fdd8755f60a878da6d42825c7a0.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_device.h5
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp12
2 files changed, 14 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h
index ae5c21baa..529744f2d 100644
--- a/src/video_core/renderer_vulkan/vk_device.h
+++ b/src/video_core/renderer_vulkan/vk_device.h
@@ -122,6 +122,11 @@ public:
return properties.limits.maxPushConstantsSize;
}
+ /// Returns the maximum size for shared memory.
+ u32 GetMaxComputeSharedMemorySize() const {
+ return properties.limits.maxComputeSharedMemorySize;
+ }
+
/// Returns true if ASTC is natively supported.
bool IsOptimalAstcSupported() const {
return is_optimal_astc_supported;
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 97429cc59..694452fd8 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -685,13 +685,19 @@ private:
}
t_smem_uint = TypePointer(spv::StorageClass::Workgroup, t_uint);
- const u32 smem_size = specialization.shared_memory_size;
+ u32 smem_size = specialization.shared_memory_size * 4;
if (smem_size == 0) {
// Avoid declaring an empty array.
return;
}
- const auto element_count = static_cast<u32>(Common::AlignUp(smem_size, 4) / 4);
- const Id type_array = TypeArray(t_uint, Constant(t_uint, element_count));
+ const u32 limit = device.GetMaxComputeSharedMemorySize();
+ if (smem_size > limit) {
+ LOG_ERROR(Render_Vulkan, "Shared memory size {} is clamped to host's limit {}",
+ smem_size, limit);
+ smem_size = limit;
+ }
+
+ const Id type_array = TypeArray(t_uint, Constant(t_uint, smem_size / 4));
const Id type_pointer = TypePointer(spv::StorageClass::Workgroup, type_array);
Name(type_pointer, "SharedMemory");