update spirv-headers and fix handling of gl_HitTEXT (#2471)
* update spirv-headers and fix handling of gl_HitTEXT
Update spirv-headers known_good to f027d53ded7e230e008d37c8b47ede7cd308e19d
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
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 4a489df..1adebef 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1006,7 +1006,17 @@
case glslang::EbvInstanceCustomIndex:
return spv::BuiltInInstanceCustomIndexKHR;
case glslang::EbvHitT:
- return spv::BuiltInHitTKHR;
+ {
+ // 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:
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index de681a8..5327f22 100644
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -395,7 +395,7 @@
case BuiltInRayGeometryIndexKHR: return "RayGeometryIndexKHR";
case BuiltInObjectToWorldKHR: return "ObjectToWorldKHR";
case BuiltInWorldToObjectKHR: return "WorldToObjectKHR";
- case BuiltInHitTKHR: return "HitTKHR";
+ case BuiltInHitTNV: return "HitTNV";
case BuiltInHitKindKHR: return "HitKindKHR";
case BuiltInIncomingRayFlagsKHR: return "IncomingRayFlagsKHR";
case BuiltInViewportMaskNV: return "ViewportMaskNV";
diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp
index a5383de..43dd2aa 100644
--- a/SPIRV/spirv.hpp
+++ b/SPIRV/spirv.hpp
@@ -614,7 +614,6 @@
BuiltInObjectToWorldNV = 5330,
BuiltInWorldToObjectKHR = 5331,
BuiltInWorldToObjectNV = 5331,
- BuiltInHitTKHR = 5332,
BuiltInHitTNV = 5332,
BuiltInHitKindKHR = 5333,
BuiltInHitKindNV = 5333,
diff --git a/Test/baseResults/spv.AnyHitShader.rahit.out b/Test/baseResults/spv.AnyHitShader.rahit.out
index f33a1bd..c893f88 100644
--- a/Test/baseResults/spv.AnyHitShader.rahit.out
+++ b/Test/baseResults/spv.AnyHitShader.rahit.out
@@ -53,7 +53,7 @@
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
- Decorate 53(gl_HitTNV) BuiltIn HitTKHR
+ Decorate 53(gl_HitTNV) BuiltIn HitTNV
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
diff --git a/Test/baseResults/spv.ClosestHitShader.rchit.out b/Test/baseResults/spv.ClosestHitShader.rchit.out
index 4a8e65d..b76629c 100644
--- a/Test/baseResults/spv.ClosestHitShader.rchit.out
+++ b/Test/baseResults/spv.ClosestHitShader.rchit.out
@@ -55,7 +55,7 @@
Decorate 42(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminNV) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxNV) BuiltIn RayTmaxKHR
- Decorate 53(gl_HitTNV) BuiltIn HitTKHR
+ Decorate 53(gl_HitTNV) BuiltIn HitTNV
Decorate 58(gl_HitKindNV) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldNV) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectNV) BuiltIn WorldToObjectKHR
diff --git a/Test/baseResults/spv.MissShader.rmiss.out b/Test/baseResults/spv.MissShader.rmiss.out
index 563e53f..e573bba 100644
--- a/Test/baseResults/spv.MissShader.rmiss.out
+++ b/Test/baseResults/spv.MissShader.rmiss.out
@@ -1,13 +1,13 @@
spv.MissShader.rmiss
// Module Version 10000
// Generated by (magic number): 8000a
-// Id's are bound by 60
+// Id's are bound by 59
Capability RayTracingNV
Extension "SPV_NV_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint MissKHR 4 "main" 11 14 21 24 27 30 35 38
+ EntryPoint MissKHR 4 "main" 11 14 21 24 29 34 37
Source GLSL 460
SourceExtension "GL_NV_ray_tracing"
Name 4 "main"
@@ -19,29 +19,26 @@
Name 21 "gl_WorldRayOriginNV"
Name 23 "v3"
Name 24 "gl_WorldRayDirectionNV"
- Name 26 "v4"
- Name 27 "gl_ObjectRayOriginNV"
- Name 29 "v5"
- Name 30 "gl_ObjectRayDirectionNV"
- Name 33 "v6"
- Name 35 "gl_RayTminNV"
- Name 37 "v7"
- Name 38 "gl_RayTmaxNV"
- Name 42 "accNV"
- Name 57 "localPayload"
- Name 59 "incomingPayload"
+ Name 27 "v4"
+ Name 29 "gl_IncomingRayFlagsNV"
+ Name 32 "v6"
+ Name 34 "gl_RayTminNV"
+ Name 36 "v7"
+ Name 37 "gl_RayTmaxNV"
+ Name 41 "accNV"
+ Name 56 "localPayload"
+ Name 58 "incomingPayload"
Decorate 11(gl_LaunchIDNV) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeNV) BuiltIn LaunchSizeKHR
Decorate 21(gl_WorldRayOriginNV) BuiltIn WorldRayOriginKHR
Decorate 24(gl_WorldRayDirectionNV) BuiltIn WorldRayDirectionKHR
- Decorate 27(gl_ObjectRayOriginNV) BuiltIn ObjectRayOriginKHR
- Decorate 30(gl_ObjectRayDirectionNV) BuiltIn ObjectRayDirectionKHR
- Decorate 35(gl_RayTminNV) BuiltIn RayTminKHR
- Decorate 38(gl_RayTmaxNV) BuiltIn RayTmaxKHR
- Decorate 42(accNV) DescriptorSet 0
- Decorate 42(accNV) Binding 0
- Decorate 57(localPayload) Location 0
- Decorate 59(incomingPayload) Location 1
+ Decorate 29(gl_IncomingRayFlagsNV) BuiltIn IncomingRayFlagsKHR
+ Decorate 34(gl_RayTminNV) BuiltIn RayTminKHR
+ Decorate 37(gl_RayTmaxNV) BuiltIn RayTmaxKHR
+ Decorate 41(accNV) DescriptorSet 0
+ Decorate 41(accNV) Binding 0
+ Decorate 56(localPayload) Location 0
+ Decorate 58(incomingPayload) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@@ -56,41 +53,41 @@
20: TypePointer Input 17(fvec3)
21(gl_WorldRayOriginNV): 20(ptr) Variable Input
24(gl_WorldRayDirectionNV): 20(ptr) Variable Input
-27(gl_ObjectRayOriginNV): 20(ptr) Variable Input
-30(gl_ObjectRayDirectionNV): 20(ptr) Variable Input
- 32: TypePointer Function 16(float)
- 34: TypePointer Input 16(float)
-35(gl_RayTminNV): 34(ptr) Variable Input
-38(gl_RayTmaxNV): 34(ptr) Variable Input
- 40: TypeAccelerationStructureKHR
- 41: TypePointer UniformConstant 40
- 42(accNV): 41(ptr) Variable UniformConstant
- 44: 6(int) Constant 0
- 45: 6(int) Constant 1
- 46: 6(int) Constant 2
- 47: 6(int) Constant 3
- 48: 16(float) Constant 1056964608
- 49: 17(fvec3) ConstantComposite 48 48 48
- 50: 16(float) Constant 1065353216
- 51: 17(fvec3) ConstantComposite 50 50 50
- 52: 16(float) Constant 1061158912
- 53: TypeInt 32 1
- 54: 53(int) Constant 1
- 55: TypeVector 16(float) 4
- 56: TypePointer RayPayloadKHR 55(fvec4)
-57(localPayload): 56(ptr) Variable RayPayloadKHR
- 58: TypePointer IncomingRayPayloadKHR 55(fvec4)
-59(incomingPayload): 58(ptr) Variable IncomingRayPayloadKHR
+ 26: TypePointer Function 6(int)
+ 28: TypePointer Input 6(int)
+29(gl_IncomingRayFlagsNV): 28(ptr) Variable Input
+ 31: TypePointer Function 16(float)
+ 33: TypePointer Input 16(float)
+34(gl_RayTminNV): 33(ptr) Variable Input
+37(gl_RayTmaxNV): 33(ptr) Variable Input
+ 39: TypeAccelerationStructureKHR
+ 40: TypePointer UniformConstant 39
+ 41(accNV): 40(ptr) Variable UniformConstant
+ 43: 6(int) Constant 0
+ 44: 6(int) Constant 1
+ 45: 6(int) Constant 2
+ 46: 6(int) Constant 3
+ 47: 16(float) Constant 1056964608
+ 48: 17(fvec3) ConstantComposite 47 47 47
+ 49: 16(float) Constant 1065353216
+ 50: 17(fvec3) ConstantComposite 49 49 49
+ 51: 16(float) Constant 1061158912
+ 52: TypeInt 32 1
+ 53: 52(int) Constant 1
+ 54: TypeVector 16(float) 4
+ 55: TypePointer RayPayloadKHR 54(fvec4)
+56(localPayload): 55(ptr) Variable RayPayloadKHR
+ 57: TypePointer IncomingRayPayloadKHR 54(fvec4)
+58(incomingPayload): 57(ptr) Variable IncomingRayPayloadKHR
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
13(v1): 8(ptr) Variable Function
19(v2): 18(ptr) Variable Function
23(v3): 18(ptr) Variable Function
- 26(v4): 18(ptr) Variable Function
- 29(v5): 18(ptr) Variable Function
- 33(v6): 32(ptr) Variable Function
- 37(v7): 32(ptr) Variable Function
+ 27(v4): 26(ptr) Variable Function
+ 32(v6): 31(ptr) Variable Function
+ 36(v7): 31(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDNV)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeNV)
@@ -99,15 +96,13 @@
Store 19(v2) 22
25: 17(fvec3) Load 24(gl_WorldRayDirectionNV)
Store 23(v3) 25
- 28: 17(fvec3) Load 27(gl_ObjectRayOriginNV)
- Store 26(v4) 28
- 31: 17(fvec3) Load 30(gl_ObjectRayDirectionNV)
- Store 29(v5) 31
- 36: 16(float) Load 35(gl_RayTminNV)
- Store 33(v6) 36
- 39: 16(float) Load 38(gl_RayTmaxNV)
- Store 37(v7) 39
- 43: 40 Load 42(accNV)
- TraceNV 43 44 45 46 47 44 49 48 51 52 54
+ 30: 6(int) Load 29(gl_IncomingRayFlagsNV)
+ Store 27(v4) 30
+ 35: 16(float) Load 34(gl_RayTminNV)
+ Store 32(v6) 35
+ 38: 16(float) Load 37(gl_RayTmaxNV)
+ Store 36(v7) 38
+ 42: 39 Load 41(accNV)
+ TraceNV 42 43 44 45 46 43 48 47 50 51 53
Return
FunctionEnd
diff --git a/Test/baseResults/spv.ext.AnyHitShader.rahit.out b/Test/baseResults/spv.ext.AnyHitShader.rahit.out
index 133fd63..7bcf812 100644
--- a/Test/baseResults/spv.ext.AnyHitShader.rahit.out
+++ b/Test/baseResults/spv.ext.AnyHitShader.rahit.out
@@ -62,7 +62,7 @@
Decorate 42(gl_ObjectRayDirectionEXT) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminEXT) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxEXT) BuiltIn RayTmaxKHR
- Decorate 53(gl_HitTEXT) BuiltIn HitTKHR
+ Decorate 53(gl_HitTEXT) BuiltIn RayTmaxKHR
Decorate 58(gl_HitKindEXT) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldEXT) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR
diff --git a/Test/baseResults/spv.ext.ClosestHitShader.rchit.out b/Test/baseResults/spv.ext.ClosestHitShader.rchit.out
index 559ba00..40903e6 100644
--- a/Test/baseResults/spv.ext.ClosestHitShader.rchit.out
+++ b/Test/baseResults/spv.ext.ClosestHitShader.rchit.out
@@ -61,7 +61,7 @@
Decorate 42(gl_ObjectRayDirectionEXT) BuiltIn ObjectRayDirectionKHR
Decorate 47(gl_RayTminEXT) BuiltIn RayTminKHR
Decorate 50(gl_RayTmaxEXT) BuiltIn RayTmaxKHR
- Decorate 53(gl_HitTEXT) BuiltIn HitTKHR
+ Decorate 53(gl_HitTEXT) BuiltIn RayTmaxKHR
Decorate 58(gl_HitKindEXT) BuiltIn HitKindKHR
Decorate 64(gl_ObjectToWorldEXT) BuiltIn ObjectToWorldKHR
Decorate 67(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR
diff --git a/Test/spv.MissShader.rmiss b/Test/spv.MissShader.rmiss
index 06113de..3c6b31c 100644
--- a/Test/spv.MissShader.rmiss
+++ b/Test/spv.MissShader.rmiss
@@ -9,8 +9,7 @@
uvec3 v1 = gl_LaunchSizeNV;
vec3 v2 = gl_WorldRayOriginNV;
vec3 v3 = gl_WorldRayDirectionNV;
- vec3 v4 = gl_ObjectRayOriginNV;
- vec3 v5 = gl_ObjectRayDirectionNV;
+ uint v4 = gl_IncomingRayFlagsNV;
float v6 = gl_RayTminNV;
float v7 = gl_RayTmaxNV;
traceNV(accNV, 0u, 1u, 2u, 3u, 0u, vec3(0.5f), 0.5f, vec3(1.0f), 0.75f, 1);
diff --git a/known_good.json b/known_good.json
index ae9c279..81301e1 100644
--- a/known_good.json
+++ b/known_good.json
@@ -12,7 +12,7 @@
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Headers",
"subdir" : "External/spirv-tools/external/spirv-headers",
- "commit" : "104ecc356c1bea4476320faca64440cd1df655a3"
+ "commit" : "f027d53ded7e230e008d37c8b47ede7cd308e19d"
}
]
}