Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11647 from AdmiralCurtiss/perfquery-inconsistency
Fix PerfQuery inconsistencies across backends.
  • Loading branch information
delroth committed Mar 15, 2023
2 parents b43f832 + aac9647 commit 91fca07
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
9 changes: 6 additions & 3 deletions Source/Core/VideoBackends/D3D/D3DPerfQuery.cpp
Expand Up @@ -8,6 +8,7 @@
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"

namespace DX11
{
Expand Down Expand Up @@ -96,7 +97,7 @@ u32 PerfQuery::GetQueryResult(PerfQueryType type)
result = m_results[PQG_EFB_COPY_CLOCKS].load(std::memory_order_relaxed);
}

return result;
return result / 4;
}

void PerfQuery::FlushOne()
Expand All @@ -114,8 +115,10 @@ void PerfQuery::FlushOne()
// NOTE: Reported pixel metrics should be referenced to native resolution
// TODO: Dropping the lower 2 bits from this count should be closer to actual
// hardware behavior when drawing triangles.
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() *
EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight();
u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
g_framebuffer_manager->GetEFBHeight();
if (g_ActiveConfig.iMultisamples > 1)
native_res_result /= g_ActiveConfig.iMultisamples;
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
std::memory_order_relaxed);

Expand Down
9 changes: 6 additions & 3 deletions Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp
Expand Up @@ -13,6 +13,7 @@
#include "VideoBackends/D3D12/DX12Context.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"

namespace DX12
{
Expand Down Expand Up @@ -244,9 +245,11 @@ void PerfQuery::AccumulateQueriesFromBuffer(u32 query_count)
std::memcpy(&result, mapped_ptr + (index * sizeof(PerfQueryDataType)), sizeof(result));

// NOTE: Reported pixel metrics should be referenced to native resolution
const u64 native_res_result = static_cast<u64>(result) * EFB_WIDTH /
g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
g_framebuffer_manager->GetEFBHeight();
u64 native_res_result = static_cast<u64>(result) * EFB_WIDTH /
g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
g_framebuffer_manager->GetEFBHeight();
if (g_ActiveConfig.iMultisamples > 1)
native_res_result /= g_ActiveConfig.iMultisamples;
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
std::memory_order_relaxed);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/Metal/MTLPerfQuery.mm
Expand Up @@ -46,7 +46,7 @@
result = m_results[PQG_EFB_COPY_CLOCKS].load(std::memory_order_relaxed);
}

return result;
return result / 4;
}

void Metal::PerfQuery::FlushResults()
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/OGLPerfQuery.cpp
Expand Up @@ -80,7 +80,7 @@ u32 PerfQuery::GetQueryResult(PerfQueryType type)
result = m_results[PQG_EFB_COPY_CLOCKS].load(std::memory_order_relaxed);
}

return result;
return result / 4;
}

// Implementations
Expand Down
9 changes: 6 additions & 3 deletions Source/Core/VideoBackends/Vulkan/VKPerfQuery.cpp
Expand Up @@ -17,6 +17,7 @@
#include "VideoBackends/Vulkan/VulkanContext.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"

namespace Vulkan
{
Expand Down Expand Up @@ -218,9 +219,11 @@ void PerfQuery::ReadbackQueries(u32 query_count)
entry.has_value = false;

// NOTE: Reported pixel metrics should be referenced to native resolution
const u64 native_res_result = static_cast<u64>(m_query_result_buffer[i]) * EFB_WIDTH /
g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
g_framebuffer_manager->GetEFBHeight();
u64 native_res_result = static_cast<u64>(m_query_result_buffer[i]) * EFB_WIDTH /
g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
g_framebuffer_manager->GetEFBHeight();
if (g_ActiveConfig.iMultisamples > 1)
native_res_result /= g_ActiveConfig.iMultisamples;
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
std::memory_order_relaxed);
}
Expand Down

0 comments on commit 91fca07

Please sign in to comment.