diff --git a/docs/MoltenVK.md b/docs/MoltenVK.md new file mode 100644 index 000000000..3c8d8bee8 --- /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 4dc58c91d..4a0381c5e 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/cos.32.test b/test/Feature/HLSLLib/cos.32.test index b8fb8e9ac..eb826f207 100644 --- a/test/Feature/HLSLLib/cos.32.test +++ b/test/Feature/HLSLLib/cos.32.test @@ -61,6 +61,8 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525 +# XFAIL: Vulkan-Darwin # RUN: split-file %s %t # RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl diff --git a/test/Feature/HLSLLib/cosh.16.test b/test/Feature/HLSLLib/cosh.16.test index ea4bb5021..6e59be7c7 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/frac.16.test b/test/Feature/HLSLLib/frac.16.test index 7561e262e..2989b4656 100644 --- a/test/Feature/HLSLLib/frac.16.test +++ b/test/Feature/HLSLLib/frac.16.test @@ -61,6 +61,9 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525 +# 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/reflect.16.test b/test/Feature/HLSLLib/reflect.16.test index 8afc0780a..823bfa0f5 100644 --- a/test/Feature/HLSLLib/reflect.16.test +++ b/test/Feature/HLSLLib/reflect.16.test @@ -186,6 +186,9 @@ DescriptorSets: #--- end # REQUIRES: Half +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2524 +# XFAIL: Vulkan-Darwin + # RUN: split-file %s %t # RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl # RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/refract.16.test b/test/Feature/HLSLLib/refract.16.test index c84980a86..c245170fd 100644 --- a/test/Feature/HLSLLib/refract.16.test +++ b/test/Feature/HLSLLib/refract.16.test @@ -187,6 +187,9 @@ DescriptorSets: #--- end # REQUIRES: Half +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2524 +# XFAIL: Vulkan-Darwin + # RUN: split-file %s %t # RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl # RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/HLSLLib/sign.32.test b/test/Feature/HLSLLib/sign.32.test index 88cef0998..295f5a935 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/sin.32.test b/test/Feature/HLSLLib/sin.32.test index 5c0d07415..56f86c346 100644 --- a/test/Feature/HLSLLib/sin.32.test +++ b/test/Feature/HLSLLib/sin.32.test @@ -61,6 +61,8 @@ DescriptorSets: ... #--- end +# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525 +# XFAIL: Vulkan-Darwin # RUN: split-file %s %t # RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl diff --git a/test/Feature/HLSLLib/sinh.16.test b/test/Feature/HLSLLib/sinh.16.test index 07150c64b..1cc9a9c61 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 5a421a105..4705a1c35 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 63722339a..1c8d4d294 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 3e5b2ac42..01c025070 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 b670e1952..83d0a62b0 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 6b0602933..9e55fb2f2 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 d19487d74..d4c6120b8 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()