Skip to content

Commit

Permalink
fix: selecting UBO as storage buffer should not remove the SSBO suppo…
Browse files Browse the repository at this point in the history
…rt flag, this flag is important to decide the shader version directive to use. With UBO set, the version was set as 330 core and some mods (Doom PBR) were complaining about unsupported features.

Also whether to use shadowmap should not be conditioned by the lack of support for the SSBO, shadowmap works just fine with version 330 core

Also add gl_no_ssbo and gl_no_clip_planes to disable support to these features for debugging purpose
  • Loading branch information
emawind84 committed Mar 19, 2024
1 parent 2ce68bc commit 2c8481f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
11 changes: 4 additions & 7 deletions src/common/rendering/gl/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,15 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
assert(screen->mBones != NULL);


if ((gl.flags & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO())
#ifdef __MOBILE__
vp_comb << "#version 310 es\n#define SUPPORTS_SHADOWMAPS\n";
vp_comb << "#version 310 es\n";
#else
vp_comb << "#version 430 core\n#define SUPPORTS_SHADOWMAPS\n";
#endif
if ((gl.flags & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO())
vp_comb << "#version 430 core\n";
else
#ifdef __MOBILE__
vp_comb << "#version 310 es\n";
#else
vp_comb << "#version 330 core\n";
#endif
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";

bool lightbuffertype = screen->mLights->GetBufferType();
if (!lightbuffertype)
Expand Down
8 changes: 5 additions & 3 deletions src/common/rendering/gl_load/gl_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ void gl_LoadExtensions()
gl_version = 3.31;
gl.flags |= RFL_NO_CLIP_PLANES;
gl.flags |= RFL_INVALIDATE_BUFFER;
if (gl_storage_buffer_type == 1)
gl.flags |= RFL_SHADER_STORAGE_BUFFER;
gl.flags |= RFL_SHADER_STORAGE_BUFFER;
#endif
// Don't even start if it's lower than 2.0 or no framebuffers are available (The framebuffer extension is needed for glGenerateMipmapsEXT!)
if (gl_version < 3.3f)
Expand Down Expand Up @@ -185,12 +184,15 @@ void gl_LoadExtensions()
}


if (gl_storage_buffer_type != 1)
if (gl_no_ssbo)
gl.flags &= ~RFL_SHADER_STORAGE_BUFFER;

if (gl_no_persistent_buffer)
gl.flags &= ~RFL_BUFFER_STORAGE;

if (gl_no_clip_planes)
gl.flags |= RFL_NO_CLIP_PLANES;

if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
if (gl_version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;

Expand Down
4 changes: 3 additions & 1 deletion src/common/rendering/hwrenderer/data/hw_cvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,6 @@ CUSTOM_CVAR (Int, gl_storage_buffer_type, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG |
Printf("You must restart " GAMENAME " for this change to take effect.\n");
}

CVARD(Bool, gl_no_persistent_buffer, false, 0, "Only used to test mobile buffer")
CVARD(Bool, gl_no_persistent_buffer, false, 0, "Disable persistent buffer storage support")
CVARD(Bool, gl_no_clip_planes, false, 0, "Disable clip planes support")
CVARD(Bool, gl_no_ssbo, false, 0, "Disable SSBO support")
4 changes: 3 additions & 1 deletion src/common/rendering/hwrenderer/data/hw_cvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ EXTERN_CVAR(Bool, gl_brightfog)
EXTERN_CVAR(Bool, gl_lightadditivesurfaces)
EXTERN_CVAR(Bool, gl_notexturefill)

EXTERN_CVAR(Bool, gl_no_persistent_buffer)
EXTERN_CVAR(Bool, gl_no_persistent_buffer)
EXTERN_CVAR(Bool, gl_no_clip_planes)
EXTERN_CVAR(Bool, gl_no_ssbo)
3 changes: 2 additions & 1 deletion src/common/rendering/v_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ EXTERN_CVAR(Int, win_y)
EXTERN_CVAR(Int, win_w)
EXTERN_CVAR(Int, win_h)
EXTERN_CVAR(Bool, win_maximized)
EXTERN_CVAR(Int, gl_storage_buffer_type)

struct FColormap;
enum FTextureFormat : uint32_t;
Expand Down Expand Up @@ -182,7 +183,7 @@ class DFrameBuffer
// SSBOs have quite worse performance for read only data, so keep this around only as long as Vulkan has not been adapted yet.
bool useSSBO()
{
return IsVulkan() || ((hwcaps & RFL_SHADER_STORAGE_BUFFER) && allowSSBO() && !strstr(vendorstring, "Intel"));
return IsVulkan() || ((hwcaps & RFL_SHADER_STORAGE_BUFFER) && allowSSBO() && !strstr(vendorstring, "Intel") && gl_storage_buffer_type == 1);
}

virtual DCanvas* GetCanvas() { return nullptr; }
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/hw_entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou

R_SetupFrame(mainvp, r_viewwindow, camera);

if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadowmap && screen->allowSSBO() && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER))
if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadowmap)
{
screen->SetAABBTree(camera->Level->aabbTree);
screen->mShadowMap.SetCollectLights([=] {
Expand Down

0 comments on commit 2c8481f

Please sign in to comment.