This commit is contained in:
twinaphex 2016-01-08 18:12:49 +01:00
parent 39dc2a0d05
commit e334278696
2 changed files with 35 additions and 30 deletions

View File

@ -35,6 +35,8 @@
#include "../../verbosity.h"
#include "d3d.h"
#define cg_d3d9_set_param_1f(param, x) if (param) cgD3D9SetUniform(param, x)
struct lut_info
{
LPDIRECT3DTEXTURE tex;
@ -68,7 +70,6 @@ typedef struct cg_renderchain
const video_info_t *video_info;
state_tracker_t *tracker;
struct state_tracker_uniform uniform_info[MAX_VARIABLES];
unsigned uniform_cnt;
struct
{
LPDIRECT3DTEXTURE tex[TEXTURES];
@ -159,8 +160,9 @@ static INLINE bool validate_param_name(const char *name)
static INLINE CGparameter find_param_from_semantic(
CGparameter param, const char *sem)
{
while (param)
for (; param; param = cgGetNextParameter(param))
{
const char *semantic = NULL;
if (cgGetParameterType(param) == CG_STRUCT)
{
CGparameter ret = find_param_from_semantic(
@ -169,16 +171,18 @@ static INLINE CGparameter find_param_from_semantic(
if (ret)
return ret;
}
else
{
if (cgGetParameterSemantic(param) &&
!strcmp(sem, cgGetParameterSemantic(param)) &&
cgGetParameterDirection(param) == CG_IN &&
cgGetParameterVariability(param) == CG_VARYING &&
validate_param_name(cgGetParameterName(param)))
return param;
}
param = cgGetNextParameter(param);
if (cgGetParameterDirection(param) != CG_IN
|| cgGetParameterVariability(param) != CG_VARYING)
continue;
semantic = cgGetParameterSemantic(param);
if (!semantic)
continue;
if (!strcmp(sem, semantic) &&
validate_param_name(cgGetParameterName(param)))
return param;
}
return NULL;
@ -323,23 +327,25 @@ static void renderchain_set_shader_params(cg_renderchain_t *chain,
set_cg_param(pass->vPrg, "IN.frame_count", frame_cnt);
}
static void renderchain_bind_tracker(cg_renderchain_t *chain,
Pass *pass, unsigned pass_index)
{
unsigned i;
unsigned cnt = 0;
if (!chain || !chain->tracker || !pass)
return;
if (pass_index == 1)
chain->uniform_cnt = state_tracker_get_uniform(chain->tracker,
cnt = state_tracker_get_uniform(chain->tracker,
chain->uniform_info, MAX_VARIABLES, chain->frame_count);
for (i = 0; i < chain->uniform_cnt; i++)
for (i = 0; i < cnt; i++)
{
set_cg_param(pass->fPrg, chain->uniform_info[i].id,
chain->uniform_info[i].value);
set_cg_param(pass->vPrg, chain->uniform_info[i].id,
chain->uniform_info[i].value);
CGparameter param_f = cgGetNamedParameter(pass->fPrg, chain->uniform_info[i].id);
CGparameter param_v = cgGetNamedParameter(pass->vPrg, chain->uniform_info[i].id);
cg_d3d9_set_param_1f(param_f, &chain->uniform_info[i].value);
cg_d3d9_set_param_1f(param_v, &chain->uniform_info[i].value);
}
}

View File

@ -40,6 +40,9 @@
#include "../../rewind.h"
#include "../video_state_tracker.h"
#define set_param_2f(param, x, y) if (param) cgGLSetParameter2f(param, x, y)
#define cg_gl_set_param_1f(param, x) if (param) cgGLSetParameter1f(param, x)
#if 0
#define RARCH_CG_DEBUG
#endif
@ -210,10 +213,6 @@ fallback:
return false;
}
#define set_param_2f(param, x, y) \
if (param) cgGLSetParameter2f(param, x, y)
#define set_param_1f(param, x) \
if (param) cgGLSetParameter1f(param, x)
static void gl_cg_set_texture_info(void *data,
const struct cg_fbo_params *params, const struct gfx_tex_info *info)
@ -270,13 +269,13 @@ static void gl_cg_set_params(void *data, void *shader_data,
set_param_2f(cg_data->prg[cg_data->active_idx].vid_size_f, width, height);
set_param_2f(cg_data->prg[cg_data->active_idx].tex_size_f, tex_width, tex_height);
set_param_2f(cg_data->prg[cg_data->active_idx].out_size_f, out_width, out_height);
set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_f,
cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_f,
state_manager_frame_is_reversed() ? -1.0 : 1.0);
set_param_2f(cg_data->prg[cg_data->active_idx].vid_size_v, width, height);
set_param_2f(cg_data->prg[cg_data->active_idx].tex_size_v, tex_width, tex_height);
set_param_2f(cg_data->prg[cg_data->active_idx].out_size_v, out_width, out_height);
set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_v,
cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_dir_v,
state_manager_frame_is_reversed() ? -1.0 : 1.0);
if (cg_data->prg[cg_data->active_idx].frame_cnt_f || cg_data->prg[cg_data->active_idx].frame_cnt_v)
@ -285,8 +284,8 @@ static void gl_cg_set_params(void *data, void *shader_data,
if (modulo)
frame_count %= modulo;
set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_f, (float)frame_count);
set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_v, (float)frame_count);
cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_f, (float)frame_count);
cg_gl_set_param_1f(cg_data->prg[cg_data->active_idx].frame_cnt_v, (float)frame_count);
}
/* Set orig texture. */
@ -336,8 +335,8 @@ static void gl_cg_set_params(void *data, void *shader_data,
cg_data->prg[cg_data->active_idx].vprg, cg_data->shader->parameters[i].id);
CGparameter param_f = cgGetNamedParameter(
cg_data->prg[cg_data->active_idx].fprg, cg_data->shader->parameters[i].id);
set_param_1f(param_v, cg_data->shader->parameters[i].current);
set_param_1f(param_f, cg_data->shader->parameters[i].current);
cg_gl_set_param_1f(param_v, cg_data->shader->parameters[i].current);
cg_gl_set_param_1f(param_f, cg_data->shader->parameters[i].current);
}
/* Set state parameters. */
@ -357,8 +356,8 @@ static void gl_cg_set_params(void *data, void *shader_data,
cg_data->prg[cg_data->active_idx].vprg, tracker_info[i].id);
CGparameter param_f = cgGetNamedParameter(
cg_data->prg[cg_data->active_idx].fprg, tracker_info[i].id);
set_param_1f(param_v, tracker_info[i].value);
set_param_1f(param_f, tracker_info[i].value);
cg_gl_set_param_1f(param_v, tracker_info[i].value);
cg_gl_set_param_1f(param_f, tracker_info[i].value);
}
}
}