1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

gl: Add some debug visualization to internally verify consistency

This commit is contained in:
kd-11 2021-06-05 17:27:03 +03:00 committed by kd-11
parent 39815801aa
commit 6ac9e6f9c4
4 changed files with 52 additions and 0 deletions

View File

@ -359,6 +359,8 @@ void GLGSRender::on_exit()
gl::g_typeless_transfer_buffer.remove();
}
gl::debug::g_vis_texture.reset(); // TODO
gl::destroy_pipe_compiler();
m_prog_buffer.clear();

View File

@ -4,6 +4,22 @@
LOG_CHANNEL(screenshot_log, "SCREENSHOT");
namespace gl
{
namespace debug
{
std::unique_ptr<texture> g_vis_texture;
void set_vis_texture(texture* visual)
{
const auto target = static_cast<GLenum>(visual->get_target());
const auto ifmt = static_cast<GLenum>(visual->get_internal_format());
g_vis_texture.reset(new texture(target, visual->width(), visual->height(), 1, 1, ifmt, visual->format_class()));
glCopyImageSubData(visual->id(), target, 0, 0, 0, 0, g_vis_texture->id(), target, 0, 0, 0, 0, visual->width(), visual->height(), 1);
}
}
}
gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf& avconfig)
{
gl::texture* image = nullptr;
@ -334,6 +350,30 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
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));
}
if (gl::debug::g_vis_texture)
{
// Optionally renders a single debug texture to framebuffer.
// Only programmatic access provided at the moment.
// TODO: Migrate to use overlay system. (kd-11)
gl::fbo m_vis_buffer;
m_vis_buffer.create();
m_vis_buffer.bind();
m_vis_buffer.color = gl::debug::g_vis_texture->id();
m_vis_buffer.read_buffer(m_vis_buffer.color);
m_vis_buffer.draw_buffer(m_vis_buffer.color);
const u32 vis_width = 320;
const u32 vis_height = 240;
areai display_view = areai(aspect_ratio).flipped_vertical();
display_view.x1 = display_view.x2 - vis_width;
display_view.y1 = vis_height;
// Blit
const auto src_region = areau{ 0u, 0u, gl::debug::g_vis_texture->width(), gl::debug::g_vis_texture->height() };
m_vis_buffer.blit(gl::screen, static_cast<areai>(src_region), display_view, gl::buffers::color, gl::filter::linear);
m_vis_buffer.remove();
}
m_frame->flip(m_context);
rsx::thread::flip(info);

View File

@ -10,6 +10,11 @@
namespace gl
{
namespace debug
{
extern void set_vis_texture(texture*);
}
buffer g_typeless_transfer_buffer;
GLenum get_target(rsx::texture_dimension_extended type)

View File

@ -119,5 +119,10 @@ namespace gl
void apply_defaults(GLenum default_filter = GL_NEAREST);
};
namespace debug
{
extern std::unique_ptr<texture> g_vis_texture;
}
extern buffer g_typeless_transfer_buffer;
}