AST.FromFile.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. #ifdef NV_EXTENSIONS
  40. using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
  41. #endif
  42. TEST_P(CompileToAstTest, FromFile)
  43. {
  44. loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
  45. Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
  46. Target::AST);
  47. }
  48. #ifdef NV_EXTENSIONS
  49. // Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
  50. TEST_P(CompileToAstTestNV, FromFile)
  51. {
  52. loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
  53. Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
  54. Target::AST);
  55. }
  56. #endif
  57. // clang-format off
  58. INSTANTIATE_TEST_CASE_P(
  59. Glsl, CompileToAstTest,
  60. ::testing::ValuesIn(std::vector<std::string>({
  61. "sample.frag",
  62. "sample.vert",
  63. "decls.frag",
  64. "specExamples.frag",
  65. "specExamples.vert",
  66. "versionsClean.frag",
  67. "versionsClean.vert",
  68. "versionsErrors.frag",
  69. "versionsErrors.vert",
  70. "100.frag",
  71. "100samplerExternal.frag",
  72. "120.vert",
  73. "120.frag",
  74. "130.vert",
  75. "130.frag",
  76. "140.vert",
  77. "140.frag",
  78. "150.vert",
  79. "150.geom",
  80. "150.frag",
  81. "precision.frag",
  82. "precision.vert",
  83. "nonSquare.vert",
  84. "matrixError.vert",
  85. "cppSimple.vert",
  86. "cppIndent.vert",
  87. "cppIntMinOverNegativeOne.frag",
  88. "cppNest.vert",
  89. "cppBad.vert",
  90. "cppBad2.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. "310.comp",
  109. "310.vert",
  110. "310.geom",
  111. "310.frag",
  112. "310.tesc",
  113. "310.tese",
  114. "310implicitSizeArrayError.vert",
  115. "310AofA.vert",
  116. "310runtimeArray.vert",
  117. "320.comp",
  118. "320.vert",
  119. "320.geom",
  120. "320.frag",
  121. "320.tesc",
  122. "320.tese",
  123. "330.frag",
  124. "330comp.frag",
  125. "constErrors.frag",
  126. "constFold.frag",
  127. "constFoldIntMin.frag",
  128. "errors.frag",
  129. "forwardRef.frag",
  130. "uint.frag",
  131. "switch.frag",
  132. "tokenLength.vert",
  133. "100Limits.vert",
  134. "100scope.vert",
  135. "110scope.vert",
  136. "300scope.vert",
  137. "400.frag",
  138. "400.vert",
  139. "410.vert",
  140. "420.comp",
  141. "420.frag",
  142. "420.vert",
  143. "420.geom",
  144. "420_size_gl_in.geom",
  145. "430scope.vert",
  146. "lineContinuation100.vert",
  147. "lineContinuation.vert",
  148. "numeral.frag",
  149. "400.geom",
  150. "400.tesc",
  151. "400.tese",
  152. "410.tesc",
  153. "420.tesc",
  154. "420.tese",
  155. "410.geom",
  156. "430.vert",
  157. "430.comp",
  158. "430AofA.frag",
  159. "435.vert",
  160. "440.vert",
  161. "440.frag",
  162. "450.vert",
  163. "450.geom",
  164. "450.tesc",
  165. "450.tese",
  166. "450.frag",
  167. "450.comp",
  168. "460.frag",
  169. "460.vert",
  170. "dce.frag",
  171. "atomic_uint.frag",
  172. "implicitInnerAtomicUint.frag",
  173. "aggOps.frag",
  174. "always-discard.frag",
  175. "always-discard2.frag",
  176. "conditionalDiscard.frag",
  177. "conversion.frag",
  178. "dataOut.frag",
  179. "dataOutIndirect.frag",
  180. "deepRvalue.frag",
  181. "depthOut.frag",
  182. "discard-dce.frag",
  183. "doWhileLoop.frag",
  184. "earlyReturnDiscard.frag",
  185. "flowControl.frag",
  186. "forLoop.frag",
  187. "functionCall.frag",
  188. "functionSemantics.frag",
  189. "length.frag",
  190. "localAggregates.frag",
  191. "loops.frag",
  192. "loopsArtificial.frag",
  193. "matrix.frag",
  194. "matrix2.frag",
  195. "mixedArrayDecls.frag",
  196. "nonuniform.frag",
  197. "newTexture.frag",
  198. "Operations.frag",
  199. "overlongLiteral.frag",
  200. "prepost.frag",
  201. "runtimeArray.vert",
  202. "simpleFunctionCall.frag",
  203. "stringToDouble.vert",
  204. "structAssignment.frag",
  205. "structDeref.frag",
  206. "structure.frag",
  207. "swizzle.frag",
  208. "invalidSwizzle.vert",
  209. "syntaxError.frag",
  210. "test.frag",
  211. "texture.frag",
  212. "tokenPaste.vert",
  213. "types.frag",
  214. "uniformArray.frag",
  215. "variableArrayIndex.frag",
  216. "varyingArray.frag",
  217. "varyingArrayIndirect.frag",
  218. "voidFunction.frag",
  219. "whileLoop.frag",
  220. "nonVulkan.frag",
  221. "negativeArraySize.comp",
  222. "precise.tesc",
  223. "precise_struct_block.vert",
  224. "maxClipDistances.vert",
  225. "findFunction.frag",
  226. })),
  227. FileNameAsCustomTestSuffix
  228. );
  229. #ifdef NV_EXTENSIONS
  230. INSTANTIATE_TEST_CASE_P(
  231. Glsl, CompileToAstTestNV,
  232. ::testing::ValuesIn(std::vector<std::string>({
  233. "nvShaderNoperspectiveInterpolation.frag",
  234. })),
  235. FileNameAsCustomTestSuffix
  236. );
  237. #endif
  238. // clang-format on
  239. } // anonymous namespace
  240. } // namespace glslangtest