ImGui: Improve style a bit, start hidden

This commit is contained in:
Silent 2021-03-16 22:15:47 +01:00 committed by RadWolfie
parent 55f1228c66
commit f68c706b1e
3 changed files with 25 additions and 11 deletions

View File

@ -186,11 +186,22 @@ float g_Xbox_BackbufferScaleY = 1;
static constexpr size_t INDEX_BUFFER_CACHE_SIZE = 10000; static constexpr size_t INDEX_BUFFER_CACHE_SIZE = 10000;
// ImGui // ImGui
static bool imGuiShown = false;
static void CxbxImGui_DrawWidgets() static void CxbxImGui_DrawWidgets()
{ {
if (!imGuiShown) return;
// Put all ImGui drawing here // Put all ImGui drawing here
ImGui::ShowDemoWindow(); constexpr float DIST_FROM_CORNER = 10.0f;
ImGui::SetNextWindowPos(ImVec2(DIST_FROM_CORNER, DIST_FROM_CORNER), ImGuiCond_Once, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowSize(ImVec2(200, 275), ImGuiCond_Once);
if (ImGui::Begin("Debugging stats", &imGuiShown, ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
if (ImGui::CollapsingHeader("Vertex Buffers", ImGuiTreeNodeFlags_DefaultOpen)) {
VertexBufferConverter.ShowImGuiStats();
}
ImGui::End();
}
} }
static std::mutex imGuiMutex; static std::mutex imGuiMutex;
@ -1946,10 +1957,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
} }
else if (wParam == VK_F1) else if (wParam == VK_F1)
{ {
VertexBufferConverter.PrintStats(); imGuiShown = !imGuiShown;
extern void DSound_PrintStats(); //TODO: move into plugin class usage.
DSound_PrintStats();
} }
else if (wParam == VK_F2) else if (wParam == VK_F2)
{ {
@ -1967,6 +1975,11 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
CxbxReleaseCursor(); CxbxReleaseCursor();
} }
} }
else if (wParam == VK_F4)
{
extern void DSound_PrintStats(); //TODO: move into plugin class usage.
DSound_PrintStats();
}
else if (wParam == VK_F6) else if (wParam == VK_F6)
{ {
// For some unknown reason, F6 isn't handled in WndMain::WndProc // For some unknown reason, F6 isn't handled in WndMain::WndProc

View File

@ -38,6 +38,8 @@
#include "core\hle\D3D8\XbVertexBuffer.h" #include "core\hle\D3D8\XbVertexBuffer.h"
#include "core\hle\D3D8\XbConvert.h" #include "core\hle\D3D8\XbConvert.h"
#include <imgui.h>
#include <ctime> #include <ctime>
#include <chrono> #include <chrono>
#include <algorithm> #include <algorithm>
@ -215,12 +217,11 @@ CxbxPatchedStream& CxbxVertexBufferConverter::GetPatchedStream(uint64_t dataKey,
return stream; return stream;
} }
void CxbxVertexBufferConverter::PrintStats() void CxbxVertexBufferConverter::ShowImGuiStats()
{ {
printf("Vertex Buffer Cache Status: \n"); ImGui::Text("Cache Size: %u", m_PatchedStreams.size());
printf("- Cache Size: %d\n", m_PatchedStreams.size()); ImGui::Text("Hits: %u", std::exchange(m_TotalCacheHits, 0));
printf("- Hits: %d\n", m_TotalCacheHits); ImGui::Text("Misses: %u", std::exchange(m_TotalCacheMisses, 0));
printf("- Misses: %d\n", m_TotalCacheMisses);
} }
void CxbxVertexBufferConverter::ConvertStream void CxbxVertexBufferConverter::ConvertStream

View File

@ -78,7 +78,7 @@ class CxbxVertexBufferConverter
public: public:
CxbxVertexBufferConverter() = default; CxbxVertexBufferConverter() = default;
void Apply(CxbxDrawContext *pPatchDesc); void Apply(CxbxDrawContext *pPatchDesc);
void PrintStats(); void ShowImGuiStats();
private: private:
struct StreamKey struct StreamKey
{ {