Skip to content

shaders: replace switch with if/else in world2d fragment shader - #1817

Open
ranawaqas-ai wants to merge 2 commits into
SFTtech:masterfrom
ranawaqas-ai:fix/macos-shader-switch
Open

ranawaqas-ai wants to merge 2 commits into
SFTtech:masterfrom
ranawaqas-ai:fix/macos-shader-switch

Conversation

@ranawaqas-ai

Copy link
Copy Markdown

Apple's OpenGL shader compiler crashes with SIGSEGV while linking world2d.frag.glsl. The stack ends in glpLLVMCGSwitchStatement inside gleLinkProgram, so the switch (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 3 renders terrain and sprites normally.

Also adds me to copying.md as a first-time contributor, per doc/contributing.md.

make checkmerge passes.

ranawaqas-ai and others added 2 commits September 18, 2026 14:43
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 TheJJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants