Skip to content

Commit be926bc

Browse files
authored
Merge branch 'main' into add_distance_tests
2 parents d95129e + 304f6ab commit be926bc

33 files changed

+1647
-9
lines changed

.github/workflows/build-and-test-callable.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ jobs:
123123
- name: Checkout OffloadTest
124124
uses: actions/checkout@v4
125125
with:
126-
repository: llvm-beanz/offload-test-suite
126+
repository: llvm/offload-test-suite
127127
ref: ${{ inputs.OffloadTest-branch }}
128128
path: OffloadTest
129129
fetch-depth: 1
130130
- name: Checkout Golden Images
131131
uses: actions/checkout@v4
132132
with:
133-
repository: llvm-beanz/offload-golden-images
133+
repository: llvm/offload-golden-images
134134
ref: main
135135
path: golden-images
136136
fetch-depth: 1

docs/WSL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ These binaries, in addition to the WSL-specific headers and libraries made avail
1010
1. Install the DirectX-Headers package (usually named `directx-headers-dev`) from your preferred package manager.
1111
This is to obtain the libraries: DirectX-Guids (`libDirectX-Guids.a`) and d3dx12-format-properties (`libd3dx12-format-properties.a`)
1212
Alternatively, build and install the DirectX-Headers from the [original repo](https://github.com/microsoft/DirectX-Headers) or the git submodule of this repository: `third-party/DirectX-Headers`
13-
1. Install the rest of the [prerequisites](https://github.com/llvm-beanz/offload-test-suite/tree/main?tab=readme-ov-file#prerequisites) and follow the [instructions](https://github.com/llvm-beanz/offload-test-suite/tree/main?tab=readme-ov-file#adding-to-llvm-build) to add the experimental runtime test suite for HLSL to an LLVM build
13+
1. Install the rest of the [prerequisites](https://github.com/llvm/offload-test-suite/tree/main?tab=readme-ov-file#prerequisites) and follow the [instructions](https://github.com/llvm/offload-test-suite/tree/main?tab=readme-ov-file#adding-to-llvm-build) to add the experimental runtime test suite for HLSL to an LLVM build
1414

1515
## Known Issues
1616

lib/API/VK/Device.cpp

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static VkDescriptorType getDescriptorType(const ResourceKind RK) {
5959
static VkBufferUsageFlagBits getFlagBits(const ResourceKind RK) {
6060
switch (RK) {
6161
case ResourceKind::Buffer:
62+
return VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
6263
case ResourceKind::RWBuffer:
6364
return VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
6465
case ResourceKind::ByteAddressBuffer:
@@ -67,7 +68,7 @@ static VkBufferUsageFlagBits getFlagBits(const ResourceKind RK) {
6768
case ResourceKind::RWStructuredBuffer:
6869
return VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
6970
case ResourceKind::ConstantBuffer:
70-
return VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
71+
return VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
7172
}
7273
llvm_unreachable("All cases handled");
7374
}
@@ -86,6 +87,73 @@ static bool isUniform(const ResourceKind RK) {
8687
}
8788
llvm_unreachable("All cases handled");
8889
}
90+
91+
static std::string getMessageSeverityString(
92+
VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity) {
93+
if (MessageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
94+
return "Error";
95+
if (MessageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
96+
return "Warning";
97+
if (MessageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
98+
return "Info";
99+
if (MessageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
100+
return "Verbose";
101+
return "Unknown";
102+
}
103+
104+
static VkBool32
105+
debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
106+
VkDebugUtilsMessageTypeFlagsEXT MessageType,
107+
const VkDebugUtilsMessengerCallbackDataEXT *Data, void *) {
108+
// Only interested in messages from the validation layers.
109+
if (!(MessageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT))
110+
return VK_FALSE;
111+
112+
llvm::dbgs() << "Validation " << getMessageSeverityString(MessageSeverity);
113+
llvm::dbgs() << ": [ " << Data->pMessageIdName << " ]\n";
114+
llvm::dbgs() << Data->pMessage;
115+
116+
for (uint32_t I = 0; I < Data->objectCount; I++) {
117+
llvm::dbgs() << '\n';
118+
if (Data->pObjects[I].pObjectName) {
119+
llvm::dbgs() << "[" << Data->pObjects[I].pObjectName << "]";
120+
}
121+
}
122+
llvm::dbgs() << '\n';
123+
124+
// Return true to turn the validation error or warning into an error in the
125+
// vulkan API. This should causes tests to fail.
126+
const bool IsErrorOrWarning =
127+
MessageSeverity & (VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT |
128+
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT);
129+
if (IsErrorOrWarning)
130+
return VK_TRUE;
131+
132+
// Continue to run even with VERBOSE and INFO messages.
133+
return VK_FALSE;
134+
}
135+
136+
static VkDebugUtilsMessengerEXT registerDebugUtilCallback(VkInstance Instance) {
137+
VkDebugUtilsMessengerCreateInfoEXT CreateInfo = {};
138+
CreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
139+
CreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
140+
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
141+
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
142+
CreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
143+
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
144+
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
145+
CreateInfo.pfnUserCallback = debugCallback;
146+
CreateInfo.pUserData = nullptr; // Optional
147+
auto Func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(
148+
Instance, "vkCreateDebugUtilsMessengerEXT");
149+
if (Func == nullptr)
150+
return VK_NULL_HANDLE;
151+
152+
VkDebugUtilsMessengerEXT DebugMessenger;
153+
Func(Instance, &CreateInfo, nullptr, &DebugMessenger);
154+
return DebugMessenger;
155+
}
156+
89157
namespace {
90158

91159
class VKDevice : public offloadtest::Device {
@@ -800,6 +868,7 @@ class VKDevice : public offloadtest::Device {
800868
class VKContext {
801869
private:
802870
VkInstance Instance = VK_NULL_HANDLE;
871+
VkDebugUtilsMessengerEXT DebugMessenger = VK_NULL_HANDLE;
803872
llvm::SmallVector<std::shared_ptr<VKDevice>> Devices;
804873

805874
VKContext() = default;
@@ -813,6 +882,13 @@ class VKContext {
813882
}
814883

815884
void cleanup() {
885+
#ifndef NDEBUG
886+
auto Func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(
887+
Instance, "vkDestroyDebugUtilsMessengerEXT");
888+
if (Func != nullptr) {
889+
Func(Instance, DebugMessenger, nullptr);
890+
}
891+
#endif
816892
vkDestroyInstance(Instance, NULL);
817893
Instance = VK_NULL_HANDLE;
818894
}
@@ -860,6 +936,10 @@ class VKContext {
860936
const char *ValidationLayer = "VK_LAYER_KHRONOS_validation";
861937
CreateInfo.ppEnabledLayerNames = &ValidationLayer;
862938
CreateInfo.enabledLayerCount = 1;
939+
940+
const char *DebugUtilsExtensionName = "VK_EXT_debug_utils";
941+
CreateInfo.ppEnabledExtensionNames = &DebugUtilsExtensionName;
942+
CreateInfo.enabledExtensionCount = 1;
863943
#endif
864944

865945
Res = vkCreateInstance(&CreateInfo, NULL, &Instance);
@@ -871,6 +951,10 @@ class VKContext {
871951
"Unknown Vulkan initialization error %d",
872952
Res);
873953

954+
#ifndef NDEBUG
955+
DebugMessenger = registerDebugUtilCallback(Instance);
956+
#endif
957+
874958
DeviceCount = 0;
875959
if (vkEnumeratePhysicalDevices(Instance, &DeviceCount, nullptr))
876960
return llvm::createStringError(std::errc::no_such_device,

test/Basic/TestPipeline.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ DescriptorSets:
4040
...
4141
#--- end
4242

43+
# Tracking issue: https://github.com/llvm/llvm-project/issues/144580
44+
# XFAIL: Clang-Vulkan
45+
4346
# RUN: split-file %s %t
4447
# RUN: %dxc_target -T cs_6_0 -E CSMain -Fo %t.o %t/source.hlsl
4548
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

test/Feature/CBuffer/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ if 'Clang' in config.available_features:
22
config.unsupported = True
33

44
# CBuffer bindings seem to be broken under metal
5-
# https://github.com/llvm-beanz/offload-test-suite/issues/55
5+
# https://github.com/llvm/offload-test-suite/issues/55
66
if 'Metal' in config.available_features:
77
config.unsupported = True

test/Feature/HLSLLib/acos.16.test

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<half4> In : register(t0);
4+
5+
RWStructuredBuffer<half4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = acos(In[0]);
10+
half4 Tmp = {acos(In[1].xyz), acos(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {acos(In[2].xy), acos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
}
15+
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: Float16
26+
Stride: 8
27+
Data: [0x7e00, 0xfc00, 0x8001, 0x8000, 0x0, 0x0001, 0x7c00, 0x3c00, 0xbc00, 0x3e00, 0xbe00, 0x7e00]
28+
# nan, -inf, -denorm, -0, 0, denorm, inf, 1, -1, 1.5, -1.5, nan (filler)
29+
- Name: Out
30+
Format: Float16
31+
Stride: 8
32+
ZeroInitSize: 24
33+
- Name: ExpectedOut # The result we expect
34+
Format: Float16
35+
Stride: 8
36+
Data: [0x7e00, 0x7e00, 0x3e48, 0x3e48, 0x3e48, 0x3e48, 0x7e00, 0x0, 0x4248, 0x7e00, 0x7e00, 0x7e00]
37+
# nan, nan, 1.570796, 1.570796, 1.570796, 1.570796, nan, 0, 3.1415926, nan, nan, nan
38+
Results:
39+
- Result: Test1
40+
Rule: BufferFloatEpsilon
41+
Epsilon: 0.0010
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: In
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: Out
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
...
61+
#--- end
62+
63+
# REQUIRES: Half
64+
65+
# RUN: split-file %s %t
66+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
67+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/acos.32.test

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = acos(In[0]);
10+
float4 Tmp = {acos(In[1].xyz), acos(In[1].w)};
11+
Out[1] = Tmp;
12+
float4 Tmp2 = {acos(In[2].xy), acos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
}
15+
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: Float32
26+
Stride: 16
27+
Data: [nan, -inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, inf, 1, -1, 1.5, -1.5, nan]
28+
# nan, -inf, -denorm, -0, 0, denorm, inf, 1, -1, 1.5, -1.5, nan
29+
- Name: Out
30+
Format: Float32
31+
Stride: 16
32+
ZeroInitSize: 48
33+
- Name: ExpectedOut # The result we expect
34+
Format: Float32
35+
Stride: 16
36+
Data: [nan, nan, 0x1.921fb6p+0, 0x1.921fb6p+0, 0x1.921fb6p+0, 0x1.921fb6p+0, nan, 0, 3.1415926, nan, nan, nan]
37+
#[nan, nan, 1.570796, 1.570796, 1.570796, 1.570796, nan, 0, 3.14, nan, nan, nan
38+
Results:
39+
- Result: Test1
40+
Rule: BufferFloatEpsilon
41+
Epsilon: 0.0008
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: In
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: Out
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
...
61+
#--- end
62+
63+
# RUN: split-file %s %t
64+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
65+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/cos.16.test

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<half4> In : register(t0);
4+
5+
RWStructuredBuffer<half4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = cos(In[0]);
10+
half4 Tmp = {cos(In[1].xyz), cos(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {cos(In[2].xy), cos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = cos(In[3]);
15+
Out[4] = cos(In[4]);
16+
}
17+
18+
19+
//--- pipeline.yaml
20+
21+
---
22+
Shaders:
23+
- Stage: Compute
24+
Entry: main
25+
DispatchSize: [1, 1, 1]
26+
Buffers:
27+
- Name: In
28+
Format: Float16
29+
Stride: 8
30+
Data: [ 0x7e00, 0xfc00, 0x8001, 0x8000, 0x0000, 0x0001, 0x7c00, 0x3906, 0x3d06, 0x3f8a, 0x4106, 0x4248, 0x438a, 0x4466, 0x4506, 0x45a7, 0x4648, 0x7e00, 0x7e00, 0x7e00,]
31+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 0.6279297, 1.255859, 1.884766, 2.511719, 3.140625, 3.769531, 4.398438, 5.023438, 5.652344, 6.281250,
32+
- Name: Out
33+
Format: Float16
34+
Stride: 8
35+
ZeroInitSize: 40
36+
- Name: ExpectedOut # The result we expect
37+
Format: Float16
38+
Stride: 8
39+
Data: [ 0x7e00, 0x7e00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x7e00, 0x3a79, 0x34f5, 0xb4f1, 0xba77, 0xbc00, 0xba79, 0xb4f1, 0x34e6, 0x3a76, 0x3c00, 0x7e00, 0x7e00, 0x7e00,]
40+
# NaN, NaN, 1.0, 1.0, 1.0, 1.0, NaN, 0.80924553, 0.30975693, -0.30883664, -0.80810183, -0.99999952, -0.80924052, -0.30881903, 0.30605716, 0.80753154, 0.99999809,
41+
Results:
42+
- Result: Test1
43+
Rule: BufferFloatEpsilon
44+
Epsilon: 0.003
45+
Actual: Out
46+
Expected: ExpectedOut
47+
DescriptorSets:
48+
- Resources:
49+
- Name: In
50+
Kind: StructuredBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 0
56+
- Name: Out
57+
Kind: RWStructuredBuffer
58+
DirectXBinding:
59+
Register: 1
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 1
63+
...
64+
#--- end
65+
66+
# REQUIRES: Half
67+
# RUN: split-file %s %t
68+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
69+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)