1 #ifndef _RSGGENERATORSTATE_HPP
2 #define _RSGGENERATORSTATE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Random Shader Generator
5 * ----------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Generator state.
24 *//*--------------------------------------------------------------------*/
26 #include "rsgDefs.hpp"
27 #include "rsgParameters.hpp"
28 #include "deRandom.hpp"
29 #include "rsgNameAllocator.hpp"
37 class VariableManager;
44 NO_VAR_ALLOCATION = (1<<1)
55 GeneratorState (const ProgramParameters& programParams, de::Random& random);
56 ~GeneratorState (void);
58 const ProgramParameters& getProgramParameters (void) const { return m_programParams; }
59 de::Random& getRandom (void) { return m_random; }
61 const ShaderParameters& getShaderParameters (void) const { return *m_shaderParams; }
62 Shader& getShader (void) { return *m_shader; }
64 void setShader (const ShaderParameters& params, Shader& shader);
66 NameAllocator& getNameAllocator (void) { return m_nameAllocator; }
67 VariableManager& getVariableManager (void) { return *m_varManager; }
68 const VariableManager& getVariableManager (void) const { return *m_varManager; }
69 void setVariableManager (VariableManager& varManager) { m_varManager = &varManager; }
71 // \todo [2011-06-10 pyry] Could we not expose whole statement stack to everyone?
72 int getStatementDepth (void) const { return (int)m_statementStack->size(); }
73 void setStatementStack (std::vector<Statement*>& stack) { m_statementStack = &stack; }
74 const Statement* getStatementStackEntry (int ndx) const { return m_statementStack->at(ndx); }
76 int getExpressionDepth (void) const { return m_expressionDepth; }
77 void setExpressionDepth (int depth) { m_expressionDepth = depth; }
79 // \todo [2011-03-21 pyry] A bit of a hack... Move to ValueRange?
80 deUint32 getExpressionFlags (void) const { return m_exprFlagStack.back(); }
81 void pushExpressionFlags (deUint32 flags) { m_exprFlagStack.push_back(flags); }
82 void popExpressionFlags (void) { m_exprFlagStack.pop_back(); }
84 int getPrecedence (void) const { return m_precedenceStack.back(); }
85 void pushPrecedence (int precedence) { m_precedenceStack.push_back(precedence); }
86 void popPrecedence (void) { m_precedenceStack.pop_back(); }
89 const ProgramParameters& m_programParams;
92 const ShaderParameters* m_shaderParams;
95 NameAllocator m_nameAllocator;
96 VariableManager* m_varManager;
98 std::vector<Statement*>* m_statementStack;
99 int m_expressionDepth;
100 std::vector<deUint32> m_exprFlagStack;
101 std::vector<int> m_precedenceStack;
106 #endif // _RSGGENERATORSTATE_HPP