[HLSL] Add the Frs DXC driver option#157690
Merged
Merged
Conversation
This pr adds the `Frs` as a DXC driver option. It is done by invoking `llvm-objcopy` with the `extract-section=RTS0` argument specified to output the separate `DXContainer`. This resolves: .
Member
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Finn Plummer (inbelic) ChangesThis pr adds the It is done by invoking This resolves: #150277. Full diff: https://github.com/llvm/llvm-project/pull/157690.diff 3 Files Affected:
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index ea5a94f840470..123caa9d35520 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -9418,6 +9418,8 @@ def dxc_Fo : DXCJoinedOrSeparate<"Fo">,
HelpText<"Output object file">;
def dxc_Fc : DXCJoinedOrSeparate<"Fc">,
HelpText<"Output assembly listing file">;
+def dxc_Frs : DXCJoinedOrSeparate<"Frs">,
+ HelpText<"Output additional root signature object file">;
def dxil_validator_version : Option<["/", "-"], "validator-version", KIND_SEPARATE>,
Group<dxc_Group>, Flags<[HelpHidden]>,
Visibility<[DXCOption, ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index 559af32dc3808..1bb7aa02188f9 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -313,7 +313,13 @@ void tools::hlsl::LLVMObjcopy::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Output.getFilename());
if (Args.hasArg(options::OPT_dxc_strip_rootsignature)) {
- const char *Frs = Args.MakeArgString("--remove-section=RTS0");
+ const char *StripRS = Args.MakeArgString("--remove-section=RTS0");
+ CmdArgs.push_back(StripRS);
+ }
+
+ if (Arg *Arg = Args.getLastArg(options::OPT_dxc_Frs)) {
+ const char *Frs =
+ Args.MakeArgString("--extract-section=RTS0=" + Twine(Arg->getValue()));
CmdArgs.push_back(Frs);
}
@@ -493,7 +499,8 @@ bool HLSLToolChain::requiresBinaryTranslation(DerivedArgList &Args) const {
bool HLSLToolChain::requiresObjcopy(DerivedArgList &Args) const {
return Args.hasArg(options::OPT_dxc_Fo) &&
- Args.hasArg(options::OPT_dxc_strip_rootsignature);
+ (Args.hasArg(options::OPT_dxc_strip_rootsignature) ||
+ Args.hasArg(options::OPT_dxc_Frs));
}
bool HLSLToolChain::isLastJob(DerivedArgList &Args,
diff --git a/clang/test/Driver/dxc_frs.hlsl b/clang/test/Driver/dxc_frs.hlsl
new file mode 100644
index 0000000000000..7f7034f6fef89
--- /dev/null
+++ b/clang/test/Driver/dxc_frs.hlsl
@@ -0,0 +1,10 @@
+// RUN: %clang_dxc -T cs_6_0 /Fo %t.dxo /Frs %t.rs.dxo -### %s 2>&1 | FileCheck %s
+
+// Test to demonstrate that extracting the root signature to the specified
+// output file with /Frs.
+
+// CHECK: "{{.*}}llvm-objcopy{{(.exe)?}}" "{{.*}}.obj" "{{.*}}.dxo" "--extract-section=RTS0={{.*}}.rs.dxo"
+
+[shader("compute"), RootSignature("")]
+[numthreads(1,1,1)]
+void EmptyEntry() {}
|
Icohedron
approved these changes
Sep 9, 2025
inbelic
commented
Sep 9, 2025
farzonl
approved these changes
Sep 9, 2025
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
inbelic
commented
Sep 9, 2025
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.
This pr adds
Frsas aDXCdriver option.It is done by invoking
llvm-objcopywith theextract-section=RTS0argument specified to output the separate
DXContainer.Option behaviour as a reference is found here.
This resolves: #150277.