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()) ||
|
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
||||||
!fbWidth || !fbHeight)
|
!fbWidth || !fbHeight)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
RepeatFrameDumpFrame();
|
||||||
AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
|
|
||||||
|
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -780,9 +778,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||||
FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount);
|
FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount);
|
||||||
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
RepeatFrameDumpFrame();
|
||||||
AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
|
|
||||||
|
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -877,7 +873,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump frames
|
// Dump frames
|
||||||
if (SConfig::GetInstance().m_DumpFrames)
|
if (IsFrameDumping())
|
||||||
{
|
{
|
||||||
if (!s_screenshot_texture)
|
if (!s_screenshot_texture)
|
||||||
CreateScreenshotTexture();
|
CreateScreenshotTexture();
|
||||||
|
@ -888,48 +884,18 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||||
D3D::context->CopySubresourceRegion(s_screenshot_texture, 0, 0, 0, 0,
|
D3D::context->CopySubresourceRegion(s_screenshot_texture, 0, 0, 0, 0,
|
||||||
(ID3D11Resource*)D3D::GetBackBuffer()->GetTex(), 0,
|
(ID3D11Resource*)D3D::GetBackBuffer()->GetTex(), 0,
|
||||||
&source_box);
|
&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;
|
D3D11_MAPPED_SUBRESOURCE map;
|
||||||
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
||||||
|
|
||||||
if (frame_data.capacity() != 3 * source_width * source_height)
|
// TODO: This convertion is not needed. Get rid of it.
|
||||||
frame_data.resize(3 * source_width * source_height);
|
std::vector<u8> image(source_width * source_height * 3);
|
||||||
|
formatBufferDump((u8*)map.pData, image.data(), source_width, source_height, map.RowPitch);
|
||||||
|
|
||||||
|
DumpFrameData(image.data(), source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR, true);
|
||||||
|
|
||||||
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);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset viewport for drawing text
|
// Reset viewport for drawing text
|
||||||
D3D11_VIEWPORT vp =
|
D3D11_VIEWPORT vp =
|
||||||
|
|
Loading…
Reference in New Issue