mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
Frontend: Reset/restore GPU state before saving screenshot
Fixes driver crashes in Vulkan.
This commit is contained in:
parent
b94de1924d
commit
58b0e6859a
|
@ -499,9 +499,11 @@ bool System::SaveState(ByteStream* state)
|
||||||
const u32 screenshot_height = 128;
|
const u32 screenshot_height = 128;
|
||||||
|
|
||||||
std::vector<u32> screenshot_buffer;
|
std::vector<u32> screenshot_buffer;
|
||||||
if (m_host_interface->GetDisplay()->WriteDisplayTextureToBuffer(&screenshot_buffer, screenshot_width,
|
m_gpu->ResetGraphicsAPIState();
|
||||||
screenshot_height) &&
|
const bool screenshot_saved =
|
||||||
!screenshot_buffer.empty())
|
m_host_interface->GetDisplay()->WriteDisplayTextureToBuffer(&screenshot_buffer, screenshot_width, screenshot_height);
|
||||||
|
m_gpu->RestoreGraphicsAPIState();
|
||||||
|
if (screenshot_saved && !screenshot_buffer.empty())
|
||||||
{
|
{
|
||||||
header.offset_to_screenshot = static_cast<u32>(state->GetPosition());
|
header.offset_to_screenshot = static_cast<u32>(state->GetPosition());
|
||||||
header.screenshot_width = screenshot_width;
|
header.screenshot_width = screenshot_width;
|
||||||
|
|
|
@ -1947,7 +1947,11 @@ bool CommonHostInterface::SaveScreenshot(const char* filename /* = nullptr */, b
|
||||||
filename = auto_filename.c_str();
|
filename = auto_filename.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_display->WriteDisplayTextureToFile(filename, full_resolution, apply_aspect_ratio))
|
m_system->GetGPU()->ResetGraphicsAPIState();
|
||||||
|
const bool screenshot_saved =
|
||||||
|
m_display->WriteDisplayTextureToFile(filename, full_resolution, apply_aspect_ratio);
|
||||||
|
m_system->GetGPU()->RestoreGraphicsAPIState();
|
||||||
|
if (!screenshot_saved)
|
||||||
{
|
{
|
||||||
AddFormattedOSDMessage(10.0f, "Failed to save screenshot to '%s'", filename);
|
AddFormattedOSDMessage(10.0f, "Failed to save screenshot to '%s'", filename);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue