Skip to content
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

[macOS] Shader failure at startup leaves Project Manager black #62548

Closed
Kev opened this issue Jun 30, 2022 · 25 comments · Fixed by #62563
Closed

[macOS] Shader failure at startup leaves Project Manager black #62548

Kev opened this issue Jun 30, 2022 · 25 comments · Fixed by #62563

Comments

@Kev
Copy link
Contributor

Kev commented Jun 30, 2022

Godot version

4.0-alpha11

System information

macOS 12.4 MacBook Pro Intel(R) Iris(TM) Plus Graphics 655

Issue description

Firing up alpha 11 gives me a black window (other than the title bar). Capturing stdin/stderr gives:

arguments
0: /Applications/Godot_v4.0-alpha11.app/Contents/MacOS/Godot
Current path: /Users/[snip]
Godot Engine v4.0.alpha11.official.d631ee330 - https://godotengine.org
Vulkan API 1.1.198 - Using Vulkan Device #0: Intel - Intel(R) Iris(TM) Plus Graphics 655
[1;31mERROR:
[0;91m Reflection of SPIR-V shader stage 'Compute' failed finding interface variable.
[0;90m   at: shader_compile_binary_from_spirv (drivers/vulkan/rendering_device_vulkan.cpp:4748)
[1;31mERROR:
[0;91m Condition "shader_data.size() == 0" is true.
[0;90m   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:287)
[1;31mERROR:
[0;91m Reflection of SPIR-V shader stage 'Compute' failed finding interface variable.
[0;90m   at: shader_compile_binary_from_spirv (drivers/vulkan/rendering_device_vulkan.cpp:4748)
[1;31mERROR:
[0;91m Condition "shader_data.size() == 0" is true.
[0;90m   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:287)
[1;31mERROR:
[0;91m Reflection of SPIR-V shader stage 'Compute' failed finding interface variable.
[0;90m   at: shader_compile_binary_from_spirv (drivers/vulkan/rendering_device_vulkan.cpp:4748)
[1;31mERROR:
[0;91m Condition "shader_data.size() == 0" is true.
[0;90m   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:287)
[1;31mERROR:
[0;91m Reflection of SPIR-V shader stage 'Compute' failed finding interface variable.
[0;90m   at: shader_compile_binary_from_spirv (drivers/vulkan/rendering_device_vulkan.cpp:4748)
[1;31mERROR:
[0;91m Condition "shader_data.size() == 0" is true.

Repeated a few tens of thousands of times.
I assume this must be particular to my system or it would have been noticed before the alpha went out, and I didn't see any other reports, please let me know what more information I can usefully give.

Steps to reproduce

Launch Godot

Minimal reproduction project

No response

@akien-mga
Copy link
Member

Do you have the same issue with earlier alpha builds or is it specific to alpha11?

@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

I was running alpha10 previously without (this) issue.

@akien-mga akien-mga changed the title Shader failure at startup leaves Project Manager black [macOS] Shader failure at startup leaves Project Manager black Jun 30, 2022
@ThunderFD
Copy link

I have the same issue, Alpha 11 looks like this:
image

and Alpha 10 like this:
image

MacOS 12.4 on an M1 Macbook Air

@JFonS
Copy link
Contributor

JFonS commented Jun 30, 2022

Same issue on an M1 Mac Mini.

I'll try to bisect the issue, but latest master work fine for me, so the problem could be in the release and packaging side.

@akien-mga akien-mga self-assigned this Jun 30, 2022
@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

I'll try to bisect the issue, but latest master work fine for me, so the problem could be in the release and packaging side.

That's interesting. I just tried latest master and had the same issue.

@akien-mga
Copy link
Member

@Kev What compilation options are you using?

@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

@Kev What compilation options are you using?

scons platform=osx arch=x86_64 use_static_mvk=yes --jobs=$(sysctl -n hw.logicalcpu)
(Although a quick search suggests that although the docs say use_static_mvk is a thing, it seems not to be)

@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

(Trying to see if I can get a bisect done on my lunch break, at the moment)

@akien-mga
Copy link
Member

akien-mga commented Jun 30, 2022

(Although a quick search suggests that although the docs say use_static_mvk is a thing, it seems not to be)

Yeah the docs are a bit outdated, it's use_volk=no now if you want to link MoltenVK statically. Otherwise it's using Volk (like on other platforms) which will locate MoltenVK if installed system-wide.

Edit: Made a PR to update it: godotengine/godot-docs#5898

@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

➜ godot (fc6ac4a155) ✗ git bisect bad
fc6ac4a155c45181d0a3528a4891c5a12e412d1f is the first bad commit
commit fc6ac4a155c45181d0a3528a4891c5a12e412d1f
Author: Pedro J. Estébanez <[email protected]>
Date:   Mon Jun 27 21:14:23 2022 +0200

    Consider uniform writability part of the interface of the set

 drivers/vulkan/rendering_device_vulkan.cpp         | 31 ++++++++++++++++++++--
 drivers/vulkan/rendering_device_vulkan.h           |  6 ++++-
 .../renderer_rd/renderer_scene_render_rd.cpp       | 15 ++++++++---
 .../renderer_rd/renderer_scene_render_rd.h         |  1 +
 .../shaders/volumetric_fog_process.glsl            |  1 -
 5 files changed, 46 insertions(+), 8 deletions(-)

Seems to be when it regressed, at least according to a local bisect (side note - envious of the M1 users in the thread, this would have been much quicker not on my aging Intel laptop :) ).

@akien-mga
Copy link
Member

That's #62467, CC @RandomShaper.

@akien-mga akien-mga removed their assignment Jun 30, 2022
@clayjohn
Copy link
Member

I think there are 2 issues here.

  1. When shaders fail to compile the screen remains black and appears not to load
  2. Shaders are failing to compile on MacOS

I can reproduce 1 when I make changes to the scene shader that fail to compile. Previously, only the element with the failing shader failed to render. Now the editor won't load if any shader fails to render.

@Kev
Copy link
Contributor Author

Kev commented Jun 30, 2022

FWIW, I found that simply commenting out the ERR_FAIL_COND_V_MSG "failed finding interface variable" and stopping writable booming from the nullderef on interface_var was enough to get the launcher rendering again on my system on master.

@RandomShaper
Copy link
Member

I've found the issue. It's related to Vulkan < 1.2. I'm working on a solution.

@RandomShaper
Copy link
Member

PR submitted. Please clear shader cache before trying it!

@Calinou
Copy link
Member

Calinou commented Jun 30, 2022

PR submitted. Please clear shader cache before trying it!

That reminds me, is shader cache scoped on a per-version basis? I'd be inclined to say each patch version or different development build should use a different shader cache location.

@RandomShaper
Copy link
Member

I was thinking the same. Right now, shader binary data version number is only changing when the structures change, but not when the logic to fill them do. Whenever the latter happens we may force cache invalidation by raising the number. Maybe we could split (via bit shifts) the current integer into major (for real structural changes) and minor (just for forcing invalidation if there's some reason to rebuild the shader cache).

@far
Copy link

far commented Jul 1, 2022

PR submitted. Please clear shader cache before trying it!

How to do it?

@bruvzg
Copy link
Member

bruvzg commented Jul 1, 2022

How to do it?

Delete ~/Library/Application Support/Godot/shader_cache (for editor/project manager cache) and .godot/shader_cache in each of affected project folders.

@far
Copy link

far commented Jul 2, 2022

How to do it?

Delete ~/Library/Application Support/Godot/shader_cache (for editor/project manager cache) and .godot/shader_cache in each of affected project folders.

Didnt help. I also tried fresh master recompiled and alpha build from downloads. Black screen window and this error repeats many times:

BigSur 11.6.7
Godot Engine v4.0.alpha.custom_build - https://godotengine.org
Vulkan API 1.2.0 - Using Vulkan Device #0: Intel - Intel(R) Iris(TM) Graphics 6000
[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
Compilation failed:

program_source:200:44: error: use of undeclared identifier 'spvSwizzleConstants'
    constant uint* sdf_vec_texturesSwzl = &spvSwizzleConstants[0];
                                           ^
program_source:201:47: error: use of undeclared identifier 'spvSwizzleConstants'
    constant uint& height_field_textureSwzl = spvSwizzleConstants[7];
                                              ^
.
ERROR:  - Message Id Number: 0 | Message Id Name:
	VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
Compilation failed:

program_source:200:44: error: use of undeclared identifier 'spvSwizzleConstants'
    constant uint* sdf_vec_texturesSwzl = &spvSwizzleConstants[0];
                                           ^
program_source:201:47: error: use of undeclared identifier 'spvSwizzleConstants'
    constant uint& height_field_textureSwzl = spvSwizzleConstants[7];
                                              ^
.
	Objects - 1
		Object[0] - VK_OBJECT_TYPE_SHADER_MODULE, Handle 140363091321792
   at: _debug_messenger_callback (drivers/vulkan/vulkan_context.cpp:159)
[mvk-error] VK_ERROR_INVALID_SHADER_NV: Compute shader function could not be compiled into pipeline. See previous logged error.
ERROR:  - Message Id Number: 0 | Message Id Name:
	VK_ERROR_INVALID_SHADER_NV: Compute shader function could not be compiled into pipeline. See previous logged error.
	Objects - 1
		Object[0] - VK_OBJECT_TYPE_PIPELINE, Handle 140363091321264
   at: _debug_messenger_callback (drivers/vulkan/vulkan_context.cpp:159)
ERROR: vkCreateComputePipelines failed with error -1000012000.
   at: compute_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6748)
.....

@RandomShaper
Copy link
Member

The Godot bug is fixed, but now you're being bitten by a MoltenVK (rooted in SPIRV-Cross) bug: powervr-graphics/Native_SDK#67

Probably something has changed recently in the Godot shader that now triggers the ill path. I'll check it

@bruvzg
Copy link
Member

bruvzg commented Jul 2, 2022

spvSwizzleConstants

What's the source of MoltenVK you are using? IIRC swizzling is an optional feature and might be disabled at compile time. Try installing Vulkan SDK from https://vulkan.lunarg.com/sdk/home#mac, and compiling Godot with statically linked MVK (build with use_volk=no VULKAN_SDK_PATH=/path/to/SDK/install/ flags).

@far
Copy link

far commented Jul 2, 2022

i updated Vulkan and tried to build with this command:
scons VULKAN_SDK_PATH=~/Vulkan/SDK/1.3.216.0 use_volk=no platform=osx arch=x86_64 --jobs=$(sysctl -n hw.logicalcpu)
but at last step of linking got this error:

[ 96%] Linking Program bin/godot.osx.tools.x86_64 ...
[ 97%] ld: warning: directory not found for option '-L~/VulkanSDK/1.3.216.0/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/'
[ 97%] ld: library not found for -lMoltenVK
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ 99%] progress_finish(["progress_finish"], [])
[100%] scons: *** [bin/godot.osx.tools.x86_64] Error 1

this library file exists:
~/VulkanSDK/1.3.216.0/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/libMoltenVK.a

@bruvzg
Copy link
Member

bruvzg commented Jul 2, 2022

~ won't work in the defines, so use the full path (/Users/USERNAME/...) instead.

@Kev
Copy link
Contributor Author

Kev commented Jul 6, 2022

Sorry for the delay in replying to the thread, but just to confirm that the merged PR fixed it for me. Thanks for the quick turn-around.

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

Successfully merging a pull request may close this issue.

9 participants