mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Revert "Be less dumb."
Revert "Actually, filename really does need to be a parameter because of some random debug thing." Revert "fix non-HAVE_WX case" Revert "Handle screenshot saving in RenderBase. Removes dependency on D3DX11 for screenshots (texture dumping is still broken)." This reverts commits00fe5057f1
,74b5fb3ab4
,cd46138d29
and5f72542e06
because taking screenshots in D3D still crashed for me so there was no point in the code changes (which I found ugly anyway).
This commit is contained in:
@ -680,7 +680,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::TakeScreenshot(const TargetRectangle &rc, std::string filename)
|
||||
bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle& rc)
|
||||
{
|
||||
if (!s_screenshot_texture)
|
||||
CreateScreenshotTexture(rc);
|
||||
@ -689,26 +689,34 @@ void Renderer::TakeScreenshot(const TargetRectangle &rc, std::string filename)
|
||||
D3D11_BOX box = CD3D11_BOX(rc.left, rc.top, 0, rc.right, rc.bottom, 1);
|
||||
D3D::context->CopySubresourceRegion(s_screenshot_texture, 0, 0, 0, 0, (ID3D11Resource*)D3D::GetBackBuffer()->GetTex(), 0, &box);
|
||||
|
||||
u8* __restrict dest = (u8*) malloc(rc.GetWidth() * rc.GetHeight() * 3);
|
||||
|
||||
// D3DX11SaveTextureToFileA doesn't allow us to ignore the alpha channel, so we need to strip it out ourselves
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ_WRITE, 0, &map);
|
||||
u8* src = (u8*) map.pData;
|
||||
for (int y = 0; y < rc.GetHeight(); ++y)
|
||||
for (unsigned int y = 0; y < rc.GetHeight(); ++y)
|
||||
{
|
||||
u8* __restrict row = src;
|
||||
for (int x = 0; x < rc.GetWidth(); ++x)
|
||||
u8* ptr = (u8*)map.pData + y * map.RowPitch + 3;
|
||||
for (unsigned int x = 0; x < rc.GetWidth(); ++x)
|
||||
{
|
||||
*dest++ = *row++;
|
||||
*dest++ = *row++;
|
||||
*dest++ = *row++;
|
||||
row++;
|
||||
*ptr = 0xFF;
|
||||
ptr += 4;
|
||||
}
|
||||
src += map.RowPitch;
|
||||
}
|
||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||
|
||||
SaveScreenshot(dest, rc.GetWidth(), rc.GetHeight(), filename);
|
||||
// ready to be saved
|
||||
//HRESULT hr = PD3DX11SaveTextureToFileA(D3D::context, s_screenshot_texture, D3DX11_IFF_PNG, filename.c_str());
|
||||
HRESULT hr = 0;
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
OSD::AddMessage(StringFromFormat("Saved %i x %i %s", rc.GetWidth(),
|
||||
rc.GetHeight(), filename.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
OSD::AddMessage(StringFromFormat("Error saving %s", filename.c_str()));
|
||||
}
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void formatBufferDump(const u8* in, u8* out, int w, int h, int p)
|
||||
@ -846,7 +854,7 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangle& r
|
||||
// done with drawing the game stuff, good moment to save a screenshot
|
||||
if (s_bScreenshot)
|
||||
{
|
||||
TakeScreenshot(GetTargetRectangle(), s_sScreenshotName);
|
||||
SaveScreenshot(s_sScreenshotName, GetTargetRectangle());
|
||||
s_bScreenshot = false;
|
||||
}
|
||||
|
||||
|
@ -48,10 +48,9 @@ public:
|
||||
|
||||
void UpdateViewport();
|
||||
|
||||
static void TakeScreenshot(const TargetRectangle &rc, std::string filename);
|
||||
bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc);
|
||||
|
||||
static bool CheckForResize();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user