From 1ca9f894d1587e57f8366430e383785f8a1bb80c Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Mon, 17 Aug 2020 06:08:01 +0200 Subject: [PATCH] Fix uniform stripping procedure for unexpected newlines in Metal shaderc. (#2223) --- tools/shaderc/shaderc_metal.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/shaderc/shaderc_metal.cpp b/tools/shaderc/shaderc_metal.cpp index 30ac8e884..7540e70b5 100644 --- a/tools/shaderc/shaderc_metal.cpp +++ b/tools/shaderc/shaderc_metal.cpp @@ -730,6 +730,15 @@ namespace bgfx { namespace metal 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; for (uint32_t ii = 0; ii < BX_COUNTOF(s_samplerTypes); ++ii)