mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
[Win32] Add ANGLE context
This commit is contained in:
parent
de203390be
commit
7cbdd845ad
@ -47,7 +47,12 @@
|
||||
|
||||
#include "../common/win32_common.h"
|
||||
|
||||
#if defined(HAVE_OPENGL)
|
||||
#ifdef HAVE_EGL
|
||||
#include "../common/egl_common.h"
|
||||
#include "../common/angle_common.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
#include "../common/gl_common.h"
|
||||
#elif defined(HAVE_OPENGL_CORE)
|
||||
#include "../common/gl_core_common.h"
|
||||
@ -103,6 +108,9 @@ static bool wgl_adaptive_vsync = false;
|
||||
#ifdef HAVE_VULKAN
|
||||
static gfx_ctx_vulkan_data_t win32_vk;
|
||||
#endif
|
||||
#ifdef HAVE_EGL
|
||||
static egl_ctx_data_t win32_egl;
|
||||
#endif
|
||||
|
||||
static unsigned win32_major = 0;
|
||||
static unsigned win32_minor = 0;
|
||||
@ -110,7 +118,7 @@ static int win32_interval = 0;
|
||||
static enum gfx_ctx_api win32_api = GFX_CTX_NONE;
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */
|
||||
static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll/libGLESv2.dll */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
@ -155,7 +163,7 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
{
|
||||
gfx_ctx_proc_t func = (gfx_ctx_proc_t)wglGetProcAddress(symbol);
|
||||
if (func)
|
||||
@ -174,7 +182,7 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
static void create_gl_context(HWND hwnd, bool *quit)
|
||||
{
|
||||
struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
|
||||
@ -357,16 +365,72 @@ static void create_gl_context(HWND hwnd, bool *quit)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGLES) && defined(HAVE_EGL)
|
||||
static void create_gles_context(HWND hwnd, bool *quit)
|
||||
{
|
||||
|
||||
EGLint n, major, minor;
|
||||
EGLint format;
|
||||
EGLint attribs[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLint context_attributes[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
if (!angle_init_context(&win32_egl, EGL_DEFAULT_DISPLAY,
|
||||
&major, &minor, &n, attribs, NULL))
|
||||
{
|
||||
egl_report_error();
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!egl_get_native_visual_id(&win32_egl, &format))
|
||||
goto error;
|
||||
|
||||
if (!egl_create_context(&win32_egl, context_attributes))
|
||||
{
|
||||
egl_report_error();
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!egl_create_surface(&win32_egl, hwnd))
|
||||
goto error;
|
||||
|
||||
g_win32_inited = true;
|
||||
return;
|
||||
|
||||
error:
|
||||
*quit = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void create_graphics_context(HWND hwnd, bool *quit)
|
||||
{
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
create_gl_context(hwnd, quit);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#if defined (HAVE_OPENGLES)
|
||||
create_gles_context(hwnd, quit);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_VULKAN_API:
|
||||
{
|
||||
#ifdef HAVE_VULKAN
|
||||
@ -406,7 +470,7 @@ static void gfx_ctx_wgl_swap_interval(void *data, int interval)
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
win32_interval = interval;
|
||||
if (!win32_hrc)
|
||||
return;
|
||||
@ -419,6 +483,16 @@ static void gfx_ctx_wgl_swap_interval(void *data, int interval)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#ifdef HAVE_EGL
|
||||
if (win32_interval != interval)
|
||||
{
|
||||
win32_interval = interval;
|
||||
egl_set_swap_interval(&win32_egl, win32_interval);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_VULKAN_API:
|
||||
#ifdef HAVE_VULKAN
|
||||
if (win32_interval != interval)
|
||||
@ -473,7 +547,11 @@ static void gfx_ctx_wgl_swap_buffers(void *data, void *data2)
|
||||
vulkan_acquire_next_image(&win32_vk);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#if defined(HAVE_EGL)
|
||||
egl_swap_buffers(&win32_egl);
|
||||
#endif
|
||||
break;
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
@ -568,7 +646,11 @@ static void *gfx_ctx_wgl_init(video_frame_info_t *video_info, void *video_driver
|
||||
gfx_ctx_wgl_destroy(NULL);
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
#ifdef HAVE_OPENGL
|
||||
dll_handle = dylib_load("libGLESv2.dll");
|
||||
#else
|
||||
dll_handle = dylib_load("OpenGL32.dll");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
win32_window_reset();
|
||||
@ -607,7 +689,7 @@ static void gfx_ctx_wgl_destroy(void *data)
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
if (win32_hrc)
|
||||
{
|
||||
glFinish();
|
||||
@ -634,6 +716,12 @@ static void gfx_ctx_wgl_destroy(void *data)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#ifdef HAVE_EGL
|
||||
egl_destroy(&win32_egl);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
@ -755,6 +843,10 @@ static bool gfx_ctx_wgl_bind_api(void *data,
|
||||
if (api == GFX_CTX_OPENGL_API)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(HAVE_OPENGLES)
|
||||
if (api == GFX_CTX_OPENGL_ES_API)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(HAVE_VULKAN)
|
||||
if (api == GFX_CTX_VULKAN_API)
|
||||
return true;
|
||||
@ -774,7 +866,7 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable)
|
||||
switch (win32_api)
|
||||
{
|
||||
case GFX_CTX_OPENGL_API:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES)
|
||||
win32_use_hw_ctx = enable;
|
||||
|
||||
if (win32_hdc)
|
||||
@ -782,6 +874,12 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#ifdef HAVE_EGL
|
||||
egl_bind_hw_render(&win32_egl, enable);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
@ -833,6 +931,16 @@ static uint32_t gfx_ctx_wgl_get_flags(void *data)
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
|
||||
#endif
|
||||
#ifdef HAVE_GLSL
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_GLSL);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GFX_CTX_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -207,7 +207,7 @@ VIDEO CONTEXT
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_VULKAN)
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_VULKAN) || defined(HAVE_OPENGLES)
|
||||
#include "../gfx/drivers_context/wgl_ctx.c"
|
||||
#endif
|
||||
|
||||
@ -275,6 +275,10 @@ VIDEO CONTEXT
|
||||
#include "../gfx/drivers_context/vc_egl_ctx.c"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "../gfx/common/angle_common.c"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_X11)
|
||||
|
@ -474,7 +474,7 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
|
||||
#if defined(HAVE_OPENDINGUX_FBDEV)
|
||||
&gfx_ctx_opendingux_fbdev,
|
||||
#endif
|
||||
#if defined(_WIN32) && (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) || defined(HAVE_VULKAN))
|
||||
#if defined(_WIN32) && !defined(__WINRT__) && (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) || defined(HAVE_VULKAN))
|
||||
&gfx_ctx_wgl,
|
||||
#endif
|
||||
#if defined(HAVE_WAYLAND)
|
||||
|
Loading…
x
Reference in New Issue
Block a user