blob: a821351df821d3b5976f6d99fa4e0e89aebdb739 [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
Jamie Madillb980c562018-11-27 11:34:27 -050013#include "GLSLANG/ShaderLang.h"
Olli Etuaho72fc5542016-12-19 19:53:29 +000014#include "angle_gl.h"
15#include "compiler/translator/PoolAlloc.h"
16#include "gtest/gtest.h"
Olli Etuaho72fc5542016-12-19 19:53:29 +000017
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
Martin Radev115fc552017-07-05 17:11:06 +030041 const std::vector<sh::Uniform> &getUniforms() const;
42 const std::vector<sh::Attribute> &getAttributes() const;
Olli Etuaho72fc5542016-12-19 19:53:29 +000043
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 TPoolAllocator mAllocator;
57};
58
Olli Etuahob12040c2017-06-27 14:20:45 +030059// Returns true if the node is some kind of a zero node - either constructor or a constant union
60// node.
61bool IsZero(TIntermNode *node);
62
Olli Etuaho72fc5542016-12-19 19:53:29 +000063} // namespace sh
64
65#endif // TESTS_TEST_UTILS_SHADER_COMPILE_TREE_TEST_H_