@@ -658,6 +658,21 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
658658 }
659659 }
660660
661+ const bool has_overlay = (m_overlay_manager && m_overlay_manager->has_visible ());
662+ const auto render_overlays = [&](vk::framebuffer_holder* fbo, const areau& area)
663+ {
664+ if (!has_overlay) return ;
665+
666+ // Lock to avoid modification during run-update chain
667+ auto ui_renderer = vk::get_overlay_pass<vk::ui_overlay_renderer>();
668+ std::lock_guard lock (*m_overlay_manager);
669+
670+ for (const auto & view : m_overlay_manager->get_views ())
671+ {
672+ ui_renderer->run (*m_current_command_buffer, area, fbo, single_target_pass, m_texture_upload_buffer_ring_info, *view.get ());
673+ }
674+ };
675+
661676 if (image_to_flip)
662677 {
663678 const bool use_full_rgb_range_output = g_cfg.video .full_rgb_range_output .get ();
@@ -744,17 +759,42 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
744759 copy_info.imageExtent .height = buffer_height;
745760 copy_info.imageExtent .depth = 1 ;
746761
747- image_to_flip->push_layout (*m_current_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
748- vk::copy_image_to_buffer (*m_current_command_buffer, image_to_flip, &sshot_vkbuf, copy_info);
749- image_to_flip->pop_layout (*m_current_command_buffer);
762+ std::unique_ptr<vk::image> tmp_tex;
763+ vk::image* image_to_copy = image_to_flip;
764+
765+ if (g_cfg.video .record_with_overlays && has_overlay)
766+ {
767+ const auto key = vk::get_renderpass_key (m_swapchain->get_surface_format ());
768+ single_target_pass = vk::get_renderpass (*m_device, key);
769+ ensure (single_target_pass != VK_NULL_HANDLE);
770+
771+ tmp_tex = std::make_unique<vk::image>(*m_device, m_device->get_memory_mapping ().device_local , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
772+ image_to_flip->type (), image_to_flip->format (), image_to_flip->width (), image_to_flip->height (), 1 , 1 , image_to_flip->layers (), VK_SAMPLE_COUNT_1_BIT, image_to_flip->current_layout ,
773+ VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
774+ 0 , VMM_ALLOCATION_POOL_UNDEFINED);
775+
776+ const areai rect = areai (0 , 0 , buffer_width, buffer_height);
777+ vk::copy_image (*m_current_command_buffer, image_to_flip, tmp_tex.get (), rect, rect, 1 );
778+
779+ vk::framebuffer_holder* sshot_fbo = vk::get_framebuffer (*m_device, buffer_width, buffer_height, VK_FALSE, single_target_pass, { tmp_tex.get () });
780+ sshot_fbo->add_ref ();
781+ render_overlays (sshot_fbo, areau (rect));
782+ sshot_fbo->release ();
783+
784+ image_to_copy = tmp_tex.get ();
785+ }
786+
787+ image_to_copy->push_layout (*m_current_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
788+ vk::copy_image_to_buffer (*m_current_command_buffer, image_to_copy, &sshot_vkbuf, copy_info);
789+ image_to_copy->pop_layout (*m_current_command_buffer);
750790
751791 flush_command_queue (true );
752792 const auto src = sshot_vkbuf.map (0 , sshot_size);
753793 std::vector<u8 > sshot_frame (sshot_size);
754794 memcpy (sshot_frame.data (), src, sshot_size);
755795 sshot_vkbuf.unmap ();
756796
757- const bool is_bgra = image_to_flip ->format () == VK_FORMAT_B8G8R8A8_UNORM;
797+ const bool is_bgra = image_to_copy ->format () == VK_FORMAT_B8G8R8A8_UNORM;
758798
759799 if (g_user_asked_for_screenshot.exchange (false ))
760800 {
@@ -767,7 +807,6 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
767807 }
768808 }
769809
770- const bool has_overlay = (m_overlay_manager && m_overlay_manager->has_visible ());
771810 if (g_cfg.video .debug_overlay || has_overlay)
772811 {
773812 if (target_layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
@@ -799,17 +838,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
799838
800839 direct_fbo->add_ref ();
801840
802- if (has_overlay)
803- {
804- // Lock to avoid modification during run-update chain
805- auto ui_renderer = vk::get_overlay_pass<vk::ui_overlay_renderer>();
806- std::lock_guard lock (*m_overlay_manager);
807-
808- for (const auto & view : m_overlay_manager->get_views ())
809- {
810- ui_renderer->run (*m_current_command_buffer, areau (aspect_ratio), direct_fbo, single_target_pass, m_texture_upload_buffer_ring_info, *view.get ());
811- }
812- }
841+ render_overlays (direct_fbo, areau (aspect_ratio));
813842
814843 if (g_cfg.video .debug_overlay )
815844 {
0 commit comments