make_current is only ever used for GL, so move it out of

video_driver_load/unload_texture and into the inner GL
drivers
This commit is contained in:
twinaphex 2020-07-27 10:26:13 +02:00
parent 3d893b7602
commit 197465c1ea
5 changed files with 51 additions and 31 deletions

View File

@ -4470,8 +4470,12 @@ static uintptr_t gl2_load_texture(void *video_data, void *data,
#ifdef HAVE_THREADS
if (threaded)
{
gl_t *gl = (gl_t*)video_data;
custom_command_method_t func = video_texture_load_wrap_gl2;
if (gl->ctx_driver->make_current)
gl->ctx_driver->make_current(false);
switch (filter_type)
{
case TEXTURE_FILTER_MIPMAP_LINEAR:
@ -4493,9 +4497,18 @@ static void gl2_unload_texture(void *data,
bool threaded, uintptr_t id)
{
GLuint glid;
gl_t *gl = (gl_t*)data;
if (!id)
return;
#ifdef HAVE_THREADS
if (threaded)
{
if (gl->ctx_driver->make_current)
gl->ctx_driver->make_current(false);
}
#endif
glid = (GLuint)id;
glDeleteTextures(1, &glid);
}

View File

@ -1303,7 +1303,12 @@ static uintptr_t gl1_load_texture(void *video_data, void *data,
#ifdef HAVE_THREADS
if (threaded)
{
gl1_t *gl1 = (gl1_t*)video_data;
custom_command_method_t func = video_texture_load_wrap_gl1;
if (gl1->ctx_driver->make_current)
gl1->ctx_driver->make_current(false);
return video_thread_texture_load(data, func);
}
#endif
@ -1327,9 +1332,18 @@ static void gl1_unload_texture(void *data,
bool threaded, uintptr_t id)
{
GLuint glid;
gl1_t *gl1 = (gl1_t*)data;
if (!id)
return;
#ifdef HAVE_THREADS
if (threaded)
{
if (gl1->ctx_driver->make_current)
gl1->ctx_driver->make_current(false);
}
#endif
glid = (GLuint)id;
glDeleteTextures(1, &glid);
}

View File

@ -2078,8 +2078,12 @@ static uintptr_t gl_core_load_texture(void *video_data, void *data,
#ifdef HAVE_THREADS
if (threaded)
{
gl_core_t *gl = (gl_core_t*)video_data;
custom_command_method_t func = video_texture_load_wrap_gl_core;
if (gl->ctx_driver->make_current)
gl->ctx_driver->make_current(false);
switch (filter_type)
{
case TEXTURE_FILTER_MIPMAP_LINEAR:
@ -2101,15 +2105,24 @@ static void gl_core_unload_texture(void *data, bool threaded,
uintptr_t id)
{
GLuint glid;
gl_core_t *gl = (gl_core_t*)data;
if (!id)
return;
#ifdef HAVE_THREADS
if (threaded)
{
if (gl->ctx_driver->make_current)
gl->ctx_driver->make_current(false);
}
#endif
glid = (GLuint)id;
glDeleteTextures(1, &glid);
}
static void gl_core_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
bool fullscreen)
{
gfx_ctx_mode_t mode;

View File

@ -267,18 +267,18 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = {
gfx_ctx_khr_display_set_swap_interval,
gfx_ctx_khr_display_set_video_mode,
gfx_ctx_khr_display_get_video_size,
NULL, /* get_refresh_rate */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL, /* get_refresh_rate */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
NULL, /* update_title */
gfx_ctx_khr_display_check_window,
gfx_ctx_khr_display_set_resize,
gfx_ctx_khr_display_has_focus,
gfx_ctx_khr_display_suppress_screensaver,
false, /* has_windowed */
false, /* has_windowed */
gfx_ctx_khr_display_swap_buffers,
gfx_ctx_khr_display_input_driver,
gfx_ctx_khr_display_get_proc_address,
@ -290,5 +290,5 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = {
gfx_ctx_khr_display_set_flags,
NULL,
gfx_ctx_khr_display_get_context_data,
NULL
NULL /* make_current */
};

View File

@ -32899,43 +32899,23 @@ bool video_driver_texture_load(void *data,
uintptr_t *id)
{
struct rarch_state *p_rarch = &rarch_st;
#ifdef HAVE_THREADS
bool is_threaded = VIDEO_DRIVER_IS_THREADED_INTERNAL();
#endif
if ( !id
|| !p_rarch->video_driver_poke
|| !p_rarch->video_driver_poke->load_texture)
return false;
#ifdef HAVE_THREADS
if (is_threaded)
if (p_rarch->current_video_context.make_current)
p_rarch->current_video_context.make_current(false);
#endif
*id = p_rarch->video_driver_poke->load_texture(
p_rarch->video_driver_data, data,
VIDEO_DRIVER_IS_THREADED_INTERNAL(),
filter_type);
return true;
}
bool video_driver_texture_unload(uintptr_t *id)
{
struct rarch_state *p_rarch = &rarch_st;
#ifdef HAVE_THREADS
bool is_threaded = VIDEO_DRIVER_IS_THREADED_INTERNAL();
#endif
if (!p_rarch->video_driver_poke || !p_rarch->video_driver_poke->unload_texture)
if ( !p_rarch->video_driver_poke
|| !p_rarch->video_driver_poke->unload_texture)
return false;
#ifdef HAVE_THREADS
if (is_threaded)
if (p_rarch->current_video_context.make_current)
p_rarch->current_video_context.make_current(false);
#endif
p_rarch->video_driver_poke->unload_texture(
p_rarch->video_driver_data,
VIDEO_DRIVER_IS_THREADED_INTERNAL(),