Ocean
Loading...
Searching...
No Matches
GLESProgramManager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_RENDERING_GLES_PROGRAM_MANAGER_H
9#define META_OCEAN_RENDERING_GLES_PROGRAM_MANAGER_H
10
15
16#include "ocean/base/Lock.h"
18
20
21#include <map>
22
23namespace Ocean
24{
25
26namespace Rendering
27{
28
29namespace GLESceneGraph
30{
31
32/**
33 * This class implements a manager for OpenGL ES shader programs.
34 * @ingroup renderinggles
35 */
36class OCEAN_RENDERING_GLES_EXPORT GLESProgramManager : public Singleton<GLESProgramManager>
37{
38 friend class Singleton<GLESProgramManager>;
39
40 protected:
41
42 /**
43 * Definition of a vector holding pointers to shader codes.
44 */
45 typedef std::vector<const char*> ShaderCodes;
46
47 /**
48 * Definition of a map mapping shader codes to compiled shader objects.
49 */
50 typedef std::map<ShaderCodes, GLESShaderRef> ShaderMap;
51
52 /**
53 * Definition of an unordered map mapping program types to program objects.
54 */
55 typedef std::unordered_map<GLESAttribute::ProgramType, GLESShaderProgramRef> ProgramMap;
56
57 public:
58
59 /**
60 * Returns a specified shader with the specified functionalities.
61 * @param engine The rendering engine to be used
62 * @param programType The necessary shader program type
63 * @return The specified shader object, invalid if the program could not be created
64 */
66
67 /**
68 * Releases the shader manager.
69 * This function should be called once before program termination.
70 */
71 void release();
72
73 protected:
74
75 /**
76 * Creates an shader manager.
77 */
79
80 /**
81 * Destructs a shader manager.
82 */
84
85 /**
86 * Returns the vertex shader code with a specified functionality.
87 * @param programType Shader program functionalities
88 * @return Vertex shader code which must not be released
89 */
91
92 /**
93 * Returns the fragment shader code with a specified functionality.
94 * @param programType Shader program functionalities
95 * @return Fragment shader code which must not be released
96 */
98
99 protected:
100
101 /// Map mapping vertex shader codes to compiled shader objects.
103
104 /// Map mapping fragment shader codes to compiled shader objects.
106
107 /// Map mapping program types to shader program objects.
109
110 /// Lock for the program manager.
112
113#ifdef OCEAN_DEBUG
114
115 /// State determining whether this manager has been released.
117
118#endif // OCEAN_DEBUG
119
120 /// The code part containing platform specific information e.g., shader version.
121 static const char* partPlatform_;
122
123 /// The code part containing the macro to convert a 1-texture Y8 lookup to a RGBA32 value
125
126 /// The code part containing the macro to convert a 1-texture RGBA32 lookup to a RGBA32 value
128
129 /// The code part containing the macro to convert a 1-texture BGRA32 lookup to a RGBA32 value
131
132 /// The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value
134
135 /// The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value
137
138 /// The code part containing the macro to convert the 2-texture Y_UV12 lookup to a RGBA32 value
140
141 /// The code part containing the macro to convert the 2-texture Y_VU12 lookup to a RGBA32 value
143
144 /// The code part containing the macro to convert the 2-texture Y_U_V12 lookup to a RGBA32 value
146
147 /// The code part defining the Material struct.
148 static const char* partDefinitionMaterial_;
149
150 /// The code part defining the Light struct.
151 static const char* partDefinitionLight_;
152
153 /// The code part defining the function to determine the light for a vertex based on up to 8 lights
154 static const char* partFunctionLighting_;
155
156 /// Vertex shader code: PT_STATIC_COLOR.
158
159 /// Vertex shader code: PT_COLOR_ID.
160 static const char* programVertexShaderColorId_;
161
162 /// Vertex shader code: PT_POINTS.
163 static const char* programVertexShaderPoints_;
164
165 /// Vertex shader code: PT_POINTS | PT_MATERIAL.
167
168 /// Vertex shader code: PT_POINTS | PT_MATERIAL | PT_LIGHT.
170
171 /// Vertex shader code: PT_DEBUG_GRAY.
173
174 /// Vertex shader code: PT_MATERIAL.
176
177 /// Vertex shader code: PT_MATERIAL | PT_LIGHT.
179
180 /// Vertex shader code: PT_TEXTURE_LOWER/UPPLER_LEFT | PT_TEXTURE_BGRA/RGBA.
181 static const char* programVertexShaderTexture_;
182
183 /// Vertex shader code: PT_MATERIAL | PT_LIGHT | PT_TEXTURE_LOWER/UPPER_LEFT | PT_TEXTURE_BGRA/RGBA:
185
186 /// Vertex shader code: PT_PHANTOM_VIDEO_TEXTURE_COORDINATES_FAST:
188
189 /// Vertex shader code: PT_OPAQUE_TEXT_Y | PT_MATERIAL | PT_LIGHT.
191
192 /// Vertex shader code: PT_TRANSPARENT_TEXT_Y | PT_MATERIAL | PT_LIGHT.
194
195 /// Fragment shader code: PT_STATIC_COLOR.
197
198 /// Fragment shader code: PT_DEBUG_GRAY.
200
201 /// Fragment shader code: PT_MATERIAL.
203
204 /// Fragment shader code for color ids.
206
207 /// Fragment shader code for one texture.
209
210 /// Fragment shader code for two textures.
212
213 /// Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT.
215
216 /// Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
218
219 /// Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
221
222 /// Fragment shader code: PT_OPAQUE_TEXT_Y.
224
225 /// Fragment shader code: PT_TRANSPARENT_TEXT_Y.
227};
228
229}
230
231}
232
233}
234
235#endif // META_OCEAN_RENDERING_GLES_PROGRAM_MANAGER_H
This class implements a recursive lock object.
Definition Lock.h:31
This class is the base class for all rendering engines like.
Definition Engine.h:46
ProgramType
Definition of different shader functionalities.
Definition GLESAttribute.h:43
This class implements a manager for OpenGL ES shader programs.
Definition GLESProgramManager.h:37
void release()
Releases the shader manager.
static const char * programVertexShaderColorId_
Vertex shader code: PT_COLOR_ID.
Definition GLESProgramManager.h:160
static const char * partOneTextureLookupRGBA32ToRGBA32_
The code part containing the macro to convert a 1-texture RGBA32 lookup to a RGBA32 value.
Definition GLESProgramManager.h:127
GLESShaderProgramRef program(const Engine &engine, const GLESAttribute::ProgramType programType)
Returns a specified shader with the specified functionalities.
static const char * partDefinitionMaterial_
The code part defining the Material struct.
Definition GLESProgramManager.h:148
static const char * programFragmentShaderMaterialTexture_
Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT.
Definition GLESProgramManager.h:214
static const char * partPlatform_
The code part containing platform specific information e.g., shader version.
Definition GLESProgramManager.h:121
static const char * programVertexShaderMaterialLightTexture_
Vertex shader code: PT_MATERIAL | PT_LIGHT | PT_TEXTURE_LOWER/UPPER_LEFT | PT_TEXTURE_BGRA/RGBA:
Definition GLESProgramManager.h:184
static const char * programFragmentShaderTwoTextures_
Fragment shader code for two textures.
Definition GLESProgramManager.h:211
std::map< ShaderCodes, GLESShaderRef > ShaderMap
Definition of a map mapping shader codes to compiled shader objects.
Definition GLESProgramManager.h:50
static const char * programFragmentShaderStaticColor_
Fragment shader code: PT_STATIC_COLOR.
Definition GLESProgramManager.h:196
static const char * partTwoTexturesLookupY_VU12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_VU12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:142
static const char * programFragmentShaderTwoSidedColor_
Fragment shader code: PT_MATERIAL.
Definition GLESProgramManager.h:202
static const char * partFunctionLighting_
The code part defining the function to determine the light for a vertex based on up to 8 lights.
Definition GLESProgramManager.h:154
static const char * partOneTextureLookupYVU24ToRGBA32_
The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value.
Definition GLESProgramManager.h:136
static const char * programVertexShaderTexture_
Vertex shader code: PT_TEXTURE_LOWER/UPPLER_LEFT | PT_TEXTURE_BGRA/RGBA.
Definition GLESProgramManager.h:181
static const char * programFragmentShaderColorId_
Fragment shader code for color ids.
Definition GLESProgramManager.h:205
static const char * programVertexShaderDebugGray_
Vertex shader code: PT_DEBUG_GRAY.
Definition GLESProgramManager.h:172
static const char * partOneTextureLookupBGRA32ToRGBA32_
The code part containing the macro to convert a 1-texture BGRA32 lookup to a RGBA32 value.
Definition GLESProgramManager.h:130
static const char * programVertexShaderMaterialLight_
Vertex shader code: PT_MATERIAL | PT_LIGHT.
Definition GLESProgramManager.h:178
Lock lock_
Lock for the program manager.
Definition GLESProgramManager.h:111
static const char * programFragmentShaderOneTexture_
Fragment shader code for one texture.
Definition GLESProgramManager.h:208
static const char * programVertexShaderStaticColor_
Vertex shader code: PT_STATIC_COLOR.
Definition GLESProgramManager.h:157
static const char * partOneTextureLookupYUV24ToRGBA32_
The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value.
Definition GLESProgramManager.h:133
static const char * programVertexShaderMaterial_
Vertex shader code: PT_MATERIAL.
Definition GLESProgramManager.h:175
ShaderMap vertexShaders_
Map mapping vertex shader codes to compiled shader objects.
Definition GLESProgramManager.h:102
static const char * programVertexShaderPointsMaterialLight_
Vertex shader code: PT_POINTS | PT_MATERIAL | PT_LIGHT.
Definition GLESProgramManager.h:169
bool debugReleased_
State determining whether this manager has been released.
Definition GLESProgramManager.h:116
static const char * programVertexShaderOpaqueTextMaterialLight_
Vertex shader code: PT_OPAQUE_TEXT_Y | PT_MATERIAL | PT_LIGHT.
Definition GLESProgramManager.h:190
ShaderCodes vertexShaderCodes(const GLESAttribute::ProgramType programType) const
Returns the vertex shader code with a specified functionality.
static const char * programFragmentShaderOneSidedColor_
Fragment shader code: PT_DEBUG_GRAY.
Definition GLESProgramManager.h:199
static const char * programVertexShaderPointsMaterial_
Vertex shader code: PT_POINTS | PT_MATERIAL.
Definition GLESProgramManager.h:166
static const char * programFragmentShaderPhantomVideoFastTwoTextures_
Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
Definition GLESProgramManager.h:220
static const char * partTwoTexturesLookupY_UV12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_UV12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:139
static const char * programFragmentShaderTransparentTextY_
Fragment shader code: PT_TRANSPARENT_TEXT_Y.
Definition GLESProgramManager.h:226
std::unordered_map< GLESAttribute::ProgramType, GLESShaderProgramRef > ProgramMap
Definition of an unordered map mapping program types to program objects.
Definition GLESProgramManager.h:55
static const char * programFragmentShaderOpaqueTextY_
Fragment shader code: PT_OPAQUE_TEXT_Y.
Definition GLESProgramManager.h:223
std::vector< const char * > ShaderCodes
Definition of a vector holding pointers to shader codes.
Definition GLESProgramManager.h:45
static const char * programVertexShaderPoints_
Vertex shader code: PT_POINTS.
Definition GLESProgramManager.h:163
static const char * programVertexShaderTransparentTextMaterialLight_
Vertex shader code: PT_TRANSPARENT_TEXT_Y | PT_MATERIAL | PT_LIGHT.
Definition GLESProgramManager.h:193
~GLESProgramManager()
Destructs a shader manager.
ProgramMap programMap_
Map mapping program types to shader program objects.
Definition GLESProgramManager.h:108
static const char * partTwoTexturesLookupY_U_V12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_U_V12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:145
static const char * partOneTextureLookupY8ToRGBA32_
The code part containing the macro to convert a 1-texture Y8 lookup to a RGBA32 value.
Definition GLESProgramManager.h:124
static const char * partDefinitionLight_
The code part defining the Light struct.
Definition GLESProgramManager.h:151
ShaderCodes fragmentShaderCodes(const GLESAttribute::ProgramType programType) const
Returns the fragment shader code with a specified functionality.
static const char * programVertexShaderPhantomVideoTextureCoordinatesFast_
Vertex shader code: PT_PHANTOM_VIDEO_TEXTURE_COORDINATES_FAST:
Definition GLESProgramManager.h:187
ShaderMap fragmentShaders_
Map mapping fragment shader codes to compiled shader objects.
Definition GLESProgramManager.h:105
static const char * programFragmentShaderPhantomVideoFastOneTexture_
Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
Definition GLESProgramManager.h:217
This template class is the base class for all singleton objects.
Definition Singleton.h:71
The namespace covering the entire Ocean framework.
Definition Accessor.h:15