-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DXIL] Add DXIL SubArch to correspond to version number #89125
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
✅ With the latest revision this PR passed the C/C++ code formatter. |
llvm/lib/TargetParser/Triple.cpp
Outdated
.Case("csky", Triple::csky) | ||
.Case("loongarch32", Triple::loongarch32) | ||
.Case("loongarch64", Triple::loongarch64) | ||
.Case("dxil", Triple::dxil) |
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.
I don't really understand what this block does, but I notice that there's a StartsWith("dxil", ...)
as well as a Case("dxil", ...)
. Should they both be there?
How come spirv lists them all out but dxil doesn't?
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.
I don't really understand what this block does, but I notice that there's a
StartsWith("dxil", ...)
as well as aCase("dxil", ...)
. Should they both be there?
Merged them.
How come spirv lists them all out but dxil doesn't?
I believe spirv lists them out to distinguish between spirv
, spirv32
and spirv64
.
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.
I don't really understand what this block does, but I notice that there's a
StartsWith("dxil", ...)
as well as aCase("dxil", ...)
. Should they both be there?Merged them.
How come spirv lists them all out but dxil doesn't?
I believe spirv lists them out to distinguish between
spirv
,spirv32
andspirv64
.
Listing them out appears to be a better option. Pushed the change. Thanks!
llvm/lib/TargetParser/Triple.cpp
Outdated
return StringSwitch<Triple::SubArchType>(SubArchName) | ||
.EndsWith("v1.0", Triple::DXILSubArch_v10) | ||
.EndsWith("v1.1", Triple::DXILSubArch_v11) | ||
.EndsWith("v1.2", Triple::DXILSubArch_v12) |
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.
does it matter than this would match something like "dxilborkborkborkv1.2"?
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.
does it matter than this would match something like "dxilborkborkborkv1.2"?
Pushed a change to address this. Thanks!
Is this related to #88885? |
Yes. |
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.
What's the plan for when a subarch isn't specified (ie, dxil-pc-shadermodel-6.0
)? Will we need a mapping somewhere else that applies a default dxil version for a given shader model? Will we just have to check both the dxil subarch and the shader model anywhere where it matters?
|
||
T = Triple("dxilv1.9-unknown-unknown"); | ||
EXPECT_EQ(Triple::UnknownArch, T.getArch()); | ||
EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); |
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.
Probably worth pointing out in a comment that this is a negative test case and that it's intentional that we're checking for an unknown triple here.
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.
If we're going to test an unknown version, maybe we should pick one that isn't likely to happen anytime soon... Since we just released 1.8 and we're publicly working on previews for potential new features, seems like 1.9 could happen imminently. 1.99
seems like it is a long way off though.
I propose defaulting to version 1.0 when SubArch is not explicitly specified. |
So if I specify |
Could you link it to the issue please? Either with a "fixes" note in the description or using the "Development" section on the right. |
DXILSubArch_v15, | ||
DXILSubArch_v16, | ||
DXILSubArch_v17, | ||
DXILSubArch_v18, |
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.
This is going to get real awkward if we hit v 1.10... maybe we should separate the major and minor versions with _
.
|
||
T = Triple("dxilv1.9-unknown-unknown"); | ||
EXPECT_EQ(Triple::UnknownArch, T.getArch()); | ||
EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); |
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.
If we're going to test an unknown version, maybe we should pick one that isn't likely to happen anytime soon... Since we just released 1.8 and we're publicly working on previews for potential new features, seems like 1.9 could happen imminently. 1.99
seems like it is a long way off though.
I linked this branch in "Development" section. |
This change is in line with similar notation in SPIRV.
On second thoughts, it appears that shader model version is embedded in the |
Something somewhere will need to validate that the dxil version is compatible with the SM version, right? I think we're at a point now where we're speccing the feature in a PR for the implementation. Sounds like we need some design discussion before continuing with this. |
Change enum value from the form DXILSubArch_v<major><minor> to DXILSubArch_v<major>_<minor> Add comment in test
8cd1f4d
to
93a8e55
Compare
In the clang DXC driver mode we translate target profiles to triples (i.e.
I think these changes are extremely straightforward, I'm not sure why we would need a larger design discussion around it. |
This explanation helps. I don't recall seeing this written down anywhere before so I've been trying to understand this change without this context, which is why I was asking for more explanation about what's going on. |
In TripleTest.cpp I don't see any test cases that exercise a specific shadermodel being specified. These are all of the form:
I can't see anything in this change that does that? Is this something that should be done in this PR, or is this happening elsewhere? |
We can add those tests, but the LLVM code shouldn't be responsible for this. LLVM should generate the code based on the triple provided or hard error if it can't. That's separate from the shader model version to DXIL version translation which should happen in Clang.
This is the requisite LLVM side of the change. We also will need a change to Clang's driver to implement setting the sub architecture as I described. We could do that in this PR or separately. |
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.
I'm happy with this change as it is with one request.
@bharadwajy, if you're not going to do the clang change with this patch, can you file an issue to track that because we will need that change to land before we can start making the backend depend on the sub-architecture (otherwise we're always going to set it wrong).
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.
I think this change looks ok to me, but I'd love to have a better understanding of the plan for how these DXIL versions / sub archs / SM versions all work together in clang/clang-dxc/llvm.
Filed an issue #89316. |
This change is in line with similar notation in SPIRV.
Decoupling Version numbering of DXIL and of Shader Model is intended to enable accurate specification of DXIL features that can be targeted by different Shader Model versions. See here for additional context.