From c84616c2d2ab9c4af8c2020c17bb9c9a2c14a47f Mon Sep 17 00:00:00 2001 From: clayjohn Date: Wed, 15 May 2024 16:30:19 -0700 Subject: [PATCH] Increase coverage of VRAM debugger and add support to RD backends --- drivers/gles3/storage/texture_storage.cpp | 2 +- modules/noise/noise_texture_2d.cpp | 1 + scene/resources/gradient_texture.cpp | 2 ++ .../renderer_rd/storage_rd/texture_storage.cpp | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 6f32e4d49d3..82513aa6095 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1391,7 +1391,7 @@ void TextureStorage::texture_debug_usage(List *r_info) { tinfo.format = t->format; tinfo.width = t->alloc_width; tinfo.height = t->alloc_height; - tinfo.depth = 0; + tinfo.depth = t->depth; tinfo.bytes = t->total_data_size; r_info->push_back(tinfo); } diff --git a/modules/noise/noise_texture_2d.cpp b/modules/noise/noise_texture_2d.cpp index 0443fec4a09..0960b2ad360 100644 --- a/modules/noise/noise_texture_2d.cpp +++ b/modules/noise/noise_texture_2d.cpp @@ -119,6 +119,7 @@ void NoiseTexture2D::_set_texture_image(const Ref &p_image) { } else { texture = RS::get_singleton()->texture_2d_create(p_image); } + RS::get_singleton()->texture_set_path(texture, get_path()); } emit_changed(); } diff --git a/scene/resources/gradient_texture.cpp b/scene/resources/gradient_texture.cpp index 327a99c6ad9..68ff5e9bd85 100644 --- a/scene/resources/gradient_texture.cpp +++ b/scene/resources/gradient_texture.cpp @@ -137,6 +137,7 @@ void GradientTexture1D::_update() { texture = RS::get_singleton()->texture_2d_create(image); } } + RS::get_singleton()->texture_set_path(texture, get_path()); } void GradientTexture1D::set_width(int p_width) { @@ -276,6 +277,7 @@ void GradientTexture2D::_update() { } else { texture = RS::get_singleton()->texture_2d_create(image); } + RS::get_singleton()->texture_set_path(texture, get_path()); } float GradientTexture2D::_get_gradient_offset_at(int x, int y) const { diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index af30a328666..b577d1a45b2 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -1457,6 +1457,23 @@ void TextureStorage::texture_set_detect_roughness_callback(RID p_texture, RS::Te } void TextureStorage::texture_debug_usage(List *r_info) { + List textures; + texture_owner.get_owned_list(&textures); + + for (List::Element *E = textures.front(); E; E = E->next()) { + Texture *t = texture_owner.get_or_null(E->get()); + if (!t) { + continue; + } + RS::TextureInfo tinfo; + tinfo.path = t->path; + tinfo.format = t->format; + tinfo.width = t->width; + tinfo.height = t->height; + tinfo.depth = t->depth; + tinfo.bytes = Image::get_image_data_size(t->width, t->height, t->format, t->mipmaps); + r_info->push_back(tinfo); + } } void TextureStorage::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) { @@ -3043,6 +3060,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { texture_2d_placeholder_initialize(rt->texture); Texture *tex = get_texture(rt->texture); tex->is_render_target = true; + tex->path = "Render Target (Internal)"; } _clear_render_target(rt);