-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[HLSL][Driver] Make vk1.3 the default. #143384
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
The HLSL driver currently defaults the triple to an unversioned os and subarch when targeting SPIR-V. This means the SPIR-V backend decides the default value. That is not a great option because a change the backend could cause a change in Clang. Now that we want to choose the default we need to consider the best option. DXC currently defaults to Vulkan1.0. We are planning on not supporting Vulkan1.0 in the Clang HLSL compiler because it is newer versions of Vulkan are commonly supported on nearly all hardware, so users do not use it. Since we have to change from DXC anyway, we are using VK1.3. It has been out long enough to be commonly available, and the initial implementation of SPIR-V features for HLSL are assuming Vulkan 1.3.
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Steven Perron (s-perron) ChangesThe HLSL driver currently defaults the triple to an unversioned os and Now that we want to choose the default we need to consider the best Since we have to change from DXC anyway, we are using VK1.3. It has been Full diff: https://github.com/llvm/llvm-project/pull/143384.diff 2 Files Affected:
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 73ff7757c3b04..af0c4f2012f30 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1596,28 +1596,26 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
A->claim();
if (Args.hasArg(options::OPT_spirv)) {
+ const llvm::StringMap<llvm::Triple::SubArchType> ValidTargets = {
+ {"vulkan1.2", llvm::Triple::SPIRVSubArch_v15},
+ {"vulkan1.3", llvm::Triple::SPIRVSubArch_v16}};
llvm::Triple T(TargetTriple);
- T.setArch(llvm::Triple::spirv);
- T.setOS(llvm::Triple::Vulkan);
- // Set specific Vulkan version if applicable.
+ // Set specific Vulkan version. Default to vulkan1.3.
+ auto TargetInfo = ValidTargets.find("vulkan1.3");
if (const Arg *A = Args.getLastArg(options::OPT_fspv_target_env_EQ)) {
- const llvm::StringMap<llvm::Triple::SubArchType> ValidTargets = {
- {"vulkan1.2", llvm::Triple::SPIRVSubArch_v15},
- {"vulkan1.3", llvm::Triple::SPIRVSubArch_v16}};
-
- auto TargetInfo = ValidTargets.find(A->getValue());
- if (TargetInfo != ValidTargets.end()) {
- T.setOSName(TargetInfo->getKey());
- T.setArch(llvm::Triple::spirv, TargetInfo->getValue());
- } else {
+ TargetInfo = ValidTargets.find(A->getValue());
+ if (TargetInfo == ValidTargets.end()) {
Diag(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
}
A->claim();
}
-
- TargetTriple = T.str();
+ if (TargetInfo != ValidTargets.end()) {
+ T.setOSName(TargetInfo->getKey());
+ T.setArch(llvm::Triple::spirv, TargetInfo->getValue());
+ TargetTriple = T.str();
+ }
}
} else {
Diag(diag::err_drv_dxc_missing_target_profile);
diff --git a/clang/test/Driver/dxc_spirv.hlsl b/clang/test/Driver/dxc_spirv.hlsl
index e6624e5f1b3f6..65c9018dc54c5 100644
--- a/clang/test/Driver/dxc_spirv.hlsl
+++ b/clang/test/Driver/dxc_spirv.hlsl
@@ -3,7 +3,7 @@
// RUN: %clang_dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-VULKAN13
// RUN: not %clang_dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.0 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
-// CHECK: "-triple" "spirv-unknown-vulkan-compute"
+// CHECK: "-triple" "spirv1.6-unknown-vulkan1.3-compute"
// CHECK-SAME: "-x" "hlsl"
// CHECK-VULKAN12: "-triple" "spirv1.5-unknown-vulkan1.2-compute"
|
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.
a nit, otherwise LGTM
Co-authored-by: Nathan Gauër <[email protected]>
The HLSL driver currently defaults the triple to an unversioned os and subarch when targeting SPIR-V. This means the SPIR-V backend decides the default value. That is not a great option because a change the backend could cause a change in Clang. Now that we want to choose the default we need to consider the best option. DXC currently defaults to Vulkan1.0. We are planning on not supporting Vulkan1.0 in the Clang HLSL compiler because it is newer versions of Vulkan are commonly supported on nearly all hardware, so users do not use it. Since we have to change from DXC anyway, we are using VK1.3. It has been out long enough to be commonly available, and the initial implementation of SPIR-V features for HLSL are assuming Vulkan 1.3. --------- Co-authored-by: Nathan Gauër <[email protected]>
The HLSL driver currently defaults the triple to an unversioned os and subarch when targeting SPIR-V. This means the SPIR-V backend decides the default value. That is not a great option because a change the backend could cause a change in Clang. Now that we want to choose the default we need to consider the best option. DXC currently defaults to Vulkan1.0. We are planning on not supporting Vulkan1.0 in the Clang HLSL compiler because it is newer versions of Vulkan are commonly supported on nearly all hardware, so users do not use it. Since we have to change from DXC anyway, we are using VK1.3. It has been out long enough to be commonly available, and the initial implementation of SPIR-V features for HLSL are assuming Vulkan 1.3. --------- Co-authored-by: Nathan Gauër <[email protected]>
The HLSL driver currently defaults the triple to an unversioned os and
subarch when targeting SPIR-V. This means the SPIR-V backend decides the
default value. That is not a great option because a change the backend
could cause a change in Clang.
Now that we want to choose the default we need to consider the best
option. DXC currently defaults to Vulkan1.0. We are planning on not
supporting Vulkan1.0 in the Clang HLSL compiler because it is newer
versions of Vulkan are commonly supported on nearly all hardware, so
users do not use it.
Since we have to change from DXC anyway, we are using VK1.3. It has been
out long enough to be commonly available, and the initial implementation
of SPIR-V features for HLSL are assuming Vulkan 1.3.