Skip to content

Commit 104f3cd

Browse files
committed
Add GlobalUBOProxy
Will be required for `PushBuffer` to set global uniform values outside of their shaders.
1 parent 29df1ac commit 104f3cd

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
@@ -3088,3 +3089,39 @@ GLShader_processSurfaces::GLShader_processSurfaces() :
30883089
u_ViewID( this ),
30893090
u_SurfaceCommandsOffset( this ) {
30903091
}
3092+
3093+
GlobalUBOProxy::GlobalUBOProxy() :
3094+
/* HACK: A GLShader* is required to initialise uniforms,
3095+
but we don't need the GLSL shader itself, so we won't actually build it */
3096+
GLShader( "proxy", 0,
3097+
false, "screenSpace", "generic", true ),
3098+
// CONST
3099+
u_ColorMap3D( this ),
3100+
u_DepthMap( this ),
3101+
u_PortalMap( this ),
3102+
u_FogMap( this ),
3103+
u_DepthTile1( this ),
3104+
u_DepthTile2( this ),
3105+
u_LightTiles( this ),
3106+
u_LightGrid1( this ),
3107+
u_LightGrid2( this ),
3108+
u_LightGridOrigin( this ),
3109+
u_LightGridScale( this ),
3110+
u_GlobalLightFactor( this ),
3111+
u_SRGB( this ),
3112+
u_FirstPortalGroup( this ),
3113+
u_TotalPortals( this ),
3114+
u_SurfaceDescriptorsCount( this ),
3115+
u_ProfilerZero( this ),
3116+
// FRAME
3117+
u_Frame( this ),
3118+
u_UseFrustumCulling( this ),
3119+
u_UseOcclusionCulling( this ),
3120+
u_blurVec( this ),
3121+
u_numLights( this ),
3122+
u_ColorModulate( this ),
3123+
u_InverseGamma( this ),
3124+
u_Tonemap( this ),
3125+
u_TonemapParms( this ),
3126+
u_TonemapExposure( this ) {
3127+
}

src/engine/renderer/gl_shader.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,6 +3806,42 @@ class GLShader_processSurfaces :
38063806
GLShader_processSurfaces();
38073807
};
38083808

3809+
class GlobalUBOProxy :
3810+
public GLShader,
3811+
// CONST
3812+
public u_ColorMap3D,
3813+
public u_DepthMap,
3814+
public u_PortalMap,
3815+
public u_FogMap,
3816+
public u_DepthTile1,
3817+
public u_DepthTile2,
3818+
public u_LightTiles,
3819+
public u_LightGrid1,
3820+
public u_LightGrid2,
3821+
public u_LightGridOrigin,
3822+
public u_LightGridScale,
3823+
public u_GlobalLightFactor,
3824+
public u_SRGB,
3825+
public u_FirstPortalGroup,
3826+
public u_TotalPortals,
3827+
public u_SurfaceDescriptorsCount,
3828+
public u_ProfilerZero,
3829+
// FRAME
3830+
public u_Frame,
3831+
public u_UseFrustumCulling,
3832+
public u_UseOcclusionCulling,
3833+
public u_blurVec,
3834+
public u_numLights,
3835+
public u_ColorModulate,
3836+
public u_InverseGamma,
3837+
public u_Tonemap,
3838+
public u_TonemapParms,
3839+
public u_TonemapExposure {
3840+
3841+
public:
3842+
GlobalUBOProxy();
3843+
};
3844+
38093845

38103846
std::string GetShaderPath();
38113847

@@ -3845,6 +3881,7 @@ extern GLShader_screen *gl_screenShader;
38453881
extern GLShader_screenMaterial *gl_screenShaderMaterial;
38463882
extern GLShader_skybox *gl_skyboxShader;
38473883
extern GLShader_skyboxMaterial *gl_skyboxShaderMaterial;
3884+
extern GlobalUBOProxy *globalUBOProxy;
38483885
extern GLShaderManager gl_shaderManager;
38493886

38503887
#endif // GL_SHADER_H

src/engine/renderer/tr_shade.cpp

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

220+
gl_shaderManager.LoadShader( globalUBOProxy );
221+
220222
// Material system shaders that are always loaded if material system is available
221223
if ( glConfig2.usingMaterialSystem )
222224
{
@@ -458,6 +460,7 @@ void GLSL_ShutdownGPUShaders()
458460

459461
gl_genericShader = nullptr;
460462
gl_genericShaderMaterial = nullptr;
463+
globalUBOProxy = nullptr;
461464
gl_cullShader = nullptr;
462465
gl_depthReductionShader = nullptr;
463466
gl_clearSurfacesShader = nullptr;

0 commit comments

Comments
 (0)