From a08669df72c24e4758f7e9488683cdae7c55e084 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 16 Jul 2026 22:11:43 -0400 Subject: [PATCH] [Fix] (MG_Impl/GLImpl): stop recording GL errors on the delete/query paths of every object family - glDeleteBuffers/VertexArrays/Renderbuffers/Framebuffers must silently ignore unknown names and glIsTexture must never raise, while glBindSampler now reports INVALID_OPERATION like the other bind entry points --- MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp | 5 ++++- .../MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp | 8 ++++++-- MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp | 11 ++++++++++- MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp | 4 +++- .../MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp | 4 +++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index b27a0665..b47b492e 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -441,7 +441,10 @@ namespace MobileGL::MG_Impl::GLImpl { for (SizeT i = 0; i < static_cast(n); ++i) { Uint bufferName = buffers[i]; if (bufferName == 0) continue; - if (!BufferImpl::ValidateBufferName(bufferName, true)) continue; + // GL 3.3 core 2.9: names that do not correspond to an existing buffer are silently + // ignored here, so probe with the non-recording query - the shared validator would + // record INVALID_OPERATION, which is only correct on the bind path. + if (!MG_State::pGLContext->ValidateBufferName(bufferName)) continue; MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName); } } diff --git a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp index f987cdfa..a8bc603d 100644 --- a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp @@ -1201,7 +1201,9 @@ namespace MobileGL::MG_Impl::GLImpl { for (SizeT i = 0; i < static_cast(n); ++i) { Uint bufferName = renderbuffers[i]; if (bufferName == 0) continue; - if (!FramebufferImpl::ValidateRenderbufferName(bufferName)) continue; + // GL 3.3 core 4.4.2: unknown names are silently ignored on delete; the shared bind-path + // validator would record INVALID_OPERATION instead. + if (!MG_State::pGLContext->ValidateRenderbufferName(bufferName)) continue; MG_State::pGLContext->MarkRenderbufferObjectForDeletion(bufferName); } } @@ -1224,7 +1226,9 @@ namespace MobileGL::MG_Impl::GLImpl { for (SizeT i = 0; i < static_cast(n); ++i) { Uint bufferName = framebuffers[i]; if (bufferName == 0) continue; - if (!FramebufferImpl::ValidateFramebufferName(bufferName)) continue; + // GL 3.3 core 4.4.1: unknown names are silently ignored on delete; the shared bind-path + // validator would record INVALID_OPERATION instead. + if (!MG_State::pGLContext->ValidateFramebufferName(bufferName)) continue; MG_State::pGLContext->MarkFramebufferObjectForDeletion(bufferName); } } diff --git a/MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp b/MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp index 0f31503e..2c78160c 100644 --- a/MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp +++ b/MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp @@ -233,7 +233,16 @@ namespace MobileGL::MG_Impl::GLImpl { if (sampler == 0) { textureUnit.SetSamplerObject(nullptr); } else { - if (!SamplerImpl::ValidateSamplerName(sampler)) return; + // GL 3.3 core 3.8.2: BindSampler on a name GenSamplers never returned - or one already + // deleted - is INVALID_OPERATION. SamplerParameter* raises INVALID_VALUE for the same + // name, which is why this cannot go through the shared SamplerImpl validator. + if (!MG_State::pGLContext->ValidateSamplerName(sampler)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeUnique("MG_Impl/GLImpl", "BindSampler_State", + std::format("Invalid sampler name {}", sampler))); + return; + } Bool doesSamplerObjectCreated = MG_State::pGLContext->ValidateSamplerObject(sampler); if (!doesSamplerObjectCreated) { MG_State::pGLContext->CreateSamplerObject(sampler); diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index fc0c852a..4654a311 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -1753,7 +1753,9 @@ namespace MobileGL::MG_Impl::GLImpl { GLboolean IsTexture_State(GLuint texture) { // ======================= Processing ================================ - if (!TextureImpl::ValidateTextureName(texture, true)) return GL_FALSE; + // GL 3.3 core 6.1.4: IsTexture generates no error - an unknown, deleted or merely reserved + // name is just GL_FALSE. Probing with the recording validator (as every other Is* entry + // point already avoids doing) would leave a spurious INVALID_VALUE behind. return MG_State::pGLContext->ValidateTextureObject(texture) ? GL_TRUE : GL_FALSE; } diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp index 9e40c3b0..221cb974 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp @@ -288,7 +288,9 @@ namespace MobileGL::MG_Impl::GLImpl { GLuint vao = arrays[i]; if (vao == 0) continue; - if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue; + // GL 3.3 core 2.10: unknown names are silently ignored on delete; the shared bind-path + // validator would record INVALID_OPERATION instead. + if (!MG_State::pGLContext->ValidateVertexArrayName(vao)) continue; if (MG_State::pGLContext->GetBoundVertexArray() && MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) {