From bf39033bc328c89904a15f397fc7e10d2e1f9ee6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 13 Apr 2016 04:21:17 +0200 Subject: [PATCH] Add 'enabled' attribute to uniform_params --- gfx/drivers_shader/shader_gl_cg.c | 74 +++++++++++++++++++------------ gfx/video_shader_driver.h | 1 + 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 1359e98998..15c39018e7 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -55,7 +55,7 @@ static void cg_uniform_set_parameter(void *data, void *uniform_data) struct uniform_info *param = (struct uniform_info*)data; CGparameter *cg_param = (CGparameter*)uniform_data; - if (!param) + if (!param || !param->enabled) return; switch (param->type) @@ -276,24 +276,28 @@ static void gl_cg_set_texture_info( cgGLEnableTextureParameter(param); } + uniform_params[0].enabled = true; uniform_params[0].type = UNIFORM_2F; - uniform_params[0].result.f.v0 = info->input_size[0]; - uniform_params[0].result.f.v1 = info->input_size[1]; + uniform_params[0].result.f.v0 = info->input_size[0]; + uniform_params[0].result.f.v1 = info->input_size[1]; uniform_data[0] = params->vid_size_v; + uniform_params[1].enabled = true; uniform_params[1].type = UNIFORM_2F; - uniform_params[1].result.f.v0 = info->input_size[0]; - uniform_params[1].result.f.v1 = info->input_size[1]; + uniform_params[1].result.f.v0 = info->input_size[0]; + uniform_params[1].result.f.v1 = info->input_size[1]; uniform_data[1] = params->vid_size_f; + uniform_params[2].enabled = true; uniform_params[2].type = UNIFORM_2F; - uniform_params[2].result.f.v0 = info->tex_size[0]; - uniform_params[2].result.f.v1 = info->tex_size[1]; + uniform_params[2].result.f.v0 = info->tex_size[0]; + uniform_params[2].result.f.v1 = info->tex_size[1]; uniform_data[2] = params->tex_size_v; + uniform_params[3].enabled = true; uniform_params[3].type = UNIFORM_2F; - uniform_params[3].result.f.v0 = info->tex_size[0]; - uniform_params[3].result.f.v1 = info->tex_size[1]; + uniform_params[3].result.f.v0 = info->tex_size[0]; + uniform_params[3].result.f.v1 = info->tex_size[1]; uniform_data[3] = params->tex_size_f; for (i = 0; i < 4; i++) @@ -334,42 +338,50 @@ static void gl_cg_set_params(void *data, void *shader_data, return; /* Set frame. */ + uniform_params[0].enabled = true; uniform_params[0].type = UNIFORM_2F; - uniform_params[0].result.f.v0 = width; - uniform_params[0].result.f.v1 = height; + uniform_params[0].result.f.v0 = width; + uniform_params[0].result.f.v1 = height; uniform_data[0] = cg_data->prg[cg_data->active_idx].vid_size_f; + uniform_params[1].enabled = true; uniform_params[1].type = UNIFORM_2F; - uniform_params[1].result.f.v0 = tex_width; - uniform_params[1].result.f.v1 = tex_height; + uniform_params[1].result.f.v0 = tex_width; + uniform_params[1].result.f.v1 = tex_height; uniform_data[1] = cg_data->prg[cg_data->active_idx].tex_size_f; + uniform_params[2].enabled = true; uniform_params[2].type = UNIFORM_2F; - uniform_params[2].result.f.v0 = out_width; - uniform_params[2].result.f.v1 = out_height; + uniform_params[2].result.f.v0 = out_width; + uniform_params[2].result.f.v1 = out_height; uniform_data[2] = cg_data->prg[cg_data->active_idx].out_size_f; + uniform_params[3].enabled = true; uniform_params[3].type = UNIFORM_1F; - uniform_params[3].result.f.v0 = state_manager_frame_is_reversed() ? -1.0 : 1.0; + uniform_params[3].result.f.v0 = state_manager_frame_is_reversed() ? -1.0 : 1.0; uniform_data[3] = cg_data->prg[cg_data->active_idx].frame_dir_f; + uniform_params[4].enabled = true; uniform_params[4].type = UNIFORM_2F; - uniform_params[4].result.f.v0 = width; - uniform_params[4].result.f.v1 = height; + uniform_params[4].result.f.v0 = width; + uniform_params[4].result.f.v1 = height; uniform_data[4] = cg_data->prg[cg_data->active_idx].vid_size_v; + uniform_params[5].enabled = true; uniform_params[5].type = UNIFORM_2F; - uniform_params[5].result.f.v0 = tex_width; - uniform_params[5].result.f.v1 = tex_height; + uniform_params[5].result.f.v0 = tex_width; + uniform_params[5].result.f.v1 = tex_height; uniform_data[5] = cg_data->prg[cg_data->active_idx].tex_size_v; + uniform_params[6].enabled = true; uniform_params[6].type = UNIFORM_2F; - uniform_params[6].result.f.v0 = out_width; - uniform_params[6].result.f.v1 = out_height; + uniform_params[6].result.f.v0 = out_width; + uniform_params[6].result.f.v1 = out_height; uniform_data[6] = cg_data->prg[cg_data->active_idx].out_size_v; + uniform_params[7].enabled = true; uniform_params[7].type = UNIFORM_1F; - uniform_params[7].result.f.v0 = state_manager_frame_is_reversed() ? -1.0 : 1.0; + uniform_params[7].result.f.v0 = state_manager_frame_is_reversed() ? -1.0 : 1.0; uniform_data[7] = cg_data->prg[cg_data->active_idx].frame_dir_v; uniform_count += 8; @@ -380,12 +392,14 @@ static void gl_cg_set_params(void *data, void *shader_data, if (modulo) frame_count %= modulo; + uniform_params[8].enabled = true; uniform_params[8].type = UNIFORM_1F; - uniform_params[8].result.f.v0 = (float)frame_count; + uniform_params[8].result.f.v0 = (float)frame_count; uniform_data[8] = cg_data->prg[cg_data->active_idx].frame_cnt_f; + uniform_params[9].enabled = true; uniform_params[9].type = UNIFORM_1F; - uniform_params[9].result.f.v0 = (float)frame_count; + uniform_params[9].result.f.v0 = (float)frame_count; uniform_data[9] = cg_data->prg[cg_data->active_idx].frame_cnt_v; uniform_count += 2; @@ -445,11 +459,13 @@ static void gl_cg_set_params(void *data, void *shader_data, pragma_cg_params[1] = cgGetNamedParameter( cg_data->prg[cg_data->active_idx].fprg, cg_data->shader->parameters[i].id); + uniform_params[0].enabled = true; uniform_params[0].type = UNIFORM_1F; - uniform_params[0].result.f.v0 = cg_data->shader->parameters[i].current; + uniform_params[0].result.f.v0 = cg_data->shader->parameters[i].current; + uniform_params[1].enabled = true; uniform_params[1].type = UNIFORM_1F; - uniform_params[1].result.f.v0 = cg_data->shader->parameters[i].current; + uniform_params[1].result.f.v0 = cg_data->shader->parameters[i].current; cg_uniform_set_parameter(&pragma_params[i], &pragma_cg_params[i]); } @@ -475,11 +491,13 @@ static void gl_cg_set_params(void *data, void *shader_data, pragma_cg_params[1] = cgGetNamedParameter( cg_data->prg[cg_data->active_idx].fprg, tracker_info[i].id); + uniform_params[0].enabled = true; uniform_params[0].type = UNIFORM_1F; uniform_params[0].result.f.v0 = tracker_info[i].value; + uniform_params[1].enabled = true; uniform_params[1].type = UNIFORM_1F; - uniform_params[1].result.f.v0 = tracker_info[i].value; + uniform_params[1].result.f.v0 = tracker_info[i].value; cg_uniform_set_parameter(&state_params[i], &pragma_cg_params[i]); } diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index 4d171fdc22..c48bd7e44c 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -92,6 +92,7 @@ enum shader_uniform_type struct uniform_info { enum shader_uniform_type type; + bool enabled; struct {