mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Rewrite video_context_driver_init_first
This commit is contained in:
parent
2bca74bbaa
commit
e661cf3cfd
@ -34,6 +34,7 @@ typedef struct gdi
|
||||
unsigned video_height;
|
||||
unsigned screen_width;
|
||||
unsigned screen_height;
|
||||
void *ctx_data;
|
||||
} gdi_t;
|
||||
|
||||
typedef struct gdi_texture
|
||||
|
@ -317,6 +317,7 @@ struct gl
|
||||
|
||||
const gl_renderchain_driver_t *renderchain_driver;
|
||||
void *renderchain_data;
|
||||
void *ctx_data;
|
||||
};
|
||||
|
||||
static INLINE void gl_bind_texture(GLuint id, GLint wrap_mode, GLint mag_filter,
|
||||
|
@ -29,6 +29,7 @@ typedef struct sixel
|
||||
unsigned video_height;
|
||||
unsigned screen_width;
|
||||
unsigned screen_height;
|
||||
void *ctx_data;
|
||||
} sixel_t;
|
||||
|
||||
#endif
|
||||
|
@ -332,6 +332,7 @@ typedef struct vk
|
||||
|
||||
vulkan_context_t *context;
|
||||
video_info_t video;
|
||||
void *ctx_data;
|
||||
|
||||
VkFormat tex_fmt;
|
||||
math_matrix_4x4 mvp, mvp_no_rot;
|
||||
|
@ -82,6 +82,7 @@ static void *gdi_gfx_init(const video_info_t *video,
|
||||
unsigned full_x, full_y;
|
||||
gfx_ctx_input_t inp;
|
||||
gfx_ctx_mode_t mode;
|
||||
void *ctx_data = NULL;
|
||||
const gfx_ctx_driver_t *ctx_driver = NULL;
|
||||
unsigned win_width = 0, win_height = 0;
|
||||
unsigned temp_width = 0, temp_height = 0;
|
||||
@ -106,10 +107,13 @@ static void *gdi_gfx_init(const video_info_t *video,
|
||||
|
||||
ctx_driver = video_context_driver_init_first(gdi,
|
||||
settings->arrays.video_context_driver,
|
||||
GFX_CTX_GDI_API, 1, 0, false);
|
||||
GFX_CTX_GDI_API, 1, 0, false, &ctx_data);
|
||||
if (!ctx_driver)
|
||||
goto error;
|
||||
|
||||
if (ctx_data)
|
||||
gdi->ctx_data = ctx_data;
|
||||
|
||||
video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
|
||||
|
||||
RARCH_LOG("[GDI]: Found GDI context: %s\n", ctx_driver->ident);
|
||||
|
@ -1501,6 +1501,8 @@ static bool gl_init_pbo_readback(gl_t *gl)
|
||||
static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
||||
{
|
||||
enum gfx_ctx_api api;
|
||||
const gfx_ctx_driver_t *gfx_ctx = NULL;
|
||||
void *ctx_data = NULL;
|
||||
const char *api_name = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
|
||||
@ -1533,9 +1535,14 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
||||
&& (hwr->context_type != RETRO_HW_CONTEXT_NONE))
|
||||
gl_shared_context_use = true;
|
||||
|
||||
return video_context_driver_init_first(gl,
|
||||
gfx_ctx = video_context_driver_init_first(gl,
|
||||
settings->arrays.video_context_driver,
|
||||
api, major, minor, gl_shared_context_use);
|
||||
api, major, minor, gl_shared_context_use, &ctx_data);
|
||||
|
||||
if (ctx_data)
|
||||
gl->ctx_data = ctx_data;
|
||||
|
||||
return gfx_ctx;
|
||||
}
|
||||
|
||||
#ifdef GL_DEBUG
|
||||
|
@ -188,9 +188,10 @@ static void scroll_on_demand(int pixelheight)
|
||||
static void *sixel_gfx_init(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
gfx_ctx_input_t inp;
|
||||
void *ctx_data = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
sixel_t *sixel = (sixel_t*)calloc(1, sizeof(*sixel));
|
||||
gfx_ctx_input_t inp;
|
||||
const gfx_ctx_driver_t *ctx_driver = NULL;
|
||||
const char *scale_str = NULL;
|
||||
|
||||
@ -218,11 +219,14 @@ static void *sixel_gfx_init(const video_info_t *video,
|
||||
|
||||
ctx_driver = video_context_driver_init_first(sixel,
|
||||
settings->arrays.video_context_driver,
|
||||
GFX_CTX_SIXEL_API, 1, 0, false);
|
||||
GFX_CTX_SIXEL_API, 1, 0, false, &ctx_data);
|
||||
|
||||
if (!ctx_driver)
|
||||
goto error;
|
||||
|
||||
if (ctx_data)
|
||||
sixel->ctx_data = ctx_data;
|
||||
|
||||
video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
|
||||
|
||||
RARCH_LOG("[SIXEL]: Found SIXEL context: %s\n", ctx_driver->ident);
|
||||
|
@ -102,15 +102,19 @@ static void *vg_init(const video_info_t *video,
|
||||
int interval = 0;
|
||||
unsigned temp_width = 0;
|
||||
unsigned temp_height = 0;
|
||||
void *ctx_data = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
|
||||
const gfx_ctx_driver_t *ctx = video_context_driver_init_first(
|
||||
vg, settings->arrays.video_context_driver,
|
||||
GFX_CTX_OPENVG_API, 0, 0, false);
|
||||
GFX_CTX_OPENVG_API, 0, 0, false, &ctx_data);
|
||||
|
||||
if (!vg || !ctx)
|
||||
goto error;
|
||||
|
||||
if (ctx_data)
|
||||
vg->ctx_data = ctx_data;
|
||||
|
||||
video_context_driver_set((void*)ctx);
|
||||
|
||||
video_context_driver_get_video_size(&mode);
|
||||
|
@ -61,14 +61,19 @@ static void vulkan_viewport_info(void *data, struct video_viewport *vp);
|
||||
|
||||
static const gfx_ctx_driver_t *vulkan_get_context(vk_t *vk)
|
||||
{
|
||||
unsigned major = 1;
|
||||
unsigned minor = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
enum gfx_ctx_api api = GFX_CTX_VULKAN_API;
|
||||
|
||||
return video_context_driver_init_first(
|
||||
void *ctx_data = NULL;
|
||||
unsigned major = 1;
|
||||
unsigned minor = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
enum gfx_ctx_api api = GFX_CTX_VULKAN_API;
|
||||
const gfx_ctx_driver_t *gfx_ctx = video_context_driver_init_first(
|
||||
vk, settings->arrays.video_context_driver,
|
||||
api, major, minor, false);
|
||||
api, major, minor, false, &ctx_data);
|
||||
|
||||
if (ctx_data)
|
||||
vk->ctx_data = ctx_data;
|
||||
|
||||
return gfx_ctx;
|
||||
}
|
||||
|
||||
static void vulkan_init_render_pass(
|
||||
|
@ -3051,18 +3051,17 @@ static const gfx_ctx_driver_t *video_context_driver_init(
|
||||
**/
|
||||
const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
|
||||
const char *ident, enum gfx_ctx_api api, unsigned major,
|
||||
unsigned minor, bool hw_render_ctx)
|
||||
unsigned minor, bool hw_render_ctx, void **ctx_data)
|
||||
{
|
||||
void *ctx_data = NULL;
|
||||
int i = find_video_context_driver_index(ident);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
const gfx_ctx_driver_t *ctx = video_context_driver_init(data, gfx_ctx_drivers[i], ident,
|
||||
api, major, minor, hw_render_ctx, &ctx_data);
|
||||
api, major, minor, hw_render_ctx, ctx_data);
|
||||
if (ctx)
|
||||
{
|
||||
video_context_data = ctx_data;
|
||||
video_context_data = *ctx_data;
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
@ -3071,11 +3070,11 @@ const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
|
||||
{
|
||||
const gfx_ctx_driver_t *ctx =
|
||||
video_context_driver_init(data, gfx_ctx_drivers[i], ident,
|
||||
api, major, minor, hw_render_ctx, &ctx_data);
|
||||
api, major, minor, hw_render_ctx, ctx_data);
|
||||
|
||||
if (ctx)
|
||||
{
|
||||
video_context_data = ctx_data;
|
||||
video_context_data = *ctx_data;
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
@ -1140,8 +1140,10 @@ void video_driver_get_status(uint64_t *frame_count, bool * is_alive,
|
||||
*
|
||||
* Returns: graphics context driver if found, otherwise NULL.
|
||||
**/
|
||||
const gfx_ctx_driver_t *video_context_driver_init_first(void *data, const char *ident,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx);
|
||||
const gfx_ctx_driver_t *video_context_driver_init_first(
|
||||
void *data, const char *ident,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor,
|
||||
bool hw_render_ctx, void **ctx_data);
|
||||
|
||||
bool video_context_driver_check_window(gfx_ctx_size_t *size_data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user