From a9cc583fb0f8877be97cf5903c3fb76abafcf2c6 Mon Sep 17 00:00:00 2001 From: Earu <20880060+Earu@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:28:21 +0400 Subject: [PATCH] Reset disabled user clip planes to a no-clip plane so Zink on macOS stops clipping with stale planes --- Source.ShaderAPI.Gl46/ShaderAPIGl46.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs b/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs index 4f31c692..aebcec60 100644 --- a/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs +++ b/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs @@ -260,6 +260,8 @@ private unsafe void CreateMatrixStacks() { uboClipPlanes = glCreateBuffer(); glObjectLabel(GL_BUFFER, uboClipPlanes, "ShaderAPI User Clip Planes UBO"); glNamedBufferData(uboClipPlanes, sizeof(Vector4) * Gl46.HardwareConfig.MAXUSERCLIPPLANES, null, GL_DYNAMIC_DRAW); + for (int i = 0; i < Gl46.HardwareConfig.MAXUSERCLIPPLANES; i++) + UploadNoClipPlane(i); UniformBufferBindings.Bind(UniformBufferBindingLocation.UserClipPlanes, uboClipPlanes); } @@ -3473,10 +3475,18 @@ public void EnableClipPlane(int index, bool bEnable) { else { UserClipPlaneEnabled &= ~(1 << index); glDisable(GL_CLIP_DISTANCE0 + index); + UploadNoClipPlane(index); } } } + private unsafe void UploadNoClipPlane(int index) { + Vector4 noClip = new(0, 0, 0, 1); + glNamedBufferSubData(uboClipPlanes, index * sizeof(Vector4), sizeof(Vector4), &noClip); + UserClipPlaneProj[index] = noClip; + UserClipPlaneChanged |= 1 << index; + } + public void EnableFastClip(bool enable) { throw new NotImplementedException("Incomplete port of IShaderAPI"); }