Skip to content

Commit e74bc30

Browse files
committed
Fix incorrect parameters for layered textures in Video RAM texture memory profiler
1 parent f648de1 commit e74bc30

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

drivers/gles3/storage/texture_storage.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -1389,8 +1389,22 @@ void TextureStorage::texture_debug_usage(List<RS::TextureInfo> *r_info) {
13891389
tinfo.format = t->format;
13901390
tinfo.width = t->alloc_width;
13911391
tinfo.height = t->alloc_height;
1392-
tinfo.depth = t->depth;
13931392
tinfo.bytes = t->total_data_size;
1393+
1394+
switch (t->type) {
1395+
case Texture::TYPE_3D:
1396+
tinfo.depth = t->depth;
1397+
break;
1398+
1399+
case Texture::TYPE_LAYERED:
1400+
tinfo.depth = t->layers;
1401+
break;
1402+
1403+
default:
1404+
tinfo.depth = 0;
1405+
break;
1406+
}
1407+
13941408
r_info->push_back(tinfo);
13951409
}
13961410
}
@@ -1521,7 +1535,11 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image,
15211535
h = MAX(1, h >> 1);
15221536
}
15231537

1524-
texture->total_data_size = tsize;
1538+
if (texture->target == GL_TEXTURE_CUBE_MAP || texture->target == GL_TEXTURE_2D_ARRAY) {
1539+
texture->total_data_size = tsize * texture->layers;
1540+
} else {
1541+
texture->total_data_size = tsize;
1542+
}
15251543

15261544
texture->stored_cube_sides |= (1 << p_layer);
15271545

servers/rendering/renderer_rd/storage_rd/texture_storage.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -1470,8 +1470,24 @@ void TextureStorage::texture_debug_usage(List<RS::TextureInfo> *r_info) {
14701470
tinfo.format = t->format;
14711471
tinfo.width = t->width;
14721472
tinfo.height = t->height;
1473-
tinfo.depth = t->depth;
1474-
tinfo.bytes = Image::get_image_data_size(t->width, t->height, t->format, t->mipmaps);
1473+
tinfo.bytes = Image::get_image_data_size(t->width, t->height, t->format, t->mipmaps > 1);
1474+
1475+
switch (t->type) {
1476+
case TextureType::TYPE_3D:
1477+
tinfo.depth = t->depth;
1478+
tinfo.bytes *= t->depth;
1479+
break;
1480+
1481+
case TextureType::TYPE_LAYERED:
1482+
tinfo.depth = t->layers;
1483+
tinfo.bytes *= t->layers;
1484+
break;
1485+
1486+
default:
1487+
tinfo.depth = 0;
1488+
break;
1489+
}
1490+
14751491
r_info->push_back(tinfo);
14761492
}
14771493
}

servers/rendering_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class RenderingServer : public Object {
176176
uint32_t height;
177177
uint32_t depth;
178178
Image::Format format;
179-
int bytes;
179+
int64_t bytes;
180180
String path;
181181
};
182182

0 commit comments

Comments
 (0)