Merge pull request #4359 from ReinUsesLisp/clamp-shared
renderer_{opengl,vulkan}: Clamp shared memory to host's limit
This commit is contained in:
commit
7278c59d70
6 changed files with 42 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue