Clean up Wave preprocessor handling#1022
Merged
AnastaZIuk merged 6 commits intoDevsh-Graphics-Programming:masterfrom Mar 18, 2026
Merged
Clean up Wave preprocessor handling#1022AnastaZIuk merged 6 commits intoDevsh-Graphics-Programming:masterfrom
AnastaZIuk merged 6 commits intoDevsh-Graphics-Programming:masterfrom
Conversation
Normalize root and include source buffers before lexing so EOF comments without a trailing newline no longer trip Wave. Thanks-to: @Themperror for the repros
Fork pull_request runs should stay unprivileged even when Examples statuses are required. The workflow now records the Examples result in the Windows build job and lets a tiny downstream Actions job publish the required check name automatically. Why: The old checks.create/update path cannot safely publish required Examples statuses for fork pull_request runs. Why: The reporter job fails closed when build-windows never reaches or never succeeds at the Examples step so required checks do not get stuck as Expected.
The downstream Examples job is now the first place reviewers look when branch protection blocks a PR. It should surface the original build and install output there as well instead of only exposing a pass or fail bit. Why: The required Examples check should stay self-contained even when it only consumes a status artifact. Why: Reprinting the captured logs keeps fork pull_request failures readable without any extra GitHub API calls or privileged workflow context.
3650da9
into
Devsh-Graphics-Programming:master
20 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR cleans up several Wave preprocessing problems in NSC and the required Examples reporting path in CI.
#pragmafdea055895support_option_prefer_pp_numbersinwaveContext.hinstead of manually gluing0+b...spellings back together#pragmaworkaround with a narrow compatibility normalization for legacy#pragma shader_stage(...)inCHLSLCompiler.cpp#pragma wave dxc_compile_flags(...)parsing so tabs and other whitespace tokens work and the directive is no longer double-counted inwaveContext.hCHLSLCompiler.cppandwaveContext.hExamples (...)statuses through a tiny downstream Actions job inbuild-nabla.ymlinstead of manual Checks API callsbuildandinstalllogs and replays them from that reporter job on failure so the required check is also the readable diagnosis pointAgainst the current
mastercompare this PR changesbuild-nabla.yml,CHLSLCompiler.cpp, andwaveContext.h.CWaveStringResolver.cppappears below only as historical context for the bug chronology.Root cause
1. Binary literals were already wrong before the recent renderer update
microfacet_to_light_transform.hlsluse binary literals like0b01.c00e5e1b38by Cyprian Skrzypczak, where Wave output started being rebuilt with raw token spelling dumps inCHLSLCompiler.cpp.3718dfc596later moved the same raw token-dump idea intoCWaveStringResolver.cpp. That commit relocated already-bad logic. It did not originate the bug.fdea055895replaced the raw token dump with a whitespace-aware renderer based on Wave's separator detection. That fixed real output issues but also made the older binary-literal problem visible by emitting0 b01instead of accidentally gluing it back to0b01.0b01as a pp-number in the first place viasupport_option_prefer_pp_numbers.2. The old
#pragmaworkaround was a broad root-file-only hack#746was previously papered over ind58cf3a01fby mutating the root source string and inserting an extra newline after every#pragma.shader_stagepragma handling already existed in the Wave hook long before that, starting from the original integration by devsh in0c829039cc3,ff093eee009, andac21de599dc.#pragma shader_stage(...)before Wave sees the line.#pragma shader_stage(...)into the already-supported#pragma wave shader_stage(...).3.
dxc_compile_flagshad two older parser assumptionshash_token_occurencesbased "must be the first directive" bookkeeping came from Cyprian-era Wave hook changes in7ef1c2fda27,cc8c793b655, and841ff913d01." "token separator in changes from07862397ee5andae4386064cf.found_directiveonlydxc_compile_flagsargument splitting now uses Wave whitespace token categories instead of comparing token text to exactly" "4. EOF handling was already incomplete in the original custom Wave integration
12afd3d42dby Cyprian Skrzypczak. That commit introduced the custom Wave integration directly insideCHLSLCompiler.cpp.wave_context_t context(code.begin(), code.end(), ...)and loaded include content was copied asiter_ctx.instring = res_str;, both without terminal newline normalization.0c829039cc3,ff9ec3a43d5, anddaea09e7cbcby devsh later split and simplified that same model intowaveContext.h. Those commits moved the path. They did not create the missing-normalization bug.support_cpp20, and that already includessupport_option_no_newline_at_end_of_file, seelanguage_support.hpp.cpp.recan trip over EOF before the iterator-level recovery incpp_iterator.hppgets a chance to help.CWaveStringResolver.cpp.Validation
Local validation on this branch included:
cmake --build build/dynamic --target nsc --config Debug -- /mcmake --build build/dynamic --target nsc --config Release -- /mnsccompile-to-SPIR-V checks for the EOF include-comment casecmake --build build/dynamic/examples_tests/22_CppCompat --target 22_cppcompat --config Debug -- /mcmake --build build/dynamic/examples_tests/30_ComputeShaderPathTracer --target 30_computeshaderpathtracer --config Debug -- /mcmake --build build/dynamic/examples_tests/31_HLSLPathTracer --target 31_hlslpathtracer --config Debug -- /mcmake --build build/dynamic/examples_tests/66_HLSLBxDFTests --target 66_hlslbxdftests --config Debug -- /mThe local Wave regression matrix now covers:
//comment/* ... *///comment//comment#pragma shader_stage(...)#pragma wave dxc_compile_flags(...)with tab-separated argumentsThanks
Thanks to @Themperror for surfacing the include, pragma, lexing, and EOF failure cases. Those reports made it much easier to separate the old latent bugs from the recent renderer changes.