fix memory leak when screenshotting/framedumping with osd with d3d9 display method

This commit is contained in:
CasualPokePlayer 2023-10-02 21:07:30 -07:00
parent a1ec56d748
commit af4e9200ed
1 changed files with 4 additions and 2 deletions

View File

@ -671,7 +671,9 @@ namespace BizHawk.Bizware.Graphics
using var target = new Texture(_device, tex.IntWidth, tex.IntHeight, 1, Usage.None, Format.A8R8G8B8, Pool.SystemMemory);
var tw = (TextureWrapper)tex.Opaque;
_device.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
using var rtSurf = tw.Texture.GetSurfaceLevel(0);
using var dstSurf = target.GetSurfaceLevel(0);
_device.GetRenderTargetData(rtSurf, dstSurf);
try
{
@ -681,7 +683,7 @@ namespace BizHawk.Bizware.Graphics
{
throw new InvalidOperationException();
}
var pixels = new int[tex.IntWidth * tex.IntHeight];
Marshal.Copy(dr.DataPointer, pixels, 0, tex.IntWidth * tex.IntHeight);
return new(tex.IntWidth, tex.IntHeight, pixels);