Home | History | Annotate | Download | only in randomshaders
      1 #ifndef _RSGVARIABLE_HPP
      2 #define _RSGVARIABLE_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program Random Shader Generator
      5  * ----------------------------------------------------
      6  *
      7  * Copyright 2014 The Android Open Source Project
      8  *
      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
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     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.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Variable class.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "rsgDefs.hpp"
     27 #include "rsgVariableType.hpp"
     28 #include "rsgToken.hpp"
     29 
     30 #include <string>
     31 
     32 namespace rsg
     33 {
     34 
     35 class GeneratorState;
     36 
     37 class Variable
     38 {
     39 public:
     40 	enum Storage
     41 	{
     42 		STORAGE_LOCAL,
     43 		STORAGE_SHADER_IN,
     44 		STORAGE_SHADER_OUT,
     45 		STORAGE_UNIFORM,
     46 		STORAGE_CONST,
     47 		STORAGE_PARAMETER_IN,
     48 		STORAGE_PARAMETER_OUT,
     49 		STORAGE_PARAMETER_INOUT,
     50 
     51 		STORAGE_LAST
     52 	};
     53 
     54 								Variable			(const VariableType& type, Storage storage, const char* name);
     55 								~Variable			(void);
     56 
     57 	const VariableType&			getType				(void) const { return m_type;					}
     58 	Storage						getStorage			(void) const { return m_storage;				}
     59 	const char*					getName				(void) const { return m_name.c_str();			}
     60 	int							getLayoutLocation	(void) const { return m_layoutLocation;			}
     61 	bool						hasLayoutLocation	(void) const { return m_layoutLocation >= 0;	}
     62 
     63 	void						setStorage			(Storage storage)	{ m_storage = storage;			}
     64 	void						setLayoutLocation	(int location)		{ m_layoutLocation = location;	}
     65 
     66 	bool						isWritable			(void) const;
     67 
     68 	void						tokenizeDeclaration	(GeneratorState& state, TokenStream& str) const;
     69 
     70 private:
     71 	VariableType				m_type;
     72 	Storage						m_storage;
     73 	std::string					m_name;
     74 	int							m_layoutLocation;
     75 };
     76 
     77 } // rsg
     78 
     79 #endif // _RSGVARIABLE_HPP
     80