mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-03 15:54:39 +00:00
Disable used attribs in Cg as well.
This commit is contained in:
parent
face42a888
commit
29dd4727b8
203
gfx/shader_cg.c
203
gfx/shader_cg.c
@ -134,10 +134,20 @@ static unsigned lut_textures[MAX_TEXTURES];
|
|||||||
static unsigned lut_textures_num = 0;
|
static unsigned lut_textures_num = 0;
|
||||||
static char lut_textures_uniform[MAX_TEXTURES][64];
|
static char lut_textures_uniform[MAX_TEXTURES][64];
|
||||||
|
|
||||||
|
static CGparameter cg_attribs[PREV_TEXTURES + 1 + MAX_SHADERS];
|
||||||
|
static unsigned cg_attrib_index;
|
||||||
|
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
static snes_tracker_t *snes_tracker = NULL;
|
static snes_tracker_t *snes_tracker = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void gl_cg_reset_attrib(void)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < cg_attrib_index; i++)
|
||||||
|
cgGLDisableClientState(cg_attribs[i]);
|
||||||
|
cg_attrib_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void gl_cg_set_proj_matrix(void)
|
void gl_cg_set_proj_matrix(void)
|
||||||
{
|
{
|
||||||
if (cg_active && prg[active_index].mvp)
|
if (cg_active && prg[active_index].mvp)
|
||||||
@ -158,121 +168,124 @@ void gl_cg_set_params(unsigned width, unsigned height,
|
|||||||
const struct gl_tex_info *fbo_info,
|
const struct gl_tex_info *fbo_info,
|
||||||
unsigned fbo_info_cnt)
|
unsigned fbo_info_cnt)
|
||||||
{
|
{
|
||||||
if (cg_active && active_index > 0)
|
if (!cg_active || (active_index == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set frame.
|
||||||
|
set_param_2f(prg[active_index].vid_size_f, width, height);
|
||||||
|
set_param_2f(prg[active_index].tex_size_f, tex_width, tex_height);
|
||||||
|
set_param_2f(prg[active_index].out_size_f, out_width, out_height);
|
||||||
|
set_param_1f(prg[active_index].frame_cnt_f, (float)frame_count);
|
||||||
|
set_param_1f(prg[active_index].frame_dir_f, g_extern.frame_is_reverse ? -1.0 : 1.0);
|
||||||
|
|
||||||
|
set_param_2f(prg[active_index].vid_size_v, width, height);
|
||||||
|
set_param_2f(prg[active_index].tex_size_v, tex_width, tex_height);
|
||||||
|
set_param_2f(prg[active_index].out_size_v, out_width, out_height);
|
||||||
|
set_param_1f(prg[active_index].frame_cnt_v, (float)frame_count);
|
||||||
|
set_param_1f(prg[active_index].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0);
|
||||||
|
|
||||||
|
// Set orig texture.
|
||||||
|
CGparameter param = prg[active_index].orig.tex;
|
||||||
|
if (param)
|
||||||
{
|
{
|
||||||
// Set frame.
|
cgGLSetTextureParameter(param, info->tex);
|
||||||
set_param_2f(prg[active_index].vid_size_f, width, height);
|
cgGLEnableTextureParameter(param);
|
||||||
set_param_2f(prg[active_index].tex_size_f, tex_width, tex_height);
|
}
|
||||||
set_param_2f(prg[active_index].out_size_f, out_width, out_height);
|
|
||||||
set_param_1f(prg[active_index].frame_cnt_f, (float)frame_count);
|
|
||||||
set_param_1f(prg[active_index].frame_dir_f, g_extern.frame_is_reverse ? -1.0 : 1.0);
|
|
||||||
|
|
||||||
set_param_2f(prg[active_index].vid_size_v, width, height);
|
set_param_2f(prg[active_index].orig.vid_size_v, info->input_size[0], info->input_size[1]);
|
||||||
set_param_2f(prg[active_index].tex_size_v, tex_width, tex_height);
|
set_param_2f(prg[active_index].orig.vid_size_f, info->input_size[0], info->input_size[1]);
|
||||||
set_param_2f(prg[active_index].out_size_v, out_width, out_height);
|
set_param_2f(prg[active_index].orig.tex_size_v, info->tex_size[0], info->tex_size[1]);
|
||||||
set_param_1f(prg[active_index].frame_cnt_v, (float)frame_count);
|
set_param_2f(prg[active_index].orig.tex_size_f, info->tex_size[0], info->tex_size[1]);
|
||||||
set_param_1f(prg[active_index].frame_dir_v, g_extern.frame_is_reverse ? -1.0 : 1.0);
|
if (prg[active_index].orig.coord)
|
||||||
|
{
|
||||||
|
cgGLSetParameterPointer(prg[active_index].orig.coord, 2, GL_FLOAT, 0, info->coord);
|
||||||
|
cgGLEnableClientState(prg[active_index].orig.coord);
|
||||||
|
cg_attribs[cg_attrib_index++] = prg[active_index].orig.coord;
|
||||||
|
}
|
||||||
|
|
||||||
// Set orig texture.
|
// Set prev textures.
|
||||||
CGparameter param = prg[active_index].orig.tex;
|
for (unsigned i = 0; i < PREV_TEXTURES; i++)
|
||||||
|
{
|
||||||
|
param = prg[active_index].prev[i].tex;
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(param, info->tex);
|
cgGLSetTextureParameter(param, prev_info[i].tex);
|
||||||
cgGLEnableTextureParameter(param);
|
cgGLEnableTextureParameter(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_param_2f(prg[active_index].orig.vid_size_v, info->input_size[0], info->input_size[1]);
|
set_param_2f(prg[active_index].prev[i].vid_size_v, prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.vid_size_f, info->input_size[0], info->input_size[1]);
|
set_param_2f(prg[active_index].prev[i].vid_size_f, prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.tex_size_v, info->tex_size[0], info->tex_size[1]);
|
set_param_2f(prg[active_index].prev[i].tex_size_v, prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
||||||
set_param_2f(prg[active_index].orig.tex_size_f, info->tex_size[0], info->tex_size[1]);
|
set_param_2f(prg[active_index].prev[i].tex_size_f, prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
||||||
if (prg[active_index].orig.coord)
|
|
||||||
{
|
|
||||||
cgGLSetParameterPointer(prg[active_index].orig.coord, 2, GL_FLOAT, 0, info->coord);
|
|
||||||
cgGLEnableClientState(prg[active_index].orig.coord);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set prev textures.
|
if (prg[active_index].prev[i].coord)
|
||||||
for (unsigned i = 0; i < PREV_TEXTURES; i++)
|
|
||||||
{
|
{
|
||||||
param = prg[active_index].prev[i].tex;
|
cgGLSetParameterPointer(prg[active_index].prev[i].coord, 2, GL_FLOAT, 0, prev_info[i].coord);
|
||||||
if (param)
|
cgGLEnableClientState(prg[active_index].prev[i].coord);
|
||||||
|
cg_attribs[cg_attrib_index++] = prg[active_index].prev[i].coord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set lookup textures.
|
||||||
|
for (unsigned i = 0; i < lut_textures_num; i++)
|
||||||
|
{
|
||||||
|
CGparameter param = cgGetNamedParameter(prg[active_index].fprg, lut_textures_uniform[i]);
|
||||||
|
if (param)
|
||||||
|
{
|
||||||
|
cgGLSetTextureParameter(param, lut_textures[i]);
|
||||||
|
cgGLEnableTextureParameter(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set FBO textures.
|
||||||
|
if (active_index > 2)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < fbo_info_cnt; i++)
|
||||||
|
{
|
||||||
|
if (prg[active_index].fbo[i].tex)
|
||||||
{
|
{
|
||||||
cgGLSetTextureParameter(param, prev_info[i].tex);
|
cgGLSetTextureParameter(prg[active_index].fbo[i].tex, fbo_info[i].tex);
|
||||||
cgGLEnableTextureParameter(param);
|
cgGLEnableTextureParameter(prg[active_index].fbo[i].tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_param_2f(prg[active_index].prev[i].vid_size_v, prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
set_param_2f(prg[active_index].fbo[i].vid_size_v,
|
||||||
set_param_2f(prg[active_index].prev[i].vid_size_f, prev_info[i].input_size[0], prev_info[i].input_size[1]);
|
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
||||||
set_param_2f(prg[active_index].prev[i].tex_size_v, prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
set_param_2f(prg[active_index].fbo[i].vid_size_f,
|
||||||
set_param_2f(prg[active_index].prev[i].tex_size_f, prev_info[i].tex_size[0], prev_info[i].tex_size[1]);
|
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
||||||
|
|
||||||
if (prg[active_index].prev[i].coord)
|
set_param_2f(prg[active_index].fbo[i].tex_size_v,
|
||||||
|
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
||||||
|
set_param_2f(prg[active_index].fbo[i].tex_size_f,
|
||||||
|
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
||||||
|
|
||||||
|
if (prg[active_index].fbo[i].coord)
|
||||||
{
|
{
|
||||||
cgGLSetParameterPointer(prg[active_index].prev[i].coord, 2, GL_FLOAT, 0, prev_info[i].coord);
|
cgGLSetParameterPointer(prg[active_index].fbo[i].coord, 2, GL_FLOAT, 0, fbo_info[i].coord);
|
||||||
cgGLEnableClientState(prg[active_index].prev[i].coord);
|
cgGLEnableClientState(prg[active_index].fbo[i].coord);
|
||||||
}
|
cg_attribs[cg_attrib_index++] = prg[active_index].fbo[i].coord;
|
||||||
}
|
|
||||||
|
|
||||||
// Set lookup textures.
|
|
||||||
for (unsigned i = 0; i < lut_textures_num; i++)
|
|
||||||
{
|
|
||||||
CGparameter param = cgGetNamedParameter(prg[active_index].fprg, lut_textures_uniform[i]);
|
|
||||||
if (param)
|
|
||||||
{
|
|
||||||
cgGLSetTextureParameter(param, lut_textures[i]);
|
|
||||||
cgGLEnableTextureParameter(param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set FBO textures.
|
|
||||||
if (active_index > 2)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < fbo_info_cnt; i++)
|
|
||||||
{
|
|
||||||
if (prg[active_index].fbo[i].tex)
|
|
||||||
{
|
|
||||||
cgGLSetTextureParameter(prg[active_index].fbo[i].tex, fbo_info[i].tex);
|
|
||||||
cgGLEnableTextureParameter(prg[active_index].fbo[i].tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_param_2f(prg[active_index].fbo[i].vid_size_v,
|
|
||||||
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
|
||||||
set_param_2f(prg[active_index].fbo[i].vid_size_f,
|
|
||||||
fbo_info[i].input_size[0], fbo_info[i].input_size[1]);
|
|
||||||
|
|
||||||
set_param_2f(prg[active_index].fbo[i].tex_size_v,
|
|
||||||
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
|
||||||
set_param_2f(prg[active_index].fbo[i].tex_size_f,
|
|
||||||
fbo_info[i].tex_size[0], fbo_info[i].tex_size[1]);
|
|
||||||
|
|
||||||
if (prg[active_index].fbo[i].coord)
|
|
||||||
{
|
|
||||||
cgGLSetParameterPointer(prg[active_index].fbo[i].coord, 2, GL_FLOAT, 0, fbo_info[i].coord);
|
|
||||||
cgGLEnableClientState(prg[active_index].fbo[i].coord);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
// Set state parameters
|
// Set state parameters
|
||||||
if (snes_tracker)
|
if (snes_tracker)
|
||||||
|
{
|
||||||
|
static struct snes_tracker_uniform info[MAX_VARIABLES];
|
||||||
|
static unsigned cnt = 0;
|
||||||
|
|
||||||
|
if (active_index == 1)
|
||||||
|
cnt = snes_get_uniform(snes_tracker, info, MAX_VARIABLES, frame_count);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < cnt; i++)
|
||||||
{
|
{
|
||||||
static struct snes_tracker_uniform info[MAX_VARIABLES];
|
CGparameter param_v = cgGetNamedParameter(prg[active_index].vprg, info[i].id);
|
||||||
static unsigned cnt = 0;
|
CGparameter param_f = cgGetNamedParameter(prg[active_index].fprg, info[i].id);
|
||||||
|
set_param_1f(param_v, info[i].value);
|
||||||
if (active_index == 1)
|
set_param_1f(param_f, info[i].value);
|
||||||
cnt = snes_get_uniform(snes_tracker, info, MAX_VARIABLES, frame_count);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < cnt; i++)
|
|
||||||
{
|
|
||||||
CGparameter param_v = cgGetNamedParameter(prg[active_index].vprg, info[i].id);
|
|
||||||
CGparameter param_f = cgGetNamedParameter(prg[active_index].fprg, info[i].id);
|
|
||||||
set_param_1f(param_v, info[i].value);
|
|
||||||
set_param_1f(param_f, info[i].value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_cg_deinit(void)
|
void gl_cg_deinit(void)
|
||||||
@ -280,6 +293,8 @@ void gl_cg_deinit(void)
|
|||||||
if (!cg_active)
|
if (!cg_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
gl_cg_reset_attrib();
|
||||||
|
|
||||||
cg_active = false;
|
cg_active = false;
|
||||||
cg_shader_num = 0;
|
cg_shader_num = 0;
|
||||||
memset(prg, 0, sizeof(prg));
|
memset(prg, 0, sizeof(prg));
|
||||||
@ -1053,6 +1068,8 @@ void gl_cg_use(unsigned index)
|
|||||||
{
|
{
|
||||||
if (cg_active && prg[index].vprg && prg[index].fprg)
|
if (cg_active && prg[index].vprg && prg[index].fprg)
|
||||||
{
|
{
|
||||||
|
gl_cg_reset_attrib();
|
||||||
|
|
||||||
active_index = index;
|
active_index = index;
|
||||||
cgGLBindProgram(prg[index].vprg);
|
cgGLBindProgram(prg[index].vprg);
|
||||||
cgGLBindProgram(prg[index].fprg);
|
cgGLBindProgram(prg[index].fprg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user