Discussed off-list with op@ already; sharing here also for documentation
of the issue: Godot 3.5 introduced stricter checks on shader syntax [1]
which was classified as a breaking change. This was discussed [2]
upstream and they conceded that starting with a warning would have been
better, but didn't make any fixes. For us, as we use built rather than
bundled Godot binary, this means that games distributed with use of the
outlawed syntax don't work anymore... or rather they run, but they
don't process the shaders that throw a (non-breaking) error here. The
result for example with Haiki [3] is that the program runs, but
everything except for a few animations is white on white.

The diff below changes the errors to a WARN_PRINT_ONCE message for
godot,-main which is the 'export template' that is used to run the
games without the editor. The upstream behavior with more disruptive
shader errors is still preserved for the godot,-tools build that is for
the editor itself (which has TOOLS_ENABLED defined).

ok?

[1] https://github.com/godotengine/godot/pull/55623/files
[2] https://github.com/godotengine/godot/issues/59316
[3] https://store.steampowered.com/app/1395270/Haiki/

Index: Makefile
===================================================================
RCS file: /cvs/ports/games/godot/Makefile,v
retrieving revision 1.47
diff -u -p -r1.47 Makefile
--- Makefile    11 Aug 2023 12:36:10 -0000      1.47
+++ Makefile    13 Aug 2023 02:27:49 -0000
@@ -7,7 +7,7 @@ V =             3.5.2
 GODOTSTEAM_V = v3.20
 DISTNAME =     godot-${V}-stable
 PKGNAME =      godot-${V}
-REVISION =     3
+REVISION =     4
 
 CATEGORIES =   games
 
Index: patches/patch-servers_visual_shader_language_cpp
===================================================================
RCS file: patches/patch-servers_visual_shader_language_cpp
diff -N patches/patch-servers_visual_shader_language_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-servers_visual_shader_language_cpp    13 Aug 2023 02:27:50 
-0000
@@ -0,0 +1,95 @@
+disable strict shader syntax check errors for export template build and warn
+instead
+
+Index: servers/visual/shader_language.cpp
+--- servers/visual/shader_language.cpp.orig
++++ servers/visual/shader_language.cpp
+@@ -596,6 +596,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                                       }
+                                               }
+ 
++#ifdef TOOLS_ENABLED
+                                               if (error) {
+                                                       if (hexa_found) {
+                                                               return 
_make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant");
+@@ -608,6 +609,9 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                                       }
+                                                       return 
_make_token(TK_ERROR, "Invalid (integer) numeric constant");
+                                               }
++#else
++                                              WARN_PRINT_ONCE("Invalid shader 
numeric constant");
++#endif
+                                               str += symbol;
+                                               i++;
+                                       }
+@@ -622,24 +626,40 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                       } else if (period_found || 
exponent_found || float_suffix_found) {
+                                               //floats
+                                               if (exponent_found && 
(!_is_number(last_char) && last_char != 'f')) { // checks for eg: "2E", "2E-", 
"2E+"
++#ifdef TOOLS_ENABLED
+                                                       return 
_make_token(TK_ERROR, "Invalid (float) numeric constant");
++#else
++                                                      
WARN_PRINT_ONCE("Invalid shader numeric constant");
++#endif
+                                               }
+                                               if (period_found) {
+                                                       if (float_suffix_found) 
{
+                                                               //checks for eg 
"1.f" or "1.99f" notations
+                                                               if (last_char 
!= 'f') {
++#ifdef TOOLS_ENABLED
+                                                                       return 
_make_token(TK_ERROR, "Invalid (float) numeric constant");
++#else
++                                                                      
WARN_PRINT_ONCE("Invalid shader numeric constant");
++#endif
+                                                               }
+                                                       } else {
+                                                               //checks for 
eg. "1." or "1.99" notations
+                                                               if (last_char 
!= '.' && !_is_number(last_char)) {
++#ifdef TOOLS_ENABLED
+                                                                       return 
_make_token(TK_ERROR, "Invalid (float) numeric constant");
++#else
++                                                                      
WARN_PRINT_ONCE("Invalid shader numeric constant");
++#endif
+                                                               }
+                                                       }
+                                               } else if (float_suffix_found) {
+                                                       // if no period found 
the float suffix must be the last character, like in "2f" for "2.0"
+                                                       if (last_char != 'f') {
++#ifdef TOOLS_ENABLED
+                                                               return 
_make_token(TK_ERROR, "Invalid (float) numeric constant");
++#else
++                                                                      
WARN_PRINT_ONCE("Invalid shader numeric constant");
++#endif
+                                                       }
+                                               }
+ 
+@@ -651,7 +671,11 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                               }
+ 
+                                               if (!str.is_valid_float()) {
++#ifdef TOOLS_ENABLED
+                                                       return 
_make_token(TK_ERROR, "Invalid (float) numeric constant");
++#else
++                                                      
WARN_PRINT_ONCE("Invalid shader numeric constant");
++#endif
+                                               }
+                                       } else {
+                                               //integers
+@@ -661,6 +685,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                                       // Compensate reading 
cursor position.
+                                                       char_idx += 1;
+                                               }
++#ifdef TOOLS_ENABLED
+                                               if (!str.is_valid_integer()) {
+                                                       if (uint_suffix_found) {
+                                                               return 
_make_token(TK_ERROR, "Invalid (unsigned integer) numeric constant");
+@@ -668,6 +693,9 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
+                                                               return 
_make_token(TK_ERROR, "Invalid (integer) numeric constant");
+                                                       }
+                                               }
++#else
++                                              WARN_PRINT_ONCE("Invalid shader 
numeric constant");
++#endif
+                                       }
+ 
+                                       char_idx += str.length();

Reply via email to