Latest microprofiler in headless mode.
This commit is contained in:
parent
4a7eccf5dc
commit
7629c0f4d2
|
@ -89,7 +89,7 @@ LRESULT WGLControl::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||
}
|
||||
|
||||
// TODO(benvanik): profiler present.
|
||||
// Profiler::Present();
|
||||
Profiler::Present();
|
||||
|
||||
// Hacky swap timer.
|
||||
static int swap_count = 0;
|
||||
|
|
|
@ -7,10 +7,17 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#define MICRO_PROFILE_IMPL
|
||||
#define MICROPROFILE_IMPL
|
||||
#define MICROPROFILE_USE_THREAD_NAME_CALLBACK 1
|
||||
#define MICROPROFILE_PRINTF PLOGI
|
||||
#include <microprofile/microprofile.h>
|
||||
|
||||
#include <xenia/profiling.h>
|
||||
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
#include <microprofile/microprofileui.h>
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
|
||||
namespace xe {
|
||||
|
||||
std::unique_ptr<ProfilerDisplay> Profiler::display_ = nullptr;
|
||||
|
@ -18,11 +25,19 @@ std::unique_ptr<ProfilerDisplay> Profiler::display_ = nullptr;
|
|||
#if XE_OPTION_PROFILING
|
||||
|
||||
void Profiler::Initialize() {
|
||||
MicroProfileInit();
|
||||
MicroProfileSetForceEnable(true);
|
||||
MicroProfileSetEnableAllGroups(true);
|
||||
MicroProfileSetForceMetaCounters(true);
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
MicroProfileInitUI();
|
||||
MicroProfileSetDisplayMode(1);
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
}
|
||||
|
||||
void Profiler::Dump() { MicroProfileDumpTimers(); }
|
||||
void Profiler::Dump() {
|
||||
MicroProfileDumpHtml("profile.html");
|
||||
MicroProfileDumpHtmlToFile();
|
||||
}
|
||||
|
||||
void Profiler::Shutdown() {
|
||||
display_.reset();
|
||||
|
@ -44,28 +59,34 @@ 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;
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
case VK_TAB:
|
||||
MicroProfileToggleDisplayMode();
|
||||
return true;
|
||||
case 0x31: // 1
|
||||
MicroProfileModKey(1);
|
||||
return true;
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Profiler::OnKeyUp(int key_code) {
|
||||
switch (key_code) {
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
case 0x31: // 1
|
||||
MicroProfileModKey(0);
|
||||
return true;
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
|
||||
void Profiler::OnMouseDown(bool left_button, bool right_button) {
|
||||
MicroProfileMouseButton(left_button, right_button);
|
||||
}
|
||||
|
@ -78,19 +99,48 @@ void Profiler::OnMouseWheel(int x, int y, int dy) {
|
|||
MicroProfileMousePosition(x, y, dy);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void Profiler::OnMouseDown(bool left_button, bool right_button) {}
|
||||
|
||||
void Profiler::OnMouseUp() {}
|
||||
|
||||
void Profiler::OnMouseMove(int x, int y) {}
|
||||
|
||||
void Profiler::OnMouseWheel(int x, int y, int dy) {}
|
||||
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
|
||||
void Profiler::set_display(std::unique_ptr<ProfilerDisplay> display) {
|
||||
display_ = std::move(display);
|
||||
}
|
||||
|
||||
void Profiler::Present() {
|
||||
MicroProfileFlip();
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
if (!display_) {
|
||||
return;
|
||||
}
|
||||
|
||||
float left = 0.f;
|
||||
float right = display_->width();
|
||||
float bottom = display_->height();
|
||||
float top = 0.f;
|
||||
float near = -1.f;
|
||||
float far = 1.f;
|
||||
float projection[16] = {0};
|
||||
projection[0] = 2.0f / (right - left);
|
||||
projection[5] = 2.0f / (top - bottom);
|
||||
projection[10] = -2.0f / (far - near);
|
||||
projection[12] = -(right + left) / (right - left);
|
||||
projection[13] = -(top + bottom) / (top - bottom);
|
||||
projection[14] = -(far + near) / (far - near);
|
||||
projection[15] = 1.f;
|
||||
display_->Begin();
|
||||
MicroProfileBeginDraw(display_->width(), display_->height(), projection);
|
||||
MicroProfileDraw(display_->width(), display_->height());
|
||||
MicroProfileEndDraw();
|
||||
display_->End();
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -124,6 +174,8 @@ uint64_t MicroProfileTicksPerSecondGpu() { return 0; }
|
|||
|
||||
const char* MicroProfileGetThreadName() { return "TODO: get thread name!"; }
|
||||
|
||||
#if XE_OPTION_PROFILING_UI
|
||||
|
||||
void MicroProfileDrawBox(int nX, int nY, int nX1, int nY1, uint32_t nColor,
|
||||
MicroProfileBoxType type) {
|
||||
auto display = xe::Profiler::display();
|
||||
|
@ -152,4 +204,6 @@ void MicroProfileDrawText(int nX, int nY, uint32_t nColor, const char* pText,
|
|||
display->DrawText(nX, nY, nColor, pText, nLen);
|
||||
}
|
||||
|
||||
#endif // XE_OPTION_PROFILING_UI
|
||||
|
||||
#endif // XE_OPTION_PROFILING
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
#include <poly/string.h>
|
||||
|
||||
#if XE_LIKE_WIN32
|
||||
#define XE_OPTION_PROFILING 1
|
||||
#if XE_LIKE_WIN32
|
||||
//#define XE_OPTION_PROFILING_UI 1
|
||||
#endif // XE_LIKE_WIN32
|
||||
|
||||
#if XE_OPTION_PROFILING
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue