Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions test/Feature/HLSLLib/distance.32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#--- source.hlsl

StructuredBuffer<float4> X : register(t0);
StructuredBuffer<float4> Y : register(t1);

RWStructuredBuffer<float> Result : register(u2);

[numthreads(1,1,1)]
void main() {
// distance ({1.125}, {2.375}) = 1.25
float R0 = distance(X[0].x, Y[0].x);
Result[0] = R0;
float R0_constant = distance(1.125, 2.375);
Result[1] = R0_constant;

// distance({1.125, 2.5}, {2.375, 5.25}) = 3.02076
float R1 = distance(X[0].xy, Y[0].xy);
Result[2] = R1;
float R1_constant = distance(float2(1.125, 2.5), float2(2.375, 5.25));
Result[3] = R1_constant;

// distance({1.125, 2.5, 4.75}, {2.375, 5.25, 8.375}) = 4.71865
float R2 = distance(float3(1.125, 2.5, 4.75), float3(2.375, 5.25, 8.375));
Result[4] = R2;
float R2_constant = distance(X[0].xyz, Y[0].xyz);
Result[5] = R2_constant;

// distance({1.125, 2.5, 4.75, 6.625}, {2.375, 5.25, 8.375, 5.30}) = 4.90115
float R3 = distance(X[0].xyzw, Y[0].xyzw);
Result[6] = R3;
float R3_constant = distance(float4(1.125, 2.5, 4.75, 6.625), float4(1.125, 2.5, 4.75, 6.625));
Result[7] = R3;
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: X
Format: Float32
Stride: 16
Data: [ 1.125, 2.5, 4.75, 6.625 ]
- Name: Y
Format: Float32
Stride: 16
Data: [ 2.375, 5.25, 8.375, 5.30 ]
- Name: Result
Format: Float32
Stride: 4
ZeroInitSize: 32
- Name: ExpectedResult
Format: Float32
Stride: 4
Data: [ 1.25, 1.25, 3.02076, 3.02076, 4.71865, 4.71865, 4.90115, 4.90115 ]
Results:
- Result: CheckResult
Rule: BufferFloatEpsilon
Epsilon: .0008
Actual: Result
Expected: ExpectedResult
DescriptorSets:
- Resources:
- Name: X
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Y
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: Result
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
...
#--- end

# UNSUPPORTED: Clang-Vulkan
# Clang-Vulkan is unsupported because of two validation errors
# This issue tracks its resolution: https://github.com/llvm/offload-test-suite/issues/285
# 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
97 changes: 97 additions & 0 deletions test/Feature/HLSLLib/distance.fp16.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#--- source.hlsl

StructuredBuffer<half4> X : register(t0);
StructuredBuffer<half4> Y : register(t1);

RWStructuredBuffer<half> Result : register(u2);

[numthreads(1,1,1)]
void main() {
// distance ({1.125}, {2.375}) = 1.25
half R0 = distance(X[0].x, Y[0].x);
Result[0] = R0;
half R0_constant = distance(half(1.125), half(2.375));
Result[1] = R0_constant;

// distance({1.125, 2.5}, {2.375, 5.25}) = 3.02076
half R1 = distance(X[0].xy, Y[0].xy);
Result[2] = R1;
half R1_constant = distance(half2(1.125, 2.5), half2(2.375, 5.25));
Result[3] = R1_constant;

// distance({1.125, 2.5, 4.75}, {2.375, 5.25, 8.375}) = 4.71865
half R2 = distance(X[0].xyz, Y[0].xyz);
Result[4] = R2;
half R2_constant = distance(half3(1.125, 2.5, 4.75), half3(2.375, 5.25, 8.375));
Result[5] = R2_constant;

// distance({1.125, 2.5, 4.75, 6.625}, {2.375, 5.25, 8.375, 5.30}) = 4.90115
half R3 = distance(X[0].xyzw, Y[0].xyzw);
Result[6] = R3;
half R3_constant = distance(half4(1.125, 2.5, 4.75, 6.625), half4(2.375, 5.25, 8.375, 5.30));
Result[7] = R3_constant;
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: X
Format: Float16
Stride: 8
Data: [ 0x3c80, 0x4100, 0x44c0, 0x46a0 ]
- Name: Y
Format: Float16
Stride: 8
Data: [ 0x40c0, 0x4540, 0x4830, 0x454d ]
- Name: Result
Format: Float16
Stride: 2
ZeroInitSize: 16
- Name: ExpectedResult
Format: Float16
Stride: 2
Data: [ 0x3d00, 0x3d00, 0x420b, 0x420b, 0x44b8, 0x44b8, 0x44e7, 0x44e7 ]
Results:
- Result: CheckResult
Rule: BufferFloatULP
ULPT: 5
Actual: Result
Expected: ExpectedResult
DescriptorSets:
- Resources:
- Name: X
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Y
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: Result
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
...
#--- end

# UNSUPPORTED: Clang-Vulkan
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Clang-Vulkan unsupported? Sorry if this has been explained before and I forgot or missed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# | Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08742 ]
# | vkCreateShaderModule(): SPIR-V Extension SPV_KHR_float_controls2 was declared, but one of the following requirements is required (1.4.0 (0x00404000) or VK_KHR_shader_float_controls2).

is what I get when running it without that line.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment about that in the tests?

# Clang-Vulkan is unsupported because of two validation errors
# This issue tracks its resolution: https://github.com/llvm/offload-test-suite/issues/285
# REQUIRES: Half
# RUN: split-file %s %t
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
Loading