Blender V4.3
gl_shader_log.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "gl_shader.hh"
10
11#include "GPU_platform.hh"
12
13namespace blender::gpu {
14
15const char *GLLogParser::parse_line(const char * /*source_combined*/,
16 const char *log_line,
17 GPULogItem &log_item)
18{
19 /* Skip ERROR: or WARNING:. */
20 log_line = skip_severity_prefix(log_line, log_item);
21 log_line = skip_separators(log_line, "(: ");
22
23 /* Parse error line & char numbers. */
24 if (at_number(log_line)) {
25 const char *error_line_number_end;
26 log_item.cursor.row = parse_number(log_line, &error_line_number_end);
27 /* Try to fetch the error character (not always available). */
28 if (at_any(error_line_number_end, "(:") && at_number(&error_line_number_end[1])) {
29 log_item.cursor.column = parse_number(error_line_number_end + 1, &log_line);
30 }
31 else {
32 log_line = error_line_number_end;
33 }
34 /* There can be a 3rd number (case of mesa driver). */
35 if (at_any(log_line, "(:") && at_number(&log_line[1])) {
36 log_item.cursor.source = log_item.cursor.row;
37 log_item.cursor.row = log_item.cursor.column;
38 log_item.cursor.column = parse_number(log_line + 1, &error_line_number_end);
39 log_line = error_line_number_end;
40 }
41 }
42
43 if ((log_item.cursor.row != -1) && (log_item.cursor.column != -1)) {
45 /* 0:line */
46 log_item.cursor.row = log_item.cursor.column;
47 log_item.cursor.column = -1;
48 }
50 /* WORKAROUND(@fclem): Both Mesa and AMDGPU-PRO are reported as official. */
51 StringRefNull(GPU_platform_version()).find(" Mesa ") == -1)
52 {
53 /* source:row */
54 log_item.cursor.source = log_item.cursor.row;
55 log_item.cursor.row = log_item.cursor.column;
56 log_item.cursor.column = -1;
57 log_item.source_base_row = true;
58 }
59 else {
60 /* line:char */
61 }
62 }
63
64 log_line = skip_separators(log_line, ":) ");
65
66 /* Skip to message. Avoid redundant info. */
67 log_line = skip_severity_keyword(log_line, log_item);
68 log_line = skip_separators(log_line, ":) ");
69
70 return log_line;
71}
72
73const char *GLLogParser::skip_severity_prefix(const char *log_line, GPULogItem &log_item)
74{
75 return skip_severity(log_line, log_item, "ERROR", "WARNING", "NOTE");
76}
77
78const char *GLLogParser::skip_severity_keyword(const char *log_line, GPULogItem &log_item)
79{
80 return skip_severity(log_line, log_item, "error", "warning", "note");
81}
82
83} // namespace blender::gpu
@ GPU_DRIVER_OFFICIAL
@ GPU_OS_UNIX
@ GPU_OS_ANY
@ GPU_DEVICE_ATI
@ GPU_DEVICE_NVIDIA
const char * GPU_platform_version()
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver)
const char * parse_line(const char *source_combined, const char *log_line, GPULogItem &log_item) override
const char * skip_severity_prefix(const char *log_line, GPULogItem &log_item)
const char * skip_severity_keyword(const char *log_line, GPULogItem &log_item)
int parse_number(const char *log_line, const char **r_new_position) const
const char * skip_separators(const char *log_line, const StringRef separators) const
bool at_number(const char *log_line) const
bool at_any(const char *log_line, const StringRef chars) const
const char * skip_severity(const char *log_line, GPULogItem &log_item, const char *error_msg, const char *warning_msg, const char *note_msg) const