Skip to content

Commit 398da90

Browse files
authored
[Vulkan] Add support for MoltenVK on macOS (#256)
This gets Vulkan support working on macOS if the Vulkan SDK and MoltenVK are available. All current Vulkan tests except particle_life pass with Vulkan on macOS with DXC, and sign.32.test fails with Clang.
1 parent 885bba6 commit 398da90

File tree

16 files changed

+67
-3
lines changed

16 files changed

+67
-3
lines changed

docs/MoltenVK.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Enabling Vulkan on macOS with MoltenVK
2+
3+
> Note: MoltenVK uses SPIRV-Cross to convert SPIRV shaders to the Metal shading
4+
> language. This increases the mismatch between shader behavior, and as a result
5+
> many of the tests in this suite have known failures or behavior differences.
6+
7+
To enable Vulkan testing on macOS you first need to download and install the
8+
Vulkan SDK from [here](https://vulkan.lunarg.com).
9+
10+
By default the SDK installs into your home directory under
11+
`~/VulkanSDK/${SDK_Version}/macOS`. For CMake to find the SDK you either need to
12+
set the `VULKAN_SDK` environment variable to the macOS subdirectory of the
13+
VulkanSDK installation you wish to use. You also need to run `sudo
14+
~/VulkanSDK/${SDK_Version}/install_vulkan.py --force-install`, to install the
15+
development binaries into `/usr/local/...` so that launched applications can
16+
find them.
17+
18+
Once the SDK is installed and exposed to CMake, a clean configuration will
19+
detect Vulkan and the MoltenVK portability layer and enable the Vulkan test
20+
configurations.

lib/API/VK/Device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ class VKContext {
12671267
VkResult Res = vkCreateInstance(&CreateInfo, NULL, &Instance);
12681268
if (Res == VK_ERROR_INCOMPATIBLE_DRIVER)
12691269
return llvm::createStringError(std::errc::no_such_device,
1270-
"Cannot find a compatible Vulkan device");
1270+
"Cannot find a base Vulkan device");
12711271
if (Res)
12721272
return llvm::createStringError(std::errc::no_such_device,
12731273
"Unknown Vulkan initialization error: %d",

test/Feature/HLSLLib/cos.32.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ DescriptorSets:
6161
...
6262
#--- end
6363

64+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525
65+
# XFAIL: Vulkan-Darwin
6466

6567
# RUN: split-file %s %t
6668
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl

test/Feature/HLSLLib/cosh.16.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ DescriptorSets:
6161
...
6262
#--- end
6363

64+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2507
65+
# XFAIL: Vulkan-Darwin
66+
6467
# REQUIRES: Half
6568
# RUN: split-file %s %t
6669
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl

test/Feature/HLSLLib/frac.16.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ DescriptorSets:
6161
...
6262
#--- end
6363

64+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525
65+
# XFAIL: Vulkan-Darwin
66+
6467
# REQUIRES: Half
6568
# RUN: split-file %s %t
6669
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl

test/Feature/HLSLLib/reflect.16.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ DescriptorSets:
186186
#--- end
187187
# REQUIRES: Half
188188

189+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2524
190+
# XFAIL: Vulkan-Darwin
191+
189192
# RUN: split-file %s %t
190193
# RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl
191194
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/refract.16.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ DescriptorSets:
187187
#--- end
188188
# REQUIRES: Half
189189

190+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2524
191+
# XFAIL: Vulkan-Darwin
192+
190193
# RUN: split-file %s %t
191194
# RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl
192195
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/sign.32.test

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ Buffers:
7474
- Name: Out2
7575
Format: Int32
7676
Stride: 16
77-
ZeroInitSize: 48
77+
ZeroInitSize: 48
7878
- Name: ExpectedOut2 # The result we expect
7979
Format: Int32
8080
Stride: 16
8181
Data: [1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0] # Last two are filler
8282
- Name: Out3
8383
Format: Int32
8484
Stride: 16
85-
ZeroInitSize: 48
85+
ZeroInitSize: 48
8686
- Name: ExpectedOut3 # The result we expect
8787
Format: Int32
8888
Stride: 16
@@ -176,6 +176,11 @@ DescriptorSets:
176176
# https://github.com/microsoft/DirectXShaderCompiler/issues/7512
177177
# XFAIL: DXC-Vulkan
178178

179+
# https://github.com/llvm/llvm-project/issues/149722
180+
# We're generating invalid SPIRV for this. I have _no_ idea why this isn't
181+
# failing on all Clang Vulkan tests.
182+
# XFAIL: Clang && Vulkan-Darwin
183+
179184
# RUN: split-file %s %t
180185
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
181186
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/sin.32.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ DescriptorSets:
6161
...
6262
#--- end
6363

64+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2525
65+
# XFAIL: Vulkan-Darwin
6466

6567
# RUN: split-file %s %t
6668
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl

test/Feature/HLSLLib/sinh.16.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ DescriptorSets:
6161
...
6262
#--- end
6363

64+
# https://github.com/KhronosGroup/SPIRV-Cross/issues/2507
65+
# XFAIL: Vulkan-Darwin
66+
6467
# REQUIRES: Half
6568
# RUN: split-file %s %t
6669
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl

0 commit comments

Comments
 (0)