diff options
author | Campbell Barton <campbell@blender.org> | 2022-05-10 04:16:23 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-05-10 04:16:23 +0300 |
commit | e7464dffbc65f0fad765d4f9905979e544700bfc (patch) | |
tree | cafc2a02b757beb39d553e0a5ee151eab6603926 | |
parent | b46825545325ed08324ff1fe16242898e2352228 (diff) | |
parent | a4c2060b91467987c930e4dd77a6673acd072ced (diff) |
Merge branch 'blender-v3.2-release'
-rw-r--r-- | source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_dependency.cc | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl index abecb373995..3c5acf62e30 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl @@ -164,7 +164,7 @@ float attr_load_float(samplerBuffer cd_buf) * \{ */ # ifndef OBINFO_LIB -# error "draw_object_infos is mandatory for volume objects" +# error draw_object_infos is mandatory for volume objects # endif vec3 g_orco; diff --git a/source/blender/gpu/intern/gpu_shader_dependency.cc b/source/blender/gpu/intern/gpu_shader_dependency.cc index eb2d40f5da9..aa2033b9154 100644 --- a/source/blender/gpu/intern/gpu_shader_dependency.cc +++ b/source/blender/gpu/intern/gpu_shader_dependency.cc @@ -8,6 +8,7 @@ * shader files. */ +#include <algorithm> #include <iomanip> #include <iostream> #include <sstream> @@ -98,6 +99,10 @@ struct GPUSource { /* Limit to shared header files to avoid the temptation to use C++ syntax in .glsl files. */ if (filename.endswith(".h") || filename.endswith(".hh")) { enum_preprocess(); + quote_preprocess(); + } + else { + check_no_quotes(); } if (is_from_material_library()) { @@ -174,6 +179,44 @@ struct GPUSource { } /** + * Some drivers completely forbid quote characters even in unused preprocessor directives. + * We fix the cases where we can't manually patch in `enum_preprocess()`. + * This check ensure none are present in non-patched sources. (see T97545) + */ + void check_no_quotes() + { +#ifdef DEBUG + int64_t pos = -1; + do { + pos = source.find('"', pos + 1); + if (pos == -1) { + break; + } + if (!is_in_comment(source, pos)) { + print_error(source, pos, "Quote characters are forbidden in GLSL files"); + } + } while (true); +#endif + } + + /** + * Some drivers completely forbid string characters even in unused preprocessor directives. + * This fixes the cases we cannot manually patch: Shared headers #includes. (see T97545) + * TODO(fclem): This could be done during the datatoc step. + */ + void quote_preprocess() + { + if (source.find_first_of('"') == -1) { + return; + } + + processed_source = source; + std::replace(processed_source.begin(), processed_source.end(), '"', ' '); + + source = processed_source.c_str(); + } + + /** * Transform C,C++ enum declaration into GLSL compatible defines and constants: * * \code{.cpp} @@ -282,6 +325,7 @@ struct GPUSource { if (last_pos != 0) { output += input.substr(last_pos); } + processed_source = output; source = processed_source.c_str(); }; |