4.8 KiB
This repository: Crafter.Graphics
The execution contexts to enumerate, beside the charter's:
- One source, several builds.
project.cppdefines exactly one ofCRAFTER_GRAPHICS_WINDOW_WAYLAND,CRAFTER_GRAPHICS_WINDOW_WIN32andCRAFTER_GRAPHICS_WINDOW_DOMfrom the target: native Linux (Wayland and Vulkan),x86_64-w64-mingw32(Win32 and Vulkan, gamepads through Windows.Gaming.Input),wasm32-wasip1(the DOM and WebGPU, throughadditional/dom-env.jsandadditional/dom-webgpu.js) andaarch64-alpine-linux-musl(Mesa Turnip: no descriptor heap, no ray tracing). Code behind one backend's#ifdefis still the range's code, and a change to one backend's half can leave the other's behind. - One device, several paths, chosen at start-up: the descriptor heap or
the bindless descriptor-set fallback (
CRAFTER_GRAPHICS_NO_DESCRIPTOR_HEAPforces it), with each UI kernel's two SPIR-V builds; ray tracing or none (heap-only;Device::stageMaskdrops its stage without it); Vulkan 1.4 or 1.3 (CRAFTER_GRAPHICS_NO_VULKAN_1_4);swapchain_maintenance1or not; GPU memory decompression or the CPU path (Device::memoryDecompressionSupported); the NVIDIA AS workaround on or off (Device::workaroundDescriptorHeapAS,CRAFTER_GRAPHICS_NO_AS_WORKAROUND); llvmpipe on a machine without a GPU. - The GPU timeline. Three frames in flight, a fence each: what lives per
frame is keyed by
Window::currentFrame, what lives per swapchain image bycurrentImage, and the image count follows the present mode. A handle a frame in flight may still use is released through the deletion queue (freedframesInFlightframes later) or after a wait for the GPU; a freed descriptor slot is handed out again at once; a swapchain rebuild asked for from a listener mid-frame (Resize,SetPresentMode) waits for that frame's present, andonResizeruns after it; a static owner is destroyed after the driver is gone. Within one dispatch, Vulkan orders nothing between workgroups. - Re-entry from the platform. The Wayland listeners run inside
wl_display_dispatch,wl_display_dispatch_pendingandwl_display_roundtrip, which the frame loop, window creation,Device::Initializeand the clipboard's reads call. Windows calls the window procedure from the message loop and also synchronously from insideCreateWindowEx,SendMessageandDefWindowProc. The DOM's listeners indom-env.jscall the__crafterDom_*exports. A listener can resize, close or destroy the window it was called for. Windows.Gaming.Input reports gamepad connects and disconnects on threads of its own, queued under a lock until the event loop takes them. - Shared state:
Device's statics are process-wide;Device::frameCounteris one clock for every window, which the deletion queue, the staging rings and the font atlas's eviction run on; the deletion queue is shared underdeletionMutex. The caches keyed on aFont*alias a new font at a freed one's address unlessUIRenderer::InvalidateFontran. - Data the GPU and JavaScript read: an item or header struct is mirrored
byte for byte by a
std430block inshaders/ui-shared.glsl, by the WGSL indom-webgpu.jsand by every shader that includes it, the examples' among them; one push block serves both builds, throughvkCmdPushDataEXTon the heap andvkCmdPushConstantsin the set build, within 256 bytes. - Tests: each its own process, in parallel, with a 60 s timeout; every
test that calls
Device::Initializeneeds a Wayland display, and one that lacks a capability exits 77 and pins nothing on that machine. A validation check counts only in a run where the layer loaded.
Semantics to read on disk rather than recall: the Vulkan headers and
registry (include/vulkan/, registry/vk.xml) and Vulkan-Utility-Libraries
as cloned (~/.cache/crafter.build/external/Vulkan-Headers-<hash>/,
Vulkan-Utility-Libraries-<hash>/; several clones may sit side by side);
the Wayland protocols (/run/host/usr/share/wayland/wayland.xml,
/run/host/usr/share/wayland-protocols/, the generated code in lib/) and
the client headers (/run/host/usr/include/wayland-client*.h,
xkbcommon/); the MinGW headers (/run/host/usr/x86_64-w64-mingw32/include/);
libc++ and clang as the host installs them (/run/host/usr/include/c++/v1,
/run/host/usr/lib/clang/<major>/include); the vendored stb and libevdev
in lib/; Crafter.Event, Crafter.Math and Crafter.Asset as cloned
(~/.cache/crafter.build/external/<Name>-<hash>/). The crafter-build
Flatpak compiles with an LLVM of its own, which is not readable from
here: where a semantic may differ between LLVM releases, the host's
headers settle it for the host's build only. The Vulkan specification's
valid-usage rules, the WebGPU and WGSL specifications and Microsoft's API
documentation are not on disk: a semantic only they settle is unverified.