Create generic egl_get_proc_address

This commit is contained in:
twinaphex 2015-11-19 13:24:51 +01:00
parent 50f8634902
commit ffbb9d0481
11 changed files with 37 additions and 106 deletions

View File

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <retro_assert.h>
#include <retro_log.h> #include <retro_log.h>
#include "egl_common.h" #include "egl_common.h"
@ -46,3 +47,16 @@ void egl_report_error(void)
RARCH_ERR("[EGL]: #0x%x, %s\n", (unsigned)error, str); RARCH_ERR("[EGL]: #0x%x, %s\n", (unsigned)error, str);
} }
gfx_ctx_proc_t egl_get_proc_address(const char *symbol)
{
gfx_ctx_proc_t ret;
void *sym__ = NULL;
retro_assert(sizeof(void*) == sizeof(void (*)(void)));
sym__ = eglGetProcAddress(symbol);
memcpy(&ret, &sym__, sizeof(void*));
return ret;
}

View File

@ -19,6 +19,10 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include "../video_context_driver.h"
void egl_report_error(void); void egl_report_error(void);
gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
#endif #endif

View File

@ -15,7 +15,6 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <EGL/egl.h>
#include <sys/system_properties.h> #include <sys/system_properties.h>
#include <formats/image.h> #include <formats/image.h>
@ -24,6 +23,7 @@
#include "../../general.h" #include "../../general.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_monitor.h" #include "../video_monitor.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
#include "../../frontend/drivers/platform_linux.h" #include "../../frontend/drivers/platform_linux.h"
@ -314,20 +314,6 @@ static void android_gfx_ctx_input_driver(void *data,
*input_data = androidinput; *input_data = androidinput;
} }
static gfx_ctx_proc_t android_gfx_ctx_get_proc_address(
const char *symbol)
{
gfx_ctx_proc_t ret;
void *sym__ = NULL;
retro_assert(sizeof(void*) == sizeof(void (*)(void)));
sym__ = eglGetProcAddress(symbol);
memcpy(&ret, &sym__, sizeof(void*));
return ret;
}
static bool android_gfx_ctx_bind_api(void *data, static bool android_gfx_ctx_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -446,7 +432,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
android_gfx_ctx_has_windowed, android_gfx_ctx_has_windowed,
android_gfx_ctx_swap_buffers, android_gfx_ctx_swap_buffers,
android_gfx_ctx_input_driver, android_gfx_ctx_input_driver,
android_gfx_ctx_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -16,7 +16,6 @@
#include <stdint.h> #include <stdint.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <bps/screen.h> #include <bps/screen.h>
@ -29,6 +28,7 @@
#include "../../general.h" #include "../../general.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_monitor.h" #include "../video_monitor.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
#include "../image/image.h" #include "../image/image.h"
@ -382,19 +382,6 @@ static void gfx_ctx_qnx_input_driver(void *data,
*input_data = NULL; *input_data = NULL;
} }
static gfx_ctx_proc_t gfx_ctx_qnx_get_proc_address(const char *symbol)
{
gfx_ctx_proc_t ret;
void *sym__;
retro_assert(sizeof(void*) == sizeof(void (*)(void)));
sym__ = eglGetProcAddress(symbol);
memcpy(&ret, &sym__, sizeof(void*));
return ret;
}
static bool gfx_ctx_qnx_bind_api(void *data, static bool gfx_ctx_qnx_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -461,7 +448,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
gfx_ctx_qnx_has_windowed, gfx_ctx_qnx_has_windowed,
gfx_ctx_qnx_swap_buffers, gfx_ctx_qnx_swap_buffers,
gfx_ctx_qnx_input_driver, gfx_ctx_qnx_input_driver,
gfx_ctx_qnx_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -30,9 +30,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <libdrm/drm.h> #include <libdrm/drm.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
@ -43,6 +40,7 @@
#include "../../driver.h" #include "../../driver.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
#include "../video_monitor.h" #include "../video_monitor.h"
@ -908,11 +906,6 @@ static bool gfx_ctx_drm_egl_has_windowed(void *data)
return false; return false;
} }
static gfx_ctx_proc_t gfx_ctx_drm_egl_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
}
static bool gfx_ctx_drm_egl_bind_api(void *data, static bool gfx_ctx_drm_egl_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -988,7 +981,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
gfx_ctx_drm_egl_has_windowed, gfx_ctx_drm_egl_has_windowed,
gfx_ctx_drm_egl_swap_buffers, gfx_ctx_drm_egl_swap_buffers,
gfx_ctx_drm_egl_input_driver, gfx_ctx_drm_egl_input_driver,
gfx_ctx_drm_egl_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -17,14 +17,12 @@
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#include "../../driver.h" #include "../../driver.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_context_driver.h" #include "../video_context_driver.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
#include "../video_monitor.h" #include "../video_monitor.h"
@ -274,11 +272,6 @@ static bool gfx_ctx_emscripten_has_windowed(void *data)
return true; return true;
} }
static gfx_ctx_proc_t gfx_ctx_emscripten_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
}
static float gfx_ctx_emscripten_translate_aspect(void *data, static float gfx_ctx_emscripten_translate_aspect(void *data,
unsigned width, unsigned height) unsigned width, unsigned height)
{ {
@ -323,7 +316,7 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = {
gfx_ctx_emscripten_has_windowed, gfx_ctx_emscripten_has_windowed,
gfx_ctx_emscripten_swap_buffers, gfx_ctx_emscripten_swap_buffers,
gfx_ctx_emscripten_input_driver, gfx_ctx_emscripten_input_driver,
gfx_ctx_emscripten_get_proc_address, egl_get_proc_address,
gfx_ctx_emscripten_init_egl_image_buffer, gfx_ctx_emscripten_init_egl_image_buffer,
gfx_ctx_emscripten_write_egl_image, gfx_ctx_emscripten_write_egl_image,
NULL, NULL,

View File

@ -18,8 +18,6 @@
#include <signal.h> #include <signal.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <EGL/egl.h>
/* Includes and defines for framebuffer size retrieval */ /* Includes and defines for framebuffer size retrieval */
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/vt.h> #include <linux/vt.h>
@ -30,6 +28,7 @@
#include "../../general.h" #include "../../general.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_monitor.h" #include "../video_monitor.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
struct fbdev_window native_window; struct fbdev_window native_window;
@ -281,19 +280,6 @@ static void gfx_ctx_mali_fbdev_input_driver(void *data,
*input_data = NULL; *input_data = NULL;
} }
static gfx_ctx_proc_t gfx_ctx_mali_fbdev_get_proc_address(const char *symbol)
{
gfx_ctx_proc_t ret;
void *sym__ = NULL;
retro_assert(sizeof(void*) == sizeof(void (*)(void)));
sym__ = eglGetProcAddress(symbol);
memcpy(&ret, &sym__, sizeof(void*));
return ret;
}
static bool gfx_ctx_mali_fbdev_bind_api(void *data, static bool gfx_ctx_mali_fbdev_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -340,7 +326,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
gfx_ctx_mali_fbdev_has_windowed, gfx_ctx_mali_fbdev_has_windowed,
gfx_ctx_mali_fbdev_swap_buffers, gfx_ctx_mali_fbdev_swap_buffers,
gfx_ctx_mali_fbdev_input_driver, gfx_ctx_mali_fbdev_input_driver,
gfx_ctx_mali_fbdev_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -21,8 +21,6 @@
#include <sched.h> #include <sched.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglext_brcm.h> #include <EGL/eglext_brcm.h>
#include <VG/openvg.h> #include <VG/openvg.h>
#include <bcm_host.h> #include <bcm_host.h>
@ -32,6 +30,7 @@
#include "../../driver.h" #include "../../driver.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_context_driver.h" #include "../video_context_driver.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
#include "../video_monitor.h" #include "../video_monitor.h"
@ -486,11 +485,6 @@ static bool gfx_ctx_vc_has_windowed(void *data)
return false; return false;
} }
static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
}
static float gfx_ctx_vc_translate_aspect(void *data, static float gfx_ctx_vc_translate_aspect(void *data,
unsigned width, unsigned height) unsigned width, unsigned height)
{ {
@ -518,9 +512,9 @@ static bool gfx_ctx_vc_image_buffer_init(void *data,
return false; return false;
peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)
gfx_ctx_vc_get_proc_address("eglCreateImageKHR"); egl_get_proc_address("eglCreateImageKHR");
peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)
gfx_ctx_vc_get_proc_address("eglDestroyImageKHR"); egl_get_proc_address("eglDestroyImageKHR");
if (!peglCreateImageKHR || !peglDestroyImageKHR if (!peglCreateImageKHR || !peglDestroyImageKHR
|| !gfx_ctx_vc_egl_query_extension("KHR_image")) || !gfx_ctx_vc_egl_query_extension("KHR_image"))
@ -657,7 +651,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
gfx_ctx_vc_has_windowed, gfx_ctx_vc_has_windowed,
gfx_ctx_vc_swap_buffers, gfx_ctx_vc_swap_buffers,
gfx_ctx_vc_input_driver, gfx_ctx_vc_input_driver,
gfx_ctx_vc_get_proc_address, egl_get_proc_address,
gfx_ctx_vc_image_buffer_init, gfx_ctx_vc_image_buffer_init,
gfx_ctx_vc_image_buffer_write, gfx_ctx_vc_image_buffer_write,
NULL, NULL,

View File

@ -16,12 +16,11 @@
#include <signal.h> #include <signal.h>
#include <EGL/egl.h>
#include "../../driver.h" #include "../../driver.h"
#include "../../general.h" #include "../../general.h"
#include "../../runloop.h" #include "../../runloop.h"
#include "../video_monitor.h" #include "../video_monitor.h"
#include "../common/egl_common.h"
#include "../common/gl_common.h" #include "../common/gl_common.h"
static EGLContext g_egl_ctx; static EGLContext g_egl_ctx;
@ -254,19 +253,6 @@ static void gfx_ctx_vivante_input_driver(void *data,
*input_data = NULL; *input_data = NULL;
} }
static gfx_ctx_proc_t gfx_ctx_vivante_get_proc_address(const char *symbol)
{
gfx_ctx_proc_t ret;
void *sym__;
retro_assert(sizeof(void*) == sizeof(void (*)(void)));
sym__ = eglGetProcAddress(symbol);
memcpy(&ret, &sym__, sizeof(void*));
return ret;
}
static bool gfx_ctx_vivante_bind_api(void *data, static bool gfx_ctx_vivante_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -313,7 +299,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
gfx_ctx_vivante_has_windowed, gfx_ctx_vivante_has_windowed,
gfx_ctx_vivante_swap_buffers, gfx_ctx_vivante_swap_buffers,
gfx_ctx_vivante_input_driver, gfx_ctx_vivante_input_driver,
gfx_ctx_vivante_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -662,11 +662,6 @@ static bool gfx_ctx_wl_has_windowed(void *data)
return true; return true;
} }
static gfx_ctx_proc_t gfx_ctx_wl_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
}
static bool gfx_ctx_wl_bind_api(void *data, static bool gfx_ctx_wl_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -709,9 +704,7 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable)
wl->g_use_hw_ctx = enable; wl->g_use_hw_ctx = enable;
if (!wl->g_egl_dpy) if (!wl->g_egl_dpy || !wl->g_egl_surf)
return;
if (!wl->g_egl_surf)
return; return;
eglMakeCurrent(wl->g_egl_dpy, wl->g_egl_surf, wl->g_egl_surf, eglMakeCurrent(wl->g_egl_dpy, wl->g_egl_surf, wl->g_egl_surf,
@ -882,7 +875,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
gfx_ctx_wl_has_windowed, gfx_ctx_wl_has_windowed,
gfx_ctx_wl_swap_buffers, gfx_ctx_wl_swap_buffers,
gfx_ctx_wl_input_driver, gfx_ctx_wl_input_driver,
gfx_ctx_wl_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
NULL, NULL,

View File

@ -549,11 +549,6 @@ static bool gfx_ctx_xegl_has_windowed(void *data)
return true; return true;
} }
static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
}
static bool gfx_ctx_xegl_bind_api(void *data, static bool gfx_ctx_xegl_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
@ -627,7 +622,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl =
gfx_ctx_xegl_has_windowed, gfx_ctx_xegl_has_windowed,
gfx_ctx_xegl_swap_buffers, gfx_ctx_xegl_swap_buffers,
gfx_ctx_xegl_input_driver, gfx_ctx_xegl_input_driver,
gfx_ctx_xegl_get_proc_address, egl_get_proc_address,
NULL, NULL,
NULL, NULL,
gfx_ctx_xegl_show_mouse, gfx_ctx_xegl_show_mouse,