Sfoglia il codice sorgente

Fix uniform stripping procedure for unexpected newlines in Metal shaderc. (#2223)

Martijn Courteaux 5 anni fa
parent
commit
1ca9f894d1
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      tools/shaderc/shaderc_metal.cpp

+ 9 - 0
tools/shaderc/shaderc_metal.cpp

@@ -730,6 +730,15 @@ namespace bgfx { namespace metal
 
 
 						if (!str.isEmpty() )
 						if (!str.isEmpty() )
 						{
 						{
+							// If the line declares a uniform, merge all next
+							// lines until we encounter a semicolon.
+							bx::StringView lineEnd = strFind(strLine, ";");
+							while (lineEnd.isEmpty() && !reader.isDone()) {
+								bx::StringView nextLine = reader.next();
+								strLine.set(strLine.getPtr(), nextLine.getTerm());
+								lineEnd = strFind(nextLine, ";");
+							}
+
 							bool found = false;
 							bool found = false;
 
 
 							for (uint32_t ii = 0; ii < BX_COUNTOF(s_samplerTypes); ++ii)
 							for (uint32_t ii = 0; ii < BX_COUNTOF(s_samplerTypes); ++ii)