• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 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 
13 #include "GLSLANG/ShaderLang.h"
14 #include "angle_gl.h"
15 #include "compiler/translator/PoolAlloc.h"
16 #include "gtest/gtest.h"
17 
18 namespace sh
19 {
20 
21 class TIntermBlock;
22 class TIntermNode;
23 class TranslatorESSL;
24 
25 class ShaderCompileTreeTest : public testing::Test
26 {
27   public:
ShaderCompileTreeTest()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 
41     const std::vector<sh::ShaderVariable> &getUniforms() const;
42     const std::vector<sh::ShaderVariable> &getAttributes() const;
43 
initResources(ShBuiltInResources * resources)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 
56     angle::PoolAllocator mAllocator;
57 };
58 
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 
63 }  // namespace sh
64 
65 #endif  // TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_
66