AST.FromFile.cpp 9.5 KB

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