Vulkan-Samples
Vulkan-Samples copied to clipboard
Running samples on macOS doesn't work out of the box
Here is the log of running samples app right after building:
➜ mac git:(main) ./app/bin/Debug/arm64/vulkan_samples sample hpp_hello_triangle
[info] Logger initialized
[info] Enabled Validation Layers:
UNASSIGNED-CreateInstance-status-message(INFO / SPEC): msgNum: -2016116905 - Validation Information: [ UNASSIGNED-CreateInstance-status-message ] Object 0: handle = 0x15a861400, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x87d47f57 | Khronos Validation Layer Active:
Settings File: Found at /Users/vodobesku/.local/share/vulkan/settings.d/vk_layer_settings.txt specified by VkConfig application override.
Current Enables: None.
Current Disables: None.
Objects: 1
[0] 0x15a861400, type: 1, name: NULL
VUID-VkDeviceCreateInfo-pProperties-04451(ERROR / SPEC): msgNum: 976972960 - Validation Error: [ VUID-VkDeviceCreateInfo-pProperties-04451 ] Object 0: handle = 0x600002e20120, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x3a3b6ca0 | vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device VkPhysicalDevice 0x600002e20120[] supports it The Vulkan spec states: If the VK_KHR_portability_subset extension is included in pProperties of vkEnumerateDeviceExtensionProperties, ppEnabledExtensionNames must include "VK_KHR_portability_subset" (https://vulkan.lunarg.com/doc/view/1.3.261.0/mac/1.3-extensions/vkspec.html#VUID-VkDeviceCreateInfo-pProperties-04451)
Objects: 1
[0] 0x600002e20120, type: 2, name: NULL
[error] [samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp:43] 976972960 - VUID-VkDeviceCreateInfo-pProperties-04451: Validation Error: [ VUID-VkDeviceCreateInfo-pProperties-04451 ] Object 0: handle = 0x600002e20120, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x3a3b6ca0 | vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device VkPhysicalDevice 0x600002e20120[] supports it The Vulkan spec states: If the VK_KHR_portability_subset extension is included in pProperties of vkEnumerateDeviceExtensionProperties, ppEnabledExtensionNames must include "VK_KHR_portability_subset" (https://vulkan.lunarg.com/doc/view/1.3.261.0/mac/1.3-extensions/vkspec.html#VUID-VkDeviceCreateInfo-pProperties-04451)
[error] [framework/platform/platform.cpp:169] Error Message: Failed to open file: shaders/triangle.vert
[error] [framework/platform/platform.cpp:170] Failed when running application hpp_hello_triangle
Press return to continue
Also if cmake generator is set to Xcode (let's say one wants to run it from Xcode IDE, maybe capture Metal API frame, possibly debug shaders out of curiosity) then one will encounter that final linking of an app fails:
error: /Applications/Xcode_14_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/vodobesku/projects/Vulkan-Samples/build/mac/build/framework.build/Debug/Objects-normal/arm64/camera.o (No such file or directory)
error: /Applications/Xcode_14_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/vodobesku/projects/Vulkan-Samples/build/mac/build/framework.build/Debug/Objects-normal/arm64/image.o (No such file or directory)
error: /Applications/Xcode_14_3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/vodobesku/projects/Vulkan-Samples/build/mac/build/framework.build/Debug/Objects-normal/arm64/sampler.o (No such file or directory)
Command Libtool failed with a nonzero exit code
Hi @VladyslavSan please try run the app from the project directory. This way the app can find the shaders that it is trying to load
./app/bin/Debug/arm64/vulkan_samples --> ./build/app/bin/Debug/arm64/vulkan_samples
Yeah, this will fix the first problem. Second one is a different creature.
The solution to the second problem is separate the build. So if you want to create a build for XCode you'd do this:
mkdir build-xcode && cd build-xcode
cmake -G XCode ..
open your xcode IDE and you should have things discovered correctly.
If you mix building with Ninja first and then building with XCode second, what happens is the built libraries will report that they are built and the pathing could be incorrect to find the objects when LLDB goes to locate them for debugging purposes.
This doesn't seem to fix the issue. The issue is still visible for me when selecting the 'vulkan-samples' scheme.
The files that are linked to are incorrect as there full name includes a hash.
camera-854f7f5a995b7cf5a3a7c2da6e002409.o
camera-f1e0855e4a4780a2207fb66e29412807.o
Reason might be that there are identical named objects (framework/camera.cpp and framework/scene_graph/components/camera.cpp.
Other projects have seen similar issues https://codereview.chromium.org/955263002
So in order to add proper support for Xcode we might need to do:
- Ensure all files are unique within a library. Currently
camera.cpp,image.cpp,sampler.cppandhpp_image.cppThis can be done by renaming the files, or split framework into multiple libraries (framework_scene_graph) - Add documentation how to create an Xcode project.
This task can be closed. It has been solved by the iOS support patch. #696