51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#include "XCEngine/RHI/D3D12/D3D12QueryHeap.h"
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
D3D12QueryHeap::D3D12QueryHeap()
|
|
: m_type(QueryType::Timestamp)
|
|
, m_count(0) {
|
|
}
|
|
|
|
D3D12QueryHeap::~D3D12QueryHeap() {
|
|
Shutdown();
|
|
}
|
|
|
|
bool D3D12QueryHeap::Initialize(ID3D12Device* device, QueryType type, uint32_t count) {
|
|
D3D12_QUERY_HEAP_DESC desc = {};
|
|
desc.Count = count;
|
|
desc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
|
|
desc.NodeMask = 0;
|
|
|
|
switch (type) {
|
|
case QueryType::Timestamp:
|
|
desc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
|
|
break;
|
|
case QueryType::Occlusion:
|
|
desc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION;
|
|
break;
|
|
case QueryType::PipelineStatistics:
|
|
desc.Type = D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS;
|
|
break;
|
|
}
|
|
|
|
HRESULT hResult = device->CreateQueryHeap(&desc, IID_PPV_ARGS(&m_queryHeap));
|
|
if (FAILED(hResult)) {
|
|
return false;
|
|
}
|
|
|
|
m_type = type;
|
|
m_count = count;
|
|
return true;
|
|
}
|
|
|
|
void D3D12QueryHeap::Shutdown() {
|
|
m_queryHeap.Reset();
|
|
m_type = QueryType::Timestamp;
|
|
m_count = 0;
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|