Skip to content

[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

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

bharadwajy
Copy link
Contributor

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.

Copy link

github-actions bot commented Apr 17, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

.Case("csky", Triple::csky)
.Case("loongarch32", Triple::loongarch32)
.Case("loongarch64", Triple::loongarch64)
.Case("dxil", Triple::dxil)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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.

Copy link
Contributor Author

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?

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.

Listing them out appears to be a better option. Pushed the change. Thanks!

return StringSwitch<Triple::SubArchType>(SubArchName)
.EndsWith("v1.0", Triple::DXILSubArch_v10)
.EndsWith("v1.1", Triple::DXILSubArch_v11)
.EndsWith("v1.2", Triple::DXILSubArch_v12)
Copy link
Contributor

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"?

Copy link
Contributor Author

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!

@damyanp
Copy link
Contributor

damyanp commented Apr 17, 2024

Is this related to #88885?

@bharadwajy
Copy link
Contributor Author

Is this related to #88885?

Yes.

Copy link
Contributor

@bogner bogner left a 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());
Copy link
Contributor

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.

Copy link
Collaborator

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.

@bharadwajy
Copy link
Contributor Author

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?

I propose defaulting to version 1.0 when SubArch is not explicitly specified.

@damyanp
Copy link
Contributor

damyanp commented Apr 17, 2024

What's the plan for when a subarch isn't specified (ie, dxil-pc-shadermodel-6.0)?
I propose defaulting to version 1.0 when SubArch is not explicitly specified.

So if I specify dxil-pc-shadermodel-6.8 then the SubArch will be DXILSubArch_v10? Will that work out ok everywhere?

@damyanp
Copy link
Contributor

damyanp commented Apr 17, 2024

Is this related to #88885?

Yes.

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,
Copy link
Collaborator

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());
Copy link
Collaborator

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.

@bharadwajy
Copy link
Contributor Author

Is this related to #88885?

Yes.

Could you link it to the issue please? Either with a "fixes" note in the description or using the "Development" section on the right.

I linked this branch in "Development" section.

@bharadwajy
Copy link
Contributor Author

What's the plan for when a subarch isn't specified (ie, dxil-pc-shadermodel-6.0)?
I propose defaulting to version 1.0 when SubArch is not explicitly specified.

So if I specify dxil-pc-shadermodel-6.8 then the SubArch will be DXILSubArch_v10? Will that work out ok everywhere?

On second thoughts, it appears that shader model version is embedded in the -T <target profile> option specified on the HLSL compiler command line (e.g., ps_6_0, lib_6_8). Since Shader Model version is being decoupled from DXIL version, the target DXIL version is also required to be explicitly specified in the target triple. This implies dxil-pc-shadermodel-6.8 would be flagged as an error.

@damyanp
Copy link
Contributor

damyanp commented Apr 18, 2024

What's the plan for when a subarch isn't specified (ie, dxil-pc-shadermodel-6.0)?
I propose defaulting to version 1.0 when SubArch is not explicitly specified.

So if I specify dxil-pc-shadermodel-6.8 then the SubArch will be DXILSubArch_v10? Will that work out ok everywhere?

On second thoughts, it appears that shader model version is embedded in the -T <target profile> option specified on the HLSL compiler command line (e.g., ps_6_0, lib_6_8). Since Shader Model version is being decoupled from DXIL version, the target DXIL version is also required to be explicitly specified in the target triple. This implies dxil-pc-shadermodel-6.8 would be flagged as an error.

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
@llvm-beanz
Copy link
Collaborator

In the clang DXC driver mode we translate target profiles to triples (i.e. ps_6_6 to dxil-pc-shadermodel6.6-pixel). Clang needs two changes to utilize this:

  1. translate target profile to dxil version and shader model version.
  2. In the non-DXC-mode driver, we should propagate shader model version to dxil sub arch if the DXIL sub arch is not set.

I think these changes are extremely straightforward, I'm not sure why we would need a larger design discussion around it.

@damyanp
Copy link
Contributor

damyanp commented Apr 18, 2024

In the clang DXC driver mode we translate target profiles to triples (i.e. ps_6_6 to dxil-pc-shadermodel6.6-pixel). Clang needs two changes to utilize this [...]

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.

@damyanp
Copy link
Contributor

damyanp commented Apr 18, 2024

In the clang DXC driver mode we translate target profiles to triples (i.e. ps_6_6 to dxil-pc-shadermodel6.6-pixel). Clang needs two changes to utilize this:

  • translate target profile to dxil version and shader model version.

In TripleTest.cpp I don't see any test cases that exercise a specific shadermodel being specified. These are all of the form:

  • dxil-unknown-shadermodel-amplification
  • dxilv1.0-unknown-unknown
  • In the non-DXC-mode driver, we should propagate shader model version to dxil sub arch if the DXIL sub arch is not set.

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?

@llvm-beanz
Copy link
Collaborator

In TripleTest.cpp I don't see any test cases that exercise a specific shadermodel being specified. These are all of the form:

  • dxil-unknown-shadermodel-amplification
  • dxilv1.0-unknown-unknown

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.

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?

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.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a 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).

Copy link
Contributor

@damyanp damyanp left a 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.

@bharadwajy
Copy link
Contributor Author

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).

Filed an issue #89316.

@bharadwajy bharadwajy merged commit a2face4 into llvm:main Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants