Merge pull request #7984 from myfreeweb/egl-fix
Fix EGL initialization not setting 'n'
This commit is contained in:
commit
ff8e10f014
|
@ -330,12 +330,11 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
EGLenum platform,
|
EGLenum platform,
|
||||||
void *display_data,
|
void *display_data,
|
||||||
EGLint *major, EGLint *minor,
|
EGLint *major, EGLint *minor,
|
||||||
EGLint *n, const EGLint *attrib_ptr,
|
EGLint *count, const EGLint *attrib_ptr,
|
||||||
egl_accept_config_cb_t cb)
|
egl_accept_config_cb_t cb)
|
||||||
{
|
{
|
||||||
EGLint i;
|
EGLint i;
|
||||||
EGLConfig *configs = NULL;
|
EGLConfig *configs = NULL;
|
||||||
EGLint count = 0;
|
|
||||||
EGLint matched = 0;
|
EGLint matched = 0;
|
||||||
int config_index = -1;
|
int config_index = -1;
|
||||||
EGLDisplay dpy = get_egl_display(platform, display_data);
|
EGLDisplay dpy = get_egl_display(platform, display_data);
|
||||||
|
@ -353,24 +352,24 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
|
|
||||||
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)
|
if (!eglGetConfigs(egl->dpy, NULL, 0, count) || *count < 1)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No configs to choose from.\n");
|
RARCH_ERR("[EGL]: No configs to choose from.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
configs = malloc(count * sizeof(*configs));
|
configs = malloc(*count * sizeof(*configs));
|
||||||
if (!configs)
|
if (!configs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!eglChooseConfig(egl->dpy, attrib_ptr,
|
if (!eglChooseConfig(egl->dpy, attrib_ptr,
|
||||||
configs, count, &matched) || !matched)
|
configs, *count, &matched) || !matched)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
|
RARCH_ERR("[EGL]: No EGL configs with appropriate attributes.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < *count; i++)
|
||||||
{
|
{
|
||||||
if (!cb || cb(display_data, egl->dpy, configs[i]))
|
if (!cb || cb(display_data, egl->dpy, configs[i]))
|
||||||
{
|
{
|
||||||
|
@ -381,7 +380,7 @@ bool egl_init_context(egl_ctx_data_t *egl,
|
||||||
|
|
||||||
free(configs);
|
free(configs);
|
||||||
|
|
||||||
if (i == count)
|
if (i == *count)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
|
RARCH_ERR("[EGL]: No EGL config found which satifies requirements.\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -568,7 +568,7 @@ static const struct wl_seat_listener seat_listener = {
|
||||||
|
|
||||||
/* Touch handle functions */
|
/* Touch handle functions */
|
||||||
|
|
||||||
bool wayland_context_gettouchpos(void *data, unsigned id,
|
bool wayland_context_gettouchpos(void *data, unsigned id,
|
||||||
unsigned* touch_x, unsigned* touch_y)
|
unsigned* touch_x, unsigned* touch_y)
|
||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
@ -619,7 +619,7 @@ static const struct xdg_wm_base_listener xdg_shell_listener = {
|
||||||
|
|
||||||
static void handle_surface_config(void *data, struct xdg_surface *surface,
|
static void handle_surface_config(void *data, struct xdg_surface *surface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
xdg_surface_ack_configure(surface, serial);
|
xdg_surface_ack_configure(surface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
|
||||||
int32_t width, int32_t height, struct wl_array *states)
|
int32_t width, int32_t height, struct wl_array *states)
|
||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
|
||||||
wl->fullscreen = false;
|
wl->fullscreen = false;
|
||||||
wl->maximized = false;
|
wl->maximized = false;
|
||||||
const uint32_t *state;
|
const uint32_t *state;
|
||||||
|
@ -657,7 +657,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
|
||||||
wl->width = width;
|
wl->width = width;
|
||||||
wl->height = height;
|
wl->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl->configured = false;
|
wl->configured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ static const struct zxdg_shell_v6_listener zxdg_shell_v6_listener = {
|
||||||
|
|
||||||
static void handle_zxdg_surface_config(void *data, struct zxdg_surface_v6 *surface,
|
static void handle_zxdg_surface_config(void *data, struct zxdg_surface_v6 *surface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
zxdg_surface_v6_ack_configure(surface, serial);
|
zxdg_surface_v6_ack_configure(surface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,7 +695,7 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top
|
||||||
int32_t width, int32_t height, struct wl_array *states)
|
int32_t width, int32_t height, struct wl_array *states)
|
||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
|
||||||
wl->fullscreen = false;
|
wl->fullscreen = false;
|
||||||
wl->maximized = false;
|
wl->maximized = false;
|
||||||
const uint32_t *state;
|
const uint32_t *state;
|
||||||
|
@ -721,7 +721,7 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top
|
||||||
wl->width = width;
|
wl->width = width;
|
||||||
wl->height = height;
|
wl->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl->configured = false;
|
wl->configured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,7 +1147,7 @@ static void gfx_ctx_wl_update_title(void *data, void *data2)
|
||||||
else if (wl->zxdg_toplevel) {
|
else if (wl->zxdg_toplevel) {
|
||||||
if (wl->deco) {
|
if (wl->deco) {
|
||||||
zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||||
}
|
}
|
||||||
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title);
|
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title);
|
||||||
}
|
}
|
||||||
else if (wl->shell_surf)
|
else if (wl->shell_surf)
|
||||||
|
@ -1318,23 +1318,23 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Wayland]: Using zxdg_shell_v6 interface.\n");
|
RARCH_LOG("[Wayland]: Using zxdg_shell_v6 interface.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl->xdg_shell && !wl->zxdg_shell)
|
if (!wl->xdg_shell && !wl->zxdg_shell)
|
||||||
{
|
{
|
||||||
RARCH_WARN("[Wayland]: Fallback to deprecated wl_shell interface!.\n");
|
RARCH_WARN("[Wayland]: Fallback to deprecated wl_shell interface!.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl->xdg_shell && !wl->zxdg_shell && !wl->shell)
|
if (!wl->xdg_shell && !wl->zxdg_shell && !wl->shell)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Wayland]: Failed to create shell.\n");
|
RARCH_ERR("[Wayland]: Failed to create shell.\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl->idle_inhibit_manager)
|
if (!wl->idle_inhibit_manager)
|
||||||
{
|
{
|
||||||
RARCH_WARN("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol!\n");
|
RARCH_WARN("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl->deco_manager)
|
if (!wl->deco_manager)
|
||||||
{
|
{
|
||||||
RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n");
|
RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n");
|
||||||
|
@ -1562,26 +1562,26 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl->xdg_shell) {
|
if (wl->xdg_shell) {
|
||||||
wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->xdg_shell, wl->surface);
|
wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->xdg_shell, wl->surface);
|
||||||
xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl);
|
xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl);
|
||||||
|
|
||||||
wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface);
|
wl->xdg_toplevel = xdg_surface_get_toplevel(wl->xdg_surface);
|
||||||
xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl);
|
xdg_toplevel_add_listener(wl->xdg_toplevel, &xdg_toplevel_listener, wl);
|
||||||
|
|
||||||
xdg_toplevel_set_app_id(wl->xdg_toplevel, "retroarch");
|
xdg_toplevel_set_app_id(wl->xdg_toplevel, "retroarch");
|
||||||
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
|
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
|
||||||
|
|
||||||
if (wl->deco_manager) {
|
if (wl->deco_manager) {
|
||||||
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
||||||
wl->deco_manager, wl->xdg_toplevel);
|
wl->deco_manager, wl->xdg_toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Waiting for xdg_toplevel to be configured before starting to draw */
|
/* Waiting for xdg_toplevel to be configured before starting to draw */
|
||||||
wl_surface_commit(wl->surface);
|
wl_surface_commit(wl->surface);
|
||||||
wl->configured = true;
|
wl->configured = true;
|
||||||
|
|
||||||
while (wl->configured) {
|
while (wl->configured) {
|
||||||
wl_display_dispatch(wl->input.dpy);
|
wl_display_dispatch(wl->input.dpy);
|
||||||
}
|
}
|
||||||
|
@ -1590,22 +1590,22 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
|
||||||
} else if (wl->zxdg_shell) {
|
} else if (wl->zxdg_shell) {
|
||||||
wl->zxdg_surface = zxdg_shell_v6_get_xdg_surface(wl->zxdg_shell, wl->surface);
|
wl->zxdg_surface = zxdg_shell_v6_get_xdg_surface(wl->zxdg_shell, wl->surface);
|
||||||
zxdg_surface_v6_add_listener(wl->zxdg_surface, &zxdg_surface_v6_listener, wl);
|
zxdg_surface_v6_add_listener(wl->zxdg_surface, &zxdg_surface_v6_listener, wl);
|
||||||
|
|
||||||
wl->zxdg_toplevel = zxdg_surface_v6_get_toplevel(wl->zxdg_surface);
|
wl->zxdg_toplevel = zxdg_surface_v6_get_toplevel(wl->zxdg_surface);
|
||||||
zxdg_toplevel_v6_add_listener(wl->zxdg_toplevel, &zxdg_toplevel_v6_listener, wl);
|
zxdg_toplevel_v6_add_listener(wl->zxdg_toplevel, &zxdg_toplevel_v6_listener, wl);
|
||||||
|
|
||||||
zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "retroarch");
|
zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "retroarch");
|
||||||
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch");
|
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch");
|
||||||
|
|
||||||
if (wl->deco_manager) {
|
if (wl->deco_manager) {
|
||||||
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
||||||
wl->deco_manager, wl->xdg_toplevel);
|
wl->deco_manager, wl->xdg_toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Waiting for xdg_toplevel to be configured before starting to draw */
|
/* Waiting for xdg_toplevel to be configured before starting to draw */
|
||||||
wl_surface_commit(wl->surface);
|
wl_surface_commit(wl->surface);
|
||||||
wl->configured = true;
|
wl->configured = true;
|
||||||
|
|
||||||
while (wl->configured) {
|
while (wl->configured) {
|
||||||
wl_display_dispatch(wl->input.dpy);
|
wl_display_dispatch(wl->input.dpy);
|
||||||
}
|
}
|
||||||
|
@ -1618,7 +1618,7 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
|
||||||
wl_shell_surface_set_class(wl->shell_surf, "RetroArch");
|
wl_shell_surface_set_class(wl->shell_surf, "RetroArch");
|
||||||
wl_shell_surface_set_title(wl->shell_surf, "RetroArch");
|
wl_shell_surface_set_title(wl->shell_surf, "RetroArch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (wl_api)
|
switch (wl_api)
|
||||||
{
|
{
|
||||||
|
@ -1718,7 +1718,7 @@ static bool gfx_ctx_wl_has_focus(void *data)
|
||||||
static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
|
static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
|
||||||
if (!wl->idle_inhibit_manager)
|
if (!wl->idle_inhibit_manager)
|
||||||
|
|
Loading…
Reference in New Issue