Always validate DXC version and forbid DXC older than 1.4
This CL add a `Backend::IsDXCAvailable` method that check not only the DXC binary is available but also its version is no older than a given minimum version, and use this function to replace all previous `PlatformFunctions::IsDXCAvailable` to ensure that we always check the DXC version. By giving the minimum version 1.4, this CL also forbid using DXC older than 1.4. Issue: tint:1719 Change-Id: I6ab0a3791ac734c4e8b13570c55194573f111e61 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105900 Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
6ee03bfc56
commit
9fc7a77609
|
@ -140,13 +140,9 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() {
|
|||
mSupportedFeatures.EnableFeature(Feature::RG11B10UfloatRenderable);
|
||||
mSupportedFeatures.EnableFeature(Feature::DepthClipControl);
|
||||
|
||||
if (GetBackend()->GetFunctions()->IsDXCAvailable()) {
|
||||
uint64_t dxcVersion = 0;
|
||||
DAWN_TRY_ASSIGN(dxcVersion, GetBackend()->GetDXCompilerVersion());
|
||||
constexpr uint64_t kLeastMajorVersionForDP4a = 1;
|
||||
constexpr uint64_t kLeastMinorVersionForDP4a = 4;
|
||||
if (mDeviceInfo.supportsDP4a &&
|
||||
dxcVersion >= MakeDXCVersion(kLeastMajorVersionForDP4a, kLeastMinorVersionForDP4a)) {
|
||||
// Both Dp4a and ShaderF16 features require DXC version being 1.4 or higher
|
||||
if (GetBackend()->IsDXCAvailable(1, 4)) {
|
||||
if (mDeviceInfo.supportsDP4a) {
|
||||
mSupportedFeatures.EnableFeature(Feature::ChromiumExperimentalDp4a);
|
||||
}
|
||||
if (mDeviceInfo.supportsShaderF16) {
|
||||
|
@ -322,13 +318,13 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
|
|||
MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(
|
||||
wgpu::FeatureName feature,
|
||||
const TripleStateTogglesSet& userProvidedToggles) {
|
||||
// shader-f16 feature and chromium-experimental-dp4a feature require DXC for D3D12.
|
||||
// shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for
|
||||
// D3D12.
|
||||
if (feature == wgpu::FeatureName::ShaderF16 ||
|
||||
feature == wgpu::FeatureName::ChromiumExperimentalDp4a) {
|
||||
DAWN_INVALID_IF(!(userProvidedToggles.IsEnabled(Toggle::UseDXC) &&
|
||||
mBackend->GetFunctions()->IsDXCAvailable()),
|
||||
"Feature %s requires DXC for D3D12.",
|
||||
GetInstance()->GetFeatureInfo(feature)->name);
|
||||
DAWN_INVALID_IF(
|
||||
!(userProvidedToggles.IsEnabled(Toggle::UseDXC) && mBackend->IsDXCAvailable(1, 4)),
|
||||
"Feature %s requires DXC for D3D12.", GetInstance()->GetFeatureInfo(feature)->name);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -157,6 +157,22 @@ ResultOrError<uint64_t> Backend::GetDXCompilerVersion() {
|
|||
return MakeDXCVersion(compilerMajor, compilerMinor);
|
||||
}
|
||||
|
||||
// Return true if and only if DXC binary is avaliable, and the DXC version is validated to
|
||||
// be no older than given minimum version.
|
||||
bool Backend::IsDXCAvailable(uint64_t minimumMajorVersion, uint64_t minimumMinorVersion) {
|
||||
if (mFunctions->IsDXCBinaryAvailable()) {
|
||||
auto versionOrError = GetDXCompilerVersion();
|
||||
if (versionOrError.IsSuccess()) {
|
||||
// Validate the DXC version
|
||||
auto version = versionOrError.AcquireSuccess();
|
||||
if (version >= MakeDXCVersion(minimumMajorVersion, minimumMinorVersion)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const PlatformFunctions* Backend::GetFunctions() const {
|
||||
return mFunctions.get();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ class Backend : public BackendConnection {
|
|||
ComPtr<IDxcValidator> GetDxcValidator() const;
|
||||
ResultOrError<uint64_t> GetDXCompilerVersion();
|
||||
|
||||
// Return true if and only if DXC binary is avaliable, and the DXC version is validated to
|
||||
// be no older than given minimium version.
|
||||
bool IsDXCAvailable(uint64_t minimumMajorVersion, uint64_t minimumMinorVersion);
|
||||
|
||||
const PlatformFunctions* GetFunctions() const;
|
||||
|
||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override;
|
||||
|
|
|
@ -235,7 +235,9 @@ ComPtr<IDXGIFactory4> Device::GetFactory() const {
|
|||
}
|
||||
|
||||
MaybeError Device::ApplyUseDxcToggle() {
|
||||
if (!ToBackend(GetAdapter())->GetBackend()->GetFunctions()->IsDXCAvailable()) {
|
||||
// Require DXC version 1.4 or higher to enable using DXC, as DXC 1.2 have some known issues when
|
||||
// compiling Tint generated HLSL program. Please refer to crbug.com/tint/1719.
|
||||
if (!ToBackend(GetAdapter())->GetBackend()->IsDXCAvailable(1, 4)) {
|
||||
ForceSetToggle(Toggle::UseDXC, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,9 @@ bool PlatformFunctions::IsPIXEventRuntimeLoaded() const {
|
|||
return mPIXEventRuntimeLib.Valid();
|
||||
}
|
||||
|
||||
bool PlatformFunctions::IsDXCAvailable() const {
|
||||
// Use Backend::IsDXCAvaliable if possible, which also check the DXC is no older than a given
|
||||
// version
|
||||
bool PlatformFunctions::IsDXCBinaryAvailable() const {
|
||||
return mDXILLib.Valid() && mDXCompilerLib.Valid();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class PlatformFunctions {
|
|||
|
||||
MaybeError LoadFunctions();
|
||||
bool IsPIXEventRuntimeLoaded() const;
|
||||
bool IsDXCAvailable() const;
|
||||
bool IsDXCBinaryAvailable() const;
|
||||
|
||||
// Functions from d3d12.dll
|
||||
PFN_D3D12_CREATE_DEVICE d3d12CreateDevice = nullptr;
|
||||
|
|
Loading…
Reference in New Issue