gl: Improve object annotation for renderdoc debugging

This commit is contained in:
kd-11 2026-03-10 04:03:17 +03:00
parent 512eeb7dd2
commit f9dfb96a3a
3 changed files with 57 additions and 2 deletions

View file

@ -689,6 +689,8 @@ gl::viewable_image* gl::render_target::get_resolve_target_safe(gl::command_conte
static_cast<GLenum>(get_internal_format()),
format_class()
));
resolve_surface->set_name(fmt::format("MSAA_Resolve_%u@0x%x", resolve_surface->id(), base_addr));
}
return static_cast<gl::viewable_image*>(resolve_surface.get());

View file

@ -160,6 +160,7 @@ struct gl_render_target_traits
std::unique_ptr<gl::render_target> result(new gl::render_target(width_, height_, samples,
static_cast<GLenum>(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<u32>(width) * get_format_block_size_in_bytes(surface_color_format) * result->samples_x);
result->set_surface_dimensions(static_cast<u16>(width), static_cast<u16>(height), static_cast<u32>(pitch));
@ -203,6 +204,7 @@ struct gl_render_target_traits
std::unique_ptr<gl::render_target> result(new gl::render_target(width_, height_, samples,
static_cast<GLenum>(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<u16>(width), static_cast<u16>(height), static_cast<u32>(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<u32>(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<GLenum, 4> native_layout = { static_cast<GLenum>(fmt.swizzle.a), static_cast<GLenum>(fmt.swizzle.r), static_cast<GLenum>(fmt.swizzle.g), static_cast<GLenum>(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);
}

View file

@ -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<GLenum>(format), static_cast<GLenum>(type), s32{ smax }, dst.data());
gl_format_to_str(format), gl_type_to_str(type), s32{ smax }, dst.data());
push_debug_label(msg);
}