Replace all gflag implementations with cvar implementations

This commit is contained in:
Jonathan Goyvaerts 2019-04-17 21:49:29 +02:00
parent a01908aa15
commit c1af632562
74 changed files with 345 additions and 375 deletions

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "xenia/app/emulator_window.h"
// Autogenerated by `xb premake`.
@ -17,6 +15,7 @@
#include "third_party/imgui/imgui.h"
#include "xenia/app/discord/discord_presence.h"
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/logging.h"
#include "xenia/base/platform.h"
@ -29,7 +28,8 @@
#include "xenia/ui/imgui_dialog.h"
#include "xenia/ui/imgui_drawer.h"
DEFINE_bool(discord, false, "Enable Discord rich presence");
DECLARE_bool(debug);
DEFINE_bool(discord, false, "Enable Discord rich presence", "General");
namespace xe {
namespace app {
@ -85,7 +85,7 @@ bool EmulatorWindow::Initialize() {
return false;
}
if (FLAGS_discord) {
if (cvars::discord) {
discord::DiscordPresence::InitializeDiscord();
discord::DiscordPresence::NotPlaying();
}
@ -344,7 +344,7 @@ void EmulatorWindow::FileOpen() {
void EmulatorWindow::FileClose() {
if (emulator_->is_title_open()) {
emulator_->TerminateTitle();
if (FLAGS_discord) {
if (cvars::discord) {
discord::DiscordPresence::NotPlaying();
}
}
@ -398,7 +398,7 @@ void EmulatorWindow::CpuTimeScalarSetDouble() {
}
void EmulatorWindow::CpuBreakIntoDebugger() {
if (!FLAGS_debug) {
if (!cvars::debug) {
xe::ui::ImGuiDialog::ShowMessageBox(window_.get(), "Xenia Debugger",
"Xenia must be launched with the "
"--debug flag in order to enable "
@ -444,7 +444,7 @@ void EmulatorWindow::UpdateTitle() {
auto game_title = emulator()->game_title();
title += xe::format_string(L" | [%.8X] %s", emulator()->title_id(),
game_title.c_str());
if (FLAGS_discord) {
if (cvars::discord) {
discord::DiscordPresence::PlayingTitle(game_title);
}
}

View File

@ -7,9 +7,8 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "xenia/app/emulator_window.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
@ -37,26 +36,33 @@
#include "xenia/hid/xinput/xinput_hid.h"
#endif // XE_PLATFORM_WIN32
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]");
DEFINE_string(gpu, "any", "Graphics system. Use: [any, vulkan, null]");
DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]");
#include "third_party/xbyak/xbyak/xbyak_util.h"
DEFINE_string(target, "", "Specifies the target .xex or .iso to execute.");
DEFINE_bool(fullscreen, false, "Toggles fullscreen");
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]", "General");
DEFINE_string(gpu, "any", "Graphics system. Use: [any, vulkan, null]",
"General");
DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]",
"General");
DEFINE_string(content_root, "", "Root path for content (save/etc) storage.");
DEFINE_bool(fullscreen, false, "Toggles fullscreen", "General");
DEFINE_bool(mount_scratch, false, "Enable scratch mount");
DEFINE_bool(mount_cache, false, "Enable cache mount");
DEFINE_string(content_root, "", "Root path for content (save/etc) storage.",
"General");
DEFINE_bool(mount_scratch, false, "Enable scratch mount", "General");
DEFINE_bool(mount_cache, false, "Enable cache mount", "General");
CmdVar(target, "", "Specifies the target .xex or .iso to execute.");
DECLARE_bool(debug);
namespace xe {
namespace app {
std::unique_ptr<apu::AudioSystem> CreateAudioSystem(cpu::Processor* processor) {
if (FLAGS_apu.compare("nop") == 0) {
if (cvars::apu.compare("nop") == 0) {
return apu::nop::NopAudioSystem::Create(processor);
#if XE_PLATFORM_WIN32
} else if (FLAGS_apu.compare("xaudio2") == 0) {
} else if (cvars::apu.compare("xaudio2") == 0) {
return apu::xaudio2::XAudio2AudioSystem::Create(processor);
#endif // XE_PLATFORM_WIN32
} else {
@ -76,10 +82,10 @@ std::unique_ptr<apu::AudioSystem> CreateAudioSystem(cpu::Processor* processor) {
}
std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() {
if (FLAGS_gpu.compare("vulkan") == 0) {
if (cvars::gpu.compare("vulkan") == 0) {
return std::unique_ptr<gpu::GraphicsSystem>(
new xe::gpu::vulkan::VulkanGraphicsSystem());
} else if (FLAGS_gpu.compare("null") == 0) {
} else if (cvars::gpu.compare("null") == 0) {
return std::unique_ptr<gpu::GraphicsSystem>(
new xe::gpu::null::NullGraphicsSystem());
} else {
@ -100,12 +106,12 @@ std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() {
std::vector<std::unique_ptr<hid::InputDriver>> CreateInputDrivers(
ui::Window* window) {
std::vector<std::unique_ptr<hid::InputDriver>> drivers;
if (FLAGS_hid.compare("nop") == 0) {
if (cvars::hid.compare("nop") == 0) {
drivers.emplace_back(xe::hid::nop::Create(window));
#if XE_PLATFORM_WIN32
} else if (FLAGS_hid.compare("winkey") == 0) {
} else if (cvars::hid.compare("winkey") == 0) {
drivers.emplace_back(xe::hid::winkey::Create(window));
} else if (FLAGS_hid.compare("xinput") == 0) {
} else if (cvars::hid.compare("xinput") == 0) {
drivers.emplace_back(xe::hid::xinput::Create(window));
#endif // XE_PLATFORM_WIN32
} else {
@ -139,10 +145,9 @@ int xenia_main(const std::vector<std::wstring>& args) {
Profiler::ThreadEnter("main");
// Figure out where content should go.
std::wstring content_root;
if (!FLAGS_content_root.empty()) {
content_root = xe::to_wstring(FLAGS_content_root);
} else {
std::wstring content_root = xe::to_wstring(cvars::content_root);
if (content_root.empty()) {
auto base_path = xe::filesystem::GetExecutableFolder();
base_path = xe::to_absolute_path(base_path);
@ -181,7 +186,7 @@ int xenia_main(const std::vector<std::wstring>& args) {
return 1;
}
if (FLAGS_mount_scratch) {
if (cvars::mount_scratch) {
auto scratch_device = std::make_unique<xe::vfs::HostPathDevice>(
"\\SCRATCH", L"scratch", false);
if (!scratch_device->Initialize()) {
@ -195,7 +200,7 @@ int xenia_main(const std::vector<std::wstring>& args) {
}
}
if (FLAGS_mount_cache) {
if (cvars::mount_cache) {
auto cache0_device =
std::make_unique<xe::vfs::HostPathDevice>("\\CACHE0", L"cache0", false);
if (!cache0_device->Initialize()) {
@ -224,7 +229,7 @@ int xenia_main(const std::vector<std::wstring>& args) {
// Set a debug handler.
// This will respond to debugging requests so we can open the debug UI.
std::unique_ptr<xe::debug::ui::DebugWindow> debug_window;
if (FLAGS_debug) {
if (cvars::debug) {
emulator->processor()->set_debug_listener_request_handler(
[&](xe::cpu::Processor* processor) {
if (debug_window) {
@ -270,20 +275,12 @@ int xenia_main(const std::vector<std::wstring>& args) {
// Grab path from the flag or unnamed argument.
std::wstring path;
if (!FLAGS_target.empty() || args.size() >= 2) {
if (!FLAGS_target.empty()) {
// Passed as a named argument.
// TODO(benvanik): find something better than gflags that supports
// unicode.
path = xe::to_wstring(FLAGS_target);
} else {
// Passed as an unnamed argument.
path = args[1];
}
if (!cvars::target.empty()) {
path = xe::to_wstring(cvars::target);
}
// Toggles fullscreen
if (FLAGS_fullscreen) emulator_window->ToggleFullscreen();
if (cvars::fullscreen) emulator_window->ToggleFullscreen();
if (!path.empty()) {
// Normalize the path and make absolute.

View File

@ -9,4 +9,4 @@
#include "xenia/apu/apu_flags.h"
DEFINE_bool(mute, false, "Mutes all audio output.");
DEFINE_bool(mute, false, "Mutes all audio output.", "Audio")

View File

@ -10,8 +10,7 @@
#ifndef XENIA_APU_APU_FLAGS_H_
#define XENIA_APU_APU_FLAGS_H_
#include <gflags/gflags.h>
DECLARE_bool(mute);
#include "xenia/base/cvar.h"
DECLARE_bool(mute)
#endif // XENIA_APU_APU_FLAGS_H_

View File

@ -10,6 +10,4 @@
#ifndef XENIA_APU_NOP_NOP_APU_FLAGS_H_
#define XENIA_APU_NOP_NOP_APU_FLAGS_H_
#include <gflags/gflags.h>
#endif // XENIA_APU_NOP_NOP_APU_FLAGS_H_

View File

@ -10,6 +10,4 @@
#ifndef XENIA_APU_XAUDIO2_XAUDIO2_APU_FLAGS_H_
#define XENIA_APU_XAUDIO2_XAUDIO2_APU_FLAGS_H_
#include <gflags/gflags.h>
#endif // XENIA_APU_XAUDIO2_XAUDIO2_APU_FLAGS_H_

View File

@ -151,7 +151,7 @@ bool XAudio2AudioDriver::Initialize() {
return false;
}
if (FLAGS_mute) {
if (cvars::mute) {
pcm_voice_->SetVolume(0.0f);
}

View File

@ -9,9 +9,8 @@
#include "xenia/apu/xma_decoder.h"
#include <gflags/gflags.h>
#include "xenia/apu/xma_context.h"
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/base/profiling.h"
@ -49,7 +48,8 @@ extern "C" {
// do this, it's likely they are either passing the context to XAudio or
// using the XMA* functions.
DEFINE_bool(libav_verbose, false, "Verbose libav output (debug and above)");
DEFINE_bool(libav_verbose, false, "Verbose libav output (debug and above)",
"Audio");
namespace xe {
namespace apu {
@ -60,7 +60,7 @@ XmaDecoder::XmaDecoder(cpu::Processor* processor)
XmaDecoder::~XmaDecoder() = default;
void av_log_callback(void* avcl, int level, const char* fmt, va_list va) {
if (!FLAGS_libav_verbose && level > AV_LOG_WARNING) {
if (!cvars::libav_verbose && level > AV_LOG_WARNING) {
return;
}

View File

@ -9,8 +9,6 @@
#include "xenia/base/logging.h"
#include <gflags/gflags.h>
#include <atomic>
#include <cinttypes>
#include <cstdarg>
@ -19,6 +17,7 @@
#include <vector>
#include "xenia/base/atomic.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/filesystem.h"
#include "xenia/base/main.h"
@ -26,6 +25,7 @@
#include "xenia/base/memory.h"
#include "xenia/base/ring_buffer.h"
#include "xenia/base/threading.h"
//#include "xenia/base/cvar.h"
// For MessageBox:
// TODO(benvanik): generic API? logging_win.cc?
@ -35,12 +35,15 @@
DEFINE_string(
log_file, "",
"Logs are written to the given file (specify stdout for command line)");
DEFINE_bool(log_debugprint, false, "Dump the log to DebugPrint.");
DEFINE_bool(flush_log, true, "Flush log file after each log line batch.");
"Logs are written to the given file (specify stdout for command line)",
"Logging");
DEFINE_bool(log_debugprint, false, "Dump the log to DebugPrint.", "Logging");
DEFINE_bool(flush_log, true, "Flush log file after each log line batch.",
"Logging");
DEFINE_int32(
log_level, 2,
"Maximum level to be logged. (0=error, 1=warning, 2=info, 3=debug)");
"Maximum level to be logged. (0=error, 1=warning, 2=info, 3=debug)",
"Logging");
namespace xe {
@ -52,16 +55,16 @@ thread_local std::vector<char> log_format_buffer_(64 * 1024);
class Logger {
public:
explicit Logger(const std::wstring& app_name) : running_(true) {
if (FLAGS_log_file.empty()) {
if (cvars::log_file.empty()) {
// Default to app name.
auto file_path = app_name + L".log";
xe::filesystem::CreateParentFolder(file_path);
file_ = xe::filesystem::OpenFile(file_path, "wt");
} else {
if (FLAGS_log_file == "stdout") {
if (cvars::log_file == "stdout") {
file_ = stdout;
} else {
auto file_path = xe::to_wstring(FLAGS_log_file.c_str());
auto file_path = xe::to_wstring(cvars::log_file);
xe::filesystem::CreateParentFolder(file_path);
file_ = xe::filesystem::OpenFile(file_path, "wt");
}
@ -81,7 +84,7 @@ class Logger {
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) > FLAGS_log_level) {
if (static_cast<int32_t>(level) > cvars::log_level) {
// Discard this line.
return;
}
@ -148,7 +151,7 @@ class Logger {
fwrite(buf, 1, size, file_);
}
if (FLAGS_log_debugprint) {
if (cvars::log_debugprint) {
debugging::DebugPrint("%.*s", size, buf);
}
}
@ -214,7 +217,7 @@ class Logger {
read_head_ = rb.read_offset();
}
if (did_write) {
if (FLAGS_flush_log) {
if (cvars::flush_log) {
fflush(file_);
}

View File

@ -7,10 +7,9 @@
******************************************************************************
*/
#include "xenia/base/cvar.h"
#include "xenia/base/main.h"
#include <gflags/gflags.h>
#include "xenia/base/logging.h"
#include "xenia/base/string.h"
@ -23,10 +22,7 @@ bool has_console_attached() { return true; }
extern "C" int main(int argc, char** argv) {
auto entry_info = xe::GetEntryInfo();
google::SetUsageMessage(std::string("usage: ") +
xe::to_string(entry_info.usage));
google::SetVersionString("1.0");
google::ParseCommandLineFlags(&argc, &argv, true);
cvar::ParseLaunchArguments(argc, argv);
std::vector<std::wstring> args;
for (int n = 0; n < argc; n++) {
@ -39,6 +35,5 @@ extern "C" int main(int argc, char** argv) {
// Call app-provided entry point.
int result = entry_info.entry_point(args);
google::ShutDownCommandLineFlags();
return result;
}

View File

@ -10,7 +10,6 @@
#include "xenia/base/main.h"
#include <fcntl.h>
#include <gflags/gflags.h>
#include <io.h>
#include <cstdlib>
@ -18,6 +17,7 @@
// Autogenerated by `xb premake`.
#include "build/version.h"
#include "xenia/base/filesystem.h"
#include "xenia/base/logging.h"
#include "xenia/base/platform_win.h"
#include "xenia/base/string.h"
@ -25,9 +25,10 @@
#include "third_party/xbyak/xbyak/xbyak_util.h"
#include <bcrypt.h>
#include "xenia/base/cvar.h"
DEFINE_bool(win32_high_freq, true,
"Requests high performance from the NT kernel");
"Requests high performance from the NT kernel", "Kernel");
namespace xe {
@ -96,10 +97,6 @@ int Main() {
return 1;
}
google::SetUsageMessage(std::string("usage: ") +
xe::to_string(entry_info.usage));
google::SetVersionString("1.0");
// Convert all args to narrow, as gflags doesn't support wchar.
int argca = argc;
char** argva = reinterpret_cast<char**>(alloca(sizeof(char*) * argca));
@ -109,8 +106,7 @@ int Main() {
std::wcstombs(argva[n], argv[n], len + 1);
}
// Parse flags; this may delete some of them.
google::ParseCommandLineFlags(&argc, &argva, true);
cvar::ParseLaunchArguments(argca, argva);
// Widen all remaining flags and convert to usable strings.
std::vector<std::wstring> args;
@ -143,7 +139,7 @@ int Main() {
XE_BUILD_DATE);
// Request high performance timing.
if (FLAGS_win32_high_freq) {
if (cvars::win32_high_freq) {
RequestHighPerformance();
}
@ -151,7 +147,6 @@ int Main() {
int result = entry_info.entry_point(args);
xe::ShutdownLogging();
google::ShutDownCommandLineFlags();
LocalFree(argv);
return result;
}

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include <string>
// NOTE: this must be included before microprofile as macro expansion needs
@ -30,6 +28,7 @@
#include "third_party/microprofile/microprofile.h"
#include "xenia/base/assert.h"
#include "xenia/base/cvar.h"
#include "xenia/base/profiling.h"
#include "xenia/ui/window.h"
@ -42,7 +41,7 @@
#include "xenia/ui/microprofile_drawer.h"
#endif // XE_OPTION_PROFILING_UI
DEFINE_bool(show_profiler, false, "Show profiling UI by default.");
DEFINE_bool(show_profiler, false, "Show profiling UI by default.", "Other");
namespace xe {
@ -77,7 +76,7 @@ void Profiler::Initialize() {
g_MicroProfileUI.bShowSpikes = true;
g_MicroProfileUI.nOpacityBackground = 0x40u << 24;
g_MicroProfileUI.nOpacityForeground = 0xc0u << 24;
if (FLAGS_show_profiler) {
if (cvars::show_profiler) {
MicroProfileSetDisplayMode(1);
}
#else

View File

@ -28,7 +28,8 @@
DEFINE_bool(
enable_haswell_instructions, true,
"Uses the AVX2/FMA/etc instructions on Haswell processors, if available.");
"Uses the AVX2/FMA/etc instructions on Haswell processors, if available.",
"CPU");
namespace xe {
namespace cpu {
@ -83,7 +84,7 @@ bool X64Backend::Initialize(Processor* processor) {
}
// Need movbe to do advanced LOAD/STORE tricks.
if (FLAGS_enable_haswell_instructions) {
if (cvars::enable_haswell_instructions) {
machine_info_.supports_extended_load_store =
cpu.has(Xbyak::util::Cpu::tMOVBE);
} else {

View File

@ -10,10 +10,9 @@
#ifndef XENIA_CPU_BACKEND_X64_X64_BACKEND_H_
#define XENIA_CPU_BACKEND_X64_X64_BACKEND_H_
#include <gflags/gflags.h>
#include <memory>
#include "xenia/base/cvar.h"
#include "xenia/cpu/backend/backend.h"
DECLARE_bool(enable_haswell_instructions);

View File

@ -9,8 +9,6 @@
#include "xenia/cpu/backend/x64/x64_emitter.h"
#include <gflags/gflags.h>
#include <stddef.h>
#include <climits>
#include <cstring>
@ -36,11 +34,12 @@
#include "xenia/cpu/thread_state.h"
DEFINE_bool(enable_debugprint_log, false,
"Log debugprint traps to the active debugger");
"Log debugprint traps to the active debugger", "CPU");
DEFINE_bool(ignore_undefined_externs, true,
"Don't exit when an undefined extern is called.");
"Don't exit when an undefined extern is called.", "CPU");
DEFINE_bool(emit_source_annotations, false,
"Add extra movs and nops to make disassembly easier to read.");
"Add extra movs and nops to make disassembly easier to read.",
"CPU");
namespace xe {
namespace cpu {
@ -71,7 +70,7 @@ X64Emitter::X64Emitter(X64Backend* backend, XbyakAllocator* allocator)
backend_(backend),
code_cache_(backend->code_cache()),
allocator_(allocator) {
if (FLAGS_enable_haswell_instructions) {
if (cvars::enable_haswell_instructions) {
feature_flags_ |= cpu_.has(Xbyak::util::Cpu::tAVX2) ? kX64EmitAVX2 : 0;
feature_flags_ |= cpu_.has(Xbyak::util::Cpu::tFMA) ? kX64EmitFMA : 0;
feature_flags_ |= cpu_.has(Xbyak::util::Cpu::tLZCNT) ? kX64EmitLZCNT : 0;
@ -245,7 +244,7 @@ bool X64Emitter::Emit(HIRBuilder* builder, size_t* out_stack_size) {
add(rsp, (uint32_t)stack_size);
ret();
if (FLAGS_emit_source_annotations) {
if (cvars::emit_source_annotations) {
nop();
nop();
nop();
@ -262,7 +261,7 @@ void X64Emitter::MarkSourceOffset(const Instr* i) {
entry->hir_offset = uint32_t(i->block->ordinal << 16) | i->ordinal;
entry->code_offset = static_cast<uint32_t>(getSize());
if (FLAGS_emit_source_annotations) {
if (cvars::emit_source_annotations) {
nop();
nop();
mov(eax, entry->guest_address);
@ -299,7 +298,7 @@ uint64_t TrapDebugPrint(void* raw_context, uint64_t address) {
// TODO(benvanik): truncate to length?
XELOGD("(DebugPrint) %s", str);
if (FLAGS_enable_debugprint_log) {
if (cvars::enable_debugprint_log) {
debugging::DebugPrint("(DebugPrint) %s", str);
}
@ -309,7 +308,7 @@ uint64_t TrapDebugPrint(void* raw_context, uint64_t address) {
uint64_t TrapDebugBreak(void* raw_context, uint64_t address) {
auto thread_state = *reinterpret_cast<ThreadState**>(raw_context);
XELOGE("tw/td forced trap hit! This should be a crash!");
if (FLAGS_break_on_debugbreak) {
if (cvars::break_on_debugbreak) {
xe::debugging::Break();
}
return 0;
@ -446,7 +445,7 @@ void X64Emitter::CallIndirect(const hir::Instr* instr,
uint64_t UndefinedCallExtern(void* raw_context, uint64_t function_ptr) {
auto function = reinterpret_cast<Function*>(function_ptr);
if (!FLAGS_ignore_undefined_externs) {
if (!cvars::ignore_undefined_externs) {
xe::FatalError("undefined extern call to %.8X %s", function->address(),
function->name().c_str());
} else {

View File

@ -9,8 +9,6 @@
#include "xenia/cpu/compiler/passes/conditional_group_pass.h"
#include <gflags/gflags.h>
#include "xenia/base/profiling.h"
#include "xenia/cpu/compiler/compiler.h"
#include "xenia/cpu/ppc/ppc_context.h"

View File

@ -9,15 +9,16 @@
#include "xenia/cpu/compiler/passes/constant_propagation_pass.h"
#include <gflags/gflags.h>
#include <cmath>
#include "xenia/base/assert.h"
#include "xenia/base/cvar.h"
#include "xenia/base/profiling.h"
#include "xenia/cpu/function.h"
#include "xenia/cpu/processor.h"
DEFINE_bool(inline_mmio_access, true, "Inline constant MMIO loads and stores.");
DEFINE_bool(inline_mmio_access, true, "Inline constant MMIO loads and stores.",
"CPU");
namespace xe {
namespace cpu {
@ -221,7 +222,7 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder, bool& result) {
auto mmio_range =
processor_->memory()->LookupVirtualMappedRange(address);
if (FLAGS_inline_mmio_access && mmio_range) {
if (cvars::inline_mmio_access && mmio_range) {
i->Replace(&OPCODE_LOAD_MMIO_info, 0);
i->src1.offset = reinterpret_cast<uint64_t>(mmio_range);
i->src2.offset = address;
@ -273,7 +274,7 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder, bool& result) {
break;
case OPCODE_STORE:
case OPCODE_STORE_OFFSET:
if (FLAGS_inline_mmio_access && i->src1.value->IsConstant()) {
if (cvars::inline_mmio_access && i->src1.value->IsConstant()) {
auto address = i->src1.value->constant.i32;
if (i->opcode->num == OPCODE_STORE_OFFSET) {
address += i->src2.value->constant.i32;

View File

@ -9,8 +9,8 @@
#include "xenia/cpu/compiler/passes/context_promotion_pass.h"
#include <gflags/gflags.h>
#include "xenia/apu/apu_flags.h"
#include "xenia/base/cvar.h"
#include "xenia/base/profiling.h"
#include "xenia/cpu/compiler/compiler.h"
#include "xenia/cpu/ppc/ppc_context.h"
@ -19,7 +19,7 @@
DECLARE_bool(debug);
DEFINE_bool(store_all_context_values, false,
"Don't strip dead context stores to aid in debugging.");
"Don't strip dead context stores to aid in debugging.", "CPU");
namespace xe {
namespace cpu {
@ -77,7 +77,7 @@ bool ContextPromotionPass::Run(HIRBuilder* builder) {
// Remove all dead stores.
// This will break debugging as we can't recover this information when
// trying to extract stack traces/register values, so we don't do that.
if (!FLAGS_debug && !FLAGS_store_all_context_values) {
if (!cvars::debug && !cvars::store_all_context_values) {
block = builder->first_block();
while (block) {
RemoveDeadStoresBlock(block);

View File

@ -9,38 +9,42 @@
#include "xenia/cpu/cpu_flags.h"
DEFINE_string(cpu, "any", "CPU backend [any, x64].");
DEFINE_string(cpu, "any", "CPU backend [any, x64].", "CPU");
DEFINE_string(
load_module_map, "",
"Loads a .map for symbol names and to diff with the generated symbol "
"database.");
"database.",
"CPU");
DEFINE_bool(disassemble_functions, false,
"Disassemble functions during generation.");
"Disassemble functions during generation.", "CPU");
DEFINE_bool(trace_functions, false,
"Generate tracing for function statistics.");
DEFINE_bool(trace_functions, false, "Generate tracing for function statistics.",
"CPU");
DEFINE_bool(trace_function_coverage, false,
"Generate tracing for function instruction coverage statistics.");
"Generate tracing for function instruction coverage statistics.",
"CPU");
DEFINE_bool(trace_function_references, false,
"Generate tracing for function address references.");
"Generate tracing for function address references.", "CPU");
DEFINE_bool(trace_function_data, false,
"Generate tracing for function result data.");
"Generate tracing for function result data.", "CPU");
DEFINE_bool(
disable_global_lock, false,
"Disables global lock usage in guest code. Does not affect host code.");
"Disables global lock usage in guest code. Does not affect host code.",
"CPU");
DEFINE_bool(validate_hir, false,
"Perform validation checks on the HIR during compilation.");
"Perform validation checks on the HIR during compilation.", "CPU");
// Breakpoints:
DEFINE_uint64(break_on_instruction, 0,
"int3 before the given guest address is executed.");
DEFINE_int32(break_condition_gpr, -1, "GPR compared to");
DEFINE_uint64(break_condition_value, 0, "value compared against");
DEFINE_string(break_condition_op, "eq", "comparison operator");
DEFINE_bool(break_condition_truncate, true, "truncate value to 32-bits");
"int3 before the given guest address is executed.", "CPU");
DEFINE_int32(break_condition_gpr, -1, "GPR compared to", "CPU");
DEFINE_uint64(break_condition_value, 0, "value compared against", "CPU");
DEFINE_string(break_condition_op, "eq", "comparison operator", "CPU");
DEFINE_bool(break_condition_truncate, true, "truncate value to 32-bits", "CPU");
DEFINE_bool(break_on_debugbreak, true, "int3 on JITed __debugbreak requests.");
DEFINE_bool(break_on_debugbreak, true, "int3 on JITed __debugbreak requests.",
"CPU");

View File

@ -9,8 +9,7 @@
#ifndef XENIA_CPU_CPU_FLAGS_H_
#define XENIA_CPU_CPU_FLAGS_H_
#include <gflags/gflags.h>
#include "xenia/base/cvar.h"
DECLARE_string(cpu);

View File

@ -728,12 +728,12 @@ int InstrEmit_mtmsr(PPCHIRBuilder& f, const InstrData& i) {
f.ZeroExtend(f.ZeroExtend(f.LoadGPR(i.X.RT), INT64_TYPE), INT64_TYPE));
if (i.X.RT == 13) {
// iff storing from r13 we are taking a lock (disable interrupts).
if (!FLAGS_disable_global_lock) {
if (!cvars::disable_global_lock) {
f.CallExtern(f.builtins()->enter_global_lock);
}
} else {
// Otherwise we are restoring interrupts (probably).
if (!FLAGS_disable_global_lock) {
if (!cvars::disable_global_lock) {
f.CallExtern(f.builtins()->leave_global_lock);
}
}
@ -753,12 +753,12 @@ int InstrEmit_mtmsrd(PPCHIRBuilder& f, const InstrData& i) {
f.ZeroExtend(f.LoadGPR(i.X.RT), INT64_TYPE));
if (i.X.RT == 13) {
// iff storing from r13 we are taking a lock (disable interrupts).
if (!FLAGS_disable_global_lock) {
if (!cvars::disable_global_lock) {
f.CallExtern(f.builtins()->enter_global_lock);
}
} else {
// Otherwise we are restoring interrupts (probably).
if (!FLAGS_disable_global_lock) {
if (!cvars::disable_global_lock) {
f.CallExtern(f.builtins()->leave_global_lock);
}
}

View File

@ -182,25 +182,25 @@ bool PPCHIRBuilder::Emit(GuestFunction* function, uint32_t flags) {
}
void PPCHIRBuilder::MaybeBreakOnInstruction(uint32_t address) {
if (address != FLAGS_break_on_instruction) {
if (address != cvars::break_on_instruction) {
return;
}
Comment("--break-on-instruction target");
if (FLAGS_break_condition_gpr < 0) {
if (cvars::break_condition_gpr < 0) {
DebugBreak();
return;
}
auto left = LoadGPR(FLAGS_break_condition_gpr);
auto right = LoadConstantUint64(FLAGS_break_condition_value);
if (FLAGS_break_condition_truncate) {
auto left = LoadGPR(cvars::break_condition_gpr);
auto right = LoadConstantUint64(cvars::break_condition_value);
if (cvars::break_condition_truncate) {
left = Truncate(left, INT32_TYPE);
right = Truncate(right, INT32_TYPE);
}
auto op = FLAGS_break_condition_op.c_str();
auto op = cvars::break_condition_op.c_str();
// TODO(rick): table?
if (strcasecmp(op, "eq") == 0) {
TrapTrue(CompareEQ(left, right));

View File

@ -9,8 +9,6 @@
#include "xenia/cpu/ppc/ppc_translator.h"
#include <gflags/gflags.h>
#include "xenia/base/assert.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/memory.h"
@ -41,7 +39,7 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
assembler_ = backend->CreateAssembler();
assembler_->Initialize();
bool validate = FLAGS_validate_hir;
bool validate = cvars::validate_hir;
// Merge blocks early. This will let us use more context in other passes.
// The CFG is required for simplification and dirtied by it.
@ -108,19 +106,19 @@ bool PPCTranslator::Translate(GuestFunction* function,
xe::make_reset_scope(&string_buffer_);
// NOTE: we only want to do this when required, as it's expensive to build.
if (FLAGS_disassemble_functions) {
if (cvars::disassemble_functions) {
debug_info_flags |= DebugInfoFlags::kDebugInfoAllDisasm;
}
if (FLAGS_trace_functions) {
if (cvars::trace_functions) {
debug_info_flags |= DebugInfoFlags::kDebugInfoTraceFunctions;
}
if (FLAGS_trace_function_coverage) {
if (cvars::trace_function_coverage) {
debug_info_flags |= DebugInfoFlags::kDebugInfoTraceFunctionCoverage;
}
if (FLAGS_trace_function_references) {
if (cvars::trace_function_references) {
debug_info_flags |= DebugInfoFlags::kDebugInfoTraceFunctionReferences;
}
if (FLAGS_trace_function_data) {
if (cvars::trace_function_data) {
debug_info_flags |= DebugInfoFlags::kDebugInfoTraceFunctionData;
}
std::unique_ptr<FunctionDebugInfo> debug_info;

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "xenia/base/filesystem.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
@ -26,9 +24,9 @@
#endif // XE_COMPILER_MSVC
DEFINE_string(test_path, "src/xenia/cpu/ppc/testing/",
"Directory scanned for test files.");
"Directory scanned for test files.", "Other");
DEFINE_string(test_bin_path, "src/xenia/cpu/ppc/testing/bin/",
"Directory with binary outputs of the test files.");
"Directory with binary outputs of the test files.", "Other");
namespace xe {
namespace cpu {
@ -54,8 +52,8 @@ class TestSuite {
name = src_file_path.substr(src_file_path.find_last_of(xe::kPathSeparator) +
1);
name = ReplaceExtension(name, L"");
map_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".map";
bin_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".bin";
map_file_path = xe::to_wstring(cvars::test_bin_path) + name + L".map";
bin_file_path = xe::to_wstring(cvars::test_bin_path) + name + L".bin";
}
bool Load() {
@ -192,11 +190,11 @@ class TestRunner {
std::unique_ptr<xe::cpu::backend::Backend> backend;
if (!backend) {
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
if (FLAGS_cpu == "x64") {
if (cvars::cpu == "x64") {
backend.reset(new xe::cpu::backend::x64::X64Backend());
}
#endif // XENIA_HAS_X64_BACKEND
if (FLAGS_cpu == "any") {
if (cvars::cpu == "any") {
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
if (!backend) {
backend.reset(new xe::cpu::backend::x64::X64Backend());
@ -408,7 +406,7 @@ bool RunTests(const std::wstring& test_name) {
int passed_count = 0;
auto test_path_root =
xe::fix_path_separators(xe::to_wstring(FLAGS_test_path));
xe::fix_path_separators(xe::to_wstring(cvars::test_path));
std::vector<std::wstring> test_files;
if (!DiscoverTests(test_path_root, test_files)) {
return false;

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "xenia/base/filesystem.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
@ -58,8 +56,8 @@ class TestSuite {
name = src_file_path.substr(src_file_path.find_last_of(xe::kPathSeparator) +
1);
name = ReplaceExtension(name, L"");
map_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".map";
bin_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".bin";
map_file_path = xe::to_wstring(cvars::test_bin_path) + name + L".map";
bin_file_path = xe::to_wstring(cvars::test_bin_path) + name + L".bin";
}
bool Load() {
@ -454,7 +452,7 @@ bool RunTests(const std::wstring& test_name) {
int passed_count = 0;
auto test_path_root =
xe::fix_path_separators(xe::to_wstring(FLAGS_test_path));
xe::fix_path_separators(xe::to_wstring(cvars::test_path));
std::vector<std::wstring> test_files;
if (!DiscoverTests(test_path_root, test_files)) {
return false;

View File

@ -9,12 +9,11 @@
#include "xenia/cpu/processor.h"
#include <gflags/gflags.h>
#include "xenia/base/assert.h"
#include "xenia/base/atomic.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/byte_stream.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/exception_handler.h"
#include "xenia/base/logging.h"
@ -42,9 +41,11 @@
#endif
DEFINE_bool(debug, DEFAULT_DEBUG_FLAG,
"Allow debugging and retain debug information.");
DEFINE_string(trace_function_data_path, "", "File to write trace data to.");
DEFINE_bool(break_on_start, false, "Break into the debugger on startup.");
"Allow debugging and retain debug information.", "General");
DEFINE_string(trace_function_data_path, "", "File to write trace data to.",
"CPU");
DEFINE_bool(break_on_start, false, "Break into the debugger on startup.",
"CPU");
namespace xe {
namespace kernel {
@ -132,14 +133,14 @@ bool Processor::Setup(std::unique_ptr<backend::Backend> backend) {
stack_walker_ = StackWalker::Create(backend_->code_cache());
if (!stack_walker_) {
// TODO(benvanik): disable features.
if (FLAGS_debug) {
if (cvars::debug) {
XELOGW("Disabling --debug due to lack of stack walker");
FLAGS_debug = false;
cvars::debug = false;
}
}
// Open the trace data path, if requested.
functions_trace_path_ = xe::to_wstring(FLAGS_trace_function_data_path);
functions_trace_path_ = xe::to_wstring(cvars::trace_function_data_path);
if (!functions_trace_path_.empty()) {
functions_trace_file_ = ChunkedMappedMemoryWriter::Open(
functions_trace_path_, 32 * 1024 * 1024, true);
@ -149,7 +150,7 @@ bool Processor::Setup(std::unique_ptr<backend::Backend> backend) {
}
void Processor::PreLaunch() {
if (FLAGS_break_on_start) {
if (cvars::break_on_start) {
// Start paused.
XELOGI("Breaking into debugger because of --break_on_start...");
execution_state_ = ExecutionState::kRunning;
@ -629,9 +630,9 @@ bool Processor::OnThreadBreakpointHit(Exception* ex) {
SuspendAllBreakpoints();
}
// Update all thread states with their latest values, using the context we got
// from the exception instead of a sampled value (as it would just show the
// exception handler).
// Update all thread states with their latest values, using the context we
// got from the exception instead of a sampled value (as it would just show
// the exception handler).
UpdateThreadExecutionStates(thread_info->thread_id, ex->thread_context());
// Walk the captured thread stack and look for breakpoints at any address in

View File

@ -10,13 +10,12 @@
#ifndef XENIA_CPU_PROCESSOR_H_
#define XENIA_CPU_PROCESSOR_H_
#include <gflags/gflags.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "xenia/base/cvar.h"
#include "xenia/base/mapped_memory.h"
#include "xenia/base/mutex.h"
#include "xenia/cpu/backend/backend.h"

View File

@ -9,8 +9,6 @@
#include "xenia/cpu/stack_walker.h"
#include <gflags/gflags.h>
#include <mutex>
#include "xenia/base/logging.h"
@ -20,7 +18,7 @@
#include "xenia/cpu/processor.h"
DEFINE_bool(debug_symbol_loader, false,
"Enable dbghelp debug logging and validation.");
"Enable dbghelp debug logging and validation.", "CPU");
// Must be included after platform_win.h:
#pragma warning(push)
@ -98,7 +96,7 @@ bool InitializeStackWalker() {
// Initialize the symbol lookup services.
DWORD options = sym_get_options_();
if (FLAGS_debug_symbol_loader) {
if (cvars::debug_symbol_loader) {
options |= SYMOPT_DEBUG;
}
options |= SYMOPT_DEFERRED_LOADS;

View File

@ -14,8 +14,6 @@
#include "xenia/cpu/ppc/ppc_frontend.h"
#include "xenia/cpu/raw_module.h"
#include <gflags/gflags.h>
namespace xe {
namespace cpu {
namespace sandbox {

View File

@ -1008,8 +1008,8 @@ bool XexModule::LoadContinue() {
}
// Load a specified module map and diff.
if (FLAGS_load_module_map.size()) {
if (!ReadMap(FLAGS_load_module_map.c_str())) {
if (cvars::load_module_map.size()) {
if (!ReadMap(cvars::load_module_map.c_str())) {
return false;
}
}

View File

@ -9,8 +9,6 @@
#include "xenia/debug/ui/debug_window.h"
#include <gflags/gflags.h>
#include <algorithm>
#include <cinttypes>
#include <utility>
@ -35,7 +33,7 @@
#include "xenia/ui/graphics_provider.h"
#include "xenia/ui/imgui_drawer.h"
DEFINE_bool(imgui_debug, false, "Show ImGui debugging tools.");
DEFINE_bool(imgui_debug, false, "Show ImGui debugging tools.", "Other");
namespace xe {
namespace debug {
@ -238,7 +236,7 @@ void DebugWindow::DrawFrame() {
ImGui::End();
ImGui::PopStyleVar();
if (FLAGS_imgui_debug) {
if (cvars::imgui_debug) {
ImGui::ShowTestWindow();
ImGui::ShowMetricsWindow();
}

View File

@ -9,13 +9,14 @@
#include "xenia/emulator.h"
#include <gflags/gflags.h>
#include <cinttypes>
#include "config.h"
#include "xenia/apu/audio_system.h"
#include "xenia/base/assert.h"
#include "xenia/base/byte_stream.h"
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/debugging.h"
#include "xenia/base/exception_handler.h"
#include "xenia/base/logging.h"
@ -44,7 +45,8 @@
#include "xenia/vfs/virtual_file_system.h"
DEFINE_double(time_scalar, 1.0,
"Scalar used to speed or slow time (1x, 2x, 1/2x, etc).");
"Scalar used to speed or slow time (1x, 2x, 1/2x, etc).",
"General");
namespace xe {
@ -112,7 +114,7 @@ X_STATUS Emulator::Setup(
// We could reset this with save state data/constant value to help replays.
Clock::set_guest_system_time_base(Clock::QueryHostSystemTime());
// This can be adjusted dynamically, as well.
Clock::set_guest_time_scalar(FLAGS_time_scalar);
Clock::set_guest_time_scalar(cvars::time_scalar);
// Before we can set thread affinity we must enable the process to use all
// logical processors.
@ -130,11 +132,11 @@ X_STATUS Emulator::Setup(
std::unique_ptr<xe::cpu::backend::Backend> backend;
if (!backend) {
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
if (FLAGS_cpu == "x64") {
if (cvars::cpu == "x64") {
backend.reset(new xe::cpu::backend::x64::X64Backend());
}
#endif // XENIA_HAS_X64_BACKEND
if (FLAGS_cpu == "any") {
if (cvars::cpu == "any") {
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
if (!backend) {
backend.reset(new xe::cpu::backend::x64::X64Backend());

View File

@ -393,7 +393,7 @@ void CommandProcessor::IssueSwap(uint32_t frontbuffer_ptr,
// This prevents the display from pulling the backbuffer out from under us.
// If we skip a lot then we may need to buffer more, but as the display
// thread should be fairly idle that shouldn't happen.
if (!FLAGS_vsync) {
if (!cvars::vsync) {
std::lock_guard<std::mutex> lock(swap_state_.mutex);
if (swap_state_.pending) {
swap_state_.pending = false;
@ -895,7 +895,7 @@ bool CommandProcessor::ExecutePacketType3_WAIT_REG_MEM(RingBuffer* reader,
// Wait.
if (wait >= 0x100) {
PrepareForWait();
if (!FLAGS_vsync) {
if (!cvars::vsync) {
// User wants it fast and dangerous.
xe::threading::MaybeYield();
} else {

View File

@ -10,10 +10,10 @@
#include "xenia/gpu/gpu_flags.h"
DEFINE_string(trace_gpu_prefix, "scratch/gpu/",
"Prefix path for GPU trace files.");
DEFINE_bool(trace_gpu_stream, false, "Trace all GPU packets.");
"Prefix path for GPU trace files.", "GPU");
DEFINE_bool(trace_gpu_stream, false, "Trace all GPU packets.", "GPU");
DEFINE_string(dump_shaders, "",
"Path to write GPU shaders to as they are compiled.");
"Path to write GPU shaders to as they are compiled.", "GPU");
DEFINE_bool(vsync, true, "Enable VSYNC.");
DEFINE_bool(vsync, true, "Enable VSYNC.", "GPU");

View File

@ -9,8 +9,7 @@
#ifndef XENIA_GPU_GPU_FLAGS_H_
#define XENIA_GPU_GPU_FLAGS_H_
#include <gflags/gflags.h>
#include "xenia/base/cvar.h"
DECLARE_string(trace_gpu_prefix);
DECLARE_bool(trace_gpu_stream);

View File

@ -113,7 +113,7 @@ X_STATUS GraphicsSystem::Setup(cpu::Processor* processor,
vsync_worker_running_ = true;
vsync_worker_thread_ = kernel::object_ref<kernel::XHostThread>(
new kernel::XHostThread(kernel_state_, 128 * 1024, 0, [this]() {
uint64_t vsync_duration = FLAGS_vsync ? 16 : 1;
uint64_t vsync_duration = cvars::vsync ? 16 : 1;
uint64_t last_frame_time = Clock::QueryGuestTickCount();
while (vsync_worker_running_) {
uint64_t current_time = Clock::QueryGuestTickCount();
@ -132,7 +132,7 @@ X_STATUS GraphicsSystem::Setup(cpu::Processor* processor,
vsync_worker_thread_->set_name("GraphicsSystem Vsync");
vsync_worker_thread_->Create();
if (FLAGS_trace_gpu_stream) {
if (cvars::trace_gpu_stream) {
BeginTracing();
}
@ -270,11 +270,12 @@ void GraphicsSystem::ClearCaches() {
}
void GraphicsSystem::RequestFrameTrace() {
command_processor_->RequestFrameTrace(xe::to_wstring(FLAGS_trace_gpu_prefix));
command_processor_->RequestFrameTrace(
xe::to_wstring(cvars::trace_gpu_prefix));
}
void GraphicsSystem::BeginTracing() {
command_processor_->BeginTracing(xe::to_wstring(FLAGS_trace_gpu_prefix));
command_processor_->BeginTracing(xe::to_wstring(cvars::trace_gpu_prefix));
}
void GraphicsSystem::EndTracing() { command_processor_->EndTracing(); }

View File

@ -7,13 +7,12 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include <cinttypes>
#include <cstring>
#include <string>
#include <vector>
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
#include "xenia/base/string.h"
@ -22,35 +21,36 @@
#include "xenia/gpu/spirv_shader_translator.h"
#include "xenia/ui/spirv/spirv_disassembler.h"
DEFINE_string(shader_input, "", "Input shader binary file path.");
DEFINE_string(shader_input, "", "Input shader binary file path.", "GPU");
DEFINE_string(shader_input_type, "",
"'vs', 'ps', or unspecified to infer from the given filename.");
DEFINE_string(shader_output, "", "Output shader file path.");
"'vs', 'ps', or unspecified to infer from the given filename.",
"GPU");
DEFINE_string(shader_output, "", "Output shader file path.", "GPU");
DEFINE_string(shader_output_type, "ucode",
"Translator to use: [ucode, glsl45, spirv, spirvtext].");
"Translator to use: [ucode, glsl45, spirv, spirvtext].", "GPU");
namespace xe {
namespace gpu {
int shader_compiler_main(const std::vector<std::wstring>& args) {
ShaderType shader_type;
if (!FLAGS_shader_input_type.empty()) {
if (FLAGS_shader_input_type == "vs") {
if (!cvars::shader_input_type.empty()) {
if (cvars::shader_input_type == "vs") {
shader_type = ShaderType::kVertex;
} else if (FLAGS_shader_input_type == "ps") {
} else if (cvars::shader_input_type == "ps") {
shader_type = ShaderType::kPixel;
} else {
XELOGE("Invalid --shader_input_type; must be 'vs' or 'ps'.");
return 1;
}
} else {
auto last_dot = FLAGS_shader_input.find_last_of('.');
auto last_dot = cvars::shader_input.find_last_of('.');
bool valid_type = false;
if (last_dot != std::string::npos) {
if (FLAGS_shader_input.substr(last_dot) == ".vs") {
if (cvars::shader_input.substr(last_dot) == ".vs") {
shader_type = ShaderType::kVertex;
valid_type = true;
} else if (FLAGS_shader_input.substr(last_dot) == ".ps") {
} else if (cvars::shader_input.substr(last_dot) == ".ps") {
shader_type = ShaderType::kPixel;
valid_type = true;
}
@ -63,9 +63,9 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
}
}
auto input_file = fopen(FLAGS_shader_input.c_str(), "rb");
auto input_file = fopen(cvars::shader_input.c_str(), "rb");
if (!input_file) {
XELOGE("Unable to open input file: %s", FLAGS_shader_input.c_str());
XELOGE("Unable to open input file: %s", cvars::shader_input.c_str());
return 1;
}
fseek(input_file, 0, SEEK_END);
@ -76,7 +76,7 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
fclose(input_file);
XELOGI("Opened %s as a %s shader, %" PRId64 " words (%" PRId64 " bytes).",
FLAGS_shader_input.c_str(),
cvars::shader_input.c_str(),
shader_type == ShaderType::kVertex ? "vertex" : "pixel",
ucode_dwords.size(), ucode_dwords.size() * 4);
@ -86,10 +86,10 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
shader_type, ucode_data_hash, ucode_dwords.data(), ucode_dwords.size());
std::unique_ptr<ShaderTranslator> translator;
if (FLAGS_shader_output_type == "spirv" ||
FLAGS_shader_output_type == "spirvtext") {
if (cvars::shader_output_type == "spirv" ||
cvars::shader_output_type == "spirvtext") {
translator = std::make_unique<SpirvShaderTranslator>();
} else if (FLAGS_shader_output_type == "glsl45") {
} else if (cvars::shader_output_type == "glsl45") {
translator = std::make_unique<GlslShaderTranslator>(
GlslShaderTranslator::Dialect::kGL45);
} else {
@ -102,7 +102,7 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
size_t source_data_size = shader->translated_binary().size();
std::unique_ptr<xe::ui::spirv::SpirvDisassembler::Result> spirv_disasm_result;
if (FLAGS_shader_output_type == "spirvtext") {
if (cvars::shader_output_type == "spirvtext") {
// Disassemble SPIRV.
spirv_disasm_result = xe::ui::spirv::SpirvDisassembler().Disassemble(
reinterpret_cast<const uint32_t*>(source_data), source_data_size / 4);
@ -110,8 +110,8 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
source_data_size = std::strlen(spirv_disasm_result->text()) + 1;
}
if (!FLAGS_shader_output.empty()) {
auto output_file = fopen(FLAGS_shader_output.c_str(), "wb");
if (!cvars::shader_output.empty()) {
auto output_file = fopen(cvars::shader_output.c_str(), "wb");
fwrite(source_data, 1, source_data_size, output_file);
fclose(output_file);
}

View File

@ -9,19 +9,20 @@
#include "xenia/gpu/spirv_shader_translator.h"
#include <gflags/gflags.h>
#include <algorithm>
#include <cfloat>
#include <cstddef>
#include <cstring>
#include <vector>
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
DEFINE_bool(spv_validate, false, "Validate SPIR-V shaders after generation");
DEFINE_bool(spv_disasm, false, "Disassemble SPIR-V shaders after generation");
DEFINE_bool(spv_validate, false, "Validate SPIR-V shaders after generation",
"GPU");
DEFINE_bool(spv_disasm, false, "Disassemble SPIR-V shaders after generation",
"GPU");
namespace xe {
namespace gpu {
@ -667,7 +668,7 @@ std::vector<uint8_t> SpirvShaderTranslator::CompleteTranslation() {
void SpirvShaderTranslator::PostTranslation(Shader* shader) {
// Validation.
if (FLAGS_spv_validate) {
if (cvars::spv_validate) {
auto validation = validator_.Validate(
reinterpret_cast<const uint32_t*>(shader->translated_binary().data()),
shader->translated_binary().size() / sizeof(uint32_t));
@ -677,7 +678,7 @@ void SpirvShaderTranslator::PostTranslation(Shader* shader) {
}
}
if (FLAGS_spv_disasm) {
if (cvars::spv_disasm) {
// TODO(benvanik): only if needed? could be slowish.
auto disasm = disassembler_.Disassemble(
reinterpret_cast<const uint32_t*>(shader->translated_binary().data()),

View File

@ -7,13 +7,12 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/gpu/texture_info.h"
DEFINE_bool(texture_dump, false, "Dump textures to DDS");
DEFINE_bool(texture_dump, false, "Dump textures to DDS", "GPU");
namespace xe {
namespace gpu {

View File

@ -9,8 +9,6 @@
#include "xenia/gpu/trace_dump.h"
#include <gflags/gflags.h>
#include "third_party/stb/stb_image_write.h"
#include "xenia/base/logging.h"
#include "xenia/base/profiling.h"
@ -28,8 +26,9 @@
#undef _CRT_NONSTDC_NO_DEPRECATE
#include "third_party/stb/stb_image_write.h"
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
DEFINE_string(trace_dump_path, "", "Output path for dumped files.");
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.",
"GPU");
DEFINE_string(trace_dump_path, "", "Output path for dumped files.", "GPU");
namespace xe {
namespace gpu {
@ -44,11 +43,11 @@ int TraceDump::Main(const std::vector<std::wstring>& args) {
// Grab path from the flag or unnamed argument.
std::wstring path;
std::wstring output_path;
if (!FLAGS_target_trace_file.empty()) {
if (!cvars::target_trace_file.empty()) {
// Passed as a named argument.
// TODO(benvanik): find something better than gflags that supports
// unicode.
path = xe::to_wstring(FLAGS_target_trace_file);
path = xe::to_wstring(cvars::target_trace_file);
} else if (args.size() >= 2) {
// Passed as an unnamed argument.
path = args[1];
@ -79,7 +78,7 @@ int TraceDump::Main(const std::vector<std::wstring>& args) {
// Root file name for outputs.
if (output_path.empty()) {
base_output_path_ =
xe::fix_path_separators(xe::to_wstring(FLAGS_trace_dump_path));
xe::fix_path_separators(xe::to_wstring(cvars::trace_dump_path));
std::wstring output_name =
xe::find_name_from_path(xe::fix_path_separators(path));

View File

@ -9,8 +9,6 @@
#include "xenia/gpu/trace_viewer.h"
#include <gflags/gflags.h>
#include <cinttypes>
#include "third_party/half/include/half.hpp"
@ -32,7 +30,8 @@
#include "xenia/ui/window.h"
#include "xenia/xbox.h"
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.",
"GPU");
namespace xe {
namespace gpu {
@ -53,11 +52,11 @@ TraceViewer::~TraceViewer() = default;
int TraceViewer::Main(const std::vector<std::wstring>& args) {
// Grab path from the flag or unnamed argument.
std::wstring path;
if (!FLAGS_target_trace_file.empty()) {
if (!cvars::target_trace_file.empty()) {
// Passed as a named argument.
// TODO(benvanik): find something better than gflags that supports
// unicode.
path = xe::to_wstring(FLAGS_target_trace_file);
path = xe::to_wstring(cvars::target_trace_file);
} else if (args.size() >= 2) {
// Passed as an unnamed argument.
path = args[1];

View File

@ -347,7 +347,7 @@ VkPipeline PipelineCache::GetPipeline(const RenderState* render_state,
}
// Dump shader disassembly.
if (FLAGS_vulkan_dump_disasm) {
if (cvars::vulkan_dump_disasm) {
if (device_->HasEnabledExtension(VK_AMD_SHADER_INFO_EXTENSION_NAME)) {
DumpShaderDisasmAMD(pipeline);
} else if (device_->device_info().properties.vendorID == 0x10DE) {
@ -387,8 +387,8 @@ bool PipelineCache::TranslateShader(VulkanShader* shader,
}
// Dump shader files if desired.
if (!FLAGS_dump_shaders.empty()) {
shader->Dump(FLAGS_dump_shaders, "vk");
if (!cvars::dump_shaders.empty()) {
shader->Dump(cvars::dump_shaders, "vk");
}
return shader->is_valid();
@ -1398,7 +1398,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateMultisampleState() {
// PA_SU_SC_MODE_CNTL MSAA_ENABLE (0x10000)
// If set, all samples will be sampled at set locations. Otherwise, they're
// all sampled from the pixel center.
if (FLAGS_vulkan_native_msaa) {
if (cvars::vulkan_native_msaa) {
auto msaa_num_samples =
static_cast<MsaaSamples>((regs.rb_surface_info >> 16) & 0x3);
switch (msaa_num_samples) {

View File

@ -194,7 +194,7 @@ VkResult CachedTileView::Initialize(VkCommandBuffer command_buffer) {
image_info.extent.depth = 1;
image_info.mipLevels = 1;
image_info.arrayLayers = 1;
if (FLAGS_vulkan_native_msaa) {
if (cvars::vulkan_native_msaa) {
auto msaa_samples = static_cast<MsaaSamples>(key.msaa_samples);
switch (msaa_samples) {
case MsaaSamples::k1X:
@ -422,7 +422,7 @@ CachedRenderPass::~CachedRenderPass() {
VkResult CachedRenderPass::Initialize() {
VkSampleCountFlagBits sample_count;
if (FLAGS_vulkan_native_msaa) {
if (cvars::vulkan_native_msaa) {
switch (config.surface_msaa) {
case MsaaSamples::k1X:
sample_count = VK_SAMPLE_COUNT_1_BIT;
@ -534,7 +534,7 @@ VkResult CachedRenderPass::Initialize() {
bool CachedRenderPass::IsCompatible(
const RenderConfiguration& desired_config) const {
if (config.surface_msaa != desired_config.surface_msaa &&
FLAGS_vulkan_native_msaa) {
cvars::vulkan_native_msaa) {
return false;
}

View File

@ -1040,7 +1040,7 @@ bool TextureCache::UploadTexture(VkCommandBuffer command_buffer,
unpack_offset += ComputeMipStorage(src, mip);
}
if (FLAGS_texture_dump) {
if (cvars::texture_dump) {
TextureDump(src, unpack_buffer, unpack_length);
}

View File

@ -356,7 +356,7 @@ void VulkanCommandProcessor::BeginFrame() {
// The capture will end when these commands are submitted to the queue.
static uint32_t frame = 0;
if (device_->is_renderdoc_attached() && !capturing_ &&
(FLAGS_vulkan_renderdoc_capture_all || trace_requested_)) {
(cvars::vulkan_renderdoc_capture_all || trace_requested_)) {
if (queue_mutex_) {
queue_mutex_->lock();
}

View File

@ -10,7 +10,7 @@
#include "xenia/gpu/vulkan/vulkan_gpu_flags.h"
DEFINE_bool(vulkan_renderdoc_capture_all, false,
"Capture everything with RenderDoc.");
DEFINE_bool(vulkan_native_msaa, false, "Use native MSAA");
"Capture everything with RenderDoc.", "Vulkan");
DEFINE_bool(vulkan_native_msaa, false, "Use native MSAA", "Vulkan");
DEFINE_bool(vulkan_dump_disasm, false,
"Dump shader disassembly. NVIDIA only supported.");
"Dump shader disassembly. NVIDIA only supported.", "Vulkan");

View File

@ -10,9 +10,8 @@
#ifndef XENIA_GPU_VULKAN_VULKAN_GPU_FLAGS_H_
#define XENIA_GPU_VULKAN_VULKAN_GPU_FLAGS_H_
#include <gflags/gflags.h>
#define FINE_GRAINED_DRAW_SCOPES 1
#include "xenia/base/cvar.h"
DECLARE_bool(vulkan_renderdoc_capture_all);
DECLARE_bool(vulkan_native_msaa);

View File

@ -7,12 +7,11 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include <cstring>
#include "third_party/imgui/imgui.h"
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/main.h"
#include "xenia/base/threading.h"
@ -28,7 +27,8 @@
#include "xenia/hid/xinput/xinput_hid.h"
#endif // XE_PLATFORM_WIN32
DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]");
DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]",
"General");
namespace xe {
namespace hid {
@ -38,12 +38,12 @@ std::unique_ptr<xe::hid::InputSystem> input_system_;
std::vector<std::unique_ptr<hid::InputDriver>> CreateInputDrivers(
ui::Window* window) {
std::vector<std::unique_ptr<hid::InputDriver>> drivers;
if (FLAGS_hid.compare("nop") == 0) {
if (cvars::hid.compare("nop") == 0) {
drivers.emplace_back(xe::hid::nop::Create(window));
#if XE_PLATFORM_WIN32
} else if (FLAGS_hid.compare("winkey") == 0) {
} else if (cvars::hid.compare("winkey") == 0) {
drivers.emplace_back(xe::hid::winkey::Create(window));
} else if (FLAGS_hid.compare("xinput") == 0) {
} else if (cvars::hid.compare("xinput") == 0) {
drivers.emplace_back(xe::hid::xinput::Create(window));
#endif // XE_PLATFORM_WIN32
} else {

View File

@ -10,6 +10,4 @@
#ifndef XENIA_HID_HID_FLAGS_H_
#define XENIA_HID_HID_FLAGS_H_
#include <gflags/gflags.h>
#endif // XENIA_HID_HID_FLAGS_H_

View File

@ -0,0 +1,16 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/kernel/kernel_flags.h"
DEFINE_bool(headless, false,
"Don't display any UI, using defaults for prompts as needed.",
"Other");
DEFINE_bool(log_high_frequency_kernel_calls, false,
"Log kernel calls with the kHighFrequency tag.", "Kernel");

View File

@ -0,0 +1,17 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_KERNEL_KERNEL_FLAGS_H_
#define XENIA_KERNEL_KERNEL_FLAGS_H_
#include "xenia/base/cvar.h"
DECLARE_bool(headless);
DECLARE_bool(log_high_frequency_kernel_calls);
#endif // XENIA_KERNEL_KERNEL_FLAGS_H_

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/kernel_state.h"
#include <gflags/gflags.h>
#include <string>
#include "xenia/base/assert.h"
@ -29,9 +27,6 @@
#include "xenia/kernel/xobject.h"
#include "xenia/kernel/xthread.h"
DEFINE_bool(headless, false,
"Don't display any UI, using defaults for prompts as needed.");
namespace xe {
namespace kernel {

View File

@ -10,8 +10,6 @@
#ifndef XENIA_KERNEL_KERNEL_STATE_H_
#define XENIA_KERNEL_KERNEL_STATE_H_
#include <gflags/gflags.h>
#include <atomic>
#include <condition_variable>
#include <functional>
@ -20,6 +18,7 @@
#include <vector>
#include "xenia/base/bit_map.h"
#include "xenia/base/cvar.h"
#include "xenia/base/mutex.h"
#include "xenia/cpu/export_resolver.h"
#include "xenia/kernel/util/native_list.h"
@ -39,8 +38,6 @@ class Processor;
} // namespace cpu
} // namespace xe
DECLARE_bool(headless);
namespace xe {
namespace kernel {

View File

@ -20,7 +20,7 @@
#include "xenia/kernel/xfile.h"
#include "xenia/kernel/xthread.h"
DEFINE_bool(xex_apply_patches, true, "Apply XEX patches.");
DEFINE_bool(xex_apply_patches, true, "Apply XEX patches.", "Kernel");
namespace xe {
namespace kernel {
@ -102,7 +102,7 @@ X_STATUS UserModule::LoadFromFile(std::string path) {
return result;
}
if (FLAGS_xex_apply_patches) {
if (cvars::xex_apply_patches) {
// Search for xexp patch file
auto patch_entry = kernel_state()->file_system()->ResolvePath(path_ + "p");

View File

@ -9,9 +9,6 @@
#include "xenia/kernel/util/shim_utils.h"
DEFINE_bool(log_high_frequency_kernel_calls, false,
"Log kernel calls with the kHighFrequency tag.");
namespace xe {
namespace kernel {
namespace shim {

View File

@ -10,8 +10,6 @@
#ifndef XENIA_KERNEL_UTIL_SHIM_UTILS_H_
#define XENIA_KERNEL_UTIL_SHIM_UTILS_H_
#include <gflags/gflags.h>
#include <cstring>
#include <string>
@ -21,10 +19,9 @@
#include "xenia/base/string_buffer.h"
#include "xenia/cpu/export_resolver.h"
#include "xenia/cpu/ppc/ppc_context.h"
#include "xenia/kernel/kernel_flags.h"
#include "xenia/kernel/kernel_state.h"
DECLARE_bool(log_high_frequency_kernel_calls);
namespace xe {
namespace kernel {
@ -482,7 +479,7 @@ xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), const char* name,
auto params = std::make_tuple<Ps...>(Ps(init)...);
if (export_entry->tags & xe::cpu::ExportTag::kLog &&
(!(export_entry->tags & xe::cpu::ExportTag::kHighFrequency) ||
FLAGS_log_high_frequency_kernel_calls)) {
cvars::log_high_frequency_kernel_calls)) {
PrintKernelCall(export_entry, params);
}
auto result =
@ -516,7 +513,7 @@ xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), const char* name,
auto params = std::make_tuple<Ps...>(Ps(init)...);
if (export_entry->tags & xe::cpu::ExportTag::kLog &&
(!(export_entry->tags & xe::cpu::ExportTag::kHighFrequency) ||
FLAGS_log_high_frequency_kernel_calls)) {
cvars::log_high_frequency_kernel_calls)) {
PrintKernelCall(export_entry, params);
}
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),

View File

@ -9,6 +9,7 @@
#include "xenia/base/logging.h"
#include "xenia/emulator.h"
#include "xenia/kernel/kernel_flags.h"
#include "xenia/kernel/kernel_state.h"
#include "xenia/kernel/util/shim_utils.h"
#include "xenia/kernel/xam/xam_private.h"
@ -43,7 +44,7 @@ dword_result_t XamShowNuiTroubleshooterUI(unknown_t unk1, unknown_t unk2,
// unk1 is 0xFF - possibly user index?
// unk2, unk3 appear to always be zero.
if (FLAGS_headless) {
if (cvars::headless) {
return 0;
}

View File

@ -10,6 +10,7 @@
#include "third_party/imgui/imgui.h"
#include "xenia/base/logging.h"
#include "xenia/emulator.h"
#include "xenia/kernel/kernel_flags.h"
#include "xenia/kernel/kernel_state.h"
#include "xenia/kernel/util/shim_utils.h"
#include "xenia/kernel/xam/xam_private.h"
@ -111,7 +112,7 @@ dword_result_t XamShowMessageBoxUI(dword_t user_index, lpwstring_t title_ptr,
}
uint32_t chosen_button;
if (FLAGS_headless) {
if (cvars::headless) {
// Auto-pick the focused button.
chosen_button = active_button;
} else {
@ -231,7 +232,7 @@ dword_result_t XamShowKeyboardUI(dword_t user_index, dword_t flags,
return X_ERROR_INVALID_PARAMETER;
}
if (FLAGS_headless) {
if (cvars::headless) {
// Redirect default_text back into the buffer.
std::memset(buffer, 0, buffer_length * 2);
if (default_text) {
@ -309,7 +310,7 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
DECLARE_XAM_EXPORT1(XamShowDeviceSelectorUI, kUI, kImplemented);
void XamShowDirtyDiscErrorUI(dword_t user_index) {
if (FLAGS_headless) {
if (cvars::headless) {
assert_always();
exit(1);
return;

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/xboxkrnl/xboxkrnl_module.h"
#include <gflags/gflags.h>
#include <vector>
#include "xenia/base/clock.h"

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/xboxkrnl/xboxkrnl_module.h"
#include <gflags/gflags.h>
#include <vector>
#include "xenia/base/clock.h"
@ -47,7 +45,7 @@ void KeDebugMonitorCallback(cpu::ppc::PPCContext* ppc_context,
XELOGI("KeDebugMonitorCallback(%u, %08x)", static_cast<uint32_t>(id), arg);
if (!FLAGS_kernel_pix) {
if (!cvars::kernel_pix) {
SHIM_SET_RETURN_32(-1);
return;
}

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/xboxkrnl/xboxkrnl_module.h"
#include <gflags/gflags.h>
#include <vector>
#include "xenia/base/clock.h"
@ -27,18 +25,19 @@
#include "xenia/kernel/xboxkrnl/xboxkrnl_private.h"
#include "xenia/kernel/xthread.h"
DEFINE_string(cl, "", "Specify additional command-line provided to guest.");
DEFINE_string(cl, "", "Specify additional command-line provided to guest.",
"Kernel");
DEFINE_bool(kernel_debug_monitor, false, "Enable debug monitor.");
DEFINE_bool(kernel_cert_monitor, false, "Enable cert monitor.");
DEFINE_bool(kernel_pix, false, "Enable PIX.");
DEFINE_bool(kernel_debug_monitor, false, "Enable debug monitor.", "Kernel");
DEFINE_bool(kernel_cert_monitor, false, "Enable cert monitor.", "Kernel");
DEFINE_bool(kernel_pix, false, "Enable PIX.", "Kernel");
namespace xe {
namespace kernel {
namespace xboxkrnl {
bool XboxkrnlModule::SendPIXCommand(const char* cmd) {
if (!FLAGS_kernel_pix) {
if (!cvars::kernel_pix) {
return false;
}
@ -103,7 +102,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
// Offset 0x18 is a 4b pointer to a handler function that seems to take two
// arguments. If we wanted to see what would happen we could fake that.
uint32_t pKeDebugMonitorData;
if (!FLAGS_kernel_debug_monitor) {
if (!cvars::kernel_debug_monitor) {
pKeDebugMonitorData = memory_->SystemHeapAlloc(4);
auto lpKeDebugMonitorData = memory_->TranslateVirtual(pKeDebugMonitorData);
xe::store_and_swap<uint32_t>(lpKeDebugMonitorData, 0);
@ -125,7 +124,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
// KeCertMonitorData (?*)
// Always set to zero, ignored.
uint32_t pKeCertMonitorData;
if (!FLAGS_kernel_cert_monitor) {
if (!cvars::kernel_cert_monitor) {
pKeCertMonitorData = memory_->SystemHeapAlloc(4);
auto lpKeCertMonitorData = memory_->TranslateVirtual(pKeCertMonitorData);
xe::store_and_swap<uint32_t>(lpKeCertMonitorData, 0);
@ -187,8 +186,8 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
// Always set to "default.xex" (with quotes) for now.
// TODO(gibbed): set this to the actual module name.
std::string command_line("\"default.xex\"");
if (FLAGS_cl.length()) {
command_line += " " + FLAGS_cl;
if (cvars::cl.length()) {
command_line += " " + cvars::cl;
}
uint32_t command_line_length =
xe::align(static_cast<uint32_t>(command_line.length()) + 1, 1024u);

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/xboxkrnl/xboxkrnl_video.h"
#include <gflags/gflags.h>
#include "xenia/base/logging.h"
#include "xenia/emulator.h"
#include "xenia/gpu/graphics_system.h"
@ -24,9 +22,11 @@
DEFINE_int32(kernel_display_gamma_type, 1,
"Display gamma type: 0 - linear, 1 - sRGB, 2 - TV (BT.709), "
"3 - power specified via kernel_display_gamma_power.");
"3 - power specified via kernel_display_gamma_power.",
"Kernel");
DEFINE_double(kernel_display_gamma_power, 2.22222233,
"Display gamma to use with kernel_display_gamma_type 3.");
"Display gamma to use with kernel_display_gamma_type 3.",
"Kernel");
namespace xe {
namespace kernel {
@ -51,8 +51,8 @@ void VdGetCurrentDisplayGamma(lpdword_t type_ptr, lpfloat_t power_ptr) {
// 3 - use the power written to *power_ptr.
// Anything else - linear.
// Used in D3D SetGammaRamp/SetPWLGamma to adjust the ramp for the display.
*type_ptr = uint32_t(FLAGS_kernel_display_gamma_type);
*power_ptr = float(FLAGS_kernel_display_gamma_power);
*type_ptr = uint32_t(cvars::kernel_display_gamma_type);
*power_ptr = float(cvars::kernel_display_gamma_power);
}
DECLARE_XBOXKRNL_EXPORT1(VdGetCurrentDisplayGamma, kVideo, kStub);

View File

@ -9,8 +9,6 @@
#include "xenia/kernel/xthread.h"
#include <gflags/gflags.h>
#include <cstring>
#ifdef XE_PLATFORM_WIN32
@ -33,9 +31,9 @@
#include "xenia/kernel/xmutant.h"
DEFINE_bool(ignore_thread_priorities, true,
"Ignores game-specified thread priorities.");
"Ignores game-specified thread priorities.", "Kernel");
DEFINE_bool(ignore_thread_affinities, true,
"Ignores game-specified thread affinities.");
"Ignores game-specified thread affinities.", "Kernel");
namespace xe {
namespace kernel {
@ -416,7 +414,7 @@ X_STATUS XThread::Create() {
return X_STATUS_NO_MEMORY;
}
if (!FLAGS_ignore_thread_affinities) {
if (!cvars::ignore_thread_affinities) {
thread_->set_affinity_mask(proc_mask);
}
@ -698,7 +696,7 @@ void XThread::SetPriority(int32_t increment) {
} else {
target_priority = xe::threading::ThreadPriority::kNormal;
}
if (!FLAGS_ignore_thread_priorities) {
if (!cvars::ignore_thread_priorities) {
thread_->set_priority(target_priority);
}
}
@ -719,7 +717,7 @@ void XThread::SetAffinity(uint32_t affinity) {
}
SetActiveCpu(GetFakeCpuNumber(affinity));
affinity_ = affinity;
if (!FLAGS_ignore_thread_affinities) {
if (!cvars::ignore_thread_affinities) {
thread_->set_affinity_mask(affinity);
}
}

View File

@ -9,13 +9,12 @@
#include "xenia/memory.h"
#include <gflags/gflags.h>
#include <algorithm>
#include <cstring>
#include "xenia/base/byte_stream.h"
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/base/threading.h"
@ -24,15 +23,14 @@
// TODO(benvanik): move xbox.h out
#include "xenia/xbox.h"
DEFINE_bool(protect_zero, true, "Protect the zero page from reads and writes.");
DEFINE_bool(protect_zero, true, "Protect the zero page from reads and writes.",
"Memory");
DEFINE_bool(protect_on_release, false,
"Protect released memory to prevent accesses.");
"Protect released memory to prevent accesses.", "Memory");
DEFINE_bool(scribble_heap, false,
"Scribble 0xCD into all allocated heap memory.");
"Scribble 0xCD into all allocated heap memory.", "Memory");
namespace xe {
uint32_t get_page_count(uint32_t value, uint32_t page_size) {
return xe::round_up(value, page_size) / page_size;
}
@ -54,10 +52,10 @@ uint32_t get_page_count(uint32_t value, uint32_t page_size) {
*
* We create our own heap of committed memory that lives at
* memory_HEAP_LOW to memory_HEAP_HIGH - all normal user allocations
* come from there. Since the Xbox has no paging, we know that the size of this
* heap will never need to be larger than ~512MB (realistically, smaller than
* that). We place it far away from the XEX data and keep the memory around it
* uncommitted so that we have some warning if things go astray.
* come from there. Since the Xbox has no paging, we know that the size of
* this heap will never need to be larger than ~512MB (realistically, smaller
* than that). We place it far away from the XEX data and keep the memory
* around it uncommitted so that we have some warning if things go astray.
*
* For XEX/GPU/etc data we allow placement allocations (base_address != 0) and
* commit the requested memory as needed. This bypasses the standard heap, but
@ -175,8 +173,8 @@ bool Memory::Initialize() {
heaps_.v00000000.AllocFixed(
0x00000000, 0x10000, 0x10000,
kMemoryAllocationReserve | kMemoryAllocationCommit,
!FLAGS_protect_zero ? kMemoryProtectRead | kMemoryProtectWrite
: kMemoryProtectNoAccess);
!cvars::protect_zero ? kMemoryProtectRead | kMemoryProtectWrite
: kMemoryProtectNoAccess);
heaps_.physical.AllocFixed(0x1FFF0000, 0x10000, 0x10000,
kMemoryAllocationReserve, kMemoryProtectNoAccess);
@ -763,7 +761,7 @@ bool BaseHeap::AllocFixed(uint32_t base_address, uint32_t size,
return false;
}
if (FLAGS_scribble_heap && protect & kMemoryProtectWrite) {
if (cvars::scribble_heap && protect & kMemoryProtectWrite) {
std::memset(result, 0xCD, page_count * page_size_);
}
}
@ -911,7 +909,7 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address,
return false;
}
if (FLAGS_scribble_heap && (protect & kMemoryProtectWrite)) {
if (cvars::scribble_heap && (protect & kMemoryProtectWrite)) {
std::memset(result, 0xCD, page_count * page_size_);
}
}
@ -996,10 +994,10 @@ bool BaseHeap::Release(uint32_t base_address, uint32_t* out_region_size) {
xe::memory::page_size() ==
0 &&
((base_page_number * page_size_) % xe::memory::page_size() == 0))) {
// TODO(benvanik): figure out why games are using memory after releasing it.
// It's possible this is some virtual/physical stuff where the GPU still can
// access it.
if (FLAGS_protect_on_release) {
// TODO(benvanik): figure out why games are using memory after releasing
// it. It's possible this is some virtual/physical stuff where the GPU
// still can access it.
if (cvars::protect_on_release) {
if (!xe::memory::Protect(
membase_ + heap_base_ + base_page_number * page_size_,
base_page_entry.region_page_count * page_size_,
@ -1211,7 +1209,8 @@ bool PhysicalHeap::Alloc(uint32_t size, uint32_t alignment,
bool top_down, uint32_t* out_address) {
*out_address = 0;
// Default top-down. Since parent heap is bottom-up this prevents collisions.
// Default top-down. Since parent heap is bottom-up this prevents
// collisions.
top_down = true;
// Adjust alignment size our page size differs from the parent.

View File

@ -7,7 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include "api_scanner_loader.h"
namespace xe {
@ -20,8 +19,8 @@ int api_scanner_main(std::vector<std::wstring>& args) {
if (args.size() == 2 || !FLAGS_target.empty()) {
apiscanner_loader loader_;
std::wstring target(FLAGS_target.empty() ? args[1]
: xe::to_wstring(FLAGS_target));
std::wstring target(cvars::target.empty() ? args[1]
: xe::to_wstring(cvars::target));
std::wstring target_abs = xe::to_absolute_path(target);

View File

@ -9,8 +9,10 @@
#include "xenia/ui/vulkan/vulkan.h"
DEFINE_bool(vulkan_validation, false, "Enable Vulkan validation layers.");
DEFINE_bool(vulkan_validation, false, "Enable Vulkan validation layers.",
"Vulkan");
DEFINE_bool(vulkan_primary_queue_only, false,
"Force the use of the primary queue, ignoring any additional that "
"may be present.");
"may be present.",
"Vulkan");

View File

@ -10,8 +10,6 @@
#ifndef XENIA_UI_VULKAN_VULKAN_H_
#define XENIA_UI_VULKAN_VULKAN_H_
#include <gflags/gflags.h>
#include "xenia/base/platform.h"
#if XE_PLATFORM_WIN32
@ -25,6 +23,7 @@
// We use a loader with its own function prototypes.
#include "third_party/volk/volk.h"
#include "third_party/vulkan/vulkan.h"
#include "xenia/base/cvar.h"
#define XELOGVK XELOGI

View File

@ -9,8 +9,6 @@
#include "xenia/ui/vulkan/vulkan_device.h"
#include <gflags/gflags.h>
#include <cinttypes>
#include <climits>
#include <mutex>
@ -33,7 +31,7 @@ namespace ui {
namespace vulkan {
VulkanDevice::VulkanDevice(VulkanInstance* instance) : instance_(instance) {
if (FLAGS_vulkan_validation) {
if (cvars::vulkan_validation) {
DeclareRequiredLayer("VK_LAYER_LUNARG_standard_validation",
Version::Make(0, 0, 0), true);
// DeclareRequiredLayer("VK_LAYER_GOOGLE_unique_objects", Version::Make(0,
@ -150,7 +148,7 @@ bool VulkanDevice::Initialize(DeviceInfo device_info) {
}
// Some tools *cough* renderdoc *cough* can't handle multiple queues.
if (FLAGS_vulkan_primary_queue_only) {
if (cvars::vulkan_primary_queue_only) {
queue_count = 1;
}

View File

@ -9,8 +9,6 @@
#include "xenia/ui/vulkan/vulkan_instance.h"
#include <gflags/gflags.h>
#include <cinttypes>
#include <mutex>
#include <string>
@ -38,7 +36,7 @@ namespace ui {
namespace vulkan {
VulkanInstance::VulkanInstance() {
if (FLAGS_vulkan_validation) {
if (cvars::vulkan_validation) {
DeclareRequiredLayer("VK_LAYER_LUNARG_standard_validation",
Version::Make(0, 0, 0), true);
// DeclareRequiredLayer("VK_LAYER_GOOGLE_unique_objects", Version::Make(0,

View File

@ -9,8 +9,6 @@
#include "xenia/ui/vulkan/vulkan_provider.h"
#include <gflags/gflags.h>
#include <algorithm>
#include "xenia/base/logging.h"
@ -19,7 +17,8 @@
#include "xenia/ui/vulkan/vulkan_instance.h"
#include "xenia/ui/vulkan/vulkan_util.h"
DEFINE_uint64(vulkan_device_index, 0, "Index of the physical device to use.");
DEFINE_uint64(vulkan_device_index, 0, "Index of the physical device to use.",
"Vulkan");
namespace xe {
namespace ui {
@ -73,7 +72,7 @@ bool VulkanProvider::Initialize() {
return false;
}
size_t device_index =
std::min(available_devices.size(), FLAGS_vulkan_device_index);
std::min(available_devices.size(), cvars::vulkan_device_index);
auto& device_info = available_devices[device_index];
// Create the device.

View File

@ -9,12 +9,11 @@
#include "xenia/ui/vulkan/vulkan_swap_chain.h"
#include <gflags/gflags.h>
#include <mutex>
#include <string>
#include "xenia/base/assert.h"
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/ui/vulkan/vulkan.h"
@ -23,7 +22,7 @@
#include "xenia/ui/vulkan/vulkan_util.h"
DEFINE_bool(vulkan_random_clear_color, false,
"Randomizes framebuffer clear color.");
"Randomizes framebuffer clear color.", "Vulkan");
namespace xe {
namespace ui {
@ -583,7 +582,7 @@ VkResult VulkanSwapChain::Begin() {
clear_color.float32[1] = 238 / 255.0f;
clear_color.float32[2] = 238 / 255.0f;
clear_color.float32[3] = 1.0f;
if (FLAGS_vulkan_random_clear_color) {
if (cvars::vulkan_random_clear_color) {
clear_color.float32[0] =
rand() / static_cast<float>(RAND_MAX); // NOLINT(runtime/threadsafe_fn)
clear_color.float32[1] = 1.0f;

View File

@ -12,6 +12,7 @@
#include <memory>
#include <string>
#include <vector>
#include "xenia/ui/vulkan/vulkan.h"

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include <cstring>
#include "third_party/imgui/imgui.h"

View File

@ -7,8 +7,6 @@
******************************************************************************
*/
#include <gflags/gflags.h>
#include <cstdlib>
#include <cstring>
#include <locale>
@ -17,6 +15,7 @@
#define CATCH_CONFIG_RUNNER
#include "third_party/catch/include/catch.hpp"
#include "xenia/base/cvar.h"
namespace xe {
@ -24,16 +23,11 @@ bool has_console_attached() { return true; }
// Used in console mode apps; automatically picked based on subsystem.
int Main(int argc, char* argv[]) {
google::SetUsageMessage(std::string("usage: ..."));
google::SetVersionString("1.0");
// Parse flags; this may delete some of them.
google::ParseCommandLineFlags(&argc, &argv, true);
cvar::ParseLaunchArguments(argc, argv);
// Run Catch.
int result = Catch::Session().run(argc, argv);
google::ShutDownCommandLineFlags();
return result;
}