(Cg) Flesh out uniform switch

This commit is contained in:
twinaphex 2016-04-13 02:54:01 +02:00
parent 960783987d
commit c5e4c90e88
2 changed files with 83 additions and 34 deletions

View File

@ -61,10 +61,30 @@ static void cg_uniform_set_parameter(void *data, void *uniform_data)
switch (param->type)
{
case UNIFORM_1F:
cgGLSetParameter1f((CGparameter)*cg_param, param->result.f.a);
cgGLSetParameter1f((CGparameter)*cg_param, param->result.f.v0);
break;
case UNIFORM_2F:
cgGLSetParameter2f((CGparameter)*cg_param, param->result.f.a, param->result.f.b);
cgGLSetParameter2f((CGparameter)*cg_param, param->result.f.v0, param->result.f.v1);
break;
case UNIFORM_3F:
cgGLSetParameter3f((CGparameter)*cg_param, param->result.f.v0, param->result.f.v1,
param->result.f.v2);
break;
case UNIFORM_4F:
cgGLSetParameter4f((CGparameter)*cg_param, param->result.f.v0, param->result.f.v1,
param->result.f.v2, param->result.f.v3);
break;
case UNIFORM_1FV:
cgGLSetParameter1fv((CGparameter)*cg_param, param->result.floatv);
break;
case UNIFORM_2FV:
cgGLSetParameter2fv((CGparameter)*cg_param, param->result.floatv);
break;
case UNIFORM_3FV:
cgGLSetParameter3fv((CGparameter)*cg_param, param->result.floatv);
break;
case UNIFORM_4FV:
cgGLSetParameter3fv((CGparameter)*cg_param, param->result.floatv);
break;
}
}
@ -257,23 +277,23 @@ static void gl_cg_set_texture_info(
}
uniform_params[0].type = UNIFORM_2F;
uniform_params[0].result.f.a = info->input_size[0];
uniform_params[0].result.f.b = 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].type = UNIFORM_2F;
uniform_params[1].result.f.a = info->input_size[0];
uniform_params[1].result.f.b = 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].type = UNIFORM_2F;
uniform_params[2].result.f.a = info->tex_size[0];
uniform_params[2].result.f.b = 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].type = UNIFORM_2F;
uniform_params[3].result.f.a = info->tex_size[0];
uniform_params[3].result.f.b = 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++)
@ -315,41 +335,41 @@ static void gl_cg_set_params(void *data, void *shader_data,
/* Set frame. */
uniform_params[0].type = UNIFORM_2F;
uniform_params[0].result.f.a = width;
uniform_params[0].result.f.b = 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].type = UNIFORM_2F;
uniform_params[1].result.f.a = tex_width;
uniform_params[1].result.f.b = 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].type = UNIFORM_2F;
uniform_params[2].result.f.a = out_width;
uniform_params[2].result.f.b = 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].type = UNIFORM_1F;
uniform_params[3].result.f.a = 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].type = UNIFORM_2F;
uniform_params[4].result.f.a = width;
uniform_params[4].result.f.b = 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].type = UNIFORM_2F;
uniform_params[5].result.f.a = tex_width;
uniform_params[5].result.f.b = 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].type = UNIFORM_2F;
uniform_params[6].result.f.a = out_width;
uniform_params[6].result.f.b = 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].type = UNIFORM_1F;
uniform_params[7].result.f.a = 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;
@ -361,11 +381,11 @@ static void gl_cg_set_params(void *data, void *shader_data,
frame_count %= modulo;
uniform_params[8].type = UNIFORM_1F;
uniform_params[8].result.f.a = (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].type = UNIFORM_1F;
uniform_params[9].result.f.a = (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;
@ -426,10 +446,10 @@ static void gl_cg_set_params(void *data, void *shader_data,
cg_data->prg[cg_data->active_idx].fprg, cg_data->shader->parameters[i].id);
uniform_params[0].type = UNIFORM_1F;
uniform_params[0].result.f.a = cg_data->shader->parameters[i].current;
uniform_params[0].result.f.v0 = cg_data->shader->parameters[i].current;
uniform_params[1].type = UNIFORM_1F;
uniform_params[1].result.f.a = 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]);
}
@ -456,10 +476,10 @@ static void gl_cg_set_params(void *data, void *shader_data,
cg_data->prg[cg_data->active_idx].fprg, tracker_info[i].id);
uniform_params[0].type = UNIFORM_1F;
uniform_params[0].result.f.a = tracker_info[i].value;
uniform_params[0].result.f.v0 = tracker_info[i].value;
uniform_params[1].type = UNIFORM_1F;
uniform_params[1].result.f.a = 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]);
}

View File

@ -80,7 +80,13 @@ enum video_shader_driver_ctl_state
enum shader_uniform_type
{
UNIFORM_1F = 0,
UNIFORM_2F
UNIFORM_2F,
UNIFORM_3F,
UNIFORM_4F,
UNIFORM_1FV,
UNIFORM_2FV,
UNIFORM_3FV,
UNIFORM_4FV,
};
struct uniform_info
@ -91,10 +97,33 @@ struct uniform_info
{
struct
{
float a;
float b;
float c;
intptr_t v0;
intptr_t v1;
intptr_t v2;
intptr_t v3;
} integer;
intptr_t *integerv;
struct
{
uintptr_t v0;
uintptr_t v1;
uintptr_t v2;
uintptr_t v3;
} unsigned_integer;
uintptr_t *unsigned_integerv;
struct
{
float v0;
float v1;
float v2;
float v3;
} f;
float *floatv;
} result;
};