Code cleanup: moving poly logging to xenia
This commit is contained in:
parent
f7ca026db0
commit
d76998915a
|
@ -1,77 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_LOGGING_H_
|
||||
#define POLY_LOGGING_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/string.h"
|
||||
|
||||
namespace poly {
|
||||
|
||||
#define POLY_OPTION_ENABLE_LOGGING 1
|
||||
#define POLY_OPTION_LOG_ERROR 1
|
||||
#define POLY_OPTION_LOG_WARNING 1
|
||||
#define POLY_OPTION_LOG_INFO 1
|
||||
#define POLY_OPTION_LOG_DEBUG 1
|
||||
|
||||
#define POLY_EMPTY_MACRO \
|
||||
do { \
|
||||
} while (false)
|
||||
|
||||
#if XE_COMPILER_GNUC
|
||||
#define POLY_LOG_LINE_ATTRIBUTE __attribute__((format(printf, 5, 6)))
|
||||
#else
|
||||
#define POLY_LOG_LINE_ATTRIBUTE
|
||||
#endif // GNUC
|
||||
void log_line(const char* file_path, const uint32_t line_number,
|
||||
const char level_char, const char* fmt,
|
||||
...) POLY_LOG_LINE_ATTRIBUTE;
|
||||
#undef POLY_LOG_LINE_ATTRIBUTE
|
||||
|
||||
void handle_fatal(const char* file_path, const uint32_t line_number,
|
||||
const char* fmt, ...);
|
||||
|
||||
#if POLY_OPTION_ENABLE_LOGGING
|
||||
#define PLOGCORE(level, fmt, ...) \
|
||||
poly::log_line(__FILE__, __LINE__, level, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PLOGCORE(level, fmt, ...) POLY_EMPTY_MACRO
|
||||
#endif // ENABLE_LOGGING
|
||||
|
||||
#define PFATAL(fmt, ...) \
|
||||
do { \
|
||||
poly::handle_fatal(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
#if POLY_OPTION_LOG_ERROR
|
||||
#define PLOGE(fmt, ...) PLOGCORE('!', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PLOGE(fmt, ...) POLY_EMPTY_MACRO
|
||||
#endif
|
||||
#if POLY_OPTION_LOG_WARNING
|
||||
#define PLOGW(fmt, ...) PLOGCORE('w', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PLOGW(fmt, ...) POLY_EMPTY_MACRO
|
||||
#endif
|
||||
#if POLY_OPTION_LOG_INFO
|
||||
#define PLOGI(fmt, ...) PLOGCORE('i', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PLOGI(fmt, ...) POLY_EMPTY_MACRO
|
||||
#endif
|
||||
#if POLY_OPTION_LOG_DEBUG
|
||||
#define PLOGD(fmt, ...) PLOGCORE('d', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PLOGD(fmt, ...) POLY_EMPTY_MACRO
|
||||
#endif
|
||||
|
||||
} // namespace poly
|
||||
|
||||
#endif // POLY_LOGGING_H_
|
|
@ -15,7 +15,6 @@
|
|||
#include "poly/byte_order.h"
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/debugging.h"
|
||||
#include "poly/logging.h"
|
||||
#include "poly/mapped_memory.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/memory.h"
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
'cxx_compat.h',
|
||||
'fs.h',
|
||||
'fs.cc',
|
||||
'logging.cc',
|
||||
'logging.h',
|
||||
'main.h',
|
||||
'mapped_memory.h',
|
||||
'math.cc',
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "xenia/cpu/backend/x64/x64_code_cache.h"
|
||||
|
||||
#include "poly/poly.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -193,7 +194,7 @@ void X64CodeChunk::AddTableEntry(uint8_t* code, size_t code_size,
|
|||
if (fn_table_count + 1 > fn_table_capacity) {
|
||||
// Table exhausted, need to realloc. If this happens a lot we should tune
|
||||
// the table size to prevent this.
|
||||
PLOGW("X64CodeCache growing FunctionTable - adjust ESTIMATED_FN_SIZE");
|
||||
XELOGW("X64CodeCache growing FunctionTable - adjust ESTIMATED_FN_SIZE");
|
||||
RtlDeleteGrowableFunctionTable(fn_table_handle);
|
||||
size_t old_size = fn_table_capacity * sizeof(RUNTIME_FUNCTION);
|
||||
size_t new_size = old_size * 2;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/backend/x64/x64_code_cache.h"
|
||||
#include "xenia/cpu/backend/x64/x64_function.h"
|
||||
|
@ -20,9 +21,9 @@
|
|||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "poly/vec128.h"
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
#include "xdb/protocol.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -201,7 +202,7 @@ int X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
|
|||
if (!SelectSequence(*this, instr, &new_tail)) {
|
||||
// No sequence found!
|
||||
assert_always();
|
||||
PLOGE("Unable to process HIR opcode %s", instr->opcode->name);
|
||||
XELOGE("Unable to process HIR opcode %s", instr->opcode->name);
|
||||
break;
|
||||
}
|
||||
instr = new_tail;
|
||||
|
@ -373,7 +374,7 @@ 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?
|
||||
PLOGD("(DebugPrint) %s", str);
|
||||
XELOGD("(DebugPrint) %s", str);
|
||||
return 0;
|
||||
}
|
||||
void X64Emitter::Trap(uint16_t trap_type) {
|
||||
|
@ -395,7 +396,7 @@ void X64Emitter::Trap(uint16_t trap_type) {
|
|||
// ?
|
||||
break;
|
||||
default:
|
||||
PLOGW("Unknown trap type %d", trap_type);
|
||||
XELOGW("Unknown trap type %d", trap_type);
|
||||
db(0xCC);
|
||||
break;
|
||||
}
|
||||
|
@ -620,8 +621,8 @@ void X64Emitter::CallIndirect(const hir::Instr* instr, const Reg64& reg) {
|
|||
|
||||
uint64_t UndefinedCallExtern(void* raw_context, uint64_t symbol_info_ptr) {
|
||||
auto symbol_info = reinterpret_cast<FunctionInfo*>(symbol_info_ptr);
|
||||
PLOGW("undefined extern call to %.8llX %s", symbol_info->address(),
|
||||
symbol_info->name().c_str());
|
||||
XELOGW("undefined extern call to %.8llX %s", symbol_info->address(),
|
||||
symbol_info->name().c_str());
|
||||
return 0;
|
||||
}
|
||||
void X64Emitter::CallExtern(const hir::Instr* instr,
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "xenia/cpu/backend/x64/x64_tracers.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -5877,7 +5878,7 @@ bool SelectSequence(X64Emitter& e, const Instr* i, const Instr** new_tail) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
PLOGE("No sequence match for variant %s", i->opcode->name);
|
||||
XELOGE("No sequence match for variant %s", i->opcode->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -146,7 +147,7 @@ int RegisterAllocationPass::Run(HIRBuilder* builder) {
|
|||
// We spill only those registers we aren't using.
|
||||
if (!SpillOneRegister(builder, block, instr->dest->type)) {
|
||||
// Unable to spill anything - this shouldn't happen.
|
||||
PLOGE("Unable to spill any registers");
|
||||
XELOGE("Unable to spill any registers");
|
||||
assert_always();
|
||||
return 1;
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ int RegisterAllocationPass::Run(HIRBuilder* builder) {
|
|||
// Demand allocation.
|
||||
if (!TryAllocateRegister(instr->dest)) {
|
||||
// Boned.
|
||||
PLOGE("Register allocation failed");
|
||||
XELOGE("Register allocation failed");
|
||||
assert_always();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -114,7 +115,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
|||
instr_offset_list_[offset] = first_instr;
|
||||
|
||||
if (!i.type) {
|
||||
PLOGE("Invalid instruction %.8llX %.8X", i.address, i.code);
|
||||
XELOGE("Invalid instruction %.8llX %.8X", i.address, i.code);
|
||||
Comment("INVALID!");
|
||||
// TraceInvalidInstruction(i);
|
||||
continue;
|
||||
|
@ -130,8 +131,8 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
|||
}
|
||||
|
||||
if (!i.type->emit || emit(*this, i)) {
|
||||
PLOGE("Unimplemented instr %.8llX %.8X %s", i.address, i.code,
|
||||
i.type->name);
|
||||
XELOGE("Unimplemented instr %.8llX %.8X %s", i.address, i.code,
|
||||
i.type->name);
|
||||
Comment("UNIMPLEMENTED!");
|
||||
// DebugBreak();
|
||||
// TraceInvalidInstruction(i);
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/cpu/frontend/ppc_frontend.h"
|
||||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "poly/logging.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
#if 0
|
||||
#define LOGPPC(fmt, ...) PLOGCORE('p', fmt, ##__VA_ARGS__)
|
||||
#define LOGPPC(fmt, ...) XELOGCORE('p', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define LOGPPC(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define LOGPPC(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
|
||||
namespace xe {
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/main.h"
|
||||
#include "poly/poly.h"
|
||||
#include "xenia/cpu/cpu.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_frontend.h"
|
||||
#include "xenia/cpu/raw_module.h"
|
||||
#include "poly/main.h"
|
||||
#include "poly/poly.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
#if !XE_PLATFORM_WIN32
|
||||
#include <dirent.h>
|
||||
|
@ -56,11 +57,11 @@ class TestSuite {
|
|||
|
||||
bool Load() {
|
||||
if (!ReadMap(map_file_path)) {
|
||||
PLOGE("Unable to read map for test %ls", src_file_path.c_str());
|
||||
XELOGE("Unable to read map for test %ls", src_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!ReadAnnotations(src_file_path)) {
|
||||
PLOGE("Unable to read annotations for test %ls", src_file_path.c_str());
|
||||
XELOGE("Unable to read annotations for test %ls", src_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -138,8 +139,8 @@ class TestSuite {
|
|||
std::string label(start + strlen("test_"), strchr(start, ':'));
|
||||
current_test_case = FindTestCase(label);
|
||||
if (!current_test_case) {
|
||||
PLOGE("Test case %s not found in corresponding map for %ls",
|
||||
label.c_str(), src_file_path.c_str());
|
||||
XELOGE("Test case %s not found in corresponding map for %ls",
|
||||
label.c_str(), src_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
} else if (strlen(start) > 3 && start[0] == '#' && start[1] == '_') {
|
||||
|
@ -154,8 +155,8 @@ class TestSuite {
|
|||
value.erase(value.end() - 1);
|
||||
}
|
||||
if (!current_test_case) {
|
||||
PLOGE("Annotation outside of test case in %ls",
|
||||
src_file_path.c_str());
|
||||
XELOGE("Annotation outside of test case in %ls",
|
||||
src_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
current_test_case->annotations.emplace_back(key, value);
|
||||
|
@ -188,7 +189,7 @@ class TestRunner {
|
|||
// Load the binary module.
|
||||
auto module = std::make_unique<xe::cpu::RawModule>(runtime.get());
|
||||
if (module->LoadFile(START_ADDRESS, suite.bin_file_path)) {
|
||||
PLOGE("Unable to load test binary %ls", suite.bin_file_path.c_str());
|
||||
XELOGE("Unable to load test binary %ls", suite.bin_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
runtime->AddModule(std::move(module));
|
||||
|
@ -206,7 +207,7 @@ class TestRunner {
|
|||
bool Run(TestCase& test_case) {
|
||||
// Setup test state from annotations.
|
||||
if (!SetupTestState(test_case)) {
|
||||
PLOGE("Test setup failed");
|
||||
XELOGE("Test setup failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -214,7 +215,7 @@ class TestRunner {
|
|||
xe::cpu::Function* fn;
|
||||
runtime->ResolveFunction(test_case.address, &fn);
|
||||
if (!fn) {
|
||||
PLOGE("Entry function not found");
|
||||
XELOGE("Entry function not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -325,7 +326,7 @@ bool DiscoverTests(std::wstring& test_path,
|
|||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = FindFirstFile(search_path.c_str(), &ffd);
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
PLOGE("Unable to find test path %ls", test_path.c_str());
|
||||
XELOGE("Unable to find test path %ls", test_path.c_str());
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
|
@ -343,7 +344,7 @@ bool DiscoverTests(std::wstring& test_path,
|
|||
#else
|
||||
DIR* d = opendir(test_path.c_str());
|
||||
if (!d) {
|
||||
PLOGE("Unable to find test path %ls", test_path.c_str());
|
||||
XELOGE("Unable to find test path %ls", test_path.c_str());
|
||||
return false;
|
||||
}
|
||||
struct dirent* dir;
|
||||
|
@ -378,11 +379,11 @@ bool RunTests(const std::wstring& test_name) {
|
|||
return false;
|
||||
}
|
||||
if (!test_files.size()) {
|
||||
PLOGE("No tests discovered - invalid path?");
|
||||
XELOGE("No tests discovered - invalid path?");
|
||||
return false;
|
||||
}
|
||||
PLOGI("%d tests discovered.", (int)test_files.size());
|
||||
PLOGI("");
|
||||
XELOGI("%d tests discovered.", (int)test_files.size());
|
||||
XELOGI("");
|
||||
|
||||
std::vector<TestSuite> test_suites;
|
||||
bool load_failed = false;
|
||||
|
@ -392,7 +393,7 @@ bool RunTests(const std::wstring& test_name) {
|
|||
continue;
|
||||
}
|
||||
if (!test_suite.Load()) {
|
||||
PLOGE("TEST SUITE %ls FAILED TO LOAD", test_path.c_str());
|
||||
XELOGE("TEST SUITE %ls FAILED TO LOAD", test_path.c_str());
|
||||
load_failed = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -403,30 +404,30 @@ bool RunTests(const std::wstring& test_name) {
|
|||
}
|
||||
|
||||
for (auto& test_suite : test_suites) {
|
||||
PLOGI("%ls.s:", test_suite.name.c_str());
|
||||
XELOGI("%ls.s:", test_suite.name.c_str());
|
||||
|
||||
for (auto& test_case : test_suite.test_cases) {
|
||||
PLOGI(" - %s", test_case.name.c_str());
|
||||
XELOGI(" - %s", test_case.name.c_str());
|
||||
TestRunner runner;
|
||||
if (!runner.Setup(test_suite)) {
|
||||
PLOGE(" TEST FAILED SETUP");
|
||||
XELOGE(" TEST FAILED SETUP");
|
||||
++failed_count;
|
||||
}
|
||||
if (runner.Run(test_case)) {
|
||||
++passed_count;
|
||||
} else {
|
||||
PLOGE(" TEST FAILED");
|
||||
XELOGE(" TEST FAILED");
|
||||
++failed_count;
|
||||
}
|
||||
}
|
||||
|
||||
PLOGI("");
|
||||
XELOGI("");
|
||||
}
|
||||
|
||||
PLOGI("");
|
||||
PLOGI("Total tests: %d", failed_count + passed_count);
|
||||
PLOGI("Passed: %d", passed_count);
|
||||
PLOGI("Failed: %d", failed_count);
|
||||
XELOGI("");
|
||||
XELOGI("Total tests: %d", failed_count + passed_count);
|
||||
XELOGI("Passed: %d", passed_count);
|
||||
XELOGI("Failed: %d", failed_count);
|
||||
|
||||
return failed_count ? false : true;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
#include "xenia/cpu/function.h"
|
||||
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/cpu/debugger.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "poly/logging.h"
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -91,8 +91,8 @@ int Function::Call(ThreadState* thread_state, uint32_t return_address) {
|
|||
handler(thread_state->context(), symbol_info_->extern_arg0(),
|
||||
symbol_info_->extern_arg1());
|
||||
} else {
|
||||
PLOGW("undefined extern call to %.8llX %s", symbol_info_->address(),
|
||||
symbol_info_->name().c_str());
|
||||
XELOGW("undefined extern call to %.8llX %s", symbol_info_->address(),
|
||||
symbol_info_->name().c_str());
|
||||
result = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "poly/logging.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||
|
@ -171,7 +170,7 @@ void CommandProcessor::CallInThread(std::function<void()> fn) {
|
|||
void CommandProcessor::WorkerMain() {
|
||||
context_->MakeCurrent();
|
||||
if (!SetupGL()) {
|
||||
PFATAL("Unable to setup command processor GL state");
|
||||
XEFATAL("Unable to setup command processor GL state");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -229,19 +228,19 @@ bool CommandProcessor::SetupGL() {
|
|||
|
||||
// Circular buffer holding scratch vertex/index data.
|
||||
if (!scratch_buffer_.Initialize()) {
|
||||
PLOGE("Unable to initialize scratch buffer");
|
||||
XELOGE("Unable to initialize scratch buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Command buffer.
|
||||
if (!draw_batcher_.Initialize(&scratch_buffer_)) {
|
||||
PLOGE("Unable to initialize command buffer");
|
||||
XELOGE("Unable to initialize command buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Texture cache that keeps track of any textures/samplers used.
|
||||
if (!texture_cache_.Initialize(memory_, &scratch_buffer_)) {
|
||||
PLOGE("Unable to initialize texture cache");
|
||||
XELOGE("Unable to initialize texture cache");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -427,7 +426,7 @@ GLuint CommandProcessor::CreateGeometryProgram(const std::string& source) {
|
|||
info_log.resize(log_length - 1);
|
||||
glGetProgramInfoLog(program, log_length, &log_length,
|
||||
const_cast<char*>(info_log.data()));
|
||||
PLOGE("Unable to link program: %s", info_log.c_str());
|
||||
XELOGE("Unable to link program: %s", info_log.c_str());
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
|
@ -928,7 +927,7 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(RingbufferReader* reader,
|
|||
uint32_t count) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
PLOGI("XE_SWAP");
|
||||
XELOGI("XE_SWAP");
|
||||
|
||||
// Xenia-specific VdSwap hook.
|
||||
// VdSwap will post this to tell us we need to swap the screen/fire an
|
||||
|
@ -1490,7 +1489,7 @@ bool CommandProcessor::IssueDraw() {
|
|||
#define CHECK_ISSUE_UPDATE_STATUS(status, mismatch, error_message) \
|
||||
{ \
|
||||
if (status == UpdateStatus::kError) { \
|
||||
PLOGE(error_message); \
|
||||
XELOGE(error_message); \
|
||||
draw_batcher_.DiscardDraw(); \
|
||||
return false; \
|
||||
} else if (status == UpdateStatus::kMismatch) { \
|
||||
|
@ -1810,7 +1809,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateState() {
|
|||
#define CHECK_UPDATE_STATUS(status, mismatch, error_message) \
|
||||
{ \
|
||||
if (status == UpdateStatus::kError) { \
|
||||
PLOGE(error_message); \
|
||||
XELOGE(error_message); \
|
||||
return status; \
|
||||
} else if (status == UpdateStatus::kMismatch) { \
|
||||
mismatch = true; \
|
||||
|
@ -2579,7 +2578,7 @@ bool CommandProcessor::IssueCopy() {
|
|||
if (!source_framebuffer) {
|
||||
// If we get here we are likely missing some state checks.
|
||||
assert_always("No framebuffer for copy source? no-op copy?");
|
||||
PLOGE("No framebuffer for copy source");
|
||||
XELOGE("No framebuffer for copy source");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
|||
// incoming ringbuffer packets.
|
||||
command_processor_ = std::make_unique<CommandProcessor>(this);
|
||||
if (!command_processor_->Initialize(std::move(processor_context))) {
|
||||
PLOGE("Unable to initialize command processor");
|
||||
XELOGE("Unable to initialize command processor");
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
command_processor_->set_swap_handler(
|
||||
|
|
|
@ -233,7 +233,7 @@ bool GL4Shader::PrepareVertexShader(
|
|||
|
||||
// Build static vertex array descriptor.
|
||||
if (!PrepareVertexArrayObject()) {
|
||||
PLOGE("Unable to prepare vertex shader array object");
|
||||
XELOGE("Unable to prepare vertex shader array object");
|
||||
return false;
|
||||
}
|
||||
std::string apply_transform =
|
||||
|
@ -280,7 +280,7 @@ bool GL4Shader::PrepareVertexShader(
|
|||
std::string translated_source =
|
||||
shader_translator_.TranslateVertexShader(this, program_cntl);
|
||||
if (translated_source.empty()) {
|
||||
PLOGE("Vertex shader failed translation");
|
||||
XELOGE("Vertex shader failed translation");
|
||||
return false;
|
||||
}
|
||||
source += translated_source;
|
||||
|
@ -333,7 +333,7 @@ bool GL4Shader::PreparePixelShader(
|
|||
std::string translated_source =
|
||||
shader_translator_.TranslatePixelShader(this, program_cntl);
|
||||
if (translated_source.empty()) {
|
||||
PLOGE("Pixel shader failed translation");
|
||||
XELOGE("Pixel shader failed translation");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ bool GL4Shader::CompileProgram(std::string source) {
|
|||
: GL_FRAGMENT_SHADER,
|
||||
1, &source_str);
|
||||
if (!program_) {
|
||||
PLOGE("Unable to create shader program");
|
||||
XELOGE("Unable to create shader program");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ bool GL4Shader::CompileProgram(std::string source) {
|
|||
info_log.resize(log_length - 1);
|
||||
glGetProgramInfoLog(program_, log_length, &log_length,
|
||||
const_cast<char*>(info_log.data()));
|
||||
PLOGE("Unable to link program: %s", info_log.c_str());
|
||||
XELOGE("Unable to link program: %s", info_log.c_str());
|
||||
error_log_ = std::move(info_log);
|
||||
assert_always("Unable to link generated shader");
|
||||
return false;
|
||||
|
@ -436,7 +436,7 @@ bool GL4Shader::CompileProgram(std::string source) {
|
|||
fprintf(f, "\n*/\n");
|
||||
fclose(f);
|
||||
} else {
|
||||
PLOGW("Got program binary but unable to find disassembly");
|
||||
XELOGW("Got program binary but unable to find disassembly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/logging.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
@ -63,17 +62,17 @@ bool GLContext::Initialize(HWND hwnd) {
|
|||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
int pixel_format = ChoosePixelFormat(dc_, &pfd);
|
||||
if (!pixel_format) {
|
||||
PLOGE("Unable to choose pixel format");
|
||||
XELOGE("Unable to choose pixel format");
|
||||
return false;
|
||||
}
|
||||
if (!SetPixelFormat(dc_, pixel_format, &pfd)) {
|
||||
PLOGE("Unable to set pixel format");
|
||||
XELOGE("Unable to set pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
HGLRC temp_context = wglCreateContext(dc_);
|
||||
if (!temp_context) {
|
||||
PLOGE("Unable to create temporary GL context");
|
||||
XELOGE("Unable to create temporary GL context");
|
||||
return false;
|
||||
}
|
||||
wglMakeCurrent(dc_, temp_context);
|
||||
|
@ -82,16 +81,16 @@ bool GLContext::Initialize(HWND hwnd) {
|
|||
tls_wglew_context_ = &wglew_context_;
|
||||
glewExperimental = GL_TRUE;
|
||||
if (glewInit() != GLEW_OK) {
|
||||
PLOGE("Unable to initialize GLEW");
|
||||
XELOGE("Unable to initialize GLEW");
|
||||
return false;
|
||||
}
|
||||
if (wglewInit() != GLEW_OK) {
|
||||
PLOGE("Unable to initialize WGLEW");
|
||||
XELOGE("Unable to initialize WGLEW");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WGLEW_ARB_create_context) {
|
||||
PLOGE("WGL_ARG_create_context not supported by GL ICD");
|
||||
XELOGE("WGL_ARG_create_context not supported by GL ICD");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,12 +107,12 @@ bool GLContext::Initialize(HWND hwnd) {
|
|||
wglMakeCurrent(nullptr, nullptr);
|
||||
wglDeleteContext(temp_context);
|
||||
if (!glrc_) {
|
||||
PLOGE("Unable to create real GL context");
|
||||
XELOGE("Unable to create real GL context");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!MakeCurrent()) {
|
||||
PLOGE("Could not make real GL context current");
|
||||
XELOGE("Could not make real GL context current");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -124,7 +123,7 @@ bool GLContext::Initialize(HWND hwnd) {
|
|||
SetupDebugging();
|
||||
|
||||
if (!blitter_.Initialize()) {
|
||||
PLOGE("Unable to initialize blitter");
|
||||
XELOGE("Unable to initialize blitter");
|
||||
ClearCurrent();
|
||||
return false;
|
||||
}
|
||||
|
@ -154,33 +153,33 @@ std::unique_ptr<GLContext> GLContext::CreateShared() {
|
|||
0};
|
||||
new_glrc = wglCreateContextAttribsARB(dc_, glrc_, attrib_list);
|
||||
if (!new_glrc) {
|
||||
PLOGE("Could not create shared context");
|
||||
XELOGE("Could not create shared context");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto new_context = std::make_unique<GLContext>(hwnd_, new_glrc);
|
||||
if (!new_context->MakeCurrent()) {
|
||||
PLOGE("Could not make new GL context current");
|
||||
XELOGE("Could not make new GL context current");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
glewExperimental = GL_TRUE;
|
||||
if (glewInit() != GLEW_OK) {
|
||||
new_context->ClearCurrent();
|
||||
PLOGE("Unable to initialize GLEW");
|
||||
XELOGE("Unable to initialize GLEW");
|
||||
return nullptr;
|
||||
}
|
||||
if (wglewInit() != GLEW_OK) {
|
||||
new_context->ClearCurrent();
|
||||
PLOGE("Unable to initialize WGLEW");
|
||||
XELOGE("Unable to initialize WGLEW");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SetupDebugging();
|
||||
|
||||
if (!new_context->blitter_.Initialize()) {
|
||||
PLOGE("Unable to initialize blitter");
|
||||
XELOGE("Unable to initialize blitter");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -325,7 +324,7 @@ bool GLContext::MakeCurrent() {
|
|||
if (FLAGS_thread_safe_gl) {
|
||||
global_gl_mutex_.unlock();
|
||||
}
|
||||
PLOGE("Unable to make GL context current");
|
||||
XELOGE("Unable to make GL context current");
|
||||
return false;
|
||||
}
|
||||
tls_glew_context_ = &glew_context_;
|
||||
|
|
|
@ -215,7 +215,7 @@ TextureCache::TextureEntryView* TextureCache::Demand(
|
|||
uint64_t texture_hash = texture_info.hash();
|
||||
auto texture_entry = LookupOrInsertTexture(texture_info, texture_hash);
|
||||
if (!texture_entry) {
|
||||
PLOGE("Failed to setup texture");
|
||||
XELOGE("Failed to setup texture");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ TextureCache::TextureEntryView* TextureCache::Demand(
|
|||
// No existing view found - build it.
|
||||
auto sampler_entry = LookupOrInsertSampler(sampler_info, sampler_hash);
|
||||
if (!sampler_entry) {
|
||||
PLOGE("Failed to setup texture sampler");
|
||||
XELOGE("Failed to setup texture sampler");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ TextureCache::TextureEntry* TextureCache::LookupOrInsertTexture(
|
|||
return false;
|
||||
}
|
||||
if (!uploaded) {
|
||||
PLOGE("Failed to convert/upload texture");
|
||||
XELOGE("Failed to convert/upload texture");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "xenia/gpu/gl4/wgl_control.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/logging.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -43,7 +43,7 @@ bool WGLControl::Create() {
|
|||
wcex.lpszMenuName = nullptr;
|
||||
wcex.lpszClassName = L"XeniaWglClass";
|
||||
if (!RegisterClassEx(&wcex)) {
|
||||
PLOGE("WGL RegisterClassEx failed");
|
||||
XELOGE("WGL RegisterClassEx failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,12 +55,12 @@ bool WGLControl::Create() {
|
|||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
parent_hwnd(), nullptr, hInstance, this);
|
||||
if (!hwnd_) {
|
||||
PLOGE("WGL CreateWindow failed");
|
||||
XELOGE("WGL CreateWindow failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context_.Initialize(hwnd_)) {
|
||||
PFATAL("Unable to initialize GL context");
|
||||
XEFATAL("Unable to initialize GL context");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/logging.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@ DEFINE_bool(flush_stdout, true, "Flush stdout after each log line.");
|
|||
DEFINE_bool(log_filenames, false,
|
||||
"Log filenames/line numbers in log statements.");
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
std::mutex log_lock;
|
||||
|
||||
|
@ -130,4 +130,4 @@ void handle_fatal(const char* file_path, const uint32_t line_number,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/logging.h"
|
||||
#include "poly/string.h"
|
||||
|
||||
namespace xe {
|
||||
|
||||
#define XE_OPTION_ENABLE_LOGGING 1
|
||||
#define XE_OPTION_LOG_ERROR 1
|
||||
|
@ -25,51 +27,82 @@
|
|||
#define XE_OPTION_LOG_KERNEL 1
|
||||
#define XE_OPTION_LOG_FS 1
|
||||
|
||||
#if XE_OPTION_LOG_ERROR
|
||||
#define XELOGE PLOGE
|
||||
#define XE_EMPTY_MACRO \
|
||||
do { \
|
||||
} while (false)
|
||||
|
||||
#if XE_COMPILER_GNUC
|
||||
#define XE_LOG_LINE_ATTRIBUTE __attribute__((format(printf, 5, 6)))
|
||||
#else
|
||||
#define XELOGE(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XE_LOG_LINE_ATTRIBUTE
|
||||
#endif // XE_COMPILER_GNUC
|
||||
void log_line(const char* file_path, const uint32_t line_number,
|
||||
const char level_char, const char* fmt,
|
||||
...) XE_LOG_LINE_ATTRIBUTE;
|
||||
#undef XE_LOG_LINE_ATTRIBUTE
|
||||
|
||||
void handle_fatal(const char* file_path, const uint32_t line_number,
|
||||
const char* fmt, ...);
|
||||
|
||||
#if XE_OPTION_ENABLE_LOGGING
|
||||
#define XELOGCORE(level, fmt, ...) \
|
||||
xe::log_line(__FILE__, __LINE__, level, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGCORE(level, fmt, ...) XE_EMPTY_MACRO
|
||||
#endif // ENABLE_LOGGING
|
||||
|
||||
#define XEFATAL(fmt, ...) \
|
||||
do { \
|
||||
xe::handle_fatal(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
#if XE_OPTION_LOG_ERROR
|
||||
#define XELOGE(fmt, ...) XELOGCORE('!', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGE(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_WARNING
|
||||
#define XELOGW PLOGW
|
||||
#define XELOGW(fmt, ...) XELOGCORE('w', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGW(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGW(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_INFO
|
||||
#define XELOGI PLOGI
|
||||
#define XELOGI(fmt, ...) XELOGCORE('i', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGI(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGI(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_DEBUG
|
||||
#define XELOGD PLOGD
|
||||
#define XELOGD(fmt, ...) XELOGCORE('d', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGD(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGD(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
|
||||
#if XE_OPTION_LOG_CPU
|
||||
#define XELOGCPU(fmt, ...) PLOGCORE('C', fmt, ##__VA_ARGS__)
|
||||
#define XELOGCPU(fmt, ...) XELOGCORE('C', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGCPU(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGCPU(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_APU
|
||||
#define XELOGAPU(fmt, ...) PLOGCORE('A', fmt, ##__VA_ARGS__)
|
||||
#define XELOGAPU(fmt, ...) XELOGCORE('A', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGAPU(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGAPU(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_GPU
|
||||
#define XELOGGPU(fmt, ...) PLOGCORE('G', fmt, ##__VA_ARGS__)
|
||||
#define XELOGGPU(fmt, ...) XELOGCORE('G', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGGPU(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGGPU(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_KERNEL
|
||||
#define XELOGKERNEL(fmt, ...) PLOGCORE('K', fmt, ##__VA_ARGS__)
|
||||
#define XELOGKERNEL(fmt, ...) XELOGCORE('K', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGKERNEL(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGKERNEL(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
#if XE_OPTION_LOG_FS
|
||||
#define XELOGFS(fmt, ...) PLOGCORE('F', fmt, ##__VA_ARGS__)
|
||||
#define XELOGFS(fmt, ...) XELOGCORE('F', fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define XELOGFS(fmt, ...) POLY_EMPTY_MACRO
|
||||
#define XELOGFS(fmt, ...) XE_EMPTY_MACRO
|
||||
#endif
|
||||
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_LOGGING_H_
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define MICROPROFILE_PER_THREAD_BUFFER_SIZE (1024 * 1024 * 10)
|
||||
#define MICROPROFILE_USE_THREAD_NAME_CALLBACK 1
|
||||
#define MICROPROFILE_WEBSERVER_MAXFRAMES 3
|
||||
#define MICROPROFILE_PRINTF PLOGI
|
||||
#define MICROPROFILE_PRINTF XELOGI
|
||||
#define MICROPROFILE_WEBSERVER 1
|
||||
#define MICROPROFILE_DEBUG 0
|
||||
#if MICROPROFILE_WEBSERVER
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
'emulator.h',
|
||||
'export_resolver.cc',
|
||||
'export_resolver.h',
|
||||
'logging.cc',
|
||||
'logging.h',
|
||||
'memory.cc',
|
||||
'memory.h',
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
#include "xenia/ui/main_window.h"
|
||||
|
||||
#include "poly/logging.h"
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/gpu/graphics_system.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -31,7 +31,7 @@ void MainWindow::Start() {
|
|||
xe::Profiler::ThreadEnter("Win32 Loop");
|
||||
|
||||
if (!Initialize()) {
|
||||
PFATAL("Failed to initialize main window");
|
||||
XEFATAL("Failed to initialize main window");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void MainWindow::OnClose() {
|
|||
loop_.Quit();
|
||||
|
||||
// TODO(benvanik): proper exit.
|
||||
PLOGI("User-initiated death!");
|
||||
XELOGI("User-initiated death!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <tpcshrd.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "poly/logging.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
@ -46,7 +46,7 @@ bool Win32Window::Create() {
|
|||
wcex.lpszMenuName = nullptr;
|
||||
wcex.lpszClassName = L"XeniaWindowClass";
|
||||
if (!RegisterClassEx(&wcex)) {
|
||||
PLOGE("RegisterClassEx failed");
|
||||
XELOGE("RegisterClassEx failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ bool Win32Window::Create() {
|
|||
window_style, rc.left, rc.top, rc.right - rc.left,
|
||||
rc.bottom - rc.top, nullptr, nullptr, hInstance, this);
|
||||
if (!hwnd_) {
|
||||
PLOGE("CreateWindow failed");
|
||||
XELOGE("CreateWindow failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue