Skip to content

Commit d610008

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

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/engine/renderer/gl_shader.cpp

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

src/engine/renderer/gl_shader.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3793,6 +3793,41 @@ class GLShader_processSurfaces :
37933793
GLShader_processSurfaces();
37943794
};
37953795

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

37973832
std::string GetShaderPath();
37983833

@@ -3832,6 +3867,7 @@ extern GLShader_screen *gl_screenShader;
38323867
extern GLShader_screenMaterial *gl_screenShaderMaterial;
38333868
extern GLShader_skybox *gl_skyboxShader;
38343869
extern GLShader_skyboxMaterial *gl_skyboxShaderMaterial;
3870+
extern GlobalUBOProxy *globalUBOProxy;
38353871
extern GLShaderManager gl_shaderManager;
38363872

38373873
#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)