godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.46k stars 21.27k forks source link

Unable to initialize Vulkan video driver for the MacOS export when dynamically linked inside app bundle #86250

Open Praytic opened 11 months ago

Praytic commented 11 months ago

Tested versions

System information

Godot v4.1.3.stable - macOS 13.3.1 - Vulkan (Forward+) - integrated Apple M1 Pro - Apple M1 Pro (10 Threads)

Issue description

I was following this guide (https://docs.godotengine.org/en/4.1/contributing/development/compiling/compiling_for_macos.html#building-export-templates) to build an export template with my own encryption key (I have SCRIPT_AES256_ENCRYPTION_KEY environment variable). I included libMoltenVK.dylib inside the macos_template.app and used use_volk=yes parameter for scons command.

Here's my macos_template.app structure:

❯ ls -R
Contents

./Contents:
Frameworks Info.plist MacOS      PkgInfo    Resources

./Contents/Frameworks:
libMoltenVK.dylib

./Contents/MacOS:
godot_macos_debug.universal   godot_macos_release.universal

./Contents/Resources:
icon.icns

After that I used this bundled template to generate export with this command:

❯ ./Godot --path <project_path> --export-release macos macos.dmg

The internal structure of the generated export:

❯ ls -R
Contents

./YouTD 2.app//Contents:
Frameworks     Info.plist     MacOS          PkgInfo        Resources      _CodeSignature

./YouTD 2.app//Contents/Frameworks:
libMoltenVK.dylib

./YouTD 2.app//Contents/MacOS:
YouTD 2

./YouTD 2.app//Contents/Resources:
YouTD 2.pck icon.icns

./YouTD 2.app//Contents/_CodeSignature:
CodeResources

However, when I run the executable on the same machine where I built it I get this error:

Screenshot 2023-12-16 at 10 01 14 PM

Steps to reproduce

Follow this guide (https://docs.godotengine.org/en/4.1/contributing/development/compiling/compiling_for_macos.html#building-export-templates) to build an export template with provided encryption key. Include libMoltenVK.dylib inside templates. Try exporting any of you project with compiled templates and run it. You should have the same error screen.

Screenshot 2023-12-16 at 10 01 14 PM

Minimal reproduction project (MRP)

N/A

Calinou commented 11 months ago

Out of curiosity, why not use statically linked MoltenVK? This is the recommended option unless you need to use GPU profiling, which requires using Volk IIRC.

Praytic commented 11 months ago

Out of curiosity, why not use statically linked MoltenVK? This is the recommended option unless you need to use GPU profiling, which requires using Volk IIRC.

I'm getting this error:

❯ scons platform=macos target=template_debug arch=arm64
scons: Reading SConscript files ...
Auto-detected 10 CPU cores available for build parallelism. Using 9 cores by default. You can override it with the -j argument.
Building for macOS 11.0+.
MoltenVK SDK installation directory not found, use 'vulkan_sdk_path' SCons parameter to specify SDK path.

Apparently, it can't find the SDK on my machine, although I have installed it correctly.

Calinou commented 11 months ago

Apparently, it can't find the SDK on my machine, although I have installed it correctly.

Which path did you install the SDK to? Try specifying the vulkan_sdk_path=/path/to/VulkanSDK SCons option with the absolute path to the folder containing the Vulkan SDK.

I recall misc/scripts/install_vulkan_sdk_macos.sh installing the Vulkan SDK to the default location automatically.

Praytic commented 11 months ago

Apparently, it can't find the SDK on my machine, although I have installed it correctly.

Which path did you install the SDK to? Try specifying the vulkan_sdk_path=/path/to/VulkanSDK SCons option with the absolute path to the folder containing the Vulkan SDK.

I recall misc/scripts/install_vulkan_sdk_macos.sh installing the Vulkan SDK to the default location automatically.

Seems like the default location is my home path:

[22] No target directory specified, using default value: "/Users/praytic/VulkanSDK/1.3.268.1"

@Calinou You suggestion, with static Vulkan linking works perfectly! But I won't close this issue because it's still exist for dynamically linked SDK.

Morokiane commented 10 months ago

@Praytic Can you share how you solved this? I am running into this issue. I don't fully grasp things like static/dynamic linking and finding any info on how to solve it is sparce. Thank you.