mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-18 18:58:55 +02:00
Merge some frame dumping code to VideoCommon, fixes a memory leak in D3D9 and OpenGL if emulation is stopped while dumping frames.
Breaks D3D11 frame dumping for some weird reason (memory corruption or whatever?).
This commit is contained in:
@ -67,7 +67,6 @@ static bool IS_AMD;
|
||||
static char *st;
|
||||
|
||||
static LPDIRECT3DSURFACE9 ScreenShootMEMSurface = NULL;
|
||||
static bool s_bAVIDumping;
|
||||
|
||||
|
||||
// State translation lookup tables
|
||||
@ -292,9 +291,6 @@ Renderer::Renderer()
|
||||
// Make sure to use valid texture sizes
|
||||
D3D::FixTextureSize(s_target_width, s_target_height);
|
||||
|
||||
bLastFrameDumped = false;
|
||||
s_bAVIDumping = false;
|
||||
|
||||
// We're not using fixed function.
|
||||
// Let's just set the matrices to identity to be sure.
|
||||
D3DXMATRIX mtx;
|
||||
@ -337,10 +333,6 @@ Renderer::~Renderer()
|
||||
D3D::Present();
|
||||
D3D::Close();
|
||||
|
||||
if (s_bAVIDumping)
|
||||
{
|
||||
AVIDump::Stop();
|
||||
}
|
||||
delete[] st;
|
||||
}
|
||||
|
||||
@ -839,11 +831,10 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
||||
// This function has the final picture. We adjust the aspect ratio here.
|
||||
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma)
|
||||
{
|
||||
static char* data = 0;
|
||||
if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight)
|
||||
{
|
||||
if (g_ActiveConfig.bDumpFrames && data)
|
||||
AVIDump::AddFrame(data);
|
||||
if (g_ActiveConfig.bDumpFrames && frame_data)
|
||||
AVIDump::AddFrame(frame_data);
|
||||
|
||||
Core::Callback_VideoCopiedToXFB(false);
|
||||
return;
|
||||
@ -857,8 +848,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
if (g_ActiveConfig.bDumpFrames && data)
|
||||
AVIDump::AddFrame(data);
|
||||
if (g_ActiveConfig.bDumpFrames && frame_data)
|
||||
AVIDump::AddFrame(frame_data);
|
||||
|
||||
Core::Callback_VideoCopiedToXFB(false);
|
||||
return;
|
||||
@ -1038,8 +1029,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
{
|
||||
s_recordWidth = dst_rect.GetWidth();
|
||||
s_recordHeight = dst_rect.GetHeight();
|
||||
s_bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||
if (!s_bAVIDumping)
|
||||
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||
if (!bAVIDumping)
|
||||
{
|
||||
PanicAlert("Error dumping frames to AVI.");
|
||||
}
|
||||
@ -1051,20 +1042,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
OSD::AddMessage(msg, 2000);
|
||||
}
|
||||
}
|
||||
if (s_bAVIDumping)
|
||||
if (bAVIDumping)
|
||||
{
|
||||
D3DLOCKED_RECT rect;
|
||||
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, dst_rect.AsRECT(), D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
|
||||
{
|
||||
if (!data || w != s_recordWidth || h != s_recordHeight)
|
||||
if (!frame_data || w != s_recordWidth || h != s_recordHeight)
|
||||
{
|
||||
free(data);
|
||||
data = (char*)malloc(3 * s_recordWidth * s_recordHeight);
|
||||
delete[] frame_data;
|
||||
frame_data = new char[3 * s_recordWidth * s_recordHeight];
|
||||
w = s_recordWidth;
|
||||
h = s_recordHeight;
|
||||
}
|
||||
formatBufferDump((const char*)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
|
||||
AVIDump::AddFrame(data);
|
||||
formatBufferDump((const char*)rect.pBits, frame_data, s_recordWidth, s_recordHeight, rect.Pitch);
|
||||
AVIDump::AddFrame(frame_data);
|
||||
ScreenShootMEMSurface->UnlockRect();
|
||||
}
|
||||
}
|
||||
@ -1072,16 +1063,16 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bLastFrameDumped && s_bAVIDumping)
|
||||
if (bLastFrameDumped && bAVIDumping)
|
||||
{
|
||||
if (data)
|
||||
if (frame_data)
|
||||
{
|
||||
free(data);
|
||||
data = 0;
|
||||
delete[] frame_data;
|
||||
frame_data = 0;
|
||||
w = h = 0;
|
||||
}
|
||||
AVIDump::Stop();
|
||||
s_bAVIDumping = false;
|
||||
bAVIDumping = false;
|
||||
OSD::AddMessage("Stop dumping frames to AVI", 2000);
|
||||
}
|
||||
bLastFrameDumped = false;
|
||||
|
Reference in New Issue
Block a user