OgreShaderGLSLESProgramWriter.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25-----------------------------------------------------------------------------
26*/
27#ifndef _ShaderProgramWriterGLSLES_
28#define _ShaderProgramWriterGLSLES_
29
31
32namespace Ogre {
33namespace RTShader {
34
46{
47 // Interface.
48public:
49
53
56
57
61 virtual void writeSourceCode (std::ostream& os, Program* program);
62
66 virtual const String& getTargetLanguage () const { return TargetLanguage; }
67
69
70 protected:
77 typedef FunctionMap::const_iterator FunctionMapIterator;
78 typedef FunctionVector::const_iterator FunctionVectorIterator;
79 typedef GpuConstTypeToStringMap::const_iterator GpuConstTypeToStringMapIterator;
80
81 // Protected methods.
82protected:
83
86
89
90
93
95 void writeProgramDependencies (std::ostream& os, Program* program);
96
99
102
105
107
109 bool isBasicType(String &type);
110
113
114 // Attributes.
115protected:
116 GpuConstTypeToStringMap mGpuConstTypeMap; // Map between GPU constant type to string value.
117 ParamSemanticToStringMap mParamSemanticMap; // Map between parameter semantic to string value.
118
119 StringMap mInputToGLStatesMap; // Map parameter name to a new parameter name (sometimes renaming is required to match names between vertex and fragment shader)
120 FunctionMap mFunctionCacheMap; // Map function invocation to body. Used as a cache to reduce library file reads and for inlining
121 StringMap mDefinesMap; // Map of #defines and the function library that contains them
122 ParamContentToStringMap mContentToPerVertexAttributes; // Map parameter content to vertex attributes
123 int mGLSLVersion; // Holds the current glsl es version
124 StringVector mFragInputParams; // Holds the fragment input params
125 StringMap mCachedFunctionLibraries; // Holds the cached function libraries
126};
127
132{
133public:
135 {
136 }
138
142 virtual const String& getTargetLanguage(void) const
143 {
144 return mLanguage;
145 }
146
150 virtual ProgramWriter* create(void)
151 {
153 }
154
155private:
157};
158
162}
163}
164
165#endif
A class that represents function invocation code from shader based program function.
A class that represents a shader based program function.
GLSL ES target language writer implementation.
vector< FunctionInvocation >::type FunctionVector
bool isBasicType(String &type)
Check if a string matches one of the GLSL ES basic types.
virtual ~GLSLESProgramWriter()
Class destructor.
void discoverFunctionDependencies(const FunctionInvocation &invoc, FunctionVector &depVector)
Search within a function body for non-builtin functions that a given function invocation depends on.
map< FunctionInvocation, String >::type FunctionMap
map< Parameter::Semantic, constchar * >::type ParamSemanticToStringMap
void writeProgramDependencies(std::ostream &os, Program *program)
Write the program dependencies.
void writeInputParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the input params of the function.
GLSLESProgramWriter()
Class constructor.
void writeLocalParameter(std::ostream &os, ParameterPtr parameter)
Write a local parameter.
FunctionVector::const_iterator FunctionVectorIterator
virtual void cacheDependencyFunctions(const String &libName)
Cache functions of a dependency.
void initializeStringMaps()
Initialize string maps.
GpuConstTypeToStringMap::const_iterator GpuConstTypeToStringMapIterator
String processOperand(Operand op, GpuProgramType gpuType)
virtual const String & getTargetLanguage() const
map< Parameter::Content, constchar * >::type ParamContentToStringMap
void writeOutParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the output params of the function.
FunctionInvocation * createInvocationFromString(const String &input)
Create a FunctionInvocation object from a string taken out of a shader library.
virtual void writeSourceCode(std::ostream &os, Program *program)
map< GpuConstantType, constchar * >::type GpuConstTypeToStringMap
A class that represents a function operand (its the combination of a parameter the in/out semantic an...
Interface definition for factories of ShaderProgramWriter.
Base class interface for shader program writers.
A class that represents a shader based program.
GLSL ES program writer factory implementation.
Reference-counted shared pointer, used for objects where implicit destruction is required.
#define OGRE_NEW
GpuProgramType
Enumerates the types of programs which can run on the GPU.
_StringBase String
std::map< K, V, P, A > type
std::vector< T, A > type

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.