Skip to content

Commit e00d256

Browse files
Updating frame timing data structure and added pruning of old data
1 parent cab947f commit e00d256

File tree

7 files changed

+94
-82
lines changed

7 files changed

+94
-82
lines changed

IntelPresentMon/PresentMonMiddleware/ConcreteMiddleware.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,10 +1313,10 @@ static void ReportMetrics(
13131313
SetActiveGraphicsAdapter(*devId);
13141314
}
13151315

1316-
SimTrackingData appProvidedSimTrackingData{};
1317-
auto iter = appSimTrackingData.find(processId);
1318-
if (iter != appSimTrackingData.end()) {
1319-
appProvidedSimTrackingData = iter->second;
1316+
FrameTimingData currentFrameTimingData{};
1317+
auto iter = frameTimingData.find(processId);
1318+
if (iter != frameTimingData.end()) {
1319+
currentFrameTimingData = iter->second;
13201320
}
13211321

13221322
FakePMTraceSession pmSession;
@@ -1326,7 +1326,7 @@ static void ReportMetrics(
13261326
PM_FRAME_QUERY::Context ctx{
13271327
nsm_hdr->start_qpc,
13281328
pShmClient->GetQpcFrequency().QuadPart,
1329-
appProvidedSimTrackingData };
1329+
currentFrameTimingData };
13301330

13311331
while (frames_copied < frames_to_copy) {
13321332
const PmNsmFrameData* pCurrentFrameData = nullptr;
@@ -1410,7 +1410,16 @@ static void ReportMetrics(
14101410
}
14111411
// Set to the actual number of frames copied
14121412
numFrames = frames_copied;
1413-
appSimTrackingData[processId] = ctx.appProvidedSimTrackingData;
1413+
// Trim off any old flip delay data that resides in the FrameTimingData::flipDelayDataMap map
1414+
// that is older than the last displayed frame id.
1415+
for (auto it = ctx.frameTimingData.flipDelayDataMap.begin(); it != ctx.frameTimingData.flipDelayDataMap.end();) {
1416+
if (it->first < ctx.frameTimingData.lastDisplayedFrameId) {
1417+
it = ctx.frameTimingData.flipDelayDataMap.erase(it); // Erase and move to the next element
1418+
} else {
1419+
++it; // Move to the next element
1420+
}
1421+
}
1422+
frameTimingData[processId] = ctx.frameTimingData;
14141423
}
14151424

14161425
void ConcreteMiddleware::CalculateFpsMetric(fpsSwapChainData& swapChain, const PM_QUERY_ELEMENT& element, uint8_t* pBlob, LARGE_INTEGER qpcFrequency)

IntelPresentMon/PresentMonMiddleware/ConcreteMiddleware.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <queue>
99
#include "../CommonUtilities/Hash.h"
1010
#include "../CommonUtilities/Math.h"
11-
#include "AppProvidedData.h"
11+
#include "FrameTimingData.h"
1212

1313
namespace pmapi::intro
1414
{
@@ -212,8 +212,8 @@ namespace pmon::mid
212212
uint32_t clientProcessId = 0;
213213
// Stream clients mapping to process id
214214
std::map<uint32_t, std::unique_ptr<StreamClient>> presentMonStreamClients;
215-
// App provided simulation timing data for each process id
216-
std::map<uint32_t, SimTrackingData> appSimTrackingData;
215+
// Frame timing data for each process id
216+
std::map<uint32_t, FrameTimingData> frameTimingData;
217217
std::unique_ptr<ipc::MiddlewareComms> pComms;
218218
// Dynamic query handle to frame data delta
219219
std::unordered_map<std::pair<const PM_DYNAMIC_QUERY*, uint32_t>, uint64_t> queryFrameDataDeltas;

IntelPresentMon/PresentMonMiddleware/FrameEventQuery.cpp

Lines changed: 68 additions & 66 deletions
Large diffs are not rendered by default.

IntelPresentMon/PresentMonMiddleware/FrameEventQuery.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <vector>
55
#include <span>
66
#include <memory>
7-
#include "AppProvidedData.h"
7+
#include "FrameTimingData.h"
88

99
namespace pmapi::intro
1010
{
@@ -23,9 +23,9 @@ struct PM_FRAME_QUERY
2323
struct Context
2424
{
2525
// functions
26-
Context(uint64_t qpcStart, long long perfCounterFrequency, SimTrackingData& appProvidedSimTrackingData) : qpcStart{ qpcStart },
26+
Context(uint64_t qpcStart, long long perfCounterFrequency, FrameTimingData& frameTimingData) : qpcStart{ qpcStart },
2727
performanceCounterPeriodMs{ perfCounterFrequency != 0.f ? 1000.0 / perfCounterFrequency : 0.f },
28-
appProvidedSimTrackingData{ appProvidedSimTrackingData } {}
28+
frameTimingData{ frameTimingData } {}
2929
void UpdateSourceData(const PmNsmFrameData* pSourceFrameData_in,
3030
const PmNsmFrameData* pFrameDataOfNextDisplayed,
3131
const PmNsmFrameData* pFrameDataofLastPresented,
@@ -60,7 +60,7 @@ struct PM_FRAME_QUERY
6060
uint64_t mLastReceivedNotDisplayedPclSimStart = 0;
6161
// QPC of the last PC Latency pc input
6262
uint64_t mLastReceivedNotDisplayedPclInputTime = 0;
63-
SimTrackingData appProvidedSimTrackingData{};
63+
FrameTimingData frameTimingData{};
6464

6565
// Accumlated input to frame start time
6666
double mAccumulatedInput2FrameStartTime = 0.f;

IntelPresentMon/PresentMonMiddleware/AppProvidedData.h renamed to IntelPresentMon/PresentMonMiddleware/FrameTimingData.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct FlipDelayData {
1212
uint64_t displayQpc = 0;
1313
};
1414

15-
struct SimTrackingData {
15+
struct FrameTimingData {
1616
// QPC of the very first AppSimStartTime. This will either be from
1717
// the app provider or the PCL simulation start time.
1818
uint64_t firstAppSimStartTime = 0;
@@ -29,4 +29,5 @@ struct SimTrackingData {
2929
AnimationErrorSource animationErrorSource = AnimationErrorSource::CpuStart;
3030
// NVIDIA Flip Delay related data
3131
std::unordered_map<uint32_t, FlipDelayData> flipDelayDataMap{};
32+
uint32_t lastDisplayedFrameId = 0;
3233
};

IntelPresentMon/PresentMonMiddleware/PresentMonMiddleware.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313
<ItemGroup>
1414
<ClInclude Include="ActionClient.h" />
15-
<ClInclude Include="AppProvidedData.h" />
15+
<ClInclude Include="FrameTimingData.h" />
1616
<ClInclude Include="ConcreteMiddleware.h" />
1717
<ClInclude Include="DynamicQuery.h" />
1818
<ClInclude Include="FrameEventQuery.h" />

IntelPresentMon/PresentMonMiddleware/PresentMonMiddleware.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<ClInclude Include="ActionClient.h">
3737
<Filter>Header Files</Filter>
3838
</ClInclude>
39-
<ClInclude Include="AppProvidedData.h">
39+
<ClInclude Include="FrameTimingData.h">
4040
<Filter>Header Files</Filter>
4141
</ClInclude>
4242
</ItemGroup>

0 commit comments

Comments
 (0)