Refactor video_shader_driver_set_parameters

This commit is contained in:
twinaphex 2018-02-26 17:51:52 +01:00
parent 5665e27324
commit 5b79d2b942
7 changed files with 62 additions and 55 deletions

View File

@ -1114,7 +1114,7 @@ static bool gl_frame(void *data, const void *frame,
params.fbo_info = NULL;
params.fbo_info_cnt = 0;
video_shader_driver_set_parameters(params);
video_shader_driver_set_parameters(&params);
gl->coords.vertices = 4;
coords.handle_data = NULL;

View File

@ -406,7 +406,7 @@ static void gl2_renderchain_render(
params.fbo_info = fbo_tex_info;
params.fbo_info_cnt = fbo_tex_info_cnt;
video_shader_driver_set_parameters(params);
video_shader_driver_set_parameters(&params);
gl->coords.vertices = 4;
@ -479,7 +479,7 @@ static void gl2_renderchain_render(
params.fbo_info = fbo_tex_info;
params.fbo_info_cnt = fbo_tex_info_cnt;
video_shader_driver_set_parameters(params);
video_shader_driver_set_parameters(&params);
gl->coords.vertex = gl->vertex_ptr;

View File

@ -307,23 +307,29 @@ static void gl_cg_set_texture_info(
gl_cg_set_coord_array(params->coord, cg, info->coord, 2);
}
static void gl_cg_set_params(void *data, void *shader_data,
unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
unsigned frame_count,
const void *_info,
const void *_prev_info,
const void *_feedback_info,
const void *_fbo_info,
unsigned fbo_info_cnt)
static void gl_cg_set_params(void *dat, void *shader_data)
{
unsigned i;
video_shader_ctx_params_t *params =
(video_shader_ctx_params_t*)dat;
void *data = params->data;
unsigned width = params->width;
unsigned height = params->height;
unsigned tex_width = params->tex_width;
unsigned tex_height = params->tex_height;
unsigned out_width = params->out_width;
unsigned out_height = params->out_height;
unsigned frame_count = params->frame_counter;
const void *_info = params->info;
const void *_prev_info = params->prev_info;
const void *_feedback_info = params->feedback_info;
const void *_fbo_info = params->fbo_info;
unsigned fbo_info_cnt = params->fbo_info_cnt;
const struct video_tex_info *info = (const struct video_tex_info*)_info;
const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info;
const struct video_tex_info *feedback_info = (const struct video_tex_info*)_feedback_info;
const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info;
cg_shader_data_t *cg = (cg_shader_data_t*)shader_data;
cg_shader_data_t *cg = (cg_shader_data_t*)shader_data;
if (!cg || (cg->active_idx == 0))
return;

View File

@ -1186,20 +1186,26 @@ static void gl_glsl_set_uniform_parameter(
}
}
static void gl_glsl_set_params(void *data, void *shader_data,
unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
unsigned frame_count,
const void *_info,
const void *_prev_info,
const void *_feedback_info,
const void *_fbo_info, unsigned fbo_info_cnt)
static void gl_glsl_set_params(void *dat, void *shader_data)
{
unsigned i;
GLfloat buffer[512];
struct glsl_attrib attribs[32];
float input_size[2], output_size[2], texture_size[2];
video_shader_ctx_params_t *params = (video_shader_ctx_params_t*)dat;
void *data = params->data;
unsigned width = params->width;
unsigned height = params->height;
unsigned tex_width = params->tex_width;
unsigned tex_height = params->tex_height;
unsigned out_width = params->out_width;
unsigned out_height = params->out_height;
unsigned frame_count = params->frame_counter;
const void *_info = params->info;
const void *_prev_info = params->prev_info;
const void *_feedback_info = params->feedback_info;
const void *_fbo_info = params->fbo_info;
unsigned fbo_info_cnt = params->fbo_info_cnt;
unsigned texunit = 1;
const struct shader_uniforms *uni = NULL;
size_t size = 0;

View File

@ -162,18 +162,24 @@ static void hlsl_set_uniform_parameter(
}
}
static void hlsl_set_params(void *data, void *shader_data,
unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
unsigned frame_counter,
const void *_info,
const void *_prev_info,
const void *_feedback_info,
const void *_fbo_info, unsigned fbo_info_cnt)
static void hlsl_set_params(void *dat, void *shader_data)
{
float ori_size[2], tex_size[2], out_size[2];
float frame_cnt = frame_counter;
video_shader_ctx_params_t *params = (video_shader_ctx_params_t*)dat;
void *data = params->data;
unsigned width = params->width;
unsigned height = params->height;
unsigned tex_width = params->tex_width;
unsigned tex_height = params->tex_height;
unsigned out_width = params->out_width;
unsigned out_height = params->out_height;
unsigned frame_count = params->frame_counter;
const void *_info = params->info;
const void *_prev_info = params->prev_info;
const void *_feedback_info = params->feedback_info;
const void *_fbo_info = params->fbo_info;
unsigned fbo_info_cnt = params->fbo_info_cnt;
float frame_cnt = frame_count;
const struct video_tex_info *info = (const struct video_tex_info*)_info;
const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info;
const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info;

View File

@ -3276,9 +3276,15 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t
return NULL;
}
void video_shader_driver_set_parameters(video_shader_ctx_params_t *params)
{
if (current_shader && current_shader->set_params)
current_shader->set_params(params, shader_data);
}
bool video_shader_driver_get_prev_textures(video_shader_ctx_texture_t *texture)
{
if (!texture)
if (!texture || !current_shader)
return false;
texture->id = current_shader->get_prev_textures(shader_data);
@ -3287,7 +3293,7 @@ bool video_shader_driver_get_prev_textures(video_shader_ctx_texture_t *texture)
bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident)
{
if (!ident)
if (!ident || !current_shader)
return false;
ident->ident = current_shader->ident;
return true;
@ -3348,15 +3354,7 @@ static struct video_shader *video_shader_driver_get_current_shader_null(void *da
}
static void video_shader_driver_set_params_null(
void *data, void *shader_data,
unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
unsigned frame_count,
const void *info,
const void *prev_info,
const void *feedback_info,
const void *fbo_info, unsigned fbo_info_cnt)
void *data, void *shader_data)
{
}

View File

@ -202,15 +202,7 @@ typedef struct shader_backend
void (*deinit)(void *data);
/* Set shader parameters. */
void (*set_params)(void *data, void *shader_data,
unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
unsigned frame_counter,
const void *info,
const void *prev_info,
const void *feedback_info,
const void *fbo_info, unsigned fbo_info_cnt);
void (*set_params)(void *data, void *shader_data);
void (*set_uniform_parameter)(void *data, struct uniform_info *param,
void *uniform_data);
@ -1282,8 +1274,7 @@ bool video_shader_driver_deinit(void);
if (current_shader && current_shader->set_uniform_parameter) \
current_shader->set_uniform_parameter(shader_data, &param, NULL)
#define video_shader_driver_set_parameters(params) \
current_shader->set_params(params.data, shader_data, params.width, params.height, params.tex_width, params.tex_height, params.out_width, params.out_height, params.frame_counter, params.info, params.prev_info, params.feedback_info, params.fbo_info, params.fbo_info_cnt)
void video_shader_driver_set_parameters(video_shader_ctx_params_t *params);
bool video_shader_driver_init_first(void);