blob: 6a39d564212842f96137345043df538d09e5517d [file] [log] [blame]
daniel@transgaming.com91ed1492010-10-29 03:11:43 +00001//
2// Copyright (c) 2002-2010 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
7#ifndef COMPILER_UTIL_H
8#define COMPILER_UTIL_H
9
Jamie Madill77f74852014-07-08 15:02:34 -040010#include <stack>
11
Jamie Madillf51639a2014-06-25 16:04:57 -040012#include "angle_gl.h"
Jamie Madille294bb82014-07-17 14:16:26 -040013#include <GLSLANG/ShaderLang.h>
Jamie Madill13cfd272014-07-17 14:16:28 -040014
15#include "compiler/translator/Types.h"
Jamie Madill033dae62014-06-18 12:56:28 -040016
Zhenyao Mof1d723c2013-09-23 14:57:07 -040017// atof_clamp is like atof but
18// 1. it forces C locale, i.e. forcing '.' as decimal point.
19// 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens.
20// Return false if overflow happens.
21extern bool atof_clamp(const char *str, float *value);
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000022
Zhenyao Mof1d723c2013-09-23 14:57:07 -040023// If overflow happens, clamp the value to INT_MIN or INT_MAX.
24// Return false if overflow happens.
25extern bool atoi_clamp(const char *str, int *value);
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000026
Jamie Madill033dae62014-06-18 12:56:28 -040027namespace sh
28{
29
30GLenum GLVariableType(const TType &type);
31GLenum GLVariablePrecision(const TType &type);
32bool IsVaryingIn(TQualifier qualifier);
33bool IsVaryingOut(TQualifier qualifier);
34bool IsVarying(TQualifier qualifier);
Jamie Madillf2575982014-06-25 16:04:54 -040035InterpolationType GetInterpolationType(TQualifier qualifier);
Jamie Madilld5512cd2014-07-10 17:50:08 -040036BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage);
Jamie Madill033dae62014-06-18 12:56:28 -040037TString ArrayString(const TType &type);
38
Jamie Madill77f74852014-07-08 15:02:34 -040039class GetVariableTraverser
40{
41 public:
Jamie Madill42bcf322014-08-25 16:20:46 -040042 GetVariableTraverser() {}
43
44 template <typename VarT>
45 void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
Jamie Madill77f74852014-07-08 15:02:34 -040046
47 protected:
Jamie Madill28f70c32014-07-18 10:33:10 -040048 // May be overloaded
Jamie Madill42bcf322014-08-25 16:20:46 -040049 virtual void visitVariable(ShaderVariable *newVar) {}
Jamie Madill77f74852014-07-08 15:02:34 -040050
51 private:
Jamie Madill42bcf322014-08-25 16:20:46 -040052 DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
Jamie Madill77f74852014-07-08 15:02:34 -040053};
54
Jamie Madill42bcf322014-08-25 16:20:46 -040055void GetInterfaceBlockFields(const TInterfaceBlock &interfaceBlock, std::vector<InterfaceBlockField> *fieldsOut);
Jamie Madill77f74852014-07-08 15:02:34 -040056
Jamie Madill033dae62014-06-18 12:56:28 -040057}
58
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000059#endif // COMPILER_UTIL_H