[PR #821] Fix D3D11 resource leaks #148

Open
opened 2026-01-29 19:06:36 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/stenzek/duckstation/pull/821

State: closed
Merged: Yes


Fixes strange leaks in AutoStagingTexture::EnsureSize and D3D11HostDisplay::DownloadTexture. I say "strange" because in other places managed COM pointers were used, but those two were erroneously defined as naked pointers, as if the functions getting them did not increase their refcount.

GetDevice and GetResource both increase the refcount of the object they return, as described here:
https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicechild-getdevice
https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11view-getresource

**Original Pull Request:** https://github.com/stenzek/duckstation/pull/821 **State:** closed **Merged:** Yes --- Fixes strange leaks in `AutoStagingTexture::EnsureSize` and `D3D11HostDisplay::DownloadTexture`. I say "strange" because in other places managed COM pointers were used, but those two were erroneously defined as naked pointers, as if the functions getting them did not increase their refcount. `GetDevice` and `GetResource` both increase the refcount of the object they return, as described here: https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicechild-getdevice https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11view-getresource
claunia added the pull-request label 2026-01-29 19:06:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/duckstation#148