-
Notifications
You must be signed in to change notification settings - Fork 20
Add reflect
tests
#287
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
Merged
Merged
Add reflect
tests
#287
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
789bc8e
add reflect tests
bob80905 512e927
special test
bob80905 755e907
remove special test
bob80905 52f65f2
throw in a -0
bob80905 00ff33c
Address Tex, use better non-edge-case values
bob80905 7e2edb4
remove Gis, remove misleading comments
bob80905 8f8cd25
address Finn, annotate decimal values in fp16 test
bob80905 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
#--- source.hlsl | ||
|
||
// This test tests three different reflection scenarios | ||
// One in 2D, 3D, and 4D | ||
|
||
StructuredBuffer<half2> IncidentRay2D : register(t0); | ||
StructuredBuffer<half4> IncidentRay3D : register(t1); | ||
StructuredBuffer<half4> IncidentRay4D : register(t2); | ||
StructuredBuffer<half2> Wall2D : register(t3); | ||
StructuredBuffer<half4> Wall3D : register(t4); | ||
StructuredBuffer<half4> Wall4D : register(t5); | ||
RWStructuredBuffer<half2> Result2D : register(u6); | ||
RWStructuredBuffer<half4> Result3D : register(u7); | ||
RWStructuredBuffer<half4> Result4D : register(u8); | ||
|
||
[numthreads(1,1,1)] | ||
void main() { | ||
// 2D case | ||
half2 result2D = reflect(IncidentRay2D[0].xy, normalize(Wall2D[0].xy)); | ||
Result2D[0] = result2D; | ||
half2 result2D_constant = reflect(half2(0.75, -0.5), half2(0.70710677, 0.70710677)); | ||
Result2D[1] = result2D_constant; | ||
|
||
// 3D case, using half4 for alignment | ||
half4 result3D = half4(reflect(IncidentRay3D[0].xyz, normalize(Wall3D[0].xyz)), 0.0); | ||
Result3D[0] = result3D; | ||
half4 result3D_constant = half4(reflect(half3(0.5, -0.25, 0.75), half3(0.5, 0.5, 0.70710677)), 0.0); | ||
Result3D[1] = result3D_constant; | ||
|
||
// 4D case | ||
half4 result4D = reflect(IncidentRay4D[0].xyzw, normalize(Wall4D[0].xyzw)); | ||
Result4D[0] = result4D; | ||
half4 result4D_constant = reflect(half4(0.5, -0.25, 0.75, -0.5), half4(0.5, 0.5, 0.5, 0.5)); | ||
Result4D[1] = result4D_constant; | ||
} | ||
|
||
//--- pipeline.yaml | ||
|
||
--- | ||
Shaders: | ||
- Stage: Compute | ||
Entry: main | ||
DispatchSize: [1, 1, 1] | ||
Buffers: | ||
|
||
- Name: IncidentRay2D | ||
Format: Float16 | ||
Stride: 4 | ||
Data: [ 0x3a00, 0xb800 ] | ||
# 0.75, -0.5 | ||
- Name: IncidentRay3D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0x3800, 0xb400, 0x3a00, 0x0000 ] | ||
# 0.5, -0.25, 0.75, 0.0 | ||
- Name: IncidentRay4D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0x3800, 0xb400, 0x3a00, 0xb800 ] | ||
# 0.5, -0.25, 0.75, 0.0 | ||
- Name: Wall2D | ||
Format: Float16 | ||
Stride: 4 | ||
Data: [ 0x39a8, 0x39a8 ] | ||
# 0.70703125, 0.70703125 | ||
- Name: Wall3D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0x3800, 0x3800, 0x39a8, 0x0000 ] | ||
# 0.5, 0.5, 0.70703125, 0.0 | ||
- Name: Wall4D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0x3800, 0x3800, 0x3800, 0x3800 ] | ||
# 0.5, 0.5, 0.5, 0.5 | ||
- Name: Result2D | ||
Format: Float16 | ||
Stride: 4 | ||
ZeroInitSize: 8 | ||
- Name: ExpectedResult2D | ||
Format: Float16 | ||
Stride: 4 | ||
Data: [ 0x3800, 0xba00, 0x3800, 0xba00 ] | ||
# 0.5, -0.75, 0.5, -0.75 | ||
- Name: Result3D | ||
Format: Float16 | ||
Stride: 8 | ||
ZeroInitSize: 16 | ||
- Name: ExpectedResult3D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0xb0f8, 0xbb3e, 0xb1a8, 0x0000, 0xb0f8, 0xbb3e, 0xb1a8, 0x0000 ] | ||
# -0.15527344, -0.90527344, -0.17675781, 0.0, -0.15527344, -0.90527344, -0.17675781, 0.0 | ||
- Name: Result4D | ||
Format: Float16 | ||
Stride: 8 | ||
ZeroInitSize: 16 | ||
- Name: ExpectedResult4D | ||
Format: Float16 | ||
Stride: 8 | ||
Data: [ 0x3400, 0xb800, 0x3800, 0xba00, 0x3400, 0xb800, 0x3800, 0xba00 ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Can we annotate what the decimal values are for these (and elsewhere) |
||
# 0.25, -0.5, 0.5, -0.75, 0.25, -0.5, 0.5, -0.75 | ||
Results: | ||
- Result: CheckResult2D | ||
Rule: BufferFloatULP | ||
ULPT: 1 | ||
Actual: Result2D | ||
Expected: ExpectedResult2D | ||
- Result: CheckResult3D | ||
Rule: BufferFloatULP | ||
ULPT: 1 | ||
Actual: Result3D | ||
Expected: ExpectedResult3D | ||
- Result: CheckResult4D | ||
Rule: BufferFloatULP | ||
ULPT: 1 | ||
Actual: Result4D | ||
Expected: ExpectedResult4D | ||
|
||
DescriptorSets: | ||
- Resources: | ||
- Name: IncidentRay2D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 0 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 0 | ||
- Name: IncidentRay3D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 1 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 1 | ||
- Name: IncidentRay4D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 2 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 2 | ||
- Name: Wall2D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 3 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 3 | ||
- Name: Wall3D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 4 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 4 | ||
- Name: Wall4D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 5 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 5 | ||
- Name: Result2D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 6 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 6 | ||
- Name: Result3D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 7 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 7 | ||
- Name: Result4D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 8 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 8 | ||
... | ||
#--- end | ||
# UNSUPPORTED: Clang-Vulkan | ||
|
||
# RUN: split-file %s %t | ||
# RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl | ||
# RUN: %offloader %t/pipeline.yaml %t.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
#--- source.hlsl | ||
|
||
// This test tests three different reflection scenarios | ||
// One in 2D, 3D, and 4D | ||
|
||
StructuredBuffer<float2> IncidentRay2D : register(t0); | ||
StructuredBuffer<float4> IncidentRay3D : register(t1); | ||
StructuredBuffer<float4> IncidentRay4D : register(t2); | ||
StructuredBuffer<float2> Wall2D : register(t3); | ||
StructuredBuffer<float4> Wall3D : register(t4); | ||
StructuredBuffer<float4> Wall4D : register(t5); | ||
RWStructuredBuffer<float2> Result2D : register(u6); | ||
RWStructuredBuffer<float4> Result3D : register(u7); | ||
RWStructuredBuffer<float4> Result4D : register(u8); | ||
|
||
[numthreads(1,1,1)] | ||
void main() { | ||
// 2D case | ||
float2 result2D = reflect(IncidentRay2D[0].xy, normalize(Wall2D[0].xy)); | ||
Result2D[0] = result2D; | ||
float2 result2D_constant = reflect(float2(0.75, -0.5), float2(0.70710677, 0.70710677)); | ||
Result2D[1] = result2D_constant; | ||
|
||
// 3D case, using float4 for alignment | ||
float4 result3D = float4(reflect(IncidentRay3D[0].xyz, normalize(Wall3D[0].xyz)), 0.0); | ||
Result3D[0] = result3D; | ||
float4 result3D_constant = float4(reflect(float3(0.5, -0.25, 0.75), float3(0.5, 0.5, 0.70710677)), 0.0); | ||
Result3D[1] = result3D_constant; | ||
|
||
// 4D case | ||
float4 result4D = reflect(IncidentRay4D[0].xyzw, normalize(Wall4D[0].xyzw)); | ||
Result4D[0] = result4D; | ||
float4 result4D_constant = reflect(float4(0.5, -0.25, 0.75, -0.5), float4(0.5, 0.5, 0.5, 0.5)); | ||
Result4D[1] = result4D_constant; | ||
} | ||
|
||
//--- pipeline.yaml | ||
|
||
--- | ||
Shaders: | ||
- Stage: Compute | ||
Entry: main | ||
DispatchSize: [1, 1, 1] | ||
Buffers: | ||
|
||
- Name: IncidentRay2D | ||
Format: Float32 | ||
Stride: 8 | ||
Data: [ 0.75, -0.5 ] | ||
- Name: IncidentRay3D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ 0.5, -0.25, 0.75, 0.0 ] | ||
- Name: IncidentRay4D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ 0.5, -0.25, 0.75, -0.5 ] | ||
|
||
- Name: Wall2D | ||
Format: Float32 | ||
Stride: 8 | ||
Data: [ 0.70710677, 0.70710677 ] | ||
- Name: Wall3D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ 0.5, 0.5, 0.70710677, 0.0 ] | ||
- Name: Wall4D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ 0.5, 0.5, 0.5, 0.5 ] | ||
|
||
- Name: Result2D | ||
Format: Float32 | ||
Stride: 8 | ||
ZeroInitSize: 16 | ||
- Name: ExpectedResult2D | ||
Format: Float32 | ||
Stride: 8 | ||
Data: [ 0.5, -0.75, 0.5, -0.75 ] | ||
|
||
- Name: Result3D | ||
Format: Float32 | ||
Stride: 16 | ||
ZeroInitSize: 32 | ||
- Name: ExpectedResult3D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ -0.15533, -0.90533, -0.176777, 0.0, -0.15533, -0.90533, -0.176777, 0.0 ] | ||
|
||
- Name: Result4D | ||
Format: Float32 | ||
Stride: 16 | ||
ZeroInitSize: 32 | ||
- Name: ExpectedResult4D | ||
Format: Float32 | ||
Stride: 16 | ||
Data: [ 0.25, -0.5, 0.5, -0.75, 0.25, -0.5, 0.5, -0.75 ] | ||
|
||
Results: | ||
- Result: CheckResult2D | ||
Rule: BufferFloatEpsilon | ||
Epsilon: 0.000002 | ||
Actual: Result2D | ||
Expected: ExpectedResult2D | ||
- Result: CheckResult3D | ||
Rule: BufferFloatEpsilon | ||
Epsilon: 0.000002 | ||
Actual: Result3D | ||
Expected: ExpectedResult3D | ||
- Result: CheckResult4D | ||
Rule: BufferFloatEpsilon | ||
Epsilon: 0.000002 | ||
Actual: Result4D | ||
Expected: ExpectedResult4D | ||
|
||
DescriptorSets: | ||
- Resources: | ||
- Name: IncidentRay2D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 0 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 0 | ||
- Name: IncidentRay3D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 1 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 1 | ||
- Name: IncidentRay4D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 2 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 2 | ||
- Name: Wall2D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 3 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 3 | ||
- Name: Wall3D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 4 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 4 | ||
- Name: Wall4D | ||
Kind: StructuredBuffer | ||
DirectXBinding: | ||
Register: 5 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 5 | ||
- Name: Result2D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 6 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 6 | ||
- Name: Result3D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 7 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 7 | ||
- Name: Result4D | ||
Kind: RWStructuredBuffer | ||
DirectXBinding: | ||
Register: 8 | ||
Space: 0 | ||
VulkanBinding: | ||
Binding: 8 | ||
... | ||
#--- end | ||
# UNSUPPORTED: Clang-Vulkan | ||
|
||
# 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe all the values that are used in this test (and all others) are exactly representable in IEE 754. Should we have an extra test that uses values that will be rounded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.70710677 gets rounded to 0.70703125 in the 3D test. Does that resolve your concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that works