Skip to content

Commit 2551a64

Browse files
committed
Merge remote-tracking branch 'origin/main' into cbieneman/moltenvk
2 parents bf9d4f4 + fd7c7bc commit 2551a64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3085
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ jobs:
158158
cd build
159159
cmake -G Ninja ${{ inputs.LLVM-ExtraCMakeArgs }} -DCMAKE_BUILD_TYPE=${{ inputs.BuildType }} -DLLVM_ENABLE_ASSERTIONS=On -C ${{ github.workspace }}/llvm-project/clang/cmake/caches/HLSL.cmake -C ${{ github.workspace }}/OffloadTest/cmake/caches/sccache.cmake -DDXC_DIR=${{ github.workspace }}/DXC/build/bin -DLLVM_EXTERNAL_OFFLOADTEST_SOURCE_DIR=${{ github.workspace }}/OffloadTest -DLLVM_EXTERNAL_PROJECTS="OffloadTest" -DLLVM_LIT_ARGS="--xunit-xml-output=testresults.xunit.xml -v" -DOFFLOADTEST_TEST_CLANG=${{steps.Test-Clang.outputs.TEST_CLANG || 'Off' }} -DGOLDENIMAGE_DIR=${{ github.workspace }}/golden-images ${{ github.workspace }}/llvm-project/llvm/
160160
ninja hlsl-test-depends
161+
- name: Dump GPU Info
162+
run: |
163+
cd llvm-project
164+
cd build
165+
./bin/api-query
161166
- name: Run HLSL Tests
162167
run: |
163168
cd llvm-project

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
}
@@ -869,6 +945,10 @@ class VKContext {
869945
const char *ValidationLayer = "VK_LAYER_KHRONOS_validation";
870946
CreateInfo.ppEnabledLayerNames = &ValidationLayer;
871947
CreateInfo.enabledLayerCount = 1;
948+
949+
const char *DebugUtilsExtensionName = "VK_EXT_debug_utils";
950+
CreateInfo.ppEnabledExtensionNames = &DebugUtilsExtensionName;
951+
CreateInfo.enabledExtensionCount = 1;
872952
#endif
873953

874954
// This second creation shouldn't ever fail, but it tries to create the
@@ -882,6 +962,10 @@ class VKContext {
882962
"Unknown Vulkan initialization error %d",
883963
Res);
884964

965+
#ifndef NDEBUG
966+
DebugMessenger = registerDebugUtilCallback(Instance);
967+
#endif
968+
885969
DeviceCount = 0;
886970
if (vkEnumeratePhysicalDevices(Instance, &DeviceCount, nullptr))
887971
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
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<int64_t4> InInt : register(t0);
4+
RWStructuredBuffer<uint4> OutInt : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
// Int
9+
OutInt[0] = countbits(InInt[0]);
10+
OutInt[1].xyz = countbits(InInt[0].xyz);
11+
OutInt[1].w = countbits(InInt[0].w);
12+
OutInt[2].xy = countbits(InInt[0].xy);
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: InInt
24+
Format: Int64
25+
Stride: 32
26+
Data: [0x2A, 0, 0x0f0f0f0f0f0f0f0f, -1]
27+
- Name: OutInt
28+
Format: UInt32
29+
Stride: 16
30+
Data: [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112]
31+
- Name: ExpectedOut # The result we expect
32+
Format: UInt32
33+
Stride: 16
34+
Data: [3, 0, 32, 64, 3, 0, 32, 64, 3, 0, 111, 112]
35+
Results:
36+
- Result: Test1
37+
Rule: BufferExact
38+
Actual: OutInt
39+
Expected: ExpectedOut
40+
DescriptorSets:
41+
- Resources:
42+
- Name: InInt
43+
Kind: StructuredBuffer
44+
DirectXBinding:
45+
Register: 0
46+
Space: 0
47+
VulkanBinding:
48+
Binding: 0
49+
- Name: OutInt
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 1
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 1
56+
...
57+
#--- end
58+
59+
# REQUIRES: Int64
60+
61+
# When compiled with DXC this test encounters a memory coherence issue on Intel
62+
# UHD drivers. This issue does not reproduce when compiled with Clang because
63+
# LLVM's load-store optimization performs correct optimizations that hide the
64+
# problem.
65+
# Tracking issue: https://github.com/llvm/offload-test-suite/issues/226
66+
# XFAIL: Intel-Memory-Coherence-Issue-226 && !Clang
67+
68+
# https://github.com/microsoft/DirectXShaderCompiler/issues/7494
69+
# https://github.com/llvm/llvm-project/issues/142677
70+
# UNSUPPORTED: Vulkan
71+
72+
# RUN: split-file %s %t
73+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
74+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<uint32_t> X : register(t0);
4+
RWStructuredBuffer<uint32_t> Result : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Result[0] = X[0] + 1;
9+
Result[1] = X[1] + Result[0];
10+
11+
Result[2] = X[0] + 2;
12+
Result[3] = X[1] + Result[2];
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: X
24+
Format: Int32
25+
Stride: 4
26+
Data: [ 0, 1 ]
27+
- Name: Result
28+
Format: Int32
29+
Stride: 4
30+
ZeroInitSize: 16
31+
- Name: ExpectedResult
32+
Format: Int32
33+
Stride: 4
34+
Data: [ 1, 2, 2, 3 ]
35+
Results:
36+
- Result: CheckResult
37+
Rule: BufferExact
38+
Actual: Result
39+
Expected: ExpectedResult
40+
DescriptorSets:
41+
- Resources:
42+
- Name: X
43+
Kind: StructuredBuffer
44+
DirectXBinding:
45+
Register: 0
46+
Space: 0
47+
VulkanBinding:
48+
Binding: 0
49+
- Name: Result
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 1
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 1
56+
...
57+
#--- end
58+
59+
# When compiled with DXC this test encounters a memory coherence issue on Intel
60+
# UHD drivers. This issue does not reproduce when compiled with Clang because
61+
# LLVM's load-store optimization performs correct optimizations that hide the
62+
# problem.
63+
# Tracking issue: https://github.com/llvm/offload-test-suite/issues/226
64+
# XFAIL: Intel-Memory-Coherence-Issue-226 && !Clang
65+
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)