-
Notifications
You must be signed in to change notification settings - Fork 263
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
Consolidate multiple inouts/outs into struct #6435
Changes from all commits
924e570
029ecc1
ef9a937
35c35fd
c2ce125
5694fe5
0133540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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. you can keep this line 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. and 57 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. ack |
||
// 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 %{{.*}} |
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.
Where is the synthesized struct in the entry point?
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.
@kaizhangNV The spirv code generated is like so. So it does include the entry point
OpEntryPoint ClosestHitKHR %main "main" %48 %31 %gl_PrimitiveID %25 %gl_InstanceID %colors %11
...
%11 = OpVariable %_ptr_IncomingRayPayloadKHR__struct_5 IncomingRayPayloadKHR ; Location 0
So it does cover it, but I guess this can't be added as a check condition here since the actual assembly instruction number would differ?
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.
Ah, I see.
Then it's fine, just keep it as it.