Skip to content

Commit f90915a

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

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
@@ -3807,6 +3807,42 @@ class GLShader_processSurfaces :
38073807
GLShader_processSurfaces();
38083808
};
38093809

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

38113847
std::string GetShaderPath();
38123848

@@ -3846,6 +3882,7 @@ extern GLShader_screen *gl_screenShader;
38463882
extern GLShader_screenMaterial *gl_screenShaderMaterial;
38473883
extern GLShader_skybox *gl_skyboxShader;
38483884
extern GLShader_skyboxMaterial *gl_skyboxShaderMaterial;
3885+
extern GlobalUBOProxy *globalUBOProxy;
38493886
extern GLShaderManager gl_shaderManager;
38503887

38513888
#endif // GL_SHADER_H

src/engine/renderer/tr_shade.cpp

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

221+
gl_shaderManager.LoadShader( globalUBOProxy );
222+
221223
// Material system shaders that are always loaded if material system is available
222224
if ( glConfig2.usingMaterialSystem )
223225
{
@@ -459,6 +461,7 @@ void GLSL_ShutdownGPUShaders()
459461

460462
gl_genericShader = nullptr;
461463
gl_genericShaderMaterial = nullptr;
464+
globalUBOProxy = nullptr;
462465
gl_cullShader = nullptr;
463466
gl_depthReductionShader = nullptr;
464467
gl_clearSurfacesShader = nullptr;

0 commit comments

Comments
 (0)