Skip to content

Commit

Permalink
Adding support for GL_EXT_ray_cull_mask
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbjorge committed May 5, 2022
1 parent e3bca2a commit 3015d00
Show file tree
Hide file tree
Showing 15 changed files with 231 additions and 156 deletions.
9 changes: 9 additions & 0 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInRayTminKHR;
case glslang::EbvRayTmax:
return spv::BuiltInRayTmaxKHR;
case glslang::EbvCullMask:
return spv::BuiltInCullMaskKHR;
case glslang::EbvInstanceCustomIndex:
return spv::BuiltInInstanceCustomIndexKHR;
case glslang::EbvHitT:
Expand Down Expand Up @@ -1777,6 +1779,13 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
builder.addCapability(spv::CapabilityRayTracingNV);
builder.addExtension("SPV_NV_ray_tracing");
}
if (glslangIntermediate->getStage() != EShLangRayGen && glslangIntermediate->getStage() != EShLangCallable)
{
if (extensions.find("GL_EXT_ray_cull_mask") != extensions.end()) {
builder.addCapability(spv::CapabilityRayCullMaskKHR);
builder.addExtension("SPV_KHR_ray_cull_mask");
}
}
break;
}
case EShLangTaskNV:
Expand Down
2 changes: 2 additions & 0 deletions SPIRV/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ const char* BuiltInString(int builtIn)
case BuiltInObjectRayDirectionKHR: return "ObjectRayDirectionKHR";
case BuiltInRayTminKHR: return "RayTminKHR";
case BuiltInRayTmaxKHR: return "RayTmaxKHR";
case BuiltInCullMaskKHR: return "CullMaskKHR";
case BuiltInInstanceCustomIndexKHR: return "InstanceCustomIndexKHR";
case BuiltInRayGeometryIndexKHR: return "RayGeometryIndexKHR";
case BuiltInObjectToWorldKHR: return "ObjectToWorldKHR";
Expand Down Expand Up @@ -925,6 +926,7 @@ const char* CapabilityString(int info)
case CapabilityRayTracingNV: return "RayTracingNV";
case CapabilityRayTracingMotionBlurNV: return "RayTracingMotionBlurNV";
case CapabilityRayTracingKHR: return "RayTracingKHR";
case CapabilityRayCullMaskKHR: return "RayCullMaskKHR";
case CapabilityRayQueryKHR: return "RayQueryKHR";
case CapabilityRayTracingProvisionalKHR: return "RayTracingProvisionalKHR";
case CapabilityRayTraversalPrimitiveCullingKHR: return "RayTraversalPrimitiveCullingKHR";
Expand Down
2 changes: 2 additions & 0 deletions SPIRV/spirv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ enum BuiltIn {
BuiltInSMCountNV = 5375,
BuiltInWarpIDNV = 5376,
BuiltInSMIDNV = 5377,
BuiltInCullMaskKHR = 6021,
BuiltInMax = 0x7fffffff,
};

Expand Down Expand Up @@ -1069,6 +1070,7 @@ enum Capability {
CapabilityDotProductInput4x8BitPackedKHR = 6018,
CapabilityDotProduct = 6019,
CapabilityDotProductKHR = 6019,
CapabilityRayCullMaskKHR = 6020,
CapabilityBitInstructions = 6025,
CapabilityAtomicFloat32AddEXT = 6033,
CapabilityAtomicFloat64AddEXT = 6034,
Expand Down
72 changes: 41 additions & 31 deletions Test/baseResults/spv.ext.AnyHitShader.rahit.out
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
spv.ext.AnyHitShader.rahit
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 107
// Id's are bound by 110

Capability GroupNonUniform
Capability RayTracingKHR
Capability RayCullMaskKHR
Extension "SPV_KHR_ray_cull_mask"
Extension "SPV_KHR_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 70 76 80 84 98
EntryPoint AnyHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80 84 87 101
Source GLSL 460
SourceExtension "GL_EXT_ray_cull_mask"
SourceExtension "GL_EXT_ray_tracing"
SourceExtension "GL_KHR_shader_subgroup_basic"
Name 4 "main"
Expand Down Expand Up @@ -49,8 +52,10 @@ spv.ext.AnyHitShader.rahit
Name 76 "gl_ObjectToWorld3x4EXT"
Name 79 "v17"
Name 80 "gl_WorldToObject3x4EXT"
Name 84 "incomingPayload"
Name 98 "gl_SubgroupSize"
Name 83 "v18"
Name 84 "gl_CullMaskEXT"
Name 87 "incomingPayload"
Name 101 "gl_SubgroupSize"
Decorate 11(gl_LaunchIDEXT) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeEXT) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
Expand All @@ -69,10 +74,11 @@ spv.ext.AnyHitShader.rahit
Decorate 70(gl_GeometryIndexEXT) BuiltIn RayGeometryIndexKHR
Decorate 76(gl_ObjectToWorld3x4EXT) BuiltIn ObjectToWorldKHR
Decorate 80(gl_WorldToObject3x4EXT) BuiltIn WorldToObjectKHR
Decorate 98(gl_SubgroupSize) RelaxedPrecision
Decorate 98(gl_SubgroupSize) BuiltIn SubgroupSize
Decorate 99 RelaxedPrecision
Decorate 100 RelaxedPrecision
Decorate 84(gl_CullMaskEXT) BuiltIn CullMaskKHR
Decorate 101(gl_SubgroupSize) RelaxedPrecision
Decorate 101(gl_SubgroupSize) BuiltIn SubgroupSize
Decorate 102 RelaxedPrecision
Decorate 103 RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
Expand Down Expand Up @@ -114,15 +120,16 @@ spv.ext.AnyHitShader.rahit
74: TypePointer Function 73
76(gl_ObjectToWorld3x4EXT): 63(ptr) Variable Input
80(gl_WorldToObject3x4EXT): 63(ptr) Variable Input
83: TypePointer IncomingRayPayloadKHR 72(fvec4)
84(incomingPayload): 83(ptr) Variable IncomingRayPayloadKHR
85: 28(float) Constant 1056964608
86: 72(fvec4) ConstantComposite 85 85 85 85
88: 16(int) Constant 1
89: TypeBool
94: 6(int) Constant 0
98(gl_SubgroupSize): 57(ptr) Variable Input
101: TypePointer IncomingRayPayloadKHR 28(float)
84(gl_CullMaskEXT): 57(ptr) Variable Input
86: TypePointer IncomingRayPayloadKHR 72(fvec4)
87(incomingPayload): 86(ptr) Variable IncomingRayPayloadKHR
88: 28(float) Constant 1056964608
89: 72(fvec4) ConstantComposite 88 88 88 88
91: 16(int) Constant 1
92: TypeBool
97: 6(int) Constant 0
101(gl_SubgroupSize): 57(ptr) Variable Input
104: TypePointer IncomingRayPayloadKHR 28(float)
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
Expand All @@ -143,6 +150,7 @@ spv.ext.AnyHitShader.rahit
69(v15): 17(ptr) Variable Function
75(v16): 74(ptr) Variable Function
79(v17): 74(ptr) Variable Function
83(v18): 55(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDEXT)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeEXT)
Expand Down Expand Up @@ -181,20 +189,22 @@ spv.ext.AnyHitShader.rahit
81: 60 Load 80(gl_WorldToObject3x4EXT)
82: 73 Transpose 81
Store 79(v17) 82
Store 84(incomingPayload) 86
87: 16(int) Load 18(v2)
90: 89(bool) IEqual 87 88
SelectionMerge 92 None
BranchConditional 90 91 92
91: Label
85: 6(int) Load 84(gl_CullMaskEXT)
Store 83(v18) 85
Store 87(incomingPayload) 89
90: 16(int) Load 18(v2)
93: 92(bool) IEqual 90 91
SelectionMerge 95 None
BranchConditional 93 94 95
94: Label
IgnoreIntersectionKHR
92: Label
99: 6(int) Load 98(gl_SubgroupSize)
100: 28(float) ConvertUToF 99
102: 101(ptr) AccessChain 84(incomingPayload) 94
103: 28(float) Load 102
104: 28(float) FAdd 103 100
105: 101(ptr) AccessChain 84(incomingPayload) 94
Store 105 104
95: Label
102: 6(int) Load 101(gl_SubgroupSize)
103: 28(float) ConvertUToF 102
105: 104(ptr) AccessChain 87(incomingPayload) 97
106: 28(float) Load 105
107: 28(float) FAdd 106 103
108: 104(ptr) AccessChain 87(incomingPayload) 97
Store 108 107
TerminateRayKHR
FunctionEnd
62 changes: 36 additions & 26 deletions Test/baseResults/spv.ext.ClosestHitShader.rchit.out
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
spv.ext.ClosestHitShader.rchit
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 101
// Id's are bound by 104

Capability RayTracingKHR
Capability RayCullMaskKHR
Extension "SPV_KHR_ray_cull_mask"
Extension "SPV_KHR_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 70 76 80 85 98 100
EntryPoint ClosestHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80 84 88 101 103
Source GLSL 460
SourceExtension "GL_EXT_ray_cull_mask"
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"
Name 9 "v0"
Expand Down Expand Up @@ -47,9 +50,11 @@ spv.ext.ClosestHitShader.rchit
Name 76 "gl_ObjectToWorld3x4EXT"
Name 79 "v17"
Name 80 "gl_WorldToObject3x4EXT"
Name 85 "accEXT"
Name 98 "incomingPayload"
Name 100 "localPayload"
Name 83 "v18"
Name 84 "gl_CullMaskEXT"
Name 88 "accEXT"
Name 101 "incomingPayload"
Name 103 "localPayload"
Decorate 11(gl_LaunchIDEXT) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeEXT) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
Expand All @@ -68,8 +73,9 @@ spv.ext.ClosestHitShader.rchit
Decorate 70(gl_GeometryIndexEXT) BuiltIn RayGeometryIndexKHR
Decorate 76(gl_ObjectToWorld3x4EXT) BuiltIn ObjectToWorldKHR
Decorate 80(gl_WorldToObject3x4EXT) BuiltIn WorldToObjectKHR
Decorate 85(accEXT) DescriptorSet 0
Decorate 85(accEXT) Binding 0
Decorate 84(gl_CullMaskEXT) BuiltIn CullMaskKHR
Decorate 88(accEXT) DescriptorSet 0
Decorate 88(accEXT) Binding 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
Expand Down Expand Up @@ -111,23 +117,24 @@ spv.ext.ClosestHitShader.rchit
74: TypePointer Function 73
76(gl_ObjectToWorld3x4EXT): 63(ptr) Variable Input
80(gl_WorldToObject3x4EXT): 63(ptr) Variable Input
83: TypeAccelerationStructureKHR
84: TypePointer UniformConstant 83
85(accEXT): 84(ptr) Variable UniformConstant
87: 6(int) Constant 0
88: 6(int) Constant 1
89: 6(int) Constant 2
90: 6(int) Constant 3
91: 28(float) Constant 1056964608
92: 29(fvec3) ConstantComposite 91 91 91
93: 28(float) Constant 1065353216
94: 29(fvec3) ConstantComposite 93 93 93
95: 28(float) Constant 1061158912
96: 16(int) Constant 1
97: TypePointer IncomingRayPayloadKHR 72(fvec4)
98(incomingPayload): 97(ptr) Variable IncomingRayPayloadKHR
99: TypePointer RayPayloadKHR 72(fvec4)
100(localPayload): 99(ptr) Variable RayPayloadKHR
84(gl_CullMaskEXT): 57(ptr) Variable Input
86: TypeAccelerationStructureKHR
87: TypePointer UniformConstant 86
88(accEXT): 87(ptr) Variable UniformConstant
90: 6(int) Constant 0
91: 6(int) Constant 1
92: 6(int) Constant 2
93: 6(int) Constant 3
94: 28(float) Constant 1056964608
95: 29(fvec3) ConstantComposite 94 94 94
96: 28(float) Constant 1065353216
97: 29(fvec3) ConstantComposite 96 96 96
98: 28(float) Constant 1061158912
99: 16(int) Constant 1
100: TypePointer IncomingRayPayloadKHR 72(fvec4)
101(incomingPayload): 100(ptr) Variable IncomingRayPayloadKHR
102: TypePointer RayPayloadKHR 72(fvec4)
103(localPayload): 102(ptr) Variable RayPayloadKHR
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
Expand All @@ -148,6 +155,7 @@ spv.ext.ClosestHitShader.rchit
69(v15): 17(ptr) Variable Function
75(v16): 74(ptr) Variable Function
79(v17): 74(ptr) Variable Function
83(v18): 55(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDEXT)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeEXT)
Expand Down Expand Up @@ -186,7 +194,9 @@ spv.ext.ClosestHitShader.rchit
81: 60 Load 80(gl_WorldToObject3x4EXT)
82: 73 Transpose 81
Store 79(v17) 82
86: 83 Load 85(accEXT)
TraceRayKHR 86 87 88 89 90 87 92 91 94 95 98(incomingPayload)
85: 6(int) Load 84(gl_CullMaskEXT)
Store 83(v18) 85
89: 86 Load 88(accEXT)
TraceRayKHR 89 90 91 92 93 90 95 94 97 98 101(incomingPayload)
Return
FunctionEnd
38 changes: 25 additions & 13 deletions Test/baseResults/spv.ext.IntersectShader.rint.out
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
spv.ext.IntersectShader.rint
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 81
// Id's are bound by 86

Capability RayTracingKHR
Capability RayCullMaskKHR
Extension "SPV_KHR_ray_cull_mask"
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 73
EntryPoint IntersectionKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 56 59 65 69 75 78
Source GLSL 460
SourceExtension "GL_EXT_ray_cull_mask"
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"
Name 9 "v0"
Expand Down Expand Up @@ -41,7 +44,9 @@ spv.ext.IntersectShader.rint
Name 65 "gl_ObjectToWorld3x4EXT"
Name 68 "v14"
Name 69 "gl_WorldToObject3x4EXT"
Name 73 "iAttr"
Name 73 "v15"
Name 75 "gl_CullMaskEXT"
Name 78 "iAttr"
Decorate 11(gl_LaunchIDEXT) BuiltIn LaunchIdKHR
Decorate 14(gl_LaunchSizeEXT) BuiltIn LaunchSizeKHR
Decorate 20(gl_PrimitiveID) BuiltIn PrimitiveId
Expand All @@ -59,6 +64,7 @@ spv.ext.IntersectShader.rint
Decorate 59(gl_WorldToObjectEXT) BuiltIn WorldToObjectKHR
Decorate 65(gl_ObjectToWorld3x4EXT) BuiltIn ObjectToWorldKHR
Decorate 69(gl_WorldToObject3x4EXT) BuiltIn WorldToObjectKHR
Decorate 75(gl_CullMaskEXT) BuiltIn CullMaskKHR
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
Expand Down Expand Up @@ -95,14 +101,17 @@ spv.ext.IntersectShader.rint
63: TypePointer Function 62
65(gl_ObjectToWorld3x4EXT): 55(ptr) Variable Input
69(gl_WorldToObject3x4EXT): 55(ptr) Variable Input
72: TypePointer HitAttributeKHR 61(fvec4)
73(iAttr): 72(ptr) Variable HitAttributeKHR
74: 28(float) Constant 1056964608
75: 28(float) Constant 0
76: 28(float) Constant 1065353216
77: 61(fvec4) ConstantComposite 74 74 75 76
78: 6(int) Constant 1
79: TypeBool
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
4(main): 2 Function None 3
5: Label
9(v0): 8(ptr) Variable Function
Expand All @@ -120,6 +129,7 @@ spv.ext.IntersectShader.rint
58(v12): 53(ptr) Variable Function
64(v13): 63(ptr) Variable Function
68(v14): 63(ptr) Variable Function
73(v15): 72(ptr) Variable Function
12: 7(ivec3) Load 11(gl_LaunchIDEXT)
Store 9(v0) 12
15: 7(ivec3) Load 14(gl_LaunchSizeEXT)
Expand Down Expand Up @@ -152,7 +162,9 @@ spv.ext.IntersectShader.rint
70: 52 Load 69(gl_WorldToObject3x4EXT)
71: 62 Transpose 70
Store 68(v14) 71
Store 73(iAttr) 77
80: 79(bool) ReportIntersectionKHR 74 78
76: 6(int) Load 75(gl_CullMaskEXT)
Store 73(v15) 76
Store 78(iAttr) 82
85: 84(bool) ReportIntersectionKHR 79 83
Return
FunctionEnd
Loading

0 comments on commit 3015d00

Please sign in to comment.