Merge pull request #448 from hulakdar/multithreaded_d3d12_zones

Multithreaded d3d12 zones
This commit is contained in:
Bartosz Taudul 2022-08-26 13:11:35 +02:00 committed by GitHub
commit 165099ca87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,7 +69,7 @@ namespace tracy
// In-progress payload. // In-progress payload.
uint32_t m_queryLimit = MaxQueries; uint32_t m_queryLimit = MaxQueries;
uint32_t m_queryCounter = 0; std::atomic<uint32_t> m_queryCounter = 0;
uint32_t m_previousQueryCounter = 0; uint32_t m_previousQueryCounter = 0;
uint32_t m_activePayload = 0; uint32_t m_activePayload = 0;
@ -179,9 +179,9 @@ namespace tracy
void NewFrame() void NewFrame()
{ {
m_payloadQueue.emplace(D3D12QueryPayload{ m_previousQueryCounter, m_queryCounter }); uint32_t queryCounter = m_queryCounter.exchange(0);
m_previousQueryCounter += m_queryCounter; m_payloadQueue.emplace(D3D12QueryPayload{ m_previousQueryCounter, queryCounter });
m_queryCounter = 0; m_previousQueryCounter += queryCounter;
if (m_previousQueryCounter >= m_queryLimit) if (m_previousQueryCounter >= m_queryLimit)
{ {
@ -297,10 +297,10 @@ namespace tracy
private: private:
tracy_force_inline uint32_t NextQueryId() tracy_force_inline uint32_t NextQueryId()
{ {
assert(m_queryCounter < m_queryLimit && "Submitted too many GPU queries! Consider increasing MaxQueries."); uint32_t queryCounter = m_queryCounter.fetch_add(2);
assert(queryCounter < m_queryLimit && "Submitted too many GPU queries! Consider increasing MaxQueries.");
const uint32_t id = (m_previousQueryCounter + m_queryCounter) % m_queryLimit; const uint32_t id = (m_previousQueryCounter + queryCounter) % m_queryLimit;
m_queryCounter += 2; // Allocate space for a begin and end query.
return id; return id;
} }