From 17225a66ee72195e67166dd6a0ac9f173abc61f0 Mon Sep 17 00:00:00 2001 From: itzmarkoni Date: Tue, 5 May 2026 18:25:15 -0400 Subject: [PATCH] fix: simplify GPU init to match working examples (refreshSize + sleep(0) + setSize) --- programs/roulette.lua | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/programs/roulette.lua b/programs/roulette.lua index 6c1447a..d1419b4 100644 --- a/programs/roulette.lua +++ b/programs/roulette.lua @@ -43,42 +43,18 @@ local function findGPU() end local function makeGpuBackend(gpu) - -- refreshSize() is async: it schedules the monitor-wall scan on the - -- server thread and returns immediately. Poll until blocksX or - -- blocksY grows, or we time out (2 s). + -- refreshSize() schedules a server-thread monitor scan asynchronously. + -- sleep(0) yields back to the server, giving it a tick to finish. gpu.refreshSize() - local pw, ph, bx, by, sb - local deadline = os.clock() + 2 - repeat - sleep(0.1) - pw, ph, bx, by, sb = gpu.getSize() - until ((bx or 0) > 1 or (by or 0) > 1) or os.clock() >= deadline + sleep(0) + gpu.setSize(64) - -- If still 1x1 try once more after a longer wait, then proceed anyway. - if (bx or 0) <= 1 and (by or 0) <= 1 then - sleep(0.5) - pw, ph, bx, by, sb = gpu.getSize() - end - - -- Try a high per-block resolution; fall back if GPU tier caps it. - local trySizes = { 64, 32, 16, 8 } - for _, s in ipairs(trySizes) do - if pcall(gpu.setSize, s) then break end - end - -- Re-read size after setSize (pixel dimensions change). - pw, ph, bx, by, sb = gpu.getSize() + local pw, ph, bx, by, sb = gpu.getSize() print(("[roulette] GPU pixel size: %sx%s blocks: %sx%s per-block: %s") :format(tostring(pw), tostring(ph), tostring(bx), tostring(by), tostring(sb))) - if (bx or 0) <= 1 and (by or 0) <= 1 then - print("[roulette] WARNING: GPU only sees 1 monitor block.") - print("[roulette] - GPU must be horizontally adjacent (N/S/E/W) to a monitor.") - print("[roulette] - All monitor blocks in the wall must face the SAME direction.") - print("[roulette] - The wall must be a solid rectangle of monitor blocks (no gaps).") - end - if not pw or not ph or pw < 8 or ph < 8 then - error(("GPU reports unusable pixel size %sx%s. Place at least one screen block adjacent to the GPU.") + error(("GPU reports unusable pixel size %sx%s.") :format(tostring(pw), tostring(ph))) end