mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
VideoBackend/OGL: Prefer KHR_subgroup over NV_shader_thread.
While the NV extension is totally fine, the KHR extension should be able to support more hardware. For NVIDIA, the hardware either supports both or neither, it just needs a driver from the last two years. For AMD, the drivers from late 2022-12 seems to bring support for the KHR extension. For Intel, the KHR is also supported for some years.
This commit is contained in:
@ -78,6 +78,8 @@ static std::string GetGLSLVersionString()
|
||||
return "#version 400";
|
||||
case Glsl430:
|
||||
return "#version 430";
|
||||
case Glsl450:
|
||||
return "#version 450";
|
||||
default:
|
||||
// Shouldn't ever hit this
|
||||
return "#version ERROR";
|
||||
@ -720,25 +722,18 @@ void ProgramShaderCache::CreateHeader()
|
||||
}
|
||||
|
||||
std::string shader_shuffle_string;
|
||||
if (g_ogl_config.bSupportsShaderThreadShuffleNV)
|
||||
if (g_ogl_config.bSupportsKHRShaderSubgroup)
|
||||
{
|
||||
shader_shuffle_string = R"(
|
||||
#extension GL_NV_shader_thread_group : enable
|
||||
#extension GL_NV_shader_thread_shuffle : enable
|
||||
#extension GL_KHR_shader_subgroup_basic : enable
|
||||
#extension GL_KHR_shader_subgroup_arithmetic : enable
|
||||
#extension GL_KHR_shader_subgroup_ballot : enable
|
||||
|
||||
#define SUPPORTS_SUBGROUP_REDUCTION 1
|
||||
|
||||
// The xor shuffle below produces incorrect results if all threads in a warp are not active.
|
||||
#define CAN_USE_SUBGROUP_REDUCTION (ballotThreadNV(true) == 0xFFFFFFFFu)
|
||||
|
||||
#define IS_HELPER_INVOCATION gl_HelperThreadNV
|
||||
#define IS_FIRST_ACTIVE_INVOCATION (gl_ThreadInWarpNV == findLSB(ballotThreadNV(!gl_HelperThreadNV)))
|
||||
#define SUBGROUP_REDUCTION(func, value) value = func(value, shuffleXorNV(value, 16, 32)); \
|
||||
value = func(value, shuffleXorNV(value, 8, 32)); \
|
||||
value = func(value, shuffleXorNV(value, 4, 32)); \
|
||||
value = func(value, shuffleXorNV(value, 2, 32)); \
|
||||
value = func(value, shuffleXorNV(value, 1, 32));
|
||||
#define SUBGROUP_MIN(value) SUBGROUP_REDUCTION(min, value)
|
||||
#define SUBGROUP_MAX(value) SUBGROUP_REDUCTION(max, value)
|
||||
#define IS_HELPER_INVOCATION gl_HelperInvocation
|
||||
#define IS_FIRST_ACTIVE_INVOCATION (subgroupElect())
|
||||
#define SUBGROUP_MIN(value) value = subgroupMin(value)
|
||||
#define SUBGROUP_MAX(value) value = subgroupMax(value)
|
||||
)";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user