removing windows/com header bloat

This commit is contained in:
Marcos Slomp 2023-09-11 12:01:21 -07:00
parent cf38d6a102
commit 6454b0bd65

View File

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