Disable the workaround about the T2T copy issue on newer Intel drivers

This patch disables the workaround about the T2T copy issue (the Toggle
UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel)
on the latest Intel Gen9 and Gen9.5 D3D driver (27.20.100.9466) which
contains the fix for this issue.

This patch also implements the D3D driver version comparison algorithm
for Intel drivers.

BUG=chromium:1161355
TEST=dawn_end2end_tests

Change-Id: I406598f2c5745214a60bfc43fb732d45360aa1fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51343
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-05-19 08:43:33 +00:00 committed by Commit Bot service account
parent 3fd2036755
commit ce3d4a5b09
5 changed files with 66 additions and 9 deletions

View File

@ -14,6 +14,8 @@
#include "common/GPUInfo.h" #include "common/GPUInfo.h"
#include "common/Assert.h"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
@ -38,6 +40,13 @@ namespace gpu_info {
const std::array<uint32_t, 21> Cometlake = { const std::array<uint32_t, 21> Cometlake = {
{0x9B21, 0x9BA0, 0x9BA2, 0x9BA4, 0x9BA5, 0x9BA8, 0x9BAA, 0x9BAB, 0x9BAC, 0x9B41, 0x9BC0, {0x9B21, 0x9BA0, 0x9BA2, 0x9BA4, 0x9BA5, 0x9BA8, 0x9BAA, 0x9BAB, 0x9BAC, 0x9B41, 0x9BC0,
0x9BC2, 0x9BC4, 0x9BC5, 0x9BC6, 0x9BC8, 0x9BCA, 0x9BCB, 0x9BCC, 0x9BE6, 0x9BF6}}; 0x9BC2, 0x9BC4, 0x9BC5, 0x9BC6, 0x9BC8, 0x9BCA, 0x9BCB, 0x9BCC, 0x9BE6, 0x9BF6}};
bool IsOldIntelD3DVersionScheme(const D3DDriverVersion& driverVersion) {
// See https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html
// for more details
return driverVersion[2] < 100u;
}
} // anonymous namespace } // anonymous namespace
bool IsAMD(PCIVendorID vendorId) { bool IsAMD(PCIVendorID vendorId) {
@ -65,6 +74,32 @@ namespace gpu_info {
return vendorId == kVendorID_Microsoft && deviceId == kDeviceID_WARP; return vendorId == kVendorID_Microsoft && deviceId == kDeviceID_WARP;
} }
int CompareD3DDriverVersion(PCIVendorID vendorId,
const D3DDriverVersion& version1,
const D3DDriverVersion& version2) {
if (IsIntel(vendorId)) {
// The Intel graphics driver version schema has had a change since the Windows 10 April
// 2018 Update release. In the new schema the 3rd number of the driver version is always
// 100, while on the older drivers it is always less than 100. For the drivers using the
// same driver version schema, the newer driver always has the bigger 4th number.
// See https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html
// for more details.
bool isOldIntelDriver1 = IsOldIntelD3DVersionScheme(version1);
bool isOldIntelDriver2 = IsOldIntelD3DVersionScheme(version2);
if (isOldIntelDriver1 && !isOldIntelDriver2) {
return -1;
} else if (!isOldIntelDriver1 && isOldIntelDriver2) {
return 1;
} else {
return static_cast<int32_t>(version1[3]) - static_cast<int32_t>(version2[3]);
}
}
// TODO(jiawei.shao@intel.com): support other GPU vendors
UNREACHABLE();
return 0;
}
// Intel GPUs // Intel GPUs
bool IsSkylake(PCIDeviceID deviceId) { bool IsSkylake(PCIDeviceID deviceId) {
return std::find(Skylake.cbegin(), Skylake.cend(), deviceId) != Skylake.cend(); return std::find(Skylake.cbegin(), Skylake.cend(), deviceId) != Skylake.cend();

View File

@ -15,6 +15,7 @@
#ifndef COMMON_GPUINFO_H #ifndef COMMON_GPUINFO_H
#define COMMON_GPUINFO_H #define COMMON_GPUINFO_H
#include <array>
#include <cstdint> #include <cstdint>
using PCIVendorID = uint32_t; using PCIVendorID = uint32_t;
@ -43,6 +44,17 @@ namespace gpu_info {
bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId); bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId);
bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId); bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId);
using D3DDriverVersion = std::array<uint16_t, 4>;
// Do comparison between two driver versions. Currently we only support the comparison between
// Intel D3D driver versions.
// - Return a negative value if version1 is older
// - Return a positive value if version1 is newer
// - Return 0 if version1 and version2 represent same driver version
int CompareD3DDriverVersion(PCIVendorID vendorId,
const D3DDriverVersion& version1,
const D3DDriverVersion& version2);
// Intel architectures // Intel architectures
bool IsSkylake(PCIDeviceID deviceId); bool IsSkylake(PCIDeviceID deviceId);
bool IsKabylake(PCIDeviceID deviceId); bool IsKabylake(PCIDeviceID deviceId);

View File

@ -52,6 +52,10 @@ namespace dawn_native { namespace d3d12 {
return mD3d12Device; return mD3d12Device;
} }
const gpu_info::D3DDriverVersion& Adapter::GetDriverVersion() const {
return mDriverVersion;
}
MaybeError Adapter::Initialize() { MaybeError Adapter::Initialize() {
// D3D12 cannot check for feature support without a device. // D3D12 cannot check for feature support without a device.
// Create the device to populate the adapter properties then reuse it when needed for actual // Create the device to populate the adapter properties then reuse it when needed for actual
@ -88,10 +92,10 @@ namespace dawn_native { namespace d3d12 {
std::ostringstream o; std::ostringstream o;
o << "D3D12 driver version "; o << "D3D12 driver version ";
o << ((encodedVersion >> 48) & 0xFFFF) << "."; for (size_t i = 0; i < mDriverVersion.size(); ++i) {
o << ((encodedVersion >> 32) & 0xFFFF) << "."; mDriverVersion[i] = (encodedVersion >> (48 - 16 * i)) & 0xFFFF;
o << ((encodedVersion >> 16) & 0xFFFF) << "."; o << mDriverVersion[i] << ".";
o << (encodedVersion & 0xFFFF); }
mDriverDescription = o.str(); mDriverDescription = o.str();
} }

View File

@ -17,6 +17,7 @@
#include "dawn_native/Adapter.h" #include "dawn_native/Adapter.h"
#include "common/GPUInfo.h"
#include "dawn_native/d3d12/D3D12Info.h" #include "dawn_native/d3d12/D3D12Info.h"
#include "dawn_native/d3d12/d3d12_platform.h" #include "dawn_native/d3d12/d3d12_platform.h"
@ -33,6 +34,7 @@ namespace dawn_native { namespace d3d12 {
IDXGIAdapter3* GetHardwareAdapter() const; IDXGIAdapter3* GetHardwareAdapter() const;
Backend* GetBackend() const; Backend* GetBackend() const;
ComPtr<ID3D12Device> GetDevice() const; ComPtr<ID3D12Device> GetDevice() const;
const gpu_info::D3DDriverVersion& GetDriverVersion() const;
MaybeError Initialize(); MaybeError Initialize();
@ -46,6 +48,7 @@ namespace dawn_native { namespace d3d12 {
ComPtr<IDXGIAdapter3> mHardwareAdapter; ComPtr<IDXGIAdapter3> mHardwareAdapter;
ComPtr<ID3D12Device> mD3d12Device; ComPtr<ID3D12Device> mD3d12Device;
gpu_info::D3DDriverVersion mDriverVersion;
Backend* mBackend; Backend* mBackend;
D3D12DeviceInfo mDeviceInfo = {}; D3D12DeviceInfo mDeviceInfo = {};

View File

@ -548,16 +548,19 @@ namespace dawn_native { namespace d3d12 {
// Currently this workaround is only needed on Intel Gen9 and Gen9.5 GPUs. // Currently this workaround is only needed on Intel Gen9 and Gen9.5 GPUs.
// See http://crbug.com/1161355 for more information. // See http://crbug.com/1161355 for more information.
// TODO(jiawei.shao@intel.com): disable this workaround on the newer drivers when the driver
// bug is fixed.
if (gpu_info::IsIntel(pciInfo.vendorId) && if (gpu_info::IsIntel(pciInfo.vendorId) &&
(gpu_info::IsSkylake(pciInfo.deviceId) || gpu_info::IsKabylake(pciInfo.deviceId) || (gpu_info::IsSkylake(pciInfo.deviceId) || gpu_info::IsKabylake(pciInfo.deviceId) ||
gpu_info::IsCoffeelake(pciInfo.deviceId))) { gpu_info::IsCoffeelake(pciInfo.deviceId))) {
constexpr gpu_info::D3DDriverVersion kFirstDriverVersionWithFix = {27, 20, 100, 9466};
if (gpu_info::CompareD3DDriverVersion(pciInfo.vendorId,
ToBackend(GetAdapter())->GetDriverVersion(),
kFirstDriverVersionWithFix) < 0) {
SetToggle( SetToggle(
Toggle::UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel, Toggle::UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel,
true); true);
} }
} }
}
MaybeError Device::WaitForIdleForDestruction() { MaybeError Device::WaitForIdleForDestruction() {
// Immediately forget about all pending commands // Immediately forget about all pending commands