From 2fb45def04e65871f78b212c2080b08d4ca39478 Mon Sep 17 00:00:00 2001 From: Neslisah Torosdagli Date: Mon, 23 Mar 2020 21:34:09 -0400 Subject: [PATCH] rayQuery test cases added --- .../rayQuery-allOps.Error.rgen.out | 26 ++ Test/baseResults/rayQuery-allOps.comp.out | 438 ++++++++++++++++++ Test/baseResults/rayQuery-allOps.frag.out | 438 ++++++++++++++++++ .../rayQuery-committed.Error.rgen.out | 19 + Test/rayQuery-allOps.Error.rgen | 212 +++++++++ Test/rayQuery-allOps.comp | 212 +++++++++ Test/rayQuery-allOps.frag | 212 +++++++++ Test/rayQuery-committed.Error.rgen | 105 +++++ gtests/Spv.FromFile.cpp | 17 +- 9 files changed, 1672 insertions(+), 7 deletions(-) create mode 100644 Test/baseResults/rayQuery-allOps.Error.rgen.out create mode 100644 Test/baseResults/rayQuery-allOps.comp.out create mode 100644 Test/baseResults/rayQuery-allOps.frag.out create mode 100644 Test/baseResults/rayQuery-committed.Error.rgen.out create mode 100644 Test/rayQuery-allOps.Error.rgen create mode 100644 Test/rayQuery-allOps.comp create mode 100644 Test/rayQuery-allOps.frag create mode 100644 Test/rayQuery-committed.Error.rgen diff --git a/Test/baseResults/rayQuery-allOps.Error.rgen.out b/Test/baseResults/rayQuery-allOps.Error.rgen.out new file mode 100644 index 00000000..98101c32 --- /dev/null +++ b/Test/baseResults/rayQuery-allOps.Error.rgen.out @@ -0,0 +1,26 @@ +rayQuery-allOps.Error.rgen +ERROR: 0:47: '==' : wrong operand types: no operation '==' exists that takes a left-hand operand of type ' global bool' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:49: '=' : cannot convert from ' global uint' to ' temp highp int' +ERROR: 0:59: '==' : wrong operand types: no operation '==' exists that takes a left-hand operand of type ' global bool' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:64: '==' : wrong operand types: no operation '==' exists that takes a left-hand operand of type ' global 2-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:69: '' : boolean expression expected +ERROR: 0:74: '' : boolean expression expected +ERROR: 0:79: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type ' global 3-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:84: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type ' global 3-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:89: '' : boolean expression expected +ERROR: 0:94: '' : boolean expression expected +ERROR: 0:99: '' : boolean expression expected +ERROR: 0:127: '=' : cannot convert from ' global uint' to ' temp highp int' +ERROR: 0:145: '==' : wrong operand types: no operation '==' exists that takes a left-hand operand of type ' global 2-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:158: '' : boolean expression expected +ERROR: 0:163: '' : boolean expression expected +ERROR: 0:168: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type ' global 3-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:173: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type ' global 3-component vector of float' and a right operand of type ' const int' (or there is no acceptable conversion) +ERROR: 0:178: '' : boolean expression expected +ERROR: 0:183: '' : boolean expression expected +ERROR: 0:195: '' : boolean expression expected +ERROR: 0:200: '' : boolean expression expected +ERROR: 21 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/rayQuery-allOps.comp.out b/Test/baseResults/rayQuery-allOps.comp.out new file mode 100644 index 00000000..d1301226 --- /dev/null +++ b/Test/baseResults/rayQuery-allOps.comp.out @@ -0,0 +1,438 @@ +rayQuery-allOps.comp +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 265 + + Capability Shader + Capability RayQueryProvisionalKHR + Extension "SPV_KHR_ray_query" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 1 1 1 + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 6 "doSomething(" + Name 10 "Ray" + MemberName 10(Ray) 0 "pos" + MemberName 10(Ray) 1 "tmin" + MemberName 10(Ray) 2 "dir" + MemberName 10(Ray) 3 "tmax" + Name 12 "makeRayDesc(" + Name 15 "Log" + MemberName 15(Log) 0 "x" + MemberName 15(Log) 1 "y" + Name 17 "" + Name 26 "ray" + Name 45 "rayQuery" + Name 48 "rtas" + Name 51 "ray" + Name 69 "candidateType" + Name 79 "_mat4x3" + Name 84 "_mat3x4" + Name 146 "t" + Name 160 "committedStatus" + Name 246 "o" + Name 249 "d" + Name 260 "Ray" + MemberName 260(Ray) 0 "pos" + MemberName 260(Ray) 1 "tmin" + MemberName 260(Ray) 2 "dir" + MemberName 260(Ray) 3 "tmax" + Name 262 "Rays" + MemberName 262(Rays) 0 "rays" + Name 264 "" + MemberDecorate 15(Log) 0 Offset 0 + MemberDecorate 15(Log) 1 Offset 4 + Decorate 15(Log) BufferBlock + Decorate 17 DescriptorSet 0 + Decorate 17 Binding 0 + Decorate 48(rtas) DescriptorSet 0 + Decorate 48(rtas) Binding 1 + MemberDecorate 260(Ray) 0 Offset 0 + MemberDecorate 260(Ray) 1 Offset 12 + MemberDecorate 260(Ray) 2 Offset 16 + MemberDecorate 260(Ray) 3 Offset 28 + Decorate 261 ArrayStride 32 + MemberDecorate 262(Rays) 0 Offset 0 + Decorate 262(Rays) BufferBlock + Decorate 264 DescriptorSet 0 + Decorate 264 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 8: TypeFloat 32 + 9: TypeVector 8(float) 3 + 10(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 11: TypeFunction 10(Ray) + 14: TypeInt 32 0 + 15(Log): TypeStruct 14(int) 14(int) + 16: TypePointer Uniform 15(Log) + 17: 16(ptr) Variable Uniform + 18: TypeInt 32 1 + 19: 18(int) Constant 0 + 20: 14(int) Constant 0 + 21: TypePointer Uniform 14(int) + 23: 18(int) Constant 1 + 25: TypePointer Function 10(Ray) + 27: 8(float) Constant 0 + 28: 9(fvec3) ConstantComposite 27 27 27 + 29: TypePointer Function 9(fvec3) + 31: 18(int) Constant 2 + 32: 8(float) Constant 1065353216 + 33: 9(fvec3) ConstantComposite 32 27 27 + 35: TypePointer Function 8(float) + 37: 18(int) Constant 3 + 38: 8(float) Constant 1176255488 + 43: TypeRayQueryProvisionalKHR + 44: TypePointer Function 43 + 46: TypeAccelerationStructureKHR + 47: TypePointer UniformConstant 46 + 48(rtas): 47(ptr) Variable UniformConstant + 50: 14(int) Constant 255 + 66: TypeBool + 68: TypePointer Function 14(int) + 70: 66(bool) ConstantFalse + 77: TypeMatrix 9(fvec3) 4 + 78: TypePointer Function 77 + 81: TypeVector 8(float) 4 + 82: TypeMatrix 81(fvec4) 3 + 83: TypePointer Function 82 + 88: 66(bool) ConstantTrue + 93: TypeVector 8(float) 2 + 147: 8(float) Constant 1056964608 + 179: 14(int) Constant 1 + 202: 14(int) Constant 2 + 260(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 261: TypeRuntimeArray 260(Ray) + 262(Rays): TypeStruct 261 + 263: TypePointer Uniform 262(Rays) + 264: 263(ptr) Variable Uniform + 4(main): 2 Function None 3 + 5: Label + 45(rayQuery): 44(ptr) Variable Function + 51(ray): 25(ptr) Variable Function +69(candidateType): 68(ptr) Variable Function + 79(_mat4x3): 78(ptr) Variable Function + 84(_mat3x4): 83(ptr) Variable Function + 146(t): 35(ptr) Variable Function +160(committedStatus): 68(ptr) Variable Function + 246(o): 29(ptr) Variable Function + 249(d): 29(ptr) Variable Function + 49: 46 Load 48(rtas) + 52: 29(ptr) AccessChain 51(ray) 19 + 53: 9(fvec3) Load 52 + 54: 35(ptr) AccessChain 51(ray) 23 + 55: 8(float) Load 54 + 56: 29(ptr) AccessChain 51(ray) 31 + 57: 9(fvec3) Load 56 + 58: 35(ptr) AccessChain 51(ray) 37 + 59: 8(float) Load 58 + RayQueryInitializeKHR 45(rayQuery) 49 20 50 53 55 57 59 + Branch 60 + 60: Label + LoopMerge 62 63 None + Branch 64 + 64: Label + 65: 43 Load 45(rayQuery) + 67: 66(bool) RayQueryProceedKHR 65 + BranchConditional 67 61 62 + 61: Label + 71: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 19 + Store 69(candidateType) 71 + 72: 14(int) Load 69(candidateType) + SelectionMerge 75 None + Switch 72 75 + case 0: 73 + case 1: 74 + 73: Label + 76: 43 Load 45(rayQuery) + RayQueryTerminateKHR 76 + 80: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 80 + 85: 77 Load 79(_mat4x3) + 86: 82 Transpose 85 + Store 84(_mat3x4) 86 + 87: 43 Load 45(rayQuery) + RayQueryConfirmIntersectionKHR 87 + 89: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 91 None + BranchConditional 89 90 91 + 90: Label + 92: 2 FunctionCall 6(doSomething() + Branch 91 + 91: Label + 94: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 95: 8(float) CompositeExtract 94 0 + 96: 66(bool) FOrdEqual 95 27 + SelectionMerge 98 None + BranchConditional 96 97 98 + 97: Label + 99: 2 FunctionCall 6(doSomething() + Branch 98 + 98: Label + 100: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 101: 66(bool) SGreaterThan 100 19 + SelectionMerge 103 None + BranchConditional 101 102 103 + 102: Label + 104: 2 FunctionCall 6(doSomething() + Branch 103 + 103: Label + 105: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 106: 66(bool) SGreaterThan 105 19 + SelectionMerge 108 None + BranchConditional 106 107 108 + 107: Label + 109: 2 FunctionCall 6(doSomething() + Branch 108 + 108: Label + 110: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 111: 8(float) CompositeExtract 110 0 + 112: 66(bool) FOrdGreaterThan 111 27 + SelectionMerge 114 None + BranchConditional 112 113 114 + 113: Label + 115: 2 FunctionCall 6(doSomething() + Branch 114 + 114: Label + 116: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 117: 8(float) CompositeExtract 116 0 + 118: 66(bool) FOrdGreaterThan 117 27 + SelectionMerge 120 None + BranchConditional 118 119 120 + 119: Label + 121: 2 FunctionCall 6(doSomething() + Branch 120 + 120: Label + 122: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 123: 66(bool) SGreaterThan 122 19 + SelectionMerge 125 None + BranchConditional 123 124 125 + 124: Label + 126: 2 FunctionCall 6(doSomething() + Branch 125 + 125: Label + 127: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 128: 66(bool) FOrdGreaterThan 127 27 + SelectionMerge 130 None + BranchConditional 128 129 130 + 129: Label + 131: 2 FunctionCall 6(doSomething() + Branch 130 + 130: Label + 132: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 45(rayQuery) 23 + 133: 66(bool) UGreaterThan 132 20 + SelectionMerge 135 None + BranchConditional 133 134 135 + 134: Label + 136: 2 FunctionCall 6(doSomething() + Branch 135 + 135: Label + Branch 75 + 74: Label + 138: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 138 + 139: 77 Load 79(_mat4x3) + 140: 82 Transpose 139 + Store 84(_mat3x4) 140 + 141: 43 Load 45(rayQuery) + 142: 66(bool) RayQueryGetIntersectionCandidateAABBOpaqueKHR 141 + SelectionMerge 144 None + BranchConditional 142 143 144 + 143: Label + 145: 2 FunctionCall 6(doSomething() + Branch 144 + 144: Label + Store 146(t) 147 + 148: 8(float) Load 146(t) + RayQueryGenerateIntersectionKHR 45(rayQuery) 148 + 149: 43 Load 45(rayQuery) + RayQueryTerminateKHR 149 + Branch 75 + 75: Label + Branch 63 + 63: Label + Branch 60 + 62: Label + 152: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 153: 8(float) Load 152 + 154: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 155: 8(float) Load 154 + 156: 66(bool) FOrdEqual 153 155 + SelectionMerge 158 None + BranchConditional 156 157 158 + 157: Label + 159: 2 FunctionCall 6(doSomething() + Branch 158 + 158: Label + 161: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 23 + Store 160(committedStatus) 161 + 162: 14(int) Load 160(committedStatus) + SelectionMerge 166 None + Switch 162 166 + case 0: 163 + case 1: 164 + case 2: 165 + 163: Label + 167: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 19 + Store 79(_mat4x3) 167 + 168: 77 Load 79(_mat4x3) + 169: 82 Transpose 168 + Store 84(_mat3x4) 169 + Branch 166 + 164: Label + 171: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 23 + Store 79(_mat4x3) 171 + 172: 77 Load 79(_mat4x3) + 173: 82 Transpose 172 + Store 84(_mat3x4) 173 + 174: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 176 None + BranchConditional 174 175 176 + 175: Label + 177: 2 FunctionCall 6(doSomething() + Branch 176 + 176: Label + 178: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 180: 8(float) CompositeExtract 178 1 + 181: 66(bool) FOrdEqual 180 27 + SelectionMerge 183 None + BranchConditional 181 182 183 + 182: Label + 184: 2 FunctionCall 6(doSomething() + Branch 183 + 183: Label + Branch 166 + 165: Label + 186: 18(int) RayQueryGetIntersectionGeometryIndexKHR 45(rayQuery) 23 + 187: 66(bool) SGreaterThan 186 19 + SelectionMerge 189 None + BranchConditional 187 188 189 + 188: Label + 190: 2 FunctionCall 6(doSomething() + Branch 189 + 189: Label + 191: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 192: 66(bool) SGreaterThan 191 19 + SelectionMerge 194 None + BranchConditional 192 193 194 + 193: Label + 195: 2 FunctionCall 6(doSomething() + Branch 194 + 194: Label + 196: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 197: 66(bool) SGreaterThan 196 19 + SelectionMerge 199 None + BranchConditional 197 198 199 + 198: Label + 200: 2 FunctionCall 6(doSomething() + Branch 199 + 199: Label + 201: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 203: 8(float) CompositeExtract 201 2 + 204: 66(bool) FOrdGreaterThan 203 27 + SelectionMerge 206 None + BranchConditional 204 205 206 + 205: Label + 207: 2 FunctionCall 6(doSomething() + Branch 206 + 206: Label + 208: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 209: 8(float) CompositeExtract 208 0 + 210: 66(bool) FOrdGreaterThan 209 27 + SelectionMerge 212 None + BranchConditional 210 211 212 + 211: Label + 213: 2 FunctionCall 6(doSomething() + Branch 212 + 212: Label + 214: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 215: 66(bool) SGreaterThan 214 19 + SelectionMerge 217 None + BranchConditional 215 216 217 + 216: Label + 218: 2 FunctionCall 6(doSomething() + Branch 217 + 217: Label + 219: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 220: 66(bool) FOrdGreaterThan 219 27 + SelectionMerge 222 None + BranchConditional 220 221 222 + 221: Label + 223: 2 FunctionCall 6(doSomething() + Branch 222 + 222: Label + Branch 166 + 166: Label + 226: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 227: 8(float) Load 226 + 228: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 229: 8(float) Load 228 + 230: 66(bool) FOrdEqual 227 229 + SelectionMerge 232 None + BranchConditional 230 231 232 + 231: Label + 233: 2 FunctionCall 6(doSomething() + Branch 232 + 232: Label + 234: 43 Load 45(rayQuery) + 235: 14(int) RayQueryGetRayFlagsKHR 234 + 236: 66(bool) UGreaterThan 235 20 + SelectionMerge 238 None + BranchConditional 236 237 238 + 237: Label + 239: 2 FunctionCall 6(doSomething() + Branch 238 + 238: Label + 240: 43 Load 45(rayQuery) + 241: 8(float) RayQueryGetRayTMinKHR 240 + 242: 66(bool) FOrdGreaterThan 241 27 + SelectionMerge 244 None + BranchConditional 242 243 244 + 243: Label + 245: 2 FunctionCall 6(doSomething() + Branch 244 + 244: Label + 247: 43 Load 45(rayQuery) + 248: 9(fvec3) RayQueryGetWorldRayOriginKHR 247 + Store 246(o) 248 + 250: 43 Load 45(rayQuery) + 251: 9(fvec3) RayQueryGetWorldRayDirectionKHR 250 + Store 249(d) 251 + 252: 35(ptr) AccessChain 246(o) 20 + 253: 8(float) Load 252 + 254: 35(ptr) AccessChain 249(d) 202 + 255: 8(float) Load 254 + 256: 66(bool) FOrdEqual 253 255 + SelectionMerge 258 None + BranchConditional 256 257 258 + 257: Label + 259: 2 FunctionCall 6(doSomething() + Branch 258 + 258: Label + Return + FunctionEnd + 6(doSomething(): 2 Function None 3 + 7: Label + 22: 21(ptr) AccessChain 17 19 + Store 22 20 + 24: 21(ptr) AccessChain 17 23 + Store 24 20 + Return + FunctionEnd +12(makeRayDesc(): 10(Ray) Function None 11 + 13: Label + 26(ray): 25(ptr) Variable Function + 30: 29(ptr) AccessChain 26(ray) 19 + Store 30 28 + 34: 29(ptr) AccessChain 26(ray) 31 + Store 34 33 + 36: 35(ptr) AccessChain 26(ray) 23 + Store 36 27 + 39: 35(ptr) AccessChain 26(ray) 37 + Store 39 38 + 40: 10(Ray) Load 26(ray) + ReturnValue 40 + FunctionEnd diff --git a/Test/baseResults/rayQuery-allOps.frag.out b/Test/baseResults/rayQuery-allOps.frag.out new file mode 100644 index 00000000..87706a85 --- /dev/null +++ b/Test/baseResults/rayQuery-allOps.frag.out @@ -0,0 +1,438 @@ +rayQuery-allOps.frag +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 265 + + Capability Shader + Capability RayQueryProvisionalKHR + Extension "SPV_KHR_ray_query" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Source GLSL 460 + SourceExtension "GL_EXT_ray_query" + SourceExtension "GL_NV_ray_tracing" + Name 4 "main" + Name 6 "doSomething(" + Name 10 "Ray" + MemberName 10(Ray) 0 "pos" + MemberName 10(Ray) 1 "tmin" + MemberName 10(Ray) 2 "dir" + MemberName 10(Ray) 3 "tmax" + Name 12 "makeRayDesc(" + Name 15 "Log" + MemberName 15(Log) 0 "x" + MemberName 15(Log) 1 "y" + Name 17 "" + Name 26 "ray" + Name 45 "rayQuery" + Name 48 "rtas" + Name 51 "ray" + Name 69 "candidateType" + Name 79 "_mat4x3" + Name 84 "_mat3x4" + Name 146 "t" + Name 160 "committedStatus" + Name 246 "o" + Name 249 "d" + Name 260 "Ray" + MemberName 260(Ray) 0 "pos" + MemberName 260(Ray) 1 "tmin" + MemberName 260(Ray) 2 "dir" + MemberName 260(Ray) 3 "tmax" + Name 262 "Rays" + MemberName 262(Rays) 0 "rays" + Name 264 "" + MemberDecorate 15(Log) 0 Offset 0 + MemberDecorate 15(Log) 1 Offset 4 + Decorate 15(Log) BufferBlock + Decorate 17 DescriptorSet 0 + Decorate 17 Binding 0 + Decorate 48(rtas) DescriptorSet 0 + Decorate 48(rtas) Binding 1 + MemberDecorate 260(Ray) 0 Offset 0 + MemberDecorate 260(Ray) 1 Offset 12 + MemberDecorate 260(Ray) 2 Offset 16 + MemberDecorate 260(Ray) 3 Offset 28 + Decorate 261 ArrayStride 32 + MemberDecorate 262(Rays) 0 Offset 0 + Decorate 262(Rays) BufferBlock + Decorate 264 DescriptorSet 0 + Decorate 264 Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 8: TypeFloat 32 + 9: TypeVector 8(float) 3 + 10(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 11: TypeFunction 10(Ray) + 14: TypeInt 32 0 + 15(Log): TypeStruct 14(int) 14(int) + 16: TypePointer Uniform 15(Log) + 17: 16(ptr) Variable Uniform + 18: TypeInt 32 1 + 19: 18(int) Constant 0 + 20: 14(int) Constant 0 + 21: TypePointer Uniform 14(int) + 23: 18(int) Constant 1 + 25: TypePointer Function 10(Ray) + 27: 8(float) Constant 0 + 28: 9(fvec3) ConstantComposite 27 27 27 + 29: TypePointer Function 9(fvec3) + 31: 18(int) Constant 2 + 32: 8(float) Constant 1065353216 + 33: 9(fvec3) ConstantComposite 32 27 27 + 35: TypePointer Function 8(float) + 37: 18(int) Constant 3 + 38: 8(float) Constant 1176255488 + 43: TypeRayQueryProvisionalKHR + 44: TypePointer Function 43 + 46: TypeAccelerationStructureKHR + 47: TypePointer UniformConstant 46 + 48(rtas): 47(ptr) Variable UniformConstant + 50: 14(int) Constant 255 + 66: TypeBool + 68: TypePointer Function 14(int) + 70: 66(bool) ConstantFalse + 77: TypeMatrix 9(fvec3) 4 + 78: TypePointer Function 77 + 81: TypeVector 8(float) 4 + 82: TypeMatrix 81(fvec4) 3 + 83: TypePointer Function 82 + 88: 66(bool) ConstantTrue + 93: TypeVector 8(float) 2 + 147: 8(float) Constant 1056964608 + 179: 14(int) Constant 1 + 202: 14(int) Constant 2 + 260(Ray): TypeStruct 9(fvec3) 8(float) 9(fvec3) 8(float) + 261: TypeRuntimeArray 260(Ray) + 262(Rays): TypeStruct 261 + 263: TypePointer Uniform 262(Rays) + 264: 263(ptr) Variable Uniform + 4(main): 2 Function None 3 + 5: Label + 45(rayQuery): 44(ptr) Variable Function + 51(ray): 25(ptr) Variable Function +69(candidateType): 68(ptr) Variable Function + 79(_mat4x3): 78(ptr) Variable Function + 84(_mat3x4): 83(ptr) Variable Function + 146(t): 35(ptr) Variable Function +160(committedStatus): 68(ptr) Variable Function + 246(o): 29(ptr) Variable Function + 249(d): 29(ptr) Variable Function + 49: 46 Load 48(rtas) + 52: 29(ptr) AccessChain 51(ray) 19 + 53: 9(fvec3) Load 52 + 54: 35(ptr) AccessChain 51(ray) 23 + 55: 8(float) Load 54 + 56: 29(ptr) AccessChain 51(ray) 31 + 57: 9(fvec3) Load 56 + 58: 35(ptr) AccessChain 51(ray) 37 + 59: 8(float) Load 58 + RayQueryInitializeKHR 45(rayQuery) 49 20 50 53 55 57 59 + Branch 60 + 60: Label + LoopMerge 62 63 None + Branch 64 + 64: Label + 65: 43 Load 45(rayQuery) + 67: 66(bool) RayQueryProceedKHR 65 + BranchConditional 67 61 62 + 61: Label + 71: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 19 + Store 69(candidateType) 71 + 72: 14(int) Load 69(candidateType) + SelectionMerge 75 None + Switch 72 75 + case 0: 73 + case 1: 74 + 73: Label + 76: 43 Load 45(rayQuery) + RayQueryTerminateKHR 76 + 80: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 80 + 85: 77 Load 79(_mat4x3) + 86: 82 Transpose 85 + Store 84(_mat3x4) 86 + 87: 43 Load 45(rayQuery) + RayQueryConfirmIntersectionKHR 87 + 89: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 91 None + BranchConditional 89 90 91 + 90: Label + 92: 2 FunctionCall 6(doSomething() + Branch 91 + 91: Label + 94: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 95: 8(float) CompositeExtract 94 0 + 96: 66(bool) FOrdEqual 95 27 + SelectionMerge 98 None + BranchConditional 96 97 98 + 97: Label + 99: 2 FunctionCall 6(doSomething() + Branch 98 + 98: Label + 100: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 101: 66(bool) SGreaterThan 100 19 + SelectionMerge 103 None + BranchConditional 101 102 103 + 102: Label + 104: 2 FunctionCall 6(doSomething() + Branch 103 + 103: Label + 105: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 106: 66(bool) SGreaterThan 105 19 + SelectionMerge 108 None + BranchConditional 106 107 108 + 107: Label + 109: 2 FunctionCall 6(doSomething() + Branch 108 + 108: Label + 110: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 111: 8(float) CompositeExtract 110 0 + 112: 66(bool) FOrdGreaterThan 111 27 + SelectionMerge 114 None + BranchConditional 112 113 114 + 113: Label + 115: 2 FunctionCall 6(doSomething() + Branch 114 + 114: Label + 116: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 117: 8(float) CompositeExtract 116 0 + 118: 66(bool) FOrdGreaterThan 117 27 + SelectionMerge 120 None + BranchConditional 118 119 120 + 119: Label + 121: 2 FunctionCall 6(doSomething() + Branch 120 + 120: Label + 122: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 123: 66(bool) SGreaterThan 122 19 + SelectionMerge 125 None + BranchConditional 123 124 125 + 124: Label + 126: 2 FunctionCall 6(doSomething() + Branch 125 + 125: Label + 127: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 128: 66(bool) FOrdGreaterThan 127 27 + SelectionMerge 130 None + BranchConditional 128 129 130 + 129: Label + 131: 2 FunctionCall 6(doSomething() + Branch 130 + 130: Label + 132: 18(int) RayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR 45(rayQuery) 23 + 133: 66(bool) UGreaterThan 132 20 + SelectionMerge 135 None + BranchConditional 133 134 135 + 134: Label + 136: 2 FunctionCall 6(doSomething() + Branch 135 + 135: Label + Branch 75 + 74: Label + 138: 77 RayQueryGetIntersectionObjectToWorldKHR 45(rayQuery) 19 + Store 79(_mat4x3) 138 + 139: 77 Load 79(_mat4x3) + 140: 82 Transpose 139 + Store 84(_mat3x4) 140 + 141: 43 Load 45(rayQuery) + 142: 66(bool) RayQueryGetIntersectionCandidateAABBOpaqueKHR 141 + SelectionMerge 144 None + BranchConditional 142 143 144 + 143: Label + 145: 2 FunctionCall 6(doSomething() + Branch 144 + 144: Label + Store 146(t) 147 + 148: 8(float) Load 146(t) + RayQueryGenerateIntersectionKHR 45(rayQuery) 148 + 149: 43 Load 45(rayQuery) + RayQueryTerminateKHR 149 + Branch 75 + 75: Label + Branch 63 + 63: Label + Branch 60 + 62: Label + 152: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 153: 8(float) Load 152 + 154: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 155: 8(float) Load 154 + 156: 66(bool) FOrdEqual 153 155 + SelectionMerge 158 None + BranchConditional 156 157 158 + 157: Label + 159: 2 FunctionCall 6(doSomething() + Branch 158 + 158: Label + 161: 14(int) RayQueryGetIntersectionTypeKHR 45(rayQuery) 23 + Store 160(committedStatus) 161 + 162: 14(int) Load 160(committedStatus) + SelectionMerge 166 None + Switch 162 166 + case 0: 163 + case 1: 164 + case 2: 165 + 163: Label + 167: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 19 + Store 79(_mat4x3) 167 + 168: 77 Load 79(_mat4x3) + 169: 82 Transpose 168 + Store 84(_mat3x4) 169 + Branch 166 + 164: Label + 171: 77 RayQueryGetIntersectionWorldToObjectKHR 45(rayQuery) 23 + Store 79(_mat4x3) 171 + 172: 77 Load 79(_mat4x3) + 173: 82 Transpose 172 + Store 84(_mat3x4) 173 + 174: 66(bool) RayQueryGetIntersectionFrontFaceKHR 45(rayQuery) 23 + SelectionMerge 176 None + BranchConditional 174 175 176 + 175: Label + 177: 2 FunctionCall 6(doSomething() + Branch 176 + 176: Label + 178: 93(fvec2) RayQueryGetIntersectionBarycentricsKHR 45(rayQuery) 23 + 180: 8(float) CompositeExtract 178 1 + 181: 66(bool) FOrdEqual 180 27 + SelectionMerge 183 None + BranchConditional 181 182 183 + 182: Label + 184: 2 FunctionCall 6(doSomething() + Branch 183 + 183: Label + Branch 166 + 165: Label + 186: 18(int) RayQueryGetIntersectionGeometryIndexKHR 45(rayQuery) 23 + 187: 66(bool) SGreaterThan 186 19 + SelectionMerge 189 None + BranchConditional 187 188 189 + 188: Label + 190: 2 FunctionCall 6(doSomething() + Branch 189 + 189: Label + 191: 18(int) RayQueryGetIntersectionInstanceIdKHR 45(rayQuery) 23 + 192: 66(bool) SGreaterThan 191 19 + SelectionMerge 194 None + BranchConditional 192 193 194 + 193: Label + 195: 2 FunctionCall 6(doSomething() + Branch 194 + 194: Label + 196: 18(int) RayQueryGetIntersectionInstanceCustomIndexKHR 45(rayQuery) 23 + 197: 66(bool) SGreaterThan 196 19 + SelectionMerge 199 None + BranchConditional 197 198 199 + 198: Label + 200: 2 FunctionCall 6(doSomething() + Branch 199 + 199: Label + 201: 9(fvec3) RayQueryGetIntersectionObjectRayDirectionKHR 45(rayQuery) 23 + 203: 8(float) CompositeExtract 201 2 + 204: 66(bool) FOrdGreaterThan 203 27 + SelectionMerge 206 None + BranchConditional 204 205 206 + 205: Label + 207: 2 FunctionCall 6(doSomething() + Branch 206 + 206: Label + 208: 9(fvec3) RayQueryGetIntersectionObjectRayOriginKHR 45(rayQuery) 23 + 209: 8(float) CompositeExtract 208 0 + 210: 66(bool) FOrdGreaterThan 209 27 + SelectionMerge 212 None + BranchConditional 210 211 212 + 211: Label + 213: 2 FunctionCall 6(doSomething() + Branch 212 + 212: Label + 214: 18(int) RayQueryGetIntersectionPrimitiveIndexKHR 45(rayQuery) 23 + 215: 66(bool) SGreaterThan 214 19 + SelectionMerge 217 None + BranchConditional 215 216 217 + 216: Label + 218: 2 FunctionCall 6(doSomething() + Branch 217 + 217: Label + 219: 8(float) RayQueryGetIntersectionTKHR 45(rayQuery) 23 + 220: 66(bool) FOrdGreaterThan 219 27 + SelectionMerge 222 None + BranchConditional 220 221 222 + 221: Label + 223: 2 FunctionCall 6(doSomething() + Branch 222 + 222: Label + Branch 166 + 166: Label + 226: 35(ptr) AccessChain 84(_mat3x4) 19 20 + 227: 8(float) Load 226 + 228: 35(ptr) AccessChain 79(_mat4x3) 19 20 + 229: 8(float) Load 228 + 230: 66(bool) FOrdEqual 227 229 + SelectionMerge 232 None + BranchConditional 230 231 232 + 231: Label + 233: 2 FunctionCall 6(doSomething() + Branch 232 + 232: Label + 234: 43 Load 45(rayQuery) + 235: 14(int) RayQueryGetRayFlagsKHR 234 + 236: 66(bool) UGreaterThan 235 20 + SelectionMerge 238 None + BranchConditional 236 237 238 + 237: Label + 239: 2 FunctionCall 6(doSomething() + Branch 238 + 238: Label + 240: 43 Load 45(rayQuery) + 241: 8(float) RayQueryGetRayTMinKHR 240 + 242: 66(bool) FOrdGreaterThan 241 27 + SelectionMerge 244 None + BranchConditional 242 243 244 + 243: Label + 245: 2 FunctionCall 6(doSomething() + Branch 244 + 244: Label + 247: 43 Load 45(rayQuery) + 248: 9(fvec3) RayQueryGetWorldRayOriginKHR 247 + Store 246(o) 248 + 250: 43 Load 45(rayQuery) + 251: 9(fvec3) RayQueryGetWorldRayDirectionKHR 250 + Store 249(d) 251 + 252: 35(ptr) AccessChain 246(o) 20 + 253: 8(float) Load 252 + 254: 35(ptr) AccessChain 249(d) 202 + 255: 8(float) Load 254 + 256: 66(bool) FOrdEqual 253 255 + SelectionMerge 258 None + BranchConditional 256 257 258 + 257: Label + 259: 2 FunctionCall 6(doSomething() + Branch 258 + 258: Label + Return + FunctionEnd + 6(doSomething(): 2 Function None 3 + 7: Label + 22: 21(ptr) AccessChain 17 19 + Store 22 20 + 24: 21(ptr) AccessChain 17 23 + Store 24 20 + Return + FunctionEnd +12(makeRayDesc(): 10(Ray) Function None 11 + 13: Label + 26(ray): 25(ptr) Variable Function + 30: 29(ptr) AccessChain 26(ray) 19 + Store 30 28 + 34: 29(ptr) AccessChain 26(ray) 31 + Store 34 33 + 36: 35(ptr) AccessChain 26(ray) 23 + Store 36 27 + 39: 35(ptr) AccessChain 26(ray) 37 + Store 39 38 + 40: 10(Ray) Load 26(ray) + ReturnValue 40 + FunctionEnd diff --git a/Test/baseResults/rayQuery-committed.Error.rgen.out b/Test/baseResults/rayQuery-committed.Error.rgen.out new file mode 100644 index 00000000..037f6927 --- /dev/null +++ b/Test/baseResults/rayQuery-committed.Error.rgen.out @@ -0,0 +1,19 @@ +rayQuery-committed.Error.rgen +ERROR: 0:48: 'committed' : argument must be compile-time constant +ERROR: 0:53: 'committed' : argument must be compile-time constant +ERROR: 0:54: 'committed' : argument must be compile-time constant +ERROR: 0:58: 'committed' : argument must be compile-time constant +ERROR: 0:62: 'committed' : argument must be compile-time constant +ERROR: 0:66: 'committed' : argument must be compile-time constant +ERROR: 0:70: 'committed' : argument must be compile-time constant +ERROR: 0:74: 'committed' : argument must be compile-time constant +ERROR: 0:78: 'committed' : argument must be compile-time constant +ERROR: 0:82: 'committed' : argument must be compile-time constant +ERROR: 0:86: 'committed' : argument must be compile-time constant +ERROR: 0:90: 'committed' : argument must be compile-time constant +ERROR: 0:97: 'committed' : argument must be compile-time constant +ERROR: 0:100: 'committed' : argument must be compile-time constant +ERROR: 14 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/rayQuery-allOps.Error.rgen b/Test/rayQuery-allOps.Error.rgen new file mode 100644 index 00000000..a33cece5 --- /dev/null +++ b/Test/rayQuery-allOps.Error.rgen @@ -0,0 +1,212 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(std430, set = 0, binding = 0) buffer Log +{ + uint x; + uint y; +}; + +layout(binding = 1, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +void doSomething() +{ + x = 0; + y = 0; +} + +Ray makeRayDesc() +{ + Ray ray; + ray.pos= vec3(0,0,0); + ray.dir = vec3(1,0,0); + ray.tmin = 0.0f; + ray.tmax = 9999.0; + return ray; +} + +void main() +{ + Ray ray = makeRayDesc(); + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, rtas, 0, 0xFF, ray.pos, ray.tmin, ray.dir, ray.tmax); + + mat4x3 _mat4x3; + mat3x4 _mat3x4; + + while (rayQueryProceedEXT(rayQuery) == 1) + { + int candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, false); + switch(candidateType) + { + case gl_RayQueryCandidateIntersectionTriangleEXT: + + rayQueryTerminateEXT(rayQuery); + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + rayQueryConfirmIntersectionEXT(rayQuery); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true) == 1) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true) == 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionTEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true)) + { + doSomething(); + } + break; + + case gl_RayQueryCandidateIntersectionAABBEXT: + { + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + if (rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery)) + { + doSomething(); + } + + int t = 1; + rayQueryGenerateIntersectionEXT(rayQuery, t); + rayQueryTerminateEXT(rayQuery); + break; + } + } + } + + if(_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + int committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, true); + + switch(committedStatus) + { + case gl_RayQueryCommittedIntersectionNoneEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + break; + + case gl_RayQueryCommittedIntersectionTriangleEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true); + _mat3x4 = transpose(_mat4x3); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true) == 0) + { + doSomething(); + } + break; + + case gl_RayQueryCommittedIntersectionGeneratedEXT : + + if(rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceIdEXT(rayQuery, true)) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true)) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true)) + { + doSomething(); + } + + if(rayQueryGetIntersectionTEXT(rayQuery, true)) + { + doSomething(); + } + break; + } + + if (_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + if (rayQueryGetRayFlagsEXT(rayQuery)) + { + doSomething(); + } + + if (rayQueryGetRayTMinEXT(rayQuery)) + { + doSomething(); + } + + vec3 o = rayQueryGetWorldRayOriginEXT(rayQuery); + vec3 d = rayQueryGetWorldRayDirectionEXT(rayQuery); + + if (o.x == d.z) + { + doSomething(); + } +} diff --git a/Test/rayQuery-allOps.comp b/Test/rayQuery-allOps.comp new file mode 100644 index 00000000..7c62a64c --- /dev/null +++ b/Test/rayQuery-allOps.comp @@ -0,0 +1,212 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(std430, set = 0, binding = 0) buffer Log +{ + uint x; + uint y; +}; + +layout(binding = 1, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +void doSomething() +{ + x = 0; + y = 0; +} + +Ray makeRayDesc() +{ + Ray ray; + ray.pos= vec3(0,0,0); + ray.dir = vec3(1,0,0); + ray.tmin = 0.0f; + ray.tmax = 9999.0; + return ray; +} + +void main() +{ + Ray ray;// = makeRayDesc(); + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, rtas, 0, 0xFF, ray.pos, ray.tmin, ray.dir, ray.tmax); + + mat4x3 _mat4x3; + mat3x4 _mat3x4; + + while (rayQueryProceedEXT(rayQuery)) + { + uint candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, false); + switch(candidateType) + { + case gl_RayQueryCandidateIntersectionTriangleEXT: + + rayQueryTerminateEXT(rayQuery); + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + rayQueryConfirmIntersectionEXT(rayQuery); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).x == 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true) > 0) + { + doSomething(); + } + break; + + case gl_RayQueryCandidateIntersectionAABBEXT: + { + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + if (rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery)) + { + doSomething(); + } + + float t = 0.5; + rayQueryGenerateIntersectionEXT(rayQuery, t); + rayQueryTerminateEXT(rayQuery); + break; + } + } + } + + if(_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + uint committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, true); + + switch(committedStatus) + { + case gl_RayQueryCommittedIntersectionNoneEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + break; + + case gl_RayQueryCommittedIntersectionTriangleEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true); + _mat3x4 = transpose(_mat4x3); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).y == 0) + { + doSomething(); + } + break; + + case gl_RayQueryCommittedIntersectionGeneratedEXT : + + if(rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).z > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + break; + } + + if (_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + if (rayQueryGetRayFlagsEXT(rayQuery) > 0) + { + doSomething(); + } + + if (rayQueryGetRayTMinEXT(rayQuery) > 0.0) + { + doSomething(); + } + + vec3 o = rayQueryGetWorldRayOriginEXT(rayQuery); + vec3 d = rayQueryGetWorldRayDirectionEXT(rayQuery); + + if (o.x == d.z) + { + doSomething(); + } +} diff --git a/Test/rayQuery-allOps.frag b/Test/rayQuery-allOps.frag new file mode 100644 index 00000000..7c62a64c --- /dev/null +++ b/Test/rayQuery-allOps.frag @@ -0,0 +1,212 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(std430, set = 0, binding = 0) buffer Log +{ + uint x; + uint y; +}; + +layout(binding = 1, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +void doSomething() +{ + x = 0; + y = 0; +} + +Ray makeRayDesc() +{ + Ray ray; + ray.pos= vec3(0,0,0); + ray.dir = vec3(1,0,0); + ray.tmin = 0.0f; + ray.tmax = 9999.0; + return ray; +} + +void main() +{ + Ray ray;// = makeRayDesc(); + rayQueryEXT rayQuery; + rayQueryInitializeEXT(rayQuery, rtas, 0, 0xFF, ray.pos, ray.tmin, ray.dir, ray.tmax); + + mat4x3 _mat4x3; + mat3x4 _mat3x4; + + while (rayQueryProceedEXT(rayQuery)) + { + uint candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, false); + switch(candidateType) + { + case gl_RayQueryCandidateIntersectionTriangleEXT: + + rayQueryTerminateEXT(rayQuery); + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + rayQueryConfirmIntersectionEXT(rayQuery); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).x == 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if (rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + + if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true) > 0) + { + doSomething(); + } + break; + + case gl_RayQueryCandidateIntersectionAABBEXT: + { + _mat4x3 = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + if (rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery)) + { + doSomething(); + } + + float t = 0.5; + rayQueryGenerateIntersectionEXT(rayQuery, t); + rayQueryTerminateEXT(rayQuery); + break; + } + } + } + + if(_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + uint committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, true); + + switch(committedStatus) + { + case gl_RayQueryCommittedIntersectionNoneEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, false); + _mat3x4 = transpose(_mat4x3); + break; + + case gl_RayQueryCommittedIntersectionTriangleEXT : + _mat4x3 = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true); + _mat3x4 = transpose(_mat4x3); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, true)) + { + doSomething(); + } + + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, true).y == 0) + { + doSomething(); + } + break; + + case gl_RayQueryCommittedIntersectionGeneratedEXT : + + if(rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceIdEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true).z > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true).x > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true) > 0) + { + doSomething(); + } + + if(rayQueryGetIntersectionTEXT(rayQuery, true) > 0.f) + { + doSomething(); + } + break; + } + + if (_mat3x4[0][0] == _mat4x3[0][0]) + { + doSomething(); + } + + if (rayQueryGetRayFlagsEXT(rayQuery) > 0) + { + doSomething(); + } + + if (rayQueryGetRayTMinEXT(rayQuery) > 0.0) + { + doSomething(); + } + + vec3 o = rayQueryGetWorldRayOriginEXT(rayQuery); + vec3 d = rayQueryGetWorldRayDirectionEXT(rayQuery); + + if (o.x == d.z) + { + doSomething(); + } +} diff --git a/Test/rayQuery-committed.Error.rgen b/Test/rayQuery-committed.Error.rgen new file mode 100644 index 00000000..7d444dd5 --- /dev/null +++ b/Test/rayQuery-committed.Error.rgen @@ -0,0 +1,105 @@ +#version 460 +#extension GL_NV_ray_tracing : enable +#extension GL_EXT_ray_query : enable + +struct Ray +{ + vec3 pos; + float tmin; + vec3 dir; + float tmax; +}; + +layout(std430, set = 0, binding = 0) buffer Log +{ + uint x; + uint y; +}; + +layout(binding = 1, set = 0) uniform accelerationStructureNV rtas; +layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; }; + +void doSomething() +{ + x = 0; + y = 0; +} + +uint launchIndex() +{ + return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x; +} + +void main() +{ + uint index = launchIndex(); + Ray ray = rays[index]; + rayQueryEXT rayQuery; + + bool committed_true = true; + bool committed_false = false; + + rayQueryInitializeEXT(rayQuery, rtas, 1, 2, ray.pos, ray.tmin, ray.dir, ray.tmax); + while (rayQueryProceedEXT(rayQuery)) + { + mat4x3 mat_o2w; + mat4x3 mat_w2o; + + uint candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, committed_false); + if (candidateType == gl_RayQueryCandidateIntersectionTriangleEXT) + { + rayQueryTerminateEXT(rayQuery); + + mat_o2w = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, committed_false); + mat_w2o = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, committed_false); + + rayQueryConfirmIntersectionEXT(rayQuery); + + if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, committed_true)) + { + doSomething(); + } + if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, committed_true).x == 0) + { + doSomething(); + } + if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, committed_true) > 0) + { + doSomething(); + } + if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, committed_true) > 0) + { + doSomething(); + } + if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, committed_true).x > 0) + { + doSomething(); + } + if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, committed_true).x > 0) + { + doSomething(); + } + if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, committed_true) > 0) + { + doSomething(); + } + if (rayQueryGetIntersectionTEXT(rayQuery, committed_true) > 0.f) + { + doSomething(); + } + if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, committed_true) > 0) + { + doSomething(); + } + } + } + + uint committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, committed_true); + if (committedStatus == gl_RayQueryCommittedIntersectionGeneratedEXT) + { + if (rayQueryGetIntersectionGeometryIndexEXT(rayQuery, committed_true) > 0) + { + doSomething(); + } + } +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 54338411..dcafb7bf 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -230,12 +230,16 @@ INSTANTIATE_TEST_CASE_P( "spv.while-continue-break.vert", "spv.while-simple.vert", // vulkan-specific tests - //"rayQuery.rgen", - //"rayQuery-array-2d-dynamic.rgen", - //"rayQuery-decls.rgen", - //"rayQuery-no-cse.rgen", - //"rayQuery-initialize.rgen", - //"rayQuery-allOps.rgen", + "rayQuery.rgen", + "rayQuery-array-2d-dynamic.rgen", + "rayQuery-decls.rgen", + "rayQuery-no-cse.rgen", + "rayQuery-initialize.rgen", + "rayQuery-allOps.rgen", + "rayQuery-allOps.Error.rgen", + "rayQuery-committed.Error.rgen", + //"rayQuery-allOps.comp", + //"rayQuery-allOps.frag", "spv.set.vert", "spv.double.comp", "spv.100ops.frag", @@ -454,7 +458,6 @@ INSTANTIATE_TEST_CASE_P( FileNameAsCustomTestSuffix ); - // Cases with deliberately unreachable code. // By default the compiler will aggressively eliminate // unreachable merges and continues.