Skip to content

Commit 4c24f41

Browse files
authored
Merge pull request #321 from GameTechDev/bug/cyberpunk-ft-issue
Fix for incorrect FrameTime metric calculation.
2 parents 9ff04eb + 0a8eb7c commit 4c24f41

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

IntelPresentMon/PresentMonAPI2Tests/CsvHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void CharConvert<T>::Convert(const std::string data, T& convertedData, Header co
239239
else if (data == "Composed: Copy with CPU GDI") {
240240
convertedData = PM_PRESENT_MODE_COMPOSED_COPY_WITH_CPU_GDI;
241241
}
242-
else if (data == "Hardware: Composed Independent Flip") {
242+
else if (data == "Hardware Composed: Independent Flip") {
243243
convertedData = PM_PRESENT_MODE_HARDWARE_COMPOSED_INDEPENDENT_FLIP;
244244
}
245245
else {

IntelPresentMon/PresentMonMiddleware/FrameEventQuery.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ namespace
263263
CpuFrameQpcGatherCommand_(size_t nextAvailableByteOffset) : outputOffset_{ (uint32_t)nextAvailableByteOffset } {}
264264
void Gather(const Context& ctx, uint8_t* pDestBlob) const override
265265
{
266-
reinterpret_cast<uint64_t&>(pDestBlob[outputOffset_]) = ctx.cpuFrameQpc;
266+
reinterpret_cast<uint64_t&>(pDestBlob[outputOffset_]) = ctx.cpuStart;
267267
}
268268
uint32_t GetBeginOffset() const override
269269
{
@@ -298,7 +298,7 @@ namespace
298298
return;
299299
}
300300
}
301-
const auto val = TimestampDeltaToUnsignedMilliSeconds(ctx.cpuFrameQpc,
301+
const auto val = TimestampDeltaToUnsignedMilliSeconds(ctx.cpuStart,
302302
ctx.pSourceFrameData->present_event.*pEnd, ctx.performanceCounterPeriodMs);
303303
reinterpret_cast<double&>(pDestBlob[outputOffset_]) = val;
304304
}
@@ -394,7 +394,7 @@ namespace
394394
}
395395
}
396396
const auto val = TimestampDeltaToMilliSeconds(ctx.pSourceFrameData->present_event.*pStart - ctx.previousDisplayedQpc,
397-
ctx.cpuFrameQpc - ctx.previousDisplayedCpuStartQpc, ctx.performanceCounterPeriodMs);
397+
ctx.cpuStart - ctx.previousDisplayedCpuStartQpc, ctx.performanceCounterPeriodMs);
398398
reinterpret_cast<double&>(pDestBlob[outputOffset_]) = val;
399399
}
400400
uint32_t GetBeginOffset() const override
@@ -419,10 +419,12 @@ namespace
419419
CpuFrameQpcFrameTimeCommand_(size_t nextAvailableByteOffset) : outputOffset_{ (uint32_t)nextAvailableByteOffset } {}
420420
void Gather(const Context& ctx, uint8_t* pDestBlob) const override
421421
{
422-
const auto qpcDuration = (ctx.pSourceFrameData->present_event.PresentStartTime - ctx.cpuFrameQpc) +
423-
ctx.pSourceFrameData->present_event.TimeInPresent;
424-
const auto val = ctx.performanceCounterPeriodMs * double(qpcDuration);
425-
reinterpret_cast<double&>(pDestBlob[outputOffset_]) = val;
422+
const auto cpuBusy = TimestampDeltaToUnsignedMilliSeconds(ctx.cpuStart, ctx.pSourceFrameData->present_event.PresentStartTime,
423+
ctx.performanceCounterPeriodMs);
424+
const auto cpuWait = TimestampDeltaToMilliSeconds(ctx.pSourceFrameData->present_event.TimeInPresent,
425+
ctx.performanceCounterPeriodMs);
426+
427+
reinterpret_cast<double&>(pDestBlob[outputOffset_]) = cpuBusy + cpuWait;
426428
}
427429
uint32_t GetBeginOffset() const override
428430
{
@@ -662,12 +664,12 @@ void PM_FRAME_QUERY::Context::UpdateSourceData(const PmNsmFrameData* pSourceFram
662664
pSourceFrameData = pSourceFrameData_in;
663665
dropped = pSourceFrameData->present_event.FinalState != PresentResult::Presented;
664666
if (pFrameDataOfLastPresented) {
665-
cpuFrameQpc = pFrameDataOfLastPresented->present_event.PresentStartTime + pFrameDataOfLastPresented->present_event.TimeInPresent;
667+
cpuStart = pFrameDataOfLastPresented->present_event.PresentStartTime + pFrameDataOfLastPresented->present_event.TimeInPresent;
666668
}
667669
else {
668670
// TODO: log issue or invalidate related columns or drop frame (or some combination)
669671
pmlog_info(L"null pFrameDataOfLastPresented");
670-
cpuFrameQpc = 0;
672+
cpuStart = 0;
671673
}
672674
if (pFrameDataOfNextDisplayed) {
673675
nextDisplayedQpc = pFrameDataOfNextDisplayed->present_event.ScreenTime;

IntelPresentMon/PresentMonMiddleware/FrameEventQuery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct PM_FRAME_QUERY
3434
const uint64_t qpcStart{};
3535
bool dropped{};
3636
// Start qpc of the previous frame, displayed or not
37-
uint64_t cpuFrameQpc = 0;
37+
uint64_t cpuStart = 0;
3838
// Start qpc of the previously DISPLAYED frame.
3939
uint64_t previousDisplayedCpuStartQpc = 0;
4040
// Screen time qpc of the previously displayed frame.

0 commit comments

Comments
 (0)