Skip to content
Merged
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
81 changes: 81 additions & 0 deletions test/Feature/InlineRT/barycentrics.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#--- source.hlsl

[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
[[vk::binding(1, 0)]] RWStructuredBuffer<uint2> Output : register(u0);

[numthreads(1,1,1)]
void main() {
// Triangle vertices V0=(0,1,0), V1=(-1,-1,0), V2=(1,-1,0). Aim the ray at
// world (0,0,0); the barycentric weights (1-u-v, u, v) that reconstruct
// that point are (0.5, 0.25, 0.25), so CommittedTriangleBarycentrics()
// must return exactly (0.25, 0.25).
RayDesc Ray;
Ray.Origin = float3(0, 0, 1);
Ray.Direction = float3(0, 0, -1);
Ray.TMin = 0.0;
Ray.TMax = 100.0;
RayQuery<RAY_FLAG_NONE> Q;
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
Q.Proceed();
Output[0] = asuint(Q.CommittedTriangleBarycentrics());
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
Buffers:
- Name: Vertices
Format: Float32
Stride: 12
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
- Name: Output
Format: UInt32
Stride: 8
FillSize: 8
- Name: Expected
Format: UInt32
Stride: 8
Data: [ 0x3e800000, 0x3e800000 ] # asuint((0.25, 0.25))
AccelerationStructures:
BLAS:
- Name: TriangleBLAS
Triangles:
- VertexBuffer: Vertices
VertexFormat: RGB32Float
VertexStride: 12
VertexCount: 3
TLAS:
- Name: Scene
Instances:
- BLAS: TriangleBLAS
DescriptorSets:
- Resources:
- Name: Scene
Kind: AccelerationStructure
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Output
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 1
Results:
- Result: CommittedTriangleBarycentrics
Rule: BufferExact
Actual: Output
Expected: Expected
...
#--- end

# REQUIRES: acceleration-structure
# XFAIL: Clang

# 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
78 changes: 78 additions & 0 deletions test/Feature/InlineRT/miss-status.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#--- source.hlsl

[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);

[numthreads(1,1,1)]
void main() {
// Ray points away from the triangle (which sits at z=0); must not hit.
RayDesc Ray;
Ray.Origin = float3(0, 0, 1);
Ray.Direction = float3(0, 0, 1);
Ray.TMin = 0.0;
Ray.TMax = 100.0;
RayQuery<RAY_FLAG_NONE> Q;
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
Q.Proceed();
Output[0] = (uint)Q.CommittedStatus();
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
Buffers:
- Name: Vertices
Format: Float32
Stride: 12
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
- Name: Output
Format: UInt32
Stride: 4
FillSize: 4
- Name: Expected
Format: UInt32
Stride: 4
Data: [ 0 ] # COMMITTED_NOTHING
AccelerationStructures:
BLAS:
- Name: TriangleBLAS
Triangles:
- VertexBuffer: Vertices
VertexFormat: RGB32Float
VertexStride: 12
VertexCount: 3
TLAS:
- Name: Scene
Instances:
- BLAS: TriangleBLAS
DescriptorSets:
- Resources:
- Name: Scene
Kind: AccelerationStructure
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Output
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 1
Results:
- Result: MissStatus
Rule: BufferExact
Actual: Output
Expected: Expected
...
#--- end

# REQUIRES: acceleration-structure
# XFAIL: Clang

# 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
79 changes: 79 additions & 0 deletions test/Feature/InlineRT/ray-t.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#--- source.hlsl

[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);

[numthreads(1,1,1)]
void main() {
// Triangle sits at z=0 and the ray starts at z=1 heading along -z, so
// CommittedRayT() must equal 1.0 exactly.
RayDesc Ray;
Ray.Origin = float3(0, 0, 1);
Ray.Direction = float3(0, 0, -1);
Ray.TMin = 0.0;
Ray.TMax = 100.0;
RayQuery<RAY_FLAG_NONE> Q;
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
Q.Proceed();
Output[0] = asuint(Q.CommittedRayT());
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
Buffers:
- Name: Vertices
Format: Float32
Stride: 12
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
- Name: Output
Format: UInt32
Stride: 4
FillSize: 4
- Name: Expected
Format: UInt32
Stride: 4
Data: [ 0x3f800000 ] # asuint(1.0)
AccelerationStructures:
BLAS:
- Name: TriangleBLAS
Triangles:
- VertexBuffer: Vertices
VertexFormat: RGB32Float
VertexStride: 12
VertexCount: 3
TLAS:
- Name: Scene
Instances:
- BLAS: TriangleBLAS
DescriptorSets:
- Resources:
- Name: Scene
Kind: AccelerationStructure
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Output
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 1
Results:
- Result: CommittedRayT
Rule: BufferExact
Actual: Output
Expected: Expected
...
#--- end

# REQUIRES: acceleration-structure
# XFAIL: Clang

# 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
89 changes: 89 additions & 0 deletions test/Feature/InlineRT/tmin-tmax-clip.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#--- source.hlsl

[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);

[numthreads(1,1,1)]
void main() {
// The triangle sits at z=0 and the ray starts at z=1 along -z, so the hit
// is at t=1.0. Probe two queries that each push the [TMin, TMax] window
// off that hit — one starts above it, the other ends below it. Both must
// return COMMITTED_NOTHING.
RayDesc Ray;
Ray.Origin = float3(0, 0, 1);
Ray.Direction = float3(0, 0, -1);

Ray.TMin = 2.0;
Ray.TMax = 100.0;
RayQuery<RAY_FLAG_NONE> QFar;
QFar.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
QFar.Proceed();
Output[0] = (uint)QFar.CommittedStatus();

Ray.TMin = 0.0;
Ray.TMax = 0.5;
RayQuery<RAY_FLAG_NONE> QNear;
QNear.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
QNear.Proceed();
Output[1] = (uint)QNear.CommittedStatus();
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
Buffers:
- Name: Vertices
Format: Float32
Stride: 12
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
- Name: Output
Format: UInt32
Stride: 4
FillSize: 8
- Name: Expected
Format: UInt32
Stride: 4
Data: [ 0, 0 ] # Both queries miss → COMMITTED_NOTHING
AccelerationStructures:
BLAS:
- Name: TriangleBLAS
Triangles:
- VertexBuffer: Vertices
VertexFormat: RGB32Float
VertexStride: 12
VertexCount: 3
TLAS:
- Name: Scene
Instances:
- BLAS: TriangleBLAS
DescriptorSets:
- Resources:
- Name: Scene
Kind: AccelerationStructure
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Output
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 1
Results:
- Result: TMinTMaxClip
Rule: BufferExact
Actual: Output
Expected: Expected
...
#--- end

# REQUIRES: acceleration-structure
# XFAIL: Clang

# 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