blob: d2188daa341bd3655f22dfb96fab7e72248d3ca6 [file] [log] [blame]
Olli Etuaho72fc5542016-12-19 19:53:29 +00001//
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
13#include "angle_gl.h"
14#include "compiler/translator/PoolAlloc.h"
15#include "gtest/gtest.h"
16#include "GLSLANG/ShaderLang.h"
17
18namespace sh
19{
20
21class TIntermBlock;
Olli Etuahob12040c2017-06-27 14:20:45 +030022class TIntermNode;
Olli Etuaho72fc5542016-12-19 19:53:29 +000023class TranslatorESSL;
24
25class 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
41 const std::vector<sh::Uniform> getUniforms();
42
43 virtual void initResources(ShBuiltInResources *resources) {}
44 virtual ::GLenum getShaderType() const = 0;
45 virtual ShShaderSpec getShaderSpec() const = 0;
46
47 std::string mInfoLog;
48 ShCompileOptions mExtraCompileOptions;
49
50 TIntermBlock *mASTRoot;
51
52 private:
53 TranslatorESSL *mTranslator;
54
55 TPoolAllocator mAllocator;
56};
57
Olli Etuahob12040c2017-06-27 14:20:45 +030058// Returns true if the node is some kind of a zero node - either constructor or a constant union
59// node.
60bool IsZero(TIntermNode *node);
61
Olli Etuaho72fc5542016-12-19 19:53:29 +000062} // namespace sh
63
64#endif // TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_