33#define DEBUG_CONTEXT_LINES 0
38#define DEBUG_DEPENDENCIES 0
46 const char line_prefix[] =
" | ";
47 char err_col[] =
"\033[31;1m";
48 char warn_col[] =
"\033[33;1m";
49 char info_col[] =
"\033[0;2m";
50 char reset_col[] =
"\033[0;0m";
55 err_col[0] = warn_col[0] = info_col[0] = reset_col[0] =
'\0';
62 dynstr,
"%s%sIncluded files (in order):%s\n", info_col, line_prefix, reset_col);
67 int64_t cursor = 0, line_count = 0;
68 while ((cursor = src.find(
'\n', cursor) + 1)) {
71 if (sources_end_line.
is_empty() ==
false) {
72 line_count += sources_end_line.
last();
74 sources_end_line.
append(line_count);
79 dynstr,
"%s%s %s%s\n", info_col, line_prefix, filename.
c_str(), reset_col);
84 sources_end_line.
append(0);
87 const char *log_line =
log, *line_end;
91 bool found_line_id =
false;
92 while ((line_end = strchr(log_line,
'\n'))) {
94 if (line_end == log_line) {
101 if (logref.
endswith(
" shader failed to compile with the following errors:") ||
102 logref.
endswith(
" No code generated"))
104 log_line += size_t(line_end) - size_t(log_line);
109 log_line = parser->
parse_line(sources_combined, log_line, log_item);
112 if ((log_item.
cursor.
row == -1) &&
ELEM(log_line[0],
'\n',
'\0')) {
126 found_line_id =
false;
132 const char *src_line = sources_combined;
147 const char *src_line_end;
148 found_line_id =
false;
150 int src_line_index = 1;
151 while ((src_line_end = strchr(src_line,
'\n'))) {
152 if (src_line_index >= log_item.
cursor.
row) {
153 found_line_id =
true;
161 src_line = src_line_end + 1;
184 src_line = src_line_end + 1;
186 while ((src_line_end = strchr(src_line,
'\n'))) {
193 src_line = src_line_end + 1;
203 if (source_index <= 0) {
205 if (log_item.
cursor.
row <= sources_end_line[i]) {
211 if (source_index > 0) {
212 row_in_file -= sources_end_line[source_index - 1];
220 else if (source_index > 0) {
222 sources[source_index]);
248 log_line = line_end + 1;
249 previous_location = log_item.
cursor;
271 const char *error_msg,
272 const char *warning_msg,
273 const char *note_msg)
const
275 if (
STREQLEN(log_line, error_msg, strlen(error_msg))) {
276 log_line += strlen(error_msg);
279 else if (
STREQLEN(log_line, warning_msg, strlen(warning_msg))) {
280 log_line += strlen(warning_msg);
283 else if (
STREQLEN(log_line, note_msg, strlen(note_msg))) {
284 log_line += strlen(note_msg);
292 while (
at_any(log_line, separators)) {
300 const char *cursor = log_line;
301 while (!
ELEM(cursor[0],
'\n',
'\0')) {
302 if (cursor[0] == stop_char) {
312 return log_line[0] >=
'0' && log_line[0] <=
'9';
322 return int(strtol(log_line,
const_cast<char **
>(r_new_position), 10));
333 if (ctx ==
nullptr) {
346 if (ctx ==
nullptr) {
363 printf(
"Printf buffer overflow.\n");
369 while (cursor < data_len + 1) {
370 uint32_t format_hash = data[cursor++];
376 switch (block.type) {
378 printf(
"%s", block.fmt.c_str());
381 printf(block.fmt.c_str(), *
reinterpret_cast<uint32_t *
>(&data[cursor++]));
384 printf(block.fmt.c_str(), *
reinterpret_cast<int32_t *
>(&data[cursor++]));
387 printf(block.fmt.c_str(), *
reinterpret_cast<float *
>(&data[cursor++]));
#define BLI_assert_unreachable()
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
char * BLI_string_join_arrayN(const char *strings[], uint strings_num) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define STREQLEN(a, b, n)
void CLG_log_str(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message) _CLOG_ATTR_NONNULL(1
int CLG_color_support_get(CLG_LogRef *clg_ref)
void GPU_storagebuf_clear_to_zero(GPUStorageBuf *ssbo)
void GPU_storagebuf_free(GPUStorageBuf *ssbo)
void GPU_storagebuf_read(GPUStorageBuf *ssbo, void *data)
#define GPU_storagebuf_create(size)
Read Guarded memory(de)allocation.
constexpr const T * data() const
constexpr int64_t size() const
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
constexpr bool is_empty() const
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr bool endswith(StringRef suffix) const
constexpr const char * c_str() const
void append(const T &value)
const T & last(const int64_t n=0) const
IndexRange index_range() const
GPUStorageBuf * printf_buf
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
virtual const char * parse_line(const char *source_combined, const char *log_line, GPULogItem &log_item)=0
const char * skip_until(const char *log_line, char stop_char) 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
void print_log(Span< const char * > sources, const char *log, const char *stage, bool error, GPULogParser *parser)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define GPU_SHADER_PRINTF_MAX_CAPACITY
#define DEBUG_CONTEXT_LINES
#define DEBUG_LOG_SHADER_SRC_ON_ERROR
void MEM_freeN(void *vmemh)
ccl_device_inline float3 log(float3 v)
static void error(const char *str)
StringRefNull gpu_shader_dependency_get_filename_from_source_string(const StringRefNull source_string)
Find the name of the file from which the given string was generated.
const PrintfFormat & gpu_shader_dependency_get_printf_format(uint32_t format_hash)
bool gpu_shader_dependency_has_printf()
void printf_begin(Context *ctx)
void printf_end(Context *ctx)
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
StringRef file_name_and_error_line