Skip to content

Fix remaining preprocess bugs and backport Wave pragma fix#1025

Merged
AnastaZIuk merged 3 commits intomasterfrom
preprocessUpdates
Mar 19, 2026
Merged

Fix remaining preprocess bugs and backport Wave pragma fix#1025
AnastaZIuk merged 3 commits intomasterfrom
preprocessUpdates

Conversation

@AnastaZIuk
Copy link
Member

@AnastaZIuk AnastaZIuk commented Mar 19, 2026

Summary

This PR fixes the remaining preprocess issues without carrying a local #pragma workaround in Nabla.

  • backports the exact upstream Wave emitted-pragma newline fix through the official wave and boost submodule commits instead of keeping a local placeholder/restore path in Nabla
  • removes the temporary local pragma workaround so external pragmas stay untouched in the preprocessed output
  • fixes Windows-style include spellings such as #include "std\\numbers.hlsli" by keeping filesystem lookup on the raw include spelling instead of unescaping string-literal escapes before lookup
  • fixes single-leading-slash virtual includes such as #include "/systems/rendergraph/common/defines.slang"
  • keeps the richer Wave failure diagnostics and nsc -P --dump-preprocessed-on-failure flow for partial dumps on failure

Root cause

The #pragma / missing #endif issue was not introduced by the recent Nabla preprocess work. Our pinned Wave snapshot was still on the Boost 1.84 line at e02cda69e4d0. In pp_iterator_functor<ContextT>::on_pragma it emits external pragmas without appending the final newline token, so a minimal input such as

#if 1
#pragma something
#endif

turns into #pragma something#endif and Wave reports a missing #endif at end of file. Upstream fixed that in 543a0e9e1d0e, so this PR backports that exact one-line fix through the official wave commit effdd48f2775 and the official boost pointer update 79a5d9a5be2d instead of updating the whole Boost dependency stack.

Windows-style backslash includes were a separate Nabla bug introduced by 0c829039cc34 in waveContext.h, where include lookup started to run through util::impl::unescape_lit(file_path) before filesystem resolution. That is wrong for filesystem lookup, because spellings such as std\\numbers.hlsli are not meant to become control characters before the lookup happens.

Single-leading-slash virtual includes were another separate Nabla bug introduced by 5ac3b555522c in IShaderCompiler.cpp. A spelling such as /systems/rendergraph/common/defines.slang is treated by std::filesystem as rooted, which discards the configured search root instead of treating that slash as a virtual include root.

The partial-output gap was not an upstream Wave bug. It was a missing failure-path feature in nsc -P, so this PR keeps the richer diagnostics and threads the already-emitted preprocess text back to -Fc when --dump-preprocessed-on-failure is requested.

Validation

Local Debug validation in NSC source mode included:

  • cmake --preset user-configure-dynamic-msvc -DNBL_NSC_MODE=SOURCE
  • cmake --build build/dynamic --config Debug --target nsc
  • direct nsc -P smoke test for a minimal external #pragma inside a conditional block
  • direct nsc -P smoke test for an external #pragma followed by ordinary shader code
  • direct nsc -P smoke test for a vendor #pragma with a trailing comment
  • direct nsc -P --dump-preprocessed-on-failure smoke test for a real missing #endif case
  • direct nsc -P smoke test for a single-leading-slash virtual include with an explicit include search root
  • direct nsc -P smoke test for a Windows-style backslash include spelling with an explicit include search root

The three pragma repros now pass without any local Nabla workaround and keep #pragma on its own line in the preprocessed output. The real missing #endif case still fails as expected and still writes a partial dump when --dump-preprocessed-on-failure is enabled. The rooted-include and Windows-backslash include repros also pass.

Thanks

Thanks to @Themperror for the missing-partial-dump request and for the additional pragma and include repros. Those made it possible to confirm that the pragma issue was really the pinned Wave 1.84 bug and to verify the Nabla-side fixes cleanly.

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.
@AnastaZIuk AnastaZIuk changed the title Fix Wave include paths and partial preprocess dumps Fix remaining preprocess bugs and backport Wave pragma fix Mar 19, 2026
@AnastaZIuk AnastaZIuk merged commit e4df2b2 into master Mar 19, 2026
32 of 34 checks passed
@AnastaZIuk AnastaZIuk deleted the preprocessUpdates branch March 19, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant