Avoid duplicate BuiltIn variables for ray tracing matrices (fix #2921)

Fixes an issue where invalid SPIR-V was generated when
gl_ObjectToWorldEXT and gl_ObjectToWorld3x4EXT, or
gl_WorldToObjectEXT and gl_WorldToObject3x4EXT, were used in the same
shader. The SPIR-V specification requires that there be at most one
OpVariable decorated with a given BuiltIn value.
This commit is contained in:
Andrea Faulds 2022-06-01 10:43:13 +02:00
parent 316f12ac1d
commit 6cdae46314
4 changed files with 142 additions and 134 deletions

View file

@ -1,7 +1,7 @@
spv.ext.IntersectShader.rint
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 86
// Id's are bound by 84
Capability RayTracingKHR
Capability RayCullMaskKHR
@ -9,7 +9,7 @@ spv.ext.IntersectShader.rint
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint IntersectionKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 56 59 65 69 75 78
EntryPoint IntersectionKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 56 59 73 76
Source GLSL 460
SourceExtension "GL_EXT_ray_cull_mask"
SourceExtension "GL_EXT_ray_tracing"
@ -41,12 +41,10 @@ spv.ext.IntersectShader.rint
Name 58 "v12"
Name 59 "gl_WorldToObjectEXT"
Name 64 "v13"
Name 65 "gl_ObjectToWorld3x4EXT"
Name 68 "v14"
Name 69 "gl_WorldToObject3x4EXT"
Name 73 "v15"
Name 75 "gl_CullMaskEXT"
Name 78 "iAttr"
Name 67 "v14"
Name 71 "v15"
Name 73 "gl_CullMaskEXT"
Name 76 "iAttr"
Decorate 11(gl_LaunchIDEXT) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeEXT) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
@ -62,9 +60,7 @@ spv.ext.IntersectShader.rint
Decorate 50(gl_RayTmaxEXT) Coherent
Decorate 56(gl_ObjectToWorldEXT) BuiltIn ObjectToWorldKHR
Decorate 59(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR
Decorate 65(gl_ObjectToWorld3x4EXT) BuiltIn ObjectToWorldKHR
Decorate 69(gl_WorldToObject3x4EXT) BuiltIn WorldToObjectKHR
Decorate 75(gl_CullMaskEXT) BuiltIn CullMaskKHR
Decorate 73(gl_CullMaskEXT) BuiltIn CullMaskKHR
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@ -99,19 +95,17 @@ spv.ext.IntersectShader.rint
61: TypeVector 28(float) 4
62: TypeMatrix 61(fvec4) 3
63: TypePointer Function 62
65(gl_ObjectToWorld3x4EXT): 55(ptr) Variable Input
69(gl_WorldToObject3x4EXT): 55(ptr) Variable Input
72: TypePointer Function 6(int)
74: TypePointer Input 6(int)
75(gl_CullMaskEXT): 74(ptr) Variable Input
77: TypePointer HitAttributeKHR 61(fvec4)
78(iAttr): 77(ptr) Variable HitAttributeKHR
79: 28(float) Constant 1056964608
80: 28(float) Constant 0
81: 28(float) Constant 1065353216
82: 61(fvec4) ConstantComposite 79 79 80 81
83: 6(int) Constant 1
84: TypeBool
70: TypePointer Function 6(int)
72: TypePointer Input 6(int)
73(gl_CullMaskEXT): 72(ptr) Variable Input
75: TypePointer HitAttributeKHR 61(fvec4)
76(iAttr): 75(ptr) Variable HitAttributeKHR
77: 28(float) Constant 1056964608
78: 28(float) Constant 0
79: 28(float) Constant 1065353216
80: 61(fvec4) ConstantComposite 77 77 78 79
81: 6(int) Constant 1
82: TypeBool
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
@ -128,8 +122,8 @@ spv.ext.IntersectShader.rint
54(v11): 53(ptr) Variable Function
58(v12): 53(ptr) Variable Function
64(v13): 63(ptr) Variable Function
68(v14): 63(ptr) Variable Function
73(v15): 72(ptr) Variable Function
67(v14): 63(ptr) Variable Function
71(v15): 70(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDEXT)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeEXT)
@ -156,15 +150,15 @@ spv.ext.IntersectShader.rint
Store 54(v11) 57
60: 52 Load 59(gl_WorldToObjectEXT)
Store 58(v12) 60
66: 52 Load 65(gl_ObjectToWorld3x4EXT)
67: 62 Transpose 66
Store 64(v13) 67
70: 52 Load 69(gl_WorldToObject3x4EXT)
71: 62 Transpose 70
Store 68(v14) 71
76: 6(int) Load 75(gl_CullMaskEXT)
Store 73(v15) 76
Store 78(iAttr) 82
85: 84(bool) ReportIntersectionKHR 79 83
65: 52 Load 56(gl_ObjectToWorldEXT)
66: 62 Transpose 65
Store 64(v13) 66
68: 52 Load 59(gl_WorldToObjectEXT)
69: 62 Transpose 68
Store 67(v14) 69
74: 6(int) Load 73(gl_CullMaskEXT)
Store 71(v15) 74
Store 76(iAttr) 80
83: 82(bool) ReportIntersectionKHR 77 81
Return
FunctionEnd