mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
rsx: Fix XBGR vs XRGB screenshots
This commit is contained in:
parent
7e1b24224d
commit
fd2607ad52
@ -220,14 +220,14 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
|
||||
pack_settings.apply();
|
||||
|
||||
if (gl::get_driver_caps().ARB_dsa_supported)
|
||||
glGetTextureImage(image_to_flip, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer_height * buffer_width * 4, sshot_frame.data());
|
||||
glGetTextureImage(image_to_flip, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer_height * buffer_width * 4, sshot_frame.data());
|
||||
else
|
||||
glGetTextureImageEXT(image_to_flip, GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, sshot_frame.data());
|
||||
glGetTextureImageEXT(image_to_flip, GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, sshot_frame.data());
|
||||
|
||||
if (GLenum err; (err = glGetError()) != GL_NO_ERROR)
|
||||
screenshot.error("Failed to capture image: 0x%x", err);
|
||||
else
|
||||
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height);
|
||||
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height, false);
|
||||
}
|
||||
|
||||
const areai screen_area = coordi({}, { static_cast<int>(buffer_width), static_cast<int>(buffer_height) });
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
virtual display_handle_t handle() const = 0;
|
||||
|
||||
std::atomic<bool> screenshot_toggle = false;
|
||||
virtual void take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height) = 0;
|
||||
virtual void take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) = 0;
|
||||
};
|
||||
|
||||
class GSRender : public rsx::thread
|
||||
|
@ -659,7 +659,8 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
|
||||
memcpy(sshot_frame.data(), src, sshot_size);
|
||||
sshot_vkbuf.unmap();
|
||||
|
||||
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height);
|
||||
const bool is_bgra = image_to_flip->format() == VK_FORMAT_B8G8R8A8_UNORM;
|
||||
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height, is_bgra);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,10 +335,10 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/)
|
||||
}
|
||||
}
|
||||
|
||||
void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height)
|
||||
void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra)
|
||||
{
|
||||
std::thread(
|
||||
[sshot_width, sshot_height](const std::vector<u8> sshot_data)
|
||||
[sshot_width, sshot_height, is_bgra](const std::vector<u8> sshot_data)
|
||||
{
|
||||
std::string screen_path = fs::get_config_dir() + "screenshots/";
|
||||
|
||||
@ -361,9 +361,19 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot
|
||||
const u32* sshot_ptr = reinterpret_cast<const u32*>(sshot_data.data());
|
||||
u32* alpha_ptr = reinterpret_cast<u32*>(sshot_data_alpha.data());
|
||||
|
||||
for (size_t index = 0; index < sshot_data.size() / sizeof(u32); index++)
|
||||
if (is_bgra) [[likely]]
|
||||
{
|
||||
alpha_ptr[index] = ((sshot_ptr[index] & 0xFF) << 16) | (sshot_ptr[index] & 0xFF00) | ((sshot_ptr[index] & 0xFF0000) >> 16) | 0xFF000000;
|
||||
for (size_t index = 0; index < sshot_data.size() / sizeof(u32); index++)
|
||||
{
|
||||
alpha_ptr[index] = ((sshot_ptr[index] & 0xFF) << 16) | (sshot_ptr[index] & 0xFF00) | ((sshot_ptr[index] & 0xFF0000) >> 16) | 0xFF000000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t index = 0; index < sshot_data.size() / sizeof(u32); index++)
|
||||
{
|
||||
alpha_ptr[index] = sshot_ptr[index] | 0xFF000000;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<u8> encoded_png;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
void progress_increment(int delta);
|
||||
void progress_set_limit(int limit);
|
||||
|
||||
void take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height) override;
|
||||
void take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) override;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user