Skip to content

Commit e11a2c8

Browse files
authored
update spirv-headers and fix handling of gl_HitTEXT (KhronosGroup#2471)
* update spirv-headers and fix handling of gl_HitTEXT Update spirv-headers known_good to f027d53 and update SPIRV/spirv.hpp to copy from that version as well. In GLSL gl_HitTNV/gl_HitTEXT is defined as an alias of gl_RayTmaxNV/gl_RayTmaxEXT SPV_NV_ray_tracing has a dedicated HitTNV which gl_HitTNV maps to. For SPV_KHR_ray_tracing, gl_HitTEXT gets mapped to a RayTmaxKHR decoraged variable to simplify the SPIRV consumer. This change fixes the mapping for the GL_EXT_ray_tracing extension, and updates the test results to match. * update MissNV shader test to not use ObjectRay builtins They shouldn't existing in the miss stage because there is no object intersected
1 parent 4d41da3 commit e11a2c8

10 files changed

+73
-70
lines changed

SPIRV/GlslangToSpv.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,17 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
10061006
case glslang::EbvInstanceCustomIndex:
10071007
return spv::BuiltInInstanceCustomIndexKHR;
10081008
case glslang::EbvHitT:
1009-
return spv::BuiltInHitTKHR;
1009+
{
1010+
// this is a GLSL alias of RayTmax
1011+
// in SPV_NV_ray_tracing it has a dedicated builtin
1012+
// but in SPV_KHR_ray_tracing it gets mapped to RayTmax
1013+
auto& extensions = glslangIntermediate->getRequestedExtensions();
1014+
if (extensions.find("GL_NV_ray_tracing") != extensions.end()) {
1015+
return spv::BuiltInHitTNV;
1016+
} else {
1017+
return spv::BuiltInRayTmaxKHR;
1018+
}
1019+
}
10101020
case glslang::EbvHitKind:
10111021
return spv::BuiltInHitKindKHR;
10121022
case glslang::EbvObjectToWorld:

SPIRV/doc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ const char* BuiltInString(int builtIn)
395395
case BuiltInRayGeometryIndexKHR: return "RayGeometryIndexKHR";
396396
case BuiltInObjectToWorldKHR: return "ObjectToWorldKHR";
397397
case BuiltInWorldToObjectKHR: return "WorldToObjectKHR";
398-
case BuiltInHitTKHR: return "HitTKHR";
398+
case BuiltInHitTNV: return "HitTNV";
399399
case BuiltInHitKindKHR: return "HitKindKHR";
400400
case BuiltInIncomingRayFlagsKHR: return "IncomingRayFlagsKHR";
401401
case BuiltInViewportMaskNV: return "ViewportMaskNV";

SPIRV/spirv.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ enum BuiltIn {
614614
BuiltInObjectToWorldNV = 5330,
615615
BuiltInWorldToObjectKHR = 5331,
616616
BuiltInWorldToObjectNV = 5331,
617-
BuiltInHitTKHR = 5332,
618617
BuiltInHitTNV = 5332,
619618
BuiltInHitKindKHR = 5333,
620619
BuiltInHitKindNV = 5333,

Test/baseResults/spv.AnyHitShader.rahit.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ spv.AnyHitShader.rahit
5353
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
5454
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
5555
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
56-
Decorate 53(gl_HitTNV) BuiltIn HitTKHR
56+
Decorate 53(gl_HitTNV) BuiltIn HitTNV
5757
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
5858
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
5959
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR

Test/baseResults/spv.ClosestHitShader.rchit.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ spv.ClosestHitShader.rchit
5555
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
5656
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
5757
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
58-
Decorate 53(gl_HitTNV) BuiltIn HitTKHR
58+
Decorate 53(gl_HitTNV) BuiltIn HitTNV
5959
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
6060
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
6161
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
spv.MissShader.rmiss
22
// Module Version 10000
33
// Generated by (magic number): 8000a
4-
// Id's are bound by 60
4+
// Id's are bound by 59
55

66
Capability RayTracingNV
77
Extension "SPV_NV_ray_tracing"
88
1: ExtInstImport "GLSL.std.450"
99
MemoryModel Logical GLSL450
10-
EntryPoint MissKHR 4 "main" 11 14 21 24 27 30 35 38
10+
EntryPoint MissKHR 4 "main" 11 14 21 24 29 34 37
1111
Source GLSL 460
1212
SourceExtension "GL_NV_ray_tracing"
1313
Name 4 "main"
@@ -19,29 +19,26 @@ spv.MissShader.rmiss
1919
Name 21 "gl_WorldRayOriginNV"
2020
Name 23 "v3"
2121
Name 24 "gl_WorldRayDirectionNV"
22-
Name 26 "v4"
23-
Name 27 "gl_ObjectRayOriginNV"
24-
Name 29 "v5"
25-
Name 30 "gl_ObjectRayDirectionNV"
26-
Name 33 "v6"
27-
Name 35 "gl_RayTminNV"
28-
Name 37 "v7"
29-
Name 38 "gl_RayTmaxNV"
30-
Name 42 "accNV"
31-
Name 57 "localPayload"
32-
Name 59 "incomingPayload"
22+
Name 27 "v4"
23+
Name 29 "gl_IncomingRayFlagsNV"
24+
Name 32 "v6"
25+
Name 34 "gl_RayTminNV"
26+
Name 36 "v7"
27+
Name 37 "gl_RayTmaxNV"
28+
Name 41 "accNV"
29+
Name 56 "localPayload"
30+
Name 58 "incomingPayload"
3331
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdKHR
3432
Decorate 14(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR
3533
Decorate 21(gl_WorldRayOriginNV) BuiltIn WorldRayOriginKHR
3634
Decorate 24(gl_WorldRayDirectionNV) BuiltIn WorldRayDirectionKHR
37-
Decorate 27(gl_ObjectRayOriginNV) BuiltIn ObjectRayOriginKHR
38-
Decorate 30(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
39-
Decorate 35(gl_RayTminNV) BuiltIn RayTminKHR
40-
Decorate 38(gl_RayTmaxNV) BuiltIn RayTmaxKHR
41-
Decorate 42(accNV) DescriptorSet 0
42-
Decorate 42(accNV) Binding 0
43-
Decorate 57(localPayload) Location 0
44-
Decorate 59(incomingPayload) Location 1
35+
Decorate 29(gl_IncomingRayFlagsNV) BuiltIn IncomingRayFlagsKHR
36+
Decorate 34(gl_RayTminNV) BuiltIn RayTminKHR
37+
Decorate 37(gl_RayTmaxNV) BuiltIn RayTmaxKHR
38+
Decorate 41(accNV) DescriptorSet 0
39+
Decorate 41(accNV) Binding 0
40+
Decorate 56(localPayload) Location 0
41+
Decorate 58(incomingPayload) Location 1
4542
2: TypeVoid
4643
3: TypeFunction 2
4744
6: TypeInt 32 0
@@ -56,41 +53,41 @@ spv.MissShader.rmiss
5653
20: TypePointer Input 17(fvec3)
5754
21(gl_WorldRayOriginNV): 20(ptr) Variable Input
5855
24(gl_WorldRayDirectionNV): 20(ptr) Variable Input
59-
27(gl_ObjectRayOriginNV): 20(ptr) Variable Input
60-
30(gl_ObjectRayDirectionNV): 20(ptr) Variable Input
61-
32: TypePointer Function 16(float)
62-
34: TypePointer Input 16(float)
63-
35(gl_RayTminNV): 34(ptr) Variable Input
64-
38(gl_RayTmaxNV): 34(ptr) Variable Input
65-
40: TypeAccelerationStructureKHR
66-
41: TypePointer UniformConstant 40
67-
42(accNV): 41(ptr) Variable UniformConstant
68-
44: 6(int) Constant 0
69-
45: 6(int) Constant 1
70-
46: 6(int) Constant 2
71-
47: 6(int) Constant 3
72-
48: 16(float) Constant 1056964608
73-
49: 17(fvec3) ConstantComposite 48 48 48
74-
50: 16(float) Constant 1065353216
75-
51: 17(fvec3) ConstantComposite 50 50 50
76-
52: 16(float) Constant 1061158912
77-
53: TypeInt 32 1
78-
54: 53(int) Constant 1
79-
55: TypeVector 16(float) 4
80-
56: TypePointer RayPayloadKHR 55(fvec4)
81-
57(localPayload): 56(ptr) Variable RayPayloadKHR
82-
58: TypePointer IncomingRayPayloadKHR 55(fvec4)
83-
59(incomingPayload): 58(ptr) Variable IncomingRayPayloadKHR
56+
26: TypePointer Function 6(int)
57+
28: TypePointer Input 6(int)
58+
29(gl_IncomingRayFlagsNV): 28(ptr) Variable Input
59+
31: TypePointer Function 16(float)
60+
33: TypePointer Input 16(float)
61+
34(gl_RayTminNV): 33(ptr) Variable Input
62+
37(gl_RayTmaxNV): 33(ptr) Variable Input
63+
39: TypeAccelerationStructureKHR
64+
40: TypePointer UniformConstant 39
65+
41(accNV): 40(ptr) Variable UniformConstant
66+
43: 6(int) Constant 0
67+
44: 6(int) Constant 1
68+
45: 6(int) Constant 2
69+
46: 6(int) Constant 3
70+
47: 16(float) Constant 1056964608
71+
48: 17(fvec3) ConstantComposite 47 47 47
72+
49: 16(float) Constant 1065353216
73+
50: 17(fvec3) ConstantComposite 49 49 49
74+
51: 16(float) Constant 1061158912
75+
52: TypeInt 32 1
76+
53: 52(int) Constant 1
77+
54: TypeVector 16(float) 4
78+
55: TypePointer RayPayloadKHR 54(fvec4)
79+
56(localPayload): 55(ptr) Variable RayPayloadKHR
80+
57: TypePointer IncomingRayPayloadKHR 54(fvec4)
81+
58(incomingPayload): 57(ptr) Variable IncomingRayPayloadKHR
8482
4(main): 2 Function None 3
8583
5: Label
8684
9(v0): 8(ptr) Variable Function
8785
13(v1): 8(ptr) Variable Function
8886
19(v2): 18(ptr) Variable Function
8987
23(v3): 18(ptr) Variable Function
90-
26(v4): 18(ptr) Variable Function
91-
29(v5): 18(ptr) Variable Function
92-
33(v6): 32(ptr) Variable Function
93-
37(v7): 32(ptr) Variable Function
88+
27(v4): 26(ptr) Variable Function
89+
32(v6): 31(ptr) Variable Function
90+
36(v7): 31(ptr) Variable Function
9491
12: 7(ivec3) Load 11(gl_LaunchIDNV)
9592
Store 9(v0) 12
9693
15: 7(ivec3) Load 14(gl_LaunchSizeNV)
@@ -99,15 +96,13 @@ spv.MissShader.rmiss
9996
Store 19(v2) 22
10097
25: 17(fvec3) Load 24(gl_WorldRayDirectionNV)
10198
Store 23(v3) 25
102-
28: 17(fvec3) Load 27(gl_ObjectRayOriginNV)
103-
Store 26(v4) 28
104-
31: 17(fvec3) Load 30(gl_ObjectRayDirectionNV)
105-
Store 29(v5) 31
106-
36: 16(float) Load 35(gl_RayTminNV)
107-
Store 33(v6) 36
108-
39: 16(float) Load 38(gl_RayTmaxNV)
109-
Store 37(v7) 39
110-
43: 40 Load 42(accNV)
111-
TraceNV 43 44 45 46 47 44 49 48 51 52 54
99+
30: 6(int) Load 29(gl_IncomingRayFlagsNV)
100+
Store 27(v4) 30
101+
35: 16(float) Load 34(gl_RayTminNV)
102+
Store 32(v6) 35
103+
38: 16(float) Load 37(gl_RayTmaxNV)
104+
Store 36(v7) 38
105+
42: 39 Load 41(accNV)
106+
TraceNV 42 43 44 45 46 43 48 47 50 51 53
112107
Return
113108
FunctionEnd

Test/baseResults/spv.ext.AnyHitShader.rahit.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ spv.ext.AnyHitShader.rahit
6262
Decorate 42(gl_ObjectRayDirectionEXT) BuiltIn ObjectRayDirectionKHR
6363
Decorate 47(gl_RayTminEXT) BuiltIn RayTminKHR
6464
Decorate 50(gl_RayTmaxEXT) BuiltIn RayTmaxKHR
65-
Decorate 53(gl_HitTEXT) BuiltIn HitTKHR
65+
Decorate 53(gl_HitTEXT) BuiltIn RayTmaxKHR
6666
Decorate 58(gl_HitKindEXT) BuiltIn HitKindKHR
6767
Decorate 64(gl_ObjectToWorldEXT) BuiltIn ObjectToWorldKHR
6868
Decorate 67(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR

Test/baseResults/spv.ext.ClosestHitShader.rchit.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spv.ext.ClosestHitShader.rchit
6161
Decorate 42(gl_ObjectRayDirectionEXT) BuiltIn ObjectRayDirectionKHR
6262
Decorate 47(gl_RayTminEXT) BuiltIn RayTminKHR
6363
Decorate 50(gl_RayTmaxEXT) BuiltIn RayTmaxKHR
64-
Decorate 53(gl_HitTEXT) BuiltIn HitTKHR
64+
Decorate 53(gl_HitTEXT) BuiltIn RayTmaxKHR
6565
Decorate 58(gl_HitKindEXT) BuiltIn HitKindKHR
6666
Decorate 64(gl_ObjectToWorldEXT) BuiltIn ObjectToWorldKHR
6767
Decorate 67(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR

Test/spv.MissShader.rmiss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ void main()
99
uvec3 v1 = gl_LaunchSizeNV;
1010
vec3 v2 = gl_WorldRayOriginNV;
1111
vec3 v3 = gl_WorldRayDirectionNV;
12-
vec3 v4 = gl_ObjectRayOriginNV;
13-
vec3 v5 = gl_ObjectRayDirectionNV;
12+
uint v4 = gl_IncomingRayFlagsNV;
1413
float v6 = gl_RayTminNV;
1514
float v7 = gl_RayTmaxNV;
1615
traceNV(accNV, 0u, 1u, 2u, 3u, 0u, vec3(0.5f), 0.5f, vec3(1.0f), 0.75f, 1);

known_good.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"site" : "github",
1313
"subrepo" : "KhronosGroup/SPIRV-Headers",
1414
"subdir" : "External/spirv-tools/external/spirv-headers",
15-
"commit" : "104ecc356c1bea4476320faca64440cd1df655a3"
15+
"commit" : "f027d53ded7e230e008d37c8b47ede7cd308e19d"
1616
}
1717
]
1818
}

0 commit comments

Comments
 (0)