From 040a79ddd1794bf9ba09b3f0d09cfad1b993038b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 10 Mar 2026 04:03:17 +0300 Subject: [PATCH] gl: Improve object annotation for renderdoc debugging --- rpcs3/Emu/RSX/GL/GLRenderTargets.cpp | 2 ++ rpcs3/Emu/RSX/GL/GLRenderTargets.h | 5 +++ rpcs3/Emu/RSX/GL/glutils/image.cpp | 52 ++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 18058842aa..a61fb4b365 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -689,6 +689,8 @@ gl::viewable_image* gl::render_target::get_resolve_target_safe(gl::command_conte static_cast(get_internal_format()), format_class() )); + + resolve_surface->set_name(fmt::format("MSAA_Resolve_%u@0x%x", resolve_surface->id(), base_addr)); } return static_cast(resolve_surface.get()); diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index 9b01746a87..ee3bc03956 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -160,6 +160,7 @@ struct gl_render_target_traits std::unique_ptr result(new gl::render_target(width_, height_, samples, static_cast(format.internal_format), RSX_FORMAT_CLASS_COLOR)); + result->set_name(fmt::format("RTV_%u@0x%x", result->id(), address)); result->set_aa_mode(antialias); result->set_native_pitch(static_cast(width) * get_format_block_size_in_bytes(surface_color_format) * result->samples_x); result->set_surface_dimensions(static_cast(width), static_cast(height), static_cast(pitch)); @@ -203,6 +204,7 @@ struct gl_render_target_traits std::unique_ptr result(new gl::render_target(width_, height_, samples, static_cast(format.internal_format), rsx::classify_format(surface_depth_format))); + result->set_name(fmt::format("DSV_%u@0x%x", result->id(), address)); result->set_aa_mode(antialias); result->set_surface_dimensions(static_cast(width), static_cast(height), static_cast(pitch)); result->set_format(surface_depth_format); @@ -238,6 +240,7 @@ struct gl_render_target_traits sink->state_flags = rsx::surface_state_flags::erase_bkgnd; sink->format_info = ref->format_info; + sink->set_name(fmt::format("SINK_%u@0x%x", sink->id(), address)); sink->set_spp(ref->get_spp()); sink->set_native_pitch(static_cast(prev.width) * ref->get_bpp() * ref->samples_x); sink->set_rsx_pitch(ref->get_rsx_pitch()); @@ -325,6 +328,7 @@ struct gl_render_target_traits std::array native_layout = { static_cast(fmt.swizzle.a), static_cast(fmt.swizzle.r), static_cast(fmt.swizzle.g), static_cast(fmt.swizzle.b) }; surface->set_native_component_layout(native_layout); surface->set_format(format); + surface->set_name(fmt::format("RTV_%u@0x%x", surface->id(), address)); int_invalidate_surface_contents(cmd, surface, address, pitch); } @@ -338,6 +342,7 @@ struct gl_render_target_traits usz pitch) { surface->set_format(format); + surface->set_name(fmt::format("DSV_%u@0x%x", surface->id(), address)); int_invalidate_surface_contents(cmd, surface, address, pitch); } diff --git a/rpcs3/Emu/RSX/GL/glutils/image.cpp b/rpcs3/Emu/RSX/GL/glutils/image.cpp index 7dd3442f84..e2f02afdfa 100644 --- a/rpcs3/Emu/RSX/GL/glutils/image.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/image.cpp @@ -19,6 +19,54 @@ namespace gl } } + static const char* gl_type_to_str(texture::type type) + { + switch (type) + { + case texture::type::ubyte: return "GL_UNSIGNED_BYTE"; + case texture::type::ushort: return "GL_UNSIGNED_SHORT"; + case texture::type::uint: return "GL_UNSIGNED_INT"; + case texture::type::ubyte_3_3_2: return "GL_UNSIGNED_BYTE_3_3_2"; + case texture::type::ubyte_2_3_3_rev: return "GL_UNSIGNED_BYTE_2_3_3_REV"; + case texture::type::ushort_5_6_5: return "GL_UNSIGNED_SHORT_5_6_5"; + case texture::type::ushort_5_6_5_rev: return "GL_UNSIGNED_SHORT_5_6_5_REV"; + case texture::type::ushort_4_4_4_4: return "GL_UNSIGNED_SHORT_4_4_4_4"; + case texture::type::ushort_4_4_4_4_rev: return "GL_UNSIGNED_SHORT_4_4_4_4_REV"; + case texture::type::ushort_5_5_5_1: return "GL_UNSIGNED_SHORT_5_5_5_1"; + case texture::type::ushort_1_5_5_5_rev: return "GL_UNSIGNED_SHORT_1_5_5_5_REV"; + case texture::type::uint_8_8_8_8: return "GL_UNSIGNED_INT_8_8_8_8"; + case texture::type::uint_8_8_8_8_rev: return "GL_UNSIGNED_INT_8_8_8_8_REV"; + case texture::type::uint_10_10_10_2: return "GL_UNSIGNED_INT_10_10_10_2"; + case texture::type::uint_2_10_10_10_rev: return "GL_UNSIGNED_INT_2_10_10_10_REV"; + case texture::type::uint_24_8: return "GL_UNSIGNED_INT_24_8"; + case texture::type::float32_uint8: return "GL_FLOAT_32_UNSIGNED_INT_24_8_REV"; + case texture::type::sbyte: return "GL_BYTE"; + case texture::type::sshort: return "GL_SHORT"; + case texture::type::sint: return "GL_INT"; + case texture::type::f16: return "GL_HALF_FLOAT"; + case texture::type::f32: return "GL_FLOAT"; + case texture::type::f64: return "GL_DOUBLE"; + default: return "UNKNOWN"; + } + } + + static const char* gl_format_to_str(texture::format format) + { + switch (format) + { + case texture::format::r: return "GL_RED"; + case texture::format::rg: return "GL_RG"; + case texture::format::rgb: return "GL_RGB"; + case texture::format::rgba: return "GL_RGBA"; + case texture::format::bgr: return "GL_BGR"; + case texture::format::bgra: return "GL_BGRA"; + case texture::format::stencil: return "GL_STENCIL_INDEX"; + case texture::format::depth: return "GL_DEPTH_COMPONENT"; + case texture::format::depth_stencil: return "GL_DEPTH_STENCIL"; + default: return "UNKNOWN"; + } + } + texture::texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLubyte samples, GLenum sized_format, rsx::format_class format_class) { // Upgrade targets for MSAA @@ -248,9 +296,9 @@ namespace gl if (caps.RENDERDOC_debug) { - const auto msg = fmt::format("glGetTextureSubImage('[%u] %s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %d, %p)", + const auto msg = fmt::format("glGetTextureSubImage('[%u] %s', %u, %u, %u, %u, %u, %u, %u, %s, %s, %d, %p)", m_id, m_name.c_str(), level, region.x, region.y, region.z, region.width, region.height, region.depth, - static_cast(format), static_cast(type), s32{ smax }, dst.data()); + gl_format_to_str(format), gl_type_to_str(type), s32{ smax }, dst.data()); push_debug_label(msg); }