tidy d3d display method a tiny bit, i guess

This commit is contained in:
zeromus 2016-03-27 01:43:24 -05:00
parent ebad5a8137
commit b8fd885d3f
2 changed files with 22 additions and 10 deletions

View File

@ -46,6 +46,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
public Control Control { get { return this; } }
public SwapChain SwapChain;
public Surface SwapChainBB;
public void SetVsync(bool state)
{

View File

@ -806,7 +806,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
_CurrentControl = control;
//don't dispose this backbuffer reference, even though it's tempting to.
//it results in weird flashes of corruption when changing the vsync setting (unproven; it's another similar code sequence that broke it)
dev.SetRenderTarget(0, _CurrentControl.SwapChain.GetBackBuffer(0));
dev.SetRenderTarget(0, _CurrentControl.SwapChainBB);
}
public void EndControl(GLControlWrapper_SlimDX9 control)
@ -816,7 +816,8 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
//don't dispose this backbuffer reference, even though it's tempting to.
//it results in weird flashes of corruption when changing the vsync setting (unproven; it's another similar code sequence that broke it)
dev.SetRenderTarget(0, dev.GetBackBuffer(0, 0));
//do we REALLY need this?
//dev.SetRenderTarget(0, dev.GetBackBuffer(0, 0));
_CurrentControl = null;
}
@ -863,24 +864,33 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
{
//don't dispose this backbuffer reference, even though it's tempting to.
//it results in weird flashes of corruption when changing the vsync setting
dev.SetRenderTarget(0, _CurrentControl.SwapChain.GetBackBuffer(0));
dev.SetRenderTarget(0, _CurrentControl.SwapChainBB);
dev.DepthStencilSurface = null;
return;
}
var tw = rt.Opaque as TextureWrapper;
//TODO - cache surface level in an RT wrapper
dev.SetRenderTarget(0, tw.Texture.GetSurfaceLevel(0));
var surf = tw.Texture.GetSurfaceLevel(0);
dev.SetRenderTarget(0, surf);
surf.Dispose();
dev.DepthStencilSurface = null;
}
void DestroyControlSwapChain(GLControlWrapper_SlimDX9 control)
{
if (control.SwapChain == null)
return;
control.SwapChainBB.Dispose();
control.SwapChainBB = null;
control.SwapChain.Dispose();
control.SwapChain = null;
}
public void RefreshControlSwapChain(GLControlWrapper_SlimDX9 control)
{
if (control.SwapChain != null)
{
control.SwapChain.Dispose();
control.SwapChain = null;
}
DestroyControlSwapChain(control);
ResetHandlers.Remove(control, "SwapChain");
var pp = new PresentParameters
@ -895,7 +905,8 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
};
control.SwapChain = new SwapChain(dev, pp);
ResetHandlers.Add(control, "SwapChain", () => { control.SwapChain.Dispose(); control.SwapChain = null; }, () => RefreshControlSwapChain(control));
control.SwapChainBB = control.SwapChain.GetBackBuffer(0);
ResetHandlers.Add(control, "SwapChain", () => DestroyControlSwapChain(control), () => RefreshControlSwapChain(control));
}
DeviceLostHandler ResetHandlers = new DeviceLostHandler();