fix: simplify GPU init to match working examples (refreshSize + sleep(0) + setSize)
This commit is contained in:
@@ -43,42 +43,18 @@ local function findGPU()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function makeGpuBackend(gpu)
|
local function makeGpuBackend(gpu)
|
||||||
-- refreshSize() is async: it schedules the monitor-wall scan on the
|
-- refreshSize() schedules a server-thread monitor scan asynchronously.
|
||||||
-- server thread and returns immediately. Poll until blocksX or
|
-- sleep(0) yields back to the server, giving it a tick to finish.
|
||||||
-- blocksY grows, or we time out (2 s).
|
|
||||||
gpu.refreshSize()
|
gpu.refreshSize()
|
||||||
local pw, ph, bx, by, sb
|
sleep(0)
|
||||||
local deadline = os.clock() + 2
|
gpu.setSize(64)
|
||||||
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
|
|
||||||
|
|
||||||
-- If still 1x1 try once more after a longer wait, then proceed anyway.
|
local pw, ph, bx, by, sb = gpu.getSize()
|
||||||
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()
|
|
||||||
print(("[roulette] GPU pixel size: %sx%s blocks: %sx%s per-block: %s")
|
print(("[roulette] GPU pixel size: %sx%s blocks: %sx%s per-block: %s")
|
||||||
:format(tostring(pw), tostring(ph), tostring(bx), tostring(by), tostring(sb)))
|
: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
|
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)))
|
:format(tostring(pw), tostring(ph)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user