diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp index 8c79f06fe3..b0076491c2 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.cpp +++ b/src/dawn/native/d3d12/DeviceD3D12.cpp @@ -859,6 +859,10 @@ void Device::DestroyImpl() { ASSERT(mUsedComObjectRefs.Empty()); ASSERT(!mPendingCommands.IsOpen()); + + // Now that we've cleared out pending work from the queue, we can safely release it and reclaim + // memory. + mCommandQueue.Reset(); } ShaderVisibleDescriptorAllocator* Device::GetViewShaderVisibleDescriptorAllocator() const { diff --git a/src/dawn/tests/end2end/DestroyTests.cpp b/src/dawn/tests/end2end/DestroyTests.cpp index fcf53b2a0b..a6ec75aad6 100644 --- a/src/dawn/tests/end2end/DestroyTests.cpp +++ b/src/dawn/tests/end2end/DestroyTests.cpp @@ -156,7 +156,7 @@ TEST_P(DestroyTest, TextureSubmitDestroySubmit) { } // Attempting to set an object label after it has been destroyed should not cause an error. -TEST_P(DestroyTest, DestroyThenSetLabel) { +TEST_P(DestroyTest, DestroyObjectThenSetLabel) { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); std::string label = "test"; wgpu::BufferDescriptor descriptor; @@ -167,6 +167,14 @@ TEST_P(DestroyTest, DestroyThenSetLabel) { buffer.SetLabel(label.c_str()); } +// Attempting to set a device label after it has been destroyed should not cause an error. +TEST_P(DestroyTest, DestroyDeviceThenSetLabel) { + DAWN_TEST_UNSUPPORTED_IF(UsesWire()); + std::string label = "test"; + device.Destroy(); + device.SetLabel(label.c_str()); +} + // Device destroy before buffer submit will result in error. TEST_P(DestroyTest, DestroyDeviceBeforeSubmit) { // TODO(crbug.com/dawn/628) Add more comprehensive tests with destroy and backends.