"""The start-up screen's drawing (gpu/vk/vk_startup_screen.h) with no game and no GPU: tests/startup_screen_preview.cpp plays a first start, an ordinary start, a start closed part-way and a start with nothing to prepare through the screen's own code, sixty pictures a second, into Dear ImGui's draw lists, and rasterizes the pictures of each state. Checked there: no picture puts a corner far outside the window, and the last picture lets the screen's textures go while drawing none of them. Checked here: every picture is written and is neither empty nor one flat colour, the stones are lit where the state says (dark glass before, the stone's own colour after), and the fade's last picture is black. Also what the game's start depends on in the files around it: vk_menu.cpp hands the view, the fade and a clock to the screen, and vk_main.cpp gives the screen the pass the preparation is in (vk_draw.cpp prepare_pass), so that the driver's part of the shaders is not shown under the translation's name. python -I -B tests/test_startup_screen.py [--cxx clang++] [--headers ] """ import argparse import importlib.util import struct import sys import tempfile from pathlib import Path RUN_ALL_ARGS = ["--cxx", "{cxx}", "--headers", "{vulkan_headers}"] ROOT = Path(__file__).resolve().parents[1] W, H = 960, 540 def picture(path): data = path.read_bytes() w, h = struct.unpack_from(" 90 and c[lead] > (2.4 if k == 2 else 1.6) * max(c[i] for i in range(3) if i != lead) return strong / ((x1 - x0) * (y1 - y0)) for name, lit in (("03-translating", ()), ("05-building-pipelines", (0,)), ("06-second-stone-ignites", (0, 1)), ("07-starting-the-game", (0, 1, 2)), ("13-with-the-drivers-part", (0,)), ("09-warm-start", (0, 1, 2)), ("09b-warm-start-stones-lit", (0, 1, 2)), ("10-warm-start-done", (0, 1, 2)), ("11-closing", ())): for k in range(3): share = stone(pics[name], k) if (share > 0.08) != (k in lit): raise SystemExit("FAIL: %s: stone %d is %s (%.0f%% of its box in its colour)" % (name, k, "lit" if share > 0.08 else "unlit", share * 100)) if max(mean(pics["08-fade"], (0, 0, 1, 1))) > 40: raise SystemExit("FAIL: the fade does not darken the screen") print("PASS: the start-up screen draws every state: %d pictures, the stones lit as the preparation goes" % len(pics)) if __name__ == "__main__": main()