[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:
parent
b64b4c6761
commit
1a8068b151
|
@ -60,7 +60,7 @@ void* Arena::Alloc(size_t size, size_t align) {
|
||||||
|
|
||||||
if (active_chunk_) {
|
if (active_chunk_) {
|
||||||
if (active_chunk_->capacity - active_chunk_->offset <
|
if (active_chunk_->capacity - active_chunk_->offset <
|
||||||
size + get_padding() + 4096) {
|
size + get_padding() + 4_KiB) {
|
||||||
Chunk* next = active_chunk_->next;
|
Chunk* next = active_chunk_->next;
|
||||||
if (!next) {
|
if (!next) {
|
||||||
assert_true(size + get_padding() < chunk_size_,
|
assert_true(size + get_padding() < chunk_size_,
|
||||||
|
|
|
@ -14,11 +14,15 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
class Arena {
|
class Arena {
|
||||||
public:
|
public:
|
||||||
explicit Arena(size_t chunk_size = 4 * 1024 * 1024);
|
explicit Arena(size_t chunk_size = 4_MiB);
|
||||||
~Arena();
|
~Arena();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2021 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XENIA_BASE_LITERALS_H_
|
||||||
|
#define XENIA_BASE_LITERALS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace xe::literals {
|
||||||
|
|
||||||
|
constexpr size_t operator""_KiB(unsigned long long int x) {
|
||||||
|
return 1024ULL * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr size_t operator""_MiB(unsigned long long int x) {
|
||||||
|
return 1024_KiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr size_t operator""_GiB(unsigned long long int x) {
|
||||||
|
return 1024_MiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr size_t operator""_TiB(unsigned long long int x) {
|
||||||
|
return 1024_GiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr size_t operator""_PiB(unsigned long long int x) {
|
||||||
|
return 1024_TiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace xe::literals
|
||||||
|
|
||||||
|
#endif // XENIA_BASE_LITERALS_H_
|
|
@ -25,6 +25,7 @@
|
||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
#include "xenia/base/debugging.h"
|
#include "xenia/base/debugging.h"
|
||||||
#include "xenia/base/filesystem.h"
|
#include "xenia/base/filesystem.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/memory.h"
|
#include "xenia/base/memory.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
|
@ -59,6 +60,7 @@ DEFINE_int32(
|
||||||
"Logging");
|
"Logging");
|
||||||
|
|
||||||
namespace dp = disruptorplus;
|
namespace dp = disruptorplus;
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ struct LogLine {
|
||||||
char prefix_char;
|
char prefix_char;
|
||||||
};
|
};
|
||||||
|
|
||||||
thread_local char thread_log_buffer_[64 * 1024];
|
thread_local char thread_log_buffer_[64_KiB];
|
||||||
|
|
||||||
FileLogSink::~FileLogSink() {
|
FileLogSink::~FileLogSink() {
|
||||||
if (file_) {
|
if (file_) {
|
||||||
|
@ -234,7 +236,7 @@ class Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const size_t kBufferSize = 8 * 1024 * 1024;
|
static const size_t kBufferSize = 8_MiB;
|
||||||
uint8_t buffer_[kBufferSize];
|
uint8_t buffer_[kBufferSize];
|
||||||
|
|
||||||
static const size_t kBlockSize = 256;
|
static const size_t kBlockSize = 256;
|
||||||
|
|
|
@ -13,12 +13,15 @@
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
StringBuffer::StringBuffer(size_t initial_capacity) {
|
StringBuffer::StringBuffer(size_t initial_capacity) {
|
||||||
buffer_capacity_ = std::max(initial_capacity, static_cast<size_t>(16 * 1024));
|
buffer_capacity_ = std::max(initial_capacity, static_cast<size_t>(16_KiB));
|
||||||
buffer_ = reinterpret_cast<char*>(std::malloc(buffer_capacity_));
|
buffer_ = reinterpret_cast<char*>(std::malloc(buffer_capacity_));
|
||||||
assert_not_null(buffer_);
|
assert_not_null(buffer_);
|
||||||
buffer_[0] = 0;
|
buffer_[0] = 0;
|
||||||
|
@ -40,7 +43,7 @@ void StringBuffer::Grow(size_t additional_length) {
|
||||||
}
|
}
|
||||||
size_t old_capacity = buffer_capacity_;
|
size_t old_capacity = buffer_capacity_;
|
||||||
size_t new_capacity =
|
size_t new_capacity =
|
||||||
std::max(xe::round_up(buffer_offset_ + additional_length, 16 * 1024),
|
std::max(xe::round_up(buffer_offset_ + additional_length, 16_KiB),
|
||||||
old_capacity * 2);
|
old_capacity * 2);
|
||||||
auto new_buffer = std::realloc(buffer_, new_capacity);
|
auto new_buffer = std::realloc(buffer_, new_capacity);
|
||||||
assert_not_null(new_buffer);
|
assert_not_null(new_buffer);
|
||||||
|
|
|
@ -824,7 +824,7 @@ TEST_CASE("Create and Run Thread", "[thread]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("16kb stack size") {
|
SECTION("16kb stack size") {
|
||||||
params.stack_size = 16 * 1024 * 1024;
|
params.stack_size = 16_MiB;
|
||||||
thread = Thread::Create(params, [] {
|
thread = Thread::Create(params, [] {
|
||||||
Thread::Exit(-1);
|
Thread::Exit(-1);
|
||||||
FAIL("Function must not return");
|
FAIL("Function must not return");
|
||||||
|
|
|
@ -25,11 +25,14 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace threading {
|
namespace threading {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
#if XE_PLATFORM_ANDROID
|
#if XE_PLATFORM_ANDROID
|
||||||
void AndroidInitialize();
|
void AndroidInitialize();
|
||||||
void AndroidShutdown();
|
void AndroidShutdown();
|
||||||
|
@ -368,7 +371,7 @@ struct ThreadPriority {
|
||||||
class Thread : public WaitHandle {
|
class Thread : public WaitHandle {
|
||||||
public:
|
public:
|
||||||
struct CreationParameters {
|
struct CreationParameters {
|
||||||
size_t stack_size = 4 * 1024 * 1024;
|
size_t stack_size = 4_MiB;
|
||||||
bool create_suspended = false;
|
bool create_suspended = false;
|
||||||
int32_t initial_priority = 0;
|
int32_t initial_priority = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "third_party/fmt/include/fmt/format.h"
|
#include "third_party/fmt/include/fmt/format.h"
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/clock.h"
|
#include "xenia/base/clock.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/memory.h"
|
#include "xenia/base/memory.h"
|
||||||
|
@ -31,6 +32,8 @@ namespace cpu {
|
||||||
namespace backend {
|
namespace backend {
|
||||||
namespace x64 {
|
namespace x64 {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
X64CodeCache::X64CodeCache() = default;
|
X64CodeCache::X64CodeCache() = default;
|
||||||
|
|
||||||
X64CodeCache::~X64CodeCache() {
|
X64CodeCache::~X64CodeCache() {
|
||||||
|
@ -227,7 +230,7 @@ void X64CodeCache::PlaceGuestCode(uint32_t guest_address, void* machine_code,
|
||||||
old_commit_mark = generated_code_commit_mark_;
|
old_commit_mark = generated_code_commit_mark_;
|
||||||
if (high_mark <= old_commit_mark) break;
|
if (high_mark <= old_commit_mark) break;
|
||||||
|
|
||||||
new_commit_mark = old_commit_mark + 16 * 1024 * 1024;
|
new_commit_mark = old_commit_mark + 16_MiB;
|
||||||
if (generated_code_execute_base_ == generated_code_write_base_) {
|
if (generated_code_execute_base_ == generated_code_write_base_) {
|
||||||
xe::memory::AllocFixed(generated_code_execute_base_, new_commit_mark,
|
xe::memory::AllocFixed(generated_code_execute_base_, new_commit_mark,
|
||||||
xe::memory::AllocationType::kCommit,
|
xe::memory::AllocationType::kCommit,
|
||||||
|
@ -310,7 +313,7 @@ uint32_t X64CodeCache::PlaceData(const void* data, size_t length) {
|
||||||
old_commit_mark = generated_code_commit_mark_;
|
old_commit_mark = generated_code_commit_mark_;
|
||||||
if (high_mark <= old_commit_mark) break;
|
if (high_mark <= old_commit_mark) break;
|
||||||
|
|
||||||
new_commit_mark = old_commit_mark + 16 * 1024 * 1024;
|
new_commit_mark = old_commit_mark + 16_MiB;
|
||||||
if (generated_code_execute_base_ == generated_code_write_base_) {
|
if (generated_code_execute_base_ == generated_code_write_base_) {
|
||||||
xe::memory::AllocFixed(generated_code_execute_base_, new_commit_mark,
|
xe::memory::AllocFixed(generated_code_execute_base_, new_commit_mark,
|
||||||
xe::memory::AllocationType::kCommit,
|
xe::memory::AllocationType::kCommit,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/atomic.h"
|
#include "xenia/base/atomic.h"
|
||||||
#include "xenia/base/debugging.h"
|
#include "xenia/base/debugging.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/memory.h"
|
#include "xenia/base/memory.h"
|
||||||
|
@ -50,8 +51,9 @@ namespace x64 {
|
||||||
|
|
||||||
using xe::cpu::hir::HIRBuilder;
|
using xe::cpu::hir::HIRBuilder;
|
||||||
using xe::cpu::hir::Instr;
|
using xe::cpu::hir::Instr;
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
static const size_t kMaxCodeSize = 1 * 1024 * 1024;
|
static const size_t kMaxCodeSize = 1_MiB;
|
||||||
|
|
||||||
static const size_t kStashOffset = 32;
|
static const size_t kStashOffset = 32;
|
||||||
// static const size_t kStashOffsetHigh = 32 + 32;
|
// static const size_t kStashOffsetHigh = 32 + 32;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "xenia/base/console_app_main.h"
|
#include "xenia/base/console_app_main.h"
|
||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
#include "xenia/base/filesystem.h"
|
#include "xenia/base/filesystem.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
|
@ -36,6 +37,7 @@ namespace cpu {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
using xe::cpu::ppc::PPCContext;
|
using xe::cpu::ppc::PPCContext;
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, std::string>> AnnotationList;
|
typedef std::vector<std::pair<std::string, std::string>> AnnotationList;
|
||||||
|
|
||||||
|
@ -177,7 +179,7 @@ class TestSuite {
|
||||||
|
|
||||||
class TestRunner {
|
class TestRunner {
|
||||||
public:
|
public:
|
||||||
TestRunner() : memory_size_(64 * 1024 * 1024) {
|
TestRunner() : memory_size_(64_MiB) {
|
||||||
memory_.reset(new Memory());
|
memory_.reset(new Memory());
|
||||||
memory_->Initialize();
|
memory_->Initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
#include "xenia/base/debugging.h"
|
#include "xenia/base/debugging.h"
|
||||||
#include "xenia/base/exception_handler.h"
|
#include "xenia/base/exception_handler.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/memory.h"
|
#include "xenia/base/memory.h"
|
||||||
#include "xenia/base/profiling.h"
|
#include "xenia/base/profiling.h"
|
||||||
|
@ -57,6 +58,8 @@ namespace cpu {
|
||||||
using xe::cpu::ppc::PPCOpcode;
|
using xe::cpu::ppc::PPCOpcode;
|
||||||
using xe::kernel::XThread;
|
using xe::kernel::XThread;
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
class BuiltinModule : public Module {
|
class BuiltinModule : public Module {
|
||||||
public:
|
public:
|
||||||
explicit BuiltinModule(Processor* processor)
|
explicit BuiltinModule(Processor* processor)
|
||||||
|
@ -142,8 +145,8 @@ bool Processor::Setup(std::unique_ptr<backend::Backend> backend) {
|
||||||
// Open the trace data path, if requested.
|
// Open the trace data path, if requested.
|
||||||
functions_trace_path_ = cvars::trace_function_data_path;
|
functions_trace_path_ = cvars::trace_function_data_path;
|
||||||
if (!functions_trace_path_.empty()) {
|
if (!functions_trace_path_.empty()) {
|
||||||
functions_trace_file_ = ChunkedMappedMemoryWriter::Open(
|
functions_trace_file_ =
|
||||||
functions_trace_path_, 32 * 1024 * 1024, true);
|
ChunkedMappedMemoryWriter::Open(functions_trace_path_, 32_MiB, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
#include "xenia/base/debugging.h"
|
#include "xenia/base/debugging.h"
|
||||||
#include "xenia/base/exception_handler.h"
|
#include "xenia/base/exception_handler.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/mapped_memory.h"
|
#include "xenia/base/mapped_memory.h"
|
||||||
#include "xenia/base/profiling.h"
|
#include "xenia/base/profiling.h"
|
||||||
|
@ -60,6 +61,8 @@ DEFINE_string(
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
Emulator::Emulator(const std::filesystem::path& command_line,
|
Emulator::Emulator(const std::filesystem::path& command_line,
|
||||||
const std::filesystem::path& storage_root,
|
const std::filesystem::path& storage_root,
|
||||||
const std::filesystem::path& content_root,
|
const std::filesystem::path& content_root,
|
||||||
|
@ -415,8 +418,7 @@ bool Emulator::SaveToFile(const std::filesystem::path& path) {
|
||||||
Pause();
|
Pause();
|
||||||
|
|
||||||
filesystem::CreateFile(path);
|
filesystem::CreateFile(path);
|
||||||
auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0,
|
auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0, 2_GiB);
|
||||||
1024ull * 1024ull * 1024ull * 2ull);
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/ui/d3d12/d3d12_api.h"
|
#include "xenia/ui/d3d12/d3d12_api.h"
|
||||||
|
|
||||||
|
@ -23,12 +24,14 @@ namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
namespace d3d12 {
|
namespace d3d12 {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
class D3D12CommandProcessor;
|
class D3D12CommandProcessor;
|
||||||
|
|
||||||
class DeferredCommandList {
|
class DeferredCommandList {
|
||||||
public:
|
public:
|
||||||
DeferredCommandList(const D3D12CommandProcessor& command_processor,
|
DeferredCommandList(const D3D12CommandProcessor& command_processor,
|
||||||
size_t initial_size_bytes = 1024 * 1024);
|
size_t initial_size_bytes = 1_MiB);
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void Execute(ID3D12GraphicsCommandList* command_list,
|
void Execute(ID3D12GraphicsCommandList* command_list,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "third_party/fmt/include/fmt/format.h"
|
#include "third_party/fmt/include/fmt/format.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/memory.h"
|
#include "xenia/base/memory.h"
|
||||||
|
@ -36,8 +37,10 @@ namespace vulkan {
|
||||||
|
|
||||||
using xe::ui::vulkan::CheckResult;
|
using xe::ui::vulkan::CheckResult;
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
constexpr uint32_t kMaxTextureSamplers = 32;
|
constexpr uint32_t kMaxTextureSamplers = 32;
|
||||||
constexpr VkDeviceSize kStagingBufferSize = 64 * 1024 * 1024;
|
constexpr VkDeviceSize kStagingBufferSize = 64_MiB;
|
||||||
|
|
||||||
const char* get_dimension_name(xenos::DataDimension dimension) {
|
const char* get_dimension_name(xenos::DataDimension dimension) {
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
|
|
|
@ -27,10 +27,12 @@ namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
namespace vulkan {
|
namespace vulkan {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
using namespace xe::gpu::xenos;
|
using namespace xe::gpu::xenos;
|
||||||
|
|
||||||
using xe::ui::vulkan::CheckResult;
|
using xe::ui::vulkan::CheckResult;
|
||||||
|
|
||||||
constexpr size_t kDefaultBufferCacheCapacity = 256 * 1024 * 1024;
|
constexpr size_t kDefaultBufferCacheCapacity = 256_MiB;
|
||||||
|
|
||||||
VulkanCommandProcessor::VulkanCommandProcessor(
|
VulkanCommandProcessor::VulkanCommandProcessor(
|
||||||
VulkanGraphicsSystem* graphics_system, kernel::KernelState* kernel_state)
|
VulkanGraphicsSystem* graphics_system, kernel::KernelState* kernel_state)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "third_party/fmt/include/fmt/format.h"
|
#include "third_party/fmt/include/fmt/format.h"
|
||||||
#include "xenia/base/byte_stream.h"
|
#include "xenia/base/byte_stream.h"
|
||||||
#include "xenia/base/clock.h"
|
#include "xenia/base/clock.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/base/profiling.h"
|
#include "xenia/base/profiling.h"
|
||||||
|
@ -41,6 +42,8 @@ const uint32_t XAPC::kDummyRundownRoutine;
|
||||||
|
|
||||||
using xe::cpu::ppc::PPCOpcode;
|
using xe::cpu::ppc::PPCOpcode;
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
uint32_t next_xthread_id_ = 0;
|
uint32_t next_xthread_id_ = 0;
|
||||||
|
|
||||||
XThread::XThread(KernelState* kernel_state)
|
XThread::XThread(KernelState* kernel_state)
|
||||||
|
@ -370,7 +373,7 @@ X_STATUS XThread::Create() {
|
||||||
RetainHandle();
|
RetainHandle();
|
||||||
|
|
||||||
xe::threading::Thread::CreationParameters params;
|
xe::threading::Thread::CreationParameters params;
|
||||||
params.stack_size = 16 * 1024 * 1024; // Allocate a big host stack.
|
params.stack_size = 16_MiB; // Allocate a big host stack.
|
||||||
params.create_suspended = true;
|
params.create_suspended = true;
|
||||||
thread_ = xe::threading::Thread::Create(params, [this]() {
|
thread_ = xe::threading::Thread::Create(params, [this]() {
|
||||||
// Set thread ID override. This is used by logging.
|
// Set thread ID override. This is used by logging.
|
||||||
|
@ -1018,7 +1021,7 @@ object_ref<XThread> XThread::Restore(KernelState* kernel_state,
|
||||||
|
|
||||||
xe::threading::Thread::CreationParameters params;
|
xe::threading::Thread::CreationParameters params;
|
||||||
params.create_suspended = true; // Not done restoring yet.
|
params.create_suspended = true; // Not done restoring yet.
|
||||||
params.stack_size = 16 * 1024 * 1024;
|
params.stack_size = 16_MiB;
|
||||||
thread->thread_ = xe::threading::Thread::Create(params, [thread, state]() {
|
thread->thread_ = xe::threading::Thread::Create(params, [thread, state]() {
|
||||||
// Set thread ID override. This is used by logging.
|
// Set thread ID override. This is used by logging.
|
||||||
xe::threading::set_current_thread_id(thread->handle());
|
xe::threading::set_current_thread_id(thread->handle());
|
||||||
|
|
|
@ -13,9 +13,13 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
// Submission index is the fence value or a value derived from it (if reclaiming
|
// Submission index is the fence value or a value derived from it (if reclaiming
|
||||||
// less often than once per fence value, for instance).
|
// less often than once per fence value, for instance).
|
||||||
|
|
||||||
|
@ -23,7 +27,7 @@ class GraphicsUploadBufferPool {
|
||||||
public:
|
public:
|
||||||
// Taken from the Direct3D 12 MiniEngine sample (LinearAllocator
|
// Taken from the Direct3D 12 MiniEngine sample (LinearAllocator
|
||||||
// kCpuAllocatorPageSize). Large enough for most cases.
|
// kCpuAllocatorPageSize). Large enough for most cases.
|
||||||
static constexpr size_t kDefaultPageSize = 2 * 1024 * 1024;
|
static constexpr size_t kDefaultPageSize = 2_MiB;
|
||||||
|
|
||||||
virtual ~GraphicsUploadBufferPool();
|
virtual ~GraphicsUploadBufferPool();
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "xenia/vfs/devices/disc_image_device.h"
|
#include "xenia/vfs/devices/disc_image_device.h"
|
||||||
|
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
#include "xenia/vfs/devices/disc_image_entry.h"
|
#include "xenia/vfs/devices/disc_image_entry.h"
|
||||||
|
@ -16,7 +17,9 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace vfs {
|
namespace vfs {
|
||||||
|
|
||||||
const size_t kXESectorSize = 2048;
|
using namespace xe::literals;
|
||||||
|
|
||||||
|
const size_t kXESectorSize = 2_KiB;
|
||||||
|
|
||||||
DiscImageDevice::DiscImageDevice(const std::string_view mount_path,
|
DiscImageDevice::DiscImageDevice(const std::string_view mount_path,
|
||||||
const std::filesystem::path& host_path)
|
const std::filesystem::path& host_path)
|
||||||
|
@ -89,7 +92,7 @@ DiscImageDevice::Error DiscImageDevice::Verify(ParseState* state) {
|
||||||
state->root_size = xe::load<uint32_t>(fs_ptr + 24);
|
state->root_size = xe::load<uint32_t>(fs_ptr + 24);
|
||||||
state->root_offset =
|
state->root_offset =
|
||||||
state->game_offset + (state->root_sector * kXESectorSize);
|
state->game_offset + (state->root_sector * kXESectorSize);
|
||||||
if (state->root_size < 13 || state->root_size > 32 * 1024 * 1024) {
|
if (state->root_size < 13 || state->root_size > 32_MiB) {
|
||||||
return Error::kErrorDamagedFile;
|
return Error::kErrorDamagedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "xenia/base/console_app_main.h"
|
#include "xenia/base/console_app_main.h"
|
||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
|
#include "xenia/base/literals.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/math.h"
|
#include "xenia/base/math.h"
|
||||||
|
|
||||||
|
@ -22,6 +23,8 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace vfs {
|
namespace vfs {
|
||||||
|
|
||||||
|
using namespace xe::literals;
|
||||||
|
|
||||||
DEFINE_transient_path(source, "", "Specifies the file to dump from.",
|
DEFINE_transient_path(source, "", "Specifies the file to dump from.",
|
||||||
"General");
|
"General");
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ int vfs_dump_main(const std::vector<std::string>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a buffer rounded up to the nearest 512MB.
|
// Allocate a buffer rounded up to the nearest 512MB.
|
||||||
buffer_size = xe::round_up(entry->size(), 512 * 1024 * 1024);
|
buffer_size = xe::round_up(entry->size(), 512_MiB);
|
||||||
buffer = new uint8_t[buffer_size];
|
buffer = new uint8_t[buffer_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue