shaders: replace switch with if/else in world2d fragment shader - #1817
Open
ranawaqas-ai wants to merge 2 commits into
Open
ranawaqas-ai wants to merge 2 commits into
ranawaqas-ai wants to merge 2 commits into
Conversation
Apple's OpenGL shader compiler crashes while linking this shader. The stack ends in glpLLVMCGSwitchStatement, and the crash reproduces with both Homebrew clang and Apple clang, so it is a driver bug rather than a build problem. Using if/else avoids the compiler path entirely and lets the world render stage load on macOS. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TheJJ
requested changes
Sep 21, 2026
TheJJ
left a comment
Member
There was a problem hiding this comment.
hmm, but the switch is the more efficient implementation, isn't there some better fix for macos? since other platforms compile this correctly, i don't think we should workaround a mac bug for all platforms :) is there a way you somehow use a more compliant glsl compiler?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apple's OpenGL shader compiler crashes with SIGSEGV while linking
world2d.frag.glsl. The stack ends inglpLLVMCGSwitchStatementinsidegleLinkProgram, so theswitch (alpha)block is what trips it.Reproduced on macOS 27 (arm64) with Qt 6.11.2, using both Homebrew clang 23.1.1 and Apple clang 21.0.0, so it is a driver bug rather than a toolchain problem. Any demo that loads the world render stage dies on startup, including
renderer_demo 3.Rewriting the switch as if/else avoids that compiler path. After the change the world render stage loads and
renderer_demo 3renders terrain and sprites normally.Also adds me to
copying.mdas a first-time contributor, per doc/contributing.md.make checkmergepasses.