@@ -124,7 +124,7 @@ namespace
124124 outputPaddingSize_ = (uint16_t )util::GetPadding (nextAvailableByteOffset, alignof (FrameType));
125125 outputOffset_ = uint32_t (nextAvailableByteOffset) + outputPaddingSize_;
126126 }
127- void Gather (const Context& ctx, uint8_t * pDestBlob) const override
127+ void Gather (Context& ctx, uint8_t * pDestBlob) const override
128128 {
129129 auto val = ctx.pSourceFrameData ->present_event .Displayed_FrameType [ctx.sourceFrameDisplayIndex ];
130130 // Currently not reporting out not set or repeated frames.
@@ -238,7 +238,7 @@ namespace
238238 outputPaddingSize_ = (uint16_t )util::GetPadding (nextAvailableByteOffset, alignof (double ));
239239 outputOffset_ = uint32_t (nextAvailableByteOffset) + outputPaddingSize_;
240240 }
241- void Gather (const Context& ctx, uint8_t * pDestBlob) const override
241+ void Gather (Context& ctx, uint8_t * pDestBlob) const override
242242 {
243243 if (ctx.dropped ) {
244244 reinterpret_cast <double &>(pDestBlob[outputOffset_]) =
@@ -406,7 +406,7 @@ namespace
406406 outputPaddingSize_ = (uint16_t )util::GetPadding (nextAvailableByteOffset, alignof (double ));
407407 outputOffset_ = uint32_t (nextAvailableByteOffset) + outputPaddingSize_;
408408 }
409- void Gather (const Context& ctx, uint8_t * pDestBlob) const override
409+ void Gather (Context& ctx, uint8_t * pDestBlob) const override
410410 {
411411 if (ctx.dropped ) {
412412 reinterpret_cast <double &>(pDestBlob[outputOffset_]) =
@@ -591,7 +591,7 @@ namespace
591591 private:
592592 uint32_t outputOffset_;
593593 };
594- template <uint64_t PmNsmPresentEvent::* pStart, uint64_t PmNsmPresentEvent::* pEnd, bool doDroppedCheck, bool isMouseClick>
594+ template <uint64_t PmNsmPresentEvent::* pStart, bool doDroppedCheck, bool isMouseClick>
595595 class InputLatencyGatherCommand_ : public pmon ::mid::GatherCommand_
596596 {
597597 public:
@@ -612,25 +612,29 @@ namespace
612612
613613 double updatedInputTime = 0 .;
614614 double val = 0 .;
615- if (isMouseClick) {
616- updatedInputTime = ctx.lastReceivedNotDisplayedClickQpc == 0 ? 0 . :
617- TimestampDeltaToUnsignedMilliSeconds (ctx.lastReceivedNotDisplayedClickQpc ,
618- ctx.pSourceFrameData ->present_event .*pEnd, ctx.performanceCounterPeriodMs );
619- val = ctx.pSourceFrameData ->present_event .*pStart == 0 ? updatedInputTime :
620- TimestampDeltaToUnsignedMilliSeconds (ctx.pSourceFrameData ->present_event .*pStart,
621- ctx.pSourceFrameData ->present_event .*pEnd,
622- ctx.performanceCounterPeriodMs );
623- ctx.lastReceivedNotDisplayedClickQpc = 0 ;
624- }
625- else {
626- updatedInputTime = ctx.lastReceivedNotDisplayedAllInputTime == 0 ? 0 . :
627- TimestampDeltaToUnsignedMilliSeconds (ctx.lastReceivedNotDisplayedAllInputTime ,
628- ctx.pSourceFrameData ->present_event .*pEnd, ctx.performanceCounterPeriodMs );
629- val = ctx.pSourceFrameData ->present_event .*pStart == 0 ? updatedInputTime :
630- TimestampDeltaToUnsignedMilliSeconds (ctx.pSourceFrameData ->present_event .*pStart,
631- ctx.pSourceFrameData ->present_event .*pEnd,
632- ctx.performanceCounterPeriodMs );
633- ctx.lastReceivedNotDisplayedAllInputTime = 0 ;
615+ if (ctx.sourceFrameDisplayIndex == ctx.appIndex ) {
616+ if (isMouseClick) {
617+ updatedInputTime = ctx.lastReceivedNotDisplayedClickQpc == 0 ? 0 . :
618+ TimestampDeltaToUnsignedMilliSeconds (ctx.lastReceivedNotDisplayedClickQpc ,
619+ ctx.pSourceFrameData ->present_event .Displayed_ScreenTime [ctx.sourceFrameDisplayIndex ],
620+ ctx.performanceCounterPeriodMs );
621+ val = ctx.pSourceFrameData ->present_event .*pStart == 0 ? updatedInputTime :
622+ TimestampDeltaToUnsignedMilliSeconds (ctx.pSourceFrameData ->present_event .*pStart,
623+ ctx.pSourceFrameData ->present_event .Displayed_ScreenTime [ctx.sourceFrameDisplayIndex ],
624+ ctx.performanceCounterPeriodMs );
625+ ctx.lastReceivedNotDisplayedClickQpc = 0 ;
626+ }
627+ else {
628+ updatedInputTime = ctx.lastReceivedNotDisplayedAllInputTime == 0 ? 0 . :
629+ TimestampDeltaToUnsignedMilliSeconds (ctx.lastReceivedNotDisplayedAllInputTime ,
630+ ctx.pSourceFrameData ->present_event .Displayed_ScreenTime [ctx.sourceFrameDisplayIndex ],
631+ ctx.performanceCounterPeriodMs );
632+ val = ctx.pSourceFrameData ->present_event .*pStart == 0 ? updatedInputTime :
633+ TimestampDeltaToUnsignedMilliSeconds (ctx.pSourceFrameData ->present_event .*pStart,
634+ ctx.pSourceFrameData ->present_event .Displayed_ScreenTime [ctx.sourceFrameDisplayIndex ],
635+ ctx.performanceCounterPeriodMs );
636+ ctx.lastReceivedNotDisplayedAllInputTime = 0 ;
637+ }
634638 }
635639
636640 if (val == 0 .) {
@@ -834,9 +838,9 @@ std::unique_ptr<mid::GatherCommand_> PM_FRAME_QUERY::MapQueryElementToGatherComm
834838 case PM_METRIC_DISPLAY_LATENCY:
835839 return std::make_unique<DisplayLatencyGatherCommand_>(pos);
836840 case PM_METRIC_CLICK_TO_PHOTON_LATENCY:
837- return std::make_unique<InputLatencyGatherCommand_<&Pre::MouseClickTime, &Pre::ScreenTime, 1 , 1 >>(pos);
841+ return std::make_unique<InputLatencyGatherCommand_<&Pre::MouseClickTime, 1 , 1 >>(pos);
838842 case PM_METRIC_ALL_INPUT_TO_PHOTON_LATENCY:
839- return std::make_unique<InputLatencyGatherCommand_<&Pre::InputTime, &Pre::ScreenTime, 1 , 0 >>(pos);
843+ return std::make_unique<InputLatencyGatherCommand_<&Pre::InputTime, 1 , 0 >>(pos);
840844
841845 default :
842846 pmlog_error (" unknown metric id" ).pmwatch ((int )q.metric ).diag ();
@@ -851,11 +855,35 @@ void PM_FRAME_QUERY::Context::UpdateSourceData(const PmNsmFrameData* pSourceFram
851855 const PmNsmFrameData* pPreviousFrameDataOfLastDisplayed)
852856{
853857 pSourceFrameData = pSourceFrameData_in;
854- @@@ do manual merge from GameTechDev/main
855- sourceFrameDisplayIndex = 0 ;
858+ sourceFrameDisplayIndex = 0 ;
856859 dropped = pSourceFrameData->present_event .FinalState != PresentResult::Presented && pSourceFrameData->present_event .DisplayedCount == 0 ;
857- cpuStart = pFrameDataOfLastPresented->present_event .PresentStartTime + pFrameDataOfLastPresented->present_event .TimeInPresent ;
858- nextDisplayedQpc = pFrameDataOfNextDisplayed->present_event .Displayed_ScreenTime [0 ];
860+ if (dropped) {
861+ if (pSourceFrameData->present_event .MouseClickTime != 0 ) {
862+ lastReceivedNotDisplayedClickQpc = pSourceFrameData->present_event .MouseClickTime ;
863+ }
864+ if (pSourceFrameData->present_event .InputTime != 0 ) {
865+ lastReceivedNotDisplayedAllInputTime = pSourceFrameData->present_event .InputTime ;
866+ }
867+ }
868+
869+ if (pFrameDataOfLastPresented) {
870+ cpuStart = pFrameDataOfLastPresented->present_event .PresentStartTime + pFrameDataOfLastPresented->present_event .TimeInPresent ;
871+ }
872+ else {
873+ // TODO: log issue or invalidate related columns or drop frame (or some combination)
874+ pmlog_info (" null pFrameDataOfLastPresented" );
875+ cpuStart = 0 ;
876+ }
877+
878+ if (pFrameDataOfNextDisplayed) {
879+ nextDisplayedQpc = pFrameDataOfNextDisplayed->present_event .Displayed_ScreenTime [0 ];
880+ }
881+ else {
882+ // TODO: log issue or invalidate related columns or drop frame (or some combination)
883+ pmlog_info (" null pFrameDataOfNextDisplayed" );
884+ nextDisplayedQpc = 0 ;
885+ }
886+
859887 if (pFrameDataOfLastDisplayed && pFrameDataOfLastDisplayed->present_event .DisplayedCount > 0 ) {
860888 previousDisplayedQpc = pFrameDataOfLastDisplayed->present_event .Displayed_ScreenTime [pFrameDataOfLastDisplayed->present_event .DisplayedCount - 1 ];
861889 }
@@ -864,10 +892,13 @@ void PM_FRAME_QUERY::Context::UpdateSourceData(const PmNsmFrameData* pSourceFram
864892 pmlog_info (" null pFrameDataOfLastDisplayed" );
865893 previousDisplayedQpc = 0 ;
866894 }
895+
867896 if (pPreviousFrameDataOfLastDisplayed) {
868- previousDisplayedCpuStartQpc = pPreviousFrameDataOfLastDisplayed->present_event .PresentStartTime + pPreviousFrameDataOfLastDisplayed->present_event .TimeInPresent ;
897+ previousDisplayedCpuStartQpc = pPreviousFrameDataOfLastDisplayed->present_event .PresentStartTime +
898+ pPreviousFrameDataOfLastDisplayed->present_event .TimeInPresent ;
869899 }
870900 else {
901+ pmlog_info (" null pPreviousFrameDataOfLastDisplayed" );
871902 previousDisplayedCpuStartQpc = 0 ;
872903 }
873904 appIndex = 0 ;
0 commit comments