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 using ShaderCodes = std::vector<const char*>;
46
47 /**
48 * Definition of a map mapping shader codes to compiled shader objects.
49 */
50 using ShaderMap = std::map<ShaderCodes, GLESShaderRef>;
51
52 /**
53 * Definition of an unordered map mapping program types to program objects.
54 */
55 using ProgramMap = std::unordered_map<GLESAttribute::ProgramType, GLESShaderProgramRef>;
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
136
137 /// The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value
139
141
142 /// The code part containing the macro to convert the 2-texture Y_UV12 lookup to a RGBA32 value
144
146
147 /// The code part containing the macro to convert the 2-texture Y_VU12 lookup to a RGBA32 value
149
151
152 /// The code part containing the macro to convert the 2-texture Y_U_V12 lookup to a RGBA32 value
154
156
157 /// The code part defining the Material struct.
158 static const char* partDefinitionMaterial_;
159
160 /// The code part defining the Light struct.
161 static const char* partDefinitionLight_;
162
163 /// The code part defining the function to determine the light for a vertex based on up to 8 lights
164 static const char* partFunctionLighting_;
165
166 /// Vertex shader code: PT_STATIC_COLOR.
168
169 /// Vertex shader code: PT_COLOR_ID.
170 static const char* programVertexShaderColorId_;
171
172 /// Vertex shader code: PT_POINTS.
173 static const char* programVertexShaderPoints_;
174
175 /// Vertex shader code: PT_POINTS | PT_MATERIAL.
177
178 /// Vertex shader code: PT_POINTS | PT_MATERIAL | PT_LIGHT.
180
181 /// Vertex shader code: PT_DEBUG_GRAY.
183
184 /// Vertex shader code: PT_MATERIAL.
186
187 /// Vertex shader code: PT_MATERIAL | PT_LIGHT.
189
190 /// Vertex shader code: PT_TEXTURE_LOWER/UPPLER_LEFT | PT_TEXTURE_BGRA/RGBA.
191 static const char* programVertexShaderTexture_;
192
193 /// Vertex shader code: PT_MATERIAL | PT_LIGHT | PT_TEXTURE_LOWER/UPPER_LEFT | PT_TEXTURE_BGRA/RGBA:
195
196 /// Vertex shader code: PT_PHANTOM_VIDEO_TEXTURE_COORDINATES_FAST:
198
199 /// Vertex shader code: PT_OPAQUE_TEXT_Y | PT_MATERIAL | PT_LIGHT.
201
202 /// Vertex shader code: PT_TRANSPARENT_TEXT_Y | PT_MATERIAL | PT_LIGHT.
204
205 /// Fragment shader code: PT_STATIC_COLOR.
207
208 /// Fragment shader code: PT_DEBUG_GRAY.
210
211 /// Fragment shader code: PT_MATERIAL.
213
214 /// Fragment shader code for color ids.
216
217 /// Fragment shader code for one texture.
219
220 /// Fragment shader code for two textures.
222
223 /// Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT.
225
226 /// Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT, for pixel formats stored in two textures.
228
229 /// Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
231
232 /// Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
234
235 /// Fragment shader code: PT_OPAQUE_TEXT_Y.
237
238 /// Fragment shader code: PT_TRANSPARENT_TEXT_Y.
240};
241
242}
243
244}
245
246}
247
248#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:170
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
static const char * partTwoTexturesLookupFullRangeY_VU12ToRGBA32_
Definition GLESProgramManager.h:150
GLESShaderProgramRef program(const Engine &engine, const GLESAttribute::ProgramType programType)
Returns a specified shader with the specified functionalities.
static const char * partTwoTexturesLookupFullRangeY_UV12ToRGBA32_
Definition GLESProgramManager.h:145
static const char * partTwoTexturesLookupLimitedRangeY_U_V12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_U_V12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:153
static const char * partDefinitionMaterial_
The code part defining the Material struct.
Definition GLESProgramManager.h:158
static const char * programFragmentShaderMaterialTexture_
Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT.
Definition GLESProgramManager.h:224
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:194
static const char * programFragmentShaderTwoTextures_
Fragment shader code for two textures.
Definition GLESProgramManager.h:221
static const char * partTwoTexturesLookupLimitedRangeY_VU12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_VU12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:148
static const char * programFragmentShaderStaticColor_
Fragment shader code: PT_STATIC_COLOR.
Definition GLESProgramManager.h:206
static const char * programFragmentShaderMaterialTwoTextures_
Fragment shader code: PT_MATERIAL | PT_TEXTURE_LOWER/UPPER_LEFT, for pixel formats stored in two text...
Definition GLESProgramManager.h:227
static const char * programFragmentShaderTwoSidedColor_
Fragment shader code: PT_MATERIAL.
Definition GLESProgramManager.h:212
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 * partTwoTexturesLookupFullRangeY_U_V12ToRGBA32_
Definition GLESProgramManager.h:155
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:164
static const char * programVertexShaderTexture_
Vertex shader code: PT_TEXTURE_LOWER/UPPLER_LEFT | PT_TEXTURE_BGRA/RGBA.
Definition GLESProgramManager.h:191
static const char * programFragmentShaderColorId_
Fragment shader code for color ids.
Definition GLESProgramManager.h:215
static const char * programVertexShaderDebugGray_
Vertex shader code: PT_DEBUG_GRAY.
Definition GLESProgramManager.h:182
static const char * partTwoTexturesLookupLimitedRangeY_UV12ToRGBA32_
The code part containing the macro to convert the 2-texture Y_UV12 lookup to a RGBA32 value.
Definition GLESProgramManager.h:143
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:188
Lock lock_
Lock for the program manager.
Definition GLESProgramManager.h:111
static const char * partOneTextureLookupFullRangeYVU24ToRGBA32_
Definition GLESProgramManager.h:140
static const char * programFragmentShaderOneTexture_
Fragment shader code for one texture.
Definition GLESProgramManager.h:218
static const char * programVertexShaderStaticColor_
Vertex shader code: PT_STATIC_COLOR.
Definition GLESProgramManager.h:167
static const char * programVertexShaderMaterial_
Vertex shader code: PT_MATERIAL.
Definition GLESProgramManager.h:185
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:179
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:200
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:209
static const char * programVertexShaderPointsMaterial_
Vertex shader code: PT_POINTS | PT_MATERIAL.
Definition GLESProgramManager.h:176
static const char * partOneTextureLookupLimitedRangeYUV24ToRGBA32_
The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value.
Definition GLESProgramManager.h:133
static const char * programFragmentShaderPhantomVideoFastTwoTextures_
Fragment shader code: PT_PHANTOM_VIDEO_FAST | PT_TEXTURE_LOWER/UPPER_LEFT.
Definition GLESProgramManager.h:233
std::map< ShaderCodes, GLESShaderRef > ShaderMap
Definition of a map mapping shader codes to compiled shader objects.
Definition GLESProgramManager.h:50
static const char * partOneTextureLookupFullRangeYUV24ToRGBA32_
Definition GLESProgramManager.h:135
static const char * programFragmentShaderTransparentTextY_
Fragment shader code: PT_TRANSPARENT_TEXT_Y.
Definition GLESProgramManager.h:239
static const char * programFragmentShaderOpaqueTextY_
Fragment shader code: PT_OPAQUE_TEXT_Y.
Definition GLESProgramManager.h:236
static const char * programVertexShaderPoints_
Vertex shader code: PT_POINTS.
Definition GLESProgramManager.h:173
static const char * programVertexShaderTransparentTextMaterialLight_
Vertex shader code: PT_TRANSPARENT_TEXT_Y | PT_MATERIAL | PT_LIGHT.
Definition GLESProgramManager.h:203
~GLESProgramManager()
Destructs a shader manager.
ProgramMap programMap_
Map mapping program types to shader program objects.
Definition GLESProgramManager.h:108
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:161
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:197
std::vector< const char * > ShaderCodes
Definition of a vector holding pointers to shader codes.
Definition GLESProgramManager.h:45
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:230
static const char * partOneTextureLookupLimitedRangeYVU24ToRGBA32_
The code part containing the macro to convert the 1-texture YUV24 lookup to a RGBA32 value.
Definition GLESProgramManager.h:138
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