Skip to content

Commit

Permalink
Fix some issues with FBO::GetMaxSamples() and CGlobalRendering::SetMi…
Browse files Browse the repository at this point in the history
…nSampleShadingRate(). Stopgap before bigger headless stub rework
  • Loading branch information
lhog committed Feb 7, 2025
1 parent 1132cdc commit 872e245
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
24 changes: 6 additions & 18 deletions rts/Rendering/GL/FBO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,28 +529,16 @@ void FBO::CreateRenderBufferMultisample(const GLenum attachment, const GLenum fo

GLsizei FBO::GetMaxSamples()
{
RECOIL_DETAILED_TRACY_ZONE;
if (maxSamples >= 0)
return maxSamples;

#ifdef HEADLESS
maxSamples = 1;
#else
// set maxSamples once
if (maxSamples == -1) {
bool multisampleExtensionFound = false;

#ifdef GLAD_GL_EXT_framebuffer_multisample
multisampleExtensionFound = multisampleExtensionFound || (GLAD_GL_EXT_framebuffer_multisample && GLAD_GL_EXT_framebuffer_blit);
#endif
#ifdef GLAD_GL_ARB_framebuffer_object
multisampleExtensionFound = multisampleExtensionFound || GLAD_GL_ARB_framebuffer_object;
#endif

if (multisampleExtensionFound) {
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
maxSamples = std::max(0, maxSamples);
} else {
maxSamples = 0;
}
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
maxSamples = std::max(0, maxSamples);
}

#endif // HEADLESS
return maxSamples;
}
11 changes: 6 additions & 5 deletions rts/Rendering/GlobalRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,18 +1784,19 @@ int CGlobalRendering::DepthBitsToFormat(int bits)

void CGlobalRendering::SetMinSampleShadingRate()
{
#ifdef GLAD_ARB_sample_shading
#ifndef HEADLESS
if (!GLAD_GL_VERSION_4_0)
return;

if (msaaLevel > 0 && minSampleShadingRate > 0.0f) {
// Enable sample shading
glEnable(GL_SAMPLE_SHADING);
if (GLAD_GL_VERSION_4_0) {
glMinSampleShading(minSampleShadingRate);
}
glMinSampleShading(minSampleShadingRate);
}
else {
glDisable(GL_SAMPLE_SHADING);
}
#endif
#endif // !HEADLESS
}

bool CGlobalRendering::SetWindowMinMaximized(bool maximize) const
Expand Down
1 change: 1 addition & 0 deletions rts/lib/headlessStubs/gladstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ extern "C" {
#define GLAD_GL_EXT_texture_array GL_FALSE
#define GLAD_GL_ARB_draw_indirect GL_FALSE
#define GLAD_GL_ARB_base_instance GL_FALSE
#define GLAD_GL_ARB_sample_shading GL_FALSE

#define GLXEW_SGI_video_sync GL_FALSE

Expand Down
7 changes: 1 addition & 6 deletions rts/lib/headlessStubs/glstub.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef _GL_STUB_H_
#define _GL_STUB_H_
#pragma once

#undef GL_GLEXT_LEGACY
#define GL_GLEXT_PROTOTYPES
Expand All @@ -15,7 +14,3 @@

#include <GL/gl.h>
#include <GL/glext.h> //gl.h may not include all extensions


#endif // _GL_STUB_H_

0 comments on commit 872e245

Please sign in to comment.