[Base] Add user-literals for several memory sizes

Rather than using `n * 1024 * 1024`, this adds a convenient `_MiB`/`_KiB` user-literal to the new `literals.h` header to concisely describe units of memory in a much more readable way. Any other useful literals can be added to this header. These literals exist in the `xe::literals` namespace so they are opt-in, similar to `std::chrono` literals, and require a `using namespace xe::literals` statement to utilize it within the current scope.

I've done a pass through the codebase to replace trivial instances of `1024 * 1024 * ...` expressions being used but avoided anything that added additional casting complexity from `size_t` to `uint32_t` and such to keep this commit concise.
This commit is contained in:
Wunkolo
2021-12-30 17:25:30 -08:00
committed by Rick Gibbed
parent b64b4c6761
commit 1a8068b151
19 changed files with 109 additions and 25 deletions

View File

@@ -13,9 +13,13 @@
#include <cstddef>
#include <cstdint>
#include "xenia/base/literals.h"
namespace xe {
namespace ui {
using namespace xe::literals;
// Submission index is the fence value or a value derived from it (if reclaiming
// less often than once per fence value, for instance).
@@ -23,7 +27,7 @@ class GraphicsUploadBufferPool {
public:
// Taken from the Direct3D 12 MiniEngine sample (LinearAllocator
// kCpuAllocatorPageSize). Large enough for most cases.
static constexpr size_t kDefaultPageSize = 2 * 1024 * 1024;
static constexpr size_t kDefaultPageSize = 2_MiB;
virtual ~GraphicsUploadBufferPool();