Disable used attribs in Cg as well.

This commit is contained in:
Themaister 2011-11-12 18:31:22 +01:00
parent face42a888
commit 29dd4727b8
1 changed files with 110 additions and 93 deletions

View File

@ -134,10 +134,20 @@ static unsigned lut_textures[MAX_TEXTURES];
static unsigned lut_textures_num = 0;
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
static snes_tracker_t *snes_tracker = NULL;
#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)
{
if (cg_active && prg[active_index].mvp)
@ -158,8 +168,9 @@ void gl_cg_set_params(unsigned width, unsigned height,
const struct gl_tex_info *fbo_info,
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);
@ -189,6 +200,7 @@ void gl_cg_set_params(unsigned width, unsigned height,
{
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 prev textures.
@ -210,6 +222,7 @@ void gl_cg_set_params(unsigned width, unsigned height,
{
cgGLSetParameterPointer(prg[active_index].prev[i].coord, 2, GL_FLOAT, 0, prev_info[i].coord);
cgGLEnableClientState(prg[active_index].prev[i].coord);
cg_attribs[cg_attrib_index++] = prg[active_index].prev[i].coord;
}
}
@ -249,6 +262,7 @@ void gl_cg_set_params(unsigned width, unsigned height,
{
cgGLSetParameterPointer(prg[active_index].fbo[i].coord, 2, GL_FLOAT, 0, fbo_info[i].coord);
cgGLEnableClientState(prg[active_index].fbo[i].coord);
cg_attribs[cg_attrib_index++] = prg[active_index].fbo[i].coord;
}
}
}
@ -272,7 +286,6 @@ void gl_cg_set_params(unsigned width, unsigned height,
}
}
#endif
}
}
void gl_cg_deinit(void)
@ -280,6 +293,8 @@ void gl_cg_deinit(void)
if (!cg_active)
return;
gl_cg_reset_attrib();
cg_active = false;
cg_shader_num = 0;
memset(prg, 0, sizeof(prg));
@ -1053,6 +1068,8 @@ void gl_cg_use(unsigned index)
{
if (cg_active && prg[index].vprg && prg[index].fprg)
{
gl_cg_reset_attrib();
active_index = index;
cgGLBindProgram(prg[index].vprg);
cgGLBindProgram(prg[index].fprg);