diff --git a/source/blender/gpu/metal/mtl_shader.mm b/source/blender/gpu/metal/mtl_shader.mm index dc42ed9c0bd..d64bb7137ff 100644 --- a/source/blender/gpu/metal/mtl_shader.mm +++ b/source/blender/gpu/metal/mtl_shader.mm @@ -379,8 +379,7 @@ bool MTLShader::finalize(const shader::ShaderCreateInfo *info) NSNotFound) { const char *errors_c_str = [[error localizedDescription] UTF8String]; - const StringRefNull source = (is_compute) ? shd_builder_->glsl_compute_source_ : - shd_builder_->glsl_fragment_source_; + const StringRefNull source = [source_to_compile UTF8String]; MTLLogParser parser; print_log({source}, errors_c_str, to_string(src_stage), true, &parser); diff --git a/source/blender/gpu/metal/mtl_shader_log.mm b/source/blender/gpu/metal/mtl_shader_log.mm index 4fb32e3d0df..b89ec70830c 100644 --- a/source/blender/gpu/metal/mtl_shader_log.mm +++ b/source/blender/gpu/metal/mtl_shader_log.mm @@ -35,9 +35,6 @@ const char *MTLLogParser::parse_line(const char *source_combined, log_line = error_line_number_end; log_line = skip_separators(log_line, ": "); log_item.cursor.column = parse_number(log_line, &error_line_number_end); - /* For some reason the row and column is 0 based in C++ / Metal compiler. */ - log_item.cursor.row -= 1; - log_item.cursor.column -= 1; log_line = error_line_number_end; /* Simply copy the start of the error line since it is already in the format we want. */ log_item.cursor.file_name_and_error_line = StringRef(name_start, error_line_number_end); @@ -68,7 +65,13 @@ const char *MTLLogParser::parse_line(const char *source_combined, log_item.cursor.row++; } } - parsed_error_ = true; + /* The method above does not work with injected #line directives. + * Just output the raw error and forget about the formatting for now. */ + log_item.cursor.row = -1; + log_item.cursor.file_name_and_error_line = ""; + parsed_error_ = false; + wrapper_error_ = true; + return name_start; } } }