Skip to content

Commit 45db1ed

Browse files
committed
Add GlobalUBOProxy
Will be required for `PushBuffer` to set global uniform values outside of their shaders.
1 parent b54267e commit 45db1ed

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

src/engine/renderer/gl_shader.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ GLShader_screen *gl_screenShader = nullptr;
7777
GLShader_screenMaterial *gl_screenShaderMaterial = nullptr;
7878
GLShader_skybox *gl_skyboxShader = nullptr;
7979
GLShader_skyboxMaterial *gl_skyboxShaderMaterial = nullptr;
80+
GlobalUBOProxy *globalUBOProxy = nullptr;
8081
GLShaderManager gl_shaderManager;
8182

8283
namespace // Implementation details
@@ -3013,3 +3014,39 @@ GLShader_processSurfaces::GLShader_processSurfaces() :
30133014
u_ViewID( this ),
30143015
u_SurfaceCommandsOffset( this ) {
30153016
}
3017+
3018+
GlobalUBOProxy::GlobalUBOProxy() :
3019+
/* HACK: A GLShader* is required to initialise uniforms,
3020+
but we don't need the GLSL shader itself, so we won't actually build it */
3021+
GLShader( "proxy", 0,
3022+
false, "screenSpace", "generic", true ),
3023+
// CONST
3024+
u_ColorMap3D( this ),
3025+
u_DepthMap( this ),
3026+
u_PortalMap( this ),
3027+
u_FogMap( this ),
3028+
u_DepthTile1( this ),
3029+
u_DepthTile2( this ),
3030+
u_LightTiles( this ),
3031+
u_LightGrid1( this ),
3032+
u_LightGrid2( this ),
3033+
u_LightGridOrigin( this ),
3034+
u_LightGridScale( this ),
3035+
u_GlobalLightFactor( this ),
3036+
u_SRGB( this ),
3037+
u_FirstPortalGroup( this ),
3038+
u_TotalPortals( this ),
3039+
u_SurfaceDescriptorsCount( this ),
3040+
u_ProfilerZero( this ),
3041+
// FRAME
3042+
u_Frame( this ),
3043+
u_UseFrustumCulling( this ),
3044+
u_UseOcclusionCulling( this ),
3045+
u_blurVec( this ),
3046+
u_numLights( this ),
3047+
u_ColorModulate( this ),
3048+
u_InverseGamma( this ),
3049+
u_Tonemap( this ),
3050+
u_TonemapParms( this ),
3051+
u_TonemapExposure( this ) {
3052+
}

src/engine/renderer/gl_shader.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,6 +3796,42 @@ class GLShader_processSurfaces :
37963796
GLShader_processSurfaces();
37973797
};
37983798

3799+
class GlobalUBOProxy :
3800+
public GLShader,
3801+
// CONST
3802+
public u_ColorMap3D,
3803+
public u_DepthMap,
3804+
public u_PortalMap,
3805+
public u_FogMap,
3806+
public u_DepthTile1,
3807+
public u_DepthTile2,
3808+
public u_LightTiles,
3809+
public u_LightGrid1,
3810+
public u_LightGrid2,
3811+
public u_LightGridOrigin,
3812+
public u_LightGridScale,
3813+
public u_GlobalLightFactor,
3814+
public u_SRGB,
3815+
public u_FirstPortalGroup,
3816+
public u_TotalPortals,
3817+
public u_SurfaceDescriptorsCount,
3818+
public u_ProfilerZero,
3819+
// FRAME
3820+
public u_Frame,
3821+
public u_UseFrustumCulling,
3822+
public u_UseOcclusionCulling,
3823+
public u_blurVec,
3824+
public u_numLights,
3825+
public u_ColorModulate,
3826+
public u_InverseGamma,
3827+
public u_Tonemap,
3828+
public u_TonemapParms,
3829+
public u_TonemapExposure {
3830+
3831+
public:
3832+
GlobalUBOProxy();
3833+
};
3834+
37993835

38003836
std::string GetShaderPath();
38013837

@@ -3835,6 +3871,7 @@ extern GLShader_screen *gl_screenShader;
38353871
extern GLShader_screenMaterial *gl_screenShaderMaterial;
38363872
extern GLShader_skybox *gl_skyboxShader;
38373873
extern GLShader_skyboxMaterial *gl_skyboxShaderMaterial;
3874+
extern GlobalUBOProxy *globalUBOProxy;
38383875
extern GLShaderManager gl_shaderManager;
38393876

38403877
#endif // GL_SHADER_H

src/engine/renderer/tr_shade.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ static void GLSL_InitGPUShadersOrError()
224224
// standard light mapping
225225
gl_shaderManager.LoadShader( gl_lightMappingShader );
226226

227+
gl_shaderManager.LoadShader( globalUBOProxy );
228+
227229
// Material system shaders that are always loaded if material system is available
228230
if ( glConfig.usingMaterialSystem )
229231
{
@@ -465,6 +467,7 @@ void GLSL_ShutdownGPUShaders()
465467

466468
gl_genericShader = nullptr;
467469
gl_genericShaderMaterial = nullptr;
470+
globalUBOProxy = nullptr;
468471
gl_cullShader = nullptr;
469472
gl_depthReductionShader = nullptr;
470473
gl_clearSurfacesShader = nullptr;

0 commit comments

Comments
 (0)