mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
shader: use specific PStatCollector and group markers for shader compile
This makes it possible to determine which shader is taking which amount of time to compile.
This commit is contained in:
parent
9565d99fab
commit
406268c2e9
@ -6206,7 +6206,7 @@ release_geom(GeomContext *gc) {
|
||||
*/
|
||||
ShaderContext *CLP(GraphicsStateGuardian)::
|
||||
prepare_shader(Shader *se) {
|
||||
PStatGPUTimer timer(this, _prepare_shader_pcollector);
|
||||
PStatGPUTimer timer(this, se->get_prepare_shader_pcollector());
|
||||
|
||||
#ifndef OPENGLES_1
|
||||
ShaderContext *result = nullptr;
|
||||
@ -6214,7 +6214,9 @@ prepare_shader(Shader *se) {
|
||||
switch (se->get_language()) {
|
||||
case Shader::SL_GLSL:
|
||||
if (_supports_glsl) {
|
||||
push_group_marker(std::string("Prepare Shader ") + se->get_debug_name());
|
||||
result = new CLP(ShaderContext)(this, se);
|
||||
pop_group_marker();
|
||||
break;
|
||||
} else {
|
||||
GLCAT.error()
|
||||
@ -6225,7 +6227,9 @@ prepare_shader(Shader *se) {
|
||||
case Shader::SL_Cg:
|
||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||
if (_supports_basic_shaders) {
|
||||
push_group_marker(std::string("Prepare Shader ") + se->get_debug_name());
|
||||
result = new CLP(CgShaderContext)(this, se);
|
||||
pop_group_marker();
|
||||
break;
|
||||
} else {
|
||||
GLCAT.error()
|
||||
|
@ -3142,7 +3142,7 @@ glsl_compile_and_link() {
|
||||
}
|
||||
|
||||
if (_glgsg->_use_object_labels) {
|
||||
string name = _shader->get_filename();
|
||||
const std::string &name = _shader->get_debug_name();
|
||||
_glgsg->_glObjectLabel(GL_PROGRAM, _glsl_program, name.size(), name.data());
|
||||
}
|
||||
|
||||
|
@ -789,3 +789,19 @@ operator < (const Shader::ShaderFile &other) const {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PStatCollector for timing the preparation of just this shader.
|
||||
*/
|
||||
INLINE PStatCollector &Shader::
|
||||
get_prepare_shader_pcollector() {
|
||||
return _prepare_shader_pcollector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a name for the shader that is used for debugging.
|
||||
*/
|
||||
INLINE const std::string &Shader::
|
||||
get_debug_name() const {
|
||||
return _debug_name;
|
||||
}
|
||||
|
@ -2479,6 +2479,8 @@ read(const ShaderFile &sfile, BamCacheRecord *record) {
|
||||
}
|
||||
}
|
||||
|
||||
_prepare_shader_pcollector = PStatCollector(std::string("Draw:Prepare:Shader:") + _debug_name);
|
||||
|
||||
_loaded = true;
|
||||
return true;
|
||||
}
|
||||
@ -2569,6 +2571,9 @@ load(const ShaderFile &sbody, BamCacheRecord *record) {
|
||||
}
|
||||
}
|
||||
|
||||
_debug_name = "created-shader";
|
||||
_prepare_shader_pcollector = PStatCollector("Draw:Prepare:Shader:created-shader");
|
||||
|
||||
_loaded = true;
|
||||
return true;
|
||||
}
|
||||
@ -2589,6 +2594,8 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Filename fullpath = vf->get_filename();
|
||||
|
||||
if (_language == SL_GLSL && glsl_preprocess) {
|
||||
istream *source = vf->open_read_file(true);
|
||||
if (source == nullptr) {
|
||||
@ -2603,7 +2610,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) {
|
||||
|
||||
std::set<Filename> open_files;
|
||||
ostringstream sstr;
|
||||
if (!r_preprocess_source(sstr, *source, fn, vf->get_filename(), open_files, record)) {
|
||||
if (!r_preprocess_source(sstr, *source, fn, fullpath, open_files, record)) {
|
||||
vf->close_read_file(source);
|
||||
return false;
|
||||
}
|
||||
@ -2625,7 +2632,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) {
|
||||
}
|
||||
|
||||
_last_modified = std::max(_last_modified, vf->get_timestamp());
|
||||
_source_files.push_back(vf->get_filename());
|
||||
_source_files.push_back(fullpath);
|
||||
|
||||
// Strip trailing whitespace.
|
||||
while (!into.empty() && isspace(into[into.size() - 1])) {
|
||||
@ -2635,6 +2642,11 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) {
|
||||
// Except add back a newline at the end, which is needed by Intel drivers.
|
||||
into += "\n";
|
||||
|
||||
if (!_debug_name.empty()) {
|
||||
_debug_name += '/';
|
||||
}
|
||||
_debug_name += fullpath.get_basename();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -529,6 +529,9 @@ public:
|
||||
|
||||
static void set_default_caps(const ShaderCaps &caps);
|
||||
|
||||
INLINE PStatCollector &get_prepare_shader_pcollector();
|
||||
INLINE const std::string &get_debug_name() const;
|
||||
|
||||
private:
|
||||
#ifdef HAVE_CG
|
||||
ShaderArgClass cg_parameter_class(CGparameter p);
|
||||
@ -612,6 +615,9 @@ protected:
|
||||
typedef pmap <PreparedGraphicsObjects *, ShaderContext *> Contexts;
|
||||
Contexts _contexts;
|
||||
|
||||
PStatCollector _prepare_shader_pcollector;
|
||||
std::string _debug_name;
|
||||
|
||||
private:
|
||||
void clear_prepared(PreparedGraphicsObjects *prepared_objects);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user