mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-24 09:39:55 +00:00
rsx: Only transfer framebuffer contents if memory contents are compatible
This commit is contained in:
parent
0de0dded53
commit
7a5c88a8d1
@ -365,16 +365,21 @@ void GLGSRender::end()
|
|||||||
//If ds is not initialized clear it; it seems new depth textures should have depth cleared
|
//If ds is not initialized clear it; it seems new depth textures should have depth cleared
|
||||||
auto copy_rtt_contents = [](gl::render_target *surface)
|
auto copy_rtt_contents = [](gl::render_target *surface)
|
||||||
{
|
{
|
||||||
//Copy data from old contents onto this one
|
if (surface->get_compatible_internal_format() == surface->old_contents->get_compatible_internal_format())
|
||||||
//1. Clip a rectangular region defning the data
|
{
|
||||||
//2. Perform a GPU blit
|
//Copy data from old contents onto this one
|
||||||
u16 parent_w = surface->old_contents->width();
|
//1. Clip a rectangular region defning the data
|
||||||
u16 parent_h = surface->old_contents->height();
|
//2. Perform a GPU blit
|
||||||
u16 copy_w, copy_h;
|
u16 parent_w = surface->old_contents->width();
|
||||||
|
u16 parent_h = surface->old_contents->height();
|
||||||
|
u16 copy_w, copy_h;
|
||||||
|
|
||||||
|
std::tie(std::ignore, std::ignore, copy_w, copy_h) = rsx::clip_region<u16>(parent_w, parent_h, 0, 0, surface->width(), surface->height(), true);
|
||||||
|
glCopyImageSubData(surface->old_contents->id(), GL_TEXTURE_2D, 0, 0, 0, 0, surface->id(), GL_TEXTURE_2D, 0, 0, 0, 0, copy_w, copy_h, 1);
|
||||||
|
surface->set_cleared();
|
||||||
|
}
|
||||||
|
//TODO: download image contents and reupload them or do a memory cast to copy memory contents if not compatible
|
||||||
|
|
||||||
std::tie(std::ignore, std::ignore, copy_w, copy_h) = rsx::clip_region<u16>(parent_w, parent_h, 0, 0, surface->width(), surface->height(), true);
|
|
||||||
glCopyImageSubData(surface->old_contents->id(), GL_TEXTURE_2D, 0, 0, 0, 0, surface->id(), GL_TEXTURE_2D, 0, 0, 0, 0, copy_w, copy_h, 1);
|
|
||||||
surface->set_cleared();
|
|
||||||
surface->old_contents = nullptr;
|
surface->old_contents = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1012,31 +1012,36 @@ void VKGSRender::end()
|
|||||||
{
|
{
|
||||||
auto copy_rtt_contents = [&](vk::render_target* surface)
|
auto copy_rtt_contents = [&](vk::render_target* surface)
|
||||||
{
|
{
|
||||||
const VkImageAspectFlags aspect = surface->attachment_aspect_flag;
|
if (surface->info.format == surface->old_contents->info.format)
|
||||||
|
{
|
||||||
|
const VkImageAspectFlags aspect = surface->attachment_aspect_flag;
|
||||||
|
|
||||||
const u16 parent_w = surface->old_contents->width();
|
const u16 parent_w = surface->old_contents->width();
|
||||||
const u16 parent_h = surface->old_contents->height();
|
const u16 parent_h = surface->old_contents->height();
|
||||||
u16 copy_w, copy_h;
|
u16 copy_w, copy_h;
|
||||||
|
|
||||||
std::tie(std::ignore, std::ignore, copy_w, copy_h) = rsx::clip_region<u16>(parent_w, parent_h, 0, 0, surface->width(), surface->height(), true);
|
std::tie(std::ignore, std::ignore, copy_w, copy_h) = rsx::clip_region<u16>(parent_w, parent_h, 0, 0, surface->width(), surface->height(), true);
|
||||||
|
|
||||||
VkImageSubresourceRange subresource_range = { aspect, 0, 1, 0, 1 };
|
VkImageSubresourceRange subresource_range = { aspect, 0, 1, 0, 1 };
|
||||||
VkImageLayout old_layout = surface->current_layout;
|
VkImageLayout old_layout = surface->current_layout;
|
||||||
|
|
||||||
vk::change_image_layout(*m_current_command_buffer, surface, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresource_range);
|
vk::change_image_layout(*m_current_command_buffer, surface, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresource_range);
|
||||||
vk::change_image_layout(*m_current_command_buffer, surface->old_contents, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, subresource_range);
|
vk::change_image_layout(*m_current_command_buffer, surface->old_contents, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, subresource_range);
|
||||||
|
|
||||||
VkImageCopy copy_rgn;
|
VkImageCopy copy_rgn;
|
||||||
copy_rgn.srcOffset = { 0, 0, 0 };
|
copy_rgn.srcOffset = { 0, 0, 0 };
|
||||||
copy_rgn.dstOffset = { 0, 0, 0 };
|
copy_rgn.dstOffset = { 0, 0, 0 };
|
||||||
copy_rgn.dstSubresource = { aspect, 0, 0, 1 };
|
copy_rgn.dstSubresource = { aspect, 0, 0, 1 };
|
||||||
copy_rgn.srcSubresource = { aspect, 0, 0, 1 };
|
copy_rgn.srcSubresource = { aspect, 0, 0, 1 };
|
||||||
copy_rgn.extent = { copy_w, copy_h, 1 };
|
copy_rgn.extent = { copy_w, copy_h, 1 };
|
||||||
|
|
||||||
vkCmdCopyImage(*m_current_command_buffer, surface->old_contents->value, surface->old_contents->current_layout, surface->value, surface->current_layout, 1, ©_rgn);
|
vkCmdCopyImage(*m_current_command_buffer, surface->old_contents->value, surface->old_contents->current_layout, surface->value, surface->current_layout, 1, ©_rgn);
|
||||||
vk::change_image_layout(*m_current_command_buffer, surface, old_layout, subresource_range);
|
vk::change_image_layout(*m_current_command_buffer, surface, old_layout, subresource_range);
|
||||||
|
|
||||||
|
surface->dirty = false;
|
||||||
|
}
|
||||||
|
//TODO: download image contents and reupload them or do a memory cast to copy memory contents if not compatible
|
||||||
|
|
||||||
surface->dirty = false;
|
|
||||||
surface->old_contents = nullptr;
|
surface->old_contents = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user