Upgrade to 13.1.1(vulkan-sdk-1.3.268.0)
[platform/upstream/glslang.git] / gtests / AST.FromFile.cpp
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
35 #include <gtest/gtest.h>
36
37 #include "TestFixture.h"
38
39 namespace glslangtest {
40 namespace {
41
42 using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
43
44 using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
45
46 TEST_P(CompileToAstTest, FromFile)
47 {
48     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
49                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
50                             Target::AST);
51 }
52
53 // Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
54 TEST_P(CompileToAstTestNV, FromFile)
55 {
56     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
57                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
58                             Target::AST);
59 }
60
61 // clang-format off
62 INSTANTIATE_TEST_SUITE_P(
63     Glsl, CompileToAstTest,
64     ::testing::ValuesIn(std::vector<std::string>({
65         "sample.frag",
66         "sample.vert",
67         "decls.frag",
68         "specExamples.frag",
69         "specExamples.vert",
70         "versionsClean.frag",
71         "versionsClean.vert",
72         "versionsErrors.frag",
73         "versionsErrors.vert",
74         "100.frag",
75         "100samplerExternal.frag",
76         "120.vert",
77         "120.frag",
78         "130.vert",
79         "130.frag",
80         "140.vert",
81         "140.frag",
82         "150.vert",
83         "150.geom",
84         "150.frag",
85         "precision.frag",
86         "precision.vert",
87         "nonSquare.vert",
88         "matrixError.vert",
89         "cppSimple.vert",
90         "cppIndent.vert",
91         "cppIntMinOverNegativeOne.frag",
92         "cppMerge.frag",
93         "cppNest.vert",
94         "cppBad.vert",
95         "cppBad2.vert",
96         "cppBad3.vert",
97         "cppBad4.vert",
98         "cppBad5.vert",
99         "cppComplexExpr.vert",
100         "cppDeepNest.frag",
101         "cppPassMacroName.frag",
102         "cppRelaxSkipTokensErrors.vert",
103         "badChars.frag",
104         "pointCoord.frag",
105         "array.frag",
106         "array100.frag",
107         "comment.frag",
108         "300.vert",
109         "300.frag",
110         "300BuiltIns.frag",
111         "300layout.vert",
112         "300layout.frag",
113         "300operations.frag",
114         "300block.frag",
115         "300samplerExternal.frag",
116         "300samplerExternalYUV.frag",
117         "310.comp",
118         "310.vert",
119         "310.geom",
120         "310.frag",
121         "310.tesc",
122         "310.tese",
123         "310implicitSizeArrayError.vert",
124         "310.inheritMemory.frag",
125         "310AofA.vert",
126         "310runtimeArray.vert",
127         "320.comp",
128         "320.vert",
129         "320.geom",
130         "320.frag",
131         "320.tesc",
132         "320.tese",
133         "330.frag",
134         "330comp.frag",
135         "constErrors.frag",
136         "constFold.frag",
137         "constFoldIntMin.frag",
138         "errors.frag",
139         "forwardRef.frag",
140         "uint.frag",
141         "switch.frag",
142         "tokenLength.vert",
143         "100Limits.vert",
144         "100scope.vert",
145         "110scope.vert",
146         "300scope.vert",
147         "400.frag",
148         "400.vert",
149         "410.vert",
150         "420.comp",
151         "420.frag",
152         "420.vert",
153         "420.geom",
154         "420_size_gl_in.geom",
155         "430scope.vert",
156         "lineContinuation100.vert",
157         "lineContinuation.vert",
158         "numeral.frag",
159         "400.geom",
160         "400.tesc",
161         "400.tese",
162         "410.tesc",
163         "420.tesc",
164         "420.tese",
165         "410.geom",
166         "430.vert",
167         "430.comp",
168         "430AofA.frag",
169         "435.vert",
170         "440.vert",
171         "440.frag",
172         "450.vert",
173         "450.geom",
174         "450.tesc",
175         "450.tese",
176         "450.frag",
177         "450.comp",
178         "460.frag",
179         "460.vert",
180         "dce.frag",
181         "atomic_uint.frag",
182         "implicitInnerAtomicUint.frag",
183         "aggOps.frag",
184         "always-discard.frag",
185         "always-discard2.frag",
186         "conditionalDiscard.frag",
187         "conversion.frag",
188         "dataOut.frag",
189         "dataOutIndirect.frag",
190         "deepRvalue.frag",
191         "depthOut.frag",
192         "discard-dce.frag",
193         "doWhileLoop.frag",
194         "earlyReturnDiscard.frag",
195         "flowControl.frag",
196         "forLoop.frag",
197         "functionCall.frag",
198         "functionSemantics.frag",
199         "length.frag",
200         "localAggregates.frag",
201         "loops.frag",
202         "loopsArtificial.frag",
203         "matrix.frag",
204         "matrix2.frag",
205         "mixedArrayDecls.frag",
206         "nonuniform.frag",
207         "newTexture.frag",
208         "Operations.frag",
209         "overlongLiteral.frag",
210         "prepost.frag",
211         "runtimeArray.vert",
212         "simpleFunctionCall.frag",
213         "stringToDouble.vert",
214         "struct.error.frag",
215         "structAssignment.frag",
216         "structDeref.frag",
217         "structure.frag",
218         "swizzle.frag",
219         "invalidSwizzle.vert",
220         "syntaxError.frag",
221         "test.frag",
222         "texture.frag",
223         "tokenPaste.vert",
224         "types.frag",
225         "uniformArray.frag",
226         "variableArrayIndex.frag",
227         "varyingArray.frag",
228         "varyingArrayIndirect.frag",
229         "voidFunction.frag",
230         "whileLoop.frag",
231         "nonVulkan.frag",
232         "negativeArraySize.comp",
233         "precise.tesc",
234         "precise_struct_block.vert",
235         "maxClipDistances.vert",
236         "findFunction.frag",
237         "noMatchingFunction.frag",
238         "constantUnaryConversion.comp",
239         "xfbUnsizedArray.error.vert",
240         "xfbUnsizedArray.error.tese",
241         "glsl.140.layoutOffset.error.vert",
242         "glsl.430.layoutOffset.error.vert",
243         "glsl.450.subgroup.frag",
244         "glsl.450.subgroup.geom",
245         "glsl.450.subgroup.tesc",
246         "glsl.450.subgroup.tese",
247         "glsl.450.subgroup.vert",
248         "glsl.450.subgroupArithmetic.comp",
249         "glsl.450.subgroupBasic.comp",
250         "glsl.450.subgroupBallot.comp",
251         "glsl.450.subgroupBallotNeg.comp",
252         "glsl.450.subgroupClustered.comp",
253         "glsl.450.subgroupClusteredNeg.comp",
254         "glsl.450.subgroupPartitioned.comp",
255         "glsl.450.subgroupShuffle.comp",
256         "glsl.450.subgroupShuffleRelative.comp",
257         "glsl.450.subgroupQuad.comp",
258         "glsl.450.subgroupVote.comp",
259         "glsl.460.subgroup.mesh",
260         "glsl.460.subgroup.task",
261         "glsl.460.subgroup.rahit",
262         "glsl.460.subgroup.rcall",
263         "glsl.460.subgroup.rchit",
264         "glsl.460.subgroup.rgen",
265         "glsl.460.subgroup.rint",
266         "glsl.460.subgroup.rmiss",
267         "glsl.es300.layoutOffset.error.vert",
268         "glsl.es320.subgroup.frag",
269         "glsl.es320.subgroup.geom",
270         "glsl.es320.subgroup.tesc",
271         "glsl.es320.subgroup.tese",
272         "glsl.es320.subgroup.vert",
273         "glsl.es320.subgroupArithmetic.comp",
274         "glsl.es320.subgroupBasic.comp",
275         "glsl.es320.subgroupBallot.comp",
276         "glsl.es320.subgroupBallotNeg.comp",
277         "glsl.es320.subgroupClustered.comp",
278         "glsl.es320.subgroupClusteredNeg.comp",
279         "glsl.es320.subgroupPartitioned.comp",
280         "glsl.es320.subgroupShuffle.comp",
281         "glsl.es320.subgroupShuffleRelative.comp",
282         "glsl.es320.subgroupQuad.comp",
283         "glsl.es320.subgroupVote.comp",
284         "glsl.es320.extTextureShadowLod.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         "textureQueryLOD.frag",
293         "atomicCounterARBOps.vert",
294         "GL_EXT_shader_integer_mix.vert",
295         "GL_ARB_draw_instanced.vert",
296         "GL_ARB_fragment_coord_conventions.vert",
297         "GL_ARB_bindless_texture.frag",
298         "BestMatchFunction.vert",
299         "EndStreamPrimitive.geom",
300         "floatBitsToInt.vert",
301         "coord_conventions.frag",
302         "gl_FragCoord.frag"
303     })),
304     FileNameAsCustomTestSuffix
305 );
306
307 INSTANTIATE_TEST_SUITE_P(
308     Glsl, CompileToAstTestNV,
309     ::testing::ValuesIn(std::vector<std::string>({
310         "nvShaderNoperspectiveInterpolation.frag",
311     })),
312     FileNameAsCustomTestSuffix
313 );
314
315 // clang-format on
316
317 }  // anonymous namespace
318 }  // namespace glslangtest