mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
VideoBackends:Metal: Fix perf queries
Fixes an issue where perf queries could end up including counts from previous queries
This commit is contained in:
parent
ae18aa0639
commit
09c80513cd
@ -267,6 +267,7 @@ private:
|
||||
u32 texel_buffer_offset0;
|
||||
u32 texel_buffer_offset1;
|
||||
PerfQueryGroup perf_query_group = static_cast<PerfQueryGroup>(-1);
|
||||
u32 perf_query_id;
|
||||
} m_state;
|
||||
|
||||
u32 m_perf_query_tracker_counter = 0;
|
||||
|
@ -674,6 +674,7 @@ std::shared_ptr<Metal::StateTracker::PerfQueryTracker> Metal::StateTracker::NewP
|
||||
m_perf_query_tracker_counter++]];
|
||||
tracker->buffer = MRCTransfer(buffer);
|
||||
tracker->contents = static_cast<const u64*>([buffer contents]);
|
||||
tracker->query_id = m_state.perf_query_id;
|
||||
return tracker;
|
||||
}
|
||||
}
|
||||
@ -682,6 +683,8 @@ std::shared_ptr<Metal::StateTracker::PerfQueryTracker> Metal::StateTracker::NewP
|
||||
// Reuse an old one
|
||||
std::shared_ptr<PerfQueryTracker> tracker = std::move(m_perf_query_tracker_cache.back());
|
||||
m_perf_query_tracker_cache.pop_back();
|
||||
tracker->groups.clear();
|
||||
tracker->query_id = m_state.perf_query_id;
|
||||
return tracker;
|
||||
}
|
||||
}
|
||||
@ -689,15 +692,26 @@ std::shared_ptr<Metal::StateTracker::PerfQueryTracker> Metal::StateTracker::NewP
|
||||
void Metal::StateTracker::EnablePerfQuery(PerfQueryGroup group, u32 query_id)
|
||||
{
|
||||
m_state.perf_query_group = group;
|
||||
m_state.perf_query_id = query_id;
|
||||
if (!m_current_perf_query || m_current_perf_query->query_id != query_id ||
|
||||
m_current_perf_query->groups.size() == PERF_QUERY_BUFFER_SIZE)
|
||||
{
|
||||
if (m_current_render_encoder)
|
||||
EndRenderPass();
|
||||
if (!m_current_perf_query)
|
||||
m_current_perf_query = NewPerfQueryTracker();
|
||||
m_current_perf_query->groups.clear();
|
||||
m_current_perf_query->query_id = query_id;
|
||||
if (m_current_perf_query)
|
||||
{
|
||||
[m_current_render_cmdbuf
|
||||
addCompletedHandler:[backref = m_backref, q = std::move(m_current_perf_query)](id) {
|
||||
std::lock_guard<std::mutex> guard(backref->mtx);
|
||||
if (StateTracker* tracker = backref->state_tracker)
|
||||
{
|
||||
if (PerfQuery* query = static_cast<PerfQuery*>(g_perf_query.get()))
|
||||
query->ReturnResults(q->contents, q->groups.data(), q->groups.size(), q->query_id);
|
||||
tracker->m_perf_query_tracker_cache.emplace_back(std::move(q));
|
||||
}
|
||||
}];
|
||||
m_current_perf_query.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user