diff options
| author | Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> | 2025-04-07 13:26:11 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 07:56:11 +0000 |
| commit | ce87ab925d06a784eec194081e00a1b4c9b94d0c (patch) | |
| tree | 086e60c0205e00e0f0e1c31761434f5e9bf5fbcb /tests/hlsl | |
| parent | 1b82501dd0c74347cda4a2c7fe5a84fd610bb485 (diff) | |
Support for Payload Access Qualifiers (#3448) (#6595)
* Add support for Ray Payload Access Qualifiers (PAQs) (#3448)
- Added [raypayload] attribute for struct declarations
- Implemented field validation requiring read/write access qualifiers
- Added diagnostic error for missing qualifiers
- Enabled PAQs in DXC compiler and HLSL emission
- Added new test demonstrating PAQ syntax
- Implemented proper handling of ray payload attributes in IR generation
* format code
* Cleanup: Remove unused vars
* Add check to enablePAQ only for profile >= lib_6_7
* Review Fix - Add PAQ support for DX Raytracing
add enablePAQ flag to DownstreamCompileOpitons, improve PAQ handling
update raypayload-attribute-paq.slang to ensure hlsl and dxil is
validated
* Add diagnostic test for missing paq for lib_6_7
Compile using `-disable-payload-qualifiers` aka lib_6_6 profile
raypayload-attribute-no-struct.slang and
raypayload-attribute.slang
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tests/hlsl')
| -rw-r--r-- | tests/hlsl/raypayload-attribute-no-struct.slang | 7 | ||||
| -rw-r--r-- | tests/hlsl/raypayload-attribute-paq.slang | 37 | ||||
| -rw-r--r-- | tests/hlsl/raypayload-attribute.slang | 9 |
3 files changed, 46 insertions, 7 deletions
diff --git a/tests/hlsl/raypayload-attribute-no-struct.slang b/tests/hlsl/raypayload-attribute-no-struct.slang index c7ad94593..4e4921e14 100644 --- a/tests/hlsl/raypayload-attribute-no-struct.slang +++ b/tests/hlsl/raypayload-attribute-no-struct.slang @@ -1,7 +1,8 @@ -//enable when https://github.com/shader-slang/slang/issues/3448 is implemented -//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_6 -stage raygeneration -entry rayGenShaderA +//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_6 -stage raygeneration -entry rayGenShaderA -// CHECK: struct [raypayload] +// CHECK: struct RayPayload +// DXIL: define void @ uniform RWTexture2D resultTexture; uniform RaytracingAccelerationStructure sceneBVH; diff --git a/tests/hlsl/raypayload-attribute-paq.slang b/tests/hlsl/raypayload-attribute-paq.slang new file mode 100644 index 000000000..3af0556bc --- /dev/null +++ b/tests/hlsl/raypayload-attribute-paq.slang @@ -0,0 +1,37 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_7 -stage raygeneration -entry rayGenShaderA +//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_7 -stage raygeneration -entry rayGenShaderA + +// CHECK: struct [raypayload] +// CHECK: float4 color_0 : read(caller, anyhit) : write(caller); +// DXIL: define void @ +// DXIL: !dx.dxrPayloadAnnotations + +struct [raypayload] RayPayload +{ + float4 color : read(caller, anyhit) : write(caller); +}; + +uniform RWTexture2D<float4> 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/hlsl/raypayload-attribute.slang b/tests/hlsl/raypayload-attribute.slang index b981589ac..1a9e9a7f5 100644 --- a/tests/hlsl/raypayload-attribute.slang +++ b/tests/hlsl/raypayload-attribute.slang @@ -1,8 +1,9 @@ -//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] +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_6 -stage raygeneration -entry rayGenShaderA +//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_6 -stage raygeneration -entry rayGenShaderA +// CHECK: struct RayPayload +// CHECK: float4 color +// DXIL: define void @ struct RayPayload { float4 color; |
