Skip to content

Commit 276e4bc

Browse files
committed
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.
1 parent cd386a3 commit 276e4bc

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

gfx/drivers/gl3.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,38 +2128,36 @@ static bool gl3_init_pipelines(gl3_t *gl)
21282128
**/
21292129
static enum rarch_shader_type gl3_get_fallback_shader_type(enum rarch_shader_type type)
21302130
{
2131-
#if defined(HAVE_SLANG) || defined(HAVE_GLSL) || defined(HAVE_CG)
2131+
#if defined(HAVE_SLANG) || defined(HAVE_GLSL)
21322132
int i;
21332133
gfx_ctx_flags_t flags;
21342134
flags.flags = 0;
21352135
video_context_driver_get_flags(&flags);
21362136

2137-
if (type != RARCH_SHADER_CG && type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
2137+
/* gl3 (glcore video driver) only ever advertises slang via spirv-cross.
2138+
* Cg requires the legacy fixed-function / ARB asm pipeline that Core
2139+
* Profile contexts don't expose, and no context driver advertises
2140+
* GFX_CTX_FLAGS_SHADERS_CG when the active video driver is "glcore"
2141+
* (see e.g. x_ctx.c, wgl_ctx.c). Treat any incoming RARCH_SHADER_CG
2142+
* the same as an unknown type and fall back to slang. */
2143+
if (type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
21382144
{
21392145
type = DEFAULT_SHADER_TYPE;
21402146

2141-
if (type != RARCH_SHADER_CG && type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
2147+
if (type != RARCH_SHADER_GLSL && type != RARCH_SHADER_SLANG)
21422148
type = RARCH_SHADER_SLANG;
21432149
}
21442150

2145-
for (i = 0; i < 3; i++)
2151+
for (i = 0; i < 2; i++)
21462152
{
21472153
switch (type)
21482154
{
2149-
case RARCH_SHADER_CG:
2150-
#ifdef HAVE_CG
2151-
if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_CG))
2152-
return type;
2153-
#endif
2154-
type = RARCH_SHADER_SLANG;
2155-
break;
2156-
21572155
case RARCH_SHADER_GLSL:
21582156
#ifdef HAVE_GLSL
21592157
if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_SHADERS_GLSL))
21602158
return type;
21612159
#endif
2162-
type = RARCH_SHADER_CG;
2160+
type = RARCH_SHADER_SLANG;
21632161
break;
21642162

21652163
case RARCH_SHADER_SLANG:
@@ -2231,11 +2229,6 @@ static const shader_backend_t *gl3_shader_driver_set_backend(
22312229

22322230
switch (fallback)
22332231
{
2234-
#ifdef HAVE_CG
2235-
case RARCH_SHADER_CG:
2236-
RARCH_LOG("[GLCore] Using Cg shader backend.\n");
2237-
return &gl_cg_backend;
2238-
#endif
22392232
#ifdef HAVE_GLSL
22402233
case RARCH_SHADER_GLSL:
22412234
RARCH_LOG("[GLCore] Using GLSL shader backend.\n");

0 commit comments

Comments
 (0)