-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version #90809
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
Changes from all commits
3b74e41
ceaf226
a370808
0eccb09
ab2eae1
e739a33
72406e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,31 @@ StringRef Triple::getArchName(ArchType Kind, SubArchType SubArch) { | |
if (SubArch == AArch64SubArch_arm64e) | ||
return "arm64e"; | ||
break; | ||
case Triple::dxil: | ||
switch (SubArch) { | ||
case Triple::NoSubArch: | ||
python3kgae marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case Triple::DXILSubArch_v1_0: | ||
return "dxilv1.0"; | ||
case Triple::DXILSubArch_v1_1: | ||
return "dxilv1.1"; | ||
case Triple::DXILSubArch_v1_2: | ||
return "dxilv1.2"; | ||
case Triple::DXILSubArch_v1_3: | ||
return "dxilv1.3"; | ||
case Triple::DXILSubArch_v1_4: | ||
return "dxilv1.4"; | ||
case Triple::DXILSubArch_v1_5: | ||
return "dxilv1.5"; | ||
case Triple::DXILSubArch_v1_6: | ||
return "dxilv1.6"; | ||
case Triple::DXILSubArch_v1_7: | ||
return "dxilv1.7"; | ||
case Triple::DXILSubArch_v1_8: | ||
return "dxilv1.8"; | ||
default: | ||
break; | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
|
@@ -1014,6 +1039,8 @@ Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, | |
ObjectFormat = getDefaultFormat(*this); | ||
} | ||
|
||
static VersionTuple parseVersionFromName(StringRef Name); | ||
|
||
std::string Triple::normalize(StringRef Str) { | ||
bool IsMinGW32 = false; | ||
bool IsCygwin = false; | ||
|
@@ -1206,6 +1233,47 @@ std::string Triple::normalize(StringRef Str) { | |
} | ||
} | ||
|
||
// Normalize DXIL triple if it does not include DXIL version number. | ||
// Determine DXIL version number using the minor version number of Shader | ||
// Model version specified in target triple, if any. Prior to decoupling DXIL | ||
// version numbering from that of Shader Model DXIL version 1.Y corresponds to | ||
// SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull | ||
if (Components[0] == "dxil") { | ||
if (Components.size() > 4) { | ||
Components.resize(4); | ||
} | ||
// Add DXIL version only if shadermodel is specified in the triple | ||
if (OS == Triple::ShaderModel) { | ||
VersionTuple Ver = | ||
parseVersionFromName(Components[2].drop_front(strlen("shadermodel"))); | ||
// Default DXIL minor version when Shader Model version is anything other | ||
// than 6.[0...8] or 6.x (which translates to latest current SM version) | ||
// DXIL version corresponding to Shader Model version other than 6.x | ||
// is 1.0 | ||
unsigned DXILMinor = 0; | ||
const unsigned SMMajor = 6; | ||
const unsigned LatestCurrentDXILMinor = 8; | ||
if (!Ver.empty()) { | ||
if (Ver.getMajor() == SMMajor) { | ||
if (std::optional<unsigned> SMMinor = Ver.getMinor()) { | ||
DXILMinor = *SMMinor; | ||
// Ensure specified minor version is supported | ||
if (DXILMinor > LatestCurrentDXILMinor) { | ||
report_fatal_error("Unsupported Shader Model version", false); | ||
} | ||
} | ||
} | ||
} else { | ||
// Special case: DXIL minor version is set to LatestCurrentDXILMinor for | ||
// shadermodel6.x is | ||
if (Components[2] == "shadermodel6.x") { | ||
DXILMinor = LatestCurrentDXILMinor; | ||
} | ||
} | ||
Components[0] = | ||
Components[0].str().append("v1.").append(std::to_string(DXILMinor)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bharadwajy this is your asan failure. You’re setting a stringref to a locally modified string temporary. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right. We've already parsed if (Arch == Triple::DXIL && SubArch == Triple::NoSubArch) {
VersionTuple Ver = OS != Triple::UnknownOS ? parseVersionFromName(Components[2]) : VersionTuple();
if (Ver)
Components[0] = Components[0].append("1.").append(Ver.Minor);
else (Ver)
// default case...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function An input DXIL triple string However, made code changes to leverage Arch and OS values already parsed as suggested. A couple of additional sanity checks are also added. |
||
} | ||
// Stick the corrected components back together to form the normalized string. | ||
return join(Components, "-"); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.