From 1f4219b5b4c5877efa12ac07d7647ed5285b288c Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 4 Feb 2014 20:16:03 +0100 Subject: [PATCH] move perfquery enable checks into videocommon (caller side) --- Source/Core/VideoBackends/D3D/PerfQuery.cpp | 21 ------------------- .../Core/VideoBackends/D3D/VertexManager.cpp | 2 -- Source/Core/VideoBackends/OGL/PerfQuery.cpp | 21 ------------------- .../Core/VideoBackends/OGL/VertexManager.cpp | 4 ---- Source/Core/VideoCommon/BPStructs.cpp | 3 ++- Source/Core/VideoCommon/PerfQueryBase.cpp | 2 +- Source/Core/VideoCommon/PerfQueryBase.h | 2 +- Source/Core/VideoCommon/VertexManagerBase.cpp | 6 +++++- 8 files changed, 9 insertions(+), 52 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/PerfQuery.cpp b/Source/Core/VideoBackends/D3D/PerfQuery.cpp index b2c77a876e..425721dbe2 100644 --- a/Source/Core/VideoBackends/D3D/PerfQuery.cpp +++ b/Source/Core/VideoBackends/D3D/PerfQuery.cpp @@ -28,9 +28,6 @@ PerfQuery::~PerfQuery() void PerfQuery::EnableQuery(PerfQueryGroup type) { - if (!ShouldEmulate()) - return; - // Is this sane? if (m_query_count > ArraySize(m_query_buffer) / 2) WeakFlush(); @@ -56,9 +53,6 @@ void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type) { - if (!ShouldEmulate()) - return; - // stop query if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) { @@ -75,9 +69,6 @@ void PerfQuery::ResetQuery() u32 PerfQuery::GetQueryResult(PerfQueryType type) { - if (!ShouldEmulate()) - return 0; - u32 result = 0; if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) @@ -102,9 +93,6 @@ u32 PerfQuery::GetQueryResult(PerfQueryType type) void PerfQuery::FlushOne() { - if (!ShouldEmulate()) - return; - auto& entry = m_query_buffer[m_query_read_pos]; UINT64 result = 0; @@ -125,18 +113,12 @@ void PerfQuery::FlushOne() // TODO: could selectively flush things, but I don't think that will do much void PerfQuery::FlushResults() { - if (!ShouldEmulate()) - return; - while (!IsFlushed()) FlushOne(); } void PerfQuery::WeakFlush() { - if (!ShouldEmulate()) - return; - while (!IsFlushed()) { auto& entry = m_query_buffer[m_query_read_pos]; @@ -161,9 +143,6 @@ void PerfQuery::WeakFlush() bool PerfQuery::IsFlushed() const { - if (!ShouldEmulate()) - return true; - return 0 == m_query_count; } diff --git a/Source/Core/VideoBackends/D3D/VertexManager.cpp b/Source/Core/VideoBackends/D3D/VertexManager.cpp index f7de0c63cb..a85c85027d 100644 --- a/Source/Core/VideoBackends/D3D/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D/VertexManager.cpp @@ -216,9 +216,7 @@ void VertexManager::vFlush(bool useDstAlpha) g_nativeVertexFmt->SetupVertexPointers(); g_renderer->ApplyState(useDstAlpha); - g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); Draw(stride); - g_perf_query->DisableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); g_renderer->RestoreState(); } diff --git a/Source/Core/VideoBackends/OGL/PerfQuery.cpp b/Source/Core/VideoBackends/OGL/PerfQuery.cpp index 0dd97d95cb..a002051584 100644 --- a/Source/Core/VideoBackends/OGL/PerfQuery.cpp +++ b/Source/Core/VideoBackends/OGL/PerfQuery.cpp @@ -28,9 +28,6 @@ PerfQuery::~PerfQuery() void PerfQuery::EnableQuery(PerfQueryGroup type) { - if (!ShouldEmulate()) - return; - // Is this sane? if (m_query_count > ArraySize(m_query_buffer) / 2) WeakFlush(); @@ -55,9 +52,6 @@ void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type) { - if (!ShouldEmulate()) - return; - // stop query if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) { @@ -67,17 +61,11 @@ void PerfQuery::DisableQuery(PerfQueryGroup type) bool PerfQuery::IsFlushed() const { - if (!ShouldEmulate()) - return true; - return 0 == m_query_count; } void PerfQuery::FlushOne() { - if (!ShouldEmulate()) - return; - auto& entry = m_query_buffer[m_query_read_pos]; GLuint result = 0; @@ -93,18 +81,12 @@ void PerfQuery::FlushOne() // TODO: could selectively flush things, but I don't think that will do much void PerfQuery::FlushResults() { - if (!ShouldEmulate()) - return; - while (!IsFlushed()) FlushOne(); } void PerfQuery::WeakFlush() { - if (!ShouldEmulate()) - return; - while (!IsFlushed()) { auto& entry = m_query_buffer[m_query_read_pos]; @@ -131,9 +113,6 @@ void PerfQuery::ResetQuery() u32 PerfQuery::GetQueryResult(PerfQueryType type) { - if (!ShouldEmulate()) - return 0; - u32 result = 0; if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp index f0e55ee86d..670dd7d8a0 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.cpp +++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp @@ -26,7 +26,6 @@ #include "IndexGenerator.h" #include "FileUtil.h" #include "StreamBuffer.h" -#include "PerfQueryBase.h" #include "Render.h" #include "main.h" @@ -173,10 +172,7 @@ void VertexManager::vFlush(bool useDstAlpha) g_nativeVertexFmt->SetupVertexPointers(); GL_REPORT_ERRORD(); - g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); Draw(stride); - g_perf_query->DisableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); - //ERROR_LOG(VIDEO, "PerfQuery result: %d", g_perf_query->GetQueryResult(bpmem.zcontrol.early_ztest ? PQ_ZCOMP_OUTPUT_ZCOMPLOC : PQ_ZCOMP_OUTPUT)); // run through vertex groups again to set alpha if (useDstAlpha && !dualSourcePossible) diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 5482dae102..2434d347fa 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -423,7 +423,8 @@ void BPWritten(const BPCmd& bp) case BPMEM_CLEAR_PIXEL_PERF: // GXClearPixMetric writes 0xAAA here, Sunshine alternates this register between values 0x000 and 0xAAA - g_perf_query->ResetQuery(); + if(PerfQueryBase::ShouldEmulate()) + g_perf_query->ResetQuery(); break; case BPMEM_PRELOAD_ADDR: diff --git a/Source/Core/VideoCommon/PerfQueryBase.cpp b/Source/Core/VideoCommon/PerfQueryBase.cpp index af8bfa72e5..ada539c05e 100644 --- a/Source/Core/VideoCommon/PerfQueryBase.cpp +++ b/Source/Core/VideoCommon/PerfQueryBase.cpp @@ -3,7 +3,7 @@ PerfQueryBase* g_perf_query = 0; -bool PerfQueryBase::ShouldEmulate() const +bool PerfQueryBase::ShouldEmulate() { return g_ActiveConfig.bPerfQueriesEnable; } diff --git a/Source/Core/VideoCommon/PerfQueryBase.h b/Source/Core/VideoCommon/PerfQueryBase.h index 64a22c2712..ad112ede9d 100644 --- a/Source/Core/VideoCommon/PerfQueryBase.h +++ b/Source/Core/VideoCommon/PerfQueryBase.h @@ -29,7 +29,7 @@ public: // Checks if performance queries are enabled in the gameini configuration. // NOTE: Called from CPU+GPU thread - bool ShouldEmulate() const; + static bool ShouldEmulate(); // Begin querying the specified value for the following host GPU commands virtual void EnableQuery(PerfQueryGroup type) {} diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index cd2eec39ce..0ea44d9a57 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -12,6 +12,7 @@ #include "BPStructs.h" #include "XFMemory.h" #include "Debugger.h" +#include "PerfQueryBase.h" #include "VertexManagerBase.h" #include "MainBase.h" @@ -220,8 +221,11 @@ void VertexManager::Flush() bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; - // TODO: need to merge more stuff into VideoCommon + if(PerfQueryBase::ShouldEmulate()) + g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); g_vertex_manager->vFlush(useDstAlpha); + if(PerfQueryBase::ShouldEmulate()) + g_perf_query->DisableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP); GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);