From a389477f785c622486c3cfcd3e45be1dc0ca4ec7 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Fri, 31 Jul 2026 16:47:45 -0400 Subject: [PATCH] [Fix] (MG_Impl): report INVALID_OPERATION for shader names in program APIs Program entry points answered GL_INVALID_VALUE whenever the name did not resolve to a program, including names that exist but belong to a shader object. Programs and shaders share one name space, so the spec (and KHR-GL33.get_uniform_tests.get_uniform) requires GL_INVALID_OPERATION for the shader-name case and GL_INVALID_VALUE only for names GL never handed out, matching the interface-query helper's existing behavior. --- MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp index 9a2a0ee3..816cb2ef 100644 --- a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp +++ b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp @@ -49,10 +49,18 @@ namespace MobileGL::MG_Impl::GLImpl { static bool CheckProgramNameValidity(GLuint program) { if (!MG_State::pGLContext->ValidateProgramName(program)) { + // Programs and shaders share one name space: a name that exists but + // belongs to a shader is INVALID_OPERATION, a name GL never handed + // out is INVALID_VALUE (GL 3.3 core 2.11.x). + const ErrorCode error = MG_State::pGLContext->ValidateShaderName(program) + ? ErrorCode::InvalidOperation + : ErrorCode::InvalidValue; MG_State::pGLContext->RecordError( - ErrorCode::InvalidValue, + error, MakeUnique("MG_Impl/GLImpl", __func__, - std::to_string(program) + " is not a valid name.")); + std::to_string(program) + + (error == ErrorCode::InvalidOperation ? " is not a program object." + : " is not a valid name."))); return false; } return true;