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:
degasus
2023-01-31 18:10:48 +01:00
parent aaad0cd39f
commit 4b2aa948e6
8 changed files with 66 additions and 33 deletions

View File

@ -489,7 +489,14 @@ bool PopulateConfig(GLContext* m_main_gl_context)
else if (GLExtensions::Version() >= 430)
{
// TODO: We should really parse the GL_SHADING_LANGUAGE_VERSION token.
g_ogl_config.eSupportedGLSLVersion = Glsl430;
if (GLExtensions::Version() >= 450)
{
g_ogl_config.eSupportedGLSLVersion = Glsl450;
}
else
{
g_ogl_config.eSupportedGLSLVersion = Glsl430;
}
g_ogl_config.bSupportsTextureStorage = true;
g_ogl_config.bSupportsImageLoadStore = true;
g_Config.backend_info.bSupportsSSAA = true;
@ -531,8 +538,23 @@ bool PopulateConfig(GLContext* m_main_gl_context)
if (g_ogl_config.max_samples < 1 || !g_ogl_config.bSupportsMSAA)
g_ogl_config.max_samples = 1;
g_ogl_config.bSupportsShaderThreadShuffleNV =
GLExtensions::Supports("GL_NV_shader_thread_shuffle");
const bool bSupportsIsHelperInvocation = g_ogl_config.bIsES ?
g_ogl_config.eSupportedGLSLVersion >= GlslEs320 :
g_ogl_config.eSupportedGLSLVersion >= Glsl450;
g_ogl_config.bSupportsKHRShaderSubgroup =
GLExtensions::Supports("GL_KHR_shader_subgroup") && bSupportsIsHelperInvocation;
if (g_ogl_config.bSupportsKHRShaderSubgroup)
{
// Check for the features: basic + arithmetic + ballot
GLint supported_features = 0;
glGetIntegerv(GL_SUBGROUP_SUPPORTED_FEATURES_KHR, &supported_features);
if (~supported_features &
(GL_SUBGROUP_FEATURE_BASIC_BIT_KHR | GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR |
GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR))
{
g_ogl_config.bSupportsKHRShaderSubgroup = false;
}
}
// We require texel buffers, image load store, and compute shaders to enable GPU texture decoding.
// If the driver doesn't expose the extensions, but supports GL4.3/GLES3.1, it will still be