Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-06-28 13:20:59 +0300
committerJeroen Bakker <jeroen@blender.org>2021-06-28 13:23:10 +0300
commit1b942ef90c9b4b7fe98af50357aa76b74754f7ff (patch)
tree498267617e896181ce67d6c68b219289b76eec6f /source/blender/gpu/intern/gpu_shader_private.hh
parentdbd4ff4163617baa3d93dca257be3b2610c28782 (diff)
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.
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_private.hh')
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.hh39
1 files changed, 38 insertions, 1 deletions
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<const char *> sources, char *log, const char *stage, const bool error);
+ void print_log(Span<const char *> 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<const Shader *>(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