Skip to content

Commit 75f77a2

Browse files
committed
Add GlobalUBOProxy
Will be required for `PushBuffer` to set global uniform values outside of their shaders.
1 parent 3f52760 commit 75f77a2

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
@@ -81,6 +81,7 @@ GLShader_screen *gl_screenShader = nullptr;
8181
GLShader_screenMaterial *gl_screenShaderMaterial = nullptr;
8282
GLShader_skybox *gl_skyboxShader = nullptr;
8383
GLShader_skyboxMaterial *gl_skyboxShaderMaterial = nullptr;
84+
GlobalUBOProxy *globalUBOProxy = nullptr;
8485
GLShaderManager gl_shaderManager;
8586

8687
namespace // Implementation details
@@ -2962,3 +2963,39 @@ GLShader_processSurfaces::GLShader_processSurfaces() :
29622963
u_ViewID( this ),
29632964
u_SurfaceCommandsOffset( this ) {
29642965
}
2966+
2967+
GlobalUBOProxy::GlobalUBOProxy() :
2968+
/* HACK: A GLShader* is required to initialise uniforms,
2969+
but we don't need the GLSL shader itself, so we won't actually build it */
2970+
GLShader( "proxy", 0,
2971+
false, "screenSpace", "generic", true ),
2972+
// CONST
2973+
u_ColorMap3D( this ),
2974+
u_DepthMap( this ),
2975+
u_PortalMap( this ),
2976+
u_FogMap( this ),
2977+
u_DepthTile1( this ),
2978+
u_DepthTile2( this ),
2979+
u_LightTiles( this ),
2980+
u_LightGrid1( this ),
2981+
u_LightGrid2( this ),
2982+
u_LightGridOrigin( this ),
2983+
u_LightGridScale( this ),
2984+
u_GlobalLightFactor( this ),
2985+
u_SRGB( this ),
2986+
u_FirstPortalGroup( this ),
2987+
u_TotalPortals( this ),
2988+
u_SurfaceDescriptorsCount( this ),
2989+
u_ProfilerZero( this ),
2990+
// FRAME
2991+
u_Frame( this ),
2992+
u_UseFrustumCulling( this ),
2993+
u_UseOcclusionCulling( this ),
2994+
u_blurVec( this ),
2995+
u_numLights( this ),
2996+
u_ColorModulate( this ),
2997+
u_InverseGamma( this ),
2998+
u_Tonemap( this ),
2999+
u_TonemapParms( this ),
3000+
u_TonemapExposure( this ) {
3001+
}

src/engine/renderer/gl_shader.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,6 +3755,42 @@ class GLShader_processSurfaces :
37553755
GLShader_processSurfaces();
37563756
};
37573757

3758+
class GlobalUBOProxy :
3759+
public GLShader,
3760+
// CONST
3761+
public u_ColorMap3D,
3762+
public u_DepthMap,
3763+
public u_PortalMap,
3764+
public u_FogMap,
3765+
public u_DepthTile1,
3766+
public u_DepthTile2,
3767+
public u_LightTiles,
3768+
public u_LightGrid1,
3769+
public u_LightGrid2,
3770+
public u_LightGridOrigin,
3771+
public u_LightGridScale,
3772+
public u_GlobalLightFactor,
3773+
public u_SRGB,
3774+
public u_FirstPortalGroup,
3775+
public u_TotalPortals,
3776+
public u_SurfaceDescriptorsCount,
3777+
public u_ProfilerZero,
3778+
// FRAME
3779+
public u_Frame,
3780+
public u_UseFrustumCulling,
3781+
public u_UseOcclusionCulling,
3782+
public u_blurVec,
3783+
public u_numLights,
3784+
public u_ColorModulate,
3785+
public u_InverseGamma,
3786+
public u_Tonemap,
3787+
public u_TonemapParms,
3788+
public u_TonemapExposure {
3789+
3790+
public:
3791+
GlobalUBOProxy();
3792+
};
3793+
37583794

37593795
std::string GetShaderPath();
37603796

@@ -3794,6 +3830,7 @@ extern GLShader_screen *gl_screenShader;
37943830
extern GLShader_screenMaterial *gl_screenShaderMaterial;
37953831
extern GLShader_skybox *gl_skyboxShader;
37963832
extern GLShader_skyboxMaterial *gl_skyboxShaderMaterial;
3833+
extern GlobalUBOProxy *globalUBOProxy;
37973834
extern GLShaderManager gl_shaderManager;
37983835

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