summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2015-01-26 02:40:52 +0100
committerPierre Bourdon <delroth@gmail.com>2015-01-26 02:40:52 +0100
commit648a676ab511efa7d95c8beea7463d04037a4df0 (patch)
tree485b5470882b50245dc444eb502d470dadc31c49 /Source/Core/VideoBackends
parent34079a00379d8fb773e570c2d6fbf8750c0cd7b2 (diff)
parent1e809d9c11079be3ed8985dae42f36595767dcb5 (diff)
Merge pull request #1964 from delroth/master
Revert "Merge pull request #1903 from RisingFog/libav"
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/D3D/Render.cpp15
-rw-r--r--Source/Core/VideoBackends/D3D/Render.h1
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp63
3 files changed, 56 insertions, 23 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp
index c3a0aba4f2..23f9ceae2d 100644
--- a/Source/Core/VideoBackends/D3D/Render.cpp
+++ b/Source/Core/VideoBackends/D3D/Render.cpp
@@ -802,7 +802,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
{
s_recordWidth = GetTargetRectangle().GetWidth();
s_recordHeight = GetTargetRectangle().GetHeight();
- bAVIDumping = AVIDump::Start(s_recordWidth, s_recordHeight);
+ bAVIDumping = AVIDump::Start(D3D::hWnd, s_recordWidth, s_recordHeight);
if (!bAVIDumping)
{
PanicAlert("Error dumping frames to AVI.");
@@ -827,7 +827,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
h = s_recordHeight;
}
formatBufferDump((u8*)map.pData, &frame_data[0], s_recordWidth, s_recordHeight, map.RowPitch);
- FlipImageData(&frame_data[0], w, h);
AVIDump::AddFrame(&frame_data[0], GetTargetRectangle().GetWidth(), GetTargetRectangle().GetHeight());
D3D::context->Unmap(s_screenshot_texture, 0);
}
@@ -1280,16 +1279,4 @@ void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, D3DTexture2D
}
}
-void Renderer::FlipImageData(u8 *data, int w, int h, int pixel_width)
-{
- for (int y = 0; y < h / 2; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- for (int delta = 0; delta < pixel_width; ++delta)
- std::swap(data[(y * w + x) * pixel_width + delta], data[((h - 1 - y) * w + x) * pixel_width + delta]);
- }
- }
-}
-
} // namespace DX11
diff --git a/Source/Core/VideoBackends/D3D/Render.h b/Source/Core/VideoBackends/D3D/Render.h
index 47984f6e6b..020dc9d85a 100644
--- a/Source/Core/VideoBackends/D3D/Render.h
+++ b/Source/Core/VideoBackends/D3D/Render.h
@@ -31,7 +31,6 @@ public:
void RestoreCull();
void RenderText(const std::string& text, int left, int top, u32 color) override;
- void FlipImageData(u8 *data, int w, int h, int pixel_width = 3);
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;
u16 BBoxRead(int index) override;
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index d3abafcfc0..019f5d2556 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -35,9 +35,6 @@
#include "VideoBackends/OGL/TextureConverter.h"
#include "VideoBackends/OGL/VertexManager.h"
-#if defined(HAVE_LIBAV) || defined (WIN32)
-#include "VideoCommon/AVIDump.h"
-#endif
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPStructs.h"
#include "VideoCommon/DriverDetails.h"
@@ -53,6 +50,10 @@
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
+#if defined _WIN32 || defined HAVE_LIBAV
+#include "VideoCommon/AVIDump.h"
+#endif
+
void VideoConfig::UpdateProjectionHack()
{
@@ -1417,7 +1418,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
static void DumpFrame(const std::vector<u8>& data, int w, int h)
{
-#if defined(HAVE_LIBAV) || defined (WIN32)
+#if defined(HAVE_LIBAV) || defined(_WIN32)
if (SConfig::GetInstance().m_DumpFrames && !data.empty())
{
AVIDump::AddFrame(&data[0], w, h);
@@ -1537,7 +1538,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// Frame dumping disabled entirely on GLES3
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
{
-#if defined(HAVE_LIBAV) || defined (WIN32)
+#if defined _WIN32 || defined HAVE_LIBAV
if (SConfig::GetInstance().m_DumpFrames)
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
@@ -1554,7 +1555,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
{
if (!bLastFrameDumped)
{
- bAVIDumping = AVIDump::Start(w, h);
+ #ifdef _WIN32
+ bAVIDumping = AVIDump::Start(nullptr, w, h);
+ #else
+ bAVIDumping = AVIDump::Start(w, h);
+ #endif
if (!bAVIDumping)
{
OSD::AddMessage("AVIDump Start failed", 2000);
@@ -1568,8 +1573,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
}
if (bAVIDumping)
{
- FlipImageData(&frame_data[0], w, h);
- AVIDump::AddFrame(&frame_data[0], w, h);
+ #ifndef _WIN32
+ FlipImageData(&frame_data[0], w, h);
+ #endif
+
+ AVIDump::AddFrame(&frame_data[0], w, h);
}
bLastFrameDumped = true;
@@ -1591,6 +1599,45 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
}
bLastFrameDumped = false;
}
+#else
+ if (SConfig::GetInstance().m_DumpFrames)
+ {
+ std::lock_guard<std::mutex> lk(s_criticalScreenshot);
+ std::string movie_file_name;
+ w = GetTargetRectangle().GetWidth();
+ h = GetTargetRectangle().GetHeight();
+ frame_data.resize(3 * w * h);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glReadPixels(GetTargetRectangle().left, GetTargetRectangle().bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, &frame_data[0]);
+
+ if (!bLastFrameDumped)
+ {
+ movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw";
+ File::CreateFullPath(movie_file_name);
+ pFrameDump.Open(movie_file_name, "wb");
+ if (!pFrameDump)
+ {
+ OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
+ }
+ else
+ {
+ OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
+ }
+ }
+ if (pFrameDump)
+ {
+ FlipImageData(&frame_data[0], w, h);
+ pFrameDump.WriteBytes(&frame_data[0], w * 3 * h);
+ pFrameDump.Flush();
+ }
+ bLastFrameDumped = true;
+ }
+ else
+ {
+ if (bLastFrameDumped)
+ pFrameDump.Close();
+ bLastFrameDumped = false;
+ }
#endif
}
// Finish up the current frame, print some stats