Skip to content

Commit

Permalink
Make gl_HitT proper aliases of gl_RayTmax
Browse files Browse the repository at this point in the history
Changes the gl_HitT builtins properly alias
their gl_RayTmax. Previously they ended up as
duplicate variables, rather than aliased.
  • Loading branch information
Max-Andersson authored and arcady-lunarg committed May 24, 2024
1 parent 7c3c50e commit 1cad045
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 327 deletions.
12 changes: 0 additions & 12 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,18 +989,6 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInHitTriangleVertexPositionsKHR;
case glslang::EbvInstanceCustomIndex:
return spv::BuiltInInstanceCustomIndexKHR;
case glslang::EbvHitT:
{
// this is a GLSL alias of RayTmax
// in SPV_NV_ray_tracing it has a dedicated builtin
// but in SPV_KHR_ray_tracing it gets mapped to RayTmax
auto& extensions = glslangIntermediate->getRequestedExtensions();
if (extensions.find("GL_NV_ray_tracing") != extensions.end()) {
return spv::BuiltInHitTNV;
} else {
return spv::BuiltInRayTmaxKHR;
}
}
case glslang::EbvHitKind:
return spv::BuiltInHitKindKHR;
case glslang::EbvObjectToWorld:
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/glsl.460.subgroup.rahit.out
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ ERROR: node is still EOpNull!
0:119 Sequence
0:119 move second child to first child ( temp float)
0:119 'v11' ( temp float)
0:119 'gl_HitTNV' ( in float HitTNV)
0:119 'gl_RayTmaxNV' ( in float ObjectRayTmaxNV)
0:120 Sequence
0:120 move second child to first child ( temp uint)
0:120 'v12' ( temp uint)
Expand Down Expand Up @@ -760,7 +760,7 @@ ERROR: node is still EOpNull!
0:119 Sequence
0:119 move second child to first child ( temp float)
0:119 'v11' ( temp float)
0:119 'gl_HitTNV' ( in float HitTNV)
0:119 'gl_RayTmaxNV' ( in float ObjectRayTmaxNV)
0:120 Sequence
0:120 move second child to first child ( temp uint)
0:120 'v12' ( temp uint)
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/glsl.460.subgroup.rchit.out
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ ERROR: node is still EOpNull!
0:121 Sequence
0:121 move second child to first child ( temp float)
0:121 'v11' ( temp float)
0:121 'gl_HitTNV' ( in float HitTNV)
0:121 'gl_RayTmaxNV' ( in float ObjectRayTmaxNV)
0:122 Sequence
0:122 move second child to first child ( temp uint)
0:122 'v12' ( temp uint)
Expand Down Expand Up @@ -771,7 +771,7 @@ ERROR: node is still EOpNull!
0:121 Sequence
0:121 move second child to first child ( temp float)
0:121 'v11' ( temp float)
0:121 'gl_HitTNV' ( in float HitTNV)
0:121 'gl_RayTmaxNV' ( in float ObjectRayTmaxNV)
0:122 Sequence
0:122 move second child to first child ( temp uint)
0:122 'v12' ( temp uint)
Expand Down
101 changes: 49 additions & 52 deletions Test/baseResults/spv.AnyHitShader.rahit.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
spv.AnyHitShader.rahit
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 81
// Id's are bound by 80

Capability RayTracingNV
Extension "SPV_NV_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint AnyHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67
EntryPoint AnyHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 57 63 66
Source GLSL 460
SourceExtension "GL_NV_ray_tracing"
Name 4 "main"
Expand All @@ -34,14 +34,13 @@ spv.AnyHitShader.rahit
Name 49 "v10"
Name 50 "gl_RayTmaxNV"
Name 52 "v11"
Name 53 "gl_HitTNV"
Name 56 "v12"
Name 58 "gl_HitKindNV"
Name 62 "v13"
Name 64 "gl_ObjectToWorldNV"
Name 66 "v14"
Name 67 "gl_WorldToObjectNV"
Name 71 "incomingPayload"
Name 55 "v12"
Name 57 "gl_HitKindNV"
Name 61 "v13"
Name 63 "gl_ObjectToWorldNV"
Name 65 "v14"
Name 66 "gl_WorldToObjectNV"
Name 70 "incomingPayload"
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
Expand All @@ -53,11 +52,10 @@ spv.AnyHitShader.rahit
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
Decorate 53(gl_HitTNV) BuiltIn HitTNV
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
Decorate 71(incomingPayload) Location 1
Decorate 57(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 63(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 66(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
Decorate 70(incomingPayload) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
Expand All @@ -84,22 +82,21 @@ spv.AnyHitShader.rahit
46: TypePointer Input 28(float)
47(gl_RayTminNV): 46(ptr) Variable Input
50(gl_RayTmaxNV): 46(ptr) Variable Input
53(gl_HitTNV): 46(ptr) Variable Input
55: TypePointer Function 6(int)
57: TypePointer Input 6(int)
58(gl_HitKindNV): 57(ptr) Variable Input
60: TypeMatrix 29(fvec3) 4
61: TypePointer Function 60
63: TypePointer Input 60
64(gl_ObjectToWorldNV): 63(ptr) Variable Input
67(gl_WorldToObjectNV): 63(ptr) Variable Input
69: TypeVector 28(float) 4
70: TypePointer IncomingRayPayloadKHR 69(fvec4)
71(incomingPayload): 70(ptr) Variable IncomingRayPayloadKHR
72: 28(float) Constant 1056964608
73: 69(fvec4) ConstantComposite 72 72 72 72
75: 16(int) Constant 1
76: TypeBool
54: TypePointer Function 6(int)
56: TypePointer Input 6(int)
57(gl_HitKindNV): 56(ptr) Variable Input
59: TypeMatrix 29(fvec3) 4
60: TypePointer Function 59
62: TypePointer Input 59
63(gl_ObjectToWorldNV): 62(ptr) Variable Input
66(gl_WorldToObjectNV): 62(ptr) Variable Input
68: TypeVector 28(float) 4
69: TypePointer IncomingRayPayloadKHR 68(fvec4)
70(incomingPayload): 69(ptr) Variable IncomingRayPayloadKHR
71: 28(float) Constant 1056964608
72: 68(fvec4) ConstantComposite 71 71 71 71
74: 16(int) Constant 1
75: TypeBool
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
Expand All @@ -114,9 +111,9 @@ spv.AnyHitShader.rahit
45(v9): 44(ptr) Variable Function
49(v10): 44(ptr) Variable Function
52(v11): 44(ptr) Variable Function
56(v12): 55(ptr) Variable Function
62(v13): 61(ptr) Variable Function
66(v14): 61(ptr) Variable Function
55(v12): 54(ptr) Variable Function
61(v13): 60(ptr) Variable Function
65(v14): 60(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDNV)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeNV)
Expand All @@ -139,25 +136,25 @@ spv.AnyHitShader.rahit
Store 45(v9) 48
51: 28(float) Load 50(gl_RayTmaxNV)
Store 49(v10) 51
54: 28(float) Load 53(gl_HitTNV)
Store 52(v11) 54
59: 6(int) Load 58(gl_HitKindNV)
Store 56(v12) 59
65: 60 Load 64(gl_ObjectToWorldNV)
Store 62(v13) 65
68: 60 Load 67(gl_WorldToObjectNV)
Store 66(v14) 68
Store 71(incomingPayload) 73
74: 16(int) Load 18(v2)
77: 76(bool) IEqual 74 75
SelectionMerge 79 None
BranchConditional 77 78 80
78: Label
53: 28(float) Load 50(gl_RayTmaxNV)
Store 52(v11) 53
58: 6(int) Load 57(gl_HitKindNV)
Store 55(v12) 58
64: 59 Load 63(gl_ObjectToWorldNV)
Store 61(v13) 64
67: 59 Load 66(gl_WorldToObjectNV)
Store 65(v14) 67
Store 70(incomingPayload) 72
73: 16(int) Load 18(v2)
76: 75(bool) IEqual 73 74
SelectionMerge 78 None
BranchConditional 76 77 79
77: Label
IgnoreIntersectionNV
Branch 79
80: Label
Branch 78
79: Label
TerminateRayNV
Branch 79
79: Label
Branch 78
78: Label
Return
FunctionEnd
117 changes: 57 additions & 60 deletions Test/baseResults/spv.ClosestHitShader.rchit.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
spv.ClosestHitShader.rchit
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 88
// Id's are bound by 87

Capability RayTracingNV
Extension "SPV_NV_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint ClosestHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67
EntryPoint ClosestHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 57 63 66
Source GLSL 460
SourceExtension "GL_NV_ray_tracing"
Name 4 "main"
Expand All @@ -34,16 +34,15 @@ spv.ClosestHitShader.rchit
Name 49 "v10"
Name 50 "gl_RayTmaxNV"
Name 52 "v11"
Name 53 "gl_HitTNV"
Name 56 "v12"
Name 58 "gl_HitKindNV"
Name 62 "v13"
Name 64 "gl_ObjectToWorldNV"
Name 66 "v14"
Name 67 "gl_WorldToObjectNV"
Name 71 "accNV"
Name 85 "localPayload"
Name 87 "incomingPayload"
Name 55 "v12"
Name 57 "gl_HitKindNV"
Name 61 "v13"
Name 63 "gl_ObjectToWorldNV"
Name 65 "v14"
Name 66 "gl_WorldToObjectNV"
Name 70 "accNV"
Name 84 "localPayload"
Name 86 "incomingPayload"
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
Expand All @@ -55,14 +54,13 @@ spv.ClosestHitShader.rchit
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
Decorate 53(gl_HitTNV) BuiltIn HitTNV
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
Decorate 71(accNV) DescriptorSet 0
Decorate 71(accNV) Binding 0
Decorate 85(localPayload) Location 0
Decorate 87(incomingPayload) Location 1
Decorate 57(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 63(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 66(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
Decorate 70(accNV) DescriptorSet 0
Decorate 70(accNV) Binding 0
Decorate 84(localPayload) Location 0
Decorate 86(incomingPayload) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
Expand All @@ -89,33 +87,32 @@ spv.ClosestHitShader.rchit
46: TypePointer Input 28(float)
47(gl_RayTminNV): 46(ptr) Variable Input
50(gl_RayTmaxNV): 46(ptr) Variable Input
53(gl_HitTNV): 46(ptr) Variable Input
55: TypePointer Function 6(int)
57: TypePointer Input 6(int)
58(gl_HitKindNV): 57(ptr) Variable Input
60: TypeMatrix 29(fvec3) 4
61: TypePointer Function 60
63: TypePointer Input 60
64(gl_ObjectToWorldNV): 63(ptr) Variable Input
67(gl_WorldToObjectNV): 63(ptr) Variable Input
69: TypeAccelerationStructureKHR
70: TypePointer UniformConstant 69
71(accNV): 70(ptr) Variable UniformConstant
73: 6(int) Constant 0
74: 6(int) Constant 1
75: 6(int) Constant 2
76: 6(int) Constant 3
77: 28(float) Constant 1056964608
78: 29(fvec3) ConstantComposite 77 77 77
79: 28(float) Constant 1065353216
80: 29(fvec3) ConstantComposite 79 79 79
81: 28(float) Constant 1061158912
82: 16(int) Constant 1
83: TypeVector 28(float) 4
84: TypePointer RayPayloadKHR 83(fvec4)
85(localPayload): 84(ptr) Variable RayPayloadKHR
86: TypePointer IncomingRayPayloadKHR 83(fvec4)
87(incomingPayload): 86(ptr) Variable IncomingRayPayloadKHR
54: TypePointer Function 6(int)
56: TypePointer Input 6(int)
57(gl_HitKindNV): 56(ptr) Variable Input
59: TypeMatrix 29(fvec3) 4
60: TypePointer Function 59
62: TypePointer Input 59
63(gl_ObjectToWorldNV): 62(ptr) Variable Input
66(gl_WorldToObjectNV): 62(ptr) Variable Input
68: TypeAccelerationStructureKHR
69: TypePointer UniformConstant 68
70(accNV): 69(ptr) Variable UniformConstant
72: 6(int) Constant 0
73: 6(int) Constant 1
74: 6(int) Constant 2
75: 6(int) Constant 3
76: 28(float) Constant 1056964608
77: 29(fvec3) ConstantComposite 76 76 76
78: 28(float) Constant 1065353216
79: 29(fvec3) ConstantComposite 78 78 78
80: 28(float) Constant 1061158912
81: 16(int) Constant 1
82: TypeVector 28(float) 4
83: TypePointer RayPayloadKHR 82(fvec4)
84(localPayload): 83(ptr) Variable RayPayloadKHR
85: TypePointer IncomingRayPayloadKHR 82(fvec4)
86(incomingPayload): 85(ptr) Variable IncomingRayPayloadKHR
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
Expand All @@ -130,9 +127,9 @@ spv.ClosestHitShader.rchit
45(v9): 44(ptr) Variable Function
49(v10): 44(ptr) Variable Function
52(v11): 44(ptr) Variable Function
56(v12): 55(ptr) Variable Function
62(v13): 61(ptr) Variable Function
66(v14): 61(ptr) Variable Function
55(v12): 54(ptr) Variable Function
61(v13): 60(ptr) Variable Function
65(v14): 60(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDNV)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeNV)
Expand All @@ -155,15 +152,15 @@ spv.ClosestHitShader.rchit
Store 45(v9) 48
51: 28(float) Load 50(gl_RayTmaxNV)
Store 49(v10) 51
54: 28(float) Load 53(gl_HitTNV)
Store 52(v11) 54
59: 6(int) Load 58(gl_HitKindNV)
Store 56(v12) 59
65: 60 Load 64(gl_ObjectToWorldNV)
Store 62(v13) 65
68: 60 Load 67(gl_WorldToObjectNV)
Store 66(v14) 68
72: 69 Load 71(accNV)
TraceNV 72 73 74 75 76 73 78 77 80 81 82
53: 28(float) Load 50(gl_RayTmaxNV)
Store 52(v11) 53
58: 6(int) Load 57(gl_HitKindNV)
Store 55(v12) 58
64: 59 Load 63(gl_ObjectToWorldNV)
Store 61(v13) 64
67: 59 Load 66(gl_WorldToObjectNV)
Store 65(v14) 67
71: 68 Load 70(accNV)
TraceNV 71 72 73 74 75 72 77 76 79 80 81
Return
FunctionEnd
Loading

0 comments on commit 1cad045

Please sign in to comment.