From f38827802ab4393d652df19febd4c308ea812177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 16 Oct 2024 16:44:56 +0200 Subject: [PATCH] Fix: GPU: Broken shader printf support Was using wrong type of data offset and not removing the quote when outputing the strings. --- source/blender/gpu/glsl_preprocess/glsl_preprocess.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh index 3a7b0ee428c..fffa7fd9030 100644 --- a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh +++ b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh @@ -330,7 +330,7 @@ class Preprocessor { /* Example: `pri$$1(2@ b)$` > `{int c_ = print_header(1, 2); c_ = print_data(c_, b); }` */ { std::regex regex(R"(pri\$\$?(\d{1,2})\()"); - out_str = std::regex_replace(out_str, regex, "{int c_ = print_header($1, "); + out_str = std::regex_replace(out_str, regex, "{uint c_ = print_header($1u, "); } { std::regex regex(R"(\@)"); @@ -379,7 +379,8 @@ class Preprocessor { } std::stringstream suffix; for (const std::string &str_var : static_strings_) { - suffix << "// " << hash("string") << " " << hash_string(str_var) << " " << str_var << "\n"; + std::string no_quote = str_var.substr(1, str_var.size() - 2); + suffix << "// " << hash("string") << " " << hash_string(str_var) << " " << no_quote << "\n"; } return suffix.str(); }