Shader compiler options to save preprocessed and spirv, optimizer upgrade#1051
Open
Shader compiler options to save preprocessed and spirv, optimizer upgrade#1051
Conversation
Member
|
@AnastaZIuk this is your territory, bring this to completion |
AnastaZIuk
requested changes
Apr 16, 2026
| auto newCode = preprocessShader(std::string(code), stage, hlslOptions.preprocessorOptions, dxc_compile_flags, dependencies); | ||
| if (newCode.empty()) return nullptr; | ||
|
|
||
| if (!options.preprocessedOutputPath.empty()) |
Member
There was a problem hiding this comment.
spvOutputPath is skipped on a cache hit
Nabla/src/nbl/asset/utils/IShaderCompiler.cpp
Lines 509 to 522 in ba922ed
please cover that
| SPreprocessorOptions preprocessorOptions = {}; | ||
| CCache* readCache = nullptr; | ||
| CCache* writeCache = nullptr; | ||
| bool optimizerIsExtraPasses = false; // Instead of disabling the default opt passes, run the provided optimization passes at the end |
Member
There was a problem hiding this comment.
optimizerIsExtraPasses needs to be covered in cache handle
| core::smart_refctd_ptr<system::IFile> preprocessedFile; | ||
|
|
||
| system::ISystem::future_t<core::smart_refctd_ptr<system::IFile>> future; | ||
| m_system->deleteFile(options.preprocessedOutputPath); |
Member
There was a problem hiding this comment.
this deletes the old dump too early, maybe use temp file plus rename
| if (spvFile) | ||
| { | ||
| system::IFile::success_t succ; | ||
| spvFile->write(succ, outSpirv->getPointer(), 0, outSpirv->getSize()); |
Member
There was a problem hiding this comment.
I think optimize() can return nullptr here, what about some small guard before writing the dump?
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.
Gives the shader compiler the option of outputting preprocessed and spirv files to a destination file, useful for debugging. Also when passing an optimizer give the option of replacing the default spirv-opt pass entirely (-O0 flag forwarded to DXC) OR to to run after the default optimization passes. Useful for stripping debug info without disabling optimization, for example.