MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DumpResourcesToLog

Method DumpResourcesToLog

Source/Engine/Graphics/GPUDevice.cpp:499–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499void GPUDevice::DumpResourcesToLog() const
500{
501 StringBuilder output;
502 _resourcesLock.Lock();
503
504 output.AppendFormat(TEXT("GPU Resources dump. Count: {0}, total GPU memory used: {1}"), _resources.Count(), Utilities::BytesToText(GetMemoryUsage()));
505 output.AppendLine();
506 output.AppendLine();
507
508 const bool printTypes[(int32)GPUResourceType::MAX] =
509 {
510 true, // RenderTarget
511 true, // Texture
512 true, // CubeTexture
513 true, // VolumeTexture
514 true, // Buffer
515 false, // Shader
516 false, // PipelineState
517 false, // Descriptor
518 false, // Query
519 false, // Sampler
520 };
521 for (int32 typeIndex = 0; typeIndex < (int32)GPUResourceType::MAX; typeIndex++)
522 {
523 const auto type = static_cast<GPUResourceType>(typeIndex);
524 const auto printType = printTypes[typeIndex];
525
526 // Get resource sof a given type
527 uint64 memUsage = 0;
528 struct Resource
529 {
530 const GPUResource* Object;
531 uint64 MemoryUsage;
532
533 bool operator<(const Resource& other) const
534 {
535 if (MemoryUsage != other.MemoryUsage)
536 return MemoryUsage > other.MemoryUsage;
537#if GPU_ENABLE_RESOURCE_NAMING
538 return Object->GetName().Compare(other.Object->GetName()) > 0;
539#else
540 return (uintptr)Object < (uintptr)other.Object;
541#endif
542 }
543 };
544 Array<Resource> resources;
545 for (int32 i = 0; i < _resources.Count(); i++)
546 {
547 const GPUResource* resource = _resources[i];
548 if (resource->GetResourceType() == type && resource->GetMemoryUsage() != 0)
549 {
550 resources.Add({ resource, resource->GetMemoryUsage() });
551 }
552 }
553 if (resources.IsEmpty())
554 continue;
555 output.AppendFormat(TEXT("> {0}:"), ScriptingEnum::ToString(type));
556 output.AppendLine();

Callers 1

DumpResourcesMethod · 0.80

Calls 15

BytesToTextFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
ToStringViewMethod · 0.80
ToStringFunction · 0.70
QuickSortFunction · 0.50
CountMethod · 0.45
GetResourceTypeMethod · 0.45
GetMemoryUsageMethod · 0.45
AddMethod · 0.45
IsEmptyMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected