From 1b942ef90c9b4b7fe98af50357aa76b74754f7ff Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 28 Jun 2021 12:20:59 +0200 Subject: GPU: Refactored +cleanup compilation log parsing. Old implementation has a single parser of many different formats. With the introduction of Vulkan this would lead to another parser in the same function. This patch separates the log parsing using a visitor pattern so the log parsing can be configured per GPU backend or even per driver. With Vulkan we manage the compiler our self so the parsing will become more straight forward. The OpenGL part depends on many factors (OS, Driver) and perhaps even GPU. --- source/blender/gpu/intern/gpu_shader_private.hh | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'source/blender/gpu/intern/gpu_shader_private.hh') diff --git a/source/blender/gpu/intern/gpu_shader_private.hh b/source/blender/gpu/intern/gpu_shader_private.hh index 281f01dbc22..ebdfc3478f8 100644 --- a/source/blender/gpu/intern/gpu_shader_private.hh +++ b/source/blender/gpu/intern/gpu_shader_private.hh @@ -29,6 +29,8 @@ namespace blender { namespace gpu { +class GPULogParser; + /** * Implementation of shader compilation and uniforms handling. * Base class which is then specialized for each implementation (GL, VK, ...). @@ -74,7 +76,11 @@ class Shader { }; protected: - void print_log(Span sources, char *log, const char *stage, const bool error); + void print_log(Span sources, + char *log, + const char *stage, + const bool error, + GPULogParser *parser); }; /* Syntactic sugar. */ @@ -91,6 +97,37 @@ static inline const Shader *unwrap(const GPUShader *vert) return reinterpret_cast(vert); } +enum class Severity { + Unknown, + Warning, + Error, +}; + +struct LogCursor { + int source = -1; + int row = -1; + int column = -1; +}; + +struct GPULogItem { + LogCursor cursor; + Severity severity = Severity::Unknown; +}; + +class GPULogParser { + public: + virtual char *parse_line(char *log_line, GPULogItem &log_item) = 0; + + protected: + char *skip_severity(char *log_line, + GPULogItem &log_item, + const char *error_msg, + const char *warning_msg) const; + char *skip_separators(char *log_line, char sep1, char sep2, char sep3) const; + + MEM_CXX_CLASS_ALLOC_FUNCS("GPULogParser"); +}; + } // namespace gpu } // namespace blender -- cgit v1.2.3