diff --git a/runtime/frame_rate.c b/runtime/frame_rate.c index 26642e40..76bebeee 100644 --- a/runtime/frame_rate.c +++ b/runtime/frame_rate.c @@ -198,6 +198,9 @@ uint64_t frame_step_cap_ns(void) { if (hz < LIMIT_MIN_HZ) hz = 60; // display rate unknown (no window yet) double max = frame_free_running() ? LIMIT_FREE_MAX_HZ : LIMIT_MAX_HZ; if (hz > max) hz = max; + // Frame generation presents a generated frame between each two of the game's (vk_fg.cpp): the game is paced at + // half the limit then, so the screen shows the limit + if (vk_fg_generating()) hz /= 2; rtss_limit_want(rtss ? (int64_t)(hz * 1000 + 0.5) : -1); if (rtss_limit_active()) return 0; return (uint64_t)(1e9 / hz + 0.5); diff --git a/runtime/vk_fg.cpp b/runtime/vk_fg.cpp index e87a905f..849c4d37 100644 --- a/runtime/vk_fg.cpp +++ b/runtime/vk_fg.cpp @@ -43,6 +43,7 @@ struct { uint64_t frame = 0; int failed = 0; uint64_t generated = 0, paused = 0, no_inputs = 0, hudless = 0; + int on = 0; // the last configured frame had generation on (vk_fg_generating) } F; VkResult submit_game(uint32_t n, const VkSubmitInfo *si, VkFence fence) { @@ -93,6 +94,8 @@ extern "C" void vk_fg_queues(VkQueue present, VkQueue acquire) { F.present = pre extern "C" int vk_fg_active(void) { return F.sc != nullptr && !F.failed; } +extern "C" int vk_fg_generating(void) { return vk_fg_active() && __atomic_load_n(&F.on, __ATOMIC_RELAXED); } + extern "C" VkResult vk_fg_create_swapchain(const VkSwapchainCreateInfoKHR *ci, VkSwapchainKHR *sc) { if (F.sc) return F.fn.pOutCreateSwapchainFFXAPI(vk_ctx()->device, ci, nullptr, sc, F.sc); if (!vk_fg_wanted() || F.failed || !F.present || !vk_ffx_load()) return VK_ERROR_FEATURE_NOT_PRESENT; @@ -195,6 +198,7 @@ extern "C" void vk_fg_frame(VkCommandBuffer cb, VkSwapchainKHR sc, VkFormat fmt, int reset = 0; int have = vk_dlaa_fg_inputs(&depth, &mv, &jx, &jy, &reset); int on = have && !menu_is_open(); + __atomic_store_n(&F.on, on, __ATOMIC_RELAXED); if (!have) F.no_inputs++; else if (!on) F.paused++; F.frame++; diff --git a/runtime/vk_fg.h b/runtime/vk_fg.h index ed91ae63..01b39b94 100644 --- a/runtime/vk_fg.h +++ b/runtime/vk_fg.h @@ -7,6 +7,7 @@ int vk_fg_wanted(void); // NX2NAVI_FRAMEGEN = fsr3 with DLS uint32_t vk_fg_queue_count(void); // graphics-family queues the device creates: 3 with frame generation, else 1 void vk_fg_queues(VkQueue present, VkQueue acquire); // vk_device.c, after the device exists int vk_fg_active(void); // the frame generation swapchain exists +int vk_fg_generating(void); // ... and the last frame had generation on (not paused for the menu) // gfx_present.c's swapchain calls while vk_fg_wanted: the first create makes AMD's swapchain context, later ones // (window resizes) its swapchain again. Non-success from the first: the plain swapchain path stays. VkResult vk_fg_create_swapchain(const VkSwapchainCreateInfoKHR *ci, VkSwapchainKHR *sc);