From d81a6a099898f126cbbc5556ce08a6cbf822b727 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Tue, 4 Aug 2026 09:52:40 -0400 Subject: [PATCH] [Fix] (MG_Impl): silently ignore program and shader name zero on delete glDeleteProgram and glDeleteShader are the two entry points in the program/shader name space where 0 is not "a name GL never handed out" but an explicit no-op: "if program is zero, it is silently ignored" (GL 4.6 core 7.3, and 7.1 for shaders). Both went through the shared name validator instead and recorded GL_INVALID_VALUE. Only tests that never got as far as creating a program noticed, because they still run their cleanup path: the five KHR-GL40.texture_gather.*-cube-array cases bail out of Init with "GL_ARB_texture_cube_map_array not supported", then Cleanup deletes its zero-initialised handles and the leftover error fails the case after the fact - the downstream-error-misattribution shape. Every array-taking delete already skipped 0. --- MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp index 65229d4c..d2dc7a92 100644 --- a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp +++ b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp @@ -325,11 +325,16 @@ namespace MobileGL::MG_Impl::GLImpl { } void DeleteProgram_State(GLuint program) { + // "If program is zero, it is silently ignored" (GL 4.6 core 7.3) - unlike every + // other program entry point, where 0 is a name GL never handed out. + if (program == 0) return; if (!CheckProgramNameValidity(program)) return; MG_State::pGLContext->MarkProgramForDeletion(program); } void DeleteShader_State(GLuint shader) { + // Same silent-zero rule as glDeleteProgram (GL 4.6 core 7.1). + if (shader == 0) return; if (!CheckShaderNameValidity(shader)) return; MG_State::pGLContext->MarkShaderForDeletion(shader); }