Reset Internal D3D12 Device After Test Shutdown

Adds dawn_native::ResetDeviceInternal, which allows us to destroy and
create a new ID3D12Device. The device should be reset after every test
when GPU-based validation is enabled in order to prevent GBV objects
from using a significant amount of memory over time.

Bug: dawn:623
Change-Id: I654d093d993ab0198c6c240bd0f3f843d2762680
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41340
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
This commit is contained in:
Brandon Jones
2021-02-24 22:09:30 +00:00
committed by Commit Bot service account
parent d87de3343a
commit 0a295c027d
8 changed files with 38 additions and 1 deletions

View File

@@ -677,6 +677,11 @@ DawnTestBase::~DawnTestBase() {
queue = wgpu::Queue();
device = wgpu::Device();
// D3D12's GPU-based validation will accumulate objects over time if the backend device is not
// destroyed and recreated, so we reset it here.
if (IsD3D12() && IsBackendValidationEnabled()) {
mBackendAdapter.ResetInternalDeviceForTesting();
}
mWireHelper.reset();
}

View File

@@ -62,7 +62,7 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) {
properties.backendType == desiredProperties.backendType) {
// Create the device, destroy the instance, and break out of the loop.
dawn_native::DeviceDescriptor deviceDescriptor = {};
device = wgpu::Device(adapter.CreateDevice(&deviceDescriptor));
device = wgpu::Device::Acquire(adapter.CreateDevice(&deviceDescriptor));
instance.reset();
break;
}