Reimplement video_driver_set_coords

This commit is contained in:
twinaphex 2019-02-03 18:29:00 +01:00
parent dd366cd5c5
commit 93ded925d3
3 changed files with 25 additions and 51 deletions

View File

@ -547,7 +547,6 @@ static void gl2_renderchain_render(
const struct video_tex_info *feedback_info)
{
int i;
video_shader_ctx_coords_t coords;
video_shader_ctx_params_t params;
static GLfloat fbo_tex_coords[8] = {0.0f};
struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS];
@ -626,10 +625,9 @@ static void gl2_renderchain_render(
gl->coords.vertices = 4;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_driver_set_coords(&coords);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_set_mvp(gl,
video_info->shader_data, &gl->mvp);
@ -702,10 +700,9 @@ static void gl2_renderchain_render(
gl->coords.vertices = 4;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_driver_set_coords(&coords);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_set_mvp(gl,
video_info->shader_data, &gl->mvp);
@ -1956,7 +1953,6 @@ static void gl_overlay_tex_geom(void *data,
static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info)
{
video_shader_ctx_coords_t coords;
unsigned i;
unsigned width = video_info->width;
unsigned height = video_info->height;
@ -1976,10 +1972,9 @@ static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info)
gl->coords.color = gl->overlay_color_coord;
gl->coords.vertices = 4 * gl->overlays;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_driver_set_coords(&coords);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_set_mvp(gl,
video_info->shader_data, &gl->mvp_no_rot);
@ -2294,7 +2289,6 @@ static void gl_render_osd_background(
gl_t *gl, video_frame_info_t *video_info,
const char *msg)
{
video_shader_ctx_coords_t coords_data;
video_coords_t coords;
struct uniform_info uniform_param;
float colors[4];
@ -2352,9 +2346,6 @@ static void gl_render_osd_background(
coords.lut_tex_coord = dummy;
coords.vertices = vertices_total;
coords_data.handle_data = NULL;
coords_data.data = &coords;
video_driver_set_viewport(video_info->width,
video_info->height, true, false);
@ -2362,7 +2353,9 @@ static void gl_render_osd_background(
video_info->shader_driver->use(gl,
video_info->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
video_driver_set_coords(&coords_data);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&coords);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -2436,7 +2429,6 @@ static struct video_shader *gl_get_current_shader(void *data)
#if defined(HAVE_MENU)
static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
{
video_shader_ctx_coords_t coords;
GLfloat color[16];
unsigned width = video_info->width;
unsigned height = video_info->height;
@ -2470,10 +2462,9 @@ static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
gl->coords.vertices = 4;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_driver_set_coords(&coords);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_set_mvp(gl,
video_info->shader_data, &gl->mvp_no_rot);
@ -2526,7 +2517,6 @@ static bool gl_frame(void *data, const void *frame,
unsigned pitch, const char *msg,
video_frame_info_t *video_info)
{
video_shader_ctx_coords_t coords;
video_shader_ctx_params_t params;
struct video_tex_info feedback_info;
gl_t *gl = (gl_t*)data;
@ -2673,10 +2663,10 @@ static bool gl_frame(void *data, const void *frame,
gl->shader->set_params(&params, gl->shader_data);
gl->coords.vertices = 4;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_driver_set_coords(&coords);
if (gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_set_mvp(gl, video_info->shader_data, &gl->mvp);
@ -4079,6 +4069,10 @@ static void gl_unload_texture(void *data, uintptr_t id)
static void gl_set_coords(void *handle_data, void *shader_data,
const struct video_coords *coords)
{
gl_t *gl = (gl_t*)handle_data;
if (gl->shader && gl->shader->set_coords)
gl->shader->set_coords(gl, gl->shader_data, coords);
}
static float gl_get_refresh_rate(void *data)

View File

@ -257,7 +257,7 @@ static void gl_raster_font_draw_vertices(gl_raster_t *font,
font->atlas->dirty = false;
}
coords_data.handle_data = NULL;
coords_data.handle_data = font->gl;
coords_data.data = coords;
video_driver_set_coords(&coords_data);

View File

@ -2737,17 +2737,6 @@ bool video_driver_texture_unload(uintptr_t *id)
return true;
}
static bool video_driver_cb_set_coords(void *handle_data,
void *shader_data, const struct video_coords *coords)
{
video_shader_ctx_coords_t ctx_coords;
ctx_coords.handle_data = handle_data;
ctx_coords.data = coords;
video_driver_set_coords(&ctx_coords);
return true;
}
void video_driver_build_info(video_frame_info_t *video_info)
{
bool is_perfcnt_enable = false;
@ -3514,8 +3503,6 @@ static void video_shader_driver_reset_to_defaults(void)
current_shader->set_mvp = video_driver_cb_set_mvp;
video_driver_cb_shader_set_mvp = video_driver_cb_set_mvp;
}
if (!current_shader->set_coords)
current_shader->set_coords = video_driver_cb_set_coords;
}
/* Finds first suitable shader context driver. */
@ -3564,17 +3551,10 @@ bool video_shader_driver_init(video_shader_ctx_init_t *init)
void video_driver_set_coords(video_shader_ctx_coords_t *coords)
{
if (current_shader && current_shader->set_coords)
current_shader->set_coords(coords->handle_data,
if (video_driver_poke && video_driver_poke->set_coords)
video_driver_poke->set_coords(coords->handle_data,
current_shader_data,
(const struct video_coords*)coords->data);
else
{
if (video_driver_poke && video_driver_poke->set_coords)
video_driver_poke->set_coords(coords->handle_data,
current_shader_data,
(const struct video_coords*)coords->data);
}
}
void video_driver_set_mvp(video_shader_ctx_mvp_t *mvp)