This bug is driving me nuts. It cannot possibly be my bug ...

This commit is contained in:
Themaister 2011-05-26 02:03:38 +02:00
parent 3ee19ec75f
commit 3aed471d57
2 changed files with 38 additions and 29 deletions

View File

@ -116,7 +116,6 @@ static inline bool load_gl_proc(void)
static inline bool load_gl_proc(void) { return true; } static inline bool load_gl_proc(void) { return true; }
#endif #endif
#define MAX_SHADERS 16 #define MAX_SHADERS 16
typedef struct gl typedef struct gl

View File

@ -57,6 +57,20 @@ static void cg_error_handler(CGcontext ctx, CGerror error, void *data)
(void)ctx; (void)ctx;
(void)data; (void)data;
switch (error)
{
case CG_INVALID_PARAM_HANDLE_ERROR:
SSNES_ERR("Invalid param handle.\n");
break;
case CG_INVALID_PARAMETER_ERROR:
SSNES_ERR("Invalid parameter.\n");
break;
default:
break;
}
SSNES_ERR("CG error!: \"%s\".\n", cgGetErrorString(error)); SSNES_ERR("CG error!: \"%s\".\n", cgGetErrorString(error));
} }
#endif #endif
@ -113,10 +127,8 @@ static char lut_textures_uniform[MAX_TEXTURES][64];
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)
{
cgGLSetStateMatrixParameter(prg[active_index].mvp, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); cgGLSetStateMatrixParameter(prg[active_index].mvp, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
} }
}
#define set_param_2f(param, x, y) \ #define set_param_2f(param, x, y) \
if (param) cgGLSetParameter2f(param, x, y) if (param) cgGLSetParameter2f(param, x, y)
@ -131,7 +143,7 @@ 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) if (cg_active && active_index > 0)
{ {
// Set frame. // Set frame.
set_param_2f(prg[active_index].vid_size_f, width, height); set_param_2f(prg[active_index].vid_size_f, width, height);
@ -144,25 +156,14 @@ void gl_cg_set_params(unsigned width, unsigned height,
set_param_2f(prg[active_index].out_size_v, out_width, out_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_cnt_v, (float)frame_count);
// Set lookup textures. // Set orig texture.
for (unsigned i = 0; i < lut_textures_num; i++) CGparameter param = prg[active_index].orig.tex;
{
CGparameter param = cgGetNamedParameter(prg[active_index].fprg, lut_textures_uniform[i]);
if (param) if (param)
{ {
cgGLSetTextureParameter(param, lut_textures[i]); cgGLSetTextureParameter(param, info->tex);
//fprintf(stderr, "ORIGtex = (%d) %d\n", cgGLGetTextureParameter(param), cgGLGetTextureEnum(param) - GL_TEXTURE0);
cgGLEnableTextureParameter(param); cgGLEnableTextureParameter(param);
} }
}
// Set orig texture.
if (active_index > 1)
{
if (prg[active_index].orig.tex)
{
cgGLSetTextureParameter(prg[active_index].orig.tex, info->tex);
cgGLEnableTextureParameter(prg[active_index].orig.tex);
}
set_param_2f(prg[active_index].orig.vid_size_v, info->input_size[0], info->input_size[1]); set_param_2f(prg[active_index].orig.vid_size_v, info->input_size[0], info->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].orig.vid_size_f, info->input_size[0], info->input_size[1]);
@ -174,6 +175,17 @@ void gl_cg_set_params(unsigned width, unsigned height,
cgGLSetParameterPointer(prg[active_index].orig.coord, 2, GL_FLOAT, 0, info->coord); cgGLSetParameterPointer(prg[active_index].orig.coord, 2, GL_FLOAT, 0, info->coord);
cgGLEnableClientState(prg[active_index].orig.coord); cgGLEnableClientState(prg[active_index].orig.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);
//fprintf(stderr, "LUTtex = (%d) %d\n", cgGLGetTextureParameter(param), cgGLGetTextureEnum(param) - GL_TEXTURE0);
}
} }
// Set FBO textures. // Set FBO textures.
@ -561,9 +573,7 @@ bool gl_cg_init(const char *path)
return false; return false;
} }
////
//cgGLSetManageTextureParameters(cgCtx, CG_TRUE); //cgGLSetManageTextureParameters(cgCtx, CG_TRUE);
///
#ifdef SSNES_CG_DEBUG #ifdef SSNES_CG_DEBUG
cgGLSetDebugMode(CG_TRUE); cgGLSetDebugMode(CG_TRUE);