(GL) Use shader_driver directly

This commit is contained in:
twinaphex 2018-10-15 06:47:18 +02:00
parent 9e90316da9
commit 778c3fff73
3 changed files with 21 additions and 16 deletions

View File

@ -214,8 +214,9 @@ 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. */
video_info->cb_shader_use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
if (video_info->shader_driver && video_info->shader_driver->use)
video_info->shader_driver->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;
@ -584,19 +585,17 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video)
static INLINE void gl_set_shader_viewports(gl_t *gl)
{
unsigned i, width, height;
video_shader_ctx_info_t shader_info;
video_frame_info_t video_info;
video_driver_build_info(&video_info);
video_driver_get_size(&width, &height);
shader_info.data = gl;
shader_info.set_active = true;
for (i = 0; i < 2; i++)
{
shader_info.idx = i;
video_shader_driver_use(&shader_info);
if (video_info.shader_driver && video_info.shader_driver->use)
video_info.shader_driver->use(gl,
video_info.shader_data, i, true);
gl_set_viewport(gl, &video_info,
width, height, false, true);
}
@ -781,8 +780,9 @@ static void gl_render_osd_background(
video_driver_set_viewport(video_info->width,
video_info->height, true, false);
video_info->cb_shader_use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
if (video_info->shader_driver && video_info->shader_driver->use)
video_info->shader_driver->use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
video_driver_set_coords(&coords_data);
@ -881,8 +881,9 @@ static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
video_info->cb_shader_use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
if (video_info->shader_driver && video_info->shader_driver->use)
video_info->shader_driver->use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
gl->coords.vertices = 4;
@ -967,7 +968,9 @@ static bool gl_frame(void *data, const void *frame,
if (gl->core_context_in_use && gl->renderchain_driver->bind_vao)
gl->renderchain_driver->bind_vao(gl, gl->renderchain_data);
video_info->cb_shader_use(gl, video_info->shader_data, 1, true);
if (video_info->shader_driver && video_info->shader_driver->use)
video_info->shader_driver->use(gl,
video_info->shader_data, 1, true);
#ifdef IOS
/* Apparently the viewport is lost each frame, thanks Apple. */
@ -1168,7 +1171,9 @@ static bool gl_frame(void *data, const void *frame,
/* Reset state which could easily mess up libretro core. */
if (gl->hw_render_fbo_init)
{
video_info->cb_shader_use(gl, video_info->shader_data, 0, true);
if (video_info->shader_driver && video_info->shader_driver->use)
video_info->shader_driver->use(gl,
video_info->shader_data, 0, true);
glBindTexture(GL_TEXTURE_2D, 0);
if (gl->renderchain_driver->disable_client_arrays)

View File

@ -2824,6 +2824,7 @@ 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_driver = current_shader;
video_info->shader_data = current_shader_data;
video_info->cb_update_window_title = current_video_context.update_window_title;
@ -2831,7 +2832,6 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->cb_get_metrics = current_video_context.get_metrics;
video_info->cb_set_resize = current_video_context.set_resize;
video_info->cb_shader_use = video_driver_cb_shader_use;
video_info->cb_set_mvp = video_driver_cb_shader_set_mvp;
video_info->userdata = video_driver_get_ptr(false);

View File

@ -493,13 +493,13 @@ typedef struct video_frame_info
float *value);
bool (*cb_set_resize)(void*, unsigned, unsigned);
void (*cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
bool (*cb_set_mvp)(void *data, void *shader_data,
const void *mat_data);
void *context_data;
void *shader_data;
void *userdata;
const shader_backend_t *shader_driver;
} video_frame_info_t;
typedef void (*update_window_title_cb)(void*, void*);