UnifiedSwapChain.cpp
| 53 | |
| 54 | // UnifiedSwapChain.cpp |
| 55 | std::vector<UnifiedSwapChain::ReadyItem> |
| 56 | UnifiedSwapChain::Enqueue(FrameData present, MetricsVersion version) |
| 57 | { |
| 58 | SanitizeDisplayedRepeatedPresents(present); |
| 59 | |
| 60 | std::vector<ReadyItem> out; |
| 61 | |
| 62 | // V1: FIFO (no buffering / no look-ahead). Every present is ready immediately. |
| 63 | if (version == MetricsVersion::V1) { |
| 64 | waitingDisplayed.reset(); |
| 65 | blocked.clear(); |
| 66 | out.push_back(ReadyItem{ std::move(present), nullptr, nullptr }); |
| 67 | return out; |
| 68 | } |
| 69 | |
| 70 | // Seed baseline |
| 71 | if (!swapChain.lastPresent.has_value()) { |
| 72 | SeedFromFirstPresent(std::move(present)); |
| 73 | return out; |
| 74 | } |
| 75 | |
| 76 | const bool isDisplayed = |
| 77 | (present.finalState == PresentResult::Presented) && |
| 78 | (!present.displayed.Empty()); |
| 79 | |
| 80 | if (isDisplayed) { |
| 81 | // 1) Finalize previously waiting displayed (if any), pointing at swapchain-owned next displayed. |
| 82 | if (waitingDisplayed.has_value()) { |
| 83 | FrameData prev = std::move(*waitingDisplayed); |
| 84 | waitingDisplayed = std::move(present); |
| 85 | |
| 86 | out.push_back(ReadyItem{ std::move(prev), nullptr, &*waitingDisplayed }); |
| 87 | } |
| 88 | else { |
| 89 | // First displayed: becomes the waitingDisplayed_. |
| 90 | waitingDisplayed = std::move(present); |
| 91 | } |
| 92 | |
| 93 | // 2) Release blocked not-displayed frames (owned, no look-ahead). |
| 94 | while (!blocked.empty()) { |
| 95 | out.push_back(ReadyItem{ std::move(blocked.front()), nullptr, nullptr }); |
| 96 | blocked.pop_front(); |
| 97 | } |
| 98 | |
| 99 | // 3) Current displayed is ready (all-but-last); provide a pointer so NV adjustments persist. |
| 100 | out.push_back(ReadyItem{ FrameData{}, &*waitingDisplayed, nullptr }); |
| 101 | return out; |
| 102 | } |
| 103 | |
| 104 | // Not displayed |
| 105 | if (waitingDisplayed.has_value()) { |
| 106 | blocked.push_back(std::move(present)); |
| 107 | return out; // nothing ready yet |
| 108 | } |
| 109 | |
| 110 | out.push_back(ReadyItem{ std::move(present), nullptr, nullptr }); |
| 111 | return out; |
| 112 | } |
no test coverage detected