| 86 | } |
| 87 | |
| 88 | void Profiler::EndFrame() |
| 89 | { |
| 90 | currFrame = (currFrame + 1) % QueryLatency; |
| 91 | g_profilerStats.clear(); |
| 92 | |
| 93 | // Iterate over all of the profiles |
| 94 | ProfileMap::iterator iter; |
| 95 | for(iter = profiles.begin(); iter != profiles.end(); iter++) |
| 96 | { |
| 97 | ProfileData& profile = (*iter).second; |
| 98 | if(profile.QueryFinished == FALSE) |
| 99 | continue; |
| 100 | |
| 101 | profile.QueryFinished = FALSE; |
| 102 | |
| 103 | if(profile.DisjointQuery[currFrame] == NULL) |
| 104 | continue; |
| 105 | |
| 106 | // Get the query data |
| 107 | UINT64 startTime = 0; |
| 108 | while(context->GetData(profile.TimestampStartQuery[currFrame], &startTime, sizeof(startTime), 0) != S_OK); |
| 109 | |
| 110 | UINT64 endTime = 0; |
| 111 | while(context->GetData(profile.TimestampEndQuery[currFrame], &endTime, sizeof(endTime), 0) != S_OK); |
| 112 | |
| 113 | D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData; |
| 114 | while(context->GetData(profile.DisjointQuery[currFrame], &disjointData, sizeof(disjointData), 0) != S_OK); |
| 115 | |
| 116 | double time = 0.0; |
| 117 | if (disjointData.Disjoint == FALSE) { |
| 118 | UINT64 delta = endTime - startTime; |
| 119 | double frequency = static_cast<double>(disjointData.Frequency); |
| 120 | time = (delta / frequency) * 1000.0; |
| 121 | } |
| 122 | |
| 123 | if (-1 != profile.lastValue) { |
| 124 | const double blend = 0.1; |
| 125 | time = time * blend + profile.lastValue * (1.0 - blend); |
| 126 | } |
| 127 | |
| 128 | profile.lastValue = time; |
| 129 | |
| 130 | g_profilerStats += std::format("{}: {:2.2f}ms\n", (*iter).first, time); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | #else |
| 135 |
nothing calls this directly
no outgoing calls
no test coverage detected