AST.FromFile.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. //
  2. // Copyright (C) 2016 Google, Inc.
  3. // Copyright (C) 2022-2024 Arm Limited.
  4. //
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions
  9. // are met:
  10. //
  11. // Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. //
  14. // Redistributions in binary form must reproduce the above
  15. // copyright notice, this list of conditions and the following
  16. // disclaimer in the documentation and/or other materials provided
  17. // with the distribution.
  18. //
  19. // Neither the name of Google Inc. nor the names of its
  20. // contributors may be used to endorse or promote products derived
  21. // from this software without specific prior written permission.
  22. //
  23. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. // POSSIBILITY OF SUCH DAMAGE.
  35. #include <gtest/gtest.h>
  36. #include "TestFixture.h"
  37. namespace glslangtest {
  38. namespace {
  39. using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
  40. using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
  41. TEST_P(CompileToAstTest, FromFile)
  42. {
  43. loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
  44. Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
  45. Target::AST);
  46. }
  47. // Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
  48. TEST_P(CompileToAstTestNV, FromFile)
  49. {
  50. loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
  51. Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
  52. Target::AST);
  53. }
  54. // clang-format off
  55. INSTANTIATE_TEST_SUITE_P(
  56. Glsl, CompileToAstTest,
  57. ::testing::ValuesIn(std::vector<std::string>({
  58. "sample.frag",
  59. "sample.vert",
  60. "decls.frag",
  61. "specExamples.frag",
  62. "specExamples.vert",
  63. "versionsClean.frag",
  64. "versionsClean.vert",
  65. "versionsErrors.frag",
  66. "versionsErrors.vert",
  67. "100.frag",
  68. "100samplerExternal.frag",
  69. "120.vert",
  70. "120.frag",
  71. "130.vert",
  72. "130.frag",
  73. "140.vert",
  74. "140.frag",
  75. "150.vert",
  76. "150.geom",
  77. "150.frag",
  78. "precision.frag",
  79. "precision.vert",
  80. "nonSquare.vert",
  81. "matrixError.vert",
  82. "cppSimple.vert",
  83. "cppIndent.vert",
  84. "cppIntMinOverNegativeOne.frag",
  85. "cppMerge.frag",
  86. "cppNest.vert",
  87. "cppBad.vert",
  88. "cppBad2.vert",
  89. "cppBad3.vert",
  90. "cppBad4.vert",
  91. "cppBad5.vert",
  92. "cppComplexExpr.vert",
  93. "cppDeepNest.frag",
  94. "cppPassMacroName.frag",
  95. "cppRelaxSkipTokensErrors.vert",
  96. "badChars.frag",
  97. "pointCoord.frag",
  98. "array.frag",
  99. "array100.frag",
  100. "comment.frag",
  101. "300.vert",
  102. "300.frag",
  103. "300BuiltIns.frag",
  104. "300layout.vert",
  105. "300layout.frag",
  106. "300operations.frag",
  107. "300block.frag",
  108. "300samplerExternal.frag",
  109. "300samplerExternalYUV.frag",
  110. "310.comp",
  111. "310.vert",
  112. "310.geom",
  113. "310.frag",
  114. "310.tesc",
  115. "310.tese",
  116. "310implicitSizeArrayError.vert",
  117. "310.inheritMemory.frag",
  118. "310AofA.vert",
  119. "310runtimeArray.vert",
  120. "320.comp",
  121. "320.vert",
  122. "320.geom",
  123. "320.frag",
  124. "320.tesc",
  125. "320.tese",
  126. "330.frag",
  127. "330comp.frag",
  128. "constErrors.frag",
  129. "constFold.frag",
  130. "constFoldIntMin.frag",
  131. "errors.frag",
  132. "forwardRef.frag",
  133. "uint.frag",
  134. "switch.frag",
  135. "tokenLength.vert",
  136. "100Limits.vert",
  137. "100scope.vert",
  138. "110scope.vert",
  139. "300scope.vert",
  140. "400.frag",
  141. "400.vert",
  142. "410.vert",
  143. "420.comp",
  144. "420.frag",
  145. "420.vert",
  146. "420.geom",
  147. "420_size_gl_in.geom",
  148. "430scope.vert",
  149. "lineContinuation100.vert",
  150. "lineContinuation.vert",
  151. "numeral.frag",
  152. "400.geom",
  153. "400.tesc",
  154. "400.tese",
  155. "410.tesc",
  156. "420.tesc",
  157. "420.tese",
  158. "410.geom",
  159. "430.vert",
  160. "430.comp",
  161. "430AofA.frag",
  162. "435.vert",
  163. "440.vert",
  164. "440.frag",
  165. "450.vert",
  166. "450.geom",
  167. "450.tesc",
  168. "450.tese",
  169. "450.frag",
  170. "450.comp",
  171. "460.frag",
  172. "460.vert",
  173. "dce.frag",
  174. "atomic_uint.frag",
  175. "implicitInnerAtomicUint.frag",
  176. "aggOps.frag",
  177. "always-discard.frag",
  178. "always-discard2.frag",
  179. "boolinput.error.frag",
  180. "booloutput.error.vert",
  181. "conditionalDiscard.frag",
  182. "conversion.frag",
  183. "dataOut.frag",
  184. "dataOutIndirect.frag",
  185. "deepRvalue.frag",
  186. "defaultArgs.comp",
  187. "depthOut.frag",
  188. "discard-dce.frag",
  189. "doWhileLoop.frag",
  190. "earlyReturnDiscard.frag",
  191. "flowControl.frag",
  192. "forLoop.frag",
  193. "functionCall.frag",
  194. "functionSemantics.frag",
  195. "length.frag",
  196. "localAggregates.frag",
  197. "loops.frag",
  198. "loopsArtificial.frag",
  199. "matrix.frag",
  200. "matrix2.frag",
  201. "mixedArrayDecls.frag",
  202. "nonuniform.frag",
  203. "newTexture.frag",
  204. "Operations.frag",
  205. "overlongLiteral.frag",
  206. "prepost.frag",
  207. "runtimeArray.vert",
  208. "simpleFunctionCall.frag",
  209. "stringToDouble.vert",
  210. "struct.error.frag",
  211. "structAssignment.frag",
  212. "structDeref.frag",
  213. "structure.frag",
  214. "swizzle.frag",
  215. "invalidSwizzle.vert",
  216. "syntaxError.frag",
  217. "test.frag",
  218. "texture.frag",
  219. "tokenPaste.vert",
  220. "types.frag",
  221. "uniformArray.frag",
  222. "variableArrayIndex.frag",
  223. "variadic.comp",
  224. "varyingArray.frag",
  225. "varyingArrayIndirect.frag",
  226. "voidFunction.frag",
  227. "whileLoop.frag",
  228. "nonVulkan.frag",
  229. "negativeArraySize.comp",
  230. "precise.tesc",
  231. "precise_struct_block.vert",
  232. "maxClipDistances.vert",
  233. "findFunction.frag",
  234. "noMatchingFunction.frag",
  235. "constantUnaryConversion.comp",
  236. "xfbUnsizedArray.error.vert",
  237. "xfbUnsizedArray.error.tese",
  238. "glsl.140.layoutOffset.error.vert",
  239. "glsl.430.layoutOffset.error.vert",
  240. "glsl.450.subgroup.frag",
  241. "glsl.450.subgroup.geom",
  242. "glsl.450.subgroup.tesc",
  243. "glsl.450.subgroup.tese",
  244. "glsl.450.subgroup.vert",
  245. "glsl.450.subgroupArithmetic.comp",
  246. "glsl.450.subgroupBasic.comp",
  247. "glsl.450.subgroupBallot.comp",
  248. "glsl.450.subgroupBallotNeg.comp",
  249. "glsl.450.subgroupClustered.comp",
  250. "glsl.450.subgroupClusteredNeg.comp",
  251. "glsl.450.subgroupPartitioned.comp",
  252. "glsl.450.subgroupRotate.comp",
  253. "glsl.450.subgroupShuffle.comp",
  254. "glsl.450.subgroupShuffleRelative.comp",
  255. "glsl.450.subgroupQuad.comp",
  256. "glsl.450.subgroupVote.comp",
  257. "glsl.460.subgroup.mesh",
  258. "glsl.460.subgroup.task",
  259. "glsl.460.subgroup.rahit",
  260. "glsl.460.subgroup.rcall",
  261. "glsl.460.subgroup.rchit",
  262. "glsl.460.subgroup.rgen",
  263. "glsl.460.subgroup.rint",
  264. "glsl.460.subgroup.rmiss",
  265. "glsl.es300.layoutOffset.error.vert",
  266. "glsl.es320.subgroup.frag",
  267. "glsl.es320.subgroup.geom",
  268. "glsl.es320.subgroup.tesc",
  269. "glsl.es320.subgroup.tese",
  270. "glsl.es320.subgroup.vert",
  271. "glsl.es320.subgroupArithmetic.comp",
  272. "glsl.es320.subgroupBasic.comp",
  273. "glsl.es320.subgroupBallot.comp",
  274. "glsl.es320.subgroupBallotNeg.comp",
  275. "glsl.es320.subgroupClustered.comp",
  276. "glsl.es320.subgroupClusteredNeg.comp",
  277. "glsl.es320.subgroupPartitioned.comp",
  278. "glsl.es320.subgroupRotate.comp",
  279. "glsl.es320.subgroupShuffle.comp",
  280. "glsl.es320.subgroupShuffleRelative.comp",
  281. "glsl.es320.subgroupQuad.comp",
  282. "glsl.es320.subgroupVote.comp",
  283. "glsl.es320.extTextureShadowLod.frag",
  284. "gl_samplemask_array_size.frag",
  285. "glsl.ext.textureShadowLod.frag",
  286. "terminate.frag",
  287. "terminate.vert",
  288. "negativeWorkGroupSize.comp",
  289. "textureoffset_sampler2darrayshadow.vert",
  290. "atomicAdd.comp",
  291. "GL_ARB_gpu_shader5.u2i.vert",
  292. "glsl.arbgpushader5.frag",
  293. "textureQueryLOD.frag",
  294. "atomicCounterARBOps.vert",
  295. "GL_EXT_shader_integer_mix.vert",
  296. "GL_ARB_draw_instanced.vert",
  297. "GL_ARB_fragment_coord_conventions.vert",
  298. "GL_ARB_bindless_texture.frag",
  299. "GL_ARB_texture_multisample.vert",
  300. "BestMatchFunction.vert",
  301. "EndStreamPrimitive.geom",
  302. "floatBitsToInt.vert",
  303. "coord_conventions.frag",
  304. "gl_FragCoord.frag",
  305. "glsl.interpOp.error.frag",
  306. "location_aliasing.tesc",
  307. "location_aliasing1.frag",
  308. "GL_EXT_draw_instanced.vert",
  309. "overflow_underflow_toinf_0.frag",
  310. "GL_EXT_texture_array.frag",
  311. "index_outside_sample_mask_range.frag",
  312. "positive_infinity.frag",
  313. "matrixCompMult.vert",
  314. "ps_uint_int.frag",
  315. "ps_sample.frag",
  316. "tes_patch.tese",
  317. })),
  318. FileNameAsCustomTestSuffix
  319. );
  320. INSTANTIATE_TEST_SUITE_P(
  321. Glsl, CompileToAstTestNV,
  322. ::testing::ValuesIn(std::vector<std::string>({
  323. "nvShaderNoperspectiveInterpolation.frag",
  324. "glsl.nvgpushader5.frag",
  325. "glsl.nvgpushader5.geom",
  326. "glsl.nvgpushader5.vert",
  327. })),
  328. FileNameAsCustomTestSuffix
  329. );
  330. // clang-format on
  331. } // anonymous namespace
  332. } // namespace glslangtest