mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-08 08:10:30 -10:00
gl3: remove dead Cg shader-backend paths from glcore driver
The gl3 (glcore video driver) shader fallback selector and dispatcher both had RARCH_SHADER_CG arms, but those branches were unreachable in any build configuration: 1. The Cg fallback in gl3_get_fallback_shader_type gates on GFX_CTX_FLAGS_SHADERS_CG. No context driver ever sets that flag when the active video driver is "glcore" -- audited x_ctx.c:1106-1116, wgl_ctx.c:778-788, drm_ctx.c, drm_go2_ctx.c, orbis_ctx.c, switch_ctx.c, wayland_ctx.c, xegl_ctx.c (eight context drivers, all of which the glcore branch advertises only SHADERS_SLANG). The Cg flag is only set by ps3_ctx (which uses the rsx driver, not glcore) and by the legacy / non-Core branch of x_ctx and wgl_ctx (gated on !core_hw_context_enable, so only for the gl driver, not glcore). 2. Even if the gating were bypassed, gl_cg_backend in shader_gl_cg.c uses cgGLEnableProfile / cgGLBindProgram / cgGLEnableClientState et al. These rely on the legacy ARB asm program pipeline (GL_VERTEX_PROGRAM_ARB style) which is removed from Core Profile contexts. NVIDIA's Cg runtime hasn't been updated since 2012 and has no Core Profile support. Remove: - the RARCH_SHADER_CG case in gl3_get_fallback_shader_type - the RARCH_SHADER_CG case in gl3_shader_driver_set_backend - HAVE_CG from the function-level guard - the now-unused 3rd loop iteration (the cycle is GLSL <-> SLANG) The fallback chain becomes a 2-element cycle: GLSL falls back to SLANG and vice versa, matching what the gating actually allows. Add a comment at the top of gl3_get_fallback_shader_type explaining the gl3-vs-Cg situation so future readers don't reintroduce the dead arm. No behaviour change on any build: HAVE_CG was defined for some Windows builds, but the gates above already prevented those branches from executing.
This commit is contained in:
1 parent
cd386a3933
commit
276e4bce82
1 file changed
+11
-18
+11
-18
@@ -2128,38 +2128,36 @@ static bool gl3_init_pipelines(gl3_t *gl)
|
||||
**/
|
||||
static enum rarch_shader_type gl3_get_fallback_shader_type(enum rarch_shader_type type)
|
||||
{
|
||||
#if defined(HAVE_SLANG) || defined(HAVE_GLSL) || defined(HAVE_CG)
|
||||
#if defined(HAVE_SLANG) || defined(HAVE_GLSL)
|
||||
int i;
|
||||
gfx_ctx_flags_t flags;
|
||||
flags.flags = 0;
|
||||
video_context_driver_get_flags(&flags);
|
||||
|
||||
if (type != RARCH_SHADER_CG && type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
|
||||
/* gl3 (glcore video driver) only ever advertises slang via spirv-cross.
|
||||
* Cg requires the legacy fixed-function / ARB asm pipeline that Core
|
||||
* Profile contexts don't expose, and no context driver advertises
|
||||
* GFX_CTX_FLAGS_SHADERS_CG when the active video driver is "glcore"
|
||||
* (see e.g. x_ctx.c, wgl_ctx.c). Treat any incoming RARCH_SHADER_CG
|
||||
* the same as an unknown type and fall back to slang. */
|
||||
if (type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
|
||||
{
|
||||
type = DEFAULT_SHADER_TYPE;
|
||||
|
||||
if (type != RARCH_SHADER_CG && type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
|
||||
if (type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
|
||||
type = RARCH_SHADER_SLANG;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RARCH_SHADER_CG:
|
||||
#ifdef HAVE_CG
|
||||
if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG))
|
||||
return type;
|
||||
#endif
|
||||
type = RARCH_SHADER_SLANG;
|
||||
break;
|
||||
|
||||
case RARCH_SHADER_GLSL:
|
||||
#ifdef HAVE_GLSL
|
||||
if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL))
|
||||
return type;
|
||||
#endif
|
||||
type = RARCH_SHADER_CG;
|
||||
type = RARCH_SHADER_SLANG;
|
||||
break;
|
||||
|
||||
case RARCH_SHADER_SLANG:
|
||||
@@ -2231,11 +2229,6 @@ static const shader_backend_t *gl3_shader_driver_set_backend(
|
||||
|
||||
switch (fallback)
|
||||
{
|
||||
#ifdef HAVE_CG
|
||||
case RARCH_SHADER_CG:
|
||||
RARCH_LOG("[GLCore] Using Cg shader backend.\n");
|
||||
return &gl_cg_backend;
|
||||
#endif
|
||||
#ifdef HAVE_GLSL
|
||||
case RARCH_SHADER_GLSL:
|
||||
RARCH_LOG("[GLCore] Using GLSL shader backend.\n");
|
||||
|
||||
Reference in new issue
Block a user