13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RSGGENERATORSTATE_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RSGGENERATORSTATE_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Random Shader Generator
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ----------------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Generator state.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rsgDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rsgParameters.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rsgNameAllocator.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rsg
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Shader;
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VariableManager;
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VariableType;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Statement;
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum ExpressionFlags
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CONST_EXPR			= (1<<0),
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	NO_VAR_ALLOCATION	= (1<<1)
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRECEDENCE_MAX		= 100
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GeneratorState
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								GeneratorState				(const ProgramParameters& programParams, de::Random& random);
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~GeneratorState				(void);
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ProgramParameters&	getProgramParameters		(void) const	{ return m_programParams;	}
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random&					getRandom					(void)			{ return m_random;			}
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ShaderParameters&		getShaderParameters			(void) const	{ return *m_shaderParams;	}
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Shader&						getShader					(void)			{ return *m_shader;			}
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setShader					(const ShaderParameters& params, Shader& shader);
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	NameAllocator&				getNameAllocator			(void)							{ return m_nameAllocator;		}
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VariableManager&			getVariableManager			(void)							{ return *m_varManager;			}
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const VariableManager&		getVariableManager			(void) const					{ return *m_varManager;			}
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setVariableManager			(VariableManager& varManager)	{ m_varManager = &varManager;	}
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2011-06-10 pyry] Could we not expose whole statement stack to everyone?
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getStatementDepth			(void) const						{ return (int)m_statementStack->size();	}
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setStatementStack			(std::vector<Statement*>& stack)	{ m_statementStack = &stack;			}
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Statement*			getStatementStackEntry		(int ndx) const						{ return m_statementStack->at(ndx);		}
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getExpressionDepth			(void) const					{ return m_expressionDepth;		}
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setExpressionDepth			(int depth)						{ m_expressionDepth = depth;	}
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2011-03-21 pyry] A bit of a hack... Move to ValueRange?
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					getExpressionFlags			(void) const					{ return m_exprFlagStack.back();	}
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						pushExpressionFlags			(deUint32 flags)				{ m_exprFlagStack.push_back(flags);	}
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						popExpressionFlags			(void)							{ m_exprFlagStack.pop_back();		}
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getPrecedence				(void) const					{ return m_precedenceStack.back();			}
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						pushPrecedence				(int precedence)				{ m_precedenceStack.push_back(precedence);	}
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						popPrecedence				(void)							{ m_precedenceStack.pop_back();				}
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ProgramParameters&	m_programParams;
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random&					m_random;
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ShaderParameters*		m_shaderParams;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Shader*						m_shader;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	NameAllocator				m_nameAllocator;
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VariableManager*			m_varManager;
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<Statement*>*	m_statementStack;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_expressionDepth;
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<deUint32>		m_exprFlagStack;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<int>			m_precedenceStack;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rsg
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RSGGENERATORSTATE_HPP
107