andrewrk / zig-vulkan-triangle

simple triangle displayed using vulkan, xcb, and zig
MIT License
116 stars 15 forks source link

Someone should try making this run on Apple #1

Open binary132 opened 6 years ago

binary132 commented 6 years ago

Two approaches:

ghost commented 5 years ago

It works intermittently (about one time in five) on macOS version 10.11.6 by following the instructions in the section "Installing Vulkan Components to System Directories" at https://vulkan.lunarg.com/doc/sdk/1.1.106.0/mac/getting_started.html , as well as copying macOS/lib/libvulkan.* from the SDK into /usr/local/lib/ and setting the environment variables:

export VK_ICD_FILENAMES=/etc/vulkan/icd.d/MoltenVK_icd.json export VULKAN_SDK=~/code/vulkan/vulkansdk-macos-1.1.92.1 export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d

When zig build run didn't work the errors i got were:

validation layer:  [ VUID_Undefined ] Object: VK_NULL_HANDLE (Type = 0) | Device Extension VK_MVK_macos_surface is not supported by this layer.  Using this extension may adversely affect validation results and/or produce undefined behavior.
validation layer:  [ VUID-VkSwapchainCreateInfoKHR-imageColorSpace-parameter ] Object: VK_NULL_HANDLE (Type = 0) | vkCreateSwapchainKHR: value of pCreateInfo->imageColorSpace (1073741824) does not fall within the begin..end range of the core VkColorSpaceKHR enumeration tokens and is not an extension added token. The Vulkan spec states: imageColorSpace must be a valid VkColorSpaceKHR value (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageColorSpace-parameter)
validation layer:  [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01273 ] Object: 0x7fa9c9813010 (Type = 3) | vkCreateSwapChainKHR() called with a non-supported pCreateInfo->imageFormat (i.e. 0). The Vulkan spec states: imageFormat and imageColorSpace must match the format and colorSpace members, respectively, of one of the VkSurfaceFormatKHR structures returned by vkGetPhysicalDeviceSurfaceFormatsKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01273)
2019-05-06 22:12:42.613 zig-vulkan-triangle[3044:137794] An uncaught exception was raised
2019-05-06 22:12:42.614 zig-vulkan-triangle[3044:137794] invalid pixel format 0
2019-05-06 22:12:42.614 zig-vulkan-triangle[3044:137794] (
    0   CoreFoundation                      0x00007fff90d0e4f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff864e0f7e objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff90d754bd +[NSException raise:format:] + 205
    3   QuartzCore                          0x00007fff8b3801d7 -[CAMetalLayer setPixelFormat:] + 96
    4   libMoltenVK.dylib                   0x0000000110224bb0 _ZN12MVKSwapchainC2EP9MVKDevicePK24VkSwapchainCreateInfoKHR + 144
    5   libMoltenVK.dylib                   0x000000011020dacb _ZN9MVKDevice15createSwapchainEPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacks + 43
    6   libMoltenVK.dylib                   0x00000001101ecf2b vkCreateSwapchainKHR + 27
    7   libvulkan.1.dylib                   0x000000010b0f245e terminator_CreateSwapchainKHR + 174
    8   libVkLayer_unique_objects.dylib     0x000000011055a83c _ZN14unique_objects18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 636
    9   libVkLayer_core_validation.dylib    0x00000001107d0690 _ZN15core_validation18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 192
    10  libVkLayer_object_tracker.dylib     0x0000000110e6c11d _ZN14object_tracker18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 1069
    11  libVkLayer_parameter_validation.dylib 0x000000011114c8a5 _ZN20parameter_validation20vkCreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 7413
    12  libVkLayer_threading.dylib          0x0000000111476bbb _ZN9threading18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 347
    13  zig-vulkan-triangle                 0x000000010b04819f createSwapChain + 1023
    14  zig-vulkan-triangle                 0x000000010b046123 initVulkan + 275
    15  zig-vulkan-triangle                 0x000000010b045db0 main.0 + 176
    16  zig-vulkan-triangle                 0x000000010b045bf8 main + 488
    17  libdyld.dylib                       0x00007fff8ae485ad start + 1
    18  ???                                 0x0000000000000001 0x0 + 1
)
2019-05-06 22:12:42.614 zig-vulkan-triangle[3044:137794] *** Terminating app due to uncaught exception 'CAMetalLayerInvalid', reason: 'invalid pixel format 0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff90d0e4f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff864e0f7e objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff90d754bd +[NSException raise:format:] + 205
    3   QuartzCore                          0x00007fff8b3801d7 -[CAMetalLayer setPixelFormat:] + 96
    4   libMoltenVK.dylib                   0x0000000110224bb0 _ZN12MVKSwapchainC2EP9MVKDevicePK24VkSwapchainCreateInfoKHR + 144
    5   libMoltenVK.dylib                   0x000000011020dacb _ZN9MVKDevice15createSwapchainEPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacks + 43
    6   libMoltenVK.dylib                   0x00000001101ecf2b vkCreateSwapchainKHR + 27
    7   libvulkan.1.dylib                   0x000000010b0f245e terminator_CreateSwapchainKHR + 174
    8   libVkLayer_unique_objects.dylib     0x000000011055a83c _ZN14unique_objects18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 636
    9   libVkLayer_core_validation.dylib    0x00000001107d0690 _ZN15core_validation18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 192
    10  libVkLayer_object_tracker.dylib     0x0000000110e6c11d _ZN14object_tracker18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 1069
    11  libVkLayer_parameter_validation.dylib 0x000000011114c8a5 _ZN20parameter_validation20vkCreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 7413
    12  libVkLayer_threading.dylib          0x0000000111476bbb _ZN9threading18CreateSwapchainKHREP10VkDevice_TPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacksPP16VkSwapchainKHR_T + 347
    13  zig-vulkan-triangle                 0x000000010b04819f createSwapChain + 1023
    14  zig-vulkan-triangle                 0x000000010b046123 initVulkan + 275
    15  zig-vulkan-triangle                 0x000000010b045db0 main.0 + 176
    16  zig-vulkan-triangle                 0x000000010b045bf8 main + 488
    17  libdyld.dylib                       0x00007fff8ae485ad start + 1
    18  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The following command terminated unexpectedly:
cd /Users/oliver/github/zig-vulkan-triangle && /Users/oliver/github/zig-vulkan-triangle/zig-cache/o/gMsVNZJccCClb9bdTfJCBrZ_6KhgiarwmdqdyckDxFBH_xPCB89o_v2v4YToZSCH/zig-vulkan-triangle 

Build failed. The following command failed:
/Users/oliver/github/zig-vulkan-triangle/zig-cache/o/k-BBlzbSwYM_J8aY08t7BDP9ou0NWAdZi02LwrL8soPA6UTGFMlN8H5yDKpJDQyD/build /Users/oliver/code/zig/zig-macos-x86_64-0.4.0+7a41af26/zig /Users/oliver/github/zig-vulkan-triangle /Users/oliver/github/zig-vulkan-triangle/zig-cache run

After updating to the latest version (1.1.106.0) of the LunarG SDK the pattern of errors is the same, but now the triangle is all black apart from the bottom left corner, which is red.

James-Riordan commented 6 months ago

I've been working on this recently. Still an issue 6 years later ;D