-
Notifications
You must be signed in to change notification settings - Fork 15k
[HLSL] Add the Frs
DXC
driver option
#157690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: .
@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() {}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
This pr adds
Frs
as aDXC
driver option.It is done by invoking
llvm-objcopy
with theextract-section=RTS0
argument specified to output the separate
DXContainer
.Option behaviour as a reference is found here.
This resolves: #150277.