mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Add debug code to print out shader asm code in debug mode.
Check for errors when the Cg generated shader code is loaded.
This commit is contained in:
parent
facb0ed528
commit
e32b6c08c4
@ -258,7 +258,7 @@ try_cg_compile(ShaderExpansion *s, GSG *gsg)
|
|||||||
parameter = cgGetNextLeafParameter(parameter)) {
|
parameter = cgGetNextLeafParameter(parameter)) {
|
||||||
CGenum vbl = cgGetParameterVariability(parameter);
|
CGenum vbl = cgGetParameterVariability(parameter);
|
||||||
if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)) {
|
if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)) {
|
||||||
success &= compile_parameter(parameter,
|
success &= compile_parameter(parameter,
|
||||||
cgGetParameterName(parameter),
|
cgGetParameterName(parameter),
|
||||||
cg_type_to_panda_type(cgGetParameterType(parameter)),
|
cg_type_to_panda_type(cgGetParameterType(parameter)),
|
||||||
cg_dir_to_panda_dir(cgGetParameterDirection(parameter)),
|
cg_dir_to_panda_dir(cgGetParameterDirection(parameter)),
|
||||||
@ -276,6 +276,18 @@ try_cg_compile(ShaderExpansion *s, GSG *gsg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DEBUG: output the generated program
|
||||||
|
if (GLCAT.is_debug()) {
|
||||||
|
const char *vertex_program;
|
||||||
|
const char *pixel_program;
|
||||||
|
|
||||||
|
vertex_program = cgGetProgramString (_cg_program[0], CG_COMPILED_PROGRAM);
|
||||||
|
pixel_program = cgGetProgramString (_cg_program[1], CG_COMPILED_PROGRAM);
|
||||||
|
|
||||||
|
GLCAT.debug() << vertex_program << "\n";
|
||||||
|
GLCAT.debug() << pixel_program << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// The following code is present to work around a bug in the Cg compiler.
|
// The following code is present to work around a bug in the Cg compiler.
|
||||||
// It does not generate correct code for shadow map lookups when using arbfp1.
|
// It does not generate correct code for shadow map lookups when using arbfp1.
|
||||||
// This is a particularly onerous limitation, given that arbfp1 is the only
|
// This is a particularly onerous limitation, given that arbfp1 is the only
|
||||||
@ -350,7 +362,9 @@ try_cg_compile(ShaderExpansion *s, GSG *gsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cgGLLoadProgram(_cg_program[SHADER_type_vert]);
|
cgGLLoadProgram(_cg_program[SHADER_type_vert]);
|
||||||
|
report_cg_compile_errors(s->get_name(), _cg_context);
|
||||||
cgGLLoadProgram(_cg_program[SHADER_type_frag]);
|
cgGLLoadProgram(_cg_program[SHADER_type_frag]);
|
||||||
|
report_cg_compile_errors(s->get_name(), _cg_context);
|
||||||
|
|
||||||
_state = true;
|
_state = true;
|
||||||
|
|
||||||
@ -449,7 +463,7 @@ issue_parameters(GSG *gsg, bool altered) {
|
|||||||
if (_cg_context == 0) {
|
if (_cg_context == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<(int)_mat_spec.size(); i++) {
|
for (int i=0; i<(int)_mat_spec.size(); i++) {
|
||||||
if (altered || _mat_spec[i]._trans_dependent) {
|
if (altered || _mat_spec[i]._trans_dependent) {
|
||||||
CGparameter p = (CGparameter)(_mat_spec[i]._parameter);
|
CGparameter p = (CGparameter)(_mat_spec[i]._parameter);
|
||||||
@ -485,7 +499,7 @@ disable_shader_vertex_arrays(GSG *gsg) {
|
|||||||
if (_cg_context == 0) {
|
if (_cg_context == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<(int)_var_spec.size(); i++) {
|
for (int i=0; i<(int)_var_spec.size(); i++) {
|
||||||
CGparameter p = (CGparameter)(_var_spec[i]._parameter);
|
CGparameter p = (CGparameter)(_var_spec[i]._parameter);
|
||||||
cgGLDisableClientState(p);
|
cgGLDisableClientState(p);
|
||||||
@ -511,7 +525,7 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg) {
|
|||||||
if (_cg_context == 0) {
|
if (_cg_context == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SUPPORT_IMMEDIATE_MODE
|
#ifdef SUPPORT_IMMEDIATE_MODE
|
||||||
if (gsg->_use_sender) {
|
if (gsg->_use_sender) {
|
||||||
GLCAT.error() << "immediate mode shaders not implemented yet\n";
|
GLCAT.error() << "immediate mode shaders not implemented yet\n";
|
||||||
@ -632,17 +646,17 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) {
|
|||||||
if (tc == (TextureContext*)NULL) {
|
if (tc == (TextureContext*)NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int texunit = cgGetParameterResourceIndex(p);
|
int texunit = cgGetParameterResourceIndex(p);
|
||||||
gsg->_glActiveTexture(GL_TEXTURE0 + texunit);
|
gsg->_glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
|
|
||||||
GLenum target = gsg->get_texture_target(tex->get_texture_type());
|
GLenum target = gsg->get_texture_target(tex->get_texture_type());
|
||||||
if (target == GL_NONE) {
|
if (target == GL_NONE) {
|
||||||
// Unsupported texture mode.
|
// Unsupported texture mode.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GLP(Enable)(target);
|
GLP(Enable)(target);
|
||||||
|
|
||||||
gsg->apply_texture(tc);
|
gsg->apply_texture(tc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user