ImGui: move generic vertex cache into ImGui's video class.

This commit is contained in:
RadWolfie 2021-03-25 15:59:17 -05:00
parent e052a681be
commit 0875de0727
4 changed files with 19 additions and 23 deletions

View File

@ -12,6 +12,7 @@
#include "EmuShared.h"
#include "core/kernel/init/CxbxKrnl.h"
#include "core/hle/D3D8/XbVertexBuffer.h"
bool ImGuiVideo::Initialize()
{
@ -27,14 +28,22 @@ void ImGuiVideo::Shutdown()
void ImGuiVideo::DrawMenu()
{
if (ImGui::BeginMenu("Video")) {
ImGui::MenuItem("Show Vertex Stats", NULL, &m_windows.cache_stats_vertex);
ImGui::MenuItem("Debug Vertex Buffer Cache Stats", NULL, &m_windows.cache_stats_vertex);
ImGui::EndMenu();
}
}
void ImGuiVideo::DrawWidgets(bool is_focus, ImGuiWindowFlags input_handler)
{
//TODO: move into plugin class usage.
extern void CxbxImGui_Video_DrawWidgets(bool, ImGuiWindowFlags, bool);
CxbxImGui_Video_DrawWidgets(is_focus, input_handler, m_windows.cache_stats_vertex);
// Render vertex buffer cache stats
if (m_windows.cache_stats_vertex) {
ImGui::SetNextWindowPos(ImVec2(IMGUI_MIN_DIST_SIDE, IMGUI_MIN_DIST_TOP), ImGuiCond_FirstUseEver, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowSize(ImVec2(200, 275), ImGuiCond_FirstUseEver);
if (ImGui::Begin("Debugging stats", nullptr, input_handler | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
if (ImGui::CollapsingHeader("Vertex Buffer Cache", ImGuiTreeNodeFlags_DefaultOpen)) {
VertexBufferConverter.DrawCacheStats();
}
ImGui::End();
}
}
}

View File

@ -128,8 +128,6 @@ static size_t g_QuadToTriangleHostIndexBuffer_Size = 0; //
static INDEX16 *g_pQuadToTriangleIndexData = nullptr;
static size_t g_QuadToTriangleIndexData_Size = 0; // = NrOfQuadIndices
static CxbxVertexBufferConverter VertexBufferConverter = {};
struct {
xbox::X_D3DSurface Surface;
RECT SrcRect;
@ -186,21 +184,6 @@ float g_Xbox_BackbufferScaleY = 1;
static constexpr size_t INDEX_BUFFER_CACHE_SIZE = 10000;
// ImGui
void CxbxImGui_Video_DrawWidgets(bool is_focus, ImGuiWindowFlags input_handler, bool show_vertex_stats)
{
if (show_vertex_stats) {
ImGui::SetNextWindowPos(ImVec2(IMGUI_MIN_DIST_SIDE, IMGUI_MIN_DIST_TOP), ImGuiCond_FirstUseEver, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowSize(ImVec2(200, 275), ImGuiCond_FirstUseEver);
if (ImGui::Begin("Debugging stats", nullptr, input_handler | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
if (ImGui::CollapsingHeader("Vertex Buffers", ImGuiTreeNodeFlags_DefaultOpen)) {
VertexBufferConverter.ShowImGuiStats();
}
ImGui::End();
}
}
}
static void CxbxImGui_RenderD3D9(ImGuiUI* m_imgui, IDirect3DSurface9* renderTarget)
{
ImGui_ImplDX9_NewFrame();

View File

@ -46,6 +46,8 @@
#define MAX_STREAM_NOT_USED_TIME (2 * CLOCKS_PER_SEC) // TODO: Trim the not used time
CxbxVertexBufferConverter VertexBufferConverter = {};
// Inline vertex buffer emulation
xbox::X_D3DPRIMITIVETYPE g_InlineVertexBuffer_PrimitiveType = xbox::X_D3DPT_INVALID;
uint32_t g_InlineVertexBuffer_WrittenRegisters = 0; // A bitmask, indicating which registers have been set in g_InlineVertexBuffer_Table
@ -218,7 +220,7 @@ CxbxPatchedStream& CxbxVertexBufferConverter::GetPatchedStream(uint64_t dataKey,
return stream;
}
void CxbxVertexBufferConverter::ShowImGuiStats()
void CxbxVertexBufferConverter::DrawCacheStats()
{
const ULONG falsePositives = std::exchange(m_TotalLookupSuccesses, 0) - m_TotalCacheHits;
const ULONG totalMisses = m_VertexStreamHashMisses + m_DataNotInCacheMisses;

View File

@ -78,7 +78,7 @@ class CxbxVertexBufferConverter
public:
CxbxVertexBufferConverter() = default;
void Apply(CxbxDrawContext *pPatchDesc);
void ShowImGuiStats();
void DrawCacheStats();
private:
struct StreamKey
{
@ -116,6 +116,8 @@ class CxbxVertexBufferConverter
void ConvertStream(CxbxDrawContext *pPatchDesc, CxbxVertexDeclaration* pCxbxVertexDeclaration, UINT uiStream);
};
extern CxbxVertexBufferConverter VertexBufferConverter;
// Inline vertex buffer emulation
extern xbox::X_D3DPRIMITIVETYPE g_InlineVertexBuffer_PrimitiveType;