diff --git a/Data/Sys/Shaders/asciiart.glsl b/Data/Sys/Shaders/asciiart.glsl index c9fa520a12..cbb9f750a1 100644 --- a/Data/Sys/Shaders/asciiart.glsl +++ b/Data/Sys/Shaders/asciiart.glsl @@ -21,6 +21,14 @@ const uint UNROLL_SIMD = 3; // max MAX_CHARS / 32 // #undef SUPPORTS_SUBGROUP_REDUCTION +#ifdef API_VULKAN +// By default, subgroupBroadcast only supports compile time constants as index. +// However we need an uniform instead. This is always supported in OpenGL, +// but in Vulkan only in SPIR-V >= 1.5. +// So fall back to subgroupShuffle on Vulkan instead. +#define subgroupBroadcast subgroupShuffle +#endif + /* The header-only font We have 96 (ASCII) characters, each of them is 12 pixels high and 8 pixels wide. diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index 49b007f43b..3555a6c9b7 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -79,6 +79,7 @@ static const char SUBGROUP_HELPER_HEADER[] = R"( #extension GL_KHR_shader_subgroup_basic : enable #extension GL_KHR_shader_subgroup_arithmetic : enable #extension GL_KHR_shader_subgroup_ballot : enable + #extension GL_KHR_shader_subgroup_shuffle : enable #define SUPPORTS_SUBGROUP_REDUCTION 1 #define IS_HELPER_INVOCATION gl_HelperInvocation diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 4834a69bb8..5b5f2ffaee 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -981,9 +981,11 @@ void VulkanContext::PopulateShaderSubgroupSupport() // We require basic ops (for gl_SubgroupInvocationID), ballot (for subgroupBallot, // subgroupBallotFindLSB), and arithmetic (for subgroupMin/subgroupMax). - constexpr VkSubgroupFeatureFlags required_operations = VK_SUBGROUP_FEATURE_BASIC_BIT | - VK_SUBGROUP_FEATURE_ARITHMETIC_BIT | - VK_SUBGROUP_FEATURE_BALLOT_BIT; + // Shuffle is enabled as a workaround until SPIR-V >= 1.5 is enabled with broadcast(uniform) + // support. + constexpr VkSubgroupFeatureFlags required_operations = + VK_SUBGROUP_FEATURE_BASIC_BIT | VK_SUBGROUP_FEATURE_ARITHMETIC_BIT | + VK_SUBGROUP_FEATURE_BALLOT_BIT | VK_SUBGROUP_FEATURE_SHUFFLE_BIT; m_supports_shader_subgroup_operations = (subgroup_properties.supportedOperations & required_operations) == required_operations && subgroup_properties.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT &&