mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-10 12:45:46 +00:00
OGL: Use VideoCommon framedump helpers.
This commit is contained in:
parent
f45ddddf1c
commit
a530708bb1
@ -32,9 +32,7 @@
|
|||||||
#include "VideoBackends/OGL/TextureCache.h"
|
#include "VideoBackends/OGL/TextureCache.h"
|
||||||
#include "VideoBackends/OGL/VertexManager.h"
|
#include "VideoBackends/OGL/VertexManager.h"
|
||||||
|
|
||||||
#if defined(HAVE_LIBAV) || defined(_WIN32)
|
|
||||||
#include "VideoCommon/AVIDump.h"
|
#include "VideoCommon/AVIDump.h"
|
||||||
#endif
|
|
||||||
#include "VideoCommon/BPFunctions.h"
|
#include "VideoCommon/BPFunctions.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/Fifo.h"
|
#include "VideoCommon/Fifo.h"
|
||||||
@ -1340,16 +1338,6 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
|||||||
s_blendMode = newval;
|
s_blendMode = newval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DumpFrame(const std::vector<u8>& data, int w, int h)
|
|
||||||
{
|
|
||||||
#if defined(HAVE_LIBAV) || defined(_WIN32)
|
|
||||||
if (SConfig::GetInstance().m_DumpFrames && !data.empty())
|
|
||||||
{
|
|
||||||
AVIDump::AddFrame(&data[0], w, h);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function has the final picture. We adjust the aspect ratio here.
|
// This function has the final picture. We adjust the aspect ratio here.
|
||||||
void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||||
const EFBRectangle& rc, float Gamma)
|
const EFBRectangle& rc, float Gamma)
|
||||||
@ -1362,11 +1350,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
glDisable(GL_DEBUG_OUTPUT);
|
glDisable(GL_DEBUG_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int w = 0, h = 0;
|
|
||||||
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
|
||||||
!fbWidth || !fbHeight)
|
!fbWidth || !fbHeight)
|
||||||
{
|
{
|
||||||
DumpFrame(frame_data, w, h);
|
RepeatFrameDumpFrame();
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1376,7 +1363,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 (g_ActiveConfig.VirtualXFBEnabled() && (!xfbSourceList || xfbCount == 0))
|
if (g_ActiveConfig.VirtualXFBEnabled() && (!xfbSourceList || xfbCount == 0))
|
||||||
{
|
{
|
||||||
DumpFrame(frame_data, w, h);
|
RepeatFrameDumpFrame();
|
||||||
Core::Callback_VideoCopiedToXFB(false);
|
Core::Callback_VideoCopiedToXFB(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1474,64 +1461,18 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
s_screenshotCompleted.Set();
|
s_screenshotCompleted.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Frame dumps are handled a little differently in Windows
|
if (IsFrameDumping())
|
||||||
#if defined(HAVE_LIBAV) || defined(_WIN32)
|
|
||||||
if (SConfig::GetInstance().m_DumpFrames)
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
|
std::vector<u8> image(flipped_trc.GetWidth() * flipped_trc.GetHeight() * 4);
|
||||||
if (frame_data.empty() || w != flipped_trc.GetWidth() || h != flipped_trc.GetHeight())
|
|
||||||
{
|
|
||||||
w = flipped_trc.GetWidth();
|
|
||||||
h = flipped_trc.GetHeight();
|
|
||||||
frame_data.resize(4 * w * h);
|
|
||||||
}
|
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
glReadPixels(flipped_trc.left, flipped_trc.bottom, w, h, GL_RGBA, GL_UNSIGNED_BYTE,
|
glReadPixels(flipped_trc.left, flipped_trc.bottom, flipped_trc.GetWidth(),
|
||||||
&frame_data[0]);
|
flipped_trc.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.data());
|
||||||
if (w > 0 && h > 0)
|
|
||||||
{
|
|
||||||
if (!bLastFrameDumped)
|
|
||||||
{
|
|
||||||
bAVIDumping = AVIDump::Start(w, h, AVIDump::DumpFormat::FORMAT_RGBA);
|
|
||||||
if (!bAVIDumping)
|
|
||||||
{
|
|
||||||
OSD::AddMessage("AVIDump Start failed", 2000);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
|
||||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h),
|
|
||||||
2000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bAVIDumping)
|
|
||||||
{
|
|
||||||
FlipImageData(&frame_data[0], w, h, 4);
|
|
||||||
AVIDump::AddFrame(&frame_data[0], w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
bLastFrameDumped = true;
|
DumpFrameData(image.data(), flipped_trc.GetWidth(), flipped_trc.GetHeight(),
|
||||||
}
|
AVIDump::DumpFormat::FORMAT_RGBA, true);
|
||||||
else
|
|
||||||
{
|
|
||||||
NOTICE_LOG(VIDEO, "Error reading framebuffer");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (bLastFrameDumped && bAVIDumping)
|
|
||||||
{
|
|
||||||
AVIDump::Stop();
|
|
||||||
std::vector<u8>().swap(frame_data);
|
|
||||||
w = h = 0;
|
|
||||||
bAVIDumping = false;
|
|
||||||
OSD::AddMessage("Stop dumping frames", 2000);
|
|
||||||
}
|
|
||||||
bLastFrameDumped = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Finish up the current frame, print some stats
|
// Finish up the current frame, print some stats
|
||||||
|
|
||||||
SetWindowSize(fbStride, fbHeight);
|
SetWindowSize(fbStride, fbHeight);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user