Support #pragma once and multiple inclusions of the same file in HLSL editing#3769
Merged
baldurk merged 1 commit intobaldurk:v1.xfrom Jan 22, 2026
Merged
Conversation
5b98e15 to
6ea112c
Compare
baldurk
requested changes
Jan 22, 2026
6ea112c to
ddfd68b
Compare
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.
Description
Updated the shader compilation logic during editing to correctly handle #pragma once directives and avoid re-inclusion errors when the same header is included multiple times.
The original implementation simply replaced #include with the file content and used only a local exclude list to prevent circular references. This led to a situation where if a file (especially one using #pragma once) was included multiple times (for example, A includes B and C, and both B and C include D), the expanded single large file would contain multiple copies of D's content, resulting in a redefinition error. Furthermore, the retained #pragma once in the expanded file would also trigger warnings from dxc.
This is my capture file(https://drive.google.com/file/d/12XYiIW-N2RjH6wmydqmQOzi5bpLIEkQc/view). After opening it, you can search for "ScreenSpaceProbeTemporalFilterCS" pass. It uses include and pragma once. Compiling it directly will result in the errors shown in the screenshot. Basically, all passes use include and pragma once, so most passes will fail to compile.
Compile Error log
My modifications include:
These changes enable RenderDoc to behave more closely to the actual compiler when manually expanding HLSL files, addressing issues such as redefinition errors and #pragma once warnings.