Skip to content

Add min tests #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
176 changes: 176 additions & 0 deletions test/Feature/HLSLLib/min.32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#--- source.hlsl
StructuredBuffer<float4> X0 : register(t0);
StructuredBuffer<float4> Y0 : register(t1);
StructuredBuffer<int4> X1 : register(t2);
StructuredBuffer<int4> Y1 : register(t3);
StructuredBuffer<uint4> X2 : register(t4);
StructuredBuffer<uint4> Y2 : register(t5);

RWStructuredBuffer<float4> Out0 : register(u6);
RWStructuredBuffer<int4> Out1 : register(u7);
RWStructuredBuffer<uint4> Out2 : register(u8);


[numthreads(1,1,1)]
void main() {
// float
Out0[0] = min(X0[0], Y0[0]);
Out0[1] = float4(min(X0[1].xyz, Y0[1].xyz), min(X0[1].w, Y0[1].w));
Out0[2] = float4(min(X0[2].xy, Y0[2].xy), min(X0[2].zw, Y0[2].zw));
Out0[3] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5));

// int
Out1[0] = min(X1[0], Y1[0]);
Out1[1] = int4(min(X1[1].xyz, Y1[1].xyz), min(X1[1].w, Y1[1].w));
Out1[2] = int4(min(X1[2].xy, Y1[2].xy), min(X1[2].zw, Y1[2].zw));
Out1[3] = min(X1[3], Y1[3]);
Out1[3] = min(int4(-2147483648, -10, 10, 2147483647), int4(0, 10, 10, 0));

// uint
Out2[0] = min(X2[0], Y2[0]);
Out2[1] = uint4(min(X2[1].xyz, Y2[1].xyz), min(X2[1].w, Y2[1].w));
Out2[2] = uint4(min(X2[2].xy, Y2[2].xy), min(X2[2].zw, Y2[2].zw));
Out2[3] = min(X2[3], Y2[3]);
Out2[3] = min(uint4(0, 0, 10, 10000), uint4(0, 256, 4, 10001));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: X0
Format: Float32
Stride: 16
Data: [ 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 3e+38, 0 ]
- Name: Y0
Format: Float32
Stride: 16
Data: [ -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -3e+38 ]
- Name: X1
Format: Int32
Stride: 16
Data: [ -2147483648, -10, 0, 0, 10, 2147483647, 1000, 2500, 1, -1, 512, -2048 ]
- Name: Y1
Format: Int32
Stride: 16
Data: [ 0, 10, -10, 10, 10, 0, 1500, 2000, -1, 1, 511, -2047 ]
- Name: X2
Format: UInt32
Stride: 16
Data: [ 0, 0, 10, 10000, 2147483647, 4294967295, 1000, 2500, 1, 256, 512, 2048 ]
- Name: Y2
Format: UInt32
Stride: 16
Data: [ 0, 256, 4, 10001, 0, 4294967295, 1500, 2000, 0, 200, 511, 2047 ]
- Name: Out0
Format: Float32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut0
Format: Float32
Stride: 16
Data: [ -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -3e+38, -1.0, -1.0, 1.5, -415 ]
- Name: Out1
Format: Int32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut1
Format: Int32
Stride: 16
Data: [ -2147483648, -10, -10, 0, 10, 0, 1000, 2000, -1, -1, 511, -2048, -2147483648, -10, 10, 0 ]
- Name: Out2
Format: UInt32
Stride: 16
ZeroInitSize: 64
- Name: ExpectedOut2
Format: UInt32
Stride: 16
Data: [ 0, 0, 4, 10000, 0, 4294967295, 1000, 2000, 0, 200, 511, 2047, 0, 0, 4, 10000 ]
Results:
- Result: Test0
Rule: BufferFloatEpsilon
Epsilon: 0
Actual: Out0
Expected: ExpectedOut0
- Result: Test1
Rule: BufferExact
Actual: Out1
Expected: ExpectedOut1
- Result: Test2
Rule: BufferExact
Actual: Out2
Expected: ExpectedOut2
DescriptorSets:
- Resources:
- Name: X0
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Y0
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: X1
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Y1
Kind: StructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
- Name: X2
Kind: StructuredBuffer
DirectXBinding:
Register: 4
Space: 0
VulkanBinding:
Binding: 4
- Name: Y2
Kind: StructuredBuffer
DirectXBinding:
Register: 5
Space: 0
VulkanBinding:
Binding: 5
- Name: Out0
Kind: RWStructuredBuffer
DirectXBinding:
Register: 6
Space: 0
VulkanBinding:
Binding: 6
- Name: Out1
Kind: RWStructuredBuffer
DirectXBinding:
Register: 7
Space: 0
VulkanBinding:
Binding: 7
- Name: Out2
Kind: RWStructuredBuffer
DirectXBinding:
Register: 8
Space: 0
VulkanBinding:
Binding: 8
#--- end


# 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
76 changes: 76 additions & 0 deletions test/Feature/HLSLLib/min.fp16.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#--- source.hlsl
StructuredBuffer<half4> X : register(t0);
StructuredBuffer<half4> Y : register(t1);

RWStructuredBuffer<half4> Out : register(u2);


[numthreads(1,1,1)]
void main() {
Out[0] = min(X[0], Y[0]);
Out[1] = half4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w));
Out[2] = half4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw));
Out[3] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: X
Format: Float16
Stride: 8
Data: [ 0x3c00, 0xbc00, 0x77ab, 0xde7c, 0x4248, 0x5140, 0xd7b7, 0x068e, 0xc900, 0x4940, 0x7bff, 0x0000 ]
# 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 65504, 0
- Name: Y
Format: Float16
Stride: 8
Data: [ 0xbc00, 0x3c00, 0x3e00, 0x580c, 0x4170, 0x5140, 0xe11d, 0x0a8e, 0x4900, 0x4940, 0x0000, 0xfbff ]
# -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -65504
- Name: Out
Format: Float16
Stride: 8
ZeroInitSize: 32
- Name: ExpectedOut
Format: Float16
Stride: 8
Data: [ 0xbc00, 0xbc00, 0x3e00, 0xde7c, 0x4170, 0x5140, 0xe11d, 0x068e, 0xc900, 0x4940, 0x0000, 0xfbff, 0xbc00, 0xbc00, 0x3e00, 0xde7c ]
# -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -65504, -1.0, -1.0, 1.5, -415
Results:
- Result: Test0
Rule: BufferFloatEpsilon
Epsilon: 0
Actual: Out
Expected: ExpectedOut
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: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
#--- end

# 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
73 changes: 73 additions & 0 deletions test/Feature/HLSLLib/min.fp64.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#--- source.hlsl
StructuredBuffer<double4> X : register(t0);
StructuredBuffer<double4> Y : register(t1);

RWStructuredBuffer<double4> Out : register(u2);


[numthreads(1,1,1)]
void main() {
Out[0] = min(X[0], Y[0]);
Out[1] = double4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w));
Out[2] = double4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw));
Out[3] = min(double4(1.0, -1.0, 31408, -415), double4(-1.0, 1.0, 1.5, 129.5));
}
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: X
Format: Float64
Stride: 32
Data: [ 1.0, -1.0, 31408, -415, 3.14159, 42, -123.456, 0.0001, -10, 10.5, 1e+308, 0 ]
- Name: Y
Format: Float64
Stride: 32
Data: [ -1.0, 1.0, 1.5, 129.5, 2.71828, 42, -654.321, 0.0002, 10, 10.5, 0, -1e+308 ]
- Name: Out
Format: Float64
Stride: 32
ZeroInitSize: 128
- Name: ExpectedOut0
Format: Float64
Stride: 32
Data: [ -1.0, -1.0, 1.5, -415, 2.71828, 42, -654.321, 0.0001, -10, 10.5, 0, -1e+308, -1.0, -1.0, 1.5, -415 ]
Results:
- Result: Test0
Rule: BufferFloatEpsilon
Epsilon: 0
Actual: Out
Expected: ExpectedOut0
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: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
#--- end

# REQUIRES: Double
# 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
Loading
Loading