Skip to content

[macOS] Restore gl_HelperInvocation workaround for Intel macs. #107769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Jun 20, 2025

Restores workaround removed in #102552

Fixes #107753

If I understand correctly, it's not adding any new defines, so should not create additional shader variants for baker and cause any issues.

@bruvzg bruvzg added this to the 4.5 milestone Jun 20, 2025
@bruvzg bruvzg requested review from DarioSamo and clayjohn June 20, 2025 15:28
@bruvzg bruvzg added the bug label Jun 20, 2025
@bruvzg bruvzg requested a review from a team as a code owner June 20, 2025 15:28
@stuartcarnie
Copy link
Contributor

Should be fine for runtime shader generation on Intel Macs, but should be noted that when baking on Linux or Windows, MOLTENVK_USED won't be defined, so it will generate shaders that may not work on Intel macs using MoltenVK.

Is it specific GPUs on Intel Macs that don't work?

@bruvzg
Copy link
Member Author

bruvzg commented Jun 20, 2025

but should be noted that when baking on Linux or Windows, MOLTENVK_USED won't be defined

Same with NO_IMAGE_ATOMICS which is defined only on macOS and iOS and used in many places, so baking shaders for macOS/iOS from a non-mac system is likely already broken (for both Metal and Vulkan).

Is it specific GPUs on Intel Macs that don't work?

No idea, but the issue was recently encountered on AMD GPU and previously on Intel GPUs, so I assume it's a generic issue with all Intel macs.

@stuartcarnie
Copy link
Contributor

stuartcarnie commented Jun 20, 2025

Same with NO_IMAGE_ATOMICS which is defined only on macOS and iOS and used in many places, so baking shaders for macOS/iOS from a non-mac system is likely already broken (for both Metal and Vulkan).

Good point – I need to test NO_IMAGE_ATOMICS again. Some of that was to do with SPIRV-Cross issues, which I haven't revisited.

I noticed @akien-mga is upgrading Vulkan SDKs in #107773. I could do SPIRV-Cross separately and fix the Metal compilation (not hard). @akien-mga has resolved it!

@stuartcarnie
Copy link
Contributor

In order to address that, additional context needs to be passed through the renderer, so that it can bake for different targets / platforms with different feature sets. I already started that in the Metal shader baker code, where I can pass OS + GPU to govern how the shaders are generated and compiled.

@@ -234,9 +234,11 @@ void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, c
builder.append(String("#define ") + String(E.key) + "_CODE_USED\n");
}
#if (defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED))
#if defined(__x86_64) || defined(__x86_64__)
Copy link
Member

Choose a reason for hiding this comment

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

I believe __x86_64__ should always work, no? So __x86_64 is likely redundant and not necessary.

@bruvzg
Copy link
Member Author

bruvzg commented Jun 20, 2025

In order to address that, additional context needs to be passed through the renderer, so that it can bake for different targets / platforms with different feature sets. I already started that in the Metal shader baker code, where I can pass OS + GPU to govern how the shaders are generated and compiled.

In case on Metal it seems to be doing it on already compiled SPIRV code, this probably won't work with define (or will be overcomplicated). So it probably should do it by enabling/disabling shader variants on a source level, and ShaderBakerExportPlugin already do have information about target platform, I guess it only need a way to selectively pick variants depending on platform.

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

Successfully merging this pull request may close these issues.

OmniLight3D & SportLight3D do not work on Intel Mac anymore ( Forward+)
3 participants