mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(GLX/WGL) Start implementing adaptive VSync (swap_control_tear) for GLX/WGL pt. 1
This commit is contained in:
parent
9bf2fb8f79
commit
98b20d4e5d
@ -47,6 +47,7 @@
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "../common/gl_common.h"
|
||||
#include <gfx/gl_capabilities.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VULKAN
|
||||
@ -106,7 +107,7 @@ static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */
|
||||
|
||||
typedef struct gfx_ctx_cgl_data
|
||||
{
|
||||
void *empty;
|
||||
bool adaptive_vsync;
|
||||
} gfx_ctx_wgl_data_t;
|
||||
|
||||
static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
@ -725,22 +726,63 @@ static void *gfx_ctx_wgl_get_context_data(void *data)
|
||||
|
||||
static uint32_t gfx_ctx_wgl_get_flags(void *data)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
if (win32_core_hw_context_enable)
|
||||
uint32_t flags = 0;
|
||||
gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)data;
|
||||
|
||||
(void)wgl;
|
||||
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
|
||||
|
||||
switch (win32_api)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
|
||||
case GFX_CTX_OPENGL_API:
|
||||
if (wgl)
|
||||
{
|
||||
if (wgl->adaptive_vsync)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC);
|
||||
}
|
||||
}
|
||||
|
||||
if (win32_core_hw_context_enable)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
|
||||
}
|
||||
break;
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags)
|
||||
{
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
|
||||
win32_core_hw_context_enable = true;
|
||||
gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)data;
|
||||
|
||||
(void)wgl;
|
||||
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#ifdef HAVE_OPENGL
|
||||
if (wgl)
|
||||
{
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC))
|
||||
if (gl_query_extension("WGL_EXT_swap_control_tear"))
|
||||
wgl->adaptive_vsync = true;
|
||||
}
|
||||
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
|
||||
win32_core_hw_context_enable = true;
|
||||
#endif
|
||||
break;
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void gfx_ctx_wgl_get_video_output_size(void *data,
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/glx.h>
|
||||
#include <gfx/gl_capabilities.h>
|
||||
|
||||
#ifndef GLX_SAMPLE_BUFFERS
|
||||
#define GLX_SAMPLE_BUFFERS 100000
|
||||
@ -91,6 +92,7 @@ typedef struct gfx_ctx_x_data
|
||||
bool g_debug;
|
||||
bool g_should_reset_mode;
|
||||
bool g_is_double;
|
||||
bool adaptive_vsync;
|
||||
bool core_hw_context_enable;
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
@ -1167,30 +1169,57 @@ static void *gfx_ctx_x_get_context_data(void *data)
|
||||
|
||||
static uint32_t gfx_ctx_x_get_flags(void *data)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
uint32_t flags = 0;
|
||||
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
|
||||
if (x->core_hw_context_enable || x->g_core_es)
|
||||
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
|
||||
|
||||
switch (x_api)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
|
||||
}
|
||||
if (x_enable_msaa)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_MULTISAMPLING);
|
||||
case GFX_CTX_OPENGL_API:
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
if (x->adaptive_vsync)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC);
|
||||
}
|
||||
|
||||
if (x->core_hw_context_enable || x->g_core_es)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
|
||||
}
|
||||
if (x_enable_msaa)
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_MULTISAMPLING);
|
||||
}
|
||||
break;
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void gfx_ctx_x_set_flags(void *data, uint32_t flags)
|
||||
{
|
||||
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
|
||||
x->core_hw_context_enable = true;
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_MULTISAMPLING))
|
||||
x_enable_msaa = true;
|
||||
|
||||
switch (x_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC))
|
||||
if (gl_query_extension("GLX_EXT_swap_control_tear"))
|
||||
x->adaptive_vsync = true;
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
|
||||
x->core_hw_context_enable = true;
|
||||
if (BIT32_GET(flags, GFX_CTX_FLAGS_MULTISAMPLING))
|
||||
x_enable_msaa = true;
|
||||
break;
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_x_make_current(bool release)
|
||||
|
@ -118,7 +118,8 @@ enum display_flags
|
||||
GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES,
|
||||
GFX_CTX_FLAGS_HARD_SYNC,
|
||||
GFX_CTX_FLAGS_BLACK_FRAME_INSERTION,
|
||||
GFX_CTX_FLAGS_MENU_FRAME_FILTERING
|
||||
GFX_CTX_FLAGS_MENU_FRAME_FILTERING,
|
||||
GFX_CTX_FLAGS_ADAPTIVE_VSYNC
|
||||
};
|
||||
|
||||
enum shader_uniform_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user