Skip to content

Commit ec96787

Browse files
committed
[Driver][DXC] add rootsig-define as an alias option
1 parent 8d47830 commit ec96787

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9443,6 +9443,11 @@ def fdx_rootsignature_define :
94439443
MarshallingInfoString<LangOpts<"HLSLRootSigOverride">, "\"\"">,
94449444
HelpText<"Override entry function root signature with root signature at "
94459445
"given macro name.">;
9446+
def dxc_rootsig_define :
9447+
Separate<["-"], "rootsig-define">,
9448+
Alias<fdx_rootsignature_define>,
9449+
Group<dxc_Group>,
9450+
Visibility<[DXCOption]>;
94469451
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
94479452
Group<dxc_Group>,
94489453
Visibility<[ClangOption, CC1Option]>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,6 +3801,7 @@ static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
38013801
options::OPT_disable_llvm_passes,
38023802
options::OPT_fnative_half_type,
38033803
options::OPT_hlsl_entrypoint,
3804+
options::OPT_fdx_rootsignature_define,
38043805
options::OPT_fdx_rootsignature_version};
38053806
if (!types::isHLSL(InputType))
38063807
return;

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
304304
A->claim();
305305
continue;
306306
}
307+
if (A->getOption().getID() == options::OPT_dxc_rootsig_define) {
308+
DAL->AddJoinedArg(nullptr,
309+
Opts.getOption(options::OPT_fdx_rootsignature_define),
310+
A->getValue());
311+
A->claim();
312+
continue;
313+
}
307314
if (A->getOption().getID() == options::OPT__SLASH_O) {
308315
StringRef OStr = A->getValue();
309316
if (OStr == "d") {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_dxc -T cs_6_0 -fcgl %s | FileCheck %s --check-prefixes=CHECK,REG
2+
// RUN: %clang_dxc -T cs_6_0 -fcgl -rootsig-define EmptyRS %s | FileCheck %s --check-prefixes=CHECK,EMPTY
3+
// RUN: %clang_dxc -T cs_6_0 -fcgl -rootsig-define CmdRS -D CmdRS='"SRV(t0)"' %s | FileCheck %s --check-prefixes=CHECK,CMD
4+
5+
#define EmptyRS ""
6+
#define NotEmptyRS "CBV(b0)"
7+
8+
// CHECK: !dx.rootsignatures = !{![[#ENTRY:]]}
9+
// CHECK: ![[#ENTRY]] = !{ptr @main, ![[#RS:]], i32 2}
10+
11+
// REG: ![[#RS]] = !{![[#CBV:]]}
12+
// REG: ![[#CBV]] = !{!"RootCBV"
13+
14+
// EMPTY: ![[#RS]] = !{}
15+
16+
// CMD: ![[#RS]] = !{![[#SRV:]]}
17+
// CMD: ![[#SRV]] = !{!"RootSRV"
18+
19+
[shader("compute"), RootSignature(NotEmptyRS)]
20+
[numthreads(1,1,1)]
21+
void main() {}

0 commit comments

Comments
 (0)