Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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 | |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 44 | #ifdef NV_EXTENSIONS |
| 45 | using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>; |
| 46 | #endif |
| 47 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 48 | TEST_P(CompileToAstTest, FromFile) |
| 49 | { |
David Neto | 1d3a966 | 2016-10-05 10:25:09 -0400 | [diff] [blame] | 50 | loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), |
John Kessenich | 66011cb | 2018-03-06 16:12:04 -0700 | [diff] [blame] | 51 | Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, |
Lei Zhang | d6f0ed2 | 2016-05-16 12:50:30 -0400 | [diff] [blame] | 52 | Target::AST); |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 55 | #ifdef NV_EXTENSIONS |
| 56 | // Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled). |
| 57 | TEST_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 Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 65 | // clang-format off |
| 66 | INSTANTIATE_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ý | 2c5b3d6 | 2017-09-04 17:33:04 +0100 | [diff] [blame] | 79 | "100samplerExternal.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 80 | "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 Kessenich | 5866e67 | 2017-10-28 12:55:02 -0600 | [diff] [blame] | 95 | "cppIntMinOverNegativeOne.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 96 | "cppNest.vert", |
John Kessenich | 73d4fb5 | 2016-07-30 12:38:17 -0600 | [diff] [blame] | 97 | "cppBad.vert", |
John Kessenich | faa720f | 2017-01-02 17:56:08 -0700 | [diff] [blame] | 98 | "cppBad2.vert", |
John Kessenich | 9840f11 | 2019-02-11 03:05:00 -0700 | [diff] [blame] | 99 | "cppBad3.vert", |
John Kessenich | 6fee944 | 2019-02-16 07:35:13 -0700 | [diff] [blame^] | 100 | "cppBad4.vert", |
| 101 | "cppBad5.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 102 | "cppComplexExpr.vert", |
John Kessenich | 7d67c6c | 2017-10-16 15:29:07 -0600 | [diff] [blame] | 103 | "cppDeepNest.frag", |
John Kessenich | 88e22a6 | 2017-11-02 06:48:32 -0600 | [diff] [blame] | 104 | "cppPassMacroName.frag", |
John Kessenich | e7e081b | 2018-03-19 00:43:18 -0600 | [diff] [blame] | 105 | "cppRelaxSkipTokensErrors.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 106 | "badChars.frag", |
| 107 | "pointCoord.frag", |
| 108 | "array.frag", |
| 109 | "array100.frag", |
| 110 | "comment.frag", |
| 111 | "300.vert", |
| 112 | "300.frag", |
| 113 | "300BuiltIns.frag", |
| 114 | "300layout.vert", |
| 115 | "300layout.frag", |
| 116 | "300operations.frag", |
| 117 | "300block.frag", |
David Srbecký | 2c5b3d6 | 2017-09-04 17:33:04 +0100 | [diff] [blame] | 118 | "300samplerExternal.frag", |
nicebyte | c28369b | 2019-01-24 12:12:20 -0800 | [diff] [blame] | 119 | "300samplerExternalYUV.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 120 | "310.comp", |
| 121 | "310.vert", |
| 122 | "310.geom", |
| 123 | "310.frag", |
| 124 | "310.tesc", |
| 125 | "310.tese", |
| 126 | "310implicitSizeArrayError.vert", |
| 127 | "310AofA.vert", |
John Kessenich | 5611c6d | 2018-04-05 11:25:02 -0600 | [diff] [blame] | 128 | "310runtimeArray.vert", |
John Kessenich | 53863a3 | 2017-07-23 13:54:15 -0600 | [diff] [blame] | 129 | "320.comp", |
| 130 | "320.vert", |
| 131 | "320.geom", |
| 132 | "320.frag", |
| 133 | "320.tesc", |
| 134 | "320.tese", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 135 | "330.frag", |
| 136 | "330comp.frag", |
| 137 | "constErrors.frag", |
| 138 | "constFold.frag", |
John Kessenich | 5866e67 | 2017-10-28 12:55:02 -0600 | [diff] [blame] | 139 | "constFoldIntMin.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 140 | "errors.frag", |
| 141 | "forwardRef.frag", |
| 142 | "uint.frag", |
| 143 | "switch.frag", |
| 144 | "tokenLength.vert", |
| 145 | "100Limits.vert", |
| 146 | "100scope.vert", |
| 147 | "110scope.vert", |
| 148 | "300scope.vert", |
| 149 | "400.frag", |
John Kessenich | 80cb324 | 2016-06-05 18:52:05 -0600 | [diff] [blame] | 150 | "400.vert", |
| 151 | "410.vert", |
John Kessenich | 0f5e3ad | 2016-05-29 18:24:31 -0600 | [diff] [blame] | 152 | "420.comp", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 153 | "420.frag", |
| 154 | "420.vert", |
| 155 | "420.geom", |
| 156 | "420_size_gl_in.geom", |
| 157 | "430scope.vert", |
| 158 | "lineContinuation100.vert", |
| 159 | "lineContinuation.vert", |
| 160 | "numeral.frag", |
| 161 | "400.geom", |
| 162 | "400.tesc", |
| 163 | "400.tese", |
| 164 | "410.tesc", |
| 165 | "420.tesc", |
| 166 | "420.tese", |
| 167 | "410.geom", |
| 168 | "430.vert", |
| 169 | "430.comp", |
| 170 | "430AofA.frag", |
John Kessenich | 9353f1a | 2017-07-23 11:49:42 -0600 | [diff] [blame] | 171 | "435.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 172 | "440.vert", |
| 173 | "440.frag", |
| 174 | "450.vert", |
| 175 | "450.geom", |
| 176 | "450.tesc", |
| 177 | "450.tese", |
| 178 | "450.frag", |
| 179 | "450.comp", |
John Kessenich | de16e52 | 2017-07-23 14:44:59 -0600 | [diff] [blame] | 180 | "460.frag", |
| 181 | "460.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 182 | "dce.frag", |
| 183 | "atomic_uint.frag", |
John Kessenich | e8d2138 | 2017-11-02 00:05:53 -0600 | [diff] [blame] | 184 | "implicitInnerAtomicUint.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 185 | "aggOps.frag", |
| 186 | "always-discard.frag", |
| 187 | "always-discard2.frag", |
| 188 | "conditionalDiscard.frag", |
| 189 | "conversion.frag", |
| 190 | "dataOut.frag", |
| 191 | "dataOutIndirect.frag", |
| 192 | "deepRvalue.frag", |
| 193 | "depthOut.frag", |
| 194 | "discard-dce.frag", |
| 195 | "doWhileLoop.frag", |
| 196 | "earlyReturnDiscard.frag", |
| 197 | "flowControl.frag", |
| 198 | "forLoop.frag", |
| 199 | "functionCall.frag", |
| 200 | "functionSemantics.frag", |
| 201 | "length.frag", |
| 202 | "localAggregates.frag", |
| 203 | "loops.frag", |
| 204 | "loopsArtificial.frag", |
| 205 | "matrix.frag", |
| 206 | "matrix2.frag", |
John Kessenich | 859b034 | 2018-03-26 00:38:53 -0600 | [diff] [blame] | 207 | "mixedArrayDecls.frag", |
John Kessenich | 5611c6d | 2018-04-05 11:25:02 -0600 | [diff] [blame] | 208 | "nonuniform.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 209 | "newTexture.frag", |
| 210 | "Operations.frag", |
Aaron Muir Hamilton | 9028ed2 | 2017-10-22 17:41:13 +0000 | [diff] [blame] | 211 | "overlongLiteral.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 212 | "prepost.frag", |
John Kessenich | 6a4a427 | 2018-04-02 14:52:15 -0600 | [diff] [blame] | 213 | "runtimeArray.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 214 | "simpleFunctionCall.frag", |
John Kessenich | 1ea1b13 | 2018-05-24 18:11:47 -0600 | [diff] [blame] | 215 | "stringToDouble.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 216 | "structAssignment.frag", |
| 217 | "structDeref.frag", |
| 218 | "structure.frag", |
| 219 | "swizzle.frag", |
Aaron Muir Hamilton | 5313613 | 2017-10-17 08:11:33 +0000 | [diff] [blame] | 220 | "invalidSwizzle.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 221 | "syntaxError.frag", |
| 222 | "test.frag", |
| 223 | "texture.frag", |
John Kessenich | d485e0b | 2016-12-19 09:19:43 -0700 | [diff] [blame] | 224 | "tokenPaste.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 225 | "types.frag", |
| 226 | "uniformArray.frag", |
| 227 | "variableArrayIndex.frag", |
| 228 | "varyingArray.frag", |
| 229 | "varyingArrayIndirect.frag", |
| 230 | "voidFunction.frag", |
| 231 | "whileLoop.frag", |
| 232 | "nonVulkan.frag", |
Lei Zhang | 48e296b | 2016-05-04 14:35:16 -0400 | [diff] [blame] | 233 | "negativeArraySize.comp", |
Lei Zhang | 48e296b | 2016-05-04 14:35:16 -0400 | [diff] [blame] | 234 | "precise.tesc", |
| 235 | "precise_struct_block.vert", |
| 236 | "maxClipDistances.vert", |
John Kessenich | 66011cb | 2018-03-06 16:12:04 -0700 | [diff] [blame] | 237 | "findFunction.frag", |
Neil Henning | 81a63f1 | 2018-11-26 10:17:33 +0000 | [diff] [blame] | 238 | "constantUnaryConversion.comp" |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 239 | })), |
Lei Zhang | d6f0ed2 | 2016-05-16 12:50:30 -0400 | [diff] [blame] | 240 | FileNameAsCustomTestSuffix |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 241 | ); |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 242 | |
| 243 | #ifdef NV_EXTENSIONS |
| 244 | INSTANTIATE_TEST_CASE_P( |
| 245 | Glsl, CompileToAstTestNV, |
| 246 | ::testing::ValuesIn(std::vector<std::string>({ |
| 247 | "nvShaderNoperspectiveInterpolation.frag", |
| 248 | })), |
| 249 | FileNameAsCustomTestSuffix |
| 250 | ); |
| 251 | #endif |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 252 | // clang-format on |
| 253 | |
| 254 | } // anonymous namespace |
| 255 | } // namespace glslangtest |