diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 3b48bffc0e..c196f1fe50 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -219,7 +219,6 @@ static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; - video_shader_ctx_info_t shader_info; unsigned i; unsigned width = video_info->width; unsigned height = video_info->height; @@ -233,11 +232,8 @@ static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) glViewport(0, 0, width, height); /* Ensure that we reset the attrib array. */ - shader_info.data = gl; - shader_info.idx = VIDEO_SHADER_STOCK_BLEND; - shader_info.set_active = true; - - video_shader_driver_use(shader_info); + video_info->cb_shader_use(gl, + video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true); gl->coords.vertex = gl->overlay_vertex_coord; gl->coords.tex_coord = gl->overlay_tex_coord; @@ -1078,7 +1074,6 @@ static bool gl_frame(void *data, const void *frame, video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; struct video_tex_info feedback_info; - video_shader_ctx_info_t shader_info; gl_t *gl = (gl_t*)data; unsigned width = video_info->width; unsigned height = video_info->height; @@ -1093,11 +1088,7 @@ static bool gl_frame(void *data, const void *frame, glBindVertexArray(gl->vao); #endif - shader_info.data = gl; - shader_info.idx = 1; - shader_info.set_active = true; - - video_shader_driver_use(shader_info); + video_info->cb_shader_use(gl, video_info->shader_data, 1, true); #ifdef IOS /* Apparently the viewport is lost each frame, thanks Apple. */ @@ -1277,11 +1268,7 @@ static bool gl_frame(void *data, const void *frame, /* Reset state which could easily mess up libretro core. */ if (gl->hw_render_fbo_init) { - shader_info.data = gl; - shader_info.idx = 0; - shader_info.set_active = true; - - video_shader_driver_use(shader_info); + video_info->cb_shader_use(gl, video_info->shader_data, 0, true); glBindTexture(GL_TEXTURE_2D, 0); #ifndef NO_GL_FF_VERTEX diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 0bd350ef01..34d5a8d94d 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2408,6 +2408,14 @@ bool video_driver_texture_unload(uintptr_t *id) return true; } +static void video_shader_driver_use_null(void *data, + void *shader_data, unsigned idx, bool set_active) +{ + (void)data; + (void)idx; + (void)set_active; +} + void video_driver_build_info(video_frame_info_t *video_info) { bool is_perfcnt_enable = false; @@ -2497,12 +2505,19 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->input_driver_nonblock_state = input_driver_is_nonblock_state(); video_info->context_data = video_context_data; + video_info->shader_data = shader_data; video_info->cb_update_window_title = current_video_context.update_window_title; video_info->cb_swap_buffers = current_video_context.swap_buffers; video_info->cb_get_metrics = current_video_context.get_metrics; video_info->cb_set_resize = current_video_context.set_resize; + if (current_shader) + video_info->cb_shader_use = current_shader->use; + + if (!video_info->cb_shader_use) + video_info->cb_shader_use = video_shader_driver_use_null; + #ifdef HAVE_THREADS video_driver_threaded_unlock(is_threaded); #endif @@ -3122,14 +3137,6 @@ static bool video_shader_driver_set_coords_null(void *handle_data, return false; } -static void video_shader_driver_use_null(void *data, - void *shader_data, unsigned idx, bool set_active) -{ - (void)data; - (void)idx; - (void)set_active; -} - static struct video_shader *video_shader_driver_get_current_shader_null(void *data) { return NULL; @@ -3182,15 +3189,15 @@ static bool video_shader_driver_get_feedback_pass_null(void *data, unsigned *idx static void video_shader_driver_reset_to_defaults(void) { if (!current_shader->wrap_type) - current_shader->wrap_type = video_shader_driver_wrap_type_null; + current_shader->wrap_type = video_shader_driver_wrap_type_null; if (!current_shader->set_mvp) - current_shader->set_mvp = video_shader_driver_set_mvp_null; + current_shader->set_mvp = video_shader_driver_set_mvp_null; if (!current_shader->set_coords) - current_shader->set_coords = video_shader_driver_set_coords_null; + current_shader->set_coords = video_shader_driver_set_coords_null; if (!current_shader->use) - current_shader->use = video_shader_driver_use_null; + current_shader->use = video_shader_driver_use_null; if (!current_shader->set_params) - current_shader->set_params = video_shader_driver_set_params_null; + current_shader->set_params = video_shader_driver_set_params_null; if (!current_shader->shader_scale) current_shader->shader_scale = video_shader_driver_scale_null; if (!current_shader->mipmap_input) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 9b4728121f..4fe53b9ab0 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -449,7 +449,11 @@ typedef struct video_frame_info bool (*cb_get_metrics)(void *data, enum display_metric_types type, float *value); bool (*cb_set_resize)(void*, unsigned, unsigned); + + void (*cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active); + void *context_data; + void *shader_data; } video_frame_info_t; typedef void (*update_window_title_cb)(void*, void*);