Overhaul logging.

This commit is contained in:
gibbed 2020-02-28 14:30:48 -06:00 committed by Rick Gibbed
parent de3c91ab2c
commit a48bb71c2f
107 changed files with 954 additions and 854 deletions

View File

@ -294,7 +294,7 @@ void EmulatorWindow::FileDrop(const std::filesystem::path& filename) {
auto result = emulator_->LaunchPath(filename);
if (XFAILED(result)) {
// TODO: Display a message box.
XELOGE("Failed to launch target: %.8X", result);
XELOGE("Failed to launch target: {:08X}", result);
}
}
@ -326,7 +326,7 @@ void EmulatorWindow::FileOpen() {
auto result = emulator_->LaunchPath(abs_path);
if (XFAILED(result)) {
// TODO: Display a message box.
XELOGE("Failed to launch target: %.8X", result);
XELOGE("Failed to launch target: {:08X}", result);
}
}
}

View File

@ -226,7 +226,7 @@ int xenia_main(const std::vector<std::string>& args) {
}
}
storage_root = std::filesystem::absolute(storage_root);
XELOGI("Storage root: %S", storage_root.c_str());
XELOGI("Storage root: {}", xe::path_to_utf8(storage_root));
config::SetupConfig(storage_root);
@ -235,7 +235,7 @@ int xenia_main(const std::vector<std::string>& args) {
content_root = storage_root / "content";
}
content_root = std::filesystem::absolute(content_root);
XELOGI("Content root: %S", content_root.c_str());
XELOGI("Content root: {}", xe::path_to_utf8(content_root));
if (cvars::discord) {
discord::DiscordPresence::Initialize();
@ -254,7 +254,7 @@ int xenia_main(const std::vector<std::string>& args) {
emulator->Setup(emulator_window->window(), CreateAudioSystem,
CreateGraphicsSystem, CreateInputDrivers);
if (XFAILED(result)) {
XELOGE("Failed to setup emulator: %.8X", result);
XELOGE("Failed to setup emulator: {:08X}", result);
return 1;
}

View File

@ -40,7 +40,7 @@ bool SDLAudioDriver::Initialize() {
if ((ver.major < 2) ||
(ver.major == 2 && ver.minor == 0 && ver.patch < 8)) {
XELOGW(
"SDL library version %d.%d.%d is outdated. "
"SDL library version {}.{}.{} is outdated. "
"You may experience choppy audio.",
ver.major, ver.minor, ver.patch);
}

View File

@ -95,7 +95,7 @@ bool XAudio2AudioDriver::Initialize() {
}
hr = xaudio2_create(&objects_.api_2_8.audio, 0, processor);
if (FAILED(hr)) {
XELOGE("XAudio2Create failed with %.8X", hr);
XELOGE("XAudio2Create failed with {:08X}", hr);
assert_always();
return false;
}
@ -104,13 +104,13 @@ bool XAudio2AudioDriver::Initialize() {
hr = CoCreateInstance(__uuidof(api::XAudio2_7), NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&objects_.api_2_7.audio));
if (FAILED(hr)) {
XELOGE("CoCreateInstance for XAudio2 failed with %.8X", hr);
XELOGE("CoCreateInstance for XAudio2 failed with {:08X}", hr);
assert_always();
return false;
}
hr = objects_.api_2_7.audio->Initialize(0, processor);
if (FAILED(hr)) {
XELOGE("IXAudio2::Initialize failed with %.8X", hr);
XELOGE("IXAudio2::Initialize failed with {:08X}", hr);
assert_always();
return false;
}
@ -133,7 +133,7 @@ bool XAudio2AudioDriver::InitializeObjects(Objects& objects) {
hr = objects.audio->CreateMasteringVoice(&objects.mastering_voice);
if (FAILED(hr)) {
XELOGE("IXAudio2::CreateMasteringVoice failed with %.8X", hr);
XELOGE("IXAudio2::CreateMasteringVoice failed with {:08X}", hr);
assert_always();
return false;
}
@ -171,14 +171,14 @@ bool XAudio2AudioDriver::InitializeObjects(Objects& objects) {
0, // api::XE_XAUDIO2_VOICE_NOSRC | api::XE_XAUDIO2_VOICE_NOPITCH,
api::XE_XAUDIO2_MAX_FREQ_RATIO, voice_callback_);
if (FAILED(hr)) {
XELOGE("IXAudio2::CreateSourceVoice failed with %.8X", hr);
XELOGE("IXAudio2::CreateSourceVoice failed with {:08X}", hr);
assert_always();
return false;
}
hr = objects.pcm_voice->Start();
if (FAILED(hr)) {
XELOGE("IXAudio2SourceVoice::Start failed with %.8X", hr);
XELOGE("IXAudio2SourceVoice::Start failed with {:08X}", hr);
assert_always();
return false;
}
@ -231,7 +231,7 @@ void XAudio2AudioDriver::SubmitFrame(uint32_t frame_ptr) {
hr = objects_.api_2_7.pcm_voice->SubmitSourceBuffer(&buffer);
}
if (FAILED(hr)) {
XELOGE("SubmitSourceBuffer failed with %.8X", hr);
XELOGE("SubmitSourceBuffer failed with {:08X}", hr);
assert_always();
return;
}

View File

@ -119,7 +119,7 @@ void XmaContext::Enable() {
auto context_ptr = memory()->TranslateVirtual(guest_ptr());
XMA_CONTEXT_DATA data(context_ptr);
XELOGAPU("XmaContext: kicking context %d (buffer %d %d/%d bits)", id(),
XELOGAPU("XmaContext: kicking context {} (buffer {} {}/{} bits)", id(),
data.current_buffer, data.input_buffer_read_offset,
(data.current_buffer == 0 ? data.input_buffer_0_packet_count
: data.input_buffer_1_packet_count) *
@ -143,7 +143,7 @@ bool XmaContext::Block(bool poll) {
void XmaContext::Clear() {
std::lock_guard<std::mutex> lock(lock_);
XELOGAPU("XmaContext: reset context %d", id());
XELOGAPU("XmaContext: reset context {}", id());
auto context_ptr = memory()->TranslateVirtual(guest_ptr());
XMA_CONTEXT_DATA data(context_ptr);
@ -160,7 +160,7 @@ void XmaContext::Clear() {
void XmaContext::Disable() {
std::lock_guard<std::mutex> lock(lock_);
XELOGAPU("XmaContext: disabling context %d", id());
XELOGAPU("XmaContext: disabling context {}", id());
set_is_enabled(false);
}
@ -323,7 +323,7 @@ void XmaContext::DecodePackets(XMA_CONTEXT_DATA* data) {
: nullptr;
uint8_t* current_input_buffer = data->current_buffer ? in1 : in0;
XELOGAPU("Processing context %d (offset %d, buffer %d, ptr %.8X)", id(),
XELOGAPU("Processing context {} (offset {}, buffer {}, ptr {:p})", id(),
data->input_buffer_read_offset, data->current_buffer,
current_input_buffer);
@ -392,7 +392,7 @@ void XmaContext::DecodePackets(XMA_CONTEXT_DATA* data) {
if (!ValidFrameOffset(current_input_buffer, current_input_size,
data->input_buffer_read_offset)) {
XELOGAPU("XmaContext %d: Invalid read offset %d!", id(),
XELOGAPU("XmaContext {}: Invalid read offset {}!", id(),
data->input_buffer_read_offset);
if (data->current_buffer == 0) {
data->current_buffer = 1;
@ -441,7 +441,7 @@ void XmaContext::DecodePackets(XMA_CONTEXT_DATA* data) {
}
if (partial_frame_saved_) {
XELOGAPU("XmaContext %d: saved a partial frame", id());
XELOGAPU("XmaContext {}: saved a partial frame", id());
if (data->current_buffer == 0) {
data->input_buffer_0_valid = 0;
@ -485,7 +485,7 @@ void XmaContext::DecodePackets(XMA_CONTEXT_DATA* data) {
bool partial = false;
size_t bit_offset = data->input_buffer_read_offset;
if (partial_frame_saved_) {
XELOGAPU("XmaContext %d: processing saved partial frame", id());
XELOGAPU("XmaContext {}: processing saved partial frame", id());
packet_->data = partial_frame_buffer_.data();
packet_->size = (int)partial_frame_buffer_.size();

View File

@ -91,7 +91,8 @@ void av_log_callback(void* avcl, int level, const char* fmt, va_list va) {
StringBuffer buff;
buff.AppendVarargs(fmt, va);
xe::LogLineFormat(log_level, level_char, "libav: %s", buff.buffer());
xe::logging::AppendLogLineFormat(log_level, level_char, "libav: {}",
buff.to_string_view());
}
X_STATUS XmaDecoder::Setup(kernel::KernelState* kernel_state) {
@ -248,7 +249,7 @@ uint32_t XmaDecoder::ReadRegister(uint32_t addr) {
switch (r) {
default: {
if (!register_file_.GetRegisterInfo(r)) {
XELOGE("XMA: Read from unknown register (%.4X)", r);
XELOGE("XMA: Read from unknown register ({:04X})", r);
}
}
#pragma warning(suppress : 4065)
@ -285,7 +286,7 @@ void XmaDecoder::WriteRegister(uint32_t addr, uint32_t value) {
} else {
switch (r) {
default: {
XELOGE("XMA: Write to unhandled register (%.4X): %.8X", r, value);
XELOGE("XMA: Write to unhandled register ({:04X}): {:08X}", r, value);
break;
}
#pragma warning(suppress : 4065)

View File

@ -12,6 +12,8 @@
#include <cstdint>
#include "third_party/fmt/include/fmt/format.h"
namespace xe {
namespace debugging {
@ -25,10 +27,18 @@ bool IsDebuggerAttached();
// If no debugger is present, a signal will be raised.
void Break();
namespace internal {
void DebugPrint(const char* s);
}
// Prints a message to the attached debugger.
// This bypasses the normal logging mechanism. If no debugger is attached it's
// likely to no-op.
void DebugPrint(const char* fmt, ...);
template <typename... Args>
void DebugPrint(fmt::string_view format, const Args&... args) {
internal::DebugPrint(
fmt::vformat(format, fmt::make_format_args(args...)).c_str());
}
} // namespace debugging
} // namespace xe

View File

@ -20,16 +20,11 @@ namespace debugging {
bool IsDebuggerAttached() { return false; }
void Break() { raise(SIGTRAP); }
void DebugPrint(const char* fmt, ...) {
StringBuffer buff;
va_list va;
va_start(va, fmt);
buff.AppendVarargs(fmt, va);
va_end(va);
// OutputDebugStringA(buff.GetString());
namespace internal {
void DebugPrint(const char* s) {
// TODO: proper implementation.
}
} // namespace internal
} // namespace debugging
} // namespace xe

View File

@ -19,16 +19,9 @@ bool IsDebuggerAttached() { return IsDebuggerPresent() ? true : false; }
void Break() { __debugbreak(); }
void DebugPrint(const char* fmt, ...) {
StringBuffer buff;
va_list va;
va_start(va, fmt);
buff.AppendVarargs(fmt, va);
va_end(va);
OutputDebugStringA(buff.GetString());
}
namespace internal {
void DebugPrint(const char* s) { OutputDebugStringA(s); }
} // namespace internal
} // namespace debugging
} // namespace xe

View File

@ -160,7 +160,7 @@ class Win32FileHandle : public FileHandle {
} else {
if (GetLastError() == ERROR_NOACCESS) {
XELOGW(
"Win32FileHandle::Read(..., %.8llX, %.8llX, ...) returned "
"Win32FileHandle::Read(..., {}, {:#X}, ...) returned "
"ERROR_NOACCESS. Read-only memory?",
buffer, buffer_length);
}

View File

@ -10,12 +10,13 @@
#include "xenia/base/logging.h"
#include <atomic>
#include <cinttypes>
#include <cstdarg>
#include <cstdlib>
#include <mutex>
#include <vector>
#include "third_party/disruptorplus/include/disruptorplus/multi_threaded_claim_strategy.hpp"
#include "third_party/disruptorplus/include/disruptorplus/ring_buffer.hpp"
#include "third_party/disruptorplus/include/disruptorplus/sequence_barrier.hpp"
#include "third_party/disruptorplus/include/disruptorplus/spin_wait_strategy.hpp"
#include "xenia/base/atomic.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
@ -47,16 +48,34 @@ DEFINE_int32(
"Maximum level to be logged. (0=error, 1=warning, 2=info, 3=debug)",
"Logging");
namespace dp = disruptorplus;
namespace xe {
class Logger;
Logger* logger_ = nullptr;
thread_local std::vector<char> log_format_buffer_(64 * 1024);
struct LogLine {
size_t buffer_length;
uint32_t thread_id;
uint16_t _pad_0; // (2b) padding
uint8_t _pad_1; // (1b) padding
char prefix_char;
};
thread_local char thread_log_buffer_[64 * 1024];
class Logger {
public:
explicit Logger(const std::string_view app_name) : running_(true) {
explicit Logger(const std::string_view app_name)
: file_(nullptr),
running_(true),
wait_strategy_(),
claim_strategy_(kBlockCount, wait_strategy_),
consumed_(wait_strategy_) {
claim_strategy_.add_claim_barrier(consumed_);
if (cvars::log_file.empty()) {
// Default to app name.
auto file_name = fmt::format("{}.log", app_name);
@ -84,165 +103,189 @@ class Logger {
fclose(file_);
}
void AppendLine(uint32_t thread_id, LogLevel level, const char prefix_char,
const char* buffer, size_t buffer_length) {
if (static_cast<int32_t>(level) > cvars::log_level) {
// Discard this line.
return;
}
LogLine line;
line.buffer_length = buffer_length;
line.thread_id = thread_id;
line.prefix_char = prefix_char;
// First, run a check and see if we can increment write
// head without any problems. If so, cmpxchg it to reserve some space in the
// ring. If someone beats us, loop around.
//
// Once we have a reservation, write our data and then increment the write
// tail.
size_t size = sizeof(LogLine) + buffer_length;
while (true) {
// Attempt to make a reservation.
size_t write_head = write_head_;
size_t read_head = read_head_;
RingBuffer rb(buffer_, kBufferSize);
rb.set_write_offset(write_head);
rb.set_read_offset(read_head);
if (rb.write_count() < size) {
xe::threading::MaybeYield();
continue;
}
// We have enough size to make a reservation!
rb.AdvanceWrite(size);
if (xe::atomic_cas(write_head, rb.write_offset(), &write_head_)) {
// Reservation made. Write out logline.
rb.set_write_offset(write_head);
rb.Write(&line, sizeof(LogLine));
rb.Write(buffer, buffer_length);
while (!xe::atomic_cas(write_head, rb.write_offset(), &write_tail_)) {
// Done writing. End the reservation.
xe::threading::MaybeYield();
}
break;
} else {
// Someone beat us to the chase. Loop around.
continue;
}
}
}
private:
static const size_t kBufferSize = 8 * 1024 * 1024;
uint8_t buffer_[kBufferSize];
struct LogLine {
size_t buffer_length;
uint32_t thread_id;
uint16_t _pad_0; // (2b) padding
uint8_t _pad_1; // (1b) padding
char prefix_char;
};
static const size_t kBlockSize = 256;
static const size_t kBlockCount = kBufferSize / kBlockSize;
static const size_t kBlockIndexMask = kBlockCount - 1;
static const size_t kClaimStrategyFootprint =
sizeof(std::atomic<dp::sequence_t>[kBlockCount]);
static size_t BlockOffset(dp::sequence_t sequence) {
return (sequence & kBlockIndexMask) * kBlockSize;
}
static size_t BlockCount(size_t byte_size) {
return (byte_size + (kBlockSize - 1)) / kBlockSize;
}
dp::spin_wait_strategy wait_strategy_;
dp::multi_threaded_claim_strategy<dp::spin_wait_strategy> claim_strategy_;
dp::sequence_barrier<dp::spin_wait_strategy> consumed_;
FILE* file_;
std::atomic<bool> running_;
std::unique_ptr<xe::threading::Thread> write_thread_;
void Write(const char* buf, size_t size) {
if (file_) {
fwrite(buf, 1, size, file_);
}
if (cvars::log_to_debugprint) {
debugging::DebugPrint("%.*s", size, buf);
debugging::DebugPrint("{}", std::string_view(buf, size));
}
}
void WriteThread() {
RingBuffer rb(buffer_, kBufferSize);
uint32_t idle_loops = 0;
size_t idle_loops = 0;
dp::sequence_t next_sequence = 0;
dp::sequence_t last_sequence = -1;
size_t desired_count = 1;
while (true) {
bool did_write = false;
rb.set_write_offset(write_tail_);
if (!running_ && rb.empty()) {
break;
}
while (!rb.empty()) {
did_write = true;
// We want one block to find out how many blocks we need or we know how
// many blocks needed for at least one log line.
auto next_range = dp::sequence_range(next_sequence, desired_count);
// Read line header and write out the line prefix.
LogLine line;
rb.Read(&line, sizeof(line));
char prefix[] = {
line.prefix_char,
'>',
' ',
'0', // Thread ID gets placed here (8 chars).
'0',
'0',
'0',
'0',
'0',
'0',
'0',
' ',
0,
};
std::snprintf(prefix + 3, sizeof(prefix) - 3, "%08" PRIX32 " ",
line.thread_id);
Write(prefix, sizeof(prefix) - 1);
if (line.buffer_length) {
// Get access to the line data - which may be split in the ring buffer
// - and write it out in parts.
auto line_range = rb.BeginRead(line.buffer_length);
Write(reinterpret_cast<const char*>(line_range.first),
line_range.first_length);
if (line_range.second_length) {
Write(reinterpret_cast<const char*>(line_range.second),
line_range.second_length);
auto available_sequence = claim_strategy_.wait_until_published(
next_range.last(), last_sequence);
auto available_difference =
dp::difference(available_sequence, next_sequence);
size_t read_count = 0;
if (available_difference > 0 &&
static_cast<size_t>(available_difference) >= desired_count) {
auto available_range = dp::sequence_range(
next_sequence, static_cast<size_t>(available_difference));
auto available_count = available_range.size();
rb.set_write_offset(BlockOffset(available_range.end()));
for (size_t i = available_range.first(); i != available_range.end();) {
rb.set_read_offset(BlockOffset(i));
LogLine line;
rb.Read(&line, sizeof(line));
auto needed_count = BlockCount(sizeof(LogLine) + line.buffer_length);
if (read_count + needed_count > available_count) {
// More blocks are needed for a complete line.
desired_count = needed_count;
break;
} else {
// Enough blocks to read this log line, advance by that many.
read_count += needed_count;
i += needed_count;
char prefix[] = {
line.prefix_char,
'>',
' ',
'?', // Thread ID gets placed here (8 chars).
'?',
'?',
'?',
'?',
'?',
'?',
'?',
' ',
0,
};
fmt::format_to_n(prefix + 3, sizeof(prefix) - 3, "{:08X}",
line.thread_id);
Write(prefix, sizeof(prefix) - 1);
if (line.buffer_length) {
// Get access to the line data - which may be split in the ring
// buffer - and write it out in parts.
auto line_range = rb.BeginRead(line.buffer_length);
Write(reinterpret_cast<const char*>(line_range.first),
line_range.first_length);
if (line_range.second_length) {
Write(reinterpret_cast<const char*>(line_range.second),
line_range.second_length);
}
// Always ensure there is a newline.
char last_char =
line_range.second
? line_range.second[line_range.second_length - 1]
: line_range.first[line_range.first_length - 1];
if (last_char != '\n') {
const char suffix[1] = {'\n'};
Write(suffix, 1);
}
rb.EndRead(std::move(line_range));
} else {
// Always ensure there is a newline.
const char suffix[1] = {'\n'};
Write(suffix, 1);
}
}
// Always ensure there is a newline.
char last_char = line_range.second
? line_range.second[line_range.second_length - 1]
: line_range.first[line_range.first_length - 1];
if (last_char != '\n') {
const char suffix[1] = {'\n'};
Write(suffix, 1);
}
rb.EndRead(std::move(line_range));
} else {
const char suffix[1] = {'\n'};
Write(suffix, 1);
}
rb.set_write_offset(write_tail_);
read_head_ = rb.read_offset();
}
if (did_write) {
if (read_count) {
// Advance by the number of blocks we read.
auto read_range = dp::sequence_range(next_sequence, read_count);
next_sequence = read_range.end();
last_sequence = read_range.last();
consumed_.publish(read_range.last());
desired_count = 1;
if (cvars::flush_log) {
fflush(file_);
}
idle_loops = 0;
} else {
if (idle_loops > 1000) {
if (!running_) {
break;
}
if (idle_loops >= 1000) {
// Introduce a waiting period.
xe::threading::Sleep(std::chrono::milliseconds(50));
} else {
idle_loops++;
}
idle_loops++;
}
}
}
volatile size_t write_tail_ = 0;
size_t write_head_ = 0;
size_t read_head_ = 0;
uint8_t buffer_[kBufferSize];
FILE* file_ = nullptr;
public:
void AppendLine(uint32_t thread_id, const char prefix_char,
const char* buffer_data, size_t buffer_length) {
size_t count = BlockCount(sizeof(LogLine) + buffer_length);
std::atomic<bool> running_;
std::unique_ptr<xe::threading::Thread> write_thread_;
auto range = claim_strategy_.claim(count);
assert_true(range.size() == count);
RingBuffer rb(buffer_, kBufferSize);
rb.set_write_offset(BlockOffset(range.first()));
rb.set_read_offset(BlockOffset(range.end()));
LogLine line = {};
line.buffer_length = buffer_length;
line.thread_id = thread_id;
line.prefix_char = prefix_char;
rb.Write(&line, sizeof(LogLine));
rb.Write(buffer_data, buffer_length);
claim_strategy_.publish(range);
}
};
void InitializeLogging(const std::string_view app_name) {
@ -258,56 +301,34 @@ void ShutdownLogging() {
memory::AlignedFree(logger);
}
void LogLineFormat(LogLevel log_level, const char prefix_char, const char* fmt,
...) {
if (!logger_) {
return;
}
va_list args;
va_start(args, fmt);
int chars_written = std::vsnprintf(log_format_buffer_.data(),
log_format_buffer_.capacity(), fmt, args);
va_end(args);
if (chars_written >= 0 && chars_written < log_format_buffer_.capacity()) {
logger_->AppendLine(xe::threading::current_thread_id(), log_level,
prefix_char, log_format_buffer_.data(), chars_written);
} else if (chars_written >= 0) {
logger_->AppendLine(xe::threading::current_thread_id(), log_level,
prefix_char, fmt, std::strlen(fmt));
}
bool logging::internal::ShouldLog(LogLevel log_level) {
return logger_ != nullptr &&
static_cast<int32_t>(log_level) <= cvars::log_level;
}
void LogLineVarargs(LogLevel log_level, const char prefix_char, const char* fmt,
va_list args) {
if (!logger_) {
std::pair<char*, size_t> logging::internal::GetThreadBuffer() {
return {thread_log_buffer_, sizeof(thread_log_buffer_)};
}
void logging::internal::AppendLogLine(LogLevel log_level,
const char prefix_char, size_t written) {
if (!ShouldLog(log_level) || !written) {
return;
}
int chars_written = std::vsnprintf(log_format_buffer_.data(),
log_format_buffer_.capacity(), fmt, args);
if (chars_written < 0) {
return;
}
auto size =
std::min(size_t(chars_written), log_format_buffer_.capacity() - 1);
logger_->AppendLine(xe::threading::current_thread_id(), log_level,
prefix_char, log_format_buffer_.data(), size);
logger_->AppendLine(xe::threading::current_thread_id(), prefix_char,
thread_log_buffer_, written);
}
void logging::AppendLogLine(LogLevel log_level, const char prefix_char,
const std::string_view str) {
if (!logger_) {
if (!internal::ShouldLog(log_level) || !str.size()) {
return;
}
logger_->AppendLine(xe::threading::current_thread_id(), log_level,
prefix_char, str.data(), str.length());
logger_->AppendLine(xe::threading::current_thread_id(), prefix_char,
str.data(), str.size());
}
void FatalError(const std::string_view str) {
LogLine(LogLevel::Error, 'X', str);
logging::AppendLogLine(LogLevel::Error, 'X', str);
#if XE_PLATFORM_WIN32

View File

@ -14,6 +14,7 @@
#include <cstdint>
#include <string>
#include "third_party/fmt/include/fmt/format.h"
#include "xenia/base/string.h"
namespace xe {
@ -38,42 +39,104 @@ enum class LogLevel {
void InitializeLogging(const std::string_view app_name);
void ShutdownLogging();
namespace logging {
namespace internal {
bool ShouldLog(LogLevel log_level);
std::pair<char*, size_t> GetThreadBuffer();
void AppendLogLine(LogLevel log_level, const char prefix_char, size_t written);
} // namespace internal
// Appends a line to the log with printf-style formatting.
void LogLineFormat(LogLevel log_level, const char prefix_char, const char* fmt,
...);
void LogLineVarargs(LogLevel log_level, const char prefix_char, const char* fmt,
va_list args);
template <typename... Args>
void AppendLogLineFormat(LogLevel log_level, const char prefix_char,
const char* format, const Args&... args) {
if (!internal::ShouldLog(log_level)) {
return;
}
auto target = internal::GetThreadBuffer();
auto result = fmt::format_to_n(target.first, target.second, format, args...);
internal::AppendLogLine(log_level, prefix_char, result.size);
}
// Appends a line to the log.
void LogLine(LogLevel log_level, const char prefix_char, std::string_view str);
void AppendLogLine(LogLevel log_level, const char prefix_char,
const std::string_view str);
} // namespace logging
// Logs a fatal error and aborts the program.
void FatalError(const std::string_view str);
#if XE_OPTION_ENABLE_LOGGING
#define XELOGCORE(level, prefix, fmt, ...) \
xe::LogLineFormat(level, prefix, fmt, ##__VA_ARGS__)
#else
#define XELOGCORE(level, fmt, ...) \
do { \
} while (false)
#endif // ENABLE_LOGGING
#define XELOGE(fmt, ...) XELOGCORE(xe::LogLevel::Error, '!', fmt, ##__VA_ARGS__)
#define XELOGW(fmt, ...) \
XELOGCORE(xe::LogLevel::Warning, 'w', fmt, ##__VA_ARGS__)
#define XELOGI(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'i', fmt, ##__VA_ARGS__)
#define XELOGD(fmt, ...) XELOGCORE(xe::LogLevel::Debug, 'd', fmt, ##__VA_ARGS__)
#define XELOGCPU(fmt, ...) \
XELOGCORE(xe::LogLevel::Info, 'C', fmt, ##__VA_ARGS__)
#define XELOGAPU(fmt, ...) \
XELOGCORE(xe::LogLevel::Info, 'A', fmt, ##__VA_ARGS__)
#define XELOGGPU(fmt, ...) \
XELOGCORE(xe::LogLevel::Info, 'G', fmt, ##__VA_ARGS__)
#define XELOGKERNEL(fmt, ...) \
XELOGCORE(xe::LogLevel::Info, 'K', fmt, ##__VA_ARGS__)
#define XELOGFS(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'F', fmt, ##__VA_ARGS__)
} // namespace xe
#if XE_OPTION_ENABLE_LOGGING
template <typename... Args>
void XELOGE(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Error, '!', format, args...);
}
template <typename... Args>
void XELOGW(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Warning, 'w', format, args...);
}
template <typename... Args>
void XELOGI(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'i', format, args...);
}
template <typename... Args>
void XELOGD(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Debug, 'd', format, args...);
}
template <typename... Args>
void XELOGCPU(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'C', format, args...);
}
template <typename... Args>
void XELOGAPU(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'A', format, args...);
}
template <typename... Args>
void XELOGGPU(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'G', format, args...);
}
template <typename... Args>
void XELOGKERNEL(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'K', format, args...);
}
template <typename... Args>
void XELOGFS(const char* format, const Args&... args) {
xe::logging::AppendLogLineFormat(xe::LogLevel::Info, 'F', format, args...);
}
#else
#define XELOGDUMMY \
do { \
} while (false)
#define XELOGE(...) XELOGDUMMY
#define XELOGW(...) XELOGDUMMY
#define XELOGI(...) XELOGDUMMY
#define XELOGD(...) XELOGDUMMY
#define XELOGCPU(...) XELOGDUMMY
#define XELOGAPU(...) XELOGDUMMY
#define XELOGGPU(...) XELOGDUMMY
#define XELOGKERNEL(...) XELOGDUMMY
#define XELOGFS(...) XELOGDUMMY
#undef XELOGDUMMY
#endif // ENABLE_LOGGING
#endif // XENIA_BASE_LOGGING_H_

View File

@ -143,8 +143,7 @@ int Main() {
}
// Print version info.
XELOGI("Build: %s / %s on %s", XE_BUILD_BRANCH, XE_BUILD_COMMIT,
XE_BUILD_DATE);
XELOGI("Build: " XE_BUILD_BRANCH " / " XE_BUILD_COMMIT " on " XE_BUILD_DATE);
// Request high performance timing.
if (cvars::win32_high_freq) {

View File

@ -50,7 +50,7 @@ class Win32Socket : public Socket {
int ret =
getaddrinfo(hostname.c_str(), port_string.c_str(), &hints, &result);
if (ret != 0) {
XELOGE("getaddrinfo failed with error: %d", ret);
XELOGE("getaddrinfo failed with error: {}", ret);
return false;
}
SOCKET try_socket = INVALID_SOCKET;
@ -58,7 +58,7 @@ class Win32Socket : public Socket {
// Create a SOCKET for connecting to server.
try_socket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (try_socket == INVALID_SOCKET) {
XELOGE("socket failed with error: %ld", WSAGetLastError());
XELOGE("socket failed with error: {}", WSAGetLastError());
freeaddrinfo(result);
return false;
}
@ -144,7 +144,7 @@ class Win32Socket : public Socket {
event_->Reset();
return 0;
}
XELOGE("Socket send error: %d", e);
XELOGE("Socket send error: {}", e);
Close();
return -1;
} else if (ret == 0) {
@ -175,7 +175,7 @@ class Win32Socket : public Socket {
buffer_data_sent.data(), 0, nullptr, nullptr);
if (ret == SOCKET_ERROR) {
int e = WSAGetLastError();
XELOGE("Socket send error: %d", e);
XELOGE("Socket send error: {}", e);
Close();
return false;
}
@ -250,12 +250,12 @@ class Win32SocketServer : public SocketServer {
if (bind(socket_, reinterpret_cast<sockaddr*>(&socket_addr),
sizeof(socket_addr)) == SOCKET_ERROR) {
int e = WSAGetLastError();
XELOGE("Unable to bind debug socket: %d", e);
XELOGE("Unable to bind debug socket: {}", e);
return false;
}
if (listen(socket_, 5) == SOCKET_ERROR) {
int e = WSAGetLastError();
XELOGE("Unable to listen on accept socket %d", e);
XELOGE("Unable to listen on accept socket {}", e);
return false;
}

View File

@ -437,7 +437,7 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
if (ret != 0) {
// TODO(benvanik): pass back?
auto last_error = errno;
XELOGE("Unable to pthread_create: %d", last_error);
XELOGE("Unable to pthread_create: {}", last_error);
delete start_data;
return nullptr;
}

View File

@ -450,7 +450,7 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
if (handle == INVALID_HANDLE_VALUE) {
// TODO(benvanik): pass back?
auto last_error = GetLastError();
XELOGE("Unable to CreateThread: %d", last_error);
XELOGE("Unable to CreateThread: {}", last_error);
delete start_data;
return nullptr;
}

View File

@ -61,7 +61,7 @@ void ReadConfig(const std::filesystem::path& file_path) {
config_var->LoadConfigValue(config->get_qualified(config_key));
}
}
XELOGI("Loaded config: %s", xe::path_to_utf8(file_path).c_str());
XELOGI("Loaded config: {}", xe::path_to_utf8(file_path));
}
void ReadGameConfig(const std::filesystem::path& file_path) {
@ -73,7 +73,7 @@ void ReadGameConfig(const std::filesystem::path& file_path) {
config_var->LoadGameConfigValue(config->get_qualified(config_key));
}
}
XELOGI("Loaded game config: %s", xe::path_to_utf8(file_path).c_str());
XELOGI("Loaded game config: {}", xe::path_to_utf8(file_path));
}
void SaveConfig() {

View File

@ -56,9 +56,10 @@ bool X64CodeCache::Initialize() {
if (!indirection_table_base_) {
XELOGE("Unable to allocate code cache indirection table");
XELOGE(
"This is likely because the %.8X-%.8X range is in use by some other "
"This is likely because the {:X}-{:X} range is in use by some other "
"system DLL",
kIndirectionTableBase, kIndirectionTableBase + kIndirectionTableSize);
static_cast<uint64_t>(kIndirectionTableBase),
kIndirectionTableBase + kIndirectionTableSize);
}
// Create mmap file. This allows us to share the code cache with the debugger.
@ -79,9 +80,10 @@ bool X64CodeCache::Initialize() {
if (!generated_code_base_) {
XELOGE("Unable to allocate code cache generated code storage");
XELOGE(
"This is likely because the %.8X-%.8X range is in use by some other "
"This is likely because the {:X}-{:X} range is in use by some other "
"system DLL",
kGeneratedCodeBase, kGeneratedCodeBase + kGeneratedCodeSize);
static_cast<uint64_t>(kGeneratedCodeBase),
kGeneratedCodeBase + kGeneratedCodeSize);
return false;
}

View File

@ -245,7 +245,7 @@ bool X64Emitter::Emit(HIRBuilder* builder, EmitFunctionInfo& func_info) {
// NOTE: If you encounter this after adding a new instruction, do a full
// rebuild!
assert_always();
XELOGE("Unable to process HIR opcode %s", instr->opcode->name);
XELOGE("Unable to process HIR opcode {}", instr->opcode->name);
break;
}
instr = new_tail;
@ -328,10 +328,10 @@ uint64_t TrapDebugPrint(void* raw_context, uint64_t address) {
// uint16_t str_len = uint16_t(thread_state->context()->r[4]);
auto str = thread_state->memory()->TranslateVirtual<const char*>(str_ptr);
// TODO(benvanik): truncate to length?
XELOGD("(DebugPrint) %s", str);
XELOGD("(DebugPrint) {}", str);
if (cvars::debugprint_trap_log) {
debugging::DebugPrint("(DebugPrint) %s", str);
debugging::DebugPrint("(DebugPrint) {}", str);
}
return 0;
@ -363,7 +363,7 @@ void X64Emitter::Trap(uint16_t trap_type) {
// ?
break;
default:
XELOGW("Unknown trap type %d", trap_type);
XELOGW("Unknown trap type {}", trap_type);
db(0xCC);
break;
}
@ -481,8 +481,8 @@ uint64_t UndefinedCallExtern(void* raw_context, uint64_t function_ptr) {
xe::FatalError(fmt::format("undefined extern call to {:08X} {}",
function->address(), function->name().c_str()));
} else {
XELOGE("undefined extern call to %.8X %s", function->address(),
function->name().c_str());
XELOGE("undefined extern call to {:08X} {}", function->address(),
function->name());
}
return 0;
}

View File

@ -3163,7 +3163,7 @@ bool SelectSequence(X64Emitter* e, const Instr* i, const Instr** new_tail) {
return true;
}
}
XELOGE("No sequence match for variant %s", i->opcode->name);
XELOGE("No sequence match for variant {}", i->opcode->name);
return false;
}

View File

@ -32,12 +32,13 @@ bool trace_enabled = true;
#define THREAD_MATCH \
(!TARGET_THREAD || thread_state->thread_id() == TARGET_THREAD)
#define IFLUSH()
#define IPRINT(s) \
if (trace_enabled && THREAD_MATCH) xe::LogLine(xe::LogLevel::Debug, 't', s)
#define IPRINT(s) \
if (trace_enabled && THREAD_MATCH) \
xe::logging::AppendLogLine(xe::LogLevel::Debug, 't', s)
#define DFLUSH()
#define DPRINT(...) \
if (trace_enabled && THREAD_MATCH) \
xe::LogLineFormat(xe::LogLevel::Debug, 't', __VA_ARGS__)
xe::logging::AppendLogLineFormat(xe::LogLevel::Debug, 't', __VA_ARGS__)
uint32_t GetTracingMode() {
uint32_t mode = 0;
@ -58,36 +59,35 @@ void TraceString(void* raw_context, const char* str) {
void TraceContextLoadI8(void* raw_context, uint64_t offset, uint8_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = ctx i8 +%" PRIu64 "\n", (int8_t)value, value, offset);
DPRINT("{} ({:X}) = ctx i8 +{}\n", (int8_t)value, value, offset);
}
void TraceContextLoadI16(void* raw_context, uint64_t offset, uint16_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = ctx i16 +%" PRIu64 "\n", (int16_t)value, value, offset);
DPRINT("{} ({:X}) = ctx i16 +{}\n", (int16_t)value, value, offset);
}
void TraceContextLoadI32(void* raw_context, uint64_t offset, uint32_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = ctx i32 +%" PRIu64 "\n", (int32_t)value, value, offset);
DPRINT("{} ({:X}) = ctx i32 +{}\n", (int32_t)value, value, offset);
}
void TraceContextLoadI64(void* raw_context, uint64_t offset, uint64_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%" PRId64 " (%" PRIX64 ") = ctx i64 +%" PRIu64 "\n", (int64_t)value,
value, offset);
DPRINT("{} ({:X}) = ctx i64 +{}\n", (int64_t)value, value, offset);
}
void TraceContextLoadF32(void* raw_context, uint64_t offset, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%e (%X) = ctx f32 +%" PRIu64 "\n", xe::m128_f32<0>(value),
DPRINT("{} ({:X}) = ctx f32 +{}\n", xe::m128_f32<0>(value),
xe::m128_i32<0>(value), offset);
}
void TraceContextLoadF64(void* raw_context, uint64_t offset,
const double* value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
auto v = _mm_loadu_pd(value);
DPRINT("%le (%" PRIX64 ") = ctx f64 +%" PRIu64 "\n", xe::m128_f64<0>(v),
xe::m128_i64<0>(v), offset);
DPRINT("{} ({:X}) = ctx f64 +{}\n", xe::m128_f64<0>(v), xe::m128_i64<0>(v),
offset);
}
void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%" PRIu64 "\n",
DPRINT("[{}, {}, {}, {}] [{:08X}, {:08X}, {:08X}, {:08X}] = ctx v128 +{}\n",
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
xe::m128_i32<2>(value), xe::m128_i32<3>(value), offset);
@ -95,36 +95,35 @@ void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) {
void TraceContextStoreI8(void* raw_context, uint64_t offset, uint8_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx i8 +%" PRIu64 " = %d (%X)\n", offset, (int8_t)value, value);
DPRINT("ctx i8 +{} = {} ({:X})\n", offset, (int8_t)value, value);
}
void TraceContextStoreI16(void* raw_context, uint64_t offset, uint16_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx i16 +%" PRIu64 " = %d (%X)\n", offset, (int16_t)value, value);
DPRINT("ctx i16 +{} = {} ({:X})\n", offset, (int16_t)value, value);
}
void TraceContextStoreI32(void* raw_context, uint64_t offset, uint32_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx i32 +%" PRIu64 " = %d (%X)\n", offset, (int32_t)value, value);
DPRINT("ctx i32 +{} = {} ({:X})\n", offset, (int32_t)value, value);
}
void TraceContextStoreI64(void* raw_context, uint64_t offset, uint64_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx i64 +%" PRIu64 " = %" PRId64 " (%" PRIX64 ")\n", offset,
(int64_t)value, value);
DPRINT("ctx i64 +{} = {} ({:X})\n", offset, (int64_t)value, value);
}
void TraceContextStoreF32(void* raw_context, uint64_t offset, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx f32 +%" PRIu64 " = %e (%X)\n", offset, xe::m128_f32<0>(value),
DPRINT("ctx f32 +{} = {} ({:X})\n", offset, xe::m128_f32<0>(value),
xe::m128_i32<0>(value));
}
void TraceContextStoreF64(void* raw_context, uint64_t offset,
const double* value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
auto v = _mm_loadu_pd(value);
DPRINT("ctx f64 +%" PRIu64 " = %le (%" PRIX64 ")\n", offset,
xe::m128_f64<0>(v), xe::m128_i64<0>(v));
DPRINT("ctx f64 +{} = {} ({:X})\n", offset, xe::m128_f64<0>(v),
xe::m128_i64<0>(v));
}
void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("ctx v128 +%" PRIu64 " = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n",
DPRINT("ctx v128 +{} = [{}, {}, {}, {}] [{:08X}, {:08X}, {:08X}, {:08X}]\n",
offset, xe::m128_f32<0>(value), xe::m128_f32<1>(value),
xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value),
xe::m128_i32<1>(value), xe::m128_i32<2>(value),
@ -133,80 +132,79 @@ void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) {
void TraceMemoryLoadI8(void* raw_context, uint32_t address, uint8_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = load.i8 %.8X\n", (int8_t)value, value, address);
DPRINT("{} ({:X}) = load.i8 {:08X}\n", (int8_t)value, value, address);
}
void TraceMemoryLoadI16(void* raw_context, uint32_t address, uint16_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = load.i16 %.8X\n", (int16_t)value, value, address);
DPRINT("{} ({:X}) = load.i16 {:08X}\n", (int16_t)value, value, address);
}
void TraceMemoryLoadI32(void* raw_context, uint32_t address, uint32_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%d (%X) = load.i32 %.8X\n", (int32_t)value, value, address);
DPRINT("{} ({:X}) = load.i32 {:08X}\n", (int32_t)value, value, address);
}
void TraceMemoryLoadI64(void* raw_context, uint32_t address, uint64_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%" PRId64 " (%" PRIX64 ") = load.i64 %.8X\n", (int64_t)value, value,
address);
DPRINT("{} ({:X}) = load.i64 {:08X}\n", (int64_t)value, value, address);
}
void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%e (%X) = load.f32 %.8X\n", xe::m128_f32<0>(value),
DPRINT("{} ({:X}) = load.f32 {:08X}\n", xe::m128_f32<0>(value),
xe::m128_i32<0>(value), address);
}
void TraceMemoryLoadF64(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("%le (%" PRIX64 ") = load.f64 %.8X\n", xe::m128_f64<0>(value),
DPRINT("{} ({:X}) = load.f64 {:08X}\n", xe::m128_f64<0>(value),
xe::m128_i64<0>(value), address);
}
void TraceMemoryLoadV128(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = load.v128 %.8X\n",
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
xe::m128_i32<2>(value), xe::m128_i32<3>(value), address);
DPRINT(
"[{}, {}, {}, {}] [{:08X}, {:08X}, {:08X}, {:08X}] = load.v128 {:08X}\n",
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
xe::m128_i32<2>(value), xe::m128_i32<3>(value), address);
}
void TraceMemoryStoreI8(void* raw_context, uint32_t address, uint8_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.i8 %.8X = %d (%X)\n", address, (int8_t)value, value);
DPRINT("store.i8 {:08X} = {} ({:X})\n", address, (int8_t)value, value);
}
void TraceMemoryStoreI16(void* raw_context, uint32_t address, uint16_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.i16 %.8X = %d (%X)\n", address, (int16_t)value, value);
DPRINT("store.i16 {:08X} = {} ({:X})\n", address, (int16_t)value, value);
}
void TraceMemoryStoreI32(void* raw_context, uint32_t address, uint32_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.i32 %.8X = %d (%X)\n", address, (int32_t)value, value);
DPRINT("store.i32 {:08X} = {} ({:X})\n", address, (int32_t)value, value);
}
void TraceMemoryStoreI64(void* raw_context, uint32_t address, uint64_t value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.i64 %.8X = %" PRId64 " (%" PRIX64 ")\n", address,
(int64_t)value, value);
DPRINT("store.i64 {:08X} = {} ({:X})\n", address, (int64_t)value, value);
}
void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.f32 %.8X = %e (%X)\n", address, xe::m128_f32<0>(value),
DPRINT("store.f32 {:08X} = {} ({:X})\n", address, xe::m128_f32<0>(value),
xe::m128_i32<0>(value));
}
void TraceMemoryStoreF64(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.f64 %.8X = %le (%" PRIX64 ")\n", address,
xe::m128_f64<0>(value), xe::m128_i64<0>(value));
DPRINT("store.f64 {:08X} = {} ({:X})\n", address, xe::m128_f64<0>(value),
xe::m128_i64<0>(value));
}
void TraceMemoryStoreV128(void* raw_context, uint32_t address, __m128 value) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("store.v128 %.8X = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n",
address, xe::m128_f32<0>(value), xe::m128_f32<1>(value),
xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value),
xe::m128_i32<1>(value), xe::m128_i32<2>(value),
xe::m128_i32<3>(value));
DPRINT(
"store.v128 {:08X} = [{}, {}, {}, {}] [{:08X}, {:08X}, {:08X}, {:08X}]\n",
address, xe::m128_f32<0>(value), xe::m128_f32<1>(value),
xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value),
xe::m128_i32<1>(value), xe::m128_i32<2>(value), xe::m128_i32<3>(value));
}
void TraceMemset(void* raw_context, uint32_t address, uint8_t value,
uint32_t length) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
DPRINT("memset %.8X-%.8X (%d) = %.2X", address, address + length, length,
value);
DPRINT("memset {:08X}-{:08X} ({}) = {:02X}", address, address + length,
length, value);
}
} // namespace x64

View File

@ -83,7 +83,7 @@ bool ElfModule::Load(const std::string_view name, const std::string_view path,
// Not a PPC ELF!
XELOGE(
"ELF: Could not load ELF because target machine is not PPC! (target: "
"%d)",
"{})",
uint32_t(hdr->e_machine));
return false;
}
@ -114,7 +114,7 @@ bool ElfModule::Load(const std::string_view name, const std::string_view path,
// Allocate and copy into memory.
// Base address @ 0x80000000
if (phdr[i].p_vaddr < 0x80000000 || phdr[i].p_vaddr > 0x9FFFFFFF) {
XELOGE("ELF: Could not allocate memory for section @ address 0x%.8X",
XELOGE("ELF: Could not allocate memory for section @ address {:#08X}",
uint32_t(phdr[i].p_vaddr));
return false;
}

View File

@ -32,16 +32,16 @@ FunctionDebugInfo::~FunctionDebugInfo() {
void FunctionDebugInfo::Dump() {
if (source_disasm_) {
XELOGD("PPC:\n%s\n", source_disasm_);
XELOGD("PPC:\n{}\n", source_disasm_);
}
if (raw_hir_disasm_) {
XELOGD("Unoptimized HIR:\n%s\n", raw_hir_disasm_);
XELOGD("Unoptimized HIR:\n{}\n", raw_hir_disasm_);
}
if (hir_disasm_) {
XELOGD("Optimized HIR:\n%s\n", hir_disasm_);
XELOGD("Optimized HIR:\n{}\n", hir_disasm_);
}
if (machine_code_disasm_) {
XELOGD("Machine Code:\n%s\n", machine_code_disasm_);
XELOGD("Machine Code:\n{}\n", machine_code_disasm_);
}
}

View File

@ -339,7 +339,7 @@ bool MMIOHandler::ExceptionCallback(Exception* ex) {
DecodedMov mov = {0};
bool decoded = TryDecodeMov(p, &mov);
if (!decoded) {
XELOGE("Unable to decode MMIO mov at %p", p);
XELOGE("Unable to decode MMIO mov at {}", p);
assert_always("Unknown MMIO instruction type");
return false;
}

View File

@ -22,8 +22,8 @@ namespace ppc {
#define XEREGISTERINSTR(name) \
RegisterOpcodeEmitter(PPCOpcode::name, InstrEmit_##name);
#define XEINSTRNOTIMPLEMENTED() \
XELOGE("Unimplemented instruction: %s", __FUNCTION__); \
#define XEINSTRNOTIMPLEMENTED() \
XELOGE("Unimplemented instruction: {}", __func__); \
assert_always("Instruction not implemented");
} // namespace ppc

View File

@ -146,7 +146,7 @@ bool PPCHIRBuilder::Emit(GuestFunction* function, uint32_t flags) {
instr_offset_list_[offset] = first_instr;
if (opcode == PPCOpcode::kInvalid) {
XELOGE("Invalid instruction %.8llX %.8X", address, code);
XELOGE("Invalid instruction {:08X} {:08X}", address, code);
Comment("INVALID!");
// TraceInvalidInstruction(i);
continue;
@ -169,7 +169,7 @@ bool PPCHIRBuilder::Emit(GuestFunction* function, uint32_t flags) {
i.opcode_info = &opcode_info;
if (!opcode_info.emit || opcode_info.emit(*this, i)) {
auto& disasm_info = GetOpcodeDisasmInfo(opcode);
XELOGE("Unimplemented instr %.8llX %.8X %s", address, code,
XELOGE("Unimplemented instr {:08X} {:08X} {}", address, code,
disasm_info.name);
Comment("UNIMPLEMENTED!");
DebugBreak();

View File

@ -51,7 +51,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
Memory* memory = frontend_->memory();
LOGPPC("Analyzing function %.8X...", function->address());
LOGPPC("Analyzing function {:08X}...", function->address());
// For debug info, only if needed.
uint32_t address_reference_count = 0;
@ -71,7 +71,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// If we fetched 0 assume that we somehow hit one of the awesome
// 'no really we meant to end after that bl' functions.
if (!code) {
LOGPPC("function end %.8X (0x00000000 read)", address);
LOGPPC("function end {:08X} (0x00000000 read)", address);
// Don't include the 0's.
address -= 4;
break;
@ -106,16 +106,17 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// Invalid instruction.
// We can just ignore it because there's (very little)/no chance it'll
// affect flow control.
LOGPPC("Invalid instruction at %.8X: %.8X", address, code);
LOGPPC("Invalid instruction at {:08X}: {:08X}", address, code);
} else if (code == 0x4E800020) {
// blr -- unconditional branch to LR.
// This is generally a return.
if (furthest_target > address) {
// Remaining targets within function, not end.
LOGPPC("ignoring blr %.8X (branch to %.8X)", address, furthest_target);
LOGPPC("ignoring blr {:08X} (branch to {:08X})", address,
furthest_target);
} else {
// Function end point.
LOGPPC("function end %.8X", address);
LOGPPC("function end {:08X}", address);
ends_fn = true;
}
ends_block = true;
@ -126,10 +127,11 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// TODO(benvanik): decode jump tables.
if (furthest_target > address) {
// Remaining targets within function, not end.
LOGPPC("ignoring bctr %.8X (branch to %.8X)", address, furthest_target);
LOGPPC("ignoring bctr {:08X} (branch to {:08X})", address,
furthest_target);
} else {
// Function end point.
LOGPPC("function end %.8X", address);
LOGPPC("function end {:08X}", address);
ends_fn = true;
}
ends_block = true;
@ -137,25 +139,25 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// b/ba/bl/bla
uint32_t target = d.I.ADDR();
if (d.I.LK()) {
LOGPPC("bl %.8X -> %.8X", address, target);
LOGPPC("bl {:08X} -> {:08X}", address, target);
// Queue call target if needed.
// GetOrInsertFunction(target);
} else {
LOGPPC("b %.8X -> %.8X", address, target);
LOGPPC("b {:08X} -> {:08X}", address, target);
// If the target is back into the function and there's no further target
// we are at the end of a function.
// (Indirect branches may still go beyond, but no way of knowing).
if (target >= start_address && target < address &&
furthest_target <= address) {
LOGPPC("function end %.8X (back b)", address);
LOGPPC("function end {:08X} (back b)", address);
ends_fn = true;
}
// If the target is not a branch and it goes to before the current
// address it's definitely a tail call.
if (!ends_fn && target < start_address && furthest_target <= address) {
LOGPPC("function end %.8X (back b before addr)", address);
LOGPPC("function end {:08X} (back b before addr)", address);
ends_fn = true;
}
@ -164,7 +166,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// of the function somewhere, so ensure we don't have any branches over
// it.
if (!ends_fn && furthest_target <= address && IsRestGprLr(target)) {
LOGPPC("function end %.8X (__restgprlr_*)", address);
LOGPPC("function end {:08X} (__restgprlr_*)", address);
ends_fn = true;
}
@ -176,7 +178,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// This check may hit on functions that jump over data code, so only
// trigger this check in leaf functions (no mfspr lr/prolog).
if (!ends_fn && !starts_with_mfspr_lr && blocks_found == 1) {
LOGPPC("HEURISTIC: ending at simple leaf thunk %.8X", address);
LOGPPC("HEURISTIC: ending at simple leaf thunk {:08X}", address);
ends_fn = true;
}
@ -213,14 +215,14 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// bc/bca/bcl/bcla
uint32_t target = d.B.ADDR();
if (d.B.LK()) {
LOGPPC("bcl %.8X -> %.8X", address, target);
LOGPPC("bcl {:08X} -> {:08X}", address, target);
// Queue call target if needed.
// TODO(benvanik): see if this is correct - not sure anyone makes
// function calls with bcl.
// GetOrInsertFunction(target);
} else {
LOGPPC("bc %.8X -> %.8X", address, target);
LOGPPC("bc {:08X} -> {:08X}", address, target);
// TODO(benvanik): GetOrInsertFunction? it's likely a BB
@ -232,17 +234,17 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
} else if (opcode == PPCOpcode::bclrx) {
// bclr/bclrl
if (d.XL.LK()) {
LOGPPC("bclrl %.8X", address);
LOGPPC("bclrl {:08X}", address);
} else {
LOGPPC("bclr %.8X", address);
LOGPPC("bclr {:08X}", address);
}
ends_block = true;
} else if (opcode == PPCOpcode::bcctrx) {
// bcctr/bcctrl
if (d.XL.LK()) {
LOGPPC("bcctrl %.8X", address);
LOGPPC("bcctrl {:08X}", address);
} else {
LOGPPC("bcctr %.8X", address);
LOGPPC("bcctr {:08X}", address);
}
ends_block = true;
}
@ -257,7 +259,8 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
address += 4;
if (end_address && address > end_address) {
// Hmm....
LOGPPC("Ran over function bounds! %.8X-%.8X", start_address, end_address);
LOGPPC("Ran over function bounds! {:08X}-{:08X}", start_address,
end_address);
break;
}
}
@ -267,7 +270,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// from someplace valid (like method hints) this may indicate an error.
// It's also possible that we guessed in hole-filling and there's another
// function below this one.
LOGPPC("Function ran under: %.8X-%.8X ended at %.8X", start_address,
LOGPPC("Function ran under: {:08X}-{:08X} ended at {:08X}", start_address,
end_address, address + 4);
}
function->set_end_address(address);
@ -285,7 +288,7 @@ bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
debug_info->set_instruction_result_count(instruction_result_count);
}
LOGPPC("Finished analyzing %.8X", start_address);
LOGPPC("Finished analyzing {:08X}", start_address);
return true;
}

View File

@ -61,13 +61,13 @@ class TestSuite {
bool Load() {
if (!ReadMap()) {
XELOGE("Unable to read map for test %s",
xe::path_to_utf8(src_file_path_).c_str());
XELOGE("Unable to read map for test {}",
xe::path_to_utf8(src_file_path_));
return false;
}
if (!ReadAnnotations()) {
XELOGE("Unable to read annotations for test %s",
xe::path_to_utf8(src_file_path_).c_str());
XELOGE("Unable to read annotations for test {}",
xe::path_to_utf8(src_file_path_));
return false;
}
return true;
@ -144,8 +144,8 @@ class TestSuite {
std::string label(start + strlen("test_"), strchr(start, ':'));
current_test_case = FindTestCase(label);
if (!current_test_case) {
XELOGE("Test case %s not found in corresponding map for %s",
label.c_str(), xe::path_to_utf8(src_file_path_).c_str());
XELOGE("Test case {} not found in corresponding map for {}", label,
xe::path_to_utf8(src_file_path_));
return false;
}
} else if (strlen(start) > 3 && start[0] == '#' && start[1] == '_') {
@ -160,8 +160,8 @@ class TestSuite {
value.erase(value.end() - 1);
}
if (!current_test_case) {
XELOGE("Annotation outside of test case in %s",
xe::path_to_utf8(src_file_path_).c_str());
XELOGE("Annotation outside of test case in {}",
xe::path_to_utf8(src_file_path_));
return false;
}
current_test_case->annotations.emplace_back(key, value);
@ -214,8 +214,8 @@ class TestRunner {
// Load the binary module.
auto module = std::make_unique<xe::cpu::RawModule>(processor_.get());
if (!module->LoadFile(START_ADDRESS, suite.bin_file_path())) {
XELOGE("Unable to load test binary %s",
xe::path_to_utf8(suite.bin_file_path).c_str());
XELOGE("Unable to load test binary {}",
xe::path_to_utf8(suite.bin_file_path()));
return false;
}
processor_->AddModule(std::move(module));
@ -313,9 +313,9 @@ class TestRunner {
if (!ppc_context->CompareRegWithString(
reg_name.c_str(), reg_value.c_str(), actual_value)) {
any_failed = true;
XELOGE("Register %s assert failed:\n", reg_name.c_str());
XELOGE(" Expected: %s == %s\n", reg_name.c_str(), reg_value.c_str());
XELOGE(" Actual: %s == %s\n", reg_name.c_str(), actual_value);
XELOGE("Register {} assert failed:\n", reg_name);
XELOGE(" Expected: {} == {}\n", reg_name, reg_value);
XELOGE(" Actual: {} == {}\n", reg_name, actual_value);
}
} else if (it.first == "MEMORY_OUT") {
size_t space_pos = it.second.find(" ");
@ -338,9 +338,9 @@ class TestRunner {
uint8_t actual = *p;
if (expected != actual) {
any_failed = true;
XELOGE("Memory %s assert failed:\n", address_str.c_str());
XELOGE(" Expected: %.8X %.2X\n", current_address, expected);
XELOGE(" Actual: %.8X %.2X\n", current_address, actual);
XELOGE("Memory {} assert failed:\n", address_str);
XELOGE(" Expected: {:08X} {:02X}\n", current_address, expected);
XELOGE(" Actual: {:08X} {:02X}\n", current_address, actual);
}
++p;
}
@ -418,7 +418,7 @@ bool RunTests(const std::string_view test_name) {
XELOGE("No tests discovered - invalid path?");
return false;
}
XELOGI("%d tests discovered.", (int)test_files.size());
XELOGI("{} tests discovered.", test_files.size());
XELOGI("");
std::vector<TestSuite> test_suites;
@ -429,8 +429,7 @@ bool RunTests(const std::string_view test_name) {
continue;
}
if (!test_suite.Load()) {
XELOGE("TEST SUITE %s FAILED TO LOAD",
xe::path_to_utf8(test_path).c_str());
XELOGE("TEST SUITE {} FAILED TO LOAD", xe::path_to_utf8(test_path));
load_failed = true;
continue;
}
@ -440,13 +439,13 @@ bool RunTests(const std::string_view test_name) {
XELOGE("One or more test suites failed to load.");
}
XELOGI("%d tests loaded.", (int)test_suites.size());
XELOGI("{} tests loaded.", test_suites.size());
TestRunner runner;
for (auto& test_suite : test_suites) {
XELOGI("%s.s:", xe::path_to_utf8(test_suite.name()).c_str());
XELOGI("{}.s:", test_suite.name());
for (auto& test_case : test_suite.test_cases()) {
XELOGI(" - %s", test_case.name.c_str());
XELOGI(" - {}", test_case.name);
ProtectedRunTest(test_suite, runner, test_case, failed_count,
passed_count);
}
@ -455,9 +454,9 @@ bool RunTests(const std::string_view test_name) {
}
XELOGI("");
XELOGI("Total tests: %d", failed_count + passed_count);
XELOGI("Passed: %d", passed_count);
XELOGI("Failed: %d", failed_count);
XELOGI("Total tests: {}", failed_count + passed_count);
XELOGI("Passed: {}", passed_count);
XELOGI("Failed: {}", failed_count);
return failed_count ? false : true;
}

View File

@ -323,7 +323,7 @@ bool Processor::Execute(ThreadState* thread_state, uint32_t address) {
auto function = ResolveFunction(address);
if (!function) {
// Symbol not found in any module.
XELOGCPU("Execute(%.8X): failed to find function", address);
XELOGCPU("Execute({:08X}): failed to find function", address);
return false;
}
@ -354,7 +354,7 @@ bool Processor::ExecuteRaw(ThreadState* thread_state, uint32_t address) {
auto function = ResolveFunction(address);
if (!function) {
// Symbol not found in any module.
XELOGCPU("Execute(%.8X): failed to find function", address);
XELOGCPU("Execute({:08X}): failed to find function", address);
return false;
}
@ -973,8 +973,9 @@ bool Processor::StepToGuestAddress(uint32_t thread_id, uint32_t pc) {
if (functions.empty()) {
// Function hasn't been generated yet. Generate it.
if (!ResolveFunction(pc)) {
XELOGE("Processor::StepToAddress(%.8X) - Function could not be resolved",
pc);
XELOGE(
"Processor::StepToAddress({:08X}) - Function could not be resolved",
pc);
return false;
}
}

View File

@ -128,7 +128,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const {
ordinal -= export_table->base;
if (ordinal > export_table->count) {
XELOGE("GetProcAddress(%.3X): ordinal out of bounds", ordinal);
XELOGE("GetProcAddress({:03X}): ordinal out of bounds", ordinal);
return 0;
}
@ -290,7 +290,7 @@ int XexModule::ApplyPatch(XexModule* module) {
&patch_header->info, headerpatch_size,
file_format_header->compression_info.normal.window_size, header_ptr);
if (result_code) {
XELOGE("XEX header patch application failed, error code %d", result_code);
XELOGE("XEX header patch application failed, error code {}", result_code);
return result_code;
}
@ -315,7 +315,7 @@ int XexModule::ApplyPatch(XexModule* module) {
xe::kMemoryProtectRead | xe::kMemoryProtectWrite);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", addr_new_mem,
XELOGE("Unable to allocate XEX memory at {:08X}-{:08X}.", addr_new_mem,
size_delta);
assert_always();
return 6;
@ -440,7 +440,7 @@ int XexModule::ApplyPatch(XexModule* module) {
->Decommit(addr_free_mem, size_delta);
if (!free_result) {
XELOGE("Unable to decommit XEX memory at %.8X-%.8X.", addr_free_mem,
XELOGE("Unable to decommit XEX memory at {:08X}-{:08X}.", addr_free_mem,
size_delta);
assert_always();
}
@ -455,12 +455,12 @@ int XexModule::ApplyPatch(XexModule* module) {
xe::byte_swap<uint32_t>(patch_header->target_version.value);
XELOGI(
"XEX patch applied successfully: base version: %d.%d.%d.%d, new "
"version: %d.%d.%d.%d",
"XEX patch applied successfully: base version: {}.{}.{}.{}, new "
"version: {}.{}.{}.{}",
source_ver.major, source_ver.minor, source_ver.build, source_ver.qfe,
target_ver.major, target_ver.minor, target_ver.build, target_ver.qfe);
} else {
XELOGE("XEX patch application failed, error code %d", result_code);
XELOGE("XEX patch application failed, error code {}", result_code);
}
if (free_input) {
@ -536,7 +536,7 @@ int XexModule::ReadImageUncompressed(const void* xex_addr, size_t xex_length) {
xe::kMemoryAllocationReserve | xe::kMemoryAllocationCommit,
xe::kMemoryProtectRead | xe::kMemoryProtectWrite);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", base_address_,
XELOGE("Unable to allocate XEX memory at {:08X}-{:08X}.", base_address_,
uncompressed_size);
return 2;
}
@ -603,7 +603,7 @@ int XexModule::ReadImageBasicCompressed(const void* xex_addr,
xe::kMemoryAllocationReserve | xe::kMemoryAllocationCommit,
xe::kMemoryProtectRead | xe::kMemoryProtectWrite);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", base_address_,
XELOGE("Unable to allocate XEX memory at {:08X}-{:08X}.", base_address_,
uncompressed_size);
return 1;
}
@ -761,7 +761,7 @@ int XexModule::ReadImageCompressed(const void* xex_addr, size_t xex_length) {
compress_buffer, d - compress_buffer, buffer, uncompressed_size,
compression_info->normal.window_size, nullptr, 0);
} else {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", base_address_,
XELOGE("Unable to allocate XEX memory at {:08X}-{:08X}.", base_address_,
uncompressed_size);
result_code = 3;
}
@ -933,12 +933,12 @@ bool XexModule::Load(const std::string_view name, const std::string_view path,
// We'll try using both XEX2 keys to see if any give a valid PE
int result_code = ReadImage(xex_addr, xex_length, false);
if (result_code) {
XELOGW("XEX load failed with code %d, trying with devkit encryption key...",
XELOGW("XEX load failed with code {}, trying with devkit encryption key...",
result_code);
result_code = ReadImage(xex_addr, xex_length, true);
if (result_code) {
XELOGE("XEX load failed with code %d, tried both encryption keys",
XELOGE("XEX load failed with code {}, tried both encryption keys",
result_code);
return false;
}
@ -1132,9 +1132,9 @@ bool XexModule::SetupLibraryImports(const std::string_view name,
// Import not resolved?
if (!kernel_export && !user_export_addr) {
XELOGW(
"WARNING: an import variable was not resolved! (library: %s, import "
"lib: %s, ordinal: %.3X)",
name_.c_str(), name.c_str(), ordinal);
"WARNING: an import variable was not resolved! (library: {}, import "
"lib: {}, ordinal: {:03X})",
name_, name, ordinal);
}
StringBuffer import_name;
@ -1166,7 +1166,7 @@ bool XexModule::SetupLibraryImports(const std::string_view name,
} else {
// Not implemented - write with a dummy value.
*record_slot = 0xD000BEEF | (kernel_export->ordinal & 0xFFF) << 16;
XELOGCPU("WARNING: imported a variable with no value: %s",
XELOGCPU("WARNING: imported a variable with no value: {}",
kernel_export->name);
}
}
@ -1251,8 +1251,8 @@ bool XexModule::SetupLibraryImports(const std::string_view name,
(GuestFunction::ExternHandler)kernel_export->function_data.shim;
}
} else {
XELOGW("WARNING: Imported kernel function %s is unimplemented!",
import_name.buffer());
XELOGW("WARNING: Imported kernel function {} is unimplemented!",
import_name.to_string_view());
}
static_cast<GuestFunction*>(function)->SetupExtern(handler,
kernel_export);

View File

@ -546,23 +546,24 @@ bool Emulator::ExceptionCallback(Exception* ex) {
auto context = current_thread->thread_state()->context();
XELOGE("==== CRASH DUMP ====");
XELOGE("Thread ID (Host: 0x%.8X / Guest: 0x%.8X)",
XELOGE("Thread ID (Host: {:#08X} / Guest: {:#08X})",
current_thread->thread()->system_id(), current_thread->thread_id());
XELOGE("Thread Handle: 0x%.8X", current_thread->handle());
XELOGE("PC: 0x%.8X", guest_function->MapMachineCodeToGuestAddress(ex->pc()));
XELOGE("Thread Handle: {:#08X}", current_thread->handle());
XELOGE("PC: {:#08X}", guest_function->MapMachineCodeToGuestAddress(ex->pc()));
XELOGE("Registers:");
for (int i = 0; i < 32; i++) {
XELOGE(" r%-3d = 0x%.16" PRIX64, i, context->r[i]);
XELOGE(" r{:-3d} = {:016X}", i, context->r[i]);
}
for (int i = 0; i < 32; i++) {
XELOGE(" f%-3d = 0x%.16" PRIX64 " = (double)%f = (float)%f", i,
context->f[i], context->f[i], *(float*)&context->f[i]);
XELOGE(" f{:-3d} = {:08X} = (double){} = (float){}", i, context->f[i],
context->f[i], *(float*)&context->f[i]);
}
for (int i = 0; i < 128; i++) {
XELOGE(" v%-3d = [0x%.8X, 0x%.8X, 0x%.8X, 0x%.8X]", i, context->v[i].i32[0],
context->v[i].i32[1], context->v[i].i32[2], context->v[i].i32[3]);
XELOGE(" v{:-3d} = [{:#08X}, {:#08X}, {:#08X}, {:#08X}]", i,
context->v[i].i32[0], context->v[i].i32[1], context->v[i].i32[2],
context->v[i].i32[3]);
}
// Display a dialog telling the user the guest has crashed.
@ -621,14 +622,14 @@ std::string Emulator::FindLaunchModule() {
if (XSUCCEEDED(result)) {
kernel::util::GameInfo info(buffer);
if (info.is_valid()) {
XELOGI("Found virtual title %s", info.virtual_title_id().c_str());
XELOGI("Found virtual title {}", info.virtual_title_id());
const std::string xna_id("584E07D1");
auto xna_id_entry(file_system_->ResolvePath(path + xna_id));
if (xna_id_entry) {
default_module = xna_id + "\\" + info.module_name();
} else {
XELOGE("Could not find fixed XNA path %s", xna_id.c_str());
XELOGE("Could not find fixed XNA path {}", xna_id);
}
}
}
@ -648,10 +649,10 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
// Allow xam to request module loads.
auto xam = kernel_state()->GetKernelModule<kernel::xam::XamModule>("xam.xex");
XELOGI("Launching module %s", module_path.c_str());
XELOGI("Launching module {}", module_path);
auto module = kernel_state_->LoadUserModule(module_path);
if (!module) {
XELOGE("Failed to load user module %s", xe::path_to_utf8(path).c_str());
XELOGE("Failed to load user module {}", xe::path_to_utf8(path));
return X_STATUS_NOT_FOUND;
}

View File

@ -284,13 +284,13 @@ void CommandProcessor::UpdateWritePointer(uint32_t value) {
void CommandProcessor::WriteRegister(uint32_t index, uint32_t value) {
RegisterFile* regs = register_file_;
if (index >= RegisterFile::kRegisterCount) {
XELOGW("CommandProcessor::WriteRegister index out of bounds: %d", index);
XELOGW("CommandProcessor::WriteRegister index out of bounds: {}", index);
return;
}
regs->values[index].u32 = value;
if (!regs->GetRegisterInfo(index)) {
XELOGW("GPU: Write to unknown register (%.4X = %.8X)", index, value);
XELOGW("GPU: Write to unknown register ({:04X} = {:08X})", index, value);
}
// If this is a COHER register, set the dirty flag.
@ -376,7 +376,7 @@ void CommandProcessor::MakeCoherent() {
}
// TODO(benvanik): notify resource cache of base->size and type.
XELOGD("Make %.8X -> %.8X (%db) coherent, action = %s", base_host,
XELOGD("Make {:08X} -> {:08X} ({}b) coherent, action = {}", base_host,
base_host + size_host, size_host, action);
// Mark coherent.
@ -541,8 +541,9 @@ bool CommandProcessor::ExecutePacketType0(RingBuffer* reader, uint32_t packet) {
uint32_t count = ((packet >> 16) & 0x3FFF) + 1;
if (reader->read_count() < count * sizeof(uint32_t)) {
XELOGE("ExecutePacketType0 overflow (read count %.8X, packet count %.8X)",
reader->read_count(), count * sizeof(uint32_t));
XELOGE(
"ExecutePacketType0 overflow (read count {:08X}, packet count {:08X})",
reader->read_count(), count * sizeof(uint32_t));
return false;
}
@ -589,8 +590,9 @@ bool CommandProcessor::ExecutePacketType3(RingBuffer* reader, uint32_t packet) {
auto data_start_offset = reader->read_offset();
if (reader->read_count() < count * sizeof(uint32_t)) {
XELOGE("ExecutePacketType3 overflow (read count %.8X, packet count %.8X)",
reader->read_count(), count * sizeof(uint32_t));
XELOGE(
"ExecutePacketType3 overflow (read count {:08X}, packet count {:08X})",
reader->read_count(), count * sizeof(uint32_t));
return false;
}
@ -728,14 +730,14 @@ bool CommandProcessor::ExecutePacketType3(RingBuffer* reader, uint32_t packet) {
case PM4_CONTEXT_UPDATE: {
assert_true(count == 1);
uint64_t value = reader->ReadAndSwap<uint32_t>();
XELOGGPU("GPU context update = %.8X", value);
XELOGGPU("GPU context update = {:08X}", value);
assert_true(value == 0);
result = true;
break;
}
default:
XELOGGPU("Unimplemented GPU OPCODE: 0x%.2X\t\tCOUNT: %d\n", opcode,
XELOGGPU("Unimplemented GPU OPCODE: {:#02X}\t\tCOUNT: {}\n", opcode,
count);
assert_always();
reader->AdvanceRead(count * sizeof(uint32_t));
@ -1200,7 +1202,7 @@ bool CommandProcessor::ExecutePacketType3_DRAW_INDX(RingBuffer* reader,
xenos::IsMajorModeExplicit(vgt_draw_initiator.major_mode,
vgt_draw_initiator.prim_type));
if (!success) {
XELOGE("PM4_DRAW_INDX(%d, %d, %d): Failed in backend",
XELOGE("PM4_DRAW_INDX({}, {}, {}): Failed in backend",
vgt_draw_initiator.num_indices,
uint32_t(vgt_draw_initiator.prim_type),
uint32_t(vgt_draw_initiator.source_select));
@ -1231,7 +1233,7 @@ bool CommandProcessor::ExecutePacketType3_DRAW_INDX_2(RingBuffer* reader,
xenos::IsMajorModeExplicit(vgt_draw_initiator.major_mode,
vgt_draw_initiator.prim_type));
if (!success) {
XELOGE("PM4_DRAW_INDX_IMM(%d, %d): Failed in backend",
XELOGE("PM4_DRAW_INDX_IMM({}, {}): Failed in backend",
vgt_draw_initiator.num_indices,
uint32_t(vgt_draw_initiator.prim_type));
}
@ -1426,11 +1428,11 @@ bool CommandProcessor::ExecutePacketType3_VIZ_QUERY(RingBuffer* reader,
if (!end) {
// begin a new viz query @ id
WriteRegister(XE_GPU_REG_VGT_EVENT_INITIATOR, VIZQUERY_START);
XELOGGPU("Begin viz query ID %.2X", id);
XELOGGPU("Begin viz query ID {:02X}", id);
} else {
// end the viz query
WriteRegister(XE_GPU_REG_VGT_EVENT_INITIATOR, VIZQUERY_END);
XELOGGPU("End viz query ID %.2X", id);
XELOGGPU("End viz query ID {:02X}", id);
}
return true;

View File

@ -419,8 +419,8 @@ ID3D12RootSignature* D3D12CommandProcessor::GetRootSignature(
GetD3D12Context()->GetD3D12Provider(), desc);
if (root_signature == nullptr) {
XELOGE(
"Failed to create a root signature with %u pixel textures, %u pixel "
"samplers, %u vertex textures and %u vertex samplers",
"Failed to create a root signature with {} pixel textures, {} pixel "
"samplers, {} vertex textures and {} vertex samplers",
texture_count_pixel, sampler_count_pixel, texture_count_vertex,
sampler_count_vertex);
return nullptr;
@ -544,7 +544,7 @@ ID3D12Resource* D3D12CommandProcessor::RequestScratchGPUBuffer(
if (FAILED(device->CreateCommittedResource(
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
&buffer_desc, state, nullptr, IID_PPV_ARGS(&buffer)))) {
XELOGE("Failed to create a %u MB scratch GPU buffer", size >> 20);
XELOGE("Failed to create a {} MB scratch GPU buffer", size >> 20);
return nullptr;
}
if (scratch_buffer_ != nullptr) {
@ -1492,20 +1492,22 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
break;
}
XELOGW(
"Vertex fetch constant %u (%.8X %.8X) has \"invalid\" type! This "
"Vertex fetch constant {} ({:08X} {:08X}) has \"invalid\" type! "
"This "
"is incorrect behavior, but you can try bypassing this by "
"launching Xenia with --gpu_allow_invalid_fetch_constants=true.",
vfetch_index, vfetch_constant.dword_0, vfetch_constant.dword_1);
return false;
default:
XELOGW("Vertex fetch constant %u (%.8X %.8X) is completely invalid!",
vfetch_index, vfetch_constant.dword_0, vfetch_constant.dword_1);
XELOGW(
"Vertex fetch constant {} ({:08X} {:08X}) is completely invalid!",
vfetch_index, vfetch_constant.dword_0, vfetch_constant.dword_1);
return false;
}
if (!shared_memory_->RequestRange(vfetch_constant.address << 2,
vfetch_constant.size << 2)) {
XELOGE(
"Failed to request vertex buffer at 0x%.8X (size %u) in the shared "
"Failed to request vertex buffer at {:#08X} (size {}) in the shared "
"memory",
vfetch_constant.address << 2, vfetch_constant.size << 2);
return false;
@ -1534,7 +1536,7 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
uint32_t memexport_format_size =
GetSupportedMemExportFormatSize(memexport_stream.format);
if (memexport_format_size == 0) {
XELOGE("Unsupported memexport format %s",
XELOGE("Unsupported memexport format {}",
FormatInfo::Get(TextureFormat(uint32_t(memexport_stream.format)))
->name);
return false;
@ -1576,7 +1578,7 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
uint32_t memexport_format_size =
GetSupportedMemExportFormatSize(memexport_stream.format);
if (memexport_format_size == 0) {
XELOGE("Unsupported memexport format %s",
XELOGE("Unsupported memexport format {}",
FormatInfo::Get(TextureFormat(uint32_t(memexport_stream.format)))
->name);
return false;
@ -1607,7 +1609,7 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
if (!shared_memory_->RequestRange(memexport_range.base_address_dwords << 2,
memexport_range.size_dwords << 2)) {
XELOGE(
"Failed to request memexport stream at 0x%.8X (size %u) in the "
"Failed to request memexport stream at {:#08X} (size {}) in the "
"shared memory",
memexport_range.base_address_dwords << 2,
memexport_range.size_dwords << 2);
@ -1653,7 +1655,7 @@ bool D3D12CommandProcessor::IssueDraw(PrimitiveType primitive_type,
uint32_t index_buffer_size = index_buffer_info->count * index_size;
if (!shared_memory_->RequestRange(index_base, index_buffer_size)) {
XELOGE(
"Failed to request index buffer at 0x%.8X (size %u) in the shared "
"Failed to request index buffer at {:#08X} (size {}) in the shared "
"memory",
index_base, index_buffer_size);
return false;
@ -3477,7 +3479,7 @@ ID3D12Resource* D3D12CommandProcessor::RequestReadbackBuffer(uint32_t size) {
&ui::d3d12::util::kHeapPropertiesReadback, D3D12_HEAP_FLAG_NONE,
&buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS(&buffer)))) {
XELOGE("Failed to create a %u MB readback buffer", size >> 20);
XELOGE("Failed to create a {} MB readback buffer", size >> 20);
return nullptr;
}
if (readback_buffer_ != nullptr) {

View File

@ -363,8 +363,7 @@ void PipelineCache::InitializeShaderStorage(
delete shader;
}
}
XELOGGPU("Translated %zu shaders from the storage in %" PRIu64
" milliseconds",
XELOGGPU("Translated {} shaders from the storage in {} milliseconds",
shaders_translated,
(xe::Clock::QueryHostTickCount() -
shader_storage_initialization_start) *
@ -580,8 +579,8 @@ void PipelineCache::InitializeShaderStorage(
}
}
XELOGGPU(
"Created %zu graphics pipeline state objects from the storage in "
"%" PRIu64 " milliseconds",
"Created {} graphics pipeline state objects from the storage in {} "
"milliseconds",
pipeline_states_created,
(xe::Clock::QueryHostTickCount() -
pipeline_state_storage_initialization_start_) *
@ -770,7 +769,7 @@ Shader::HostVertexShaderType PipelineCache::GetHostVertexShaderTypeIfValid()
// tessellation.
}
XELOGE(
"Unsupported tessellation mode %u for primitive type %u. Report the game "
"Unsupported tessellation mode {} for primitive type {}. Report the game "
"to Xenia developers!",
uint32_t(tessellation_mode), uint32_t(vgt_draw_initiator.prim_type));
return Shader::HostVertexShaderType(-1);
@ -931,7 +930,7 @@ bool PipelineCache::TranslateShader(
// Perform translation.
// If this fails the shader will be marked as invalid and ignored later.
if (!translator.Translate(shader, cntl, host_vertex_shader_type)) {
XELOGE("Shader %.16" PRIX64 " translation failed; marking as ignored",
XELOGE("Shader {:016X} translation failed; marking as ignored",
shader->ucode_data_hash());
return false;
}
@ -973,7 +972,7 @@ bool PipelineCache::TranslateShader(
} else {
host_shader_type = "pixel";
}
XELOGGPU("Generated %s shader (%db) - hash %.16" PRIX64 ":\n%s\n",
XELOGGPU("Generated {} shader ({}b) - hash {:016X}:\n{}\n",
host_shader_type, shader->ucode_dword_count() * 4,
shader->ucode_data_hash(), shader->ucode_disassembly().c_str());
}
@ -992,7 +991,7 @@ bool PipelineCache::TranslateShader(
if (cvars::d3d12_dxbc_disasm) {
auto provider = command_processor_->GetD3D12Context()->GetD3D12Provider();
if (!shader->DisassembleDxbc(provider)) {
XELOGE("Failed to disassemble DXBC shader %.16" PRIX64,
XELOGE("Failed to disassemble DXBC shader {:016X}",
shader->ucode_data_hash());
}
}
@ -1364,12 +1363,13 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
const PipelineDescription& description = runtime_description.description;
if (runtime_description.pixel_shader != nullptr) {
XELOGGPU("Creating graphics pipeline state with VS %.16" PRIX64
", PS %.16" PRIX64,
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
XELOGGPU(
"Creating graphics pipeline state with VS {:016X}"
", PS {:016X}",
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
} else {
XELOGGPU("Creating graphics pipeline state with VS %.16" PRIX64,
XELOGGPU("Creating graphics pipeline state with VS {:016X}",
runtime_description.vertex_shader->ucode_data_hash());
}
@ -1395,7 +1395,7 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
// Primitive topology, vertex, hull, domain and geometry shaders.
if (!runtime_description.vertex_shader->is_translated()) {
XELOGE("Vertex shader %.16" PRIX64 " not translated",
XELOGE("Vertex shader {:016X} not translated",
runtime_description.vertex_shader->ucode_data_hash());
assert_always();
return nullptr;
@ -1404,10 +1404,10 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
description.host_vertex_shader_type;
if (runtime_description.vertex_shader->host_vertex_shader_type() !=
host_vertex_shader_type) {
XELOGE("Vertex shader %.16" PRIX64
" translated into the wrong host shader "
"type",
runtime_description.vertex_shader->ucode_data_hash());
XELOGE(
"Vertex shader {:016X} translated into the wrong host shader "
"type",
runtime_description.vertex_shader->ucode_data_hash());
assert_always();
return nullptr;
}
@ -1511,7 +1511,7 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
// Pixel shader.
if (runtime_description.pixel_shader != nullptr) {
if (!runtime_description.pixel_shader->is_translated()) {
XELOGE("Pixel shader %.16" PRIX64 " not translated",
XELOGE("Pixel shader {:016X} not translated",
runtime_description.pixel_shader->ucode_data_hash());
assert_always();
return nullptr;
@ -1681,12 +1681,13 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
if (FAILED(device->CreateGraphicsPipelineState(&state_desc,
IID_PPV_ARGS(&state)))) {
if (runtime_description.pixel_shader != nullptr) {
XELOGE("Failed to create graphics pipeline state with VS %.16" PRIX64
", PS %.16" PRIX64,
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
XELOGE(
"Failed to create graphics pipeline state with VS {:016X}"
", PS {:016X}",
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
} else {
XELOGE("Failed to create graphics pipeline state with VS %.16" PRIX64,
XELOGE("Failed to create graphics pipeline state with VS {:016X}",
runtime_description.vertex_shader->ucode_data_hash());
}
return nullptr;

View File

@ -702,7 +702,7 @@ void* PrimitiveConverter::AllocateIndices(
buffer_pool_->Request(command_processor_->GetCurrentFrame(), size,
nullptr, nullptr, &gpu_address);
if (mapping == nullptr) {
XELOGE("Failed to allocate space for %u converted %u-bit vertex indices",
XELOGE("Failed to allocate space for {} converted {}-bit vertex indices",
count, format == IndexFormat::kInt32 ? 32 : 16);
return nullptr;
}

View File

@ -266,7 +266,7 @@ bool RenderTargetCache::Initialize(const TextureCache* texture_cache) {
(!rov_used && edram_store_pipelines_[i] == nullptr) ||
(load_2x_resolve_pipeline_used &&
edram_load_2x_resolve_pipelines_[i] == nullptr)) {
XELOGE("Failed to create the EDRAM load/store pipelines for mode %u", i);
XELOGE("Failed to create the EDRAM load/store pipelines for mode {}", i);
Shutdown();
return false;
}
@ -824,7 +824,7 @@ bool RenderTargetCache::UpdateRenderTargets(const D3D12Shader* pixel_shader) {
}
#endif
}
XELOGGPU("RT Cache: %s update - pitch %u, samples %u, RTs to attach %u",
XELOGGPU("RT Cache: {} update - pitch {}, samples {}, RTs to attach {}",
full_update ? "Full" : "Partial", surface_pitch,
rb_surface_info.msaa_samples, render_targets_to_attach);
@ -954,7 +954,7 @@ bool RenderTargetCache::UpdateRenderTargets(const D3D12Shader* pixel_shader) {
if (render_target == nullptr) {
continue;
}
XELOGGPU("RT Color %u: base %u, format %u", i, edram_bases[i],
XELOGGPU("RT Color {}: base {}, format {}", i, edram_bases[i],
formats[i]);
command_processor_->PushTransitionBarrier(
render_target->resource, render_target->state,
@ -973,7 +973,7 @@ bool RenderTargetCache::UpdateRenderTargets(const D3D12Shader* pixel_shader) {
RenderTarget* depth_render_target = depth_binding.render_target;
current_pipeline_render_targets_[4].guest_render_target = 4;
if (depth_binding.is_bound && depth_render_target != nullptr) {
XELOGGPU("RT Depth: base %u, format %u", edram_bases[4], formats[4]);
XELOGGPU("RT Depth: base {}, format {}", edram_bases[4], formats[4]);
command_processor_->PushTransitionBarrier(
depth_render_target->resource, depth_render_target->state,
D3D12_RESOURCE_STATE_DEPTH_WRITE);
@ -1165,8 +1165,8 @@ bool RenderTargetCache::Resolve(SharedMemory* shared_memory,
rect.bottom = std::min(rect.bottom, scissor.bottom);
XELOGGPU(
"Resolve: (%d,%d)->(%d,%d) of RT %u (pitch %u, %u sample%s, format %u) "
"at %u",
"Resolve: ({},{})->({},{}) of RT {} (pitch {}, {} sample{}, format {}) "
"at {}",
rect.left, rect.top, rect.right, rect.bottom, surface_index,
surface_pitch, 1 << uint32_t(rb_surface_info.msaa_samples),
rb_surface_info.msaa_samples != MsaaSamples::k1X ? "s" : "",
@ -1340,8 +1340,8 @@ bool RenderTargetCache::ResolveCopy(SharedMemory* shared_memory,
bool dest_swap = !is_depth && rb_copy_dest_info.copy_dest_swap;
XELOGGPU(
"Resolve: Copying samples %u to 0x%.8X (%ux%u, %cD), destination Z %u, "
"destination format %s, exponent bias %d, red and blue %sswapped",
"Resolve: Copying samples {} to {:#08X} ({}x{}, {}D), destination Z {}, "
"destination format {}, exponent bias {}, red and blue {}swapped",
uint32_t(sample_select), dest_address, dest_pitch, dest_height,
rb_copy_dest_info.copy_dest_array ? '3' : '2', dest_z,
dest_format_info->name, dest_exp_bias, dest_swap ? "" : "not ");
@ -1532,7 +1532,7 @@ bool RenderTargetCache::ResolveCopy(SharedMemory* shared_memory,
texture_cache->GetResolveDXGIFormat(dest_format);
if (dest_dxgi_format == DXGI_FORMAT_UNKNOWN) {
XELOGE(
"No resolve pipeline for destination format %s - tell Xenia "
"No resolve pipeline for destination format {} - tell Xenia "
"developers!",
FormatInfo::Get(dest_format)->name);
return false;
@ -1864,7 +1864,7 @@ bool RenderTargetCache::ResolveClear(uint32_t edram_base,
}
}
XELOGGPU("Resolve: Clearing the %s render target",
XELOGGPU("Resolve: Clearing the {} render target",
is_depth ? "depth" : "color");
// Calculate the layout.
@ -1980,7 +1980,7 @@ ID3D12PipelineState* RenderTargetCache::GetResolvePipeline(
ID3D12PipelineState* pipeline;
if (FAILED(device->CreateGraphicsPipelineState(&pipeline_desc,
IID_PPV_ARGS(&pipeline)))) {
XELOGE("Failed to create the resolve pipeline for DXGI format %u",
XELOGE("Failed to create the resolve pipeline for DXGI format {}",
dest_format);
return nullptr;
}
@ -2063,8 +2063,8 @@ RenderTargetCache::ResolveTarget* RenderTargetCache::FindOrCreateResolveTarget(
if (heap_page_count == 0 || heap_page_count > kHeap4MBPages) {
assert_always();
XELOGE(
"%ux%u resolve target with DXGI format %u can't fit in a heap, "
"needs %u bytes - tell Xenia developers to increase the heap size!",
"{}x{} resolve target with DXGI format {} can't fit in a heap, "
"needs {} bytes - tell Xenia developers to increase the heap size!",
uint32_t(resource_desc.Width), resource_desc.Height, format,
uint32_t(allocation_info.SizeInBytes));
return nullptr;
@ -2090,8 +2090,8 @@ RenderTargetCache::ResolveTarget* RenderTargetCache::FindOrCreateResolveTarget(
heaps_[heap_index], (min_heap_page_first % kHeap4MBPages) << 22,
&resource_desc, state, nullptr, IID_PPV_ARGS(&resource)))) {
XELOGE(
"Failed to create a placed resource for %ux%u resolve target with DXGI "
"format %u at heap 4 MB pages %u:%u",
"Failed to create a placed resource for {}x{} resolve target with DXGI "
"format {} at heap 4 MB pages {}:{}",
uint32_t(resource_desc.Width), resource_desc.Height, format,
min_heap_page_first, min_heap_page_first + heap_page_count - 1);
return nullptr;
@ -2101,8 +2101,8 @@ RenderTargetCache::ResolveTarget* RenderTargetCache::FindOrCreateResolveTarget(
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
&resource_desc, state, nullptr, IID_PPV_ARGS(&resource)))) {
XELOGE(
"Failed to create a committed resource for %ux%u resolve target with "
"DXGI format %u",
"Failed to create a committed resource for {}x{} resolve target with "
"DXGI format {}",
uint32_t(resource_desc.Width), resource_desc.Height, format);
return nullptr;
}
@ -2397,7 +2397,7 @@ bool RenderTargetCache::MakeHeapResident(uint32_t heap_index) {
heap_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES;
if (FAILED(
device->CreateHeap(&heap_desc, IID_PPV_ARGS(&heaps_[heap_index])))) {
XELOGE("Failed to create a %u MB heap for render targets",
XELOGE("Failed to create a {} MB heap for render targets",
kHeap4MBPages * 4);
return false;
}
@ -2422,7 +2422,7 @@ bool RenderTargetCache::EnsureRTVHeapAvailable(bool is_depth) {
ID3D12DescriptorHeap* new_d3d_heap;
if (FAILED(device->CreateDescriptorHeap(&heap_desc,
IID_PPV_ARGS(&new_d3d_heap)))) {
XELOGE("Failed to create a heap for %u %s buffer descriptors",
XELOGE("Failed to create a heap for {} {} buffer descriptors",
kRenderTargetDescriptorHeapSize, is_depth ? "depth" : "color");
return false;
}
@ -2530,8 +2530,8 @@ RenderTargetCache::RenderTarget* RenderTargetCache::FindOrCreateRenderTarget(
heaps_[heap_index], (heap_page_first % kHeap4MBPages) << 22,
&resource_desc, state, nullptr, IID_PPV_ARGS(&resource)))) {
XELOGE(
"Failed to create a placed resource for %ux%u %s render target with "
"format %u at heap 4 MB pages %u:%u",
"Failed to create a placed resource for {}x{} {} render target with "
"format {} at heap 4 MB pages {}:{}",
uint32_t(resource_desc.Width), resource_desc.Height,
key.is_depth ? "depth" : "color", key.format, heap_page_first,
heap_page_first + heap_page_count - 1);
@ -2542,8 +2542,8 @@ RenderTargetCache::RenderTarget* RenderTargetCache::FindOrCreateRenderTarget(
&ui::d3d12::util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE,
&resource_desc, state, nullptr, IID_PPV_ARGS(&resource)))) {
XELOGE(
"Failed to create a committed resource for %ux%u %s render target with "
"format %u",
"Failed to create a committed resource for {}x{} {} render target with "
"format {}",
uint32_t(resource_desc.Width), resource_desc.Height,
key.is_depth ? "depth" : "color", key.format);
return nullptr;
@ -2598,12 +2598,12 @@ RenderTargetCache::RenderTarget* RenderTargetCache::FindOrCreateRenderTarget(
render_targets_.size());
#if 0
XELOGGPU(
"Created %ux%u %s render target with format %u at heap 4 MB pages %u:%u",
"Created {}x{} {} render target with format {} at heap 4 MB pages {}:{}",
uint32_t(resource_desc.Width), resource_desc.Height,
key.is_depth ? "depth" : "color", key.format, heap_page_first,
heap_page_first + heap_page_count - 1);
#else
XELOGGPU("Created %ux%u %s render target with format %u",
XELOGGPU("Created {}x{} {} render target with format {}",
uint32_t(resource_desc.Width), resource_desc.Height,
key.is_depth ? "depth" : "color", key.format);
#endif

View File

@ -805,7 +805,7 @@ bool SharedMemory::InitializeTraceSubmitDownloads() {
&gpu_written_buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS(&trace_gpu_written_buffer_)))) {
XELOGE(
"Shared memory: Failed to create a %u KB GPU-written memory download "
"Shared memory: Failed to create a {} KB GPU-written memory download "
"buffer for frame tracing",
gpu_written_page_count << page_size_log2_ >> 10);
ResetTraceGPUWrittenBuffer();

View File

@ -1004,7 +1004,7 @@ bool TextureCache::Initialize() {
load_pipelines_[i] = ui::d3d12::util::CreateComputePipeline(
device, mode_info.shader, mode_info.shader_size, load_root_signature_);
if (load_pipelines_[i] == nullptr) {
XELOGE("Failed to create the texture loading pipeline for mode %u", i);
XELOGE("Failed to create the texture loading pipeline for mode {}", i);
Shutdown();
return false;
}
@ -1015,7 +1015,7 @@ bool TextureCache::Initialize() {
if (load_pipelines_2x_[i] == nullptr) {
XELOGE(
"Failed to create the 2x-scaled texture loading pipeline for mode "
"%u",
"{}",
i);
Shutdown();
return false;
@ -1028,7 +1028,7 @@ bool TextureCache::Initialize() {
device, mode_info.shader, mode_info.shader_size,
resolve_tile_root_signature_);
if (resolve_tile_pipelines_[i] == nullptr) {
XELOGE("Failed to create the texture tiling pipeline for mode %u", i);
XELOGE("Failed to create the texture tiling pipeline for mode {}", i);
Shutdown();
return false;
}
@ -1243,7 +1243,7 @@ void TextureCache::EndFrame() {
XELOGE("Unsupported texture formats used in the frame:");
unsupported_header_written = true;
}
XELOGE("* %s%s%s%s", FormatInfo::Get(TextureFormat(i))->name,
XELOGE("* {}{}{}{}", FormatInfo::Get(TextureFormat(i))->name,
unsupported_features & kUnsupportedResourceBit ? " resource" : "",
unsupported_features & kUnsupportedUnormBit ? " unorm" : "",
unsupported_features & kUnsupportedSnormBit ? " snorm" : "");
@ -2094,7 +2094,8 @@ void TextureCache::BindingInfoFromFetchConstant(
break;
}
XELOGW(
"Texture fetch constant (%.8X %.8X %.8X %.8X %.8X %.8X) has "
"Texture fetch constant ({:08X} {:08X} {:08X} {:08X} {:08X} {:08X}) "
"has "
"\"invalid\" type! This is incorrect behavior, but you can try "
"bypassing this by launching Xenia with "
"--gpu_allow_invalid_fetch_constants=true.",
@ -2103,7 +2104,8 @@ void TextureCache::BindingInfoFromFetchConstant(
return;
default:
XELOGW(
"Texture fetch constant (%.8X %.8X %.8X %.8X %.8X %.8X) is "
"Texture fetch constant ({:08X} {:08X} {:08X} {:08X} {:08X} {:08X}) "
"is "
"completely invalid!",
fetch.dword_0, fetch.dword_1, fetch.dword_2, fetch.dword_3,
fetch.dword_4, fetch.dword_5);
@ -2121,7 +2123,7 @@ void TextureCache::BindingInfoFromFetchConstant(
}
if (fetch.dimension == Dimension::k1D && width > 8192) {
XELOGE(
"1D texture is too wide (%u) - ignoring! "
"1D texture is too wide ({}) - ignoring! "
"Report the game to Xenia developers",
width);
return;
@ -2175,8 +2177,8 @@ void TextureCache::BindingInfoFromFetchConstant(
void TextureCache::LogTextureKeyAction(TextureKey key, const char* action) {
XELOGGPU(
"%s %s %s%ux%ux%u %s %s texture with %u %spacked mip level%s, "
"base at 0x%.8X, mips at 0x%.8X",
"{} {} {}{}x{}x{} {} {} texture with {} {}packed mip level{}, "
"base at {:#08X}, mips at {:#08X}",
action, key.tiled ? "tiled" : "linear",
key.scaled_resolve ? "2x-scaled " : "", key.width, key.height, key.depth,
dimension_names_[uint32_t(key.dimension)],
@ -2188,8 +2190,8 @@ void TextureCache::LogTextureKeyAction(TextureKey key, const char* action) {
void TextureCache::LogTextureAction(const Texture* texture,
const char* action) {
XELOGGPU(
"%s %s %s%ux%ux%u %s %s texture with %u %spacked mip level%s, "
"base at 0x%.8X (size %u), mips at 0x%.8X (size %u)",
"{} {} {}{}x{}x{} {} {} texture with {} {}packed mip level{}, "
"base at {:#08X} (size {}), mips at {:#08X} (size {})",
action, texture->key.tiled ? "tiled" : "linear",
texture->key.scaled_resolve ? "2x-scaled " : "", texture->key.width,
texture->key.height, texture->key.depth,

View File

@ -194,7 +194,7 @@ uint32_t GraphicsSystem::ReadRegister(uint32_t addr) {
return 0x050002D0;
default:
if (!register_file_.GetRegisterInfo(r)) {
XELOGE("GPU: Read from unknown register (%.4X)", r);
XELOGE("GPU: Read from unknown register ({:04X})", r);
}
}
@ -212,7 +212,7 @@ void GraphicsSystem::WriteRegister(uint32_t addr, uint32_t value) {
case 0x1844: // AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS
break;
default:
XELOGW("Unknown GPU register %.4X write: %.8X", r, value);
XELOGW("Unknown GPU register {:04X} write: {:08X}", r, value);
break;
}
@ -233,7 +233,7 @@ void GraphicsSystem::SetInterruptCallback(uint32_t callback,
uint32_t user_data) {
interrupt_callback_ = callback;
interrupt_callback_data_ = user_data;
XELOGGPU("SetInterruptCallback(%.4X, %.4X)", callback, user_data);
XELOGGPU("SetInterruptCallback({:08X}, {:08X})", callback, user_data);
}
void GraphicsSystem::DispatchInterruptCallback(uint32_t source, uint32_t cpu) {
@ -250,7 +250,7 @@ void GraphicsSystem::DispatchInterruptCallback(uint32_t source, uint32_t cpu) {
}
thread->SetActiveCpu(cpu);
// XELOGGPU("Dispatching GPU interrupt at %.8X w/ mode %d on cpu %d",
// XELOGGPU("Dispatching GPU interrupt at {:08X} w/ mode {} on cpu {}",
// interrupt_callback_, source, cpu);
uint64_t args[] = {source, interrupt_callback_data_};

View File

@ -81,8 +81,8 @@ int shader_compiler_main(const std::vector<std::string>& args) {
auto input_file = filesystem::OpenFile(cvars::shader_input, "rb");
if (!input_file) {
XELOGE("Unable to open input file: %s",
xe::path_to_utf8(cvars::shader_input).c_str());
XELOGE("Unable to open input file: {}",
xe::path_to_utf8(cvars::shader_input));
return 1;
}
fseek(input_file, 0, SEEK_END);
@ -92,8 +92,8 @@ int shader_compiler_main(const std::vector<std::string>& args) {
fread(ucode_dwords.data(), 4, ucode_dwords.size(), input_file);
fclose(input_file);
XELOGI("Opened %s as a %s shader, %" PRId64 " words (%" PRId64 " bytes).",
xe::path_to_utf8(cvars::shader_input).c_str(),
XELOGI("Opened {} as a {} shader, {} words ({} bytes).",
xe::path_to_utf8(cvars::shader_input),
shader_type == ShaderType::kVertex ? "vertex" : "pixel",
ucode_dwords.size(), ucode_dwords.size() * 4);

View File

@ -1299,7 +1299,7 @@ void ShaderTranslator::ParseAluVectorOperation(const AluInstruction& op,
// assert_always();
XELOGE(
"ShaderTranslator::ParseAluVectorOperation: Unsupported write to "
"export %d",
"export {}",
dest_num);
i.vector_result.storage_target = InstructionStorageTarget::kNone;
i.vector_result.storage_index = 0;
@ -1343,7 +1343,7 @@ void ShaderTranslator::ParseAluVectorOperation(const AluInstruction& op,
default:
XELOGE(
"ShaderTranslator::ParseAluVectorOperation: Unsupported write to "
"export %d",
"export {}",
dest_num);
i.vector_result.storage_target = InstructionStorageTarget::kNone;
i.vector_result.storage_index = 0;
@ -1468,7 +1468,7 @@ void ShaderTranslator::ParseAluScalarOperation(const AluInstruction& op,
// assert_always();
XELOGE(
"ShaderTranslator::ParseAluScalarOperation: Unsupported write to "
"export %d",
"export {}",
dest_num);
i.scalar_result.storage_target = InstructionStorageTarget::kNone;
i.scalar_result.storage_index = 0;

View File

@ -674,7 +674,7 @@ void SpirvShaderTranslator::PostTranslation(Shader* shader) {
reinterpret_cast<const uint32_t*>(shader->translated_binary().data()),
shader->translated_binary().size() / sizeof(uint32_t));
if (validation->has_error()) {
XELOGE("SPIR-V Shader Validation failed! Error: %s",
XELOGE("SPIR-V Shader Validation failed! Error: {}",
validation->error_string());
}
}

View File

@ -85,7 +85,7 @@ void TextureDump(const TextureInfo& src, void* buffer, size_t length) {
assert_unhandled_case(src.format);
std::memset(&dds_header.pixel_format, 0xCD,
sizeof(dds_header.pixel_format));
XELOGW("Skipping %s for texture dump.", src.format_info()->name);
XELOGW("Skipping {} for texture dump.", src.format_info()->name);
return;
}
}
@ -93,12 +93,12 @@ void TextureDump(const TextureInfo& src, void* buffer, size_t length) {
dds_header.caps[0] = 8u | 0x1000u;
static int dump_counter = 0;
char path[256];
sprintf(path, "texture_dumps\\%05d_%.8X_%.8X_%s.dds", dump_counter++,
src.memory.base_address, src.memory.mip_address,
src.format_info()->name);
std::filesystem::path path = "texture_dumps";
path /= fmt::format("{:05d}_{:08X}_{:08X}_{:08X}.dds", dump_counter++,
src.memory.base_address, src.memory.mip_address,
src.format_info()->name);
FILE* handle = fopen(path, "wb");
FILE* handle = filesystem::OpenFile(path, "wb");
if (handle) {
const uint32_t signature = ' SDD';
fwrite(&signature, sizeof(signature), 1, handle);

View File

@ -79,7 +79,7 @@ bool TextureInfo::Prepare(const xe_gpu_texture_fetch_t& fetch,
info.has_packed_mips = fetch.packed_mips;
if (info.format_info()->format == TextureFormat::kUnknown) {
XELOGE("Attempting to fetch from unsupported texture format %d",
XELOGE("Attempting to fetch from unsupported texture format {}",
info.format);
info.memory.base_address = fetch.base_address << 12;
info.memory.mip_address = fetch.mip_address << 12;

View File

@ -63,7 +63,7 @@ int TraceDump::Main(const std::vector<std::string>& args) {
// Normalize the path and make absolute.
auto abs_path = std::filesystem::absolute(path);
XELOGI("Loading trace file %s...", xe::path_to_utf8(abs_path).c_str());
XELOGI("Loading trace file {}...", xe::path_to_utf8(abs_path));
if (!Setup()) {
XELOGE("Unable to setup trace dump tool");
@ -96,7 +96,7 @@ bool TraceDump::Setup() {
X_STATUS result = emulator_->Setup(
nullptr, nullptr, [this]() { return CreateGraphicsSystem(); }, nullptr);
if (XFAILED(result)) {
XELOGE("Failed to setup emulator: %.8X", result);
XELOGE("Failed to setup emulator: {:08X}", result);
return false;
}
graphics_system_ = emulator_->graphics_system();

View File

@ -37,7 +37,7 @@ bool TraceReader::Open(const std::filesystem::path& path) {
// Verify version.
auto header = reinterpret_cast<const TraceHeader*>(trace_data_);
if (header->version != kTraceFormatVersion) {
XELOGE("Trace format version mismatch, code has %u, file has %u",
XELOGE("Trace format version mismatch, code has {}, file has {}",
kTraceFormatVersion, header->version);
if (header->version < kTraceFormatVersion) {
XELOGE("You need to regenerate your trace for the latest version");
@ -45,13 +45,12 @@ bool TraceReader::Open(const std::filesystem::path& path) {
return false;
}
auto path_str = xe::path_to_utf8(path);
XELOGI("Mapped %" PRId64 "b trace from %s", trace_size_, path_str.c_str());
XELOGI(" Version: %u", header->version);
XELOGI("Mapped {}b trace from {}", trace_size_, xe::path_to_utf8(path));
XELOGI(" Version: {}", header->version);
auto commit_str = std::string(header->build_commit_sha,
xe::countof(header->build_commit_sha));
XELOGI(" Commit: %s", commit_str.c_str());
XELOGI(" Title ID: %u", header->title_id);
XELOGI(" Commit: {}", commit_str);
XELOGI(" Title ID: {}", header->title_id);
ParseTrace();

View File

@ -126,7 +126,7 @@ bool TraceViewer::Setup() {
window_.get(), nullptr, [this]() { return CreateGraphicsSystem(); },
nullptr);
if (XFAILED(result)) {
XELOGE("Failed to setup emulator: %.8X", result);
XELOGE("Failed to setup emulator: {:08X}", result);
return false;
}
memory_ = emulator_->memory();

View File

@ -509,7 +509,7 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadVertexBuffer(
// OOM.
XELOGW(
"Failed to allocate transient data for vertex buffer! Wanted to "
"allocate %u bytes.",
"allocate {} bytes.",
upload_size);
return {nullptr, VK_WHOLE_SIZE};
}
@ -648,14 +648,16 @@ VkDescriptorSet BufferCache::PrepareVertexSet(
break;
}
XELOGW(
"Vertex fetch constant %u (%.8X %.8X) has \"invalid\" type! This "
"Vertex fetch constant {} ({:08X} {:08X}) has \"invalid\" type! "
"This "
"is incorrect behavior, but you can try bypassing this by "
"launching Xenia with --gpu_allow_invalid_fetch_constants=true.",
vertex_binding.fetch_constant, fetch->dword_0, fetch->dword_1);
return nullptr;
default:
XELOGW("Vertex fetch constant %u (%.8X %.8X) is completely invalid!",
vertex_binding.fetch_constant, fetch->dword_0, fetch->dword_1);
XELOGW(
"Vertex fetch constant {} ({:08X} {:08X}) is completely invalid!",
vertex_binding.fetch_constant, fetch->dword_0, fetch->dword_1);
return nullptr;
}

View File

@ -340,7 +340,7 @@ VkPipeline PipelineCache::GetPipeline(const RenderState* render_state,
auto result = vkCreateGraphicsPipelines(*device_, pipeline_cache_, 1,
&pipeline_info, nullptr, &pipeline);
if (result != VK_SUCCESS) {
XELOGE("vkCreateGraphicsPipelines failed with code %d", result);
XELOGE("vkCreateGraphicsPipelines failed with code {}", result);
assert_always();
return nullptr;
}
@ -379,10 +379,10 @@ bool PipelineCache::TranslateShader(VulkanShader* shader,
}
if (shader->is_valid()) {
XELOGGPU("Generated %s shader (%db) - hash %.16" PRIX64 ":\n%s\n",
XELOGGPU("Generated {} shader ({}b) - hash {:016X}:\n{}\n",
shader->type() == ShaderType::kVertex ? "vertex" : "pixel",
shader->ucode_dword_count() * 4, shader->ucode_data_hash(),
shader->ucode_disassembly().c_str());
shader->ucode_disassembly());
}
// Dump shader files if desired.
@ -395,18 +395,18 @@ bool PipelineCache::TranslateShader(VulkanShader* shader,
static void DumpShaderStatisticsAMD(const VkShaderStatisticsInfoAMD& stats) {
XELOGI(" - resource usage:");
XELOGI(" numUsedVgprs: %d", stats.resourceUsage.numUsedVgprs);
XELOGI(" numUsedSgprs: %d", stats.resourceUsage.numUsedSgprs);
XELOGI(" ldsSizePerLocalWorkGroup: %d",
XELOGI(" numUsedVgprs: {}", stats.resourceUsage.numUsedVgprs);
XELOGI(" numUsedSgprs: {}", stats.resourceUsage.numUsedSgprs);
XELOGI(" ldsSizePerLocalWorkGroup: {}",
stats.resourceUsage.ldsSizePerLocalWorkGroup);
XELOGI(" ldsUsageSizeInBytes : %d",
XELOGI(" ldsUsageSizeInBytes : {}",
stats.resourceUsage.ldsUsageSizeInBytes);
XELOGI(" scratchMemUsageInBytes : %d",
XELOGI(" scratchMemUsageInBytes : {}",
stats.resourceUsage.scratchMemUsageInBytes);
XELOGI("numPhysicalVgprs : %d", stats.numPhysicalVgprs);
XELOGI("numPhysicalSgprs : %d", stats.numPhysicalSgprs);
XELOGI("numAvailableVgprs: %d", stats.numAvailableVgprs);
XELOGI("numAvailableSgprs: %d", stats.numAvailableSgprs);
XELOGI("numPhysicalVgprs : {}", stats.numPhysicalVgprs);
XELOGI("numPhysicalSgprs : {}", stats.numPhysicalSgprs);
XELOGI("numAvailableVgprs: {}", stats.numAvailableVgprs);
XELOGI("numAvailableSgprs: {}", stats.numAvailableSgprs);
}
void PipelineCache::DumpShaderDisasmAMD(VkPipeline pipeline) {
@ -521,8 +521,8 @@ void PipelineCache::DumpShaderDisasmNV(
disasm_fp = std::string("Shader disassembly not available.");
}
XELOGI("%s\n=====================================\n%s\n", disasm_vp.c_str(),
disasm_fp.c_str());
XELOGI("{}\n=====================================\n{}\n", disasm_vp,
disasm_fp);
}
vkDestroyPipeline(*device_, dummy_pipeline, nullptr);
@ -1201,7 +1201,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateInputAssemblyState(
break;
default:
case PrimitiveType::kTriangleWithWFlags:
XELOGE("unsupported primitive type %d", primitive_type);
XELOGE("unsupported primitive type {}", primitive_type);
assert_unhandled_case(primitive_type);
return UpdateStatus::kError;
}

View File

@ -864,7 +864,7 @@ bool RenderCache::ConfigureRenderPass(VkCommandBuffer command_buffer,
render_pass = new CachedRenderPass(*device_, *config);
VkResult status = render_pass->Initialize();
if (status != VK_SUCCESS) {
XELOGE("%s: Failed to create render pass, status %s", __func__,
XELOGE("{}: Failed to create render pass, status {}", __func__,
ui::vulkan::to_string(status));
delete render_pass;
return false;
@ -943,7 +943,7 @@ bool RenderCache::ConfigureRenderPass(VkCommandBuffer command_buffer,
target_color_attachments, target_depth_stencil_attachment);
VkResult status = framebuffer->Initialize();
if (status != VK_SUCCESS) {
XELOGE("%s: Failed to create framebuffer, status %s", __func__,
XELOGE("{}: Failed to create framebuffer, status {}", __func__,
ui::vulkan::to_string(status));
delete framebuffer;
return false;
@ -996,7 +996,7 @@ CachedTileView* RenderCache::FindOrCreateTileView(
tile_view = new CachedTileView(device_, edram_memory_, view_key);
VkResult status = tile_view->Initialize(command_buffer);
if (status != VK_SUCCESS) {
XELOGE("%s: Failed to create tile view, status %s", __func__,
XELOGE("{}: Failed to create tile view, status {}", __func__,
ui::vulkan::to_string(status));
delete tile_view;

View File

@ -88,8 +88,8 @@ VkResult TextureCache::Initialize() {
limits.maxPerStageDescriptorSampledImages < kMaxTextureSamplers) {
XELOGE(
"Physical device is unable to support required number of sampled "
"images! Expect instability! (maxPerStageDescriptorSamplers=%d, "
"maxPerStageDescriptorSampledImages=%d)",
"images! Expect instability! (maxPerStageDescriptorSamplers={}, "
"maxPerStageDescriptorSampledImages={})",
limits.maxPerStageDescriptorSamplers,
limits.maxPerStageDescriptorSampledImages);
// assert_always();
@ -190,7 +190,7 @@ TextureCache::Texture* TextureCache::AllocateTexture(
VkFormat format = config.host_format;
if (format == VK_FORMAT_UNDEFINED) {
XELOGE(
"Texture Cache: Attempted to allocate texture format %s, which is "
"Texture Cache: Attempted to allocate texture format {}, which is "
"defined as VK_FORMAT_UNDEFINED!",
texture_info.format_info()->name);
return nullptr;
@ -235,13 +235,11 @@ TextureCache::Texture* TextureCache::AllocateTexture(
if ((props.optimalTilingFeatures & required_flags) != required_flags) {
// Texture needs conversion on upload to a native format.
XELOGE(
"Texture Cache: Invalid usage flag specified on format %s (%s)\n\t"
"(requested: %s)",
"Texture Cache: Invalid usage flag specified on format {} ({})\n\t"
"(requested: {})",
texture_info.format_info()->name, ui::vulkan::to_string(format),
ui::vulkan::to_flags_string(
static_cast<VkFormatFeatureFlagBits>(required_flags &
~props.optimalTilingFeatures))
.c_str());
ui::vulkan::to_flags_string(static_cast<VkFormatFeatureFlagBits>(
required_flags & ~props.optimalTilingFeatures)));
}
if (texture_info.dimension != Dimension::kCube &&
@ -1070,9 +1068,9 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
size_t unpack_length = ComputeTextureStorage(src);
XELOGGPU(
"Uploading texture @ 0x%.8X/0x%.8X (%ux%ux%u, format: %s, dim: %s, "
"levels: %u (%u-%u), stacked: %s, pitch: %u, tiled: %s, packed mips: %s, "
"unpack length: 0x%.8X)",
"Uploading texture @ {:#08X}/{:#08X} ({}x{}x{}, format: {}, dim: {}, "
"levels: {} ({}-{}), stacked: {}, pitch: {}, tiled: {}, packed mips: {}, "
"unpack length: {:#X})",
src.memory.base_address, src.memory.mip_address, src.width + 1,
src.height + 1, src.depth + 1, src.format_info()->name,
get_dimension_name(src.dimension), src.mip_levels(), src.mip_min_level,
@ -1080,7 +1078,7 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
src.is_tiled ? "yes" : "no", src.has_packed_mips ? "yes" : "no",
unpack_length);
XELOGGPU("Extent: %ux%ux%u %u,%u,%u", src.extent.pitch, src.extent.height,
XELOGGPU("Extent: {}x{}x{} {},{},{}", src.extent.pitch, src.extent.height,
src.extent.depth, src.extent.block_pitch_h, src.extent.block_height,
src.extent.block_pitch_v);
@ -1099,7 +1097,7 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
if (!staging_buffer_.CanAcquire(unpack_length)) {
// The staging buffer isn't big enough to hold this texture.
XELOGE(
"TextureCache staging buffer is too small! (uploading 0x%.8X bytes)",
"TextureCache staging buffer is too small! (uploading {:#X} bytes)",
unpack_length);
assert_always();
return false;
@ -1110,7 +1108,7 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
auto alloc = staging_buffer_.Acquire(unpack_length, completion_fence);
assert_not_null(alloc);
if (!alloc) {
XELOGE("%s: Failed to acquire staging memory!", __func__);
XELOGE("{}: Failed to acquire staging memory!", __func__);
return false;
}
@ -1125,7 +1123,7 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
}
if (!valid) {
XELOGW("Warning: Texture @ 0x%.8X is blank!", src.memory.base_address);
XELOGW("Warning: Texture @ {:#08X} is blank!", src.memory.base_address);
}
// Upload texture into GPU memory.
@ -1142,14 +1140,14 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
mip++, region++) {
if (!ConvertTexture(&unpack_buffer[unpack_offset], &copy_regions[region],
mip, src)) {
XELOGW("Failed to convert texture mip %u!", mip);
XELOGW("Failed to convert texture mip {}!", mip);
return false;
}
copy_regions[region].bufferOffset = alloc->offset + unpack_offset;
copy_regions[region].imageOffset = {0, 0, 0};
/*
XELOGGPU("Mip %u %ux%ux%u @ 0x%X", mip,
XELOGGPU("Mip {} {}x{}x{} @ {:#X}", mip,
copy_regions[region].imageExtent.width,
copy_regions[region].imageExtent.height,
copy_regions[region].imageExtent.depth, unpack_offset);
@ -1510,7 +1508,8 @@ bool TextureCache::SetupTextureBinding(VkCommandBuffer command_buffer,
break;
}
XELOGW(
"Texture fetch constant %u (%.8X %.8X %.8X %.8X %.8X %.8X) has "
"Texture fetch constant {} ({:08X} {:08X} {:08X} {:08X} {:08X} "
"{:08X}) has "
"\"invalid\" type! This is incorrect behavior, but you can try "
"bypassing this by launching Xenia with "
"--gpu_allow_invalid_fetch_constants=true.",
@ -1519,7 +1518,8 @@ bool TextureCache::SetupTextureBinding(VkCommandBuffer command_buffer,
return false;
default:
XELOGW(
"Texture fetch constant %u (%.8X %.8X %.8X %.8X %.8X %.8X) is "
"Texture fetch constant {} ({:08X} {:08X} {:08X} {:08X} {:08X} "
"{:08X}) is "
"completely invalid!",
binding.fetch_constant, fetch.dword_0, fetch.dword_1, fetch.dword_2,
fetch.dword_3, fetch.dword_4, fetch.dword_5);

View File

@ -1121,9 +1121,9 @@ bool VulkanCommandProcessor::IssueCopy() {
: static_cast<uint32_t>(depth_format);
VkFilter filter = is_color_source ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
XELOGGPU("Resolve RT %.8X %.8X(%d) -> 0x%.8X (%dx%d, format: %s)", edram_base,
surface_pitch, surface_pitch, copy_dest_base, copy_dest_pitch,
copy_dest_height, texture_info.format_info()->name);
XELOGGPU("Resolve RT {:08X} {:08X}({}) -> {:#08X} ({}x{}, format: {})",
edram_base, surface_pitch, surface_pitch, copy_dest_base,
copy_dest_pitch, copy_dest_height, texture_info.format_info()->name);
switch (copy_command) {
case CopyCommand::kRaw:
/*

View File

@ -121,22 +121,21 @@ X_STATUS SDLInputDriver::Setup() {
if (!cvars::mappings_file.empty()) {
if (!filesystem::PathExists(cvars::mappings_file)) {
XELOGW("SDL GameControllerDB: file '%s' does not exist.",
xe::path_to_utf8(cvars::mappings_file).c_str());
XELOGW("SDL GameControllerDB: file '{}' does not exist.",
xe::path_to_utf8(cvars::mappings_file));
} else {
auto mappings_file = filesystem::OpenFile(cvars::mappings_file, "rb");
if (!mappings_file) {
XELOGE("SDL GameControllerDB: failed to open file '%s'.",
xe::path_to_utf8(cvars::mappings_file).c_str());
XELOGE("SDL GameControllerDB: failed to open file '{}'.",
xe::path_to_utf8(cvars::mappings_file));
} else {
auto mappings_result = SDL_GameControllerAddMappingsFromRW(
SDL_RWFromFP(mappings_file, SDL_TRUE), 1);
if (mappings_result < 0) {
XELOGE("SDL GameControllerDB: error loading file '%s': %d.",
xe::path_to_utf8(cvars::mappings_file).c_str(),
mappings_result);
XELOGE("SDL GameControllerDB: error loading file '{}': {}.",
xe::path_to_utf8(cvars::mappings_file), mappings_result);
} else {
XELOGI("SDL GameControllerDB: loaded %d mappings.",
XELOGI("SDL GameControllerDB: loaded {} mappings.",
mappings_result);
}
}

View File

@ -48,8 +48,8 @@ KernelModule::KernelModule(KernelState* kernel_state,
module->SetAddressRange(guest_trampoline_, guest_trampoline_size_);
emulator_->processor()->AddModule(std::move(module));
} else {
XELOGW("KernelModule %s could not allocate trampoline for GetProcAddress!",
path.c_str());
XELOGW("KernelModule {} could not allocate trampoline for GetProcAddress!",
path);
}
OnLoad();
@ -99,7 +99,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
return export_entry->variable_ptr;
} else {
XELOGW(
"ERROR: var export referenced GetProcAddressByOrdinal(%.4X(%s)) is "
"ERROR: var export referenced GetProcAddressByOrdinal({:04X}({})) is "
"not implemented",
ordinal, export_entry->name);
return 0;
@ -127,7 +127,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
uint32_t guest_addr =
GenerateTrampoline(export_entry->name, handler, export_entry);
XELOGD("GetProcAddressByOrdinal(\"%s\", \"%s\") = %.8X", name().c_str(),
XELOGD("GetProcAddressByOrdinal(\"{}\", \"{}\") = {:08X}", name(),
export_entry->name, guest_addr);
// Register the function in our map.
@ -136,7 +136,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
} else {
// Not implemented.
XELOGW(
"ERROR: fn export referenced GetProcAddressByOrdinal(%.4X(%s)) is "
"ERROR: fn export referenced GetProcAddressByOrdinal({:04X}({})) is "
"not implemented",
ordinal, export_entry->name);
return 0;

View File

@ -249,7 +249,7 @@ object_ref<XThread> KernelState::LaunchModule(object_ref<UserModule> module) {
X_STATUS result = thread->Create();
if (XFAILED(result)) {
XELOGE("Could not create launch thread: %.8X", result);
XELOGE("Could not create launch thread: {:08X}", result);
return nullptr;
}
@ -736,7 +736,7 @@ bool KernelState::Save(ByteStream* stream) {
stream->Write(static_cast<uint32_t>(threads.size()));
size_t num_threads = threads.size();
XELOGD("Serializing %d threads...", threads.size());
XELOGD("Serializing {} threads...", threads.size());
for (auto thread : threads) {
if (!thread->is_guest_thread()) {
// Don't save host threads. They can be reconstructed on startup.
@ -745,7 +745,7 @@ bool KernelState::Save(ByteStream* stream) {
}
if (!thread->Save(stream)) {
XELOGD("Failed to save thread \"%s\"", thread->name().c_str());
XELOGD("Failed to save thread \"{}\"", thread->name());
num_threads--;
}
}
@ -759,7 +759,7 @@ bool KernelState::Save(ByteStream* stream) {
stream->Write(static_cast<uint32_t>(objects.size()));
size_t num_objects = objects.size();
XELOGD("Serializing %d objects...", num_objects);
XELOGD("Serializing {} objects...", num_objects);
for (auto object : objects) {
auto prev_offset = stream->offset();
@ -771,7 +771,7 @@ bool KernelState::Save(ByteStream* stream) {
stream->Write<uint32_t>(object->type());
if (!object->Save(stream)) {
XELOGD("Did not save object of type %d", object->type());
XELOGD("Did not save object of type {}", object->type());
assert_always();
// Revert backwards and overwrite if a save failed.
@ -802,7 +802,7 @@ bool KernelState::Restore(ByteStream* stream) {
}
uint32_t num_threads = stream->Read<uint32_t>();
XELOGD("Loading %d threads...", num_threads);
XELOGD("Loading {} threads...", num_threads);
for (uint32_t i = 0; i < num_threads; i++) {
auto thread = XObject::Restore(this, XObject::kTypeThread, stream);
if (!thread) {
@ -813,7 +813,7 @@ bool KernelState::Restore(ByteStream* stream) {
}
uint32_t num_objects = stream->Read<uint32_t>();
XELOGD("Loading %d objects...", num_objects);
XELOGD("Loading {} objects...", num_objects);
for (uint32_t i = 0; i < num_objects; i++) {
uint32_t type = stream->Read<uint32_t>();

View File

@ -55,7 +55,7 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
// TODO(benvanik): make this code shared?
auto fs_entry = kernel_state()->file_system()->ResolvePath(path);
if (!fs_entry) {
XELOGE("File not found: %s", path.c_str());
XELOGE("File not found: {}", path);
return X_STATUS_NO_SUCH_FILE;
}
@ -109,17 +109,17 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
if (patch_entry) {
auto patch_path = patch_entry->absolute_path();
XELOGI("Loading XEX patch from %s", patch_path.c_str());
XELOGI("Loading XEX patch from {}", patch_path);
auto patch_module = object_ref<UserModule>(new UserModule(kernel_state_));
result = patch_module->LoadFromFile(patch_path);
if (!result) {
result = patch_module->xex_module()->ApplyPatch(xex_module());
if (result) {
XELOGE("Failed to apply XEX patch, code: %d", result);
XELOGE("Failed to apply XEX patch, code: {}", result);
}
} else {
XELOGE("Failed to load XEX patch, code: %d", result);
XELOGE("Failed to load XEX patch, code: {}", result);
}
if (result) {
@ -145,7 +145,7 @@ X_STATUS UserModule::LoadFromMemory(const void* addr, const size_t length) {
XELOGE("XNA executables are not yet implemented");
return X_STATUS_NOT_IMPLEMENTED;
} else {
XELOGE("Unknown module magic: %.8X", magic);
XELOGE("Unknown module magic: {:08X}", magic);
return X_STATUS_NOT_IMPLEMENTED;
}
}
@ -376,8 +376,8 @@ object_ref<UserModule> UserModule::Restore(KernelState* kernel_state,
auto result = module->LoadFromFile(path);
if (XFAILED(result)) {
XELOGD("UserModule::Restore LoadFromFile(%s) FAILED - code %.8X",
path.c_str(), result);
XELOGD("UserModule::Restore LoadFromFile({}) FAILED - code {:08X}", path,
result);
return nullptr;
}
@ -801,7 +801,7 @@ void UserModule::Dump() {
sb.Append("\n");
}
xe::LogLine(xe::LogLevel::Info, 'i', sb.to_string_view());
xe::logging::AppendLogLine(xe::LogLevel::Info, 'i', sb.to_string_view());
}
} // namespace kernel

View File

@ -119,7 +119,7 @@ X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
// Retain so long as the object is in the table.
object->Retain();
XELOGI("Added handle:%08X for %s", handle, typeid(*object).name());
XELOGI("Added handle:{:08X} for {}", handle, typeid(*object).name());
}
}
@ -204,7 +204,7 @@ X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) {
object->handles().erase(handle_entry);
}
XELOGI("Removed handle:%08X for %s", handle, typeid(*object).name());
XELOGI("Removed handle:{:08X} for {}", handle, typeid(*object).name());
// Release now that the object has been removed from the table.
object->Release();

View File

@ -494,9 +494,11 @@ void PrintKernelCall(cpu::Export* export_entry, const Tuple& params) {
AppendKernelCallParams(string_buffer, export_entry, params);
string_buffer.Append(')');
if (export_entry->tags & xe::cpu::ExportTag::kImportant) {
xe::LogLine(xe::LogLevel::Info, 'i', string_buffer.to_string_view());
xe::logging::AppendLogLine(xe::LogLevel::Info, 'i',
string_buffer.to_string_view());
} else {
xe::LogLine(xe::LogLevel::Debug, 'd', string_buffer.to_string_view());
xe::logging::AppendLogLine(xe::LogLevel::Debug, 'd',
string_buffer.to_string_view());
}
}

View File

@ -36,15 +36,15 @@ X_RESULT UnknownFEApp::DispatchMessageSync(uint32_t message,
assert_true(buffer_length == sizeof(message_data));
auto unk = memory_->TranslateVirtual<xe::be<uint32_t>*>(data->unk_44);
*unk = 0;
XELOGD("UnknownFEApp(0x00020021)('%s', %.8X, %.8X, %.8X)", data->unk_00,
(uint32_t)data->unk_40, (uint32_t)data->unk_44,
XELOGD("UnknownFEApp(0x00020021)('{}', {:08X}, {:08X}, {:08X})",
data->unk_00, (uint32_t)data->unk_40, (uint32_t)data->unk_44,
(uint32_t)data->unk_48);
return X_ERROR_SUCCESS;
}
}
XELOGE(
"Unimplemented 0xFE message app=%.8X, msg=%.8X, arg1=%.8X, "
"arg2=%.8X",
"Unimplemented 0xFE message app={:08X}, msg={:08X}, arg1={:08X}, "
"arg2={:08X}",
app_id(), message, buffer_ptr, buffer_length);
return X_STATUS_UNSUCCESSFUL;
}

View File

@ -36,8 +36,8 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t user_index = xe::load_and_swap<uint32_t>(buffer + 0);
uint32_t context_id = xe::load_and_swap<uint32_t>(buffer + 16);
uint32_t context_value = xe::load_and_swap<uint32_t>(buffer + 20);
XELOGD("XGIUserSetContextEx(%.8X, %.8X, %.8X)", user_index, context_id,
context_value);
XELOGD("XGIUserSetContextEx({:08X}, {:08X}, {:08X})", user_index,
context_id, context_value);
return X_ERROR_SUCCESS;
}
case 0x000B0007: {
@ -45,7 +45,7 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t property_id = xe::load_and_swap<uint32_t>(buffer + 16);
uint32_t value_size = xe::load_and_swap<uint32_t>(buffer + 20);
uint32_t value_ptr = xe::load_and_swap<uint32_t>(buffer + 24);
XELOGD("XGIUserSetPropertyEx(%.8X, %.8X, %d, %.8X)", user_index,
XELOGD("XGIUserSetPropertyEx({:08X}, {:08X}, {}, {:08X})", user_index,
property_id, value_size, value_ptr);
return X_ERROR_SUCCESS;
}
@ -53,7 +53,7 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
assert_true(!buffer_length || buffer_length == 8);
uint32_t achievement_count = xe::load_and_swap<uint32_t>(buffer + 0);
uint32_t achievements_ptr = xe::load_and_swap<uint32_t>(buffer + 4);
XELOGD("XGIUserWriteAchievements(%.8X, %.8X)", achievement_count,
XELOGD("XGIUserWriteAchievements({:08X}, {:08X})", achievement_count,
achievements_ptr);
return X_ERROR_SUCCESS;
}
@ -72,9 +72,11 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t session_info_ptr = xe::load_and_swap<uint32_t>(buffer + 0x14);
uint32_t nonce_ptr = xe::load_and_swap<uint32_t>(buffer + 0x18);
XELOGD("XGISessionCreateImpl(%.8X, %.8X, %d, %d, %.8X, %.8X, %.8X)",
session_ptr, flags, num_slots_public, num_slots_private, user_xuid,
session_info_ptr, nonce_ptr);
XELOGD(
"XGISessionCreateImpl({:08X}, {:08X}, {}, {}, {:08X}, {:08X}, "
"{:08X})",
session_ptr, flags, num_slots_public, num_slots_private, user_xuid,
session_info_ptr, nonce_ptr);
return X_STATUS_SUCCESS;
}
case 0x000B0011: {
@ -89,7 +91,7 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t private_slots_array = xe::load_and_swap<uint32_t>(buffer + 0x10);
assert_zero(unk_0);
XELOGD("XGISessionJoinLocal(%.8X, %d, %d, %.8X, %.8X)", session_ptr,
XELOGD("XGISessionJoinLocal({:08X}, {}, {}, {:08X}, {:08X})", session_ptr,
user_count, unk_0, user_index_array, private_slots_array);
return X_STATUS_SUCCESS;
}
@ -102,8 +104,8 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
context_ptr ? memory_->TranslateVirtual(context_ptr) : nullptr;
uint32_t context_id =
context ? xe::load_and_swap<uint32_t>(context + 0) : 0;
XELOGD("XGIUserGetContext(%.8X, %.8X(%.8X))", user_index, context_ptr,
context_id);
XELOGD("XGIUserGetContext({:08X}, {:08X}{:08X}))", user_index,
context_ptr, context_id);
uint32_t value = 0;
if (context) {
xe::store_and_swap<uint32_t>(context + 4, value);
@ -115,8 +117,10 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
return X_ERROR_SUCCESS;
}
}
XELOGE("Unimplemented XGI message app=%.8X, msg=%.8X, arg1=%.8X, arg2=%.8X",
app_id(), message, buffer_ptr, buffer_length);
XELOGE(
"Unimplemented XGI message app={:08X}, msg={:08X}, arg1={:08X}, "
"arg2={:08X}",
app_id(), message, buffer_ptr, buffer_length);
return X_STATUS_UNSUCCESSFUL;
}

View File

@ -31,13 +31,13 @@ X_RESULT XLiveBaseApp::DispatchMessageSync(uint32_t message,
case 0x00058004: {
// Called on startup, seems to just return a bool in the buffer.
assert_true(!buffer_length || buffer_length == 4);
XELOGD("XLiveBaseGetLogonId(%.8X)", buffer_ptr);
XELOGD("XLiveBaseGetLogonId({:08X})", buffer_ptr);
xe::store_and_swap<uint32_t>(buffer + 0, 1); // ?
return X_ERROR_SUCCESS;
}
case 0x00058006: {
assert_true(!buffer_length || buffer_length == 4);
XELOGD("XLiveBaseGetNatType(%.8X)", buffer_ptr);
XELOGD("XLiveBaseGetNatType({:08X})", buffer_ptr);
xe::store_and_swap<uint32_t>(buffer + 0, 1); // XONLINE_NAT_OPEN
return X_ERROR_SUCCESS;
}
@ -46,12 +46,12 @@ X_RESULT XLiveBaseApp::DispatchMessageSync(uint32_t message,
// We should create a XamEnumerate-able empty list here, but I'm not
// sure of the format.
// buffer_length seems to be the same ptr sent to 0x00058004.
XELOGD("XLiveBaseFriendsCreateEnumerator(%.8X, %.8X) unimplemented",
XELOGD("XLiveBaseFriendsCreateEnumerator({:08X}, {:08X}) unimplemented",
buffer_ptr, buffer_length);
return X_STATUS_UNSUCCESSFUL;
}
case 0x00058023: {
XELOGD("XliveBaseUnk58023(%.8X, %.8X) unimplemented", buffer_ptr,
XELOGD("XliveBaseUnk58023({:08X}, {:08X}) unimplemented", buffer_ptr,
buffer_length);
return X_STATUS_UNSUCCESSFUL;
}
@ -59,14 +59,14 @@ X_RESULT XLiveBaseApp::DispatchMessageSync(uint32_t message,
// Required to be successful for Forza 4 to detect signed-in profile
// Doesn't seem to set anything in the given buffer, probably only takes
// input
XELOGD("XLiveBaseUnk58046(%.8X, %.8X) unimplemented", buffer_ptr,
XELOGD("XLiveBaseUnk58046({:08X}, {:08X}) unimplemented", buffer_ptr,
buffer_length);
return X_ERROR_SUCCESS;
}
}
XELOGE(
"Unimplemented XLIVEBASE message app=%.8X, msg=%.8X, arg1=%.8X, "
"arg2=%.8X",
"Unimplemented XLIVEBASE message app={:08X}, msg={:08X}, arg1={:08X}, "
"arg2={:08X}",
app_id(), message, buffer_ptr, buffer_length);
return X_STATUS_UNSUCCESSFUL;
}

View File

@ -35,7 +35,7 @@ X_RESULT XmpApp::XMPGetStatus(uint32_t state_ptr) {
// here to keep from starving real threads.
xe::threading::Sleep(std::chrono::milliseconds(1));
XELOGD("XMPGetStatus(%.8X)", state_ptr);
XELOGD("XMPGetStatus({:08X})", state_ptr);
xe::store_and_swap<uint32_t>(memory_->TranslateVirtual(state_ptr),
static_cast<uint32_t>(state_));
return X_ERROR_SUCCESS;
@ -47,10 +47,11 @@ X_RESULT XmpApp::XMPCreateTitlePlaylist(uint32_t songs_ptr, uint32_t song_count,
uint32_t flags,
uint32_t out_song_handles,
uint32_t out_playlist_handle) {
XELOGD("XMPCreateTitlePlaylist(%.8X, %.8X, %.8X(%s), %.8X, %.8X, %.8X)",
songs_ptr, song_count, playlist_name_ptr,
xe::to_utf8(playlist_name).c_str(), flags, out_song_handles,
out_playlist_handle);
XELOGD(
"XMPCreateTitlePlaylist({:08X}, {:08X}, {:08X}({}), {:08X}, {:08X}, "
"{:08X})",
songs_ptr, song_count, playlist_name_ptr, xe::to_utf8(playlist_name),
flags, out_song_handles, out_playlist_handle);
auto playlist = std::make_unique<Playlist>();
playlist->handle = ++next_playlist_handle_;
playlist->name = playlist_name;
@ -99,7 +100,7 @@ X_RESULT XmpApp::XMPCreateTitlePlaylist(uint32_t songs_ptr, uint32_t song_count,
}
X_RESULT XmpApp::XMPDeleteTitlePlaylist(uint32_t playlist_handle) {
XELOGD("XMPDeleteTitlePlaylist(%.8X)", playlist_handle);
XELOGD("XMPDeleteTitlePlaylist({:08X})", playlist_handle);
auto global_lock = global_critical_region_.Acquire();
auto it = playlists_.find(playlist_handle);
if (it == playlists_.end()) {
@ -117,13 +118,13 @@ X_RESULT XmpApp::XMPDeleteTitlePlaylist(uint32_t playlist_handle) {
X_RESULT XmpApp::XMPPlayTitlePlaylist(uint32_t playlist_handle,
uint32_t song_handle) {
XELOGD("XMPPlayTitlePlaylist(%.8X, %.8X)", playlist_handle, song_handle);
XELOGD("XMPPlayTitlePlaylist({:08X}, {:08X})", playlist_handle, song_handle);
Playlist* playlist = nullptr;
{
auto global_lock = global_critical_region_.Acquire();
auto it = playlists_.find(playlist_handle);
if (it == playlists_.end()) {
XELOGE("Playlist %.8X not found", playlist_handle);
XELOGE("Playlist {:08X} not found", playlist_handle);
return X_ERROR_NOT_FOUND;
}
playlist = it->second;
@ -156,7 +157,7 @@ X_RESULT XmpApp::XMPContinue() {
X_RESULT XmpApp::XMPStop(uint32_t unk) {
assert_zero(unk);
XELOGD("XMPStop(%.8X)", unk);
XELOGD("XMPStop({:08X})", unk);
active_playlist_ = nullptr; // ?
active_song_index_ = 0;
state_ = State::kIdle;
@ -258,7 +259,7 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t repeat_mode = xe::load_and_swap<uint32_t>(buffer + 8);
uint32_t flags = xe::load_and_swap<uint32_t>(buffer + 12);
assert_true(xmp_client == 0x00000002);
XELOGD("XMPSetPlaybackBehavior(%.8X, %.8X, %.8X)", playback_mode,
XELOGD("XMPSetPlaybackBehavior({:08X}, {:08X}, {:08X})", playback_mode,
repeat_mode, flags);
playback_mode_ = static_cast<PlaybackMode>(playback_mode);
repeat_mode_ = static_cast<RepeatMode>(repeat_mode);
@ -282,7 +283,7 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
}* args = memory_->TranslateVirtual<decltype(args)>(buffer_ptr);
assert_true(args->xmp_client == 0x00000002);
XELOGD("XMPGetVolume(%.8X)", uint32_t(args->volume_ptr));
XELOGD("XMPGetVolume({:08X})", uint32_t(args->volume_ptr));
xe::store_and_swap<float>(memory_->TranslateVirtual(args->volume_ptr),
volume_);
return X_ERROR_SUCCESS;
@ -292,7 +293,7 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t xmp_client = xe::load_and_swap<uint32_t>(buffer + 0);
float float_value = xe::load_and_swap<float>(buffer + 4);
assert_true(xmp_client == 0x00000002);
XELOGD("XMPSetVolume(%g)", float_value);
XELOGD("XMPSetVolume({})", float_value);
volume_ = float_value;
return X_ERROR_SUCCESS;
}
@ -332,7 +333,7 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
auto info = memory_->TranslateVirtual(info_ptr);
assert_true(xmp_client == 0x00000002);
assert_zero(unk_ptr);
XELOGE("XMPGetInfo?(%.8X, %.8X)", unk_ptr, info_ptr);
XELOGE("XMPGetInfo?({:08X}, {:08X})", unk_ptr, info_ptr);
if (!active_playlist_) {
return X_STATUS_UNSUCCESSFUL;
}
@ -370,8 +371,8 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
assert_true(args->xmp_client == 0x00000002);
assert_true(args->controller == 0x00000000);
XELOGD("XMPSetPlaybackController(%.8X, %.8X)", uint32_t(args->controller),
uint32_t(args->locked));
XELOGD("XMPSetPlaybackController({:08X}, {:08X})",
uint32_t(args->controller), uint32_t(args->locked));
disabled_ = args->locked;
if (disabled_) {
@ -390,7 +391,7 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
}* args = memory_->TranslateVirtual<decltype(args)>(buffer_ptr);
assert_true(args->xmp_client == 0x00000002);
XELOGD("XMPGetPlaybackController(%.8X, %.8X, %.8X)",
XELOGD("XMPGetPlaybackController({:08X}, {:08X}, {:08X})",
uint32_t(args->xmp_client), uint32_t(args->controller_ptr),
uint32_t(args->locked_ptr));
xe::store_and_swap<uint32_t>(
@ -410,8 +411,8 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
uint32_t repeat_mode_ptr = xe::load_and_swap<uint32_t>(buffer + 8);
uint32_t unk3_ptr = xe::load_and_swap<uint32_t>(buffer + 12);
assert_true(xmp_client == 0x00000002);
XELOGD("XMPGetPlaybackBehavior(%.8X, %.8X, %.8X)", playback_mode_ptr,
repeat_mode_ptr, unk3_ptr);
XELOGD("XMPGetPlaybackBehavior({:08X}, {:08X}, {:08X})",
playback_mode_ptr, repeat_mode_ptr, unk3_ptr);
if (playback_mode_ptr) {
xe::store_and_swap<uint32_t>(
memory_->TranslateVirtual(playback_mode_ptr),
@ -447,8 +448,10 @@ X_RESULT XmpApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
return X_STATUS_UNSUCCESSFUL;
}
}
XELOGE("Unimplemented XMP message app=%.8X, msg=%.8X, arg1=%.8X, arg2=%.8X",
app_id(), message, buffer_ptr, buffer_length);
XELOGE(
"Unimplemented XMP message app={:08X}, msg={:08X}, arg1={:08X}, "
"arg2={:08X}",
app_id(), message, buffer_ptr, buffer_length);
return X_STATUS_UNSUCCESSFUL;
}

View File

@ -189,7 +189,7 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
content_data.Write(ptr);
}
XELOGD("XamContentCreateEnumerator: added %d items to enumerator",
XELOGD("XamContentCreateEnumerator: added {} items to enumerator",
e->item_count());
*handle_out = e->handle();

View File

@ -114,8 +114,9 @@ dword_result_t keXamBuildResourceLocator(uint64_t module,
std::u16string path;
if (!module) {
path = fmt::format(u"file://media:/{0}.xzp#{0}", container, resource);
XELOGD("XamBuildResourceLocator(%s) returning locator to local file %s.xzp",
xe::to_utf8(container).c_str(), xe::to_utf8(container).c_str());
XELOGD(
"XamBuildResourceLocator({0}) returning locator to local file {0}.xzp",
xe::to_utf8(container));
} else {
path = fmt::format(u"section://{:X},{}#{}", (uint32_t)module, container,
resource);
@ -358,8 +359,9 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
// Known culprits:
// Final Fight: Double Impact (saves)
XELOGW(
"Broken usage of XamEnumerate! buffer length=%.X vs actual length=%.X "
"(item size=%.X, items per enumerate=%u)",
"Broken usage of XamEnumerate! buffer length={:X} vs actual "
"length={:X} "
"(item size={:X}, items per enumerate={})",
(uint32_t)buffer_length, actual_buffer_length, e->item_size(),
e->items_per_enumerate());
}
@ -430,4 +432,4 @@ void RegisterInfoExports(xe::cpu::ExportResolver* export_resolver,
} // namespace xam
} // namespace kernel
} // namespace xe
} // namespace xe

View File

@ -23,7 +23,7 @@ dword_result_t XMsgInProcessCall(dword_t app, dword_t message, dword_t arg1,
auto result = kernel_state()->app_manager()->DispatchMessageSync(app, message,
arg1, arg2);
if (result == X_ERROR_NOT_FOUND) {
XELOGE("XMsgInProcessCall: app %.8X undefined", (uint32_t)app);
XELOGE("XMsgInProcessCall: app {:08X} undefined", app);
}
return result;
}
@ -34,7 +34,7 @@ dword_result_t XMsgSystemProcessCall(dword_t app, dword_t message,
auto result = kernel_state()->app_manager()->DispatchMessageAsync(
app, message, buffer, buffer_length);
if (result == X_ERROR_NOT_FOUND) {
XELOGE("XMsgSystemProcessCall: app %.8X undefined", (uint32_t)app);
XELOGE("XMsgSystemProcessCall: app {:08X} undefined", app);
}
return result;
}
@ -46,7 +46,7 @@ dword_result_t XMsgStartIORequest(dword_t app, dword_t message,
auto result = kernel_state()->app_manager()->DispatchMessageAsync(
app, message, buffer, buffer_length);
if (result == X_ERROR_NOT_FOUND) {
XELOGE("XMsgStartIORequest: app %.8X undefined", (uint32_t)app);
XELOGE("XMsgStartIORequest: app {:08X} undefined", app);
}
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, result);
@ -63,7 +63,7 @@ dword_result_t XMsgStartIORequestEx(dword_t app, dword_t message,
auto result = kernel_state()->app_manager()->DispatchMessageAsync(
app, message, buffer, buffer_length);
if (result == X_ERROR_NOT_FOUND) {
XELOGE("XMsgStartIORequestEx: app %.8X undefined", (uint32_t)app);
XELOGE("XMsgStartIORequestEx: app {:08X} undefined", app);
}
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, result);

View File

@ -196,7 +196,7 @@ dword_result_t NetDll_XNetGetOpt(dword_t one, dword_t option_id,
std::memcpy(buffer_ptr, &xnet_startup_params, sizeof(XNetStartupParams));
return 0;
default:
XELOGE("NetDll_XNetGetOpt: option %d unimplemented", option_id);
XELOGE("NetDll_XNetGetOpt: option {} unimplemented", option_id);
return 0x2726; // WSAEINVAL
}
}
@ -537,7 +537,7 @@ SHIM_CALL NetDll_XNetQosServiceLookup_shim(PPCContext* ppc_context,
uint32_t event_handle = SHIM_GET_ARG_32(2);
uint32_t out_ptr = SHIM_GET_ARG_32(3);
XELOGD("NetDll_XNetQosServiceLookup(%d, %d, %.8X, %.8X)", caller, zero,
XELOGD("NetDll_XNetQosServiceLookup({}, {}, {:08X}, {:08X})", caller, zero,
event_handle, out_ptr);
// Non-zero is error.

View File

@ -172,8 +172,9 @@ dword_result_t XamUserReadProfileSettings(
}
} else {
any_missing = true;
XELOGE("XamUserReadProfileSettings requested unimplemented setting %.8X",
setting_id);
XELOGE(
"XamUserReadProfileSettings requested unimplemented setting {:08X}",
setting_id);
}
}
@ -288,8 +289,8 @@ dword_result_t XamUserWriteProfileSettings(
for (uint32_t n = 0; n < setting_count; ++n) {
const X_USER_WRITE_PROFILE_SETTING& settings_data = settings[n];
XELOGD(
"XamUserWriteProfileSettings: setting index [%d]:"
" from=%d setting_id=%.8X data.type=%d",
"XamUserWriteProfileSettings: setting index [{}]:"
" from={} setting_id={:08X} data.type={}",
n, (uint32_t)settings_data.from, (uint32_t)settings_data.setting_id,
settings_data.type);
@ -327,7 +328,7 @@ dword_result_t XamUserWriteProfileSettings(
case UserProfile::Setting::Type::DATETIME:
default:
XELOGE("XamUserWriteProfileSettings: Unimplemented data type %d",
XELOGE("XamUserWriteProfileSettings: Unimplemented data type {}",
settingType);
break;
};

View File

@ -31,7 +31,7 @@ void KeCertMonitorCallback(cpu::ppc::PPCContext* ppc_context,
kernel::KernelState* kernel_state) {
auto id = ppc_context->r[3];
auto arg = ppc_context->r[4];
XELOGI("KeCertMonitorCallback(%u, %08x)", id, arg);
XELOGI("KeCertMonitorCallback({}, {:08X})", id, arg);
auto xboxkrnl = kernel_state->GetKernelModule<XboxkrnlModule>("xboxkrnl.exe");
}

View File

@ -43,7 +43,7 @@ void KeDebugMonitorCallback(cpu::ppc::PPCContext* ppc_context,
auto id = static_cast<DebugMonitorCommand>(ppc_context->r[3] & 0xFFFFFFFFu);
auto arg = static_cast<uint32_t>(ppc_context->r[4] & 0xFFFFFFFFu);
XELOGI("KeDebugMonitorCallback(%u, %08x)", static_cast<uint32_t>(id), arg);
XELOGI("KeDebugMonitorCallback({}, {:08X})", static_cast<uint32_t>(id), arg);
if (!cvars::kernel_pix) {
SHIM_SET_RETURN_32(-1);
@ -55,8 +55,8 @@ void KeDebugMonitorCallback(cpu::ppc::PPCContext* ppc_context,
switch (id) {
case DebugMonitorCommand::PIXCommandResult: {
auto s = kernel_state->memory()->TranslateVirtual<const char*>(arg);
debugging::DebugPrint("%s\n", s);
XELOGD("PIX command result: %s\n", s);
debugging::DebugPrint("{}\n", s);
XELOGD("PIX command result: {}\n", s);
if (strcmp(s, "PIX!{CaptureFileCreationEnded} 0x00000000") == 0) {
xboxkrnl->SendPIXCommand("{BeginCapture}");
}

View File

@ -130,7 +130,7 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
assert_true(input_buffer_0_physical_address != UINT32_MAX);
if (input_buffer_0_physical_address == UINT32_MAX) {
XELOGE(
"XMAInitializeContext: Invalid input buffer 0 virtual address %.8X",
"XMAInitializeContext: Invalid input buffer 0 virtual address {:08X}",
input_buffer_0_guest_ptr);
return X_E_FALSE;
}
@ -143,7 +143,7 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
assert_true(input_buffer_1_physical_address != UINT32_MAX);
if (input_buffer_1_physical_address == UINT32_MAX) {
XELOGE(
"XMAInitializeContext: Invalid input buffer 1 virtual address %.8X",
"XMAInitializeContext: Invalid input buffer 1 virtual address {:08X}",
input_buffer_1_guest_ptr);
return X_E_FALSE;
}
@ -154,7 +154,7 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
kernel_memory()->GetPhysicalAddress(output_buffer_guest_ptr);
assert_true(output_buffer_physical_address != UINT32_MAX);
if (output_buffer_physical_address == UINT32_MAX) {
XELOGE("XMAInitializeContext: Invalid output buffer virtual address %.8X",
XELOGE("XMAInitializeContext: Invalid output buffer virtual address {:08X}",
output_buffer_guest_ptr);
return X_E_FALSE;
}
@ -234,7 +234,7 @@ dword_result_t XMASetInputBuffer0(lpvoid_t context_ptr, lpvoid_t buffer,
assert_true(buffer_physical_address != UINT32_MAX);
if (buffer_physical_address == UINT32_MAX) {
// Xenia-specific safety check.
XELOGE("XMASetInputBuffer0: Invalid buffer virtual address %.8X",
XELOGE("XMASetInputBuffer0: Invalid buffer virtual address {:08X}",
buffer.guest_address());
return X_E_FALSE;
}
@ -275,7 +275,7 @@ dword_result_t XMASetInputBuffer1(lpvoid_t context_ptr, lpvoid_t buffer,
assert_true(buffer_physical_address != UINT32_MAX);
if (buffer_physical_address == UINT32_MAX) {
// Xenia-specific safety check.
XELOGE("XMASetInputBuffer1: Invalid buffer virtual address %.8X",
XELOGE("XMASetInputBuffer1: Invalid buffer virtual address {:08X}",
buffer.guest_address());
return X_E_FALSE;
}

View File

@ -60,7 +60,7 @@ void HandleSetThreadName(pointer_t<X_EXCEPTION_RECORD> record) {
}
if (thread) {
XELOGD("SetThreadName(%d, %s)", thread->thread_id(), name);
XELOGD("SetThreadName({}, {})", thread->thread_id(), name);
thread->set_name(name);
}
@ -136,7 +136,7 @@ DECLARE_XBOXKRNL_EXPORT2(RtlRaiseException, kDebug, kStub, kImportant);
void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
dword_t param4) {
XELOGD("*** STOP: 0x%.8X (0x%.8X, 0x%.8X, 0x%.8X, 0x%.8X)", code, param1,
XELOGD("*** STOP: {:#08X} ({:#08X}, {:#08X}, {:#08X}, {:#08X})", code, param1,
param2, param3, param4);
fflush(stdout);
xe::debugging::Break();

View File

@ -997,7 +997,7 @@ uint32_t xeRtlNtStatusToDosError(uint32_t source_status) {
if (!result) {
break;
}
XELOGI("RtlNtStatusToDosError %X => %X", status, result);
XELOGI("RtlNtStatusToDosError {:X} => {:X}", status, result);
return result;
}
++error_table;

View File

@ -375,7 +375,7 @@ dword_result_t NtSetInformationFile(
info = 0;
bool delete_on_close =
(xe::load_and_swap<uint8_t>(file_info)) ? true : false;
XELOGW("NtSetInformationFile ignoring delete on close: %d",
XELOGW("NtSetInformationFile ignoring delete on close: {}",
delete_on_close);
break;
}

View File

@ -160,7 +160,7 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
}
}
XELOGD("NtAllocateVirtualMemory = %.8X", address);
XELOGD("NtAllocateVirtualMemory = {:08X}", address);
// Stash back.
// Maybe set X_STATUS_ALREADY_COMMITTED if MEM_COMMIT?
@ -356,7 +356,7 @@ dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size,
// Failed - assume no memory available.
return 0;
}
XELOGD("MmAllocatePhysicalMemoryEx = %.8X", base_address);
XELOGD("MmAllocatePhysicalMemoryEx = {:08X}", base_address);
return base_address;
}

View File

@ -65,8 +65,8 @@ bool XboxkrnlModule::SendPIXCommand(const char* cmd) {
xe::countof(args));
global_lock.lock();
XELOGD("PIX(command): %s", cmd);
XELOGD("PIX(response): %s", response);
XELOGD("PIX(command): {}", cmd);
XELOGD("PIX(response): {}", response);
memory_->SystemHeapFree(scratch_ptr);

View File

@ -830,7 +830,7 @@ SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
return;
}
XELOGD("(DbgPrint) %s", data.str().c_str());
XELOGD("(DbgPrint) {}", data.str());
SHIM_SET_RETURN_32(X_STATUS_SUCCESS);
}
@ -841,7 +841,7 @@ SHIM_CALL _snprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
XELOGD("_snprintf(%08X, %i, %08X, ...)", buffer_ptr, buffer_count,
XELOGD("_snprintf({:08X}, {}, {:08X}, ...)", buffer_ptr, buffer_count,
format_ptr);
if (buffer_ptr == 0 || buffer_count <= 0 || format_ptr == 0) {
@ -877,7 +877,7 @@ SHIM_CALL sprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
XELOGD("sprintf(%08X, %08X, ...)", buffer_ptr, format_ptr);
XELOGD("sprintf({:08X}, {:08X}, ...)", buffer_ptr, format_ptr);
if (buffer_ptr == 0 || format_ptr == 0) {
SHIM_SET_RETURN_32(-1);
@ -906,7 +906,7 @@ SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
int32_t buffer_count = SHIM_GET_ARG_32(1);
uint32_t format_ptr = SHIM_GET_ARG_32(2);
XELOGD("_snwprintf(%08X, %i, %08X, ...)", buffer_ptr, buffer_count,
XELOGD("_snwprintf({:08X}, {}, {:08X}, ...)", buffer_ptr, buffer_count,
format_ptr);
if (buffer_ptr == 0 || buffer_count <= 0 || format_ptr == 0) {
@ -942,7 +942,7 @@ SHIM_CALL swprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
uint32_t format_ptr = SHIM_GET_ARG_32(1);
XELOGD("swprintf(%08X, %08X, ...)", buffer_ptr, format_ptr);
XELOGD("swprintf({:08X}, {:08X}, ...)", buffer_ptr, format_ptr);
if (buffer_ptr == 0 || format_ptr == 0) {
SHIM_SET_RETURN_32(-1);
@ -972,7 +972,7 @@ SHIM_CALL _vsnprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(2);
uint32_t arg_ptr = SHIM_GET_ARG_32(3);
XELOGD("_vsnprintf(%08X, %i, %08X, %08X)", buffer_ptr, buffer_count,
XELOGD("_vsnprintf({:08X}, {}, {:08X}, {:08X})", buffer_ptr, buffer_count,
format_ptr, arg_ptr);
if (buffer_ptr == 0 || buffer_count <= 0 || format_ptr == 0) {
@ -1012,7 +1012,7 @@ SHIM_CALL _vsnwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(2);
uint32_t arg_ptr = SHIM_GET_ARG_32(3);
XELOGD("_vsnwprintf(%08X, %i, %08X, %08X)", buffer_ptr, buffer_count,
XELOGD("_vsnwprintf({:08X}, {}, {:08X}, {:08X})", buffer_ptr, buffer_count,
format_ptr, arg_ptr);
if (buffer_ptr == 0 || buffer_count <= 0 || format_ptr == 0) {
@ -1051,7 +1051,7 @@ SHIM_CALL vsprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(1);
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
XELOGD("vsprintf(%08X, %08X, %08X)", buffer_ptr, format_ptr, arg_ptr);
XELOGD("vsprintf({:08X}, {:08X}, {:08X})", buffer_ptr, format_ptr, arg_ptr);
if (buffer_ptr == 0 || format_ptr == 0) {
SHIM_SET_RETURN_32(-1);
@ -1079,7 +1079,7 @@ SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
uint32_t arg_ptr = SHIM_GET_ARG_32(1);
XELOGD("_vscwprintf(%08X, %08X)", format_ptr, arg_ptr);
XELOGD("_vscwprintf({:08X}, {:08X})", format_ptr, arg_ptr);
if (format_ptr == 0) {
SHIM_SET_RETURN_32(-1);

View File

@ -129,7 +129,7 @@ dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
X_STATUS result = thread->Create();
if (XFAILED(result)) {
// Failed!
XELOGE("Thread creation failed: %.8X", result);
XELOGE("Thread creation failed: {:08X}", result);
return result;
}
@ -872,7 +872,7 @@ DECLARE_XBOXKRNL_EXPORT3(NtSignalAndWaitForSingleObjectEx, kThreading,
uint32_t xeKeKfAcquireSpinLock(uint32_t* lock) {
// XELOGD(
// "KfAcquireSpinLock(%.8X)",
// "KfAcquireSpinLock({:08X})",
// lock_ptr);
// Lock.

View File

@ -370,7 +370,7 @@ void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
assert_true(frontbuffer_address != UINT32_MAX);
if (frontbuffer_address == UINT32_MAX) {
// Xenia-specific safety check.
XELOGE("VdSwap: Invalid front buffer virtual address 0x%.8X",
XELOGE("VdSwap: Invalid front buffer virtual address {:#08X}",
fetch.base_address << 12);
return;
}

View File

@ -72,7 +72,7 @@ int32_t XEvent::Reset() {
void XEvent::Clear() { event_->Reset(); }
bool XEvent::Save(ByteStream* stream) {
XELOGD("XEvent %.8X (%s)", handle(), manual_reset_ ? "manual" : "auto");
XELOGD("XEvent {:08X} ({})", handle(), manual_reset_ ? "manual" : "auto");
SaveObject(stream);
bool signaled = true;

View File

@ -226,7 +226,8 @@ void XFile::RemoveIOCompletionPort(uint32_t key) {
}
bool XFile::Save(ByteStream* stream) {
XELOGD("XFile %.8X (%s)", handle(), file_->entry()->absolute_path().c_str());
XELOGD("XFile {:08X} ({})", handle(),
file_->entry()->absolute_path().c_str());
if (!SaveObject(stream)) {
return false;
@ -257,7 +258,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
auto is_directory = stream->Read<bool>();
auto is_synchronous = stream->Read<bool>();
XELOGD("XFile %.8X (%s)", file->handle(), abs_path.c_str());
XELOGD("XFile {:08X} ({})", file->handle(), abs_path);
vfs::File* vfs_file = nullptr;
vfs::FileAction action;
@ -265,7 +266,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
abs_path, vfs::FileDisposition::kOpen, access, is_directory, &vfs_file,
&action);
if (XFAILED(res)) {
XELOGE("Failed to open XFile: error %.8X", res);
XELOGE("Failed to open XFile: error {:08X}", res);
return object_ref<XFile>(file);
}

View File

@ -69,7 +69,7 @@ uint32_t XModule::GetHandleFromHModule(void* hmodule) {
}
bool XModule::Save(ByteStream* stream) {
XELOGD("XModule %.8X (%s)", handle(), path().c_str());
XELOGD("XModule {:08X} ({})", handle(), path());
stream->Write('XMOD');
@ -99,7 +99,7 @@ object_ref<XModule> XModule::Restore(KernelState* kernel_state,
return nullptr;
}
XELOGD("XModule %.8X (%s)", module->handle(), module->path().c_str());
XELOGD("XModule {:08X} ({})", module->handle(), module->path());
module->hmodule_ptr_ = hmodule_ptr;
return module;

View File

@ -59,7 +59,7 @@ bool XMutant::Save(ByteStream* stream) {
uint32_t owning_thread_handle = owning_thread_ ? owning_thread_->handle() : 0;
stream->Write<uint32_t>(owning_thread_handle);
XELOGD("XMutant %.8X (owner: %.8X)", handle(), owning_thread_handle);
XELOGD("XMutant {:08X} (owner: {:08X})", handle(), owning_thread_handle);
return true;
}

View File

@ -57,7 +57,8 @@ bool XSemaphore::Save(ByteStream* stream) {
free_count++;
}
XELOGD("XSemaphore %.8X (count %d/%d)", handle(), free_count, maximum_count_);
XELOGD("XSemaphore {:08X} (count {}/{})", handle(), free_count,
maximum_count_);
// Restore the semaphore back to its previous count.
semaphore_->Release(free_count, nullptr);
@ -79,7 +80,7 @@ object_ref<XSemaphore> XSemaphore::Restore(KernelState* kernel_state,
sem->maximum_count_ = stream->Read<uint32_t>();
auto free_count = stream->Read<uint32_t>();
XELOGD("XSemaphore %.8X (count %d/%d)", sem->handle(), free_count,
XELOGD("XSemaphore {:08X} (count {}/{})", sem->handle(), free_count,
sem->maximum_count_);
sem->semaphore_ =

View File

@ -340,7 +340,7 @@ X_STATUS XThread::Create() {
// This is thread safe.
thread_state_ = new cpu::ThreadState(kernel_state()->processor(), thread_id_,
stack_base_, pcr_address_);
XELOGI("XThread%08X (%X) Stack: %.8X-%.8X", handle(), thread_id_,
XELOGI("XThread{:08X} ({:X}) Stack: {:08X}-{:08X}", handle(), thread_id_,
stack_limit_, stack_base_);
// Exports use this to get the kernel.
@ -493,8 +493,8 @@ X_STATUS XThread::Terminate(int exit_code) {
}
void XThread::Execute() {
XELOGKERNEL("XThread::Execute thid %d (handle=%.8X, '%s', native=%.8X)",
thread_id_, handle(), thread_name_.c_str(), thread_->system_id());
XELOGKERNEL("XThread::Execute thid {} (handle={:08X}, '{}', native={:08X})",
thread_id_, handle(), thread_name_, thread_->system_id());
// Let the kernel know we are starting.
kernel_state()->OnThreadExecute(this);
@ -593,7 +593,7 @@ void XThread::DeliverAPCs() {
auto apc = reinterpret_cast<XAPC*>(memory()->TranslateVirtual(apc_ptr));
bool needs_freeing = apc->kernel_routine == XAPC::kDummyKernelRoutine;
XELOGD("Delivering APC to %.8X", uint32_t(apc->normal_routine));
XELOGD("Delivering APC to {:08X}", uint32_t(apc->normal_routine));
// Mark as uninserted so that it can be reinserted again by the routine.
apc->enqueued = 0;
@ -636,7 +636,7 @@ void XThread::DeliverAPCs() {
LockApc();
}
XELOGD("Completed delivery of APC to %.8X (%.8X, %.8X, %.8X)",
XELOGD("Completed delivery of APC to {:08X} ({:08X}, {:08X}, {:08X})",
normal_routine, normal_context, arg1, arg2);
// If special, free it.
@ -852,13 +852,13 @@ bool XThread::Save(ByteStream* stream) {
return false;
}
XELOGD("XThread %.8X serializing...", handle());
XELOGD("XThread {:08X} serializing...", handle());
uint32_t pc = 0;
if (running_) {
pc = emulator()->processor()->StepToGuestSafePoint(thread_id_);
if (!pc) {
XELOGE("XThread %.8X failed to save: could not step to a safe point!",
XELOGE("XThread {:08X} failed to save: could not step to a safe point!",
handle());
assert_always();
return false;
@ -930,7 +930,7 @@ object_ref<XThread> XThread::Restore(KernelState* kernel_state,
return nullptr;
}
XELOGD("XThread %.8X", thread->handle());
XELOGD("XThread {:08X}", thread->handle());
thread->thread_name_ = stream->Read<std::string>();
@ -1041,8 +1041,8 @@ XHostThread::XHostThread(KernelState* kernel_state, uint32_t stack_size,
void XHostThread::Execute() {
XELOGKERNEL(
"XThread::Execute thid %d (handle=%.8X, '%s', native=%.8X, <host>)",
thread_id_, handle(), thread_name_.c_str(), thread_->system_id());
"XThread::Execute thid {} (handle={:08X}, '{}', native={:08X}, <host>)",
thread_id_, handle(), thread_name_, thread_->system_id());
// Let the kernel know we are starting.
kernel_state()->OnThreadExecute(this);

View File

@ -553,12 +553,11 @@ void Memory::DumpMap() {
XELOGE("==================================================================");
XELOGE("Memory Dump");
XELOGE("==================================================================");
XELOGE(" System Page Size: %d (%.8X)", system_page_size_,
system_page_size_);
XELOGE(" System Allocation Granularity: %d (%.8X)",
system_allocation_granularity_, system_allocation_granularity_);
XELOGE(" Virtual Membase: %.16llX", virtual_membase_);
XELOGE(" Physical Membase: %.16llX", physical_membase_);
XELOGE(" System Page Size: {0} ({0:08X})", system_page_size_);
XELOGE(" System Allocation Granularity: {0} ({0:08X})",
system_allocation_granularity_);
XELOGE(" Virtual Membase: {}", virtual_membase_);
XELOGE(" Physical Membase: {}", physical_membase_);
XELOGE("");
XELOGE("------------------------------------------------------------------");
XELOGE("Virtual Heaps");
@ -663,14 +662,13 @@ void BaseHeap::Dispose() {
void BaseHeap::DumpMap() {
auto global_lock = global_critical_region_.Acquire();
XELOGE("------------------------------------------------------------------");
XELOGE("Heap: %.8X-%.8X", heap_base_, heap_base_ + (heap_size_ - 1));
XELOGE("Heap: {:08X}-{:08X}", heap_base_, heap_base_ + (heap_size_ - 1));
XELOGE("------------------------------------------------------------------");
XELOGE(" Heap Base: %.8X", heap_base_);
XELOGE(" Heap Size: %d (%.8X)", heap_size_, heap_size_);
XELOGE(" Page Size: %d (%.8X)", page_size_, page_size_);
XELOGE(" Page Count: %lld", page_table_.size());
XELOGE(" Host Address Offset: %d (%.8X)", host_address_offset_,
host_address_offset_);
XELOGE(" Heap Base: {:08X}", heap_base_);
XELOGE(" Heap Size: {0} ({0:08X})", heap_size_);
XELOGE(" Page Size: {0} ({0:08X})", page_size_);
XELOGE(" Page Count: {}", page_table_.size());
XELOGE(" Host Address Offset: {0} ({0:08X})", host_address_offset_);
bool is_empty_span = false;
uint32_t empty_span_start = 0;
for (uint32_t i = 0; i < uint32_t(page_table_.size()); ++i) {
@ -683,7 +681,7 @@ void BaseHeap::DumpMap() {
continue;
}
if (is_empty_span) {
XELOGE(" %.8X-%.8X %6dp %10db unreserved",
XELOGE(" {:08X}-{:08X} {:6d}p {:10d}b unreserved",
heap_base_ + empty_span_start * page_size_,
heap_base_ + i * page_size_, i - empty_span_start,
(i - empty_span_start) * page_size_);
@ -697,14 +695,15 @@ void BaseHeap::DumpMap() {
}
char access_r = (page.current_protect & kMemoryProtectRead) ? 'R' : ' ';
char access_w = (page.current_protect & kMemoryProtectWrite) ? 'W' : ' ';
XELOGE(" %.8X-%.8X %6dp %10db %s %c%c", heap_base_ + i * page_size_,
XELOGE(" {:08X}-{:08X} {:6d}p {:10d}b {} {}{}",
heap_base_ + i * page_size_,
heap_base_ + (i + page.region_page_count) * page_size_,
page.region_page_count, page.region_page_count * page_size_,
state_name, access_r, access_w);
i += page.region_page_count - 1;
}
if (is_empty_span) {
XELOGE(" %.8X-%.8X - %d unreserved pages)",
XELOGE(" {:08X}-{:08X} - {} unreserved pages)",
heap_base_ + empty_span_start * page_size_,
heap_base_ + (heap_size_ - 1),
page_table_.size() - empty_span_start);
@ -741,7 +740,7 @@ uint32_t BaseHeap::GetUnreservedPageCount() {
}
bool BaseHeap::Save(ByteStream* stream) {
XELOGD("Heap %.8X-%.8X", heap_base_, heap_base_ + (heap_size_ - 1));
XELOGD("Heap {:08X}-{:08X}", heap_base_, heap_base_ + (heap_size_ - 1));
for (size_t i = 0; i < page_table_.size(); i++) {
auto& page = page_table_[i];
@ -769,7 +768,7 @@ bool BaseHeap::Save(ByteStream* stream) {
}
bool BaseHeap::Restore(ByteStream* stream) {
XELOGD("Heap %.8X-%.8X", heap_base_, heap_base_ + (heap_size_ - 1));
XELOGD("Heap {:08X}-{:08X}", heap_base_, heap_base_ + (heap_size_ - 1));
for (size_t i = 0; i < page_table_.size(); i++) {
auto& page = page_table_[i];

View File

@ -149,7 +149,7 @@ bool D3D12Context::InitializeSwapChainBuffers() {
for (uint32_t i = 0; i < kSwapChainBufferCount; ++i) {
if (FAILED(
swap_chain_->GetBuffer(i, IID_PPV_ARGS(&swap_chain_buffers_[i])))) {
XELOGE("Failed to get buffer %u of the swap chain", i);
XELOGE("Failed to get buffer {} of the swap chain", i);
return false;
}
}

View File

@ -78,7 +78,7 @@ bool D3D12ImmediateTexture::Initialize(ID3D12Device* device) {
if (FAILED(device->CreateCommittedResource(
&util::kHeapPropertiesDefault, D3D12_HEAP_FLAG_NONE, &resource_desc,
state_, nullptr, IID_PPV_ARGS(&resource_)))) {
XELOGE("Failed to create a %ux%u texture for immediate drawing", width,
XELOGE("Failed to create a {}x{} texture for immediate drawing", width,
height);
return false;
}
@ -358,7 +358,7 @@ void D3D12ImmediateDrawer::UpdateTexture(ImmediateTexture* texture,
&util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE, &buffer_desc,
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&buffer)))) {
XELOGE(
"Failed to create an upload buffer for a %ux%u texture for "
"Failed to create an upload buffer for a {}x{} texture for "
"immediate drawing",
width, height);
return;
@ -369,7 +369,7 @@ void D3D12ImmediateDrawer::UpdateTexture(ImmediateTexture* texture,
void* buffer_mapping;
if (FAILED(buffer->Map(0, &buffer_read_range, &buffer_mapping))) {
XELOGE(
"Failed to map an upload buffer for a %ux%u texture for immediate "
"Failed to map an upload buffer for a {}x{} texture for immediate "
"drawing",
width, height);
buffer->Release();
@ -506,7 +506,7 @@ void D3D12ImmediateDrawer::BeginDrawBatch(const ImmediateDrawBatch& batch) {
current_fence_value, vertex_buffer_view.SizeInBytes, nullptr, nullptr,
&vertex_buffer_view.BufferLocation);
if (vertex_buffer_mapping == nullptr) {
XELOGE("Failed to get a buffer for %u vertices in the immediate drawer",
XELOGE("Failed to get a buffer for {} vertices in the immediate drawer",
batch.vertex_count);
return;
}
@ -525,7 +525,7 @@ void D3D12ImmediateDrawer::BeginDrawBatch(const ImmediateDrawBatch& batch) {
xe::align(index_buffer_view.SizeInBytes, UINT(sizeof(uint32_t))),
nullptr, nullptr, &index_buffer_view.BufferLocation);
if (index_buffer_mapping == nullptr) {
XELOGE("Failed to get a buffer for %u indices in the immediate drawer",
XELOGE("Failed to get a buffer for {} indices in the immediate drawer",
batch.index_count);
return;
}

View File

@ -87,7 +87,7 @@ bool D3D12Provider::Initialize() {
library_d3dcompiler_ = LoadLibraryW(L"D3DCompiler_47.dll");
if (library_dxgi_ == nullptr || library_d3d12_ == nullptr ||
library_d3dcompiler_ == nullptr) {
XELOGE("Failed to load dxgi.dll, D3D12.dll and D3DCompiler_47.dll.");
XELOGE("Failed to load dxgi.dll, D3D12.dll or D3DCompiler_47.dll.");
return false;
}
bool libraries_loaded = true;
@ -184,8 +184,8 @@ bool D3D12Provider::Initialize() {
if (WideCharToMultiByte(CP_UTF8, 0, adapter_desc.Description, -1,
adapter_name_mb, adapter_name_mb_size, nullptr,
nullptr) != 0) {
XELOGD3D("DXGI adapter: %s (vendor %.4X, device %.4X)", adapter_name_mb,
adapter_desc.VendorId, adapter_desc.DeviceId);
XELOGD3D("DXGI adapter: {} (vendor {:04X}, device {:04X})",
adapter_name_mb, adapter_desc.VendorId, adapter_desc.DeviceId);
}
}
@ -253,13 +253,13 @@ bool D3D12Provider::Initialize() {
virtual_address_support.MaxGPUVirtualAddressBitsPerResource;
}
XELOGD3D("Direct3D 12 device features:");
XELOGD3D("* Max GPU virtual address bits per resource: %u",
XELOGD3D("* Max GPU virtual address bits per resource: {}",
virtual_address_bits_per_resource_);
XELOGD3D("* Programmable sample positions: tier %u",
XELOGD3D("* Programmable sample positions: tier {}",
programmable_sample_positions_tier_);
XELOGD3D("* Rasterizer-ordered views: %s",
XELOGD3D("* Rasterizer-ordered views: {}",
rasterizer_ordered_views_supported_ ? "yes" : "no");
XELOGD3D("* Tiled resources: tier %u", tiled_resources_tier_);
XELOGD3D("* Tiled resources: tier {}", tiled_resources_tier_);
// Get the graphics analysis interface, will silently fail if PIX is not
// attached.

View File

@ -30,7 +30,7 @@ ID3D12RootSignature* CreateRootSignature(
&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, &error_blob))) {
XELOGE("Failed to serialize a root signature");
if (error_blob != nullptr) {
XELOGE("%s",
XELOGE("{}",
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
error_blob->Release();
}

View File

@ -105,7 +105,7 @@ uint8_t* UploadBufferPool::Request(uint64_t submission_index, uint32_t size,
&util::kHeapPropertiesUpload, D3D12_HEAP_FLAG_NONE,
&new_buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS(&new_buffer)))) {
XELOGE("Failed to create a D3D upload buffer with %u bytes",
XELOGE("Failed to create a D3D upload buffer with {} bytes",
page_size_);
return nullptr;
}
@ -114,7 +114,7 @@ uint8_t* UploadBufferPool::Request(uint64_t submission_index, uint32_t size,
read_range.End = 0;
void* new_buffer_mapping;
if (FAILED(new_buffer->Map(0, &read_range, &new_buffer_mapping))) {
XELOGE("Failed to map a D3D upload buffer with %u bytes", page_size_);
XELOGE("Failed to map a D3D upload buffer with {} bytes", page_size_);
new_buffer->Release();
return nullptr;
}
@ -263,7 +263,7 @@ uint64_t DescriptorHeapPool::Request(uint64_t submission_index,
ID3D12DescriptorHeap* new_heap;
if (FAILED(device_->CreateDescriptorHeap(&new_heap_desc,
IID_PPV_ARGS(&new_heap)))) {
XELOGE("Failed to create a heap for %u shader-visible descriptors",
XELOGE("Failed to create a heap for {} shader-visible descriptors",
page_size_);
return kHeapIndexInvalid;
}

View File

@ -63,7 +63,7 @@ std::unique_ptr<SpirvAssembler::Result> SpirvAssembler::Assemble(
source_text_length, &binary, &diagnostic);
std::unique_ptr<Result> result(new Result(binary, diagnostic));
if (result_code) {
XELOGE("Failed to assemble spv: %d", result_code);
XELOGE("Failed to assemble spv: {}", result_code);
if (result->has_error()) {
return result;
} else {

View File

@ -67,7 +67,7 @@ std::unique_ptr<SpirvDisassembler::Result> SpirvDisassembler::Disassemble(
SPV_BINARY_TO_TEXT_OPTION_INDENT, &text, &diagnostic);
std::unique_ptr<Result> result(new Result(text, diagnostic));
if (result_code) {
XELOGE("Failed to disassemble spv: %d", result_code);
XELOGE("Failed to disassemble spv: {}", result_code);
if (result->has_error()) {
return result;
} else {

View File

@ -65,7 +65,7 @@ std::unique_ptr<SpirvValidator::Result> SpirvValidator::Validate(
auto result_code = spvValidate(spv_context_, &binary, &diagnostic);
std::unique_ptr<Result> result(new Result(text, diagnostic));
if (result_code) {
XELOGE("Failed to validate spv: %d", result_code);
XELOGE("Failed to validate spv: {}", result_code);
if (result->has_error()) {
return result;
} else {

View File

@ -93,9 +93,10 @@ bool UploadBufferChain::EnsureCurrentBufferAllocated() {
if (vkCreateBuffer(device, &buffer_create_info, nullptr,
&upload_buffer.buffer) != VK_SUCCESS) {
XELOGE(
"Failed to create a Vulkan upload buffer with %ull x %u bytes and "
"0x%.8X usage",
buffer_create_info.size, VulkanContext::kQueuedFrames, usage_flags_);
"Failed to create a Vulkan upload buffer with {} x {} bytes and "
"{:#08X} usage",
buffer_create_info.size, VulkanContext::kQueuedFrames,
static_cast<uint32_t>(usage_flags_));
buffer_creation_failed_ = true;
return false;
}
@ -110,8 +111,8 @@ bool UploadBufferChain::EnsureCurrentBufferAllocated() {
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
if (memory_type_ == UINT32_MAX) {
XELOGE(
"Failed to find a memory type for an upload buffer with %ull bytes "
"and 0x%.8X usage",
"Failed to find a memory type for an upload buffer with {} bytes "
"and {:#08X} usage",
buffer_memory_requirements.size, usage_flags_);
vkDestroyBuffer(device, upload_buffer.buffer, nullptr);
buffer_creation_failed_ = true;
@ -132,7 +133,7 @@ bool UploadBufferChain::EnsureCurrentBufferAllocated() {
memory_allocate_info.memoryTypeIndex = memory_type_;
if (vkAllocateMemory(device, &memory_allocate_info, nullptr,
&upload_buffer.memory) != VK_SUCCESS) {
XELOGE("Failed to allocate %ull for a Vulkan upload buffer",
XELOGE("Failed to allocate {} for a Vulkan upload buffer",
memory_page_size_);
vkDestroyBuffer(device, upload_buffer.buffer, nullptr);
buffer_creation_failed_ = true;
@ -141,7 +142,7 @@ bool UploadBufferChain::EnsureCurrentBufferAllocated() {
if (vkBindBufferMemory(device, upload_buffer.buffer, upload_buffer.memory,
0) != VK_SUCCESS) {
XELOGE("Failed to bind a %ull-byte memory object to a Vulkan upload buffer",
XELOGE("Failed to bind a {}-byte memory object to a Vulkan upload buffer",
memory_page_size_);
vkDestroyBuffer(device, upload_buffer.buffer, nullptr);
vkFreeMemory(device, upload_buffer.memory, nullptr);
@ -151,7 +152,7 @@ bool UploadBufferChain::EnsureCurrentBufferAllocated() {
if (vkMapMemory(device, upload_buffer.memory, 0, memory_page_size_, 0,
&upload_buffer.mapping) != VK_SUCCESS) {
XELOGE("Failed to map a %ull-byte memory object of a Vulkan upload buffer",
XELOGE("Failed to map a {}-byte memory object of a Vulkan upload buffer",
memory_page_size_);
vkDestroyBuffer(device, upload_buffer.buffer, nullptr);
vkFreeMemory(device, upload_buffer.memory, nullptr);

View File

@ -471,7 +471,7 @@ void VulkanContext::BeginSwap() {
swapchain_create_info.oldSwapchain = swapchain_;
if (vkCreateSwapchainKHR(device, &swapchain_create_info, nullptr,
&swapchain) != VK_SUCCESS) {
XELOGE("Failed to create a %ux%u Vulkan swap chain",
XELOGE("Failed to create a {}x{} Vulkan swap chain",
target_window_extent.width, target_window_extent.height);
context_lost_ = true;
return;

View File

@ -324,7 +324,7 @@ void VulkanImmediateDrawer::BeginDrawBatch(const ImmediateDrawBatch& batch) {
vertex_buffer_size, vertex_buffer, vertex_buffer_offset);
if (!vertex_buffer_mapping) {
XELOGE(
"Failed to get a Vulkan buffer for %u vertices in the immediate drawer",
"Failed to get a Vulkan buffer for {} vertices in the immediate drawer",
batch.vertex_count);
return;
}
@ -343,7 +343,7 @@ void VulkanImmediateDrawer::BeginDrawBatch(const ImmediateDrawBatch& batch) {
index_buffer, index_buffer_offset);
if (!index_buffer_mapping) {
XELOGE(
"Failed to get a Vulkan buffer for %u indices in the immediate "
"Failed to get a Vulkan buffer for {} indices in the immediate "
"drawer",
batch.index_count);
return;

View File

@ -241,7 +241,7 @@ bool VulkanProvider::Initialize() {
&physical_device_memory_properties_);
// Log physical device properties.
XELOGVK("Vulkan physical device: %s (vendor %.4X, device %.4X)",
XELOGVK("Vulkan physical device: {} (vendor {:04X}, device {:04X})",
physical_device_properties_.deviceName,
physical_device_properties_.vendorID,
physical_device_properties_.deviceID);

View File

@ -70,7 +70,7 @@ VulkanInstance::~VulkanInstance() { DestroyInstance(); }
bool VulkanInstance::Initialize() {
auto version = Version::Parse(VK_API_VERSION);
XELOGVK("Initializing Vulkan %s...", version.pretty_string.c_str());
XELOGVK("Initializing Vulkan {}...", version.pretty_string);
if (volkInitialize() != VK_SUCCESS) {
XELOGE("volkInitialize() failed!");
return false;
@ -134,7 +134,7 @@ bool VulkanInstance::EnableRenderDoc() {
int minor;
int patch;
api->GetAPIVersion(&major, &minor, &patch);
XELOGI("RenderDoc attached; %d.%d.%d", major, minor, patch);
XELOGI("RenderDoc attached; {}.{}.{}", major, minor, patch);
is_renderdoc_attached_ = true;
@ -173,18 +173,17 @@ bool VulkanInstance::QueryGlobals() {
} while (err == VK_INCOMPLETE);
CheckResult(err, "vkEnumerateInstanceExtensionProperties");
}
XELOGVK("Found %d global layers:", global_layers_.size());
XELOGVK("Found {} global layers:", global_layers_.size());
for (size_t i = 0; i < global_layers_.size(); ++i) {
auto& global_layer = global_layers_[i];
auto spec_version = Version::Parse(global_layer.properties.specVersion);
auto impl_version =
Version::Parse(global_layer.properties.implementationVersion);
XELOGVK("- %s (spec: %s, impl: %s)", global_layer.properties.layerName,
spec_version.pretty_string.c_str(),
impl_version.pretty_string.c_str());
XELOGVK(" %s", global_layer.properties.description);
XELOGVK("- {} (spec: {}, impl: {})", global_layer.properties.layerName,
spec_version.pretty_string, impl_version.pretty_string);
XELOGVK(" {}", global_layer.properties.description);
if (!global_layer.extensions.empty()) {
XELOGVK(" %d extensions:", global_layer.extensions.size());
XELOGVK(" {} extensions:", global_layer.extensions.size());
DumpExtensions(global_layer.extensions, " ");
}
}
@ -198,7 +197,7 @@ bool VulkanInstance::QueryGlobals() {
global_extensions_.data());
} while (err == VK_INCOMPLETE);
CheckResult(err, "vkEnumerateInstanceExtensionProperties");
XELOGVK("Found %d global extensions:", global_extensions_.size());
XELOGVK("Found {} global extensions:", global_extensions_.size());
DumpExtensions(global_extensions_, "");
return true;
@ -249,7 +248,7 @@ bool VulkanInstance::CreateInstance() {
auto err = vkCreateInstance(&instance_info, nullptr, &handle);
if (err != VK_SUCCESS) {
XELOGE("vkCreateInstance returned %s", to_string(err));
XELOGE("vkCreateInstance returned {}", to_string(err));
}
switch (err) {
case VK_SUCCESS:
@ -270,7 +269,7 @@ bool VulkanInstance::CreateInstance() {
XELOGE("Instance initialization failed; requested layer not present");
return false;
default:
XELOGE("Instance initialization failed; unknown: %s", to_string(err));
XELOGE("Instance initialization failed; unknown: {}", to_string(err));
return false;
}
@ -325,7 +324,7 @@ VkBool32 VKAPI_PTR DebugMessageCallback(VkDebugReportFlagsEXT flags,
message_type = "DEBUG";
}
XELOGVK("[%s/%s:%d] %s", pLayerPrefix, message_type, messageCode, pMessage);
XELOGVK("[{}/{}:{}] {}", pLayerPrefix, message_type, messageCode, pMessage);
return false;
}
@ -355,7 +354,7 @@ void VulkanInstance::EnableDebugValidation() {
if (status == VK_SUCCESS) {
XELOGVK("Debug validation layer enabled");
} else {
XELOGVK("Debug validation layer failed to install; error %s",
XELOGVK("Debug validation layer failed to install; error {}",
to_string(status));
}
}
@ -437,10 +436,10 @@ bool VulkanInstance::QueryDevices() {
available_devices_.push_back(std::move(device_info));
}
XELOGVK("Found %d physical devices:", available_devices_.size());
XELOGVK("Found {} physical devices:", available_devices_.size());
for (size_t i = 0; i < available_devices_.size(); ++i) {
auto& device_info = available_devices_[i];
XELOGVK("- Device %d:", i);
XELOGVK("- Device {}:", i);
DumpDeviceInfo(device_info);
}
@ -453,12 +452,11 @@ void VulkanInstance::DumpLayers(const std::vector<LayerInfo>& layers,
auto& layer = layers[i];
auto spec_version = Version::Parse(layer.properties.specVersion);
auto impl_version = Version::Parse(layer.properties.implementationVersion);
XELOGVK("%s- %s (spec: %s, impl: %s)", indent, layer.properties.layerName,
spec_version.pretty_string.c_str(),
impl_version.pretty_string.c_str());
XELOGVK("%s %s", indent, layer.properties.description);
XELOGVK("{}- {} (spec: {}, impl: {})", indent, layer.properties.layerName,
spec_version.pretty_string, impl_version.pretty_string);
XELOGVK("{} {}", indent, layer.properties.description);
if (!layer.extensions.empty()) {
XELOGVK("%s %d extensions:", indent, layer.extensions.size());
XELOGVK("{} {} extensions:", indent, layer.extensions.size());
DumpExtensions(layer.extensions, std::strlen(indent) ? " " : " ");
}
}
@ -469,8 +467,8 @@ void VulkanInstance::DumpExtensions(
for (size_t i = 0; i < extensions.size(); ++i) {
auto& extension = extensions[i];
auto version = Version::Parse(extension.specVersion);
XELOGVK("%s- %s (%s)", indent, extension.extensionName,
version.pretty_string.c_str());
XELOGVK("{}- {} ({})", indent, extension.extensionName,
version.pretty_string);
}
}
@ -478,21 +476,20 @@ void VulkanInstance::DumpDeviceInfo(const DeviceInfo& device_info) {
auto& properties = device_info.properties;
auto api_version = Version::Parse(properties.apiVersion);
auto driver_version = Version::Parse(properties.driverVersion);
XELOGVK(" apiVersion = %s", api_version.pretty_string.c_str());
XELOGVK(" driverVersion = %s", driver_version.pretty_string.c_str());
XELOGVK(" vendorId = 0x%04x", properties.vendorID);
XELOGVK(" deviceId = 0x%04x", properties.deviceID);
XELOGVK(" deviceType = %s", to_string(properties.deviceType));
XELOGVK(" deviceName = %s", properties.deviceName);
XELOGVK(" apiVersion = {}", api_version.pretty_string);
XELOGVK(" driverVersion = {}", driver_version.pretty_string);
XELOGVK(" vendorId = {:#04x}", properties.vendorID);
XELOGVK(" deviceId = {:#04x}", properties.deviceID);
XELOGVK(" deviceType = {}", to_string(properties.deviceType));
XELOGVK(" deviceName = {}", properties.deviceName);
auto& memory_props = device_info.memory_properties;
XELOGVK(" Memory Heaps:");
for (size_t j = 0; j < memory_props.memoryHeapCount; ++j) {
XELOGVK(" - Heap %u: %" PRIu64 " bytes", j,
memory_props.memoryHeaps[j].size);
XELOGVK(" - Heap {}: {} bytes", j, memory_props.memoryHeaps[j].size);
for (size_t k = 0; k < memory_props.memoryTypeCount; ++k) {
if (memory_props.memoryTypes[k].heapIndex == j) {
XELOGVK(" - Type %u:", k);
XELOGVK(" - Type {}:", k);
auto type_flags = memory_props.memoryTypes[k].propertyFlags;
if (!type_flags) {
XELOGVK(" VK_MEMORY_PROPERTY_DEVICE_ONLY");
@ -519,16 +516,16 @@ void VulkanInstance::DumpDeviceInfo(const DeviceInfo& device_info) {
XELOGVK(" Queue Families:");
for (size_t j = 0; j < device_info.queue_family_properties.size(); ++j) {
auto& queue_props = device_info.queue_family_properties[j];
XELOGVK(" - Queue %d:", j);
XELOGVK(" - Queue {}:", j);
XELOGVK(
" queueFlags = %s%s%s%s",
" queueFlags = {}{}{}{}",
(queue_props.queueFlags & VK_QUEUE_GRAPHICS_BIT) ? "graphics, " : "",
(queue_props.queueFlags & VK_QUEUE_COMPUTE_BIT) ? "compute, " : "",
(queue_props.queueFlags & VK_QUEUE_TRANSFER_BIT) ? "transfer, " : "",
(queue_props.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) ? "sparse, "
: "");
XELOGVK(" queueCount = %u", queue_props.queueCount);
XELOGVK(" timestampValidBits = %u", queue_props.timestampValidBits);
XELOGVK(" queueCount = {}", queue_props.queueCount);
XELOGVK(" timestampValidBits = {}", queue_props.timestampValidBits);
}
XELOGVK(" Layers:");

View File

@ -162,7 +162,7 @@ VkResult VulkanSwapChain::Initialize(VkSurfaceKHR surface) {
if (surface_caps.maxImageCount > 0 &&
image_count > surface_caps.maxImageCount) {
// Too many requested - use whatever we can.
XELOGI("Requested number of swapchain images (%d) exceeds maximum (%d)",
XELOGI("Requested number of swapchain images ({}) exceeds maximum ({})",
image_count, surface_caps.maxImageCount);
image_count = surface_caps.maxImageCount;
}
@ -194,25 +194,25 @@ VkResult VulkanSwapChain::Initialize(VkSurfaceKHR surface) {
create_info.oldSwapchain = nullptr;
XELOGVK("Creating swap chain:");
XELOGVK(" minImageCount = %u", create_info.minImageCount);
XELOGVK(" imageFormat = %s", to_string(create_info.imageFormat));
XELOGVK(" imageExtent = %d x %d", create_info.imageExtent.width,
XELOGVK(" minImageCount = {}", create_info.minImageCount);
XELOGVK(" imageFormat = {}", to_string(create_info.imageFormat));
XELOGVK(" imageExtent = {} x {}", create_info.imageExtent.width,
create_info.imageExtent.height);
auto pre_transform_str = to_flags_string(create_info.preTransform);
XELOGVK(" preTransform = %s", pre_transform_str.c_str());
XELOGVK(" imageArrayLayers = %u", create_info.imageArrayLayers);
XELOGVK(" presentMode = %s", to_string(create_info.presentMode));
XELOGVK(" clipped = %s", create_info.clipped ? "true" : "false");
XELOGVK(" imageColorSpace = %s", to_string(create_info.imageColorSpace));
XELOGVK(" preTransform = {}", pre_transform_str);
XELOGVK(" imageArrayLayers = {}", create_info.imageArrayLayers);
XELOGVK(" presentMode = {}", to_string(create_info.presentMode));
XELOGVK(" clipped = {}", create_info.clipped ? "true" : "false");
XELOGVK(" imageColorSpace = {}", to_string(create_info.imageColorSpace));
auto image_usage_flags_str = to_flags_string(
static_cast<VkImageUsageFlagBits>(create_info.imageUsage));
XELOGVK(" imageUsageFlags = %s", image_usage_flags_str.c_str());
XELOGVK(" imageSharingMode = %s", to_string(create_info.imageSharingMode));
XELOGVK(" queueFamilyCount = %u", create_info.queueFamilyIndexCount);
XELOGVK(" imageUsageFlags = {}", image_usage_flags_str);
XELOGVK(" imageSharingMode = {}", to_string(create_info.imageSharingMode));
XELOGVK(" queueFamilyCount = {}", create_info.queueFamilyIndexCount);
status = vkCreateSwapchainKHR(*device_, &create_info, nullptr, &handle);
if (status != VK_SUCCESS) {
XELOGE("Failed to create swapchain: %s", to_string(status));
XELOGE("Failed to create swapchain: {}", to_string(status));
return status;
}
@ -799,7 +799,7 @@ VkResult VulkanSwapChain::End() {
// Fatal. Device lost.
break;
default:
XELOGE("Failed to queue present: %s", to_string(status));
XELOGE("Failed to queue present: {}", to_string(status));
assert_always("Unexpected queue present failure");
}

View File

@ -410,7 +410,7 @@ void FatalVulkanError(std::string error) {
void CheckResult(VkResult result, const char* action) {
if (result) {
XELOGE("Vulkan check: %s returned %s", action, to_string(result));
XELOGE("Vulkan check: {} returned {}", action, to_string(result));
}
assert_true(result == VK_SUCCESS, action);
}
@ -430,26 +430,26 @@ std::pair<bool, std::vector<const char*>> CheckRequirements(
found = true;
if (requirement.min_version > layer_infos[j].properties.specVersion) {
if (requirement.is_optional) {
XELOGVK("- optional layer %s (%s) version mismatch", layer_name,
layer_version.pretty_string.c_str());
XELOGVK("- optional layer {} ({}) version mismatch", layer_name,
layer_version.pretty_string);
continue;
}
XELOGE("ERROR: required layer %s (%s) version mismatch", layer_name,
layer_version.pretty_string.c_str());
XELOGE("ERROR: required layer {} ({}) version mismatch", layer_name,
layer_version.pretty_string);
any_missing = true;
break;
}
XELOGVK("- enabling layer %s (%s)", layer_name,
layer_version.pretty_string.c_str());
XELOGVK("- enabling layer {} ({})", layer_name,
layer_version.pretty_string);
enabled_layers.push_back(layer_name);
break;
}
}
if (!found) {
if (requirement.is_optional) {
XELOGVK("- optional layer %s not found", requirement.name.c_str());
XELOGVK("- optional layer {} not found", requirement.name);
} else {
XELOGE("ERROR: required layer %s not found", requirement.name.c_str());
XELOGE("ERROR: required layer {} not found", requirement.name);
any_missing = true;
}
}
@ -472,27 +472,26 @@ std::pair<bool, std::vector<const char*>> CheckRequirements(
found = true;
if (requirement.min_version > extension_properties[j].specVersion) {
if (requirement.is_optional) {
XELOGVK("- optional extension %s (%s) version mismatch",
extension_name, extension_version.pretty_string.c_str());
XELOGVK("- optional extension {} ({}) version mismatch",
extension_name, extension_version.pretty_string);
continue;
}
XELOGE("ERROR: required extension %s (%s) version mismatch",
extension_name, extension_version.pretty_string.c_str());
XELOGE("ERROR: required extension {} ({}) version mismatch",
extension_name, extension_version.pretty_string);
any_missing = true;
break;
}
XELOGVK("- enabling extension %s (%s)", extension_name,
extension_version.pretty_string.c_str());
XELOGVK("- enabling extension {} ({})", extension_name,
extension_version.pretty_string);
enabled_extensions.push_back(extension_name);
break;
}
}
if (!found) {
if (requirement.is_optional) {
XELOGVK("- optional extension %s not found", requirement.name.c_str());
XELOGVK("- optional extension {} not found", requirement.name);
} else {
XELOGE("ERROR: required extension %s not found",
requirement.name.c_str());
XELOGE("ERROR: required extension {} not found", requirement.name);
any_missing = true;
}
}

Some files were not shown because too many files have changed in this diff Show More