Add new GPU Query API that is lightweight and supports occlusion queries

This commit is contained in:
Wojtek Figat
2026-01-16 10:40:30 +01:00
parent d2d7a871ce
commit 9ac231c403
31 changed files with 829 additions and 254 deletions

View File

@@ -1275,6 +1275,31 @@ void GPUContextDX12::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint
RENDER_STAT_DRAW_CALL(0, 0);
}
uint64 GPUContextDX12::BeginQuery(GPUQueryType type)
{
auto query = _device->AllocQuery(type);
if (query.Raw)
{
auto heap = _device->QueryHeaps[query.Heap];
if (type == GPUQueryType::Timer) // Timer queries call End twice on different queries to calculate duration between GPU time clocks
_commandList->EndQuery(heap->QueryHeap, heap->QueryType, query.SecondaryElement);
else
_commandList->BeginQuery(heap->QueryHeap, heap->QueryType, query.Element);
}
return query.Raw;
}
void GPUContextDX12::EndQuery(uint64 queryID)
{
if (queryID)
{
GPUQueryDX12 query;
query.Raw = queryID;
auto heap = _device->QueryHeaps[query.Heap];
_commandList->EndQuery(heap->QueryHeap, heap->QueryType, query.Element);
}
}
void GPUContextDX12::SetViewport(const Viewport& viewport)
{
_commandList->RSSetViewports(1, (D3D12_VIEWPORT*)&viewport);