Przeglądaj źródła

Merge pull request #50536 from Calinou/improve-shader-error-output-3.x

Improve the shader error console output
Rémi Verschelde 4 lat temu
rodzic
commit
087f23fd15

+ 7 - 1
drivers/gles2/shader_compiler_gles2.cpp

@@ -987,7 +987,13 @@ Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code,
 	if (err != OK) {
 		Vector<String> shader = p_code.split("\n");
 		for (int i = 0; i < shader.size(); i++) {
-			print_line(itos(i + 1) + " " + shader[i]);
+			if (i + 1 == parser.get_error_line()) {
+				// 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, shader[i]));
+			} else {
+				print_line(vformat("%5d | %s", i + 1, shader[i]));
+			}
 		}
 
 		_err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);

+ 1 - 1
drivers/gles2/shader_gles2.cpp

@@ -119,7 +119,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
 	Vector<String> lines = String(total_code).split("\n");
 
 	for (int j = 0; j < lines.size(); j++) {
-		print_line(itos(line) + ": " + lines[j]);
+		print_line(vformat("%4d | %s", line, lines[j]));
 		line++;
 	}
 

+ 7 - 1
drivers/gles3/shader_compiler_gles3.cpp

@@ -1031,7 +1031,13 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String &p_code,
 	if (err != OK) {
 		Vector<String> shader = p_code.split("\n");
 		for (int i = 0; i < shader.size(); i++) {
-			print_line(itos(i + 1) + " " + shader[i]);
+			if (i + 1 == parser.get_error_line()) {
+				// 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, shader[i]));
+			} else {
+				print_line(vformat("%5d | %s", i + 1, shader[i]));
+			}
 		}
 
 		_err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);

+ 1 - 1
drivers/gles3/shader_gles3.cpp

@@ -149,7 +149,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
 	Vector<String> lines = String(total_code).split("\n");
 
 	for (int j = 0; j < lines.size(); j++) {
-		print_line(itos(line) + ": " + lines[j]);
+		print_line(vformat("%4d | %s", line, lines[j]));
 		line++;
 	}