Header cleanup.

This commit is contained in:
Ben Vanik 2014-08-16 18:31:54 -07:00
parent 27bc4ba405
commit 4675161902
9 changed files with 90 additions and 138 deletions

View File

@ -11,7 +11,6 @@
#define ALLOY_CORE_H_
// TODO(benvanik): move the common stuff into here?
#include <xenia/config.h>
#include <xenia/logging.h>
#include <xenia/malloc.h>
#include <xenia/profiling.h>

View File

@ -15,7 +15,6 @@
#include <poly/byte_order.h>
#include <poly/memory.h>
#include <xenia/config.h>
#include <xenia/logging.h>
#include <xenia/malloc.h>
#include <xenia/profiling.h>

View File

@ -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_

View File

@ -12,9 +12,19 @@
#include <cstdint>
#include <xenia/config.h>
#include <xenia/string.h>
#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)))

View File

@ -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<xe::ProfilerDisplay::BoxType>(type));
display->DrawBox(nX, nY, nX1, nY1, nColor,
static_cast<xe::ProfilerDisplay::BoxType>(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;

View File

@ -12,10 +12,11 @@
#include <memory>
#include <xenia/config.h>
#include <xenia/string.h>
#include <xenia/types.h>
#define XE_OPTION_PROFILING 1
#if XE_OPTION_PROFILING
// Pollutes the global namespace. Yuck.
#include <microprofile/microprofile.h>
@ -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<ProfilerDisplay> display_;
};

View File

@ -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': [

View File

@ -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 <xenia/common.h>
#include <xenia/core.h>
#include <xenia/emulator.h>
#include <xenia/xbox.h>
#include <xenia/apu/apu.h>
#include <xenia/cpu/cpu.h>
#include <xenia/gpu/gpu.h>
#include <xenia/kernel/kernel.h>
#endif // XENIA_H_

View File

@ -7,10 +7,10 @@
******************************************************************************
*/
#include <xenia/xenia.h>
#include <gflags/gflags.h>
#include <poly/main.h>
#include <xenia/emulator.h>
#include <xenia/kernel/kernel.h>
using namespace xe;