mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Merge pull request #107547 from beicause/shader-compiler-print-content-verbose
ShaderCompiler: Optimize compilation error printing
This commit is contained in:
commit
daa1fc97dd
1 changed files with 13 additions and 7 deletions
|
@ -1520,6 +1520,17 @@ Error ShaderCompiler::compile(RS::ShaderMode p_mode, const String &p_code, Ident
|
|||
|
||||
// Print the files.
|
||||
for (const KeyValue<String, Vector<String>> &E : includes) {
|
||||
int err_line = -1;
|
||||
for (const ShaderLanguage::FilePosition &include_position : include_positions) {
|
||||
if (include_position.file == E.key) {
|
||||
err_line = include_position.line;
|
||||
}
|
||||
}
|
||||
if (err_line < 0) {
|
||||
// Skip files that don't contain errors.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (E.key.is_empty()) {
|
||||
if (p_path == "") {
|
||||
print_line("--Main Shader--");
|
||||
|
@ -1529,19 +1540,14 @@ Error ShaderCompiler::compile(RS::ShaderMode p_mode, const String &p_code, Ident
|
|||
} else {
|
||||
print_line("--" + E.key + "--");
|
||||
}
|
||||
int err_line = -1;
|
||||
for (int i = 0; i < include_positions.size(); i++) {
|
||||
if (include_positions[i].file == E.key) {
|
||||
err_line = include_positions[i].line;
|
||||
}
|
||||
}
|
||||
const Vector<String> &V = E.value;
|
||||
for (int i = 0; i < V.size(); i++) {
|
||||
if (i == err_line - 1) {
|
||||
// Mark the error line to be visible without having to look at
|
||||
// the trace at the end.
|
||||
print_line(vformat("E%4d-> %s", i + 1, V[i]));
|
||||
} else {
|
||||
} else if ((i == err_line - 3) || (i == err_line - 2) || (i == err_line) || (i == err_line + 1)) {
|
||||
// Print 4 lines around the error line.
|
||||
print_line(vformat("%5d | %s", i + 1, V[i]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue