Add cb_shader_use to video_frame_info

This commit is contained in:
twinaphex 2017-05-19 14:24:19 +02:00
parent 4144c8de35
commit 2a54544eb3
3 changed files with 28 additions and 30 deletions

View File

@ -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_mvp_t mvp;
video_shader_ctx_coords_t coords; video_shader_ctx_coords_t coords;
video_shader_ctx_info_t shader_info;
unsigned i; unsigned i;
unsigned width = video_info->width; unsigned width = video_info->width;
unsigned height = video_info->height; 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); glViewport(0, 0, width, height);
/* Ensure that we reset the attrib array. */ /* Ensure that we reset the attrib array. */
shader_info.data = gl; video_info->cb_shader_use(gl,
shader_info.idx = VIDEO_SHADER_STOCK_BLEND; video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
shader_info.set_active = true;
video_shader_driver_use(shader_info);
gl->coords.vertex = gl->overlay_vertex_coord; gl->coords.vertex = gl->overlay_vertex_coord;
gl->coords.tex_coord = gl->overlay_tex_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_coords_t coords;
video_shader_ctx_params_t params; video_shader_ctx_params_t params;
struct video_tex_info feedback_info; struct video_tex_info feedback_info;
video_shader_ctx_info_t shader_info;
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
unsigned width = video_info->width; unsigned width = video_info->width;
unsigned height = video_info->height; unsigned height = video_info->height;
@ -1093,11 +1088,7 @@ static bool gl_frame(void *data, const void *frame,
glBindVertexArray(gl->vao); glBindVertexArray(gl->vao);
#endif #endif
shader_info.data = gl; video_info->cb_shader_use(gl, video_info->shader_data, 1, true);
shader_info.idx = 1;
shader_info.set_active = true;
video_shader_driver_use(shader_info);
#ifdef IOS #ifdef IOS
/* Apparently the viewport is lost each frame, thanks Apple. */ /* 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. */ /* Reset state which could easily mess up libretro core. */
if (gl->hw_render_fbo_init) if (gl->hw_render_fbo_init)
{ {
shader_info.data = gl; video_info->cb_shader_use(gl, video_info->shader_data, 0, true);
shader_info.idx = 0;
shader_info.set_active = true;
video_shader_driver_use(shader_info);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
#ifndef NO_GL_FF_VERTEX #ifndef NO_GL_FF_VERTEX

View File

@ -2408,6 +2408,14 @@ bool video_driver_texture_unload(uintptr_t *id)
return true; 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) void video_driver_build_info(video_frame_info_t *video_info)
{ {
bool is_perfcnt_enable = false; 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->input_driver_nonblock_state = input_driver_is_nonblock_state();
video_info->context_data = video_context_data; 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_update_window_title = current_video_context.update_window_title;
video_info->cb_swap_buffers = current_video_context.swap_buffers; video_info->cb_swap_buffers = current_video_context.swap_buffers;
video_info->cb_get_metrics = current_video_context.get_metrics; video_info->cb_get_metrics = current_video_context.get_metrics;
video_info->cb_set_resize = current_video_context.set_resize; 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 #ifdef HAVE_THREADS
video_driver_threaded_unlock(is_threaded); video_driver_threaded_unlock(is_threaded);
#endif #endif
@ -3122,14 +3137,6 @@ static bool video_shader_driver_set_coords_null(void *handle_data,
return false; 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) static struct video_shader *video_shader_driver_get_current_shader_null(void *data)
{ {
return NULL; 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) static void video_shader_driver_reset_to_defaults(void)
{ {
if (!current_shader->wrap_type) 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) 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) 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) 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) 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) if (!current_shader->shader_scale)
current_shader->shader_scale = video_shader_driver_scale_null; current_shader->shader_scale = video_shader_driver_scale_null;
if (!current_shader->mipmap_input) if (!current_shader->mipmap_input)

View File

@ -449,7 +449,11 @@ typedef struct video_frame_info
bool (*cb_get_metrics)(void *data, enum display_metric_types type, bool (*cb_get_metrics)(void *data, enum display_metric_types type,
float *value); float *value);
bool (*cb_set_resize)(void*, unsigned, unsigned); 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 *context_data;
void *shader_data;
} video_frame_info_t; } video_frame_info_t;
typedef void (*update_window_title_cb)(void*, void*); typedef void (*update_window_title_cb)(void*, void*);