mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
fix(framegen): an engine that lost the GPU is not re-armed after recovery
This commit is contained in:
1 parent
34fff40b56
commit
99f4d0ce3b
2 files changed
+226
No files matched your search
@@ -57,6 +57,8 @@ static int g_engine_cache_gen = -1;
|
||||
static int g_engine_ok;
|
||||
static _Atomic int g_failed_kind = -1;
|
||||
static _Atomic int g_failed_cache_gen = -1;
|
||||
static _Atomic int g_lost_kind = -1;
|
||||
static int g_gen_in_flight;
|
||||
|
||||
struct ring_image { VkImage img; VkDeviceMemory mem; VkImageView view; int fresh; };
|
||||
static struct ring_image g_ring[VKP_FG_MAX_GENERATIONS];
|
||||
@@ -102,6 +104,7 @@ void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
||||
if (multiplier > VKP_FG_MAX_GENERATIONS + 1) multiplier = VKP_FG_MAX_GENERATIONS + 1;
|
||||
if (atomic_exchange(&g_mult, multiplier) != multiplier) atomic_store(&g_cfg_dirty, 1);
|
||||
if (atomic_exchange(&g_target, target_fps) != target_fps) atomic_store(&g_cfg_dirty, 1);
|
||||
if (!armed) atomic_store(&g_lost_kind, -1);
|
||||
atomic_store(&g_armed, armed ? 1 : 0);
|
||||
LOGD("framegen: set_armed(%d, x%d, target %d fps)", armed, multiplier, target_fps);
|
||||
}
|
||||
@@ -135,6 +138,7 @@ void vkp_framegen_set_ddfg_tuning(int model, int perf_preset) {
|
||||
}
|
||||
|
||||
static int start_failed_for(int kind) {
|
||||
if (atomic_load(&g_lost_kind) == kind) return 1;
|
||||
return atomic_load(&g_failed_kind) == kind && atomic_load(&g_failed_cache_gen) == atomic_load(&g_cache_gen);
|
||||
}
|
||||
|
||||
@@ -196,6 +200,12 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
||||
}
|
||||
|
||||
void vkp_framegen_device_lost(void) {
|
||||
if (g_gen_in_flight && g_engine_ok) {
|
||||
atomic_store(&g_lost_kind, g_engine_kind);
|
||||
FGLOG("%s was generating when the display GPU was lost: it stays off until frame generation is turned "
|
||||
"on again", fge_engine_name(g_engine_kind));
|
||||
}
|
||||
g_gen_in_flight = 0;
|
||||
atomic_store(&g_dev_lost, 1);
|
||||
atomic_store(&g_dev_ready, 0);
|
||||
fge_device_lost();
|
||||
@@ -382,6 +392,7 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
int armed = atomic_load(&g_armed);
|
||||
int mult = atomic_load(&g_mult);
|
||||
g_planned = 0;
|
||||
g_gen_in_flight = 0;
|
||||
if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; }
|
||||
if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; }
|
||||
log_arm_transition(1, kind, mult);
|
||||
@@ -426,6 +437,7 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
uint32_t n_gen = fge_plan(g_ring_n, game_frames ? game_frames : g_source_frames, g_presented_rate);
|
||||
if (n_gen > g_ring_n) n_gen = g_ring_n;
|
||||
g_planned = n_gen;
|
||||
g_gen_in_flight = n_gen > 0;
|
||||
|
||||
VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS];
|
||||
uint32_t nb = 0;
|
||||
@@ -480,6 +492,7 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
}
|
||||
|
||||
void vkp_framegen_presented(int generated) {
|
||||
g_gen_in_flight = 0;
|
||||
if (generated < 0) generated = 0;
|
||||
int64_t now = now_ns();
|
||||
if (!g_window_start_ns) { g_window_start_ns = now; g_present_accum = 0; g_source_accum = 0; }
|
||||
|
||||
Reference in new issue
Block a user