diff options
| author | Mukund Keshava <mkeshava@nvidia.com> | 2025-03-01 12:19:26 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-28 22:49:26 -0800 |
| commit | b86925c1929186c122536b9a7ed75131faceddb7 (patch) | |
| tree | 86f1078bffd1001bcafe6fbaa2d0da297389b997 /tests/vkray | |
| parent | dd9d24d29c4a9e05a4510eb9959fafa0ed36618b (diff) | |
Consolidate multiple inouts/outs into struct (#6435)
* Consolidate multiple inout/outs into struct
Fixes #5121
VUID-StandaloneSpirv-IncomingRayPayloadKHR-04700 requires that there be
only one IncomingRayPayloadKHR per entry point. This change does two
things:
1. If an entry point has the one inout or out, or has only ins, then
stay with current implementation.
2. If there are multiple outs/inouts, then create a new structure to
consolidate these fields and emit this structure.
These two code paths are split into two separate functions for clarity.
This patch also adds a new test: multipleinout.slang to test this.
* Address review comments
* Refactor code as per review comments
* format code
* fix failing tests
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/vkray')
| -rw-r--r-- | tests/vkray/multipleinout.slang | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/vkray/multipleinout.slang b/tests/vkray/multipleinout.slang new file mode 100644 index 000000000..52e1758b0 --- /dev/null +++ b/tests/vkray/multipleinout.slang @@ -0,0 +1,36 @@ +//TEST:SIMPLE(filecheck=CHECK): -stage closesthit -entry main -target spirv -emit-spirv-directly + +// This test checks whether the spirv generated when there are multiple inout or out variables, they +// all get consolidated into one IncomingRayPayloadKHR. + +struct ReflectionRay +{ + float4 color; +}; + +StructuredBuffer<float4> colors; + +[shader("closesthit")] +void main( + BuiltInTriangleIntersectionAttributes attributes, + inout ReflectionRay ioPayload, + out float3 dummy) +{ + uint materialID = (InstanceIndex() << 1) + + InstanceID() + + PrimitiveIndex() + + HitKind(); + + ioPayload.color = colors[materialID]; + dummy = HitTriangleVertexPosition(0); +} + +// CHECK: OpEntryPoint ClosestHitKHR %main "main" %{{.*}} %{{.*}} %gl_PrimitiveID %{{.*}} %gl_InstanceID %colors %{{.*}} +// CHECK: %_struct_{{.*}} = OpTypeStruct %ReflectionRay %v3float +// CHECK: %_ptr_IncomingRayPayloadKHR__struct_{{.*}} = OpTypePointer IncomingRayPayloadKHR %_struct_{{.*}} +// CHECK: %main = OpFunction %void None %{{.*}} +// CHECK: %materialID = OpIAdd %uint %{{.*}} %{{.*}} +// CHECK: %{{.*}} = OpAccessChain %_ptr_StorageBuffer_v4float %colors %int_0 %materialID +// CHECK: %{{.*}} = OpLoad %v4float %{{.*}} +// CHECK: %{{.*}} = OpAccessChain %_ptr_Input_v3float %{{.*}} %uint_0 +// CHECK: %{{.*}} = OpLoad %v3float %{{.*}} |
