From 4675161902424b12f65eb4aedad16c2b43d2aac2 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 16 Aug 2014 18:31:54 -0700 Subject: [PATCH] Header cleanup. --- src/alloy/core.h | 1 - src/xenia/common.h | 1 - src/xenia/config.h | 38 ------------------ src/xenia/logging.h | 12 +++++- src/xenia/profiling.cc | 71 ++++++++++++++-------------------- src/xenia/profiling.h | 75 +++++++++++++++++++++++------------- src/xenia/sources.gypi | 2 - src/xenia/xenia.h | 24 ------------ tools/xenia-run/xenia-run.cc | 4 +- 9 files changed, 90 insertions(+), 138 deletions(-) delete mode 100644 src/xenia/config.h delete mode 100644 src/xenia/xenia.h diff --git a/src/alloy/core.h b/src/alloy/core.h index 5f90cb31a..c465fe9d5 100644 --- a/src/alloy/core.h +++ b/src/alloy/core.h @@ -11,7 +11,6 @@ #define ALLOY_CORE_H_ // TODO(benvanik): move the common stuff into here? -#include #include #include #include diff --git a/src/xenia/common.h b/src/xenia/common.h index 9288f0d24..3e027f858 100644 --- a/src/xenia/common.h +++ b/src/xenia/common.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/src/xenia/config.h b/src/xenia/config.h deleted file mode 100644 index 0804277bf..000000000 --- a/src/xenia/config.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - ****************************************************************************** - * 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_CONFIG_H_ -#define XENIA_CONFIG_H_ - - -// Enable compile-time and runtime-time assertions. -#define XE_OPTION_ENABLE_ASSERTS 1 - -// Enable general logging. -#define XE_OPTION_ENABLE_LOGGING 1 -#define XE_OPTION_LOG_ERROR 1 -#define XE_OPTION_LOG_WARNING 1 -#define XE_OPTION_LOG_INFO 1 -#define XE_OPTION_LOG_DEBUG 1 -#define XE_OPTION_LOG_CPU 1 -#define XE_OPTION_LOG_SDB 0 -#define XE_OPTION_LOG_APU 1 -#define XE_OPTION_LOG_GPU 1 -#define XE_OPTION_LOG_KERNEL 1 -#define XE_OPTION_LOG_FS 1 - -// Enable profiling. -#define XE_OPTION_PROFILING 1 - -// TODO(benvanik): make this a runtime option -#define XE_OPTION_OPTIMIZED 0 - - -#endif // XENIA_CONFIG_H_ - diff --git a/src/xenia/logging.h b/src/xenia/logging.h index d8b7c30ae..9b29ea778 100644 --- a/src/xenia/logging.h +++ b/src/xenia/logging.h @@ -12,9 +12,19 @@ #include -#include #include +#define XE_OPTION_ENABLE_LOGGING 1 +#define XE_OPTION_LOG_ERROR 1 +#define XE_OPTION_LOG_WARNING 1 +#define XE_OPTION_LOG_INFO 1 +#define XE_OPTION_LOG_DEBUG 1 +#define XE_OPTION_LOG_CPU 1 +#define XE_OPTION_LOG_SDB 0 +#define XE_OPTION_LOG_APU 1 +#define XE_OPTION_LOG_GPU 1 +#define XE_OPTION_LOG_KERNEL 1 +#define XE_OPTION_LOG_FS 1 #if XE_COMPILER_GNUC #define XE_LOG_LINE_ATTRIBUTE __attribute__ ((format (printf, 5, 6))) diff --git a/src/xenia/profiling.cc b/src/xenia/profiling.cc index ce3a4ece0..649c686fc 100644 --- a/src/xenia/profiling.cc +++ b/src/xenia/profiling.cc @@ -22,9 +22,7 @@ void Profiler::Initialize() { MicroProfileSetDisplayMode(1); } -void Profiler::Dump() { - MicroProfileDumpTimers(); -} +void Profiler::Dump() { MicroProfileDumpTimers(); } void Profiler::Shutdown() { display_.reset(); @@ -41,31 +39,29 @@ void Profiler::ThreadEnter(const char* name) { MicroProfileOnThreadCreate(name); } -void Profiler::ThreadExit() { - MicroProfileOnThreadExit(); -} +void Profiler::ThreadExit() { MicroProfileOnThreadExit(); } bool Profiler::OnKeyDown(int key_code) { // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx switch (key_code) { - case VK_TAB: - MicroProfileToggleDisplayMode(); - return true; - case VK_OEM_3: // ` - MicroProfileTogglePause(); - return true; - case 0x31: // 1 - MicroProfileModKey(1); - return true; + case VK_TAB: + MicroProfileToggleDisplayMode(); + return true; + case VK_OEM_3: // ` + MicroProfileTogglePause(); + return true; + case 0x31: // 1 + MicroProfileModKey(1); + return true; } return false; } bool Profiler::OnKeyUp(int key_code) { switch (key_code) { - case 0x31: // 1 - MicroProfileModKey(0); - return true; + case 0x31: // 1 + MicroProfileModKey(0); + return true; } return false; } @@ -74,13 +70,9 @@ void Profiler::OnMouseDown(bool left_button, bool right_button) { MicroProfileMouseButton(left_button, right_button); } -void Profiler::OnMouseUp() { - MicroProfileMouseButton(0, 0); -} +void Profiler::OnMouseUp() { MicroProfileMouseButton(0, 0); } -void Profiler::OnMouseMove(int x, int y) { - MicroProfileMousePosition(x, y, 0); -} +void Profiler::OnMouseMove(int x, int y) { MicroProfileMousePosition(x, y, 0); } void Profiler::OnMouseWheel(int x, int y, int dy) { MicroProfileMousePosition(x, y, dy); @@ -124,34 +116,26 @@ void Profiler::Present() {} #if XE_OPTION_PROFILING -uint32_t MicroProfileGpuInsertTimeStamp() { - return 0; -} +uint32_t MicroProfileGpuInsertTimeStamp() { return 0; } -uint64_t MicroProfileGpuGetTimeStamp(uint32_t nKey) { - return 0; -} +uint64_t MicroProfileGpuGetTimeStamp(uint32_t nKey) { return 0; } -uint64_t MicroProfileTicksPerSecondGpu() { - return 0; -} +uint64_t MicroProfileTicksPerSecondGpu() { return 0; } -const char* MicroProfileGetThreadName() { - return "TODO: get thread name!"; -} +const char* MicroProfileGetThreadName() { return "TODO: get thread name!"; } -void MicroProfileDrawBox(int nX, int nY, int nX1, int nY1, uint32_t nColor, MicroProfileBoxType type) { +void MicroProfileDrawBox(int nX, int nY, int nX1, int nY1, uint32_t nColor, + MicroProfileBoxType type) { auto display = xe::Profiler::display(); if (!display) { return; } - display->DrawBox( - nX, nY, nX1, nY1, - nColor, - static_cast(type)); + display->DrawBox(nX, nY, nX1, nY1, nColor, + static_cast(type)); } -void MicroProfileDrawLine2D(uint32_t nVertices, float* pVertices, uint32_t nColor) { +void MicroProfileDrawLine2D(uint32_t nVertices, float* pVertices, + uint32_t nColor) { auto display = xe::Profiler::display(); if (!display) { return; @@ -159,7 +143,8 @@ void MicroProfileDrawLine2D(uint32_t nVertices, float* pVertices, uint32_t nColo display->DrawLine2D(nVertices, pVertices, nColor); } -void MicroProfileDrawText(int nX, int nY, uint32_t nColor, const char* pText, uint32_t nLen) { +void MicroProfileDrawText(int nX, int nY, uint32_t nColor, const char* pText, + uint32_t nLen) { auto display = xe::Profiler::display(); if (!display) { return; diff --git a/src/xenia/profiling.h b/src/xenia/profiling.h index 03ebdf720..88c63c994 100644 --- a/src/xenia/profiling.h +++ b/src/xenia/profiling.h @@ -12,10 +12,11 @@ #include -#include #include #include +#define XE_OPTION_PROFILING 1 + #if XE_OPTION_PROFILING // Pollutes the global namespace. Yuck. #include @@ -28,7 +29,8 @@ namespace xe { // Defines a profiling scope for CPU tasks. // Use `SCOPE_profile_cpu(name)` to activate the scope. #define DEFINE_profile_cpu(name, group_name, scope_name) \ - MICROPROFILE_DEFINE(name, group_name, scope_name, xe::Profiler::GetColor(scope_name)) + MICROPROFILE_DEFINE(name, group_name, scope_name, \ + xe::Profiler::GetColor(scope_name)) // Declares a previously defined profile scope. Use in a translation unit. #define DECLARE_profile_cpu(name) MICROPROFILE_DECLARE(name) @@ -36,40 +38,43 @@ namespace xe { // Defines a profiling scope for GPU tasks. // Use `COUNT_profile_gpu(name)` to activate the scope. #define DEFINE_profile_gpu(name, group_name, scope_name) \ - MICROPROFILE_DEFINE_GPU(name, group_name, scope_name, xe::Profiler::GetColor(scope_name)) + MICROPROFILE_DEFINE_GPU(name, group_name, scope_name, \ + xe::Profiler::GetColor(scope_name)) // Declares a previously defined profile scope. Use in a translation unit. #define DECLARE_profile_gpu(name) MICROPROFILE_DECLARE_GPU(name) // Enters a previously defined CPU profiling scope, active for the duration // of the containing block. -#define SCOPE_profile_cpu(name) \ - MICROPROFILE_SCOPE(name) +#define SCOPE_profile_cpu(name) MICROPROFILE_SCOPE(name) // Enters a CPU profiling scope, active for the duration of the containing // block. No previous definition required. #define SCOPE_profile_cpu_i(group_name, scope_name) \ - MICROPROFILE_SCOPEI(group_name, scope_name, xe::Profiler::GetColor(scope_name)) + MICROPROFILE_SCOPEI(group_name, scope_name, \ + xe::Profiler::GetColor(scope_name)) // Enters a CPU profiling scope by function name, active for the duration of // the containing block. No previous definition required. -#define SCOPE_profile_cpu_f(group_name) \ - MICROPROFILE_SCOPEI(group_name, __FUNCTION__, xe::Profiler::GetColor(__FUNCTION__)) +#define SCOPE_profile_cpu_f(group_name) \ + MICROPROFILE_SCOPEI(group_name, __FUNCTION__, \ + xe::Profiler::GetColor(__FUNCTION__)) // Enters a previously defined GPU profiling scope, active for the duration // of the containing block. -#define SCOPE_profile_gpu(name) \ - MICROPROFILE_SCOPEGPU(name) +#define SCOPE_profile_gpu(name) MICROPROFILE_SCOPEGPU(name) // Enters a GPU profiling scope, active for the duration of the containing // block. No previous definition required. #define SCOPE_profile_gpu_i(group_name, scope_name) \ - MICROPROFILE_SCOPEGPUI(group_name, scope_name, xe::Profiler::GetColor(scope_name)) + MICROPROFILE_SCOPEGPUI(group_name, scope_name, \ + xe::Profiler::GetColor(scope_name)) // Enters a GPU profiling scope by function name, active for the duration of // the containing block. No previous definition required. -#define SCOPE_profile_gpu_f(group_name) \ - MICROPROFILE_SCOPEGPUI(group_name, __FUNCTION__, xe::Profiler::GetColor(__FUNCTION__)) +#define SCOPE_profile_gpu_f(group_name) \ + MICROPROFILE_SCOPEGPUI(group_name, __FUNCTION__, \ + xe::Profiler::GetColor(__FUNCTION__)) // Tracks a CPU value counter. #define COUNT_profile_cpu(name, count) MICROPROFILE_META_CPU(name, count) @@ -83,14 +88,30 @@ namespace xe { #define DEFINE_profile_gpu(name, group_name, scope_name) #define DECLARE_profile_cpu(name) #define DECLARE_profile_gpu(name) -#define SCOPE_profile_cpu(name) do {} while (false) -#define SCOPE_profile_cpu_f(name) do {} while (false) -#define SCOPE_profile_cpu_i(group_name, scope_name) do {} while (false) -#define SCOPE_profile_gpu(name) do {} while (false) -#define SCOPE_profile_gpu_f(name) do {} while (false) -#define SCOPE_profile_gpu_i(group_name, scope_name) do {} while (false) -#define COUNT_profile_cpu(name, count) do {} while (false) -#define COUNT_profile_gpu(name, count) do {} while (false) +#define SCOPE_profile_cpu(name) \ + do { \ + } while (false) +#define SCOPE_profile_cpu_f(name) \ + do { \ + } while (false) +#define SCOPE_profile_cpu_i(group_name, scope_name) \ + do { \ + } while (false) +#define SCOPE_profile_gpu(name) \ + do { \ + } while (false) +#define SCOPE_profile_gpu_f(name) \ + do { \ + } while (false) +#define SCOPE_profile_gpu_i(group_name, scope_name) \ + do { \ + } while (false) +#define COUNT_profile_cpu(name, count) \ + do { \ + } while (false) +#define COUNT_profile_gpu(name, count) \ + do { \ + } while (false) #define MICROPROFILE_TEXT_WIDTH 1 #define MICROPROFILE_TEXT_HEIGHT 1 @@ -98,7 +119,7 @@ namespace xe { #endif // XE_OPTION_PROFILING class ProfilerDisplay { -public: + public: enum BoxType { #if XE_OPTION_PROFILING BOX_TYPE_BAR = MicroProfileBoxTypeBar, @@ -116,13 +137,15 @@ public: virtual void Begin() = 0; virtual void End() = 0; - virtual void DrawBox(int x, int y, int x1, int y1, uint32_t color, BoxType type) = 0; + virtual void DrawBox(int x, int y, int x1, int y1, uint32_t color, + BoxType type) = 0; virtual void DrawLine2D(uint32_t count, float* vertices, uint32_t color) = 0; - virtual void DrawText(int x, int y, uint32_t color, const char* text, size_t text_length) = 0; + virtual void DrawText(int x, int y, uint32_t color, const char* text, + size_t text_length) = 0; }; class Profiler { -public: + public: #if XE_OPTION_PROFILING static bool is_enabled() { return true; } #else @@ -161,7 +184,7 @@ public: // TODO(benvanik): display mode/pause/etc? -private: + private: static std::unique_ptr display_; }; diff --git a/src/xenia/sources.gypi b/src/xenia/sources.gypi index 9eaf39280..0afc479e1 100644 --- a/src/xenia/sources.gypi +++ b/src/xenia/sources.gypi @@ -2,7 +2,6 @@ { 'sources': [ 'common.h', - 'config.h', 'core.h', 'debug_agent.cc', 'debug_agent.h', @@ -19,7 +18,6 @@ 'string.h', 'types.h', 'xbox.h', - 'xenia.h', ], 'includes': [ diff --git a/src/xenia/xenia.h b/src/xenia/xenia.h deleted file mode 100644 index ebb04559d..000000000 --- a/src/xenia/xenia.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - ****************************************************************************** - * 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_H_ -#define XENIA_H_ - -#include -#include -#include -#include - -#include -#include -#include -#include - - -#endif // XENIA_H_ diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index 6c2c38802..4f95bbf2b 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -7,10 +7,10 @@ ****************************************************************************** */ -#include - #include #include +#include +#include using namespace xe;