Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // ShaderCompileTreeTest.h: |
| 7 | // Test that shader validation results in the correct compile status. |
| 8 | // |
| 9 | |
| 10 | #ifndef TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_ |
| 11 | #define TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_ |
| 12 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 13 | #include "GLSLANG/ShaderLang.h" |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 14 | #include "angle_gl.h" |
| 15 | #include "compiler/translator/PoolAlloc.h" |
| 16 | #include "gtest/gtest.h" |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 17 | |
| 18 | namespace sh |
| 19 | { |
| 20 | |
| 21 | class TIntermBlock; |
Olli Etuaho | b12040c | 2017-06-27 14:20:45 +0300 | [diff] [blame] | 22 | class TIntermNode; |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 23 | class TranslatorESSL; |
| 24 | |
| 25 | class ShaderCompileTreeTest : public testing::Test |
| 26 | { |
| 27 | public: |
| 28 | ShaderCompileTreeTest() : mExtraCompileOptions(0) {} |
| 29 | |
| 30 | protected: |
| 31 | void SetUp() override; |
| 32 | |
| 33 | void TearDown() override; |
| 34 | |
| 35 | // Return true when compilation succeeds |
| 36 | bool compile(const std::string &shaderString); |
| 37 | void compileAssumeSuccess(const std::string &shaderString); |
| 38 | |
| 39 | bool hasWarning() const; |
| 40 | |
Martin Radev | 115fc55 | 2017-07-05 17:11:06 +0300 | [diff] [blame] | 41 | const std::vector<sh::Uniform> &getUniforms() const; |
| 42 | const std::vector<sh::Attribute> &getAttributes() const; |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 43 | |
| 44 | virtual void initResources(ShBuiltInResources *resources) {} |
| 45 | virtual ::GLenum getShaderType() const = 0; |
| 46 | virtual ShShaderSpec getShaderSpec() const = 0; |
| 47 | |
| 48 | std::string mInfoLog; |
| 49 | ShCompileOptions mExtraCompileOptions; |
| 50 | |
| 51 | TIntermBlock *mASTRoot; |
| 52 | |
| 53 | private: |
| 54 | TranslatorESSL *mTranslator; |
| 55 | |
Tobin Ehlis | 47ca1b2 | 2019-01-23 16:11:41 +0000 | [diff] [blame^] | 56 | TPoolAllocator mAllocator; |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
Olli Etuaho | b12040c | 2017-06-27 14:20:45 +0300 | [diff] [blame] | 59 | // Returns true if the node is some kind of a zero node - either constructor or a constant union |
| 60 | // node. |
| 61 | bool IsZero(TIntermNode *node); |
| 62 | |
Olli Etuaho | 72fc554 | 2016-12-19 19:53:29 +0000 | [diff] [blame] | 63 | } // namespace sh |
| 64 | |
| 65 | #endif // TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_ |