D3D12: Use VideoCommon framedump helpers.
This commit is contained in:
parent
64b648f6c8
commit
6b08830a95
|
@ -711,9 +711,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
||||||
!fb_width || !fb_height)
|
!fb_width || !fb_height)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
RepeatFrameDumpFrame();
|
||||||
AVIDump::AddFrame(&frame_data[0], fb_width, fb_height);
|
|
||||||
|
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -723,9 +721,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
FramebufferManager::GetXFBSource(xfb_addr, fb_stride, fb_height, &xfb_count);
|
FramebufferManager::GetXFBSource(xfb_addr, fb_stride, fb_height, &xfb_count);
|
||||||
if ((!xfb_source_list || xfb_count == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
if ((!xfb_source_list || xfb_count == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
|
RepeatFrameDumpFrame();
|
||||||
AVIDump::AddFrame(&frame_data[0], fb_width, fb_height);
|
|
||||||
|
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -832,7 +828,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump frames
|
// Dump frames
|
||||||
if (SConfig::GetInstance().m_DumpFrames)
|
if (IsFrameDumping())
|
||||||
{
|
{
|
||||||
if (!s_screenshot_texture)
|
if (!s_screenshot_texture)
|
||||||
CreateScreenshotTexture();
|
CreateScreenshotTexture();
|
||||||
|
@ -865,51 +861,19 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
|
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
if (!bLastFrameDumped)
|
void* screenshot_texture_map;
|
||||||
{
|
D3D12_RANGE read_range = {0, dst_location.PlacedFootprint.Footprint.RowPitch * source_height};
|
||||||
bAVIDumping = AVIDump::Start(source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR);
|
CheckHR(s_screenshot_texture->Map(0, &read_range, &screenshot_texture_map));
|
||||||
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);
|
// TODO: This convertion is not needed. Get rid of it.
|
||||||
}
|
std::vector<u8> image(source_width * source_height * 3);
|
||||||
}
|
formatBufferDump(static_cast<u8*>(screenshot_texture_map), image.data(), source_width,
|
||||||
if (bAVIDumping)
|
source_height, dst_location.PlacedFootprint.Footprint.RowPitch);
|
||||||
{
|
|
||||||
if (frame_data.capacity() != 3 * source_width * source_height)
|
|
||||||
frame_data.resize(3 * source_width * source_height);
|
|
||||||
|
|
||||||
void* screenshot_texture_map;
|
DumpFrameData(image.data(), source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR, true);
|
||||||
D3D12_RANGE read_range = {0, dst_location.PlacedFootprint.Footprint.RowPitch * source_height};
|
|
||||||
CheckHR(s_screenshot_texture->Map(0, &read_range, &screenshot_texture_map));
|
|
||||||
formatBufferDump(static_cast<u8*>(screenshot_texture_map), &frame_data[0], source_width,
|
|
||||||
source_height, dst_location.PlacedFootprint.Footprint.RowPitch);
|
|
||||||
|
|
||||||
D3D12_RANGE write_range = {};
|
D3D12_RANGE write_range = {};
|
||||||
s_screenshot_texture->Unmap(0, &write_range);
|
s_screenshot_texture->Unmap(0, &write_range);
|
||||||
|
|
||||||
FlipImageData(&frame_data[0], source_width, source_height);
|
|
||||||
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
|
||||||
}
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue