diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2025-02-11 19:07:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-11 19:07:57 +0800 |
| commit | 0b4e463aee4107b383067424007c6a995f1f9f87 (patch) | |
| tree | e78fc7287a07643b890c0d981bd5ef95520dcf93 /tests | |
| parent | 0bc18d233966fc80cf2c482922d0b773d58394ca (diff) | |
Add raypayload decoration to ray payload structs (#6164)
* Add raypayload decoration to ray payload structs
Closes https://github.com/shader-slang/slang/issues/6104
* Disable PAQs when compiling with DXC
See https://github.com/shader-slang/slang/issues/3448
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expected-failure-github.txt | 2 | ||||
| -rw-r--r-- | tests/hlsl/raypayload-attribute-no-struct.slang | 29 | ||||
| -rw-r--r-- | tests/hlsl/raypayload-attribute.slang | 34 | ||||
| -rw-r--r-- | tests/vkray/raygen-trace-ray-param-non-struct.slang | 24 |
4 files changed, 75 insertions, 14 deletions
diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt index 6bf4f041d..60d632785 100644 --- a/tests/expected-failure-github.txt +++ b/tests/expected-failure-github.txt @@ -13,6 +13,4 @@ tests/bugs/buffer-swizzle-store.slang.3 syn (wgpu) tests/compute/interface-shader-param-in-struct.slang.4 syn (wgpu) tests/compute/interface-shader-param.slang.5 syn (wgpu) tests/language-feature/shader-params/interface-shader-param-ordinary.slang.4 syn (wgpu) -gfx-unit-test-tool/RayTracingTestAD3D12.internal -gfx-unit-test-tool/RayTracingTestBD3D12.internal gfx-unit-test-tool/precompiledTargetModule2Vulkan.internal diff --git a/tests/hlsl/raypayload-attribute-no-struct.slang b/tests/hlsl/raypayload-attribute-no-struct.slang new file mode 100644 index 000000000..c7ad94593 --- /dev/null +++ b/tests/hlsl/raypayload-attribute-no-struct.slang @@ -0,0 +1,29 @@ +//enable when https://github.com/shader-slang/slang/issues/3448 is implemented +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA + +// CHECK: struct [raypayload] + +uniform RWTexture2D resultTexture; +uniform RaytracingAccelerationStructure sceneBVH; + +[shader("raygeneration")] +void rayGenShaderA() +{ + int2 threadIdx = DispatchRaysIndex().xy; + + float3 rayDir = float3(0, 0, 1); + float3 rayOrigin = 0; + rayOrigin.x = (threadIdx.x * 2) - 1; + rayOrigin.y = (threadIdx.y * 2) - 1; + + // Trace the ray. + RayDesc ray; + ray.Origin = rayOrigin; + ray.Direction = rayDir; + ray.TMin = 0.001; + ray.TMax = 10000.0; + float4 payload = float4(0, 0, 0, 0); + TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload); + + resultTexture[threadIdx.xy] = payload; +} diff --git a/tests/hlsl/raypayload-attribute.slang b/tests/hlsl/raypayload-attribute.slang new file mode 100644 index 000000000..b981589ac --- /dev/null +++ b/tests/hlsl/raypayload-attribute.slang @@ -0,0 +1,34 @@ +//enable when https://github.com/shader-slang/slang/issues/3448 is implemented +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA + +// CHECK: struct [raypayload] + +struct RayPayload +{ + float4 color; +}; + +uniform RWTexture2D resultTexture; +uniform RaytracingAccelerationStructure sceneBVH; + +[shader("raygeneration")] +void rayGenShaderA() +{ + int2 threadIdx = DispatchRaysIndex().xy; + + float3 rayDir = float3(0, 0, 1); + float3 rayOrigin = 0; + rayOrigin.x = (threadIdx.x * 2) - 1; + rayOrigin.y = (threadIdx.y * 2) - 1; + + // Trace the ray. + RayDesc ray; + ray.Origin = rayOrigin; + ray.Direction = rayDir; + ray.TMin = 0.001; + ray.TMax = 10000.0; + RayPayload payload = { float4(0, 0, 0, 0) }; + TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload); + + resultTexture[threadIdx.xy] = payload.color; +} diff --git a/tests/vkray/raygen-trace-ray-param-non-struct.slang b/tests/vkray/raygen-trace-ray-param-non-struct.slang index c4451d941..b0a129761 100644 --- a/tests/vkray/raygen-trace-ray-param-non-struct.slang +++ b/tests/vkray/raygen-trace-ray-param-non-struct.slang @@ -22,13 +22,13 @@ void main() ray.Direction = float3(0,0,1); ray.TMax = 100.0f; - // CHECK: ForceVarIntoStructTemporarily_t{{_[0-9]}} forceVarIntoStructTemporarily{{_[0-9]}}; + // CHECK: RayPayload_t{{_[0-9]}} rayPayload{{_[0-9]}}; float someInData1 = 5.0f; addComplexity1(someInData1); - // CHECK: forceVarIntoStructTemporarily{{_[0-9]}}.data{{_[0-9]}} = {{.*}} + // CHECK: rayPayload{{_[0-9]}}.data{{_[0-9]}} = {{.*}} // CHECK: TraceRay( - // CHECK: {{.*}} = forceVarIntoStructTemporarily{{.*}}.data{{.*}}; + // CHECK: {{.*}} = rayPayload{{.*}}.data{{.*}}; TraceRay(as, 1, 0xff, @@ -39,9 +39,9 @@ void main() someInData1); outputBuffer1[0] = outputBuffer1[0]+someInData1; - // CHECK: forceVarIntoStructTemporarily{{_[0-9]}}.data{{_[0-9]}} = {{.*}} + // CHECK: rayPayload{{_[0-9]}}.data{{_[0-9]}} = {{.*}} // CHECK: TraceMotionRay( - // CHECK: {{.*}} = forceVarIntoStructTemporarily{{.*}}.data{{.*}}; + // CHECK: {{.*}} = rayPayload{{.*}}.data{{.*}}; TraceMotionRay(as, 1, 0xff, @@ -53,9 +53,9 @@ void main() someInData1); outputBuffer1[0] = outputBuffer1[0]+someInData1; - // CHECK: forceVarIntoStructTemporarily{{_[0-9]}}.data{{_[0-9]}} = {{.*}} + // CHECK: rayPayload{{_[0-9]}}.data{{_[0-9]}} = {{.*}} // CHECK: NvTraceRayHitObject( - // CHECK: {{.*}} = forceVarIntoStructTemporarily{{.*}}.data{{.*}}; + // CHECK: {{.*}} = rayPayload{{.*}}.data{{.*}}; HitObject::TraceRay(as, 1, 0xff, @@ -66,9 +66,9 @@ void main() someInData1); outputBuffer1[0] = outputBuffer1[0]+someInData1; - // CHECK: forceVarIntoStructTemporarily{{_[0-9]}}.data{{_[0-9]}} = {{.*}} + // CHECK: rayPayload{{_[0-9]}}.data{{_[0-9]}} = {{.*}} // CHECK: TraceMotionRay( - // CHECK: {{.*}} = forceVarIntoStructTemporarily{{.*}}.data{{.*}}; + // CHECK: {{.*}} = rayPayload{{.*}}.data{{.*}}; HitObject::TraceMotionRay(as, 1, 0xff, @@ -80,9 +80,9 @@ void main() someInData1); outputBuffer1[0] = outputBuffer1[0]+someInData1; - // CHECK: forceVarIntoStructTemporarily{{_[0-9]}}.data{{_[0-9]}} = {{.*}} + // CHECK: rayPayload{{_[0-9]}}.data{{_[0-9]}} = {{.*}} // CHECK: NvInvokeHitObject( - // CHECK: {{.*}} = forceVarIntoStructTemporarily{{.*}}.data{{.*}}; + // CHECK: {{.*}} = rayPayload{{.*}}.data{{.*}}; HitObject hitObject_HitOrMiss; HitObject::Invoke( as, @@ -91,4 +91,4 @@ void main() outputBuffer1[0] = outputBuffer1[0]+someInData1; addComplexity2(someInData1); -}
\ No newline at end of file +} |
