#include <msp/core/algorithm.h>
#include <msp/core/maputils.h>
+#include <msp/strings/format.h>
#include "error.h"
#include "renderbuffer.h"
#include "sequence.h"
get_item(postprocessors, name) = &pproc;
}
+void SequenceBuilder::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ debug_name = name;
+#else
+ (void)name;
+#endif
+}
+
void SequenceBuilder::build(Sequence &sequence) const
{
+#ifdef DEBUG
+ if(!debug_name.empty())
+ sequence.set_debug_name(debug_name);
+#endif
+
sequence.set_hdr(tmpl.get_hdr());
sequence.set_alpha(tmpl.get_alpha());
unsigned samples = min(tmpl.get_maximum_multisample(), Renderbuffer::get_max_samples());
{
proc = i->postprocessor_template->create(sequence.get_width(), sequence.get_height());
if(proc)
+ {
+#ifdef DEBUG
+ if(!debug_name.empty())
+ proc->set_debug_name(format("%s/%d.pproc", debug_name, i-postprocs.begin()));
+#endif
sequence.add_postprocessor_owned(proc);
+ }
}
}
}
const SequenceTemplate &tmpl;
std::map<std::string, Renderable *> renderables;
std::map<std::string, PostProcessor *> postprocessors;
+ std::string debug_name;
public:
SequenceBuilder(const SequenceTemplate &);
void set_renderable(const std::string &, Renderable &);
void set_postprocessor(const std::string &, PostProcessor &);
+ void set_debug_name(const std::string &);
+
void build(Sequence &) const;
Sequence *build(unsigned, unsigned) const;
Sequence *build(const View &) const;
#include <msp/gl/extensions/ext_texture_array.h>
#include <msp/gl/extensions/ext_texture3d.h>
#include <msp/gl/extensions/msp_buffer_control.h>
+#include <msp/gl/extensions/khr_debug.h>
#include "error.h"
#include "framebuffer.h"
#include "misc.h"
system().bind();
}
+void Framebuffer::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ if(KHR_debug)
+ glObjectLabel(GL_FRAMEBUFFER, id, name.size(), name.c_str());
+#else
+ (void)name;
+#endif
+}
+
Framebuffer &Framebuffer::system()
{
static Framebuffer sys_framebuf(0);
static const Framebuffer *current();
static void unbind();
+ void set_debug_name(const std::string &);
+
static Framebuffer &system();
};
#include <msp/gl/extensions/arb_direct_state_access.h>
#include <msp/gl/extensions/ext_framebuffer_multisample.h>
#include <msp/gl/extensions/ext_framebuffer_object.h>
+#include <msp/gl/extensions/khr_debug.h>
#include "misc.h"
#include "renderbuffer.h"
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
+void Renderbuffer::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ if(KHR_debug)
+ glObjectLabel(GL_RENDERBUFFER, id, name.size(), name.c_str());
+#else
+ (void)name;
+#endif
+}
+
} // namespace GL
} // namespace Msp
void bind() const;
static void unbind();
+
+ void set_debug_name(const std::string &);
};
} // namespace GL
quad.draw(renderer);
}
+void AmbientOcclusion::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ occlude_target.set_debug_name(name+" [RT]");
+ shdata.set_debug_name(name+" [UBO]");
+#else
+ (void)name;
+#endif
+}
+
AmbientOcclusion::Template::Template():
n_samples(16),
void set_darkness(float);
virtual void render(Renderer &, const Texture2D &, const Texture2D &);
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
quad.draw(renderer);
}
+void Bloom::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ for(unsigned i=0; i<2; ++i)
+ target[i]->set_debug_name(format("%s [RT:%d]", name, i));
+ common_shdata.set_debug_name(name+" [UBO:common]");
+ blur_shdata[0].set_debug_name(name+" [UBO:blur_x]");
+ blur_shdata[1].set_debug_name(name+" [UBO:blur_y]");
+#else
+ (void)name;
+#endif
+}
+
Bloom::Template::Template():
radius(2.0f),
void set_strength(float);
virtual void render(Renderer &, const Texture2D &, const Texture2D &);
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
quad.draw(renderer);
}
+void ColorCurve::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ shdata.set_debug_name(name+" [UBO]");
+ curve.set_debug_name(name+"/curve.tex1d");
+#else
+ (void)name;
+#endif
+}
+
ColorCurve::Template::Template():
exposure_adjust(0.0f),
void set_linear();
virtual void render(Renderer &, const Texture2D &, const Texture2D &);
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
virtual void setup_frame(Renderer &r) { renderable.setup_frame(r); }
virtual void finish_frame() { renderable.finish_frame(); }
+
+ virtual void set_debug_name(const std::string &) = 0;
};
} // namespace GL
renderer.render(renderable, tag);
}
+void EnvironmentMap::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ env_tex.set_debug_name(name+"/environment.texcb");
+ depth_buf.set_debug_name(name+"/environment_depth.rbuf");
+ static const char *face_names[] = { "X+", "X-", "Y+", "Y-", "Z+", "Z-" };
+ for(unsigned i=0; i<6; ++i)
+ {
+ faces[i].fbo.set_debug_name(format("%s [FBO:%s]", name, face_names[i]));
+ faces[i].camera.set_debug_name(format("%s/%s.camera", name, face_names[i]));
+ }
+
+ irradiance.set_debug_name(name+"/irradiance.texcb");
+ irradiance_fbo.set_debug_name(name+" [FBO:irradiance]");
+ for(unsigned i=0; i<specular_fbos.size(); ++i)
+ specular_fbos[i].set_debug_name(format("%s [FBO:specular_mip%d]", name, i+1));
+ prefilter_shdata.set_debug_name(name+" [UBO:prefilter]");
+ shdata.set_debug_name(name+" [UBO]");
+#else
+ (void)name;
+#endif
+}
+
} // namespace GL
} // namespace Msp
virtual void finish_frame();
virtual void render(Renderer &, Tag = Tag()) const;
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
virtual void render(const Texture2D &, const Texture2D &) { }
virtual void render(Renderer &, const Texture2D &, const Texture2D &);
+
+ virtual void set_debug_name(const std::string &) = 0;
};
} // namespace GL
renderer.render(renderable, tag);
}
+void ShadowMap::set_debug_name(const std::string &name)
+{
+#ifdef DEBUG
+ fbo.set_debug_name(name+" [FBO]");
+ shadow_camera.set_debug_name(name+".camera");
+ depth_buf.set_debug_name(name+"/depth.tex2d");
+ shdata.set_debug_name(name+" [UBO]");
+#else
+ (void)name;
+#endif
+}
+
} // namespace GL
} // namespace Msp
virtual void finish_frame();
virtual void render(Renderer &, Tag = Tag()) const;
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
fullscreen_mesh.draw(renderer);
}
+void Sky::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ transmittance_lookup.set_debug_name(name+" [RT:transmittance]");
+ distant.set_debug_name(name+" [RT:distant]");
+ shdata.set_debug_name(name+" [UBO]");
+#else
+ (void)name;
+#endif
+}
+
Sky::Planet::Planet():
rayleigh_scatter(0.0f),
virtual void setup_frame(Renderer &);
virtual void finish_frame();
virtual void render(Renderer &, Tag = Tag()) const;
+
+ virtual void set_debug_name(const std::string &);
};
} // namespace GL
#include <msp/core/maputils.h>
+#include <msp/strings/format.h>
#include "error.h"
#include "renderbuffer.h"
#include "rendertarget.h"
fbo.blit_from(other.fbo, COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT, false);
}
+void RenderTarget::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ fbo.set_debug_name(name+" [FBO]");
+ unsigned i = 0;
+ for(const unsigned char *j=format.begin(); j!=format.end(); ++i, ++j)
+ {
+ unsigned type = get_output_type(*j);
+
+ string buf_name;
+ if(type>=get_output_type(RENDER_DEPTH))
+ buf_name = name+"/depth";
+ else
+ buf_name = Msp::format("%s/color%d", name, type);
+
+ if(samples)
+ buffers[i].buffer->set_debug_name(buf_name+".tex2d");
+ else
+ buffers[i].texture->set_debug_name(buf_name+".rbuf");
+ }
+#else
+ (void)name;
+#endif
+}
+
} // namespace GL
} // namespace Msp
const Texture2D &get_target_texture(unsigned) const;
const Texture2D &get_target_texture(RenderOutput) const;
void blit_from(const RenderTarget &);
+
+ void set_debug_name(const std::string &);
};
} // namespace GL
if(!target_ms && samples)
target_ms = new RenderTarget(width, height, samples, fmt);
+
+#ifdef DEBUG
+ if(!debug_name.empty())
+ set_target_debug_names();
+#endif
+}
+
+void Sequence::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ debug_name = name;
+ if(!name.empty())
+ set_target_debug_names();
+#else
+ (void)name;
+#endif
+}
+
+void Sequence::set_target_debug_names()
+{
+#ifdef DEBUG
+ for(unsigned i=0; i<2; ++i)
+ if(target[i])
+ target[i]->set_debug_name(format("%s [RT:%d]", debug_name, i));
+ if(target_ms)
+ target_ms->set_debug_name(debug_name+" [RT:ms]");
+#endif
}
unsigned samples;
RenderTarget *target[2];
RenderTarget *target_ms;
+ std::string debug_name;
public:
Sequence(unsigned, unsigned, bool = false);
private:
void create_targets(unsigned);
+
+public:
+ void set_debug_name(const std::string &);
+private:
+ void set_target_debug_names();
};
} // namespace GL