Skip to content

Commit 1f73d6a

Browse files
committed
Backport Wave pragma fix and remove workaround
Point Boost to the exact Wave one-line backport for emitted pragma newlines, remove the temporary local pragma workaround, and keep the remaining include-path fixes in Nabla. This leaves the Wave pragma issue fixed at the dependency level while preserving the Nabla-side fixes for Windows backslash includes and single-leading-slash virtual includes. Thanks to @Themperror for the additional pragma and include repros. Those made it straightforward to verify the dependency-level fix and drop the local workaround cleanly.
1 parent 4871e24 commit 1f73d6a

4 files changed

Lines changed: 33 additions & 10 deletions

File tree

3rdparty/boost/superproject

src/nbl/asset/utils/CWaveStringResolver.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ std::string preprocessImpl(
316316
std::function<void(nbl::wave::context&)> post)
317317
{
318318
nbl::wave::context context(code.begin(), code.end(), preprocessOptions.sourceIdentifier.data(), { preprocessOptions });
319-
context.set_caching(withCaching);
320-
context.add_macro_definition("__HLSL_VERSION");
321-
context.add_macro_definition("__SPIRV_MAJOR_VERSION__=" + std::to_string(IShaderCompiler::getSpirvMajor(preprocessOptions.targetSpirvVersion)));
322-
context.add_macro_definition("__SPIRV_MINOR_VERSION__=" + std::to_string(IShaderCompiler::getSpirvMinor(preprocessOptions.targetSpirvVersion)));
323319

324320
WaveRenderProgress renderProgress;
325321
const char* phase = "registering built-in macros";
@@ -335,6 +331,11 @@ std::string preprocessImpl(
335331
};
336332
try
337333
{
334+
context.set_caching(withCaching);
335+
context.add_macro_definition("__HLSL_VERSION");
336+
context.add_macro_definition("__SPIRV_MAJOR_VERSION__=" + std::to_string(IShaderCompiler::getSpirvMajor(preprocessOptions.targetSpirvVersion)));
337+
context.add_macro_definition("__SPIRV_MINOR_VERSION__=" + std::to_string(IShaderCompiler::getSpirvMinor(preprocessOptions.targetSpirvVersion)));
338+
338339
phase = "registering extra macro definitions";
339340
for (const auto& define : preprocessOptions.extraDefines)
340341
{

src/nbl/asset/utils/IShaderCompiler.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,25 @@ auto IShaderCompiler::CFileSystemIncludeLoader::getInclude(const system::path& s
627627
return { f->getFileName(),std::move(contents) };
628628
}
629629

630+
namespace
631+
{
632+
std::string normalizeIncludeLookupName(const std::string& includeName)
633+
{
634+
if (includeName.size() <= 1ull)
635+
return includeName;
636+
637+
const auto first = includeName.front();
638+
const auto second = includeName[1ull];
639+
const bool hasSingleLeadingSeparator =
640+
(first == '/' || first == '\\') &&
641+
second != '/' && second != '\\';
642+
if (!hasSingleLeadingSeparator)
643+
return includeName;
644+
645+
return includeName.substr(1ull);
646+
}
647+
}
648+
630649
IShaderCompiler::CIncludeFinder::CIncludeFinder(core::smart_refctd_ptr<system::ISystem>&& system)
631650
: m_defaultFileSystemLoader(core::make_smart_refctd_ptr<CFileSystemIncludeLoader>(std::move(system)))
632651
{
@@ -639,12 +658,13 @@ IShaderCompiler::CIncludeFinder::CIncludeFinder(core::smart_refctd_ptr<system::I
639658
// @param
640659
auto IShaderCompiler::CIncludeFinder::getIncludeStandard(const system::path& requestingSourceDir, const std::string& includeName) const -> IIncludeLoader::found_t
641660
{
661+
const auto lookupName = normalizeIncludeLookupName(includeName);
642662
IShaderCompiler::IIncludeLoader::found_t retVal;
643-
if (auto contents = tryIncludeGenerators(includeName))
663+
if (auto contents = tryIncludeGenerators(lookupName))
644664
retVal = std::move(contents);
645-
else if (auto contents = trySearchPaths(includeName))
665+
else if (auto contents = trySearchPaths(lookupName))
646666
retVal = std::move(contents);
647-
else retVal = m_defaultFileSystemLoader->getInclude(requestingSourceDir.string(), includeName);
667+
else retVal = m_defaultFileSystemLoader->getInclude(requestingSourceDir.string(), lookupName);
648668

649669

650670
core::blake3_hasher hasher;
@@ -658,10 +678,11 @@ auto IShaderCompiler::CIncludeFinder::getIncludeStandard(const system::path& req
658678
// @param includeName: the string within "" of the include preprocessing directive
659679
auto IShaderCompiler::CIncludeFinder::getIncludeRelative(const system::path& requestingSourceDir, const std::string& includeName) const -> IIncludeLoader::found_t
660680
{
681+
const auto lookupName = normalizeIncludeLookupName(includeName);
661682
IShaderCompiler::IIncludeLoader::found_t retVal;
662-
if (auto contents = m_defaultFileSystemLoader->getInclude(requestingSourceDir.string(), includeName))
683+
if (auto contents = m_defaultFileSystemLoader->getInclude(requestingSourceDir.string(), lookupName))
663684
retVal = std::move(contents);
664-
else retVal = std::move(trySearchPaths(includeName));
685+
else retVal = std::move(trySearchPaths(lookupName));
665686

666687
core::blake3_hasher hasher;
667688
hasher.update(reinterpret_cast<uint8_t*>(retVal.contents.data()), retVal.contents.size() * (sizeof(char) / sizeof(uint8_t)));

src/nbl/asset/utils/waveContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boost/wave.hpp>
99
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
1010
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
11+
#include <string_view>
1112
#include <unordered_set>
1213

1314
#include "nbl/asset/utils/IShaderCompiler.h"

0 commit comments

Comments
 (0)