Skip to content

Commit

Permalink
DX11ScreenCapture proper dispose previous capture resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Neakita committed Oct 13, 2024
1 parent 6ada416 commit bce80f1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions SightKeeper.Application.Windows/DX11ScreenCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public DX11ScreenCapture()

private unsafe ReadOnlySpan2D<Bgra32> Capture()
{
_device.ImmediateContext.UnmapSubresource(_screenTexture, 0);
_screenResource?.Dispose();
_outputDuplication.ReleaseFrame();
if (_screenResource != null)
{
_device.ImmediateContext.UnmapSubresource(_screenTexture, 0);
_screenResource.Dispose();
_outputDuplication.ReleaseFrame();
}
_outputDuplication.TryAcquireNextFrame(1000, out _, out _screenResource).CheckError();
using (var screenTexture2D = _screenResource.QueryInterface<Texture2D>())
_device.ImmediateContext.CopyResource(screenTexture2D, _screenTexture);
Expand Down

0 comments on commit bce80f1

Please sign in to comment.