mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -04:00
fix Cg error reporting and lack of shader unbinding
This commit is contained in:
parent
bfebff1d0a
commit
edab64c570
@ -221,8 +221,10 @@ CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) {
|
|||||||
|
|
||||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||||
_cg_context = 0;
|
_cg_context = 0;
|
||||||
|
_cg_vprofile = CG_PROFILE_UNKNOWN;
|
||||||
|
_cg_fprofile = CG_PROFILE_UNKNOWN;
|
||||||
|
_cg_gprofile = CG_PROFILE_UNKNOWN;
|
||||||
if (s->get_language() == Shader::SL_Cg) {
|
if (s->get_language() == Shader::SL_Cg) {
|
||||||
|
|
||||||
// Ask the shader to compile itself for us and
|
// Ask the shader to compile itself for us and
|
||||||
// to give us the resulting Cg program objects.
|
// to give us the resulting Cg program objects.
|
||||||
|
|
||||||
@ -236,36 +238,41 @@ CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the program.
|
// Load the program.
|
||||||
|
|
||||||
if (_cg_vprogram != 0) {
|
if (_cg_vprogram != 0) {
|
||||||
|
_cg_vprofile = cgGetProgramProfile(_cg_vprogram);
|
||||||
cgGLLoadProgram(_cg_vprogram);
|
cgGLLoadProgram(_cg_vprogram);
|
||||||
CGerror verror = cgGetError();
|
CGerror verror = cgGetError();
|
||||||
if (verror != CG_NO_ERROR) {
|
if (verror != CG_NO_ERROR) {
|
||||||
const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
|
const char *str = cgGetErrorString(verror);
|
||||||
GLCAT.error() << "Could not load Cg vertex program:" << s->get_filename(Shader::ST_vertex) << " (" <<
|
GLCAT.error()
|
||||||
cgGetProfileString(cgGetProgramProfile(_cg_vprogram)) << " " << str << ")\n";
|
<< "Could not load Cg vertex program: " << s->get_filename(Shader::ST_vertex)
|
||||||
|
<< " (" << cgGetProfileString(_cg_vprofile) << " " << str << ")\n";
|
||||||
release_resources(gsg);
|
release_resources(gsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cg_fprogram != 0) {
|
if (_cg_fprogram != 0) {
|
||||||
|
_cg_fprofile = cgGetProgramProfile(_cg_fprogram);
|
||||||
cgGLLoadProgram(_cg_fprogram);
|
cgGLLoadProgram(_cg_fprogram);
|
||||||
CGerror ferror = cgGetError();
|
CGerror ferror = cgGetError();
|
||||||
if (ferror != CG_NO_ERROR) {
|
if (ferror != CG_NO_ERROR) {
|
||||||
const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
|
const char *str = cgGetErrorString(ferror);
|
||||||
GLCAT.error() << "Could not load Cg fragment program:" << s->get_filename(Shader::ST_fragment) << " (" <<
|
GLCAT.error()
|
||||||
cgGetProfileString(cgGetProgramProfile(_cg_fprogram)) << " " << str << ")\n";
|
<< "Could not load Cg fragment program: " << s->get_filename(Shader::ST_fragment)
|
||||||
|
<< " (" << cgGetProfileString(_cg_fprofile) << " " << str << ")\n";
|
||||||
release_resources(gsg);
|
release_resources(gsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cg_gprogram != 0) {
|
if (_cg_gprogram != 0) {
|
||||||
|
_cg_gprofile = cgGetProgramProfile(_cg_gprogram);
|
||||||
cgGLLoadProgram(_cg_gprogram);
|
cgGLLoadProgram(_cg_gprogram);
|
||||||
CGerror gerror = cgGetError();
|
CGerror gerror = cgGetError();
|
||||||
if (gerror != CG_NO_ERROR) {
|
if (gerror != CG_NO_ERROR) {
|
||||||
const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
|
const char *str = cgGetErrorString(gerror);
|
||||||
GLCAT.error() << "Could not load Cg geometry program:" << s->get_filename(Shader::ST_geometry) << " (" <<
|
GLCAT.error()
|
||||||
cgGetProfileString(cgGetProgramProfile(_cg_gprogram)) << " " << str << ")\n";
|
<< "Could not load Cg geometry program: " << s->get_filename(Shader::ST_geometry)
|
||||||
|
<< " (" << cgGetProfileString(_cg_gprofile) << " " << str << ")\n";
|
||||||
release_resources(gsg);
|
release_resources(gsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,15 +839,15 @@ bind(GSG *gsg, bool reissue_parameters) {
|
|||||||
if (_cg_context != 0) {
|
if (_cg_context != 0) {
|
||||||
// Bind the shaders.
|
// Bind the shaders.
|
||||||
if (_cg_vprogram != 0) {
|
if (_cg_vprogram != 0) {
|
||||||
cgGLEnableProfile(cgGetProgramProfile(_cg_vprogram));
|
cgGLEnableProfile(_cg_vprofile);
|
||||||
cgGLBindProgram(_cg_vprogram);
|
cgGLBindProgram(_cg_vprogram);
|
||||||
}
|
}
|
||||||
if (_cg_fprogram != 0) {
|
if (_cg_fprogram != 0) {
|
||||||
cgGLEnableProfile(cgGetProgramProfile(_cg_fprogram));
|
cgGLEnableProfile(_cg_fprofile);
|
||||||
cgGLBindProgram(_cg_fprogram);
|
cgGLBindProgram(_cg_fprogram);
|
||||||
}
|
}
|
||||||
if (_cg_gprogram != 0) {
|
if (_cg_gprogram != 0) {
|
||||||
cgGLEnableProfile(cgGetProgramProfile(_cg_gprogram));
|
cgGLEnableProfile(_cg_gprofile);
|
||||||
cgGLBindProgram(_cg_gprogram);
|
cgGLBindProgram(_cg_gprogram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,13 +870,16 @@ unbind(GSG *gsg) {
|
|||||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||||
if (_cg_context != 0) {
|
if (_cg_context != 0) {
|
||||||
if (_cg_vprogram != 0) {
|
if (_cg_vprogram != 0) {
|
||||||
cgGLDisableProfile(cgGetProgramProfile(_cg_vprogram));
|
cgGLUnbindProgram(_cg_vprofile);
|
||||||
|
cgGLDisableProfile(_cg_vprofile);
|
||||||
}
|
}
|
||||||
if (_cg_fprogram != 0) {
|
if (_cg_fprogram != 0) {
|
||||||
cgGLDisableProfile(cgGetProgramProfile(_cg_fprogram));
|
cgGLUnbindProgram(_cg_fprofile);
|
||||||
|
cgGLDisableProfile(_cg_fprofile);
|
||||||
}
|
}
|
||||||
if (_cg_gprogram != 0) {
|
if (_cg_gprogram != 0) {
|
||||||
cgGLDisableProfile(cgGetProgramProfile(_cg_gprogram));
|
cgGLUnbindProgram(_cg_gprofile);
|
||||||
|
cgGLDisableProfile(_cg_gprofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
cg_report_errors();
|
cg_report_errors();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user