diff --git a/public/tracy/TracyD3D12.hpp b/public/tracy/TracyD3D12.hpp index bca11809..74102b04 100644 --- a/public/tracy/TracyD3D12.hpp +++ b/public/tracy/TracyD3D12.hpp @@ -40,7 +40,6 @@ using TracyD3D12Ctx = void*; #include #include #include -#include #include namespace tracy @@ -62,8 +61,8 @@ namespace tracy ID3D12Device* m_device = nullptr; ID3D12CommandQueue* m_queue = nullptr; uint8_t m_contextId = 255; // TODO: apparently, 255 means "invalid id"; is this documented somewhere? - Microsoft::WRL::ComPtr m_queryHeap; - Microsoft::WRL::ComPtr m_readbackBuffer; + ID3D12QueryHeap* m_queryHeap = nullptr; + ID3D12Resource* m_readbackBuffer = nullptr; // In-progress payload. uint32_t m_queryLimit = MaxQueries; @@ -71,7 +70,7 @@ namespace tracy uint32_t m_previousQueryCounter = 0; uint32_t m_activePayload = 0; - Microsoft::WRL::ComPtr m_payloadFence; + ID3D12Fence* m_payloadFence = nullptr; std::queue m_payloadQueue; int64_t m_prevCalibration = 0; @@ -178,6 +177,14 @@ namespace tracy SubmitQueueItem(item); } + ~D3D12QueueCtx() + { + m_payloadFence->Release(); + m_readbackBuffer->Release(); + m_queryHeap->Release(); + } + + void NewFrame() { uint32_t queryCounter = m_queryCounter.exchange(0); @@ -189,7 +196,7 @@ namespace tracy m_previousQueryCounter -= m_queryLimit; } - m_queue->Signal(m_payloadFence.Get(), ++m_activePayload); + m_queue->Signal(m_payloadFence, ++m_activePayload); } void Name( const char* name, uint16_t len ) @@ -340,7 +347,7 @@ namespace tracy m_cmdList = cmdList; m_queryId = m_ctx->NextQueryId(); - m_cmdList->EndQuery(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId); + m_cmdList->EndQuery(m_ctx->m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, m_queryId); } public: @@ -389,7 +396,7 @@ namespace tracy if (!m_active) return; const auto queryId = m_queryId + 1; // Our end query slot is immediately after the begin slot. - m_cmdList->EndQuery(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, queryId); + m_cmdList->EndQuery(m_ctx->m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, queryId); auto* item = Profiler::QueueSerial(); MemWrite(&item->hdr.type, QueueType::GpuZoneEndSerial); @@ -399,7 +406,7 @@ namespace tracy MemWrite(&item->gpuZoneEnd.context, m_ctx->GetId()); Profiler::QueueSerialFinish(); - m_cmdList->ResolveQueryData(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId, 2, m_ctx->m_readbackBuffer.Get(), m_queryId * sizeof(uint64_t)); + m_cmdList->ResolveQueryData(m_ctx->m_queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, m_queryId, 2, m_ctx->m_readbackBuffer, m_queryId * sizeof(uint64_t)); } };