Refactoring and cleanup of GLInterface (now GLContext)

This commit is contained in:
Stenzek
2018-10-03 23:02:45 +10:00
parent 74b82bab3b
commit 134d967be2
39 changed files with 741 additions and 690 deletions

View File

@ -16,7 +16,7 @@
#include "Common/Assert.h"
#include "Common/Atomic.h"
#include "Common/CommonTypes.h"
#include "Common/GL/GLInterfaceBase.h"
#include "Common/GL/GLContext.h"
#include "Common/GL/GLUtil.h"
#include "Common/Logging/LogManager.h"
#include "Common/MathUtil.h"
@ -354,8 +354,8 @@ static void InitDriverInfo()
// Init functions
Renderer::Renderer()
: ::Renderer(static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u)),
static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u)))
: ::Renderer(static_cast<int>(std::max(g_main_gl_context->GetBackBufferWidth(), 1u)),
static_cast<int>(std::max(g_main_gl_context->GetBackBufferHeight(), 1u)))
{
bool bSuccess = true;
@ -365,7 +365,7 @@ Renderer::Renderer()
InitDriverInfo();
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
if (!g_main_gl_context->IsGLES())
{
if (!GLExtensions::Supports("GL_ARB_framebuffer_object"))
{
@ -500,7 +500,7 @@ Renderer::Renderer()
g_Config.backend_info.bSupportsBPTCTextures =
GLExtensions::Supports("GL_ARB_texture_compression_bptc");
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
if (g_main_gl_context->IsGLES())
{
g_ogl_config.SupportedESPointSize =
GLExtensions::Supports("GL_OES_geometry_point_size") ?
@ -730,10 +730,9 @@ Renderer::Renderer()
if (!g_ogl_config.bSupportsGLBufferStorage && !g_ogl_config.bSupportsGLPinnedMemory)
{
OSD::AddMessage(
StringFromFormat("Your OpenGL driver does not support %s_buffer_storage.",
GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3 ? "EXT" : "ARB"),
60000);
OSD::AddMessage(StringFromFormat("Your OpenGL driver does not support %s_buffer_storage.",
g_main_gl_context->IsGLES() ? "EXT" : "ARB"),
60000);
OSD::AddMessage("This device's performance will be terrible.", 60000);
OSD::AddMessage("Please ask your device vendor for an updated OpenGL driver.", 60000);
}
@ -761,7 +760,7 @@ Renderer::Renderer()
// Handle VSync on/off
s_vsync = g_ActiveConfig.IsVSync();
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_VSYNC))
GLInterface->SwapInterval(s_vsync);
g_main_gl_context->SwapInterval(s_vsync);
// Because of the fixed framebuffer size we need to disable the resolution
// options while running
@ -1044,7 +1043,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
std::unique_ptr<u32[]> colorMap(new u32[targetPixelRcWidth * targetPixelRcHeight]);
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
if (g_main_gl_context->IsGLES())
// XXX: Swap colours
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth,
targetPixelRcHeight, GL_RGBA, GL_UNSIGNED_BYTE, colorMap.get());
@ -1351,7 +1350,7 @@ void Renderer::ApplyBlendingState(const BlendingState state, bool force)
GL_XOR, GL_OR, GL_NOR, GL_EQUIV, GL_INVERT, GL_OR_REVERSE,
GL_COPY_INVERTED, GL_OR_INVERTED, GL_NAND, GL_SET};
if (GLInterface->GetMode() != GLInterfaceMode::MODE_OPENGL)
if (g_main_gl_context->IsGLES())
{
// Logic ops aren't available in GLES3
}
@ -1421,7 +1420,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
OSD::DrawMessages();
// Swap the back and front buffers, presenting the image.
GLInterface->Swap();
g_main_gl_context->Swap();
}
else
{
@ -1466,7 +1465,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
{
s_vsync = g_ActiveConfig.IsVSync();
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_VSYNC))
GLInterface->SwapInterval(s_vsync);
g_main_gl_context->SwapInterval(s_vsync);
}
// Clean out old stuff from caches. It's not worth it to clean out the shader caches.
@ -1502,12 +1501,11 @@ void Renderer::CheckForSurfaceChange()
m_surface_handle = m_new_surface_handle;
m_new_surface_handle = nullptr;
GLInterface->UpdateHandle(m_surface_handle);
GLInterface->UpdateSurface();
g_main_gl_context->UpdateSurface(m_surface_handle);
// With a surface change, the window likely has new dimensions.
m_backbuffer_width = GLInterface->GetBackBufferWidth();
m_backbuffer_height = GLInterface->GetBackBufferHeight();
m_backbuffer_width = g_main_gl_context->GetBackBufferWidth();
m_backbuffer_height = g_main_gl_context->GetBackBufferHeight();
}
void Renderer::CheckForSurfaceResize()
@ -1515,7 +1513,7 @@ void Renderer::CheckForSurfaceResize()
if (!m_surface_resized.TestAndClear())
return;
GLInterface->Update();
g_main_gl_context->Update();
m_backbuffer_width = m_new_backbuffer_width;
m_backbuffer_height = m_new_backbuffer_height;
}
@ -1538,7 +1536,7 @@ void Renderer::ResetAPIState()
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
if (!g_main_gl_context->IsGLES())
glDisable(GL_COLOR_LOGIC_OP);
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
{
@ -1717,4 +1715,4 @@ std::unique_ptr<VideoCommon::AsyncShaderCompiler> Renderer::CreateAsyncShaderCom
{
return std::make_unique<SharedContextAsyncShaderCompiler>();
}
}
} // namespace OGL