From 56db115a1a77bb83e440c78d713eafd3146c7f3f Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 16 Jul 2026 19:10:11 -0400 Subject: [PATCH] [Fix] (MG_Impl/GLImpl): clamp glClearDepth to [0,1] per GL 3.3 (Vulkan clear values require it) --- MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp index 54d0557b..aa1fe5a1 100644 --- a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp +++ b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp @@ -649,7 +649,9 @@ namespace MobileGL::MG_Impl::GLImpl { } void ClearDepth_State(GLclampd depth) { - MG_State::pGLContext->SetClearDepth(static_cast(depth)); + // GL 3.3 ยง4.2.3: the clear depth is clamped to [0,1] at specification time (Vulkan clear + // values additionally require it: VUID-VkClearDepthStencilValue-depth-00022). + MG_State::pGLContext->SetClearDepth(ClampUnitFloat(static_cast(depth))); } void ClearColor_State(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {