Move all EGL functions to egl_common.c file
This commit is contained in:
parent
063986a4b3
commit
d5cdfbb7ba
|
@ -30,7 +30,6 @@
|
||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
#include "../../frontend/frontend_driver.h"
|
#include "../../frontend/frontend_driver.h"
|
||||||
|
|
||||||
|
|
||||||
/* Normal DirectX 11 backend */
|
/* Normal DirectX 11 backend */
|
||||||
const EGLint backendD3D11[] =
|
const EGLint backendD3D11[] =
|
||||||
{
|
{
|
||||||
|
@ -87,21 +86,23 @@ const char* backendNamesList[] = {
|
||||||
/* Try initializing EGL with the backend specified in display_attr. */
|
/* Try initializing EGL with the backend specified in display_attr. */
|
||||||
static bool angle_try_initialize(egl_ctx_data_t* egl,
|
static bool angle_try_initialize(egl_ctx_data_t* egl,
|
||||||
void* display_data, const EGLint* display_attr,
|
void* display_data, const EGLint* display_attr,
|
||||||
EGLint* major, EGLint* minor) {
|
EGLint* major, EGLint* minor)
|
||||||
|
{
|
||||||
EGLDisplay dpy = EGL_NO_DISPLAY;
|
EGLDisplay dpy = EGL_NO_DISPLAY;
|
||||||
|
|
||||||
PFNEGLGETPLATFORMDISPLAYEXTPROC ptr_eglGetPlatformDisplayEXT =
|
PFNEGLGETPLATFORMDISPLAYEXTPROC ptr_eglGetPlatformDisplayEXT =
|
||||||
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
(PFNEGLGETPLATFORMDISPLAYEXTPROC)egl_get_proc_address("eglGetPlatformDisplayEXT");
|
||||||
|
|
||||||
if (ptr_eglGetPlatformDisplayEXT == NULL)
|
if (!ptr_eglGetPlatformDisplayEXT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dpy = ptr_eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, display_data, display_attr);
|
dpy = ptr_eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, display_data, display_attr);
|
||||||
if (dpy == EGL_NO_DISPLAY) return false;
|
if (dpy == EGL_NO_DISPLAY)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!eglInitialize(dpy, major, minor)) {
|
if (!egl_initialize(dpy, major, minor))
|
||||||
eglTerminate(egl->dpy);
|
{
|
||||||
|
egl_terminate(egl->dpy);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,60 +118,23 @@ bool angle_init_context(egl_ctx_data_t *egl,
|
||||||
EGLint *count, const EGLint *attrib_ptr,
|
EGLint *count, const EGLint *attrib_ptr,
|
||||||
egl_accept_config_cb_t cb)
|
egl_accept_config_cb_t cb)
|
||||||
{
|
{
|
||||||
EGLint i; int j;
|
int j;
|
||||||
EGLConfig *configs = NULL;
|
|
||||||
EGLint matched = 0;
|
|
||||||
int config_index = -1;
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
for (j = 0; backendNamesList[j] != NULL; j++) {
|
for (j = 0; backendNamesList[j] != NULL; j++)
|
||||||
|
{
|
||||||
RARCH_LOG("[ANGLE] Trying %s...\n", backendNamesList[j]);
|
RARCH_LOG("[ANGLE] Trying %s...\n", backendNamesList[j]);
|
||||||
if (angle_try_initialize(egl, display_data, backendList[j], major, minor)) {
|
if (angle_try_initialize(egl, display_data, backendList[j], major, minor))
|
||||||
|
{
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) return false;
|
if (!success)
|
||||||
|
return false;
|
||||||
|
|
||||||
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
||||||
|
|
||||||
if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
|
return egl_init_context_common(egl, count, attrib_ptr, cb, display_data);
|
||||||
{
|
|
||||||
RARCH_ERR("[EGL]: No configs to choose from.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
configs = (EGLConfig*)malloc(*count * sizeof(*configs));
|
|
||||||
if (!configs)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!eglChooseConfig(egl->dpy, attrib_ptr,
|
|
||||||
configs, *count, &matched) || !matched)
|
|
||||||
{
|
|
||||||
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < *count; i++)
|
|
||||||
{
|
|
||||||
if (!cb || cb(display_data, egl->dpy, configs[i]))
|
|
||||||
{
|
|
||||||
egl->config = configs[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(configs);
|
|
||||||
|
|
||||||
if (i == *count)
|
|
||||||
{
|
|
||||||
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
egl->major = g_egl_major;
|
|
||||||
egl->minor = g_egl_minor;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,9 @@
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
bool angle_init_context(egl_ctx_data_t* egl, void* display_data, EGLint* major, EGLint* minor,
|
bool angle_init_context(egl_ctx_data_t* egl,
|
||||||
EGLint* count, const EGLint* attrib_ptr, egl_accept_config_cb_t cb);
|
void* display_data, EGLint* major, EGLint* minor,
|
||||||
|
EGLint* count, const EGLint* attrib_ptr, egl_accept_config_cb_t cb);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,11 @@ gfx_ctx_proc_t egl_get_proc_address(const char *symbol)
|
||||||
return eglGetProcAddress(symbol);
|
return eglGetProcAddress(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void egl_terminate(EGLDisplay dpy)
|
||||||
|
{
|
||||||
|
eglTerminate(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
void egl_destroy(egl_ctx_data_t *egl)
|
void egl_destroy(egl_ctx_data_t *egl)
|
||||||
{
|
{
|
||||||
if (egl->dpy)
|
if (egl->dpy)
|
||||||
|
@ -133,7 +138,7 @@ void egl_destroy(egl_ctx_data_t *egl)
|
||||||
|
|
||||||
if (egl->surf != EGL_NO_SURFACE)
|
if (egl->surf != EGL_NO_SURFACE)
|
||||||
eglDestroySurface(egl->dpy, egl->surf);
|
eglDestroySurface(egl->dpy, egl->surf);
|
||||||
eglTerminate(egl->dpy);
|
egl_terminate(egl->dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Be as careful as possible in deinit.
|
/* Be as careful as possible in deinit.
|
||||||
|
@ -329,31 +334,17 @@ bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool egl_init_context(egl_ctx_data_t *egl,
|
bool egl_init_context_common(
|
||||||
EGLenum platform,
|
egl_ctx_data_t *egl, EGLint *count,
|
||||||
void *display_data,
|
const EGLint *attrib_ptr,
|
||||||
EGLint *major, EGLint *minor,
|
egl_accept_config_cb_t cb,
|
||||||
EGLint *count, const EGLint *attrib_ptr,
|
void *display_data)
|
||||||
egl_accept_config_cb_t cb)
|
|
||||||
{
|
{
|
||||||
EGLint i;
|
EGLint i;
|
||||||
EGLConfig *configs = NULL;
|
|
||||||
EGLint matched = 0;
|
EGLint matched = 0;
|
||||||
int config_index = -1;
|
EGLConfig *configs = NULL;
|
||||||
EGLDisplay dpy = get_egl_display(platform, display_data);
|
if (!egl)
|
||||||
|
|
||||||
if (dpy == EGL_NO_DISPLAY)
|
|
||||||
{
|
|
||||||
RARCH_ERR("[EGL]: Couldn't get EGL display.\n");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
egl->dpy = dpy;
|
|
||||||
|
|
||||||
if (!eglInitialize(egl->dpy, major, minor))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
|
||||||
|
|
||||||
if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
|
if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
|
||||||
{
|
{
|
||||||
|
@ -395,6 +386,38 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool egl_initialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
|
||||||
|
{
|
||||||
|
return eglInitialize(dpy, major, minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
|
EGLenum platform,
|
||||||
|
void *display_data,
|
||||||
|
EGLint *major, EGLint *minor,
|
||||||
|
EGLint *count, const EGLint *attrib_ptr,
|
||||||
|
egl_accept_config_cb_t cb)
|
||||||
|
{
|
||||||
|
int config_index = -1;
|
||||||
|
EGLDisplay dpy = get_egl_display(platform, display_data);
|
||||||
|
|
||||||
|
if (dpy == EGL_NO_DISPLAY)
|
||||||
|
{
|
||||||
|
RARCH_ERR("[EGL]: Couldn't get EGL display.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
egl->dpy = dpy;
|
||||||
|
|
||||||
|
if (!egl_initialize(egl->dpy, major, minor))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RARCH_LOG("[EGL]: EGL version: %d.%d\n", *major, *minor);
|
||||||
|
|
||||||
|
return egl_init_context_common(egl, count, attrib_ptr, cb,
|
||||||
|
display_data);
|
||||||
|
}
|
||||||
|
|
||||||
bool egl_bind_api(EGLenum egl_api)
|
bool egl_bind_api(EGLenum egl_api)
|
||||||
{
|
{
|
||||||
return eglBindAPI(egl_api);
|
return eglBindAPI(egl_api);
|
||||||
|
|
|
@ -78,6 +78,8 @@ void egl_report_error(void);
|
||||||
|
|
||||||
void egl_destroy(egl_ctx_data_t *egl);
|
void egl_destroy(egl_ctx_data_t *egl);
|
||||||
|
|
||||||
|
void egl_terminate(EGLDisplay dpy);
|
||||||
|
|
||||||
gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
|
gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
|
||||||
|
|
||||||
void egl_bind_hw_render(egl_ctx_data_t *egl, bool enable);
|
void egl_bind_hw_render(egl_ctx_data_t *egl, bool enable);
|
||||||
|
@ -91,6 +93,14 @@ void egl_get_video_size(egl_ctx_data_t *egl, unsigned *width, unsigned *height);
|
||||||
typedef bool (*egl_accept_config_cb_t)(void *display_data, EGLDisplay dpy, EGLConfig config);
|
typedef bool (*egl_accept_config_cb_t)(void *display_data, EGLDisplay dpy, EGLConfig config);
|
||||||
bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config);
|
bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config);
|
||||||
|
|
||||||
|
bool egl_initialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||||
|
|
||||||
|
bool egl_init_context_common(
|
||||||
|
egl_ctx_data_t *egl, EGLint *count,
|
||||||
|
const EGLint *attrib_ptr,
|
||||||
|
egl_accept_config_cb_t cb,
|
||||||
|
void *display_data);
|
||||||
|
|
||||||
bool egl_init_context(egl_ctx_data_t *egl,
|
bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
EGLenum platform,
|
EGLenum platform,
|
||||||
void *display_data,
|
void *display_data,
|
||||||
|
|
Loading…
Reference in New Issue