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 #ifdef NV_EXTENSIONS 45 using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>; 46 #endif 47 48 TEST_P(CompileToAstTest, FromFile) 49 { 50 loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), 51 Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, 52 Target::AST); 53 } 54 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 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", 79 "100samplerExternal.frag", 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", 95 "cppIntMinOverNegativeOne.frag", 96 "cppNest.vert", 97 "cppBad.vert", 98 "cppBad2.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 "310.comp", 117 "310.vert", 118 "310.geom", 119 "310.frag", 120 "310.tesc", 121 "310.tese", 122 "310implicitSizeArrayError.vert", 123 "310AofA.vert", 124 "310runtimeArray.vert", 125 "320.comp", 126 "320.vert", 127 "320.geom", 128 "320.frag", 129 "320.tesc", 130 "320.tese", 131 "330.frag", 132 "330comp.frag", 133 "constErrors.frag", 134 "constFold.frag", 135 "constFoldIntMin.frag", 136 "errors.frag", 137 "forwardRef.frag", 138 "uint.frag", 139 "switch.frag", 140 "tokenLength.vert", 141 "100Limits.vert", 142 "100scope.vert", 143 "110scope.vert", 144 "300scope.vert", 145 "400.frag", 146 "400.vert", 147 "410.vert", 148 "420.comp", 149 "420.frag", 150 "420.vert", 151 "420.geom", 152 "420_size_gl_in.geom", 153 "430scope.vert", 154 "lineContinuation100.vert", 155 "lineContinuation.vert", 156 "numeral.frag", 157 "400.geom", 158 "400.tesc", 159 "400.tese", 160 "410.tesc", 161 "420.tesc", 162 "420.tese", 163 "410.geom", 164 "430.vert", 165 "430.comp", 166 "430AofA.frag", 167 "435.vert", 168 "440.vert", 169 "440.frag", 170 "450.vert", 171 "450.geom", 172 "450.tesc", 173 "450.tese", 174 "450.frag", 175 "450.comp", 176 "460.frag", 177 "460.vert", 178 "dce.frag", 179 "atomic_uint.frag", 180 "implicitInnerAtomicUint.frag", 181 "aggOps.frag", 182 "always-discard.frag", 183 "always-discard2.frag", 184 "conditionalDiscard.frag", 185 "conversion.frag", 186 "dataOut.frag", 187 "dataOutIndirect.frag", 188 "deepRvalue.frag", 189 "depthOut.frag", 190 "discard-dce.frag", 191 "doWhileLoop.frag", 192 "earlyReturnDiscard.frag", 193 "flowControl.frag", 194 "forLoop.frag", 195 "functionCall.frag", 196 "functionSemantics.frag", 197 "length.frag", 198 "localAggregates.frag", 199 "loops.frag", 200 "loopsArtificial.frag", 201 "matrix.frag", 202 "matrix2.frag", 203 "mixedArrayDecls.frag", 204 "nonuniform.frag", 205 "newTexture.frag", 206 "Operations.frag", 207 "overlongLiteral.frag", 208 "prepost.frag", 209 "runtimeArray.vert", 210 "simpleFunctionCall.frag", 211 "stringToDouble.vert", 212 "structAssignment.frag", 213 "structDeref.frag", 214 "structure.frag", 215 "swizzle.frag", 216 "invalidSwizzle.vert", 217 "syntaxError.frag", 218 "test.frag", 219 "texture.frag", 220 "tokenPaste.vert", 221 "types.frag", 222 "uniformArray.frag", 223 "variableArrayIndex.frag", 224 "varyingArray.frag", 225 "varyingArrayIndirect.frag", 226 "voidFunction.frag", 227 "whileLoop.frag", 228 "nonVulkan.frag", 229 "negativeArraySize.comp", 230 "precise.tesc", 231 "precise_struct_block.vert", 232 "maxClipDistances.vert", 233 "findFunction.frag", 234 "constantUnaryConversion.comp" 235 })), 236 FileNameAsCustomTestSuffix 237 ); 238 239 #ifdef NV_EXTENSIONS 240 INSTANTIATE_TEST_CASE_P( 241 Glsl, CompileToAstTestNV, 242 ::testing::ValuesIn(std::vector<std::string>({ 243 "nvShaderNoperspectiveInterpolation.frag", 244 })), 245 FileNameAsCustomTestSuffix 246 ); 247 #endif 248 // clang-format on 249 250 } // anonymous namespace 251 } // namespace glslangtest 252