X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=ed2455f86aa315ec79f97bf2860563f7d40cc243;hb=e92de029768eef5f0fd744329e589161b46d0762;hp=d6bd5ee88d889c4efc02a0b9ee86a8051b8ec9a2;hpb=7f0e08f04536bf42b8f64e7dff5cc3e18b916c7b;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index d6bd5ee8..ed2455f8 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,11 @@ unsigned Program::add_stage(Stage type) stage_ids[type] = stage_id; glAttachShader(id, stage_id); +#ifdef DEBUG + if(!debug_name.empty() && KHR_debug) + set_stage_debug_name(stage_id, type); +#endif + return stage_id; } @@ -349,7 +355,8 @@ void Program::link() } } - Conditional _bind(!ARB_separate_shader_objects, this); + if(!ARB_separate_shader_objects) + glUseProgram(id); for(map::const_iterator i=transient->textures.begin(); i!=transient->textures.end(); ++i) { int location = get_uniform_location(i->first); @@ -748,23 +755,31 @@ int Program::get_attribute_location(const string &name) const return i!=attributes.end() && i->name==name ? i->location : -1; } -void Program::bind() const +void Program::set_debug_name(const string &name) { - if(!linked) - throw invalid_operation("Program::bind"); - - if(!set_current(this)) - return; - - glUseProgram(id); +#ifdef DEBUG + debug_name = name; + if(KHR_debug) + { + glObjectLabel(GL_PROGRAM, id, name.size(), name.c_str()); + for(unsigned i=0; i(i)); + } +#else + (void)name; +#endif } -void Program::unbind() +void Program::set_stage_debug_name(unsigned stage_id, Stage type) { - if(!set_current(0)) - return; - - glUseProgram(0); +#ifdef DEBUG + static const char *const suffixes[] = { " [VS]", " [GS]", " [FS]" }; + string name = debug_name+suffixes[type]; + glObjectLabel(GL_SHADER, stage_id, name.size(), name.c_str()); +#else + (void)stage_id; (void)type; +#endif }