[Fix] (MG_Impl/GLImpl): stop double-recording GL errors for a bad program handle

glBindFragDataLocation, glGetFragDataLocation and glGetFragDataIndex each
recorded a redundant GL_INVALID_OPERATION on top of the error that
TryToGetProgramObject already recorded (GL_INVALID_VALUE for an unknown
name, GL_INVALID_OPERATION for a non-program object). One bad call thus
queued two errors, so an app calling glGetError twice saw a spurious
second error, and any following code that expects a clean error queue
(e.g. a later test) picked up the stale one.

Drop the second RecordError from all three call sites and rely on the
single error TryToGetProgramObject already reports -- matching the clean
`if (!programObject) return;` pattern the rest of GL_Program.cpp uses. The
first, app-visible error is unchanged; only the redundant second is gone.

ProgramTest's invalid-handle case now asserts exactly one error (mutation-
verified: reintroducing the second record fails it) and keeps a defensive
error-queue drain. ProgramTest 24/24.
This commit is contained in:
2026-07-11 00:19:33 -04:00
parent 9ffcb23877
commit bebe534bad
2 changed files with 9 additions and 23 deletions
+5 -21
View File
@@ -1485,13 +1485,9 @@ namespace MobileGL::MG_Impl::GLImpl {
void BindFragDataLocation_State(GLuint program, GLuint colorNumber, const char* name) {
auto& programObject = TryToGetProgramObject(program);
if (programObject == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
std::to_string(program) + " is not the name of a program object."));
return;
}
// TryToGetProgramObject already recorded the error for a bad handle (GL_INVALID_VALUE for an
// unknown name, GL_INVALID_OPERATION for a non-program object); do not record a second one.
if (!programObject) return;
if (name == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
@@ -1520,13 +1516,7 @@ namespace MobileGL::MG_Impl::GLImpl {
GLint GetFragDataLocation_State(GLuint program, const char* name) {
auto& programObject = TryToGetProgramObject(program);
if (programObject == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
std::to_string(program) + " is not the name of a program object."));
return -1;
}
if (!programObject) return -1; // TryToGetProgramObject already recorded the error.
if (name == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
@@ -1545,13 +1535,7 @@ namespace MobileGL::MG_Impl::GLImpl {
GLint GetFragDataIndex_State(GLuint program, const char* name) {
auto& programObject = TryToGetProgramObject(program);
if (programObject == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
std::to_string(program) + " is not the name of a program object."));
return -1;
}
if (!programObject) return -1; // TryToGetProgramObject already recorded the error.
if (name == nullptr) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,