diff --git a/docs/MoltenVK.md b/docs/MoltenVK.md new file mode 100644 index 00000000..3c8d8bee --- /dev/null +++ b/docs/MoltenVK.md @@ -0,0 +1,20 @@ +# Enabling Vulkan on macOS with MoltenVK + +> Note: MoltenVK uses SPIRV-Cross to convert SPIRV shaders to the Metal shading +> language. This increases the mismatch between shader behavior, and as a result +> many of the tests in this suite have known failures or behavior differences. + +To enable Vulkan testing on macOS you first need to download and install the +Vulkan SDK from [here](https://vulkan.lunarg.com). + +By default the SDK installs into your home directory under +`~/VulkanSDK/${SDK_Version}/macOS`. For CMake to find the SDK you either need to +set the `VULKAN_SDK` environment variable to the macOS subdirectory of the +VulkanSDK installation you wish to use. You also need to run `sudo +~/VulkanSDK/${SDK_Version}/install_vulkan.py --force-install`, to install the +development binaries into `/usr/local/...` so that launched applications can +find them. + +Once the SDK is installed and exposed to CMake, a clean configuration will +detect Vulkan and the MoltenVK portability layer and enable the Vulkan test +configurations. diff --git a/lib/API/VK/Device.cpp b/lib/API/VK/Device.cpp index 4dc58c91..4a0381c5 100644 --- a/lib/API/VK/Device.cpp +++ b/lib/API/VK/Device.cpp @@ -1267,7 +1267,7 @@ class VKContext { VkResult Res = vkCreateInstance(&CreateInfo, NULL, &Instance); if (Res == VK_ERROR_INCOMPATIBLE_DRIVER) return llvm::createStringError(std::errc::no_such_device, - "Cannot find a compatible Vulkan device"); + "Cannot find a base Vulkan device"); if (Res) return llvm::createStringError(std::errc::no_such_device, "Unknown Vulkan initialization error: %d", diff --git a/test/Feature/HLSLLib/cosh.16.test b/test/Feature/HLSLLib/cosh.16.test index ea4bb502..6e59be7c 100644 --- a/test/Feature/HLSLLib/cosh.16.test +++ b/test/Feature/HLSLLib/cosh.16.test @@ -61,6 +61,9 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2507 +# XFAIL: Vulkan-Darwin + # REQUIRES: Half # RUN: split-file %s %t # RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl diff --git a/test/Feature/HLSLLib/sign.32.test b/test/Feature/HLSLLib/sign.32.test index 88cef099..295f5a93 100644 --- a/test/Feature/HLSLLib/sign.32.test +++ b/test/Feature/HLSLLib/sign.32.test @@ -74,7 +74,7 @@ Buffers: - Name: Out2 Format: Int32 Stride: 16 - ZeroInitSize: 48 + ZeroInitSize: 48 - Name: ExpectedOut2 # The result we expect Format: Int32 Stride: 16 @@ -82,7 +82,7 @@ Buffers: - Name: Out3 Format: Int32 Stride: 16 - ZeroInitSize: 48 + ZeroInitSize: 48 - Name: ExpectedOut3 # The result we expect Format: Int32 Stride: 16 @@ -176,6 +176,11 @@ DescriptorSets: # https://github.com/microsoft/DirectXShaderCompiler/issues/7512 # XFAIL: DXC-Vulkan +# https://github.com/llvm/llvm-project/issues/149722 +# We're generating invalid SPIRV for this. I have _no_ idea why this isn't +# failing on all Clang Vulkan tests. +# XFAIL: Clang && Vulkan-Darwin + # RUN: split-file %s %t # RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl # RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/sinh.16.test b/test/Feature/HLSLLib/sinh.16.test index 6a9de395..8d6f7ee1 100644 --- a/test/Feature/HLSLLib/sinh.16.test +++ b/test/Feature/HLSLLib/sinh.16.test @@ -61,6 +61,9 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2507 +# XFAIL: Vulkan-Darwin + # REQUIRES: Half # RUN: split-file %s %t # RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl diff --git a/test/Feature/HLSLLib/tanh.16.test b/test/Feature/HLSLLib/tanh.16.test index 6e4fc9e5..26efebf7 100644 --- a/test/Feature/HLSLLib/tanh.16.test +++ b/test/Feature/HLSLLib/tanh.16.test @@ -61,6 +61,9 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2507 +# XFAIL: Vulkan-Darwin + # REQUIRES: Half # RUN: split-file %s %t # RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl diff --git a/test/UseCase/particle-life.test b/test/UseCase/particle-life.test index 63722339..1c8d4d29 100644 --- a/test/UseCase/particle-life.test +++ b/test/UseCase/particle-life.test @@ -357,6 +357,9 @@ DescriptorSets: # https://github.com/llvm/offload-test-suite/issues/55 # UNSUPPORTED: Metal +# No idea what is going on here, but the results are _way_ off. +# XFAIL: Vulkan-Darwin + # RUN: split-file %s %t # RUN: %if !Vulkan %{ %dxc_target -T cs_6_0 -Fo %t.o %t/particle-life.hlsl %} # RUN: %if Vulkan %{ %dxc_target -T cs_6_0 -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.o %t/particle-life.hlsl %} diff --git a/test/lit.cfg.py b/test/lit.cfg.py index 9cd3a943..23968fe3 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py @@ -51,6 +51,7 @@ def setDeviceFeatures(config, device, compiler): API = device["API"] config.available_features.add(API) + config.available_features.add("%s-%s" % (API, config.offloadtest_os)) if "Microsoft Basic Render Driver" in device["Description"]: config.available_features.add("%s-WARP" % API) if "Intel" in device["Description"]: diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index b670e195..83d0a62b 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -16,6 +16,7 @@ config.offloadtest_suite = "@suite@" config.offloadtest_enable_d3d12 = @TEST_d3d12@ config.offloadtest_enable_vulkan = @TEST_vk@ config.offloadtest_enable_metal = @TEST_mtl@ +config.offloadtest_os = "@CMAKE_SYSTEM_NAME@" import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/tools/api-query/CMakeLists.txt b/tools/api-query/CMakeLists.txt index 6b060293..9e55fb2f 100644 --- a/tools/api-query/CMakeLists.txt +++ b/tools/api-query/CMakeLists.txt @@ -2,3 +2,9 @@ add_offloadtest_tool(api-query api-query.cpp) target_link_libraries(api-query PRIVATE LLVMSupport OffloadTestAPI) + +if (APPLE AND OFFLOADTEST_ENABLE_VULKAN) + get_filename_component(_Vulkan_LIB_DIR ${Vulkan_LIBRARY} DIRECTORY) + set_property(TARGET api-query APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-rpath,${_Vulkan_LIB_DIR} ") +endif() diff --git a/tools/offloader/CMakeLists.txt b/tools/offloader/CMakeLists.txt index d19487d7..d4c6120b 100644 --- a/tools/offloader/CMakeLists.txt +++ b/tools/offloader/CMakeLists.txt @@ -6,3 +6,9 @@ target_link_libraries(offloader PRIVATE OffloadTestAPI OffloadTestImage OffloadTestSupport) + +if (APPLE AND OFFLOADTEST_ENABLE_VULKAN) + get_filename_component(_Vulkan_LIB_DIR ${Vulkan_LIBRARY} DIRECTORY) + set_property(TARGET offloader APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-rpath,${_Vulkan_LIB_DIR} ") +endif()