Some checks failed
release / linux/x86_64 (pull_request) Failing after 1m54s
release / freebsd/x86_64 (pull_request) Successful in 5m1s
release / linux/aarch64 (pull_request) Failing after 1m54s
release / linux/armv7 (pull_request) Failing after 2m12s
release / linux/i686 (pull_request) Failing after 1m59s
release / android (pull_request) Successful in 2m54s
release / windows/i686 (pull_request) Successful in 2m3s
release / windows/x86_64 (pull_request) Successful in 2m15s
52 lines
1.7 KiB
Lua
52 lines
1.7 KiB
Lua
-- 06: closing the window makes GPU finalizers skip instead of calling into a
|
|
-- dead GL context. The process must survive and report no errors.
|
|
local M = dofile("tests/helpers.lua")
|
|
local R = M.load()
|
|
|
|
if not M.window(64, 64) then
|
|
M.skip("06_teardown", "no window")
|
|
return
|
|
end
|
|
|
|
M.reset()
|
|
local img = R.GenImageColor(4, 4, R.RED)
|
|
local b = M.snapshot()
|
|
|
|
-- Hold every resource until after CloseWindow so nothing can be collected
|
|
-- while the GPU context is still alive.
|
|
local pool = {}
|
|
for i = 1, 5 do
|
|
pool[i] = R.LoadTextureFromImage(img)
|
|
M.ok(pool[i].id ~= 0, "texture " .. i .. " created")
|
|
end
|
|
pool[6] = R.GenImageColor(4, 4, R.WHITE)
|
|
pool[7] = R.GenImageColor(4, 4, R.BLUE)
|
|
-- Kept out of the pool so it can be explicitly unloaded after the window dies.
|
|
local late = R.LoadTextureFromImage(img)
|
|
M.eq(M.delta(b, "armed"), 8, "six textures and two images armed")
|
|
|
|
R.CloseWindow()
|
|
|
|
-- Explicit unload after CloseWindow must also be a safe no-op: no GL call, the
|
|
-- handle is zeroed, and the counters stay clean.
|
|
local rel = M.snapshot()
|
|
R.UnloadTexture(late)
|
|
M.eq(M.delta(rel, "errors"), 0, "explicit unload after CloseWindow is safe")
|
|
M.eq(M.delta(rel, "released"), 0, "explicit unload after CloseWindow is skipped")
|
|
M.eq(late.id, 0, "explicit unload after CloseWindow zeroes the handle")
|
|
late = nil
|
|
|
|
-- After CloseWindow the five texture finalizers must refuse to touch the dead
|
|
-- GPU context. The two RAM images may still be released.
|
|
pool = nil
|
|
M.gc(3)
|
|
M.ok(M.delta(b, "skipped") >= 5,
|
|
string.format("expected >=5 skipped finalizers, got %d",
|
|
M.delta(b, "skipped")))
|
|
M.eq(M.delta(b, "errors"), 0, "no finalizer errors after CloseWindow")
|
|
M.eq(M.delta(b, "released"), 2, "RAM images still released after CloseWindow")
|
|
|
|
img = nil
|
|
M.gc(2)
|
|
|
|
print("ok 06_teardown")
|