blob: 061c86c305de8f0273f1cb8c9e16574e41ed8cb1 [file] [log] [blame]
Lei Zhang414eb602016-03-04 16:22:34 -05001//
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
39namespace glslangtest {
40namespace {
41
42using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
43
Ben Claytonf6480832018-03-16 13:15:48 +000044#ifdef NV_EXTENSIONS
45using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
46#endif
47
Lei Zhang414eb602016-03-04 16:22:34 -050048TEST_P(CompileToAstTest, FromFile)
49{
David Neto1d3a9662016-10-05 10:25:09 -040050 loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
John Kessenich66011cb2018-03-06 16:12:04 -070051 Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Lei Zhangd6f0ed22016-05-16 12:50:30 -040052 Target::AST);
Lei Zhang414eb602016-03-04 16:22:34 -050053}
54
Ben Claytonf6480832018-03-16 13:15:48 +000055#ifdef NV_EXTENSIONS
56// Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
57TEST_P(CompileToAstTestNV, FromFile)
58{
59 loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
60 Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
61 Target::AST);
62}
63#endif
64
Lei Zhang414eb602016-03-04 16:22:34 -050065// clang-format off
66INSTANTIATE_TEST_CASE_P(
67 Glsl, CompileToAstTest,
68 ::testing::ValuesIn(std::vector<std::string>({
69 "sample.frag",
70 "sample.vert",
71 "decls.frag",
72 "specExamples.frag",
73 "specExamples.vert",
74 "versionsClean.frag",
75 "versionsClean.vert",
76 "versionsErrors.frag",
77 "versionsErrors.vert",
78 "100.frag",
David Srbecký2c5b3d62017-09-04 17:33:04 +010079 "100samplerExternal.frag",
Lei Zhang414eb602016-03-04 16:22:34 -050080 "120.vert",
81 "120.frag",
82 "130.vert",
83 "130.frag",
84 "140.vert",
85 "140.frag",
86 "150.vert",
87 "150.geom",
88 "150.frag",
89 "precision.frag",
90 "precision.vert",
91 "nonSquare.vert",
92 "matrixError.vert",
93 "cppSimple.vert",
94 "cppIndent.vert",
John Kessenich5866e672017-10-28 12:55:02 -060095 "cppIntMinOverNegativeOne.frag",
Lei Zhang414eb602016-03-04 16:22:34 -050096 "cppNest.vert",
John Kessenich73d4fb52016-07-30 12:38:17 -060097 "cppBad.vert",
John Kessenichfaa720f2017-01-02 17:56:08 -070098 "cppBad2.vert",
Lei Zhang414eb602016-03-04 16:22:34 -050099 "cppComplexExpr.vert",
John Kessenich7d67c6c2017-10-16 15:29:07 -0600100 "cppDeepNest.frag",
John Kessenich88e22a62017-11-02 06:48:32 -0600101 "cppPassMacroName.frag",
John Kesseniche7e081b2018-03-19 00:43:18 -0600102 "cppRelaxSkipTokensErrors.vert",
Lei Zhang414eb602016-03-04 16:22:34 -0500103 "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",
David Srbecký2c5b3d62017-09-04 17:33:04 +0100115 "300samplerExternal.frag",
Lei Zhang414eb602016-03-04 16:22:34 -0500116 "310.comp",
117 "310.vert",
118 "310.geom",
119 "310.frag",
120 "310.tesc",
121 "310.tese",
122 "310implicitSizeArrayError.vert",
123 "310AofA.vert",
John Kessenich53863a32017-07-23 13:54:15 -0600124 "320.comp",
125 "320.vert",
126 "320.geom",
127 "320.frag",
128 "320.tesc",
129 "320.tese",
Lei Zhang414eb602016-03-04 16:22:34 -0500130 "330.frag",
131 "330comp.frag",
132 "constErrors.frag",
133 "constFold.frag",
John Kessenich5866e672017-10-28 12:55:02 -0600134 "constFoldIntMin.frag",
Lei Zhang414eb602016-03-04 16:22:34 -0500135 "errors.frag",
136 "forwardRef.frag",
137 "uint.frag",
138 "switch.frag",
139 "tokenLength.vert",
140 "100Limits.vert",
141 "100scope.vert",
142 "110scope.vert",
143 "300scope.vert",
144 "400.frag",
John Kessenich80cb3242016-06-05 18:52:05 -0600145 "400.vert",
146 "410.vert",
John Kessenich0f5e3ad2016-05-29 18:24:31 -0600147 "420.comp",
Lei Zhang414eb602016-03-04 16:22:34 -0500148 "420.frag",
149 "420.vert",
150 "420.geom",
151 "420_size_gl_in.geom",
152 "430scope.vert",
153 "lineContinuation100.vert",
154 "lineContinuation.vert",
155 "numeral.frag",
156 "400.geom",
157 "400.tesc",
158 "400.tese",
159 "410.tesc",
160 "420.tesc",
161 "420.tese",
162 "410.geom",
163 "430.vert",
164 "430.comp",
165 "430AofA.frag",
John Kessenich9353f1a2017-07-23 11:49:42 -0600166 "435.vert",
Lei Zhang414eb602016-03-04 16:22:34 -0500167 "440.vert",
168 "440.frag",
169 "450.vert",
170 "450.geom",
171 "450.tesc",
172 "450.tese",
173 "450.frag",
174 "450.comp",
John Kessenichde16e522017-07-23 14:44:59 -0600175 "460.frag",
176 "460.vert",
Lei Zhang414eb602016-03-04 16:22:34 -0500177 "dce.frag",
178 "atomic_uint.frag",
John Kesseniche8d21382017-11-02 00:05:53 -0600179 "implicitInnerAtomicUint.frag",
Lei Zhang414eb602016-03-04 16:22:34 -0500180 "aggOps.frag",
181 "always-discard.frag",
182 "always-discard2.frag",
183 "conditionalDiscard.frag",
184 "conversion.frag",
185 "dataOut.frag",
186 "dataOutIndirect.frag",
187 "deepRvalue.frag",
188 "depthOut.frag",
189 "discard-dce.frag",
190 "doWhileLoop.frag",
191 "earlyReturnDiscard.frag",
192 "flowControl.frag",
193 "forLoop.frag",
194 "functionCall.frag",
195 "functionSemantics.frag",
196 "length.frag",
197 "localAggregates.frag",
198 "loops.frag",
199 "loopsArtificial.frag",
200 "matrix.frag",
201 "matrix2.frag",
202 "newTexture.frag",
203 "Operations.frag",
Aaron Muir Hamilton9028ed22017-10-22 17:41:13 +0000204 "overlongLiteral.frag",
Lei Zhang414eb602016-03-04 16:22:34 -0500205 "prepost.frag",
206 "simpleFunctionCall.frag",
207 "structAssignment.frag",
208 "structDeref.frag",
209 "structure.frag",
210 "swizzle.frag",
Aaron Muir Hamilton53136132017-10-17 08:11:33 +0000211 "invalidSwizzle.vert",
Lei Zhang414eb602016-03-04 16:22:34 -0500212 "syntaxError.frag",
213 "test.frag",
214 "texture.frag",
John Kessenichd485e0b2016-12-19 09:19:43 -0700215 "tokenPaste.vert",
Lei Zhang414eb602016-03-04 16:22:34 -0500216 "types.frag",
217 "uniformArray.frag",
218 "variableArrayIndex.frag",
219 "varyingArray.frag",
220 "varyingArrayIndirect.frag",
221 "voidFunction.frag",
222 "whileLoop.frag",
223 "nonVulkan.frag",
Lei Zhang48e296b2016-05-04 14:35:16 -0400224 "negativeArraySize.comp",
Lei Zhang48e296b2016-05-04 14:35:16 -0400225 "precise.tesc",
226 "precise_struct_block.vert",
227 "maxClipDistances.vert",
John Kessenich66011cb2018-03-06 16:12:04 -0700228 "findFunction.frag",
Lei Zhang414eb602016-03-04 16:22:34 -0500229 })),
Lei Zhangd6f0ed22016-05-16 12:50:30 -0400230 FileNameAsCustomTestSuffix
Lei Zhang414eb602016-03-04 16:22:34 -0500231);
Ben Claytonf6480832018-03-16 13:15:48 +0000232
233#ifdef NV_EXTENSIONS
234INSTANTIATE_TEST_CASE_P(
235 Glsl, CompileToAstTestNV,
236 ::testing::ValuesIn(std::vector<std::string>({
237 "nvShaderNoperspectiveInterpolation.frag",
238 })),
239 FileNameAsCustomTestSuffix
240);
241#endif
Lei Zhang414eb602016-03-04 16:22:34 -0500242// clang-format on
243
244} // anonymous namespace
245} // namespace glslangtest