Fix leak of D3D12 fence share handle
The D3D12 fence share handle should be closed when the device is deleted. A future change will make it valid to call EndAccess after the device is destroyed, thus the handle is closed in ~Device instead of Device::DestroyImpl. It needs to live as long as ExternalImageDXGI holds a reference onto the device. Bug: chromium:1359106 Change-Id: Ib9c9aaa7fb0b5a3de035b512f8fc0316d4bd225e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104540 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
2a3eae7371
commit
5a687b084e
|
@ -193,6 +193,13 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
|
||||||
|
|
||||||
Device::~Device() {
|
Device::~Device() {
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
|
// Close the handle here instead of in DestroyImpl. The handle is returned from
|
||||||
|
// ExternalImageDXGI, so it needs to live as long as the Device ref does, even if the device
|
||||||
|
// state is destroyed.
|
||||||
|
if (mFenceHandle != nullptr) {
|
||||||
|
::CloseHandle(mFenceHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Device* Device::GetD3D12Device() const {
|
ID3D12Device* Device::GetD3D12Device() const {
|
||||||
|
|
|
@ -111,7 +111,7 @@ WGPUTexture ExternalImageDXGIImpl::BeginAccess(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
d3d11on12Resource = mD3D11on12ResourceCache->GetOrCreateD3D11on12Resource(
|
d3d11on12Resource = mD3D11on12ResourceCache->GetOrCreateD3D11on12Resource(
|
||||||
mBackendDevice, mD3D12Resource.Get());
|
mBackendDevice.Get(), mD3D12Resource.Get());
|
||||||
if (d3d11on12Resource == nullptr) {
|
if (d3d11on12Resource == nullptr) {
|
||||||
dawn::ErrorLog() << "Unable to create 11on12 resource for external image";
|
dawn::ErrorLog() << "Unable to create 11on12 resource for external image";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ExternalImageDXGIImpl : public LinkNode<ExternalImageDXGIImpl> {
|
||||||
void EndAccess(WGPUTexture texture, ExternalImageDXGIFenceDescriptor* signalFence);
|
void EndAccess(WGPUTexture texture, ExternalImageDXGIFenceDescriptor* signalFence);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Device* mBackendDevice = nullptr;
|
Ref<Device> mBackendDevice;
|
||||||
Microsoft::WRL::ComPtr<ID3D12Resource> mD3D12Resource;
|
Microsoft::WRL::ComPtr<ID3D12Resource> mD3D12Resource;
|
||||||
const bool mUseFenceSynchronization;
|
const bool mUseFenceSynchronization;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue