Add cb_set_shader_coords

This commit is contained in:
twinaphex 2017-05-19 21:13:44 +02:00
parent 8a12bb9f04
commit 06df028722
7 changed files with 25 additions and 43 deletions

View File

@ -217,7 +217,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;
@ -239,10 +238,8 @@ 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_shader_driver_set_coords(coords);
video_info->cb_shader_set_coords(NULL, video_info->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp_no_rot);
@ -997,7 +994,6 @@ static void gl_pbo_async_readback(gl_t *gl)
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;
@ -1019,9 +1015,6 @@ static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
color[14] = 1.0f;
color[15] = gl->menu_texture_alpha;
if (!gl->menu_texture)
return;
gl->coords.vertex = vertexes_flipped;
gl->coords.tex_coord = tex_coords;
gl->coords.color = color;
@ -1031,10 +1024,8 @@ 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_shader_driver_set_coords(coords);
video_info->cb_shader_set_coords(NULL, video_info->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp_no_rot);
@ -1064,7 +1055,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;
@ -1216,10 +1206,9 @@ static bool gl_frame(void *data, const void *frame,
video_shader_driver_set_parameters(params);
gl->coords.vertices = 4;
coords.handle_data = NULL;
coords.data = &gl->coords;
video_shader_driver_set_coords(coords);
video_info->cb_shader_set_coords(NULL, video_info->shader_data,
(const struct video_coords*)&gl->coords);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp);
@ -1239,7 +1228,7 @@ static bool gl_frame(void *data, const void *frame,
{
menu_driver_frame(video_info);
if (gl->menu_texture_enable)
if (gl->menu_texture_enable && gl->menu_texture)
gl_draw_texture(gl, video_info);
}
#endif

View File

@ -296,12 +296,6 @@ static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct
return true;
}
static bool gl_cg_set_coords_fallback(void *handle_data, void *shader_data, const struct video_coords *coords)
{
gl_ff_vertex(coords);
return true;
}
static void gl_cg_set_texture_info(
cg_shader_data_t *cg,
const struct cg_fbo_params *params,
@ -1233,7 +1227,6 @@ const shader_backend_t gl_cg_backend = {
gl_cg_wrap_type,
gl_cg_shader_scale,
gl_cg_set_coords,
gl_cg_set_coords_fallback,
gl_cg_set_mvp,
gl_cg_get_prev_textures,
gl_cg_get_feedback_pass,

View File

@ -1488,13 +1488,6 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data,
return true;
}
static bool gl_glsl_set_coords_fallback(void *handle_data, void *shader_data,
const struct video_coords *coords)
{
gl_ff_vertex(coords);
return true;
}
static void gl_glsl_use(void *data, void *shader_data, unsigned idx, bool set_active)
{
GLuint id;
@ -1621,7 +1614,6 @@ const shader_backend_t gl_glsl_backend = {
gl_glsl_wrap_type,
gl_glsl_shader_scale,
gl_glsl_set_coords,
gl_glsl_set_coords_fallback,
gl_glsl_set_mvp,
gl_glsl_get_prev_textures,
gl_glsl_get_feedback_pass,

View File

@ -539,7 +539,6 @@ const shader_backend_t hlsl_backend = {
NULL, /* hlsl_wrap_type */
hlsl_shader_scale,
NULL, /* hlsl_set_coords */
NULL, /* hlsl_set_coords_fallback */
hlsl_set_mvp,
NULL, /* hlsl_get_prev_textures */
hlsl_get_feedback_pass,

View File

@ -88,7 +88,6 @@ const shader_backend_t shader_null_backend = {
NULL,
NULL,
NULL,
NULL,
shader_null_get_prev_textures,
NULL,
NULL,

View File

@ -121,8 +121,12 @@ typedef struct video_pixel_scaler
void *scaler_out;
} video_pixel_scaler_t;
static void (*video_driver_cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
static bool (*video_driver_cb_shader_set_mvp)(void *data, void *shader_data, const math_matrix_4x4 *mat);
static void (*video_driver_cb_shader_use)(void *data,
void *shader_data, unsigned index, bool set_active);
static bool (*video_driver_cb_shader_set_mvp)(void *data,
void *shader_data, const math_matrix_4x4 *mat);
static bool (*video_driver_cb_shader_set_coords)(void *handle_data,
void *shader_data, const struct video_coords *coords);
/* Opaque handles to currently running window.
* Used by e.g. input drivers which bind to a window.
@ -2517,6 +2521,7 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->cb_shader_use = video_driver_cb_shader_use;
video_info->cb_shader_set_mvp = video_driver_cb_shader_set_mvp;
video_info->cb_shader_set_coords = video_driver_cb_shader_set_coords;
#ifdef HAVE_THREADS
video_driver_threaded_unlock(is_threaded);
@ -3197,8 +3202,15 @@ static void video_shader_driver_reset_to_defaults(void)
current_shader->set_mvp = video_shader_driver_set_mvp_null;
video_driver_cb_shader_set_mvp = video_shader_driver_set_mvp_null;
}
if (!current_shader->set_coords)
if (current_shader->set_coords)
{
video_driver_cb_shader_set_coords = current_shader->set_coords;
}
else
{
current_shader->set_coords = video_shader_driver_set_coords_null;
video_driver_cb_shader_set_coords = video_shader_driver_set_coords_null;
}
if (current_shader->use)
video_driver_cb_shader_use = current_shader->use;
else

View File

@ -219,8 +219,6 @@ typedef struct shader_backend
unsigned index, struct gfx_fbo_scale *scale);
bool (*set_coords)(void *handle_data,
void *shader_data, const struct video_coords *coords);
bool (*set_coords_fallback)(void *handle_data,
void *shader_data, const struct video_coords *coords);
bool (*set_mvp)(void *data, void *shader_data,
const math_matrix_4x4 *mat);
unsigned (*get_prev_textures)(void *data);
@ -453,6 +451,8 @@ typedef struct video_frame_info
void (*cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
bool (*cb_shader_set_mvp)(void *data, void *shader_data,
const math_matrix_4x4 *mat);
bool (*cb_shader_set_coords)(void *handle_data,
void *shader_data, const struct video_coords *coords);
void *context_data;
void *shader_data;
@ -1223,9 +1223,7 @@ bool video_shader_driver_get_feedback_pass(unsigned *data);
bool video_shader_driver_mipmap_input(unsigned *index);
#define video_shader_driver_set_coords(coords) \
if (!current_shader->set_coords(coords.handle_data, shader_data, (const struct video_coords*)coords.data) && current_shader->set_coords_fallback) \
current_shader->set_coords_fallback(coords.handle_data, shader_data, (const struct video_coords*)coords.data)
#define video_shader_driver_set_coords(coords) current_shader->set_coords(coords.handle_data, shader_data, (const struct video_coords*)coords.data)
bool video_shader_driver_scale(video_shader_ctx_scale_t *scaler);