MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _send_resource_usage

Method _send_resource_usage

servers/debugger/servers_debugger.cpp:436–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436void ServersDebugger::_send_resource_usage() {
437 ServersDebugger::ResourceUsage usage;
438
439 List<RS::TextureInfo> tinfo;
440 RS::get_singleton()->texture_debug_usage(&tinfo);
441
442 for (const RS::TextureInfo &E : tinfo) {
443 ServersDebugger::ResourceInfo info;
444 info.path = E.path;
445 info.vram = E.bytes;
446 info.id = E.texture;
447
448 switch (E.type) {
449 case RS::TextureType::TEXTURE_TYPE_2D:
450 info.type = "Texture2D";
451 break;
452 case RS::TextureType::TEXTURE_TYPE_3D:
453 info.type = "Texture3D";
454 break;
455 case RS::TextureType::TEXTURE_TYPE_LAYERED:
456 info.type = "TextureLayered";
457 break;
458 }
459
460 String possible_type = _get_resource_type_from_path(E.path);
461 if (!possible_type.is_empty()) {
462 info.type = possible_type;
463 }
464
465 if (E.depth == 0) {
466 info.format = itos(E.width) + "x" + itos(E.height) + " " + Image::get_format_name(E.format);
467 } else {
468 info.format = itos(E.width) + "x" + itos(E.height) + "x" + itos(E.depth) + " " + Image::get_format_name(E.format);
469 }
470 usage.infos.push_back(info);
471 }
472
473 List<RS::MeshInfo> mesh_info;
474 RS::get_singleton()->mesh_debug_usage(&mesh_info);
475
476 for (const RS::MeshInfo &E : mesh_info) {
477 ServersDebugger::ResourceInfo info;
478 info.path = E.path;
479 // We use 64-bit integers to avoid overflow, if for whatever reason, the sum is bigger than 4GB.
480 uint64_t vram = E.vertex_buffer_size + E.attribute_buffer_size + E.skin_buffer_size + E.index_buffer_size + E.blend_shape_buffer_size + E.lod_index_buffers_size;
481 // But can info.vram even hold that, and why is it an int instead of an uint?
482 info.vram = vram;
483
484 // Even though these empty meshes can be indicative of issues somewhere else
485 // for UX reasons, we don't want to show them.
486 if (vram == 0 && E.path.is_empty()) {
487 continue;
488 }
489
490 info.id = E.mesh;
491 info.type = "Mesh";
492 String possible_type = _get_resource_type_from_path(E.path);
493 if (!possible_type.is_empty()) {

Callers 1

_captureMethod · 0.80

Calls 7

itosFunction · 0.85
texture_debug_usageMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45
mesh_debug_usageMethod · 0.45
send_messageMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected