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