-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[HLSL][DirectX] Add the Qdx-rootsignature-strip driver option #154454
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0f11eb0
add BinaryModifyJobClass
inbelic acfd4d5
[HLSL] Add the `Qstrip-rootsignature` DXC driver option
inbelic f3f3a07
review: use terminology directed for objcopy
inbelic f8ff016
review: add assert
inbelic 154c2b0
review: apply objcopy before validation
inbelic a0ff7f7
review: improve comments
inbelic 2b6f936
re-review: make this llvmobcopy hlsl specific
inbelic ba36461
review: remove unused marshalling
inbelic 7dd6205
review: clarify `isLastJob` check
inbelic 514063b
self-review: little clean-up
inbelic 2945de4
review: correct job order and add test that validation occurs after
inbelic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,32 @@ void tools::hlsl::MetalConverter::ConstructJob( | |
Exec, CmdArgs, Inputs, Input)); | ||
} | ||
|
||
void tools::hlsl::LLVMObjcopy::ConstructJob(Compilation &C, const JobAction &JA, | ||
const InputInfo &Output, | ||
const InputInfoList &Inputs, | ||
const ArgList &Args, | ||
const char *LinkingOutput) const { | ||
|
||
std::string ObjcopyPath = getToolChain().GetProgramPath("llvm-objcopy"); | ||
inbelic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const char *Exec = Args.MakeArgString(ObjcopyPath); | ||
|
||
ArgStringList CmdArgs; | ||
assert(Inputs.size() == 1 && "Unable to handle multiple inputs."); | ||
const InputInfo &Input = Inputs[0]; | ||
CmdArgs.push_back(Input.getFilename()); | ||
CmdArgs.push_back(Output.getFilename()); | ||
|
||
if (Args.hasArg(options::OPT_dxc_strip_rootsignature)) { | ||
const char *Frs = Args.MakeArgString("--remove-section=RTS0"); | ||
CmdArgs.push_back(Frs); | ||
} | ||
|
||
inbelic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
assert(CmdArgs.size() > 2 && "Unnecessary invocation of objcopy."); | ||
|
||
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(), | ||
Exec, CmdArgs, Inputs, Input)); | ||
} | ||
|
||
/// DirectX Toolchain | ||
HLSLToolChain::HLSLToolChain(const Driver &D, const llvm::Triple &Triple, | ||
const ArgList &Args) | ||
|
@@ -315,6 +341,10 @@ Tool *clang::driver::toolchains::HLSLToolChain::getTool( | |
if (!MetalConverter) | ||
MetalConverter.reset(new tools::hlsl::MetalConverter(*this)); | ||
return MetalConverter.get(); | ||
case Action::ObjcopyJobClass: | ||
if (!LLVMObjcopy) | ||
LLVMObjcopy.reset(new tools::hlsl::LLVMObjcopy(*this)); | ||
return LLVMObjcopy.get(); | ||
default: | ||
return ToolChain::getTool(AC); | ||
} | ||
|
@@ -452,16 +482,25 @@ bool HLSLToolChain::requiresBinaryTranslation(DerivedArgList &Args) const { | |
return Args.hasArg(options::OPT_metal) && Args.hasArg(options::OPT_dxc_Fo); | ||
} | ||
|
||
bool HLSLToolChain::requiresObjcopy(DerivedArgList &Args) const { | ||
return Args.hasArg(options::OPT_dxc_Fo) && | ||
Args.hasArg(options::OPT_dxc_strip_rootsignature); | ||
} | ||
|
||
bool HLSLToolChain::isLastJob(DerivedArgList &Args, | ||
Action::ActionClass AC) const { | ||
bool HasTranslation = requiresBinaryTranslation(Args); | ||
bool HasValidation = requiresValidation(Args); | ||
bool HasObjcopy = requiresObjcopy(Args); | ||
// If translation and validation are not required, we should only have one | ||
// action. | ||
if (!HasTranslation && !HasValidation) | ||
if (!HasTranslation && !HasValidation && !HasObjcopy) | ||
return true; | ||
if ((HasTranslation && AC == Action::BinaryTranslatorJobClass) || | ||
(!HasTranslation && HasValidation && AC == Action::BinaryAnalyzeJobClass)) | ||
(!HasTranslation && HasValidation && | ||
AC == Action::BinaryAnalyzeJobClass) || | ||
(!HasTranslation && !HasValidation && HasObjcopy && | ||
AC == Action::ObjcopyJobClass)) | ||
return true; | ||
return false; | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %clang_dxc -Qstrip-rootsignature -T cs_6_0 /Fo %t -### %s 2>&1 | FileCheck %s | ||
|
||
// Test to demonstrate that we specify to the root signature with the | ||
// -Qstrip-rootsignature option | ||
|
||
// CHECK: "{{.*}}llvm-objcopy{{.*}}" "{{.*}}" "{{.*}}" "--remove-section=RTS0" | ||
|
||
[shader("compute"), RootSignature("")] | ||
[numthreads(1,1,1)] | ||
void EmptyEntry() {} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this anymore? I don't see it being used, and I would think that making this a separate tool's job would make this unnecessary.