diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index a465b9a754..b5dc33d0e3 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -1580,7 +1580,7 @@ static uintptr_t d3d10_gfx_load_texture( return (uintptr_t)texture; } -static void d3d10_gfx_unload_texture(void* data, uintptr_t handle, bool threaded) +static void d3d10_gfx_unload_texture(void* data, uintptr_t handle) { d3d10_texture_t* texture = (d3d10_texture_t*)handle; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f01a09eead..6e0850b712 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1640,7 +1640,7 @@ static uintptr_t d3d11_gfx_load_texture( return (uintptr_t)texture; } -static void d3d11_gfx_unload_texture(void* data, uintptr_t handle, bool threaded) +static void d3d11_gfx_unload_texture(void* data, uintptr_t handle) { d3d11_texture_t* texture = (d3d11_texture_t*)handle; diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 658dcaaff9..2251a428d4 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -1759,7 +1759,7 @@ static uintptr_t d3d12_gfx_load_texture( return (uintptr_t)texture; } -static void d3d12_gfx_unload_texture(void* data, uintptr_t handle, bool threaded) +static void d3d12_gfx_unload_texture(void* data, uintptr_t handle) { d3d12_texture_t* texture = (d3d12_texture_t*)handle; diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index c5daccb7aa..21830cd500 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1811,14 +1811,14 @@ static uintptr_t d3d8_load_texture(void *video_data, void *data, info.type = filter_type; if (threaded) - return video_thread_custom_cmd(&info, + return video_thread_texture_load(&info, d3d8_video_texture_load_wrap_d3d); d3d8_video_texture_load_d3d(&info, &id); return id; } -static void d3d8_unload_texture(void *data, uintptr_t id, bool threaded) +static void d3d8_unload_texture(void *data, uintptr_t id) { LPDIRECT3DTEXTURE8 texid; if (!id) diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index 1ffe236eb5..c5fc42bf70 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1980,14 +1980,14 @@ static uintptr_t d3d9_load_texture(void *video_data, void *data, info.type = filter_type; if (threaded) - return video_thread_custom_cmd(&info, + return video_thread_texture_load(&info, d3d9_video_texture_load_wrap_d3d); d3d9_video_texture_load_d3d(&info, &id); return id; } -static void d3d9_unload_texture(void *data, uintptr_t id, bool threaded) +static void d3d9_unload_texture(void *data, uintptr_t id) { LPDIRECT3DTEXTURE9 texid; if (!id) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 567ff83fbd..360b341773 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -610,7 +610,7 @@ static uintptr_t gdi_load_texture(void *video_data, void *data, return (uintptr_t)texture; } -static void gdi_unload_texture(void *data, uintptr_t handle, bool threaded) +static void gdi_unload_texture(void *data, uintptr_t handle) { struct gdi_texture *texture = (struct gdi_texture*)handle; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index bde3671810..d870d98fb0 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - + #ifdef _MSC_VER #pragma comment(lib, "opengl32") #endif @@ -128,7 +128,6 @@ void context_bind_hw_render(void *data, bool enable) gl_context_bind_hw_render(gl, enable); } - #ifdef HAVE_OVERLAY static void gl_free_overlay(gl_t *gl) { @@ -247,7 +246,6 @@ static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) } #endif - static void gl_set_projection(gl_t *gl, struct video_ortho *ortho, bool allow_rotate) { @@ -688,7 +686,6 @@ static void gl_set_texture_frame(void *data, if (!gl->menu_texture) glGenTextures(1, &gl->menu_texture); - gl_load_texture_data(gl->menu_texture, RARCH_WRAP_EDGE, menu_filter, video_pixel_get_alignment(width * base_size), @@ -940,7 +937,6 @@ static void gl_pbo_async_readback(gl_t *gl) gl->renderchain_driver->unbind_pbo(gl, gl->renderchain_data); } - static bool gl_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, @@ -1234,7 +1230,6 @@ static bool gl_frame(void *data, const void *frame, return true; } - static void gl_destroy_resources(gl_t *gl) { if (gl) @@ -2357,8 +2352,6 @@ static bool gl_overlay_load(void *data, return true; } - - static void gl_overlay_enable(void *data, bool state) { gl_t *gl = (gl_t*)data; @@ -2395,7 +2388,6 @@ static void gl_overlay_set_alpha(void *data, unsigned image, float mod) color[12 + 3] = mod; } - static const video_overlay_interface_t gl_overlay_interface = { gl_overlay_enable, gl_overlay_load, @@ -2413,7 +2405,6 @@ static void gl_get_overlay_interface(void *data, } #endif - static retro_proc_address_t gl_get_proc_address(void *data, const char *sym) { gfx_ctx_proc_address_t proc_address; @@ -2458,7 +2449,6 @@ static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) gl->should_resize = true; } - static void gl_apply_state_changes(void *data) { gl_t *gl = (gl_t*)data; @@ -2467,7 +2457,6 @@ static void gl_apply_state_changes(void *data) gl->should_resize = true; } - static void gl_get_video_output_size(void *data, unsigned *width, unsigned *height) { @@ -2502,12 +2491,6 @@ static void video_texture_load_gl( ); } -static void video_texture_unload_gl( - uintptr_t *id) -{ - glDeleteTextures(1, (GLuint*)id); -} - #ifdef HAVE_THREADS static int video_texture_load_wrap_gl_mipmap(void *data) { @@ -2530,20 +2513,13 @@ static int video_texture_load_wrap_gl(void *data) TEXTURE_FILTER_LINEAR, &id); return (int)id; } - -static int video_texture_unload_wrap_gl(void *data) -{ - if (!data) - return 0; - video_texture_unload_gl((uintptr_t*)data); - return 0; -} #endif static uintptr_t gl_load_texture(void *video_data, void *data, bool threaded, enum texture_filter_type filter_type) { uintptr_t id = 0; + #ifdef HAVE_THREADS if (threaded) { @@ -2558,8 +2534,7 @@ static uintptr_t gl_load_texture(void *video_data, void *data, default: break; } - id=video_thread_custom_cmd(data, func); - return id; + return video_thread_texture_load(data, func); } #endif @@ -2567,22 +2542,14 @@ static uintptr_t gl_load_texture(void *video_data, void *data, return id; } -static void gl_unload_texture(void *video_data, uintptr_t data, bool threaded) +static void gl_unload_texture(void *data, uintptr_t id) { - if (!data) + GLuint glid; + if (!id) return; - GLuint* glid = (GLuint*)data; -#ifdef HAVE_THREADS - if (threaded) - { - custom_command_method_t func = video_texture_unload_wrap_gl; - video_thread_custom_cmd((void *)&data, func); - return; - } -#endif - - video_texture_unload_gl(&data); + glid = (GLuint)id; + glDeleteTextures(1, &glid); } static void gl_set_coords(void *handle_data, void *shader_data, diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 7b404121fe..123c274621 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2334,7 +2334,7 @@ static uintptr_t vulkan_load_texture(void *video_data, void *data, return (uintptr_t)texture; } -static void vulkan_unload_texture(void *data, uintptr_t handle, bool threaded) +static void vulkan_unload_texture(void *data, uintptr_t handle) { vk_t *vk = (vk_t*)data; struct vk_texture *texture = (struct vk_texture*)handle; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index eee9e38f13..ce9a83cc40 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2715,7 +2715,7 @@ bool video_driver_texture_unload(uintptr_t *id) if (!video_driver_poke || !video_driver_poke->unload_texture) return false; - video_driver_poke->unload_texture(video_driver_data, *id, video_driver_is_threaded_internal()); + video_driver_poke->unload_texture(video_driver_data, *id); *id = 0; return true; } diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 905fef9817..eea9ef14e4 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -710,7 +710,7 @@ typedef struct video_poke_interface const void *mat_data); uintptr_t (*load_texture)(void *video_data, void *data, bool threaded, enum texture_filter_type filter_type); - void (*unload_texture)(void *data, uintptr_t id, bool threaded); + void (*unload_texture)(void *data, uintptr_t id); void (*set_video_mode)(void *data, unsigned width, unsigned height, bool fullscreen); float (*get_refresh_rate)(void *data); diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 10cc2377f9..1093deae0a 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1198,13 +1198,15 @@ static uintptr_t thread_load_texture(void *video_data, void *data, return thr->poke->load_texture(thr->driver_data, data, threaded, filter_type); } -static void thread_unload_texture(void *video_data, uintptr_t id, bool threaded) +static void thread_unload_texture(void *video_data, uintptr_t id) { thread_video_t *thr = (thread_video_t*)video_data; + if (!thr) return; + if (thr->poke && thr->poke->unload_texture) - thr->poke->unload_texture(thr->driver_data, id, threaded); + thr->poke->unload_texture(thr->driver_data, id); } static void thread_apply_state_changes(void *data) @@ -1426,7 +1428,7 @@ bool video_thread_font_init(const void **font_driver, void **font_handle, return pkt.data.font_init.return_value; } -unsigned video_thread_custom_cmd(void *data, +unsigned video_thread_texture_load(void *data, custom_command_method_t func) { thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true); diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 5aba4fd741..3fd306590a 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -83,7 +83,7 @@ bool video_thread_font_init( custom_font_command_method_t func, bool is_threaded); -unsigned video_thread_custom_cmd(void *data, +unsigned video_thread_texture_load(void *data, custom_command_method_t func); RETRO_END_DECLS