mirror of
https://github.com/libretro/RetroArch
synced 2025-02-08 15:40:14 +00:00
Refactor gfx_ctx_init_first
This commit is contained in:
parent
af302530ef
commit
52052794b2
@ -85,24 +85,45 @@ const gfx_ctx_driver_t *gfx_ctx_find_driver(const char *ident)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t *gfx_ctx_init_first(void *data,
|
||||
static const gfx_ctx_driver_t *ctx_init(void *data,
|
||||
const gfx_ctx_driver_t *ctx,
|
||||
const char *driver,
|
||||
enum gfx_ctx_api api, unsigned major,
|
||||
unsigned minor, bool hw_render_ctx)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; gfx_ctx_drivers[i]; i++)
|
||||
{
|
||||
if (gfx_ctx_drivers[i]->bind_api(data, api, major, minor))
|
||||
{
|
||||
if (gfx_ctx_drivers[i]->bind_hw_render)
|
||||
{
|
||||
gfx_ctx_drivers[i]->bind_hw_render(data,
|
||||
g_settings.video.shared_context && hw_render_ctx);
|
||||
}
|
||||
const gfx_ctx_driver_t *tmp = gfx_ctx_find_driver(driver);
|
||||
|
||||
if (gfx_ctx_drivers[i]->init(data))
|
||||
return gfx_ctx_drivers[i];
|
||||
}
|
||||
if (tmp)
|
||||
ctx = (const gfx_ctx_driver_t*)tmp;
|
||||
|
||||
if (ctx->bind_api(data, api, major, minor))
|
||||
{
|
||||
if (ctx->bind_hw_render)
|
||||
ctx->bind_hw_render(data,
|
||||
g_settings.video.shared_context && hw_render_ctx);
|
||||
|
||||
if (ctx->init(data))
|
||||
return ctx;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t *gfx_ctx_init_first(void *data,
|
||||
const char *driver,
|
||||
enum gfx_ctx_api api, unsigned major,
|
||||
unsigned minor, bool hw_render_ctx)
|
||||
{
|
||||
unsigned i;
|
||||
const gfx_ctx_driver_t *ctx = NULL;
|
||||
|
||||
for (i = 0; gfx_ctx_drivers[i]; i++)
|
||||
{
|
||||
ctx = ctx_init(data, gfx_ctx_drivers[i], driver,
|
||||
api, major, minor, hw_render_ctx);
|
||||
|
||||
if (ctx)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -150,8 +150,8 @@ extern const gfx_ctx_driver_t gfx_ctx_null;
|
||||
const gfx_ctx_driver_t *gfx_ctx_find_driver(const char *ident);
|
||||
|
||||
/* Finds first suitable driver and initializes. */
|
||||
const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, enum gfx_ctx_api api,
|
||||
unsigned major, unsigned minor, bool hw_render_ctx);
|
||||
const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *driver,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
35
gfx/gl.c
35
gfx/gl.c
@ -2017,39 +2017,8 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
||||
gl->shared_context_use = g_settings.video.shared_context
|
||||
&& cb->context_type != RETRO_HW_CONTEXT_NONE;
|
||||
|
||||
if (*g_settings.video.context_driver)
|
||||
{
|
||||
const gfx_ctx_driver_t *ctx = gfx_ctx_find_driver(
|
||||
g_settings.video.context_driver);
|
||||
|
||||
if (ctx)
|
||||
{
|
||||
if (!ctx->bind_api(gl, api, major, minor))
|
||||
{
|
||||
RARCH_ERR("Failed to bind API %s to context %s.\n", api_name, g_settings.video.context_driver);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Enables or disables offscreen HW context. */
|
||||
if (ctx->bind_hw_render)
|
||||
ctx->bind_hw_render(gl, gl->shared_context_use);
|
||||
|
||||
if (!ctx->init(gl))
|
||||
{
|
||||
RARCH_ERR("Failed to init GL context: %s.\n", ctx->ident);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("Didn't find GL context: %s.\n", g_settings.video.context_driver);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
return gfx_ctx_init_first(gl, api, major, minor, gl->shared_context_use);
|
||||
return gfx_ctx_init_first(gl, g_settings.video.context_driver,
|
||||
api, major, minor, gl->shared_context_use);
|
||||
}
|
||||
|
||||
#ifdef GL_DEBUG
|
||||
|
Loading…
x
Reference in New Issue
Block a user