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 | using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>; |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 45 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 46 | TEST_P(CompileToAstTest, FromFile) |
| 47 | { |
David Neto | 1d3a966 | 2016-10-05 10:25:09 -0400 | [diff] [blame] | 48 | loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), |
John Kessenich | cfea59d | 2019-01-04 17:10:53 +0700 | [diff] [blame] | 49 | Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, |
Lei Zhang | d6f0ed2 | 2016-05-16 12:50:30 -0400 | [diff] [blame] | 50 | Target::AST); |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 51 | } |
| 52 | |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 53 | // Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled). |
| 54 | TEST_P(CompileToAstTestNV, FromFile) |
| 55 | { |
| 56 | loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), |
John Kessenich | cfea59d | 2019-01-04 17:10:53 +0700 | [diff] [blame] | 57 | Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 58 | Target::AST); |
| 59 | } |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 60 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 61 | // clang-format off |
| 62 | INSTANTIATE_TEST_CASE_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", |
David Srbecký | 2c5b3d6 | 2017-09-04 17:33:04 +0100 | [diff] [blame] | 75 | "100samplerExternal.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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", |
John Kessenich | 5866e67 | 2017-10-28 12:55:02 -0600 | [diff] [blame] | 91 | "cppIntMinOverNegativeOne.frag", |
John Kessenich | a84079d | 2019-02-20 03:03:40 -0700 | [diff] [blame] | 92 | "cppMerge.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 93 | "cppNest.vert", |
John Kessenich | 73d4fb5 | 2016-07-30 12:38:17 -0600 | [diff] [blame] | 94 | "cppBad.vert", |
John Kessenich | faa720f | 2017-01-02 17:56:08 -0700 | [diff] [blame] | 95 | "cppBad2.vert", |
John Kessenich | 9840f11 | 2019-02-11 03:05:00 -0700 | [diff] [blame] | 96 | "cppBad3.vert", |
John Kessenich | 6fee944 | 2019-02-16 07:35:13 -0700 | [diff] [blame] | 97 | "cppBad4.vert", |
| 98 | "cppBad5.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 99 | "cppComplexExpr.vert", |
John Kessenich | 7d67c6c | 2017-10-16 15:29:07 -0600 | [diff] [blame] | 100 | "cppDeepNest.frag", |
John Kessenich | 88e22a6 | 2017-11-02 06:48:32 -0600 | [diff] [blame] | 101 | "cppPassMacroName.frag", |
John Kessenich | e7e081b | 2018-03-19 00:43:18 -0600 | [diff] [blame] | 102 | "cppRelaxSkipTokensErrors.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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", |
David Srbecký | 2c5b3d6 | 2017-09-04 17:33:04 +0100 | [diff] [blame] | 115 | "300samplerExternal.frag", |
nicebyte | c28369b | 2019-01-24 12:12:20 -0800 | [diff] [blame] | 116 | "300samplerExternalYUV.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 117 | "310.comp", |
| 118 | "310.vert", |
| 119 | "310.geom", |
| 120 | "310.frag", |
| 121 | "310.tesc", |
| 122 | "310.tese", |
| 123 | "310implicitSizeArrayError.vert", |
John Kessenich | 9a5689f | 2019-08-22 06:58:26 -0600 | [diff] [blame^] | 124 | "310.inheritMemory.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 125 | "310AofA.vert", |
John Kessenich | 5611c6d | 2018-04-05 11:25:02 -0600 | [diff] [blame] | 126 | "310runtimeArray.vert", |
John Kessenich | 53863a3 | 2017-07-23 13:54:15 -0600 | [diff] [blame] | 127 | "320.comp", |
| 128 | "320.vert", |
| 129 | "320.geom", |
| 130 | "320.frag", |
| 131 | "320.tesc", |
| 132 | "320.tese", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 133 | "330.frag", |
| 134 | "330comp.frag", |
| 135 | "constErrors.frag", |
| 136 | "constFold.frag", |
John Kessenich | 5866e67 | 2017-10-28 12:55:02 -0600 | [diff] [blame] | 137 | "constFoldIntMin.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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", |
John Kessenich | 80cb324 | 2016-06-05 18:52:05 -0600 | [diff] [blame] | 148 | "400.vert", |
| 149 | "410.vert", |
John Kessenich | 0f5e3ad | 2016-05-29 18:24:31 -0600 | [diff] [blame] | 150 | "420.comp", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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", |
John Kessenich | 9353f1a | 2017-07-23 11:49:42 -0600 | [diff] [blame] | 169 | "435.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 170 | "440.vert", |
| 171 | "440.frag", |
| 172 | "450.vert", |
| 173 | "450.geom", |
| 174 | "450.tesc", |
| 175 | "450.tese", |
| 176 | "450.frag", |
| 177 | "450.comp", |
John Kessenich | de16e52 | 2017-07-23 14:44:59 -0600 | [diff] [blame] | 178 | "460.frag", |
| 179 | "460.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 180 | "dce.frag", |
| 181 | "atomic_uint.frag", |
John Kessenich | e8d2138 | 2017-11-02 00:05:53 -0600 | [diff] [blame] | 182 | "implicitInnerAtomicUint.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 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", |
John Kessenich | 859b034 | 2018-03-26 00:38:53 -0600 | [diff] [blame] | 205 | "mixedArrayDecls.frag", |
John Kessenich | 5611c6d | 2018-04-05 11:25:02 -0600 | [diff] [blame] | 206 | "nonuniform.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 207 | "newTexture.frag", |
| 208 | "Operations.frag", |
Aaron Muir Hamilton | 9028ed2 | 2017-10-22 17:41:13 +0000 | [diff] [blame] | 209 | "overlongLiteral.frag", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 210 | "prepost.frag", |
John Kessenich | 6a4a427 | 2018-04-02 14:52:15 -0600 | [diff] [blame] | 211 | "runtimeArray.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 212 | "simpleFunctionCall.frag", |
John Kessenich | 1ea1b13 | 2018-05-24 18:11:47 -0600 | [diff] [blame] | 213 | "stringToDouble.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 214 | "structAssignment.frag", |
| 215 | "structDeref.frag", |
| 216 | "structure.frag", |
| 217 | "swizzle.frag", |
Aaron Muir Hamilton | 5313613 | 2017-10-17 08:11:33 +0000 | [diff] [blame] | 218 | "invalidSwizzle.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 219 | "syntaxError.frag", |
| 220 | "test.frag", |
| 221 | "texture.frag", |
John Kessenich | d485e0b | 2016-12-19 09:19:43 -0700 | [diff] [blame] | 222 | "tokenPaste.vert", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 223 | "types.frag", |
| 224 | "uniformArray.frag", |
| 225 | "variableArrayIndex.frag", |
| 226 | "varyingArray.frag", |
| 227 | "varyingArrayIndirect.frag", |
| 228 | "voidFunction.frag", |
| 229 | "whileLoop.frag", |
| 230 | "nonVulkan.frag", |
Lei Zhang | 48e296b | 2016-05-04 14:35:16 -0400 | [diff] [blame] | 231 | "negativeArraySize.comp", |
Lei Zhang | 48e296b | 2016-05-04 14:35:16 -0400 | [diff] [blame] | 232 | "precise.tesc", |
| 233 | "precise_struct_block.vert", |
| 234 | "maxClipDistances.vert", |
John Kessenich | 66011cb | 2018-03-06 16:12:04 -0700 | [diff] [blame] | 235 | "findFunction.frag", |
Daniel Koch | 83170e3 | 2019-03-26 13:45:33 -0400 | [diff] [blame] | 236 | "constantUnaryConversion.comp", |
| 237 | "glsl.450.subgroup.frag", |
| 238 | "glsl.450.subgroup.geom", |
| 239 | "glsl.450.subgroup.tesc", |
| 240 | "glsl.450.subgroup.tese", |
| 241 | "glsl.450.subgroup.vert", |
| 242 | "glsl.450.subgroupArithmetic.comp", |
| 243 | "glsl.450.subgroupBasic.comp", |
| 244 | "glsl.450.subgroupBallot.comp", |
| 245 | "glsl.450.subgroupBallotNeg.comp", |
| 246 | "glsl.450.subgroupClustered.comp", |
| 247 | "glsl.450.subgroupClusteredNeg.comp", |
| 248 | "glsl.450.subgroupPartitioned.comp", |
| 249 | "glsl.450.subgroupShuffle.comp", |
| 250 | "glsl.450.subgroupShuffleRelative.comp", |
| 251 | "glsl.450.subgroupQuad.comp", |
| 252 | "glsl.450.subgroupVote.comp", |
Daniel Koch | 3418cb4 | 2019-05-30 01:08:41 -0400 | [diff] [blame] | 253 | "glsl.460.subgroup.mesh", |
| 254 | "glsl.460.subgroup.task", |
Daniel Koch | c3e60ad | 2019-05-30 19:40:20 -0400 | [diff] [blame] | 255 | "glsl.460.subgroup.rahit", |
| 256 | "glsl.460.subgroup.rcall", |
| 257 | "glsl.460.subgroup.rchit", |
| 258 | "glsl.460.subgroup.rgen", |
| 259 | "glsl.460.subgroup.rint", |
| 260 | "glsl.460.subgroup.rmiss", |
Daniel Koch | 83170e3 | 2019-03-26 13:45:33 -0400 | [diff] [blame] | 261 | "glsl.es320.subgroup.frag", |
| 262 | "glsl.es320.subgroup.geom", |
| 263 | "glsl.es320.subgroup.tesc", |
| 264 | "glsl.es320.subgroup.tese", |
| 265 | "glsl.es320.subgroup.vert", |
| 266 | "glsl.es320.subgroupArithmetic.comp", |
| 267 | "glsl.es320.subgroupBasic.comp", |
| 268 | "glsl.es320.subgroupBallot.comp", |
| 269 | "glsl.es320.subgroupBallotNeg.comp", |
| 270 | "glsl.es320.subgroupClustered.comp", |
| 271 | "glsl.es320.subgroupClusteredNeg.comp", |
| 272 | "glsl.es320.subgroupPartitioned.comp", |
| 273 | "glsl.es320.subgroupShuffle.comp", |
| 274 | "glsl.es320.subgroupShuffleRelative.comp", |
| 275 | "glsl.es320.subgroupQuad.comp", |
| 276 | "glsl.es320.subgroupVote.comp", |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 277 | })), |
Lei Zhang | d6f0ed2 | 2016-05-16 12:50:30 -0400 | [diff] [blame] | 278 | FileNameAsCustomTestSuffix |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 279 | ); |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 280 | |
Ben Clayton | f648083 | 2018-03-16 13:15:48 +0000 | [diff] [blame] | 281 | INSTANTIATE_TEST_CASE_P( |
| 282 | Glsl, CompileToAstTestNV, |
| 283 | ::testing::ValuesIn(std::vector<std::string>({ |
| 284 | "nvShaderNoperspectiveInterpolation.frag", |
| 285 | })), |
| 286 | FileNameAsCustomTestSuffix |
| 287 | ); |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 288 | // clang-format on |
| 289 | |
| 290 | } // anonymous namespace |
| 291 | } // namespace glslangtest |