diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index e8e912403..e4ea32647 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -186,11 +186,22 @@ float g_Xbox_BackbufferScaleY = 1; static constexpr size_t INDEX_BUFFER_CACHE_SIZE = 10000; // ImGui +static bool imGuiShown = false; static void CxbxImGui_DrawWidgets() { + if (!imGuiShown) return; + // 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; @@ -1946,10 +1957,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar } else if (wParam == VK_F1) { - VertexBufferConverter.PrintStats(); - - extern void DSound_PrintStats(); //TODO: move into plugin class usage. - DSound_PrintStats(); + imGuiShown = !imGuiShown; } else if (wParam == VK_F2) { @@ -1967,6 +1975,11 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar CxbxReleaseCursor(); } } + else if (wParam == VK_F4) + { + extern void DSound_PrintStats(); //TODO: move into plugin class usage. + DSound_PrintStats(); + } else if (wParam == VK_F6) { // For some unknown reason, F6 isn't handled in WndMain::WndProc diff --git a/src/core/hle/D3D8/XbVertexBuffer.cpp b/src/core/hle/D3D8/XbVertexBuffer.cpp index eb3c8d526..d4950fbf6 100644 --- a/src/core/hle/D3D8/XbVertexBuffer.cpp +++ b/src/core/hle/D3D8/XbVertexBuffer.cpp @@ -38,6 +38,8 @@ #include "core\hle\D3D8\XbVertexBuffer.h" #include "core\hle\D3D8\XbConvert.h" +#include + #include #include #include @@ -215,12 +217,11 @@ CxbxPatchedStream& CxbxVertexBufferConverter::GetPatchedStream(uint64_t dataKey, return stream; } -void CxbxVertexBufferConverter::PrintStats() +void CxbxVertexBufferConverter::ShowImGuiStats() { - printf("Vertex Buffer Cache Status: \n"); - printf("- Cache Size: %d\n", m_PatchedStreams.size()); - printf("- Hits: %d\n", m_TotalCacheHits); - printf("- Misses: %d\n", m_TotalCacheMisses); + ImGui::Text("Cache Size: %u", m_PatchedStreams.size()); + ImGui::Text("Hits: %u", std::exchange(m_TotalCacheHits, 0)); + ImGui::Text("Misses: %u", std::exchange(m_TotalCacheMisses, 0)); } void CxbxVertexBufferConverter::ConvertStream diff --git a/src/core/hle/D3D8/XbVertexBuffer.h b/src/core/hle/D3D8/XbVertexBuffer.h index cad1fd7c9..ae59c1e67 100644 --- a/src/core/hle/D3D8/XbVertexBuffer.h +++ b/src/core/hle/D3D8/XbVertexBuffer.h @@ -78,7 +78,7 @@ class CxbxVertexBufferConverter public: CxbxVertexBufferConverter() = default; void Apply(CxbxDrawContext *pPatchDesc); - void PrintStats(); + void ShowImGuiStats(); private: struct StreamKey {