From fa0b794902bb457c57d6f63acfb610ef183a0cbc Mon Sep 17 00:00:00 2001 From: Virgile Bello Date: Wed, 27 May 2026 08:02:40 +0900 Subject: [PATCH] iOS: bootstrap Vulkan via main-binary dlsym (vkGetInstanceProcAddr re-exported) --- .../Vulkan/GraphicsAdapterFactory.Vulkan.cs | 7 +++---- .../Stride.Build.Sdk/Sdk/Stride.Dependencies.targets | 12 +++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sources/engine/Stride.Graphics/Vulkan/GraphicsAdapterFactory.Vulkan.cs b/sources/engine/Stride.Graphics/Vulkan/GraphicsAdapterFactory.Vulkan.cs index 3ed341e8c..657dfba56 100644 --- a/sources/engine/Stride.Graphics/Vulkan/GraphicsAdapterFactory.Vulkan.cs +++ b/sources/engine/Stride.Graphics/Vulkan/GraphicsAdapterFactory.Vulkan.cs @@ -28,13 +28,12 @@ namespace Stride.Graphics // when one is installed (e.g. via 'brew install vulkan-loader') because only the loader // chains validation layers — bundled MoltenVK alone is an ICD and ignores VK_LAYER_*. // If no loader is available, fall back to the bundled MoltenVK at runtimes//native/. - // On iOS, MoltenVK is statically linked into the app bundle (iOS forbids dlopen of - // arbitrary dylibs); "__Internal" resolves to the main executable's symbol table, - // so Vortice's NativeLibrary.GetExport finds vkGetInstanceProcAddr there. + // On iOS, MoltenVK is statically linked into the app binary: dlopen the executable itself, + // which exports vkGetInstanceProcAddr (see Stride.Core.NativeLibraries.targets). string vkLibraryName = Platform.Type switch { PlatformType.macOS => ResolveMacOSVulkanLibrary(), - PlatformType.iOS => "__Internal", + PlatformType.iOS => Environment.ProcessPath, _ => null, }; var result = vkInitialize(vkLibraryName); diff --git a/sources/sdk/Stride.Build.Sdk/Sdk/Stride.Dependencies.targets b/sources/sdk/Stride.Build.Sdk/Sdk/Stride.Dependencies.targets index 67ad77bd3..54363094f 100644 --- a/sources/sdk/Stride.Build.Sdk/Sdk/Stride.Dependencies.targets +++ b/sources/sdk/Stride.Build.Sdk/Sdk/Stride.Dependencies.targets @@ -17,7 +17,9 @@ Platform-specific handling: - Desktop (Windows/Linux/macOS): Native libs copied as None items - Android: Native libs added as AndroidNativeLibrary - - iOS: Native libs linked via mtouch arguments + - iOS: Native libs added as NativeReference (Kind=Static, ForceLoad=True) so libfoo.a is + whole-archive linked into the main executable; libMoltenVK.a additionally re-exports + vkGetInstanceProcAddr so Vortice.Vulkan's dlsym-based loader finds it. ================================================================ --> @@ -197,6 +199,14 @@ True False + +