summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2017-03-16 21:39:17 +0100
committerGitHub <noreply@github.com>2017-03-16 21:39:17 +0100
commita0acdfc070d5bed422d3cdafd7675fc28af4eed5 (patch)
tree0edd5873022cafad1caf3c9588ae6fda8e201d75 /Source/Core/VideoBackends/OGL/Render.cpp
parentb2ab713ad93f8734fc65e104f4dc6c1c9a3e9411 (diff)
parent134317e07f7c371000389e7c3f45ceaf046eea69 (diff)
Merge pull request #5029 from ligfx/bboximagemask
OGL: implement Bounding Box on systems w/o SSBO
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp71
1 files changed, 39 insertions, 32 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index f898d73722..69554269cb 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -411,7 +411,8 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsPrimitiveRestart =
!DriverDetails::HasBug(DriverDetails::BUG_PRIMITIVE_RESTART) &&
((GLExtensions::Version() >= 310) || GLExtensions::Supports("GL_NV_primitive_restart"));
- g_Config.backend_info.bSupportsBBox =
+ g_Config.backend_info.bSupportsBBox = true;
+ g_Config.backend_info.bSupportsFragmentStoresAndAtomics =
GLExtensions::Supports("GL_ARB_shader_storage_buffer_object");
g_Config.backend_info.bSupportsGSInstancing = GLExtensions::Supports("GL_ARB_gpu_shader5");
g_Config.backend_info.bSupportsSSAA = GLExtensions::Supports("GL_ARB_gpu_shader5") &&
@@ -497,7 +498,7 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsGSInstancing =
g_Config.backend_info.bSupportsGeometryShaders && g_ogl_config.SupportedESPointSize > 0;
g_Config.backend_info.bSupportsSSAA = g_ogl_config.bSupportsAEP;
- g_Config.backend_info.bSupportsBBox = true;
+ g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true;
g_ogl_config.bSupportsMSAA = true;
g_ogl_config.bSupports2DTextureStorage = true;
if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisamples > 1 &&
@@ -518,7 +519,7 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsGSInstancing = g_ogl_config.SupportedESPointSize > 0;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsSSAA = true;
- g_Config.backend_info.bSupportsBBox = true;
+ g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true;
g_ogl_config.bSupportsCopySubImage = true;
g_ogl_config.bSupportsGLBaseVertex = true;
g_ogl_config.bSupportsDebug = true;
@@ -655,10 +656,13 @@ Renderer::Renderer()
// options while running
g_Config.bRunning = true;
- glStencilFunc(GL_ALWAYS, 0, 0);
- glBlendFunc(GL_ONE, GL_ONE);
+ // The stencil is used for bounding box emulation when SSBOs are not available
+ glDisable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 1, 0xFF);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
- glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
+ // Reset The Current Viewport
+ glViewport(0, 0, GetTargetWidth(), GetTargetHeight());
if (g_ActiveConfig.backend_info.bSupportsClipControl)
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
@@ -675,10 +679,9 @@ Renderer::Renderer()
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
- glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST);
-
glScissor(0, 0, GetTargetWidth(), GetTargetHeight());
+ glBlendFunc(GL_ONE, GL_ONE);
glBlendColor(0, 0, 0, 0.5f);
glClearDepthf(1.0f);
@@ -731,8 +734,8 @@ void Renderer::Shutdown()
void Renderer::Init()
{
// Initialize the FramebufferManager
- g_framebuffer_manager =
- std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
+ g_framebuffer_manager = std::make_unique<FramebufferManager>(
+ m_target_width, m_target_height, s_MSAASamples, BoundingBox::NeedsStencilBuffer());
m_post_processor = std::make_unique<OpenGLPostProcessing>();
s_raster_font = std::make_unique<RasterFont>();
@@ -1335,34 +1338,38 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
}
bool target_size_changed = CalculateTargetSize();
- if (target_size_changed || xfbchanged || window_resized ||
- (s_last_multisamples != g_ActiveConfig.iMultisamples) ||
- (s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0)))
+ bool stencil_buffer_enabled =
+ static_cast<FramebufferManager*>(g_framebuffer_manager.get())->HasStencilBuffer();
+
+ bool fb_needs_update = target_size_changed ||
+ s_last_multisamples != g_ActiveConfig.iMultisamples ||
+ stencil_buffer_enabled != BoundingBox::NeedsStencilBuffer() ||
+ s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0);
+
+ if (xfbchanged || window_resized || fb_needs_update)
{
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
-
UpdateDrawRectangle();
+ }
+ if (fb_needs_update)
+ {
+ s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
+ s_last_multisamples = g_ActiveConfig.iMultisamples;
+ s_MSAASamples = s_last_multisamples;
- if (target_size_changed || s_last_multisamples != g_ActiveConfig.iMultisamples ||
- s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
+ if (s_MSAASamples > 1 && s_MSAASamples > g_ogl_config.max_samples)
{
- s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
- s_last_multisamples = g_ActiveConfig.iMultisamples;
- s_MSAASamples = s_last_multisamples;
-
- if (s_MSAASamples > 1 && s_MSAASamples > g_ogl_config.max_samples)
- {
- s_MSAASamples = g_ogl_config.max_samples;
- OSD::AddMessage(StringFromFormat(
- "%d Anti Aliasing samples selected, but only %d supported by your GPU.",
- s_last_multisamples, g_ogl_config.max_samples),
- 10000);
- }
-
- g_framebuffer_manager.reset();
- g_framebuffer_manager =
- std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
+ s_MSAASamples = g_ogl_config.max_samples;
+ OSD::AddMessage(
+ StringFromFormat("%d Anti Aliasing samples selected, but only %d supported by your GPU.",
+ s_last_multisamples, g_ogl_config.max_samples),
+ 10000);
}
+
+ g_framebuffer_manager.reset();
+ g_framebuffer_manager = std::make_unique<FramebufferManager>(
+ m_target_width, m_target_height, s_MSAASamples, BoundingBox::NeedsStencilBuffer());
+ BoundingBox::SetTargetSizeChanged(m_target_width, m_target_height);
}
// ---------------------------------------------------------------------