GPU: Improve shader dependency logger
Add shader name to graph. Strip CLOG prefix for mermaid lines.
This commit is contained in:
@@ -702,12 +702,12 @@ Shader *ShaderCompiler::compile(const shader::ShaderCreateInfo &info, bool is_ba
|
||||
}
|
||||
for (auto filename : info.typedef_sources_) {
|
||||
typedefs.extend_non_duplicates(
|
||||
gpu_shader_dependency_get_resolved_source(filename, info.generated_sources));
|
||||
gpu_shader_dependency_get_resolved_source(filename, info.generated_sources, info.name_));
|
||||
}
|
||||
|
||||
if (!info.vertex_source_.is_empty()) {
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(info.vertex_source_,
|
||||
info.generated_sources);
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(
|
||||
info.vertex_source_, info.generated_sources, info.name_);
|
||||
std::string interface = shader->vertex_interface_declare(info);
|
||||
|
||||
Vector<StringRefNull> sources;
|
||||
@@ -733,8 +733,8 @@ Shader *ShaderCompiler::compile(const shader::ShaderCreateInfo &info, bool is_ba
|
||||
}
|
||||
|
||||
if (!info.fragment_source_.is_empty()) {
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(info.fragment_source_,
|
||||
info.generated_sources);
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(
|
||||
info.fragment_source_, info.generated_sources, info.name_);
|
||||
std::string interface = shader->fragment_interface_declare(info);
|
||||
|
||||
Vector<StringRefNull> sources;
|
||||
@@ -760,8 +760,8 @@ Shader *ShaderCompiler::compile(const shader::ShaderCreateInfo &info, bool is_ba
|
||||
}
|
||||
|
||||
if (!info.geometry_source_.is_empty()) {
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(info.geometry_source_,
|
||||
info.generated_sources);
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(
|
||||
info.geometry_source_, info.generated_sources, info.name_);
|
||||
std::string layout = shader->geometry_layout_declare(info);
|
||||
std::string interface = shader->geometry_interface_declare(info);
|
||||
|
||||
@@ -786,8 +786,8 @@ Shader *ShaderCompiler::compile(const shader::ShaderCreateInfo &info, bool is_ba
|
||||
}
|
||||
|
||||
if (!info.compute_source_.is_empty()) {
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(info.compute_source_,
|
||||
info.generated_sources);
|
||||
Vector<StringRefNull> code = gpu_shader_dependency_get_resolved_source(
|
||||
info.compute_source_, info.generated_sources, info.name_);
|
||||
std::string layout = shader->compute_layout_declare(info);
|
||||
|
||||
Vector<StringRefNull> sources;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <fmt/format.h>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
@@ -345,18 +346,21 @@ struct GPUSource {
|
||||
const GPUSource &from) const
|
||||
{
|
||||
#define CLOG_FILE_INCLUDE(_from, _include) \
|
||||
if ((from).filename.c_str() != (_include).filename.c_str()) { \
|
||||
if (CLOG_CHECK(&LOG, CLG_LEVEL_INFO) && (from).filename.c_str() != (_include).filename.c_str()) \
|
||||
{ \
|
||||
const char *from_filename = (_from).filename.c_str(); \
|
||||
const char *include_filename = (_include).filename.c_str(); \
|
||||
const int from_size = int((_from).source.size()); \
|
||||
const int include_size = int((_include).source.size()); \
|
||||
CLOG_INFO(&LOG, "%s_%d --> %s_%d", from_filename, from_size, include_filename, include_size); \
|
||||
CLOG_INFO(&LOG, \
|
||||
"style %s_%d fill:#%x%x0", \
|
||||
include_filename, \
|
||||
include_size, \
|
||||
min_uu(15, include_size / 1000), \
|
||||
15 - min_uu(15, include_size / 1000)); \
|
||||
std::string link = fmt::format( \
|
||||
"{}_{} --> {}_{}\n", from_filename, from_size, include_filename, include_size); \
|
||||
std::string style = fmt::format("style {}_{} fill:#{:x}{:x}0\n", \
|
||||
include_filename, \
|
||||
include_size, \
|
||||
min_uu(15, include_size / 1000), \
|
||||
15 - min_uu(15, include_size / 1000)); \
|
||||
CLG_log_raw(LOG.type, link.c_str()); \
|
||||
CLG_log_raw(LOG.type, style.c_str()); \
|
||||
}
|
||||
|
||||
/* Check if this file was already included. */
|
||||
@@ -586,17 +590,23 @@ BuiltinBits gpu_shader_dependency_get_builtins(const StringRefNull shader_source
|
||||
}
|
||||
|
||||
Vector<StringRefNull> gpu_shader_dependency_get_resolved_source(
|
||||
const StringRefNull shader_source_name, const shader::GeneratedSourceList &generated_sources)
|
||||
const StringRefNull shader_source_name,
|
||||
const shader::GeneratedSourceList &generated_sources,
|
||||
const StringRefNull shader_name)
|
||||
{
|
||||
Vector<StringRefNull> result;
|
||||
GPUSource *src = g_sources->lookup_default(shader_source_name, nullptr);
|
||||
if (src == nullptr) {
|
||||
std::cerr << "Error source not found : " << shader_source_name << std::endl;
|
||||
}
|
||||
CLOG_INFO(&LOG, "Resolved Source Tree (Mermaid flowchart)");
|
||||
CLOG_INFO(&LOG, "flowchart LR");
|
||||
CLOG_INFO(&LOG, "Resolved Source Tree (Mermaid flowchart) %s", shader_name.c_str());
|
||||
if (CLOG_CHECK(&LOG, CLG_LEVEL_INFO)) {
|
||||
CLG_log_raw(LOG.type, "flowchart LR\n");
|
||||
}
|
||||
src->build(result, generated_sources, *g_sources);
|
||||
CLOG_INFO(&LOG, " ");
|
||||
if (CLOG_CHECK(&LOG, CLG_LEVEL_INFO)) {
|
||||
CLG_log_raw(LOG.type, "\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ struct PrintfFormat {
|
||||
const PrintfFormat &gpu_shader_dependency_get_printf_format(uint32_t format_hash);
|
||||
|
||||
Vector<StringRefNull> gpu_shader_dependency_get_resolved_source(
|
||||
StringRefNull source_name, const GeneratedSourceList &generated_sources);
|
||||
StringRefNull source_name,
|
||||
const GeneratedSourceList &generated_sources,
|
||||
StringRefNull shader_name = "");
|
||||
StringRefNull gpu_shader_dependency_get_source(StringRefNull source_name);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user