D3D: Use VideoCommon framedumping helpers.
This commit is contained in:
parent
a530708bb1
commit
64b648f6c8
|
@ -768,9 +768,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
||||
!fbWidth || !fbHeight)
|
||||
{
|
||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
||||
AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
|
||||
|
||||
RepeatFrameDumpFrame();
|
||||
Core::Callback_VideoCopiedToXFB(false);
|
||||
return;
|
||||
}
|
||||
|
@ -780,9 +778,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount);
|
||||
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
||||
AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
|
||||
|
||||
RepeatFrameDumpFrame();
|
||||
Core::Callback_VideoCopiedToXFB(false);
|
||||
return;
|
||||
}
|
||||
|
@ -877,7 +873,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
}
|
||||
|
||||
// Dump frames
|
||||
if (SConfig::GetInstance().m_DumpFrames)
|
||||
if (IsFrameDumping())
|
||||
{
|
||||
if (!s_screenshot_texture)
|
||||
CreateScreenshotTexture();
|
||||
|
@ -888,47 +884,17 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
D3D::context->CopySubresourceRegion(s_screenshot_texture, 0, 0, 0, 0,
|
||||
(ID3D11Resource*)D3D::GetBackBuffer()->GetTex(), 0,
|
||||
&source_box);
|
||||
if (!bLastFrameDumped)
|
||||
{
|
||||
bAVIDumping = AVIDump::Start(source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR);
|
||||
if (!bAVIDumping)
|
||||
{
|
||||
PanicAlert("Error dumping frames to AVI.");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
||||
source_width, source_height);
|
||||
|
||||
OSD::AddMessage(msg, 2000);
|
||||
}
|
||||
}
|
||||
if (bAVIDumping)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
||||
|
||||
if (frame_data.capacity() != 3 * source_width * source_height)
|
||||
frame_data.resize(3 * source_width * source_height);
|
||||
// TODO: This convertion is not needed. Get rid of it.
|
||||
std::vector<u8> image(source_width * source_height * 3);
|
||||
formatBufferDump((u8*)map.pData, image.data(), source_width, source_height, map.RowPitch);
|
||||
|
||||
formatBufferDump((u8*)map.pData, &frame_data[0], source_width, source_height, map.RowPitch);
|
||||
FlipImageData(&frame_data[0], source_width, source_height);
|
||||
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||
}
|
||||
bLastFrameDumped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bLastFrameDumped && bAVIDumping)
|
||||
{
|
||||
AVIDump::Stop();
|
||||
std::vector<u8>().swap(frame_data);
|
||||
bAVIDumping = false;
|
||||
OSD::AddMessage("Stop dumping frames to AVI", 2000);
|
||||
}
|
||||
bLastFrameDumped = false;
|
||||
DumpFrameData(image.data(), source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR, true);
|
||||
|
||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||
}
|
||||
|
||||
// Reset viewport for drawing text
|
||||
|
|
Loading…
Reference in New Issue