| 110 | } |
| 111 | |
| 112 | void Profiler::EndProfile(ID3D12GraphicsCommandList* cmdList, uint64 idx) |
| 113 | { |
| 114 | if(enableGPUProfiling == false) |
| 115 | return; |
| 116 | |
| 117 | Assert_(idx < numProfiles); |
| 118 | |
| 119 | ProfileData& profileData = profiles[idx]; |
| 120 | Assert_(profileData.QueryStarted == true); |
| 121 | Assert_(profileData.QueryFinished == false); |
| 122 | |
| 123 | // Insert the end timestamp |
| 124 | const uint32 startQueryIdx = uint32(idx * 2); |
| 125 | const uint32 endQueryIdx = startQueryIdx + 1; |
| 126 | cmdList->EndQuery(queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, endQueryIdx); |
| 127 | |
| 128 | // Resolve the data |
| 129 | const uint64 dstOffset = ((DX12::CurrFrameIdx * MaxProfiles * 2) + startQueryIdx) * sizeof(uint64); |
| 130 | cmdList->ResolveQueryData(queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, startQueryIdx, 2, readbackBuffer.Resource, dstOffset); |
| 131 | |
| 132 | profileData.QueryStarted = false; |
| 133 | profileData.QueryFinished = true; |
| 134 | } |
| 135 | |
| 136 | uint64 Profiler::StartCPUProfile(const char* name) |
| 137 | { |