diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index 7d1ac4e1cb..7608c03e42 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -276,6 +276,16 @@ namespace rsx return format_info.gcm_depth_format; } + u32 get_gcm_format() const + { + return + ( + is_depth_surface() ? + get_compatible_gcm_format(format_info.gcm_depth_format).first : + get_compatible_gcm_format(format_info.gcm_color_format).first + ); + } + bool dirty() const { return (state_flags != rsx::surface_state_flags::ready) || !old_contents.empty(); diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index d6617cd5d5..07b09b7105 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -454,9 +454,6 @@ void gl::render_target::clear_memory(gl::command_context& cmd) void gl::render_target::load_memory(gl::command_context& cmd) { const bool is_swizzled = (raster_type == rsx::surface_raster_type::swizzle); - const u32 gcm_format = is_depth_surface() ? - get_compatible_gcm_format(format_info.gcm_depth_format).first : - get_compatible_gcm_format(format_info.gcm_color_format).first; rsx::subresource_layout subres{}; subres.width_in_block = subres.width_in_texel = surface_width * samples_x; @@ -468,12 +465,12 @@ void gl::render_target::load_memory(gl::command_context& cmd) // TODO: MSAA support if (g_cfg.video.resolution_scale_percent == 100 && spp == 1) [[likely]] { - gl::upload_texture(this, gcm_format, is_swizzled, { subres }); + gl::upload_texture(this, get_gcm_format(), is_swizzled, { subres }); } else { - auto tmp = std::make_unique(GL_TEXTURE_2D, subres.width_in_block, subres.height_in_block, 1, 1, static_cast(get_internal_format())); - gl::upload_texture(tmp.get(), gcm_format, is_swizzled, { subres }); + auto tmp = std::make_unique(GL_TEXTURE_2D, subres.width_in_block, subres.height_in_block, 1, 1, static_cast(get_internal_format()), format_class()); + gl::upload_texture(tmp.get(), get_gcm_format(), is_swizzled, { subres }); gl::g_hw_blitter->scale_image(cmd, tmp.get(), this, { 0, 0, subres.width_in_block, subres.height_in_block }, @@ -542,6 +539,7 @@ void gl::render_target::memory_barrier(gl::command_context& cmd, rsx::surface_ac typeless_info.src_is_typeless = true; typeless_info.src_context = rsx::texture_upload_context::framebuffer_storage; typeless_info.src_native_format_override = static_cast(get_internal_format()); + typeless_info.src_gcm_format = src_texture->get_gcm_format(); typeless_info.src_scaling_hint = static_cast(src_bpp) / dst_bpp; } } diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index 07f4cd9f33..4556228422 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -233,11 +233,7 @@ namespace vk void load_memory(vk::command_buffer& cmd) { auto& upload_heap = *vk::get_upload_heap(); - const bool is_swizzled = (raster_type == rsx::surface_raster_type::swizzle); - const u32 gcm_format = is_depth_surface() ? - get_compatible_gcm_format(format_info.gcm_depth_format).first : - get_compatible_gcm_format(format_info.gcm_color_format).first; rsx::subresource_layout subres{}; subres.width_in_block = subres.width_in_texel = surface_width * samples_x; @@ -249,7 +245,7 @@ namespace vk if (g_cfg.video.resolution_scale_percent == 100 && spp == 1) [[likely]] { push_layout(cmd, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - vk::copy_mipmaped_image_using_buffer(cmd, this, { subres }, gcm_format, is_swizzled, 1, aspect(), upload_heap, rsx_pitch); + vk::copy_mipmaped_image_using_buffer(cmd, this, { subres }, get_gcm_format(), is_swizzled, 1, aspect(), upload_heap, rsx_pitch); pop_layout(cmd); } else @@ -269,12 +265,12 @@ namespace vk } else { - content = vk::get_typeless_helper(format(), rsx::classify_format(gcm_format), subres.width_in_block, subres.height_in_block); + content = vk::get_typeless_helper(format(), format_class(), subres.width_in_block, subres.height_in_block); content->change_layout(cmd, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); } // Load Cell data into temp buffer - vk::copy_mipmaped_image_using_buffer(cmd, content, { subres }, gcm_format, is_swizzled, 1, aspect(), upload_heap, rsx_pitch); + vk::copy_mipmaped_image_using_buffer(cmd, content, { subres }, get_gcm_format(), is_swizzled, 1, aspect(), upload_heap, rsx_pitch); // Write into final image if (content != final_dst) @@ -520,6 +516,7 @@ namespace vk typeless_info.src_is_typeless = true; typeless_info.src_context = rsx::texture_upload_context::framebuffer_storage; typeless_info.src_native_format_override = static_cast(info.format); + typeless_info.src_gcm_format = src_texture->get_gcm_format(); typeless_info.src_scaling_hint = f32(src_bpp) / dst_bpp; }