diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-06-16 18:57:12 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-06-16 18:57:12 +0000 |
| commit | 50f26d4c6c75e11ae1cc44aad6c795681de76124 (patch) | |
| tree | b32f2071103c294b8d09486fb47ddb87c42bff2f /Primitives/interface | |
| parent | Reworked dynamic buffer mapping using ring buffers (diff) | |
| download | DiligentCore-50f26d4c6c75e11ae1cc44aad6c795681de76124.tar.gz DiligentCore-50f26d4c6c75e11ae1cc44aad6c795681de76124.zip | |
Reworked vulkan dynamic heap implementation
Diffstat (limited to 'Primitives/interface')
| -rw-r--r-- | Primitives/interface/FormatMessage.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Primitives/interface/FormatMessage.h b/Primitives/interface/FormatMessage.h index 12748474..d0df1472 100644 --- a/Primitives/interface/FormatMessage.h +++ b/Primitives/interface/FormatMessage.h @@ -24,6 +24,7 @@ #pragma once #include <sstream> +#include <iomanip> namespace Diligent { @@ -41,4 +42,34 @@ namespace Diligent FormatMsg( ss, FirstArg ); FormatMsg( ss, RestArgs... ); // recursive call using pack expansion syntax } + + + struct SizeFormatter + { + size_t size = 0; + size_t precision = 0; + size_t ref_size = 0; + }; + + template<typename SSType> + void FormatMsg(SSType &ss, const SizeFormatter& Arg) + { + auto ref_size = Arg.ref_size != 0 ? Arg.ref_size : Arg.size; + if (ref_size >= (1 << 30)) + { + ss << std::fixed << std::setprecision(Arg.precision) << Arg.size / double{ 1 << 30 } << " GB"; + } + else if(ref_size >= (1 << 20)) + { + ss << std::fixed << std::setprecision(Arg.precision) << Arg.size / double{ 1 << 20 } << " MB"; + } + else if (ref_size >= (1 << 10)) + { + ss << std::fixed << std::setprecision(Arg.precision) << Arg.size / double{ 1 << 10 } << " KB"; + } + else + { + ss << Arg.size << (Arg.size > 1 ? " Byte" : " Bytes" ); + } + } }
\ No newline at end of file |
