diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index 6c64e2ece85c..469b8d2d3978 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -178,9 +178,13 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) buffer_height = present_info.height; } + // Get window state + const int width = m_frame->client_width(); + const int height = m_frame->client_height(); + // Calculate blit coordinates coordi aspect_ratio; - sizei csize(m_frame->client_width(), m_frame->client_height()); + sizei csize(width, height); sizei new_size = csize; if (!g_cfg.video.stretch_to_display_area) @@ -302,14 +306,16 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) gl_state.depth_func(GL_ALWAYS); gl::screen.bind(); - glViewport(0, 0, m_frame->client_width(), m_frame->client_height()); + glViewport(0, 0, width, height); + + m_text_printer.set_scale(m_frame->client_device_pixel_ratio()); - m_text_printer.print_text(0, 0, m_frame->client_width(), m_frame->client_height(), fmt::format("RSX Load: %3d%%", get_load())); - m_text_printer.print_text(0, 18, m_frame->client_width(), m_frame->client_height(), fmt::format("draw calls: %16d", info.stats.draw_calls)); - m_text_printer.print_text(0, 36, m_frame->client_width(), m_frame->client_height(), fmt::format("draw call setup: %11dus", info.stats.setup_time)); - m_text_printer.print_text(0, 54, m_frame->client_width(), m_frame->client_height(), fmt::format("vertex upload time: %8dus", info.stats.vertex_upload_time)); - m_text_printer.print_text(0, 72, m_frame->client_width(), m_frame->client_height(), fmt::format("textures upload time: %6dus", info.stats.textures_upload_time)); - m_text_printer.print_text(0, 90, m_frame->client_width(), m_frame->client_height(), fmt::format("draw call execution: %7dus", info.stats.draw_exec_time)); + m_text_printer.print_text(4, 0, width, height, fmt::format("RSX Load: %3d%%", get_load())); + m_text_printer.print_text(4, 18, width, height, fmt::format("draw calls: %16d", info.stats.draw_calls)); + m_text_printer.print_text(4, 36, width, height, fmt::format("draw call setup: %11dus", info.stats.setup_time)); + m_text_printer.print_text(4, 54, width, height, fmt::format("vertex upload time: %8dus", info.stats.vertex_upload_time)); + m_text_printer.print_text(4, 72, width, height, fmt::format("textures upload time: %6dus", info.stats.textures_upload_time)); + m_text_printer.print_text(4, 90, width, height, fmt::format("draw call execution: %7dus", info.stats.draw_exec_time)); const auto num_dirty_textures = m_gl_texture_cache.get_unreleased_textures_count(); const auto texture_memory_size = m_gl_texture_cache.get_texture_memory_in_use() / (1024 * 1024); @@ -322,10 +328,10 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) const auto num_texture_upload = m_gl_texture_cache.get_texture_upload_calls_this_frame(); const auto num_texture_upload_miss = m_gl_texture_cache.get_texture_upload_misses_this_frame(); const auto texture_upload_miss_ratio = m_gl_texture_cache.get_texture_upload_miss_percentage(); - m_text_printer.print_text(0, 126, m_frame->client_width(), m_frame->client_height(), fmt::format("Unreleased textures: %7d", num_dirty_textures)); - m_text_printer.print_text(0, 144, m_frame->client_width(), m_frame->client_height(), fmt::format("Texture memory: %12dM", texture_memory_size)); - m_text_printer.print_text(0, 162, m_frame->client_width(), m_frame->client_height(), fmt::format("Flush requests: %12d = %2d (%3d%%) hard faults, %2d unavoidable, %2d misprediction(s), %2d speculation(s)", num_flushes, num_misses, cache_miss_ratio, num_unavoidable, num_mispredict, num_speculate)); - m_text_printer.print_text(0, 180, m_frame->client_width(), m_frame->client_height(), fmt::format("Texture uploads: %15u (%u from CPU - %02u%%)", num_texture_upload, num_texture_upload_miss, texture_upload_miss_ratio)); + m_text_printer.print_text(4, 126, width, height, fmt::format("Unreleased textures: %7d", num_dirty_textures)); + m_text_printer.print_text(4, 144, width, height, fmt::format("Texture memory: %12dM", texture_memory_size)); + m_text_printer.print_text(4, 162, width, height, fmt::format("Flush requests: %12d = %2d (%3d%%) hard faults, %2d unavoidable, %2d misprediction(s), %2d speculation(s)", num_flushes, num_misses, cache_miss_ratio, num_unavoidable, num_mispredict, num_speculate)); + m_text_printer.print_text(4, 180, width, height, fmt::format("Texture uploads: %15u (%u from CPU - %02u%%)", num_texture_upload, num_texture_upload_miss, texture_upload_miss_ratio)); } m_frame->flip(m_context); diff --git a/rpcs3/Emu/RSX/GL/GLTextOut.h b/rpcs3/Emu/RSX/GL/GLTextOut.h index 52e5ab1b3440..7edadee0cb66 100644 --- a/rpcs3/Emu/RSX/GL/GLTextOut.h +++ b/rpcs3/Emu/RSX/GL/GLTextOut.h @@ -25,6 +25,8 @@ namespace gl bool initialized = false; bool enabled = false; + double m_scale = 1.0; + void init_program() { std::string vs = @@ -138,11 +140,11 @@ namespace gl char *s = const_cast(text.c_str()); //Y is in raster coordinates: convert to bottom-left origin - y = (target_h - y - 16); + y = ((target_h / m_scale) - y - 16); //Compress [0, w] and [0, h] into range [-1, 1] - float scale_x = 2.f / target_w; - float scale_y = 2.f / target_h; + float scale_x = m_scale * 2.f / target_w; + float scale_y = m_scale * 2.f / target_h; float base_offset = 0.f; shader_offsets.reserve(text.length() * 2); @@ -207,5 +209,11 @@ namespace gl initialized = false; } } + + void set_scale(double scale) + { + // Restrict scale to 2. The dots are gonna be too sparse otherwise. + m_scale = std::min(scale, 2.0); + } }; } diff --git a/rpcs3/Emu/RSX/GSFrameBase.h b/rpcs3/Emu/RSX/GSFrameBase.h index 8eb0c3ebbffc..f68c6d4aa337 100644 --- a/rpcs3/Emu/RSX/GSFrameBase.h +++ b/rpcs3/Emu/RSX/GSFrameBase.h @@ -25,6 +25,7 @@ class GSFrameBase virtual void flip(draw_context_t ctx, bool skip_frame = false) = 0; virtual int client_width() = 0; virtual int client_height() = 0; + virtual double client_device_pixel_ratio() const = 0; virtual display_handle_t handle() const = 0; diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index 4439b1438da5..a5441d24d4bc 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -741,13 +741,15 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) m_text_writer->init(*m_device, vk::get_renderpass(*m_device, key)); } - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 0, direct_fbo->width(), direct_fbo->height(), fmt::format("RSX Load: %3d%%", get_load())); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 18, direct_fbo->width(), direct_fbo->height(), fmt::format("draw calls: %17d", info.stats.draw_calls)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 36, direct_fbo->width(), direct_fbo->height(), fmt::format("draw call setup: %12dus", info.stats.setup_time)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 54, direct_fbo->width(), direct_fbo->height(), fmt::format("vertex upload time: %9dus", info.stats.vertex_upload_time)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 72, direct_fbo->width(), direct_fbo->height(), fmt::format("texture upload time: %8dus", info.stats.textures_upload_time)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 90, direct_fbo->width(), direct_fbo->height(), fmt::format("draw call execution: %8dus", info.stats.draw_exec_time)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 108, direct_fbo->width(), direct_fbo->height(), fmt::format("submit and flip: %12dus", info.stats.flip_time)); + m_text_writer->set_scale(m_frame->client_device_pixel_ratio()); + + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 0, direct_fbo->width(), direct_fbo->height(), fmt::format("RSX Load: %3d%%", get_load())); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 18, direct_fbo->width(), direct_fbo->height(), fmt::format("draw calls: %17d", info.stats.draw_calls)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 36, direct_fbo->width(), direct_fbo->height(), fmt::format("draw call setup: %12dus", info.stats.setup_time)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 54, direct_fbo->width(), direct_fbo->height(), fmt::format("vertex upload time: %9dus", info.stats.vertex_upload_time)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 72, direct_fbo->width(), direct_fbo->height(), fmt::format("texture upload time: %8dus", info.stats.textures_upload_time)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 90, direct_fbo->width(), direct_fbo->height(), fmt::format("draw call execution: %8dus", info.stats.draw_exec_time)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 108, direct_fbo->width(), direct_fbo->height(), fmt::format("submit and flip: %12dus", info.stats.flip_time)); const auto num_dirty_textures = m_texture_cache.get_unreleased_textures_count(); const auto texture_memory_size = m_texture_cache.get_texture_memory_in_use() / (1024 * 1024); @@ -761,11 +763,11 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) const auto num_texture_upload = m_texture_cache.get_texture_upload_calls_this_frame(); const auto num_texture_upload_miss = m_texture_cache.get_texture_upload_misses_this_frame(); const auto texture_upload_miss_ratio = m_texture_cache.get_texture_upload_miss_percentage(); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 144, direct_fbo->width(), direct_fbo->height(), fmt::format("Unreleased textures: %8d", num_dirty_textures)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 162, direct_fbo->width(), direct_fbo->height(), fmt::format("Texture cache memory: %7dM", texture_memory_size)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 180, direct_fbo->width(), direct_fbo->height(), fmt::format("Temporary texture memory: %3dM", tmp_texture_memory_size)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 198, direct_fbo->width(), direct_fbo->height(), fmt::format("Flush requests: %13d = %2d (%3d%%) hard faults, %2d unavoidable, %2d misprediction(s), %2d speculation(s)", num_flushes, num_misses, cache_miss_ratio, num_unavoidable, num_mispredict, num_speculate)); - m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 0, 216, direct_fbo->width(), direct_fbo->height(), fmt::format("Texture uploads: %14u (%u from CPU - %02u%%)", num_texture_upload, num_texture_upload_miss, texture_upload_miss_ratio)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 144, direct_fbo->width(), direct_fbo->height(), fmt::format("Unreleased textures: %8d", num_dirty_textures)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 162, direct_fbo->width(), direct_fbo->height(), fmt::format("Texture cache memory: %7dM", texture_memory_size)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 180, direct_fbo->width(), direct_fbo->height(), fmt::format("Temporary texture memory: %3dM", tmp_texture_memory_size)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 198, direct_fbo->width(), direct_fbo->height(), fmt::format("Flush requests: %13d = %2d (%3d%%) hard faults, %2d unavoidable, %2d misprediction(s), %2d speculation(s)", num_flushes, num_misses, cache_miss_ratio, num_unavoidable, num_mispredict, num_speculate)); + m_text_writer->print_text(*m_current_command_buffer, *direct_fbo, 4, 216, direct_fbo->width(), direct_fbo->height(), fmt::format("Texture uploads: %14u (%u from CPU - %02u%%)", num_texture_upload, num_texture_upload_miss, texture_upload_miss_ratio)); } direct_fbo->release(); diff --git a/rpcs3/Emu/RSX/VK/VKTextOut.h b/rpcs3/Emu/RSX/VK/VKTextOut.h index aaa40af43db9..d7d60f82b7e9 100644 --- a/rpcs3/Emu/RSX/VK/VKTextOut.h +++ b/rpcs3/Emu/RSX/VK/VKTextOut.h @@ -33,6 +33,8 @@ namespace vk u32 m_uniform_buffer_offset = 0; u32 m_uniform_buffer_size = 0; + double m_scale = 1.0; + bool initialized = false; std::unordered_map> m_offsets; @@ -293,12 +295,12 @@ namespace vk char *s = const_cast(text.c_str()); //Y is in raster coordinates: convert to bottom-left origin - y = (target_h - y - 16); + y = ((target_h / m_scale) - y - 16); //Compress [0, w] and [0, h] into range [-1, 1] //Flip Y scaling - float scale_x = +2.f / target_w; - float scale_y = -2.f / target_h; + float scale_x = m_scale * +2.f / target_w; + float scale_y = m_scale * -2.f / target_h; float base_offset = 0.f; shader_offsets.reserve(text.length() * 2); @@ -366,5 +368,11 @@ namespace vk m_descriptor_pool.reset(0); m_used_descriptors = 0; } + + void set_scale(double scale) + { + // Restrict scale to 2. The dots are gonna be too sparse otherwise. + m_scale = std::min(scale, 2.0); + } }; } diff --git a/rpcs3/rpcs3qt/gl_gs_frame.h b/rpcs3/rpcs3qt/gl_gs_frame.h index ab42e660bc56..50f09f634d62 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.h +++ b/rpcs3/rpcs3qt/gl_gs_frame.h @@ -23,5 +23,5 @@ class gl_gs_frame : public gs_frame draw_context_t make_context() override; void set_current(draw_context_t ctx) override; void delete_context(draw_context_t ctx) override; - void flip(draw_context_t context, bool skip_frame=false) override; + void flip(draw_context_t context, bool skip_frame = false) override; }; diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index 89b3e768888d..e68c2bd867fc 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -400,6 +400,11 @@ int gs_frame::client_height() return height() * devicePixelRatio(); } +double gs_frame::client_device_pixel_ratio() const +{ + return devicePixelRatio(); +} + void gs_frame::flip(draw_context_t, bool /*skip_frame*/) { static Timer fps_t; diff --git a/rpcs3/rpcs3qt/gs_frame.h b/rpcs3/rpcs3qt/gs_frame.h index 2c9467764988..c42d35f9c4b5 100644 --- a/rpcs3/rpcs3qt/gs_frame.h +++ b/rpcs3/rpcs3qt/gs_frame.h @@ -90,6 +90,7 @@ class gs_frame : public QWindow, public GSFrameBase void flip(draw_context_t context, bool skip_frame = false) override; int client_width() override; int client_height() override; + double client_device_pixel_ratio() const override; bool event(QEvent* ev) override;