Files
DroidDeck/tools/tests/test_effects_source_resolution.py
T
+1 3733c50902 feat: non-Adreno graphics stack (Venus, open driver pairs, gamescope patches) (#2029)
* Retain compositor resources when GPU completion is unconfirmed

* Stop quarantined GPU callers before retries and mapped writes

* Support Android hardware-buffer presentation over Wayland

* Support PowerVR swapchains and linear image imports in Gamescope

* Bundle verified PowerVR graphics components through existing build preparation

* Detect and select the system Vulkan backend on PowerVR

* Apply PowerVR Steam and game compatibility during normal launches

* Show PowerVR support through existing driver and component controls

* Update existing hardware guidance for system Vulkan support

* Import the shared system Vulkan readiness check

* Discover and propagate the actual PowerVR render node

* Prune obsolete PowerVR runtimes after guest processes exit

* Retain external DMA-BUF ownership after GPU quarantine

* Name the PowerVR HAL selection explicitly

* Isolate component UI tests from application startup

* Cover the inherited FEX preset in PowerVR profile tests

* Log test worker failures for CI diagnosis

* Remove temporary test logging after diagnostic CI

* Prefer system dependencies for the Android Vulkan loader

* Capture raw stderr before test worker termination

* Remove the temporary test worker crash probe

* Import pinned DXVK recipe prerequisite from PowerVR PR570

Copy only the standalone build recipe, source pin, BC-format prerequisite
and presentation-sync patch/check from wallentx/DroidDeck at d0f7264ea8.
Source: https://github.com/Droid-Deck/DroidDeck/pull/570
Preserve that proposal attribution; no Android app, compositor, managed
pack, private data or fork development history is imported.

* Add opt-in low32 GPU mapping adapter and integrity probes

* Add opt-in D3D9 single-sample workaround and fix HUD texel format

* Document verified production game workaround and publication scope

* Restrict reset diagnostics and create private output atomically

* Target official runtime review and document PR570 prerequisite provenance

* Fix runtime tool output isolation, mmap64 chaining and DST ambiguity

* Normalize swapchain backbuffers for the opt-in D3D9 single-sample path

* Experimental Samsung Xclipse support on the system Vulkan path

Detect Samsung's Vulkan HAL (vulkan.samsung.so) and its sgpu render node
alongside PowerVR, and run Xclipse through the same libhybris bridge:

- VK_LAYER_DROIDDECK_xclipse (tools/linuxfs/xclipse-layer), built with the
  glibc preloads and enabled only on Xclipse: sets bionic's environ for the
  driver's shader compiler, avoids immutable YCbCr samplers in compute
  layouts, forwards the KHR calibrated-timestamp entry points to the EXT
  ones, and reports textureCompressionBC and BC4/BC5 filtering over the
  compat layer's BC emulation.
- Upstream DXVK 2.6.2, pinned as a tar.gz component and selected on Xclipse:
  the driver has 128 bytes of push constants, DXVK 3 needs 256.
- android_wlegl accepts a zero stride and passes it through unchanged:
  Samsung's gralloc records none for GPU-only buffers.

Tested on a Galaxy A56 (Xclipse 540, driver 24.0.560): Steam Big Picture
and PICO PARK (D3D9).

* Xclipse layer: copy the device chain and track samplers per device

- Clear textureCompressionBC in a copy of the device-create chain (every
  structure up to the VkPhysicalDeviceFeatures2 that enables it) instead of
  writing the caller's structure; a chain led by a structure of unknown size
  is passed on unchanged.
- Track YCbCr samplers per device in a growable list, drop them on
  vkDestroySampler and device teardown, and fail sampler creation rather
  than leave one untracked when the list cannot grow.
- Fail descriptor set layout creation with VK_ERROR_OUT_OF_HOST_MEMORY when
  a replacement sampler array cannot be allocated, instead of passing the
  original YCbCr samplers to the driver.

* Xclipse layer: copy any device-chain structure the headers define

The chain copy that clears the emulated textureCompressionBC only knew a
handful of structure sizes, so a valid chain such as
VkPhysicalDeviceTimelineSemaphoreFeatures -> VkPhysicalDeviceFeatures2 was
passed on unchanged and the compat layer refused the bit. Size every
structure that may extend VkDeviceCreateInfo from a table generated from the
Vulkan registry (gen_device_chain.py, Vulkan-Headers 1.3.275, the headers
the build compiles with), and copy onto the heap instead of a fixed buffer.
Only a structure newer than those headers still passes the chain unchanged.

Add a regression test that runs the layer between a simulated loader and a
mock driver: the timeline-semaphore chain, pEnabledFeatures, an unknown
structure, the caller's structures left untouched, per-device YCbCr sampler
tracking with handle reuse, and the KHR calibrated-timestamp forwarding. CI
installs libvulkan-dev for it.

* Mali bridge (#517, by ASEbrahim) on the non-Adreno test branch

Squash of Droid-Deck/DroidDeck#517 (ASEbrahim/DroidDeck mali-bridge @ 6b823341): the Vulkan
bridge (tools/vkbridge) that runs the guest's Vulkan on the phone's own driver, with BC1-BC7,
clip/cull distance, vertex-divisor and depth-clip emulation and dma-heap memory sharing for Mali.
All of the bridge is ASEbrahim's work; squashed only to carry it on this test branch.

Combined with #570 on this branch, a device draws through exactly one path:
- Adreno: Turnip, unchanged (checked first; the bridge setting is ignored there).
- PowerVR / Xclipse with the system HAL and a render node: the system-Vulkan path (#570).
- Anything else with the Setup toggle on (Mali): the bridge.

* Test branch: keep #570's DXVK build recipe so its pinned PowerVR components verify

#602 adds output checks to tools/dxvk/build.sh; tools/powervr/fetch.py pins the exact
recipe the published PowerVR DXVK was built from, so the branch carries #570's copy.

* Test branch: make #570, #602 and #560/#561 pass each other's tests

- tools/dxvk/build.sh: #602's copy (its output checks) and the PowerVR pin in
  tools/powervr/release.json moved to that file's hash; the recipe's outputs are unchanged.
- droiddeck-session: the presentation block sets _bl_cef for #570's PowerVR path, and the UI
  block keeps main's order, defaulting to -cef-use-angle=vulkan when the block has not run.
- Compositor test harnesses: AHardwareBuffer stubs for #570's AHB import, and a stub for
  vkp_effects_forget_image (main #597) that #561's caller harness predates.

* Auto drivers for Mali and Xclipse on the non-Adreno test branch

Auto now picks an open driver pair for the GPU, the way it does for Adreno:
- Mali (no KGSL, /dev/mali0): the GPU's name ("Mali-G720-Immortalis MC12", from the vendor
  Vulkan driver or kbase's gpuinfo) picks the PanVK build: G52-G78 (Job Manager), G610/G710,
  G615 or G720. A Mali none of them covers (G925...), or one whose pair is not published yet,
  draws through the Mali bridge, switched on by Auto.
- Xclipse keeps the system-driver path as Auto; the RADV pair is offered as a manual choice.
- The pairs come from The412Banner/droiddeck-nonadreno-drivers (one pre-release per driver,
  each a DriverBundle zip). Only a device without an Adreno reads that repo.
- The importers accept PanVK and RADV libraries (libvulkan_panfrost / libvulkan_radeon).
- An open driver pair and the Mali bridge are alternatives: a selected pair turns the bridge off.
- TU_DEBUG is only set for Turnip, on an Adreno.

Every new branch is reached only when the device has no Adreno; an Adreno's detection, release
sources, Auto choice and session environment are unchanged.

* Auto: the one-binary PanVK kbase build for Mali v9-v13 on Android 15+

The412Banner/droiddeck-nonadreno-drivers adds panvk-mali-kbase: one PanVK build for
G57/G68/G77/G78, G610/G710, G615/G715, G720/G725 and G925, whose display half needs Android 15.
On Android 15+ Auto prefers it for every Mali it covers; below 15, and whenever its release is
not listed, Auto falls back to the GPU generation's own pair. G52/G76 keep the Job Manager
build; a G715/G725/G925 below Android 15, or any Mali no pair covers, draws through the bridge.
Every pair stays selectable by hand.

* Test: the G925 is in the kbase build's family now

* Offer faux123's device PanVK builds (RP4 Pro, Ace, RG556) as manual pairs for their Mali

* Detailed graphics logs for non-Adreno test reports

- graphics-report.txt in every session folder: the graphics path the session draws with and why
  (Turnip, system Vulkan #570, Mali bridge #517, or an open driver pair with its release), the
  driver mode and choices, what Auto would pick, the GPU (family, Vulkan device name, kbase
  gpuinfo, Android, SoC, kernel), the GPU nodes the app can see (access, device numbers, SELinux
  label; nothing is opened) and the guest's graphics environment. At the end it adds the
  compositor's driver lines from app.log and the game launches that were logged.
- vulkan-summary.txt: the session's own vulkaninfo --summary with the driver as exported, in the
  background with a 10 s timeout.
- Per-game logs under games/<time>-<appid>/: Proton's log, DXVK's and vkd3d-proton's, Mesa's and
  PanVK's startup messages and the launch environment, from droiddeck-game-env. Each file is cut
  to 20 MB and the folder to 120 MB at the session's end.
- The per-game logs and the Vulkan summary are on for a GPU that is not an Adreno, and on an
  Adreno only with Setup's new "Detailed graphics logs" switch. Share logs already takes the
  whole session folder, so all of it is in the zip, scrubbed as before.

* Mali pairs: a stand-in render node, the driver's real library name, and a Mali known by its chip

- Auto on Jim's Dimensity 9300+ chose the bridge: the GPU had no name (the app had not asked
  Vulkan yet and kbase's gpuinfo is unreadable under SELinux), so a Mali-G720 counted as a Mali
  no build covers. The name now falls back to the GPU the chip is known to carry (Dimensity,
  Helio, Kompanio, Tensor); and when nothing names it, Auto asks the vendor Vulkan driver off the
  main thread before it settles for the bridge. Auto logs what it decided and why.
- An open Mali driver pair gets /dev/mali0 as the guest's render node, as the bridge does
  (bindGpuNode, BL_DRM_STANDIN): gamescope needs the node the driver reports. The session shim
  only answers libdrm's PRIME and GEM-close calls on it, which PanVK on kbase never makes.
- A PanVK or RADV runtime half is installed as libvulkan_panfrost.so / libvulkan_radeon.so rather
  than under Turnip's name; Turnip keeps libvulkan_freedreno.so.
- graphics-report.txt names the render node the guest got, adds the session script's driver lines
  and flags a failed Mali-bridge self-test at the top.

* Auto takes the RADV pair on a Samsung Xclipse, with the system route as its fallback

A tester's Galaxy S24 FE (Xclipse 940) boots to Steam with the RADV-Xclipse pair, where the
system-driver route fails at Steam's OpenGL (glamor and GLX cannot load a driver). Auto now
downloads and selects RADV on an Xclipse like the Mali pairs, and falls back to the system route
only when RADV is not published. #570's reset of both drivers at each start no longer undoes an
open driver pair. PowerVR (vulkan.powervr.so) keeps the system driver as before.

* An Exynos with a Mali is a Mali, not an Xclipse

The system route took vulkan.samsung.so as Samsung's Xclipse, but an Exynos 1280/1380 (Galaxy Tab
S9 FE: Mali-G68) may name its HAL the same; with /dev/mali0 present that HAL is not the system
route's, and the device is detected as the Mali it is. The chip table adds the Exynos 1380 and
1280 (s5e8835, s5e8825: Mali-G68).

* Auto fetches the open drivers itself; Xclipse named as such; sound and frame-gen in the logs

- Auto looks online again when its saved release list predates this device's open drivers, so a
  Samsung or Mali phone gets its pair without pressing refresh first.
- A Samsung Xclipse is labelled "Samsung Xclipse" (not PowerVR), with its own support line.
- Per-game logs add audio-streams.txt: PulseAudio's sink inputs 20 s and 60 s into the launch,
  so a silent game shows whether its stream reached Pulse.
- graphics-report.txt states the frame-generation setting and keeps the LSFG gate, FrameGen and
  audio lines from app.log.

* Client sound retries a briefly disconnected AAudio; kbase ioctl refusals explained in the report

A Galaxy S24 FE's session had no sound at all: the DirectAudio sink's AAudio stream opened with
AAUDIO_ERROR_DISCONNECTED while the output route was still changing at session start, and the
plain AAudio fallback failed the same moment. The sink guard now retries DirectAudio, then the
plain sink, five times over ten seconds and says which one it got. graphics-report.txt keeps the
client-sink and kbase lines, and explains a KBASE_IOCTL_MEM_EXEC_INIT EPERM as the kbase driver's
own answer rather than the session's sandbox.

* Mali pairs draw the display on the phone's own Mali driver; Xwayland falls back without glamor

- Testers' Mali pairs got the guest drawing (gamescope on the stand-in node, Zink on PanVK) but
  the compositor's PanVK Android half failed on Mali gralloc: it probes AHB formats 0x38/0x3b that
  mali_gralloc does not have, and "vkCreateImage w/ native buffer failed". Under Auto a Mali pair
  now leaves the display on the phone's own Vulkan driver (dma-buf, modifiers and AHB all pass the
  testers' checks) and runs the pair's PanVK in the guest; the Android half stays installed for a
  manual pick. "Pair in use" now follows the runtime half.
- A session after one whose Xwayland crashed (segfault, then gamescope's X11 I/O error) starts
  Xwayland with XWAYLAND_NO_GLAMOR=1 on a non-Adreno device, and says so in app.log.
- graphics-report.txt names the display driver the compositor used, and keeps gralloc, dma-buf,
  modifier and import lines from app.log and Xwayland's own lines from the session log.

* Non-Adreno sound: the daemon falls back on its own; the build's commit in device.txt and the report

The S24 FE's session still had no sound: its AAudio refuses DirectAudio's low-latency stream with
AAUDIO_ERROR_DISCONNECTED, and the sink guard never got to retry because pactl did not reach the
daemon in time ("the daemon did not answer in 15 s"). On a GPU that is not an Adreno the daemon's
own start-up script now asks DirectAudio again without low latency and loads the plain AAudio sink
underneath it, so a default sink exists whatever pactl does. device.txt and graphics-report.txt
name the build label and source commit, so a log says which build it came from.

* Non-Adreno sound: no second DirectAudio load (it hung the daemon); the plain AAudio sink underneath

On the S24 FE the daemon stopped after DirectAudio's failed low-latency load: the second
DirectAudio load in the same daemon never returned, so nothing after it ran and pactl never
connected. The daemon now loads only the plain AAudio sink (no low latency) after DirectAudio,
inside .nofail, and sets whichever exists as the default.

* gamescope: explicit sync off where the kernel or the stand-in node cannot signal its timelines

Adds tools/gamescope/patches/0126 (GAMESCOPE_DISABLE_EXPLICIT_SYNC=1 for the nested backends) and
sets it on a GPU that is not an Adreno when the kernel is older than 6.6 (no
DRM_IOCTL_SYNCOBJ_EVENTFD) or the guest's render node is Mali's stand-in. The graphics report
lists it with the rest of the guest's graphics environment.

* Test branch: gamescope with the explicit-sync switch (0126), pinned by sha

Built by build-gamescope.yml run 38335744351 from 0136fb61 and published as a component release
of The412Banner/droiddeck-nonadreno-drivers; the apk build fetches it by tag and checks the sha.

* Sound: nothing that can block in the daemon's start-up; Steam's web compositing in software on open pairs

- The S24 FE (US) daemon hung loading the plain AAudio sink from default.pa (its AAudio open
  blocks rather than fails), so it never finished starting. default.pa is back to DirectAudio
  alone inside .nofail; the fallbacks are loaded from the app once the daemon answers, each pactl
  bounded by its timeout (DirectAudio, then the plain sink with and without low latency). The
  guard waits 30 s and logs, with timestamps, how long the daemon took, whether its socket and
  pactl exist, and what it finally got.
- With an open driver pair on a GPU that is not an Adreno, Steam's CEF composites in software
  (-cef-disable-gpu-compositing) with GPU raster kept: RADV on Xclipse showed stale, half-written
  tiles, as #570 saw on PowerVR. The session log says so.

* Mali under Auto: the display always on Android's own Vulkan loader; a reboot hint for refused audio

Axel's Tab S9 FE still drew its display with the PanVK Android half, set by an earlier build, and
stalled at "Waiting for Steam's first frame" on Mali gralloc's format probes. Under Auto a Mali's
display now goes to Android's own loader whatever was set before (DriverMenus resets it, and the
compositor's driver choice ignores a pair's Android half), with no HAL path to find first. A pair
counts as in use when its runtime half is. A manual pick of the PanVK display is kept.
When audio.log shows AAUDIO_ERROR_DISCONNECTED, the report and the client-sink line say Android
refused the output and that rebooting the phone usually fixes it.

* Fix: call SessionPrefs.gpuDriverMode through its instance from Java

* Compositor: log each new dma-buf format/modifier/size it imports (for colour and swizzle reports)

Steam's software web compositing already covers every open driver pair, Mali included.

* Open driver pairs: vkd3d-proton reports the driver's caps; buffer attach/release tracing; Mesa log

- With a PanVK or RADV pair (BL_OPEN_DRIVER=1), droiddeck-game-env drops the app-wide
  VKD3D_FEATURE_LEVEL=12_2 and VKD3D_SHADER_MODEL=6_9 so vkd3d-proton reports what the driver has
  (an Unreal DX12 game crashed at start on PanVK with the overrides); a game's own setting still
  wins, and launch.txt records DROIDDECK_VKD3D_CAPS=driver.
- The compositor traces, on a GPU that is not an Adreno, the first 400 dma-buf attaches and buffer
  releases by wl_buffer id and sending line, and logs any release of a buffer already released
  and not attached again (gamescope's "Compositor released us but we were not acquired" on G925).
- Per-game logs no longer set MESA_DEBUG=silent, which kept mesa.log empty.

* Tests: the dma-buf quarantine harness follows send_buffer_release's tracing macro

* Mali (Venus): David Cimo's Venus route sources and recipes

From DavidCimo/droiddeck-mali, branch mali-venus @ 4f838891 (prototype 13; his 12 commits on top
of DroidDeck 0.3.1, GPL-3.0), by David Cimo:
- tools/venus: Mesa Venus vtest patch (incl. the per-queue submit_mutex fix and the cached-memory
  frame readback), virglrenderer Android patch, the Mali compatibility layer (the six features
  DXVK needs: fill modes, multi-viewport, robustness2, clip/cull distance, BC1-BC7) and his tools.
- tools/linuxfs/preload/venus.c: keeps Zink's kopper under Venus.
- tools/gamescope/patches/0127 (his 0114): shm buffers uploaded on every commit.
- docs/development/mali-venus.md: his design notes.
- tools/venus/ci-build.sh and build-venus.yml: his build recipes as one CI job that packs the
  component (vtest server, ICD, layer) as venus.tzst for the apk.

Co-authored-by: Dersim Abbas <derabb0620@gmail.com>

* Mali (Venus) as a selectable route, by David Cimo

Ports David Cimo's Venus route (DavidCimo/droiddeck-mali, mali-venus @ 4f838891) onto this branch
as "Mali (Venus)", one tap in Setup next to the Mali bridge:
- VenusComponent (his): stages the Venus ICD and runs virglrenderer's vtest server over the
  phone's own Vulkan driver; the guest gets VK_ICD_FILENAMES, VN_DEBUG=vtest, VTEST_SOCKET_NAME and
  MESA_VK_WSI_DEBUG=sw.
- Selection rule: Venus when Setup's "Mali (Venus)" is on, on a GPU that is neither an Adreno nor
  a system-driver one (PowerVR, Xclipse), and the apk carries it. It then replaces the Mali bridge
  and any open driver pair for the session, and the display stays on the phone's own driver.
  Auto is unchanged (the PanVK pair). Adreno never takes any of it.
- The compositor enables only the dma-buf extensions the driver has, logs a vendor driver's
  extension list, and gives a zero row pitch a packed row (his vk_present.c changes).
- The Mali compatibility layer is staged into the runtime on non-Adreno devices only.
- The component (vtest server, ICD, layer) comes from build-venus.yml as venus.tzst, published on
  The412Banner/droiddeck-nonadreno-drivers and pinned by sha in tools/venus/release.env.
- gamescope 3.16.29-p15 adds his shm upload patch (0127) next to 0126; pinned by sha.
- device.txt and graphics-report.txt name the route.

Co-authored-by: Dersim Abbas <derabb0620@gmail.com>

* Mali: Venus gamescope without robustness2, the bridge switch honoured and kept, clean driver switches

- gamescope 0128: VK_EXT_robustness2 is optional. A Mali driver through Venus has none, and
  gamescope stopped at "Missing required extension: VK_EXT_robustness2" (the wayland_surface error
  after it was only the knock-on). Without it, unused descriptor slots point at a 1x1 texture
  instead of VK_NULL_HANDLE. (David Cimo's Pixel 9 driver has robustness2, so his build never
  needed this.) gamescope component rebuilt and pinned by sha.
- Open-files limit: on a GPU that is not an Adreno the session script raises the soft limit to the
  hard limit for the whole session tree (a PanVK-kbase session froze on "Too many open files"
  after ten minutes) and graphics-report.txt shows before and after. A stopgap; the driver leak is
  fixed separately.
- The Mali bridge switch is honoured: when on and usable it wins over a PanVK pair for the
  session (Venus still wins over it). Selecting a pair no longer switches the bridge off, which is
  why the switch did not survive an app restart (Auto re-selected the pair at start). Setup says
  when this phone cannot use the bridge at all.
- Driver switching: picking a Mali pair by hand keeps the display on the phone's own driver, as
  Auto does (a PanVK Android display stalls on Mali gralloc at "Waiting for Steam's first frame",
  and stayed set after switching back); installing a bundle again replaces it instead of adding a
  "-2" copy beside the old one.
- graphics-report.txt names the runtime driver's folder and libraries, and the previous session's
  drivers, flagged when they changed.

* gamescope p16 (0128 robustness2 optional), pinned by sha; graphics-report says who chose the display driver

* Bundle replace only for open non-Adreno pairs; Adreno bundles keep their numbered copies

* Rebuilt open drivers reach phones: re-downloaded when their digest changes, release list hourly on non-Adreno

The non-Adreno driver releases replace their assets in place (the PanVK kbase sync-file fd leak
fix). A download is now remembered with its GitHub sha256, and an asset whose digest changed
counts as not installed, so Auto fetches it again and the bundle replaces the old one; the release
list is re-read after an hour instead of a day on a GPU that is not an Adreno.

* Mali compatibility layer: multiDrawIndirect, depthClipEnable and robustness2 for DXVK on Venus

A Galaxy A15 (Mali-G57) on Venus got gamescope and Steam up, but DXVK refused the GPU:
"Device does not support required feature 'multiDrawIndirect'". DXVK 3.1 stops at the first
missing feature, so the rest of its required list (dxvk_device_info.cpp) was checked against what
the testers' Mali drivers cannot have, and covered in the same pass, on top of David Cimo's six:
- multiDrawIndirect: reported, taken off the device, and an indirect draw with drawCount > 1 is
  recorded as single draws at offset + i * stride; maxDrawIndirectCount reported as 2^30.
  (drawIndirectCount is optional for DXVK and stays as the driver says.)
- VK_EXT_depth_clip_enable (required): offered when the driver lacks it; depthClipEnable off in a
  pipeline becomes depthClampEnable, and the extension's structures never reach the driver.
- VK_EXT_robustness2 missing entirely (gamescope saw the same on these phones): offered with
  robustBufferAccess2 (as robustBufferAccess, as before) and nullDescriptor, emulated by small
  stand-ins (a zeroed buffer, a 1x1 image) for VK_NULL_HANDLE buffers, image views and vertex
  buffers in plain, template and push descriptor writes and vertex-buffer binds. A null
  texel-buffer view stays null (its format is not known).
The layer logs every feature it emulates per device.

* Venus component 22694a38 (layer: multiDrawIndirect, depthClipEnable, robustness2), pinned by sha

* Non-Adreno round 3: bridge images, Venus GL, shared buffers, Steam GPU drawing

- vkbridge: the memory model skips lazily allocated types. Mali-G615 lists
  DEVICE_LOCAL|LAZILY_ALLOCATED first; taken as the device-local type it left
  images with no memory type (self-test "image clear/draw: setup" FAIL,
  gamescope "No compatible image memory type").
- Session: a bridge self-test that fails images or draws falls back to the
  runtime's driver pair for that session (BL_VKBRIDGE_FALLBACK_ICD); Setup
  and the graphics report say so.
- Venus: the Mali compatibility layer runs in every process but gamescope
  (DROIDDECK_MALI_COMPAT=1), so Zink in Steam and Xwayland gets
  nullDescriptor; null texel-buffer views get stand-ins too. Without
  nullDescriptor the session's GL goes to llvmpipe.
- gamescope 0129: a refused compute pipeline is named with its SPIR-V
  capabilities.
- Compositor: a buffer on two surfaces at once (gamescope's planes while a
  notification is up) is released only when the last one lets go.
- Open driver pairs: processes.txt timeline for the first three minutes;
  Setup "Steam interface: GPU drawing" turns off software web compositing.

* Pin gamescope p17 (0129) and Venus 55b30fbf

* Non-Adreno round 4: Mali GPU-drawing block, gamescope YCbCr retry, GL probe, bridge draw sync

- Setup's "Steam interface: GPU drawing" is hidden on Mali and a saved "on" is
  cleared: with PanVK it rebooted an Edge 60 (G615) as steamwebhelper started.
  Kept for Xclipse.
- gamescope 0130: a composite pipeline refused at start-up is retried with a
  layout without immutable YCbCr samplers (G615 through Venus refused every
  composite shader; their SPIR-V has no Float16, so fp16 was not the cause).
- Venus: droiddeck-glprobe opens GL through GLX the way the Steam client does,
  with the loader's reasons logged; when it fails the client's GL goes to
  llvmpipe.
- vkbridge self-test: the draw check waits for the render pass's stores before
  copying out (a tiler read zeros without the dependency).

* Pin gamescope p18 (0130)

* Non-Adreno round 5: gamescope memory fallback, Venus destroy guard, OpenAL depot

- gamescope 0131: DEVICE_LOCAL|HOST_VISIBLE requests fall back to host-visible
  memory (the bridge's unified-memory model lists none with both), with the
  request, type bits and memory types logged on failure; 0130's probe pipeline
  is kept and skipped when forced.
- Venus: GAMESCOPE_NO_YCBCR_SAMPLERS=1 from the start; virglrenderer ignores
  the destroy of a pipeline it never created instead of marking the context
  fatal (vtest server exit 137 on a Mali-G615).
- Steam's OpenAL depot (229020) maps to oalinst_dll, so games that list it
  (Hotline Miami) get OpenAL in their prefix.

* Pin gamescope p19 (0131) and Venus 6199a93f

* Non-Adreno round 6: PowerVR PRIME on old kernels, thermal, hang-up names, bridge flippable images, Venus Zink variants

- drm.c: PR #570's current PRIME ownership check (F_DUPFD_QUERY, then kcmp,
  then the F_SETOWN_EX owner marker): on a kernel before 6.10 with kcmp
  blocked, drmPrimeFDToHandle answered EOPNOTSUPP for every PowerVR import
  (Pixel 10, Android 17: Zink "failed drmPrimeFDToHandle", Xwayland error 7,
  gamescope X11 I/O error). The Mali stand-in node is kept.
- A /sys/class/thermal the kernel will not list gets an empty directory, so
  mangoapp no longer aborts on it.
- gamescope 0132: a hung-up waitable is named before the abort; 0133: the
  bridge's flippable images use supported-but-unexportable modifiers instead
  of asserting.
- Venus: when Zink does not start, the loader's view is logged and Zink is
  retried without ZINK_DEBUG=compact, with ZINK_DESCRIPTORS=auto and without
  kopper before falling back to llvmpipe.

* Pin gamescope p20 (0132, 0133)

* Non-Adreno round 7: bridge command-buffer guard, Venus Zink trace, PowerVR mangoapp, Xclipse label

- vkbridge server: every command buffer a device hands out is tracked; Begin,
  End (stream replay) and QueueSubmit refuse one it never allocated or has
  freed (VK_ERROR_DEVICE_LOST, logged) instead of passing it to the driver,
  where Mali's vkBeginCommandBuffer crashed the app (SIGSEGV 0x10, Steam's
  Zink on an Edge 60 and a Tab S11).
- vkbridge server: a fault inside the driver while serving a request cuts
  that client off (SIGSEGV/SIGBUS guard per request) and leaves its objects
  alone; the app and the other clients carry on. Other faults go to the
  previous handler.
- vkbridge server: the pipeline cache directory is copied; the JNI string it
  pointed at was freed (garbage in the cache path).
- Venus: DROIDDECK_MALI_COMPAT_TRACE=1 makes the Mali compatibility layer log
  what an application queries before vkCreateDevice; a failed glprobe adds a
  traced run and vulkaninfo --summary under the same environment.
- PowerVR: mangoapp draws with llvmpipe (Zink could not make it a swapchain
  and it crashed at every start).
- Setup: an Xclipse GPU reads "Experimental: RADV or the system Xclipse
  driver", not the PowerVR line.

* Pin Venus e40cd361 (layer trace)

* Non-Adreno round 8: bridge sharing fallback and crash detail, Venus diagnostics and 1.2 gate, compositor disconnect reasons, RADV upstream

- Mali bridge: the self-test fails "memory sharing" when the server offers
  no host-visible memory type (no sharing method passed, RP4 Pro G77); the
  session then falls back to the PanVK pair like a failed draw, and Setup
  says the bridge cannot share memory with that driver. Without a pair to
  fall back on, the log says so.
- Mali bridge: a guarded driver crash now logs the sub-command it was in,
  the fault address and pc (library + offset via dladdr), the command
  buffer's level, begin flags, pool flags and state, and the last 32
  replayed commands. Begin on an executable buffer from a pool without
  RESET_COMMAND_BUFFER_BIT is logged once (implicit reset).
- Venus: vulkan-summary.txt gets the device extension list and key
  features (full vulkaninfo in vulkan-full.txt); a failed GL probe runs
  once with VN_DEBUG=init,result, ZINK_DEBUG=mem, MESA_LOG_LEVEL=debug and
  the layer trace into glprobe-trace.txt. The Mali compatibility layer's
  trace covers every pre-device query (devices, memory, queue families,
  formats, image formats, external handles) and names the extensions.
- Venus: off when the phone's driver reports Vulkan below 1.2 (gamescope
  skips such a device); Setup and the graphics report say why and the
  session uses the PanVK pair.
- Compositor: libwayland's own disconnect reasons go to wayland.log, and a
  client's buffer may grow to 1 MB before a slow reader is dropped. A
  session that ended without teardown records Android's exit reasons.
- Drivers: RADV-Xclipse upstream (radv-xclipse-upstream) is a manual
  choice for Xclipse; Auto keeps radv-xclipse.

* Tests: the terminal-callers harness stubs the Quest layer and Cardboard modules and Android's system properties

* Pin gamescope p21 (main's patches + 0120-0133) and Venus a4d47cf3 (layer trace)

* Display driver Auto: Quest's patched Turnip first; the system driver only for a Mali, other GPUs keep the generic fallback

* Open driver pairs: the installed build's version, its upload date, and an Update when the release is rebuilt in place

- The release check records each asset's GitHub id and updated_at; a
  download records them (with the digest) for an open non-Adreno pair.
- Components > GPU drivers: an installed open pair shows its manifest
  version ("android <tag> + linux <commit>"), one not yet installed shows
  "built YYYY-MM-DD". A different digest, asset id or upload time on the
  same tag marks the installed pair "Update available" with an Update
  action: the pair is downloaded again and replaced in place, and stays
  selected only if it was. Adreno and DD-Turnip pairs are unchanged.
- graphics-report.txt: the pair release line gives the installed and the
  listed upload dates and flags a newer build; an exact bundle id match is
  preferred (RADV-Xclipse-upstream is not RADV-Xclipse).

* Session preload: drop oom_score_adj raises so lmkd does not treat games as cached apps

steam-launch-wrapper starts every game with --oom-score-adjust 900; on
Android 900 is CACHED_APP_MIN_ADJ, so lmkd kills the running game first
when memory runs short (and on Linux 6.1 the raise becomes the process's
permanent minimum). A process in the app cannot go below the score it
inherits, so the writes that succeed from inside are raises: every
write-open of /proc/<pid|self|thread-self>[/task/<tid>]/oom_score_adj (or
oom_adj), through open/openat or fopen, goes to /dev/null, logged once.

Based on the oom_score_adj redirect in the preload's opens.c by jdmg28 (https://github.com/jdmg28/DroidDeck-Mali/commit/6be00e00)

* Display: why presenting failed on the session-ended screen, and the display driver that really loaded

- The compositor records why it cannot present (no Vulkan driver loaded,
  vkCreateInstance/vkCreateDevice failed, no GPU or graphics queue, no
  swapchain on the screen with the driver's reason, device lost, GPU work
  unconfirmed). Each is a DD_PRESENT_FAULT line in wayland.log, read back
  over JNI or from wayland.log; the session-ended screen shows it instead
  of a black screen, and graphics-report.txt gets "!! DISPLAY FAILED". A
  first frame or a working swapchain clears it.
- After the display device is created, the driver that answered is logged
  from VkPhysicalDeviceDriverProperties (device, driverName, driverInfo,
  driver id, Vulkan version) and reported in graphics-report.txt. When a
  driver pair's display half was requested but a vendor driver answered
  (adrenotools falls back to the system driver when the requested one does
  not load), it says so.

Based on DD_PRESENT_FAULT in vk_present.c / waylandcomp_jni.c / SessionActivity by jdmg28 (https://github.com/jdmg28/DroidDeck-Mali/blob/arena/cd8ab18a-droiddeck-mali/app/src/main/cpp/waylandcomp/src/vk_present.c)
Based on the adrenotools silent-fallback finding by ryanistr (https://github.com/ryanistr/DroidDeck-Mali/blob/main/docs/development/panvk-mali-g77-bringup.md)

* tests: steam presentation test sets 0.5.0's steam_client

* Non-Adreno: find every driver pair, Venus before the bridge, fix the bridge's begin info

From the logs testers sent since c9ebb247:
- The app read the drivers repo's newest 15 releases only; the component releases (gamescope,
  Venus) pushed every PanVK pair and RADV-Xclipse past them, so Auto found no pair on any Mali
  and switched the Mali bridge on. The non-Adreno repo is now read in one page of 100.
- Auto's stand-in for a missing pair: Mali (Venus) where the apk carries it (Steam runs on it
  from the G57 to the G1-Ultra), the bridge otherwise, nothing on a driver below Vulkan 1.2. It
  no longer clears the Linux driver, does nothing when the list could not be read, records that
  it chose the route, and turns it off again once a pair is installed. A bridge that earlier
  builds left on under Auto is taken as Auto's.
- Mali bridge: vkBeginCommandBuffer sent its begin info without the count the server decodes, so
  Mali got a zeroed begin info with stale flags and crashed at 0x10 (Pixel 8 Pro G715, Lenovo
  G615, Xiaomi G925, Tab S11).
- Mali-G1 series (MT6993, arch v14) known by its chip; its label says Venus, not the bridge.
- A session Android killed for memory is said so on the next start (the S24 FE "crashes" were
  low-memory kills, not driver faults).
- The in-app updater never installs an official (Adreno-only) build over this test build.

* Venus: destroy the device's object mutex after the objects that lock it

Bionic aborts on locking a destroyed mutex ("pthread_mutex_lock called on a destroyed mutex",
Tab S9 FE G68, Pixel 9a), so a client that exited holding objects took the render worker down.
From BattleTempest's DroidDeck-Pixel (kevinbryant551-ux/DroidDeck-Pixel, GPL-3.0).

* release check: a session helper may be extracted to another runtime path

droiddeck-steam-taskset (#570) goes to usr/local/libexec/droiddeck-steam/taskset, where PATH puts
it in front of Steam's own taskset for the client only; 0.5.0's check wanted every droiddeck-*
helper at its own path.

* Venus component 93038b7d (destroyed-mutex fix)

* Update MaliBridge to v0.5.1 (#1135)

* Mali Auto: never leave a session on the runtime's Turnip

Logs from a Retroid Pocket 4 Pro (G77), Galaxy S21 Ultra (G78), Tab S11 Ultra
(G925) and Xiaomi G610 showed Auto ending on the runtime's Turnip, where
gamescope finds no GPU ("failed to find physical device"): after a pair's
trial rolled back, when the pair is on the bad list, and when the driver
list could not be read. In each case Auto now switches on its stand-in
(Venus, or the bridge) when no open driver, Venus or bridge is set.
Under Auto the Mali display also leaves any imported driver, not only a
pair's PanVK half (a lone PanVK_G720 import gave a black screen).

* Mali bridge: MaliBridge 224b6e36 (v0.5.3 source, by ASEbrahim)

From c65062b6 (v0.5.1). v0.5.2/v0.5.3: Steam mode on older Mali drivers
(G77/G710/G610/G57) gets past "starting display and audio", OpenGL 4.6 on
most Malis through dynamic-rendering and vertex-format emulation, Dimensity
9500 texture fixes, async pipeline compile, RE2 flicker on G925, DirectX on
the Pixel 8 family. JNI entry and session env names are unchanged.

* gamescope 0134: linear when the backend offers no modifier; Venus on Mesa 26.2.5

0134: CVulkanTexture::BInit asserted !modifiers.empty() when the nested Wayland
backend offered no modifier for a flippable image's format (NieR Replicant on a
Pixel 9a under Venus, session exit 134). It now tries linear and logs it.
Venus ICD: mesa-26.2.5 (venus TLS teardown from an unloaded driver, virtio-gpu
devices without 3D skipped); virglrenderer stays on 1.3.0.

* gamescope p22-nonadreno (0134 + main's 0116 cursor fix; build run 40159674290)

* CI: build the non-Adreno additions before the preload check

* build.gradle: drop verifyHandModel (main moved the hand models into the tracking pack)

* Venus component venus-proto13-e24ed8ab (Mesa 26.2.5; build run 40161447324)

* CI: fetch the Mali (Venus) component again (lost when build.yml took main's jobs)

Build a7a1ebf1 (run 40161734101) had no assets/venus or libvirgl_test_server.so, so
VenusComponent.available() was false and Auto's stand-in would have been the bridge.

* Auto: the Mali bridge stands in on a Vulkan 1.1 Mali driver

Auto refused both Venus and the bridge when the phone's driver reports Vulkan
below 1.2, so on the G77, G78 and G610 (r32p1/r38, Vulkan 1.1) a rolled-back or
missing pair left the runtime's Turnip: "failed to find physical device"
(Retroid Pocket 4 Pro after the JM pair's trial, Xiaomi 13T). Only Venus needs
1.2; the bridge raises the driver for gamescope and runs on these phones. A
Venus switch that cannot start on such a driver no longer counts as a route.

* Tests: stub main's g_release_unpaced in the DMA-BUF quarantine probe

The probe copies release_buffer out of compositor.c; since the merge it reads
g_release_unpaced, which the harness did not declare (setUpClass failed to compile).

* Update MaliBridge to v0.5.4 (ASEbrahim)

48477fe6 (tag v0.5.4): Dimensity 9500 green squares and red-tinted textures,
Balatro and other OpenGL text, fewer crashes when memory runs low, one screen
update per game frame, picture kept after a long background pause (SIGHUP no
longer stops the server), wrong colours after changing graphics settings on
the G720, more in the session report. The app-side changes of his DroidDeck
Mali app (Steam menus setting, per-game setup, Send logs, updates) are not
part of the MaliBridge repository and are not in this build.

* gamescope 0135: linear when the driver rejects every offered modifier

An r32p1 Mali-G610 (Vulkan 1.1) behind the Mali bridge answered both of the
backend's modifiers for AR24 with VK_ERROR_FORMAT_NOT_SUPPORTED, so the first
flippable image failed and gamescope asserted in vulkan_create_flat_texture
(Xiaomi 13T). Linear, when offered, is tried anyway; the bridge makes such
images without the handle type and exports them through a dma-heap. If the
image cannot be made, BInit fails as before.

* gamescope: pin the non-Adreno p23 build (0135)

* Tests: the terminal-callers harness stubs take_shm's game-frame detection

Main's take_shm now reads surface damage, parent/role/mapped and the HUD state
to spot game frames; the harness declares them so the copied function compiles
(setUpClass failed in Build APK run 40505286127). No damage, so it stays off.

* gamescope: number the test branch's patches 0920-0935

Main now has its own 0121-0125 (window override walk, host-event wake, commit fences, done at
import, HUD frame times), which sorted in between this branch's 0120-0135. The branch's sixteen
patches move to 0920-0935 with the same last two digits, so they apply after main's set and stay
clear of its next numbers. Applying all 38 to gamescope 3.16.29 in the old order and the new one
gives the same tree (checked with patch -p1, as build-in-arch.sh does). PATCHES.md and the one
code comment that named 0130 follow the new numbers.

* check_session_assets: helpers count in usr/local/bin or the Steam taskset folder only

The merge kept this branch's pattern (any usr/ target), which main's new test rejects: a helper
extracted into a subfolder of usr/local/bin must not count. The pattern now takes usr/local/bin
under any name, as on main, plus usr/local/libexec/droiddeck-steam for droiddeck-steam-taskset.
Every helper in the overlay is still found extracted in SessionFiles.kt.

* gamescope: pin 3.16.29 p24 (non-Adreno)

Built from this branch @d13b9d88 (run 41119284267): main a5b035b2's patches plus this branch's,
now 0920-0935. All 38 applied, gamescope's tests 2/2. sha256 1d1088d4.

* Update MaliBridge to v0.5.4.2 (ASEbrahim)

95a1e600 (tag v0.5.4.2), was v0.5.4 (48477fe6). For the bridge: memory sharing without the handle
type where that is all the self-test passed (unflagged buffers, client/memory.c, server_memory.c),
the older-Mali (G52-G77) game-mode start fixes, the r38p1 beta geometry-shader erratum (gs_hide),
present timeouts and an API cap per process. Client, server and the in-app library all build from
the submodule with MaliBridge's own scripts, which did not change; the protocol only gained
fields an older server sends as 0.

* Session end: the compositor fault query no longer fails the hint when the native library is absent

presentationFault() (6778a224) called WaylandCompositor.compositorFault() directly. Main's new
SessionEndHintTest runs sessionEndHint() in Robolectric, where libdroiddeckwayland cannot load, so
all six cases ended in UnsatisfiedLinkError (Build APK run 41125749537). The call is now wrapped
like runtimeDamageHint()'s, and without an answer the hint reads wayland.log as before.

* test: stub the GPU busy reader in the caller harness

* fix: release build is not debuggable, Mali uses the system display driver, staging failure ends its own session

* fix: address non-Adreno review findings

* fix: preserve current gamescope and GPU warning behavior

* fix: retain graphics failure hints and launch diagnostics

* fix: identify non-Adreno GPUs in driver failure hints

* test: harnesses follow the external client barrier and effects upscaling changes

* fix: client sources return to foreign ownership after the overlay draws

---------

Co-authored-by: Leask Wong <i@leaskh.com>
Co-authored-by: wallentx <william.allentx@gmail.com>
Co-authored-by: Stefan Zijlstra <6730062+stefanz92@users.noreply.github.com>
Co-authored-by: William Allen <wallentx@users.noreply.github.com>
Co-authored-by: The412Banner <the412banner@users.noreply.github.com>
Co-authored-by: Dersim Abbas <derabb0620@gmail.com>
Co-authored-by: root <root@localhost.localdomain>
Co-authored-by: ASEbrahim <ahmadsmain@gmail.com>
Co-authored-by: The412Banner <the412banner@gmail.com>
Co-authored-by: The412Banner <205237651+The412Banner@users.noreply.github.com>
2026-11-05 22:06:16 -05:00

578 lines
29 KiB
Python

"""Exercise the renderer's source selection and both presentation paths without a GPU."""
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import unittest
REPO = Path(__file__).resolve().parents[2]
def function(source, signature):
start = source.rindex(signature)
return source[start:source.index('\n}\n', start) + 3]
class EffectsSourceResolutionTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
compiler = shutil.which(os.environ.get('CC', 'cc'))
if not compiler:
raise unittest.SkipTest('A host C compiler is required')
source = (REPO / 'app/src/main/cpp/waylandcomp/src/vk_present.c').read_text()
header = (REPO / 'app/src/main/cpp/waylandcomp/src/vk_present.h').read_text()
effects = (REPO / 'app/src/main/cpp/waylandcomp/src/effects_chain.c').read_text()
functions = '\n'.join(function(source, signature) for signature in (
'static void release_external_client_image(', 'static void release_external_client_draws(',
'static int map_draw(', 'static int draw_to_blit(',
'static int draw_to_scene_blit(', 'static int effects_source_draw(',
'static void effects_source_note(',
'static void effects_overlay_draws(',
'static int render_impl(', 'static int pass_begin_impl('))
functions = (re.search(r'static int spatial_mode\([^\n]+', effects).group() + '\n' +
function(effects, 'int vkp_effects_upscaling(') +
function(effects, 'int vkp_effects_postprocessing(') + functions)
image = source[source.index('struct vkp_image {'):source.index('\n};', source.index('struct vkp_image {')) + 3]
draw = header[header.index('struct vkp_draw {'):header.index('\n};', header.index('struct vkp_draw {')) + 3]
hdr = header[header.index('struct vkp_hdr_frame {'):header.index('\n};', header.index('struct vkp_hdr_frame {')) + 3]
sync = (REPO / 'app/src/main/cpp/waylandcomp/src/vk_external_image_sync.h').read_text()
sync = re.sub(r'^#(include|ifndef|define|endif).*$', '', sync, flags=re.M)
constants = sorted(set(re.findall(r'\bVK_[A-Z0-9_]+\b', functions + image + sync)) -
{'VK_FORMAT_R8G8B8A8_UNORM'})
definitions = '\n'.join(f'#define {name} {0 if name in ("VK_SUCCESS", "VK_NULL_HANDLE") else i + 1}'
for i, name in enumerate(constants))
code = TYPES + definitions + '\n' + sync + '\n' + image + '\n' + draw + '\n' + hdr + STUBS + functions + CASES
cls.temp = tempfile.TemporaryDirectory(prefix='droiddeck-effects-resolution-')
cls.addClassCleanup(cls.temp.cleanup)
folder = Path(cls.temp.name)
(folder / 'resolution.c').write_text(code)
cls.binary = folder / 'resolution'
build = subprocess.run([compiler, '-std=c11', '-Wall', '-Wextra',
'-Wno-unused-parameter', '-Wno-unused-function',
str(folder / 'resolution.c'), '-o', str(cls.binary)],
capture_output=True, text=True)
if build.returncode:
raise RuntimeError(build.stderr)
def check_case(self, case):
result = subprocess.run([str(self.binary), case], capture_output=True, text=True, timeout=10)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertEqual(result.stdout.strip(), 'PASS')
def test_low_resolution_viewport_is_copied_at_native_buffer_size(self):
self.check_case('helper')
def test_a_source_within_a_pixel_of_the_buffer_is_still_upscaled(self):
self.check_case('near-full')
def test_ineligible_compositions_keep_the_logical_scene(self):
self.check_case('rejections')
def test_swapchain_path_uses_the_game_buffer_as_effects_input(self):
self.check_case('render')
def test_offscreen_pass_uses_the_game_buffer_as_effects_input(self):
self.check_case('pass')
def test_hdr_and_non_upscaling_effects_keep_the_logical_scene(self):
self.check_case('gates')
def test_each_scaling_mode_selects_the_correct_input(self):
self.check_case('modes')
def test_fullscreen_source_occludes_unrelated_background_draws(self):
self.check_case('occlusion')
def test_foreground_overlays_keep_their_geometry_after_upscaling(self):
self.check_case('overlay')
def test_failed_intermediate_allocation_draws_all_original_layers(self):
self.check_case('allocation')
def test_effects_failure_maps_overlays_to_the_returned_image_size(self):
self.check_case('effect-failure')
def test_offscreen_pass_acquires_foreground_sources_and_restores_result_layout(self):
self.check_case('overlay-barriers')
def test_postprocessing_keeps_foreground_inside_the_effect_chain(self):
self.check_case('postprocessing')
TYPES = r'''
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int VkImage, VkDeviceMemory, VkFormat, VkCommandBuffer, VkResult, VkFilter;
typedef int VkImageLayout, VkPipelineStageFlags, VkImageUsageFlags;
typedef uint64_t VkDeviceSize;
typedef struct { unsigned width, height; } VkExtent2D;
typedef struct { int x, y, z; } VkOffset3D;
typedef struct { unsigned aspectMask, mipLevel, baseArrayLayer, layerCount; } VkImageSubresourceLayers;
typedef struct { unsigned aspectMask, baseMipLevel, levelCount, baseArrayLayer, layerCount; } VkImageSubresourceRange;
typedef struct {
VkImageSubresourceLayers srcSubresource;
VkOffset3D srcOffsets[2];
VkImageSubresourceLayers dstSubresource;
VkOffset3D dstOffsets[2];
} VkImageBlit;
typedef struct { int sType, flags; } VkCommandBufferBeginInfo;
typedef struct {
int sType, oldLayout, newLayout, srcQueueFamilyIndex, dstQueueFamilyIndex;
VkImage image;
VkImageSubresourceRange subresourceRange;
unsigned srcAccessMask, dstAccessMask;
} VkImageMemoryBarrier;
typedef struct { int sType; unsigned srcAccessMask, dstAccessMask; } VkMemoryBarrier;
typedef union { float float32[4]; } VkClearColorValue;
typedef struct {
int sType;
unsigned waitSemaphoreCount, commandBufferCount, signalSemaphoreCount;
const int *pWaitSemaphores, *pWaitDstStageMask, *pCommandBuffers, *pSignalSemaphores;
} VkSubmitInfo;
typedef struct {
int sType;
unsigned waitSemaphoreCount, swapchainCount;
const int *pWaitSemaphores, *pSwapchains;
const unsigned *pImageIndices;
} VkPresentInfoKHR;
#define SCENE_FMT 100
#define HDR_FMT 101
#define FG_HDR_FMT 102
#define VK_FORMAT_R8G8B8A8_UNORM SCENE_FMT
#define VKP_FG_MAX_GENERATIONS 2
#define HDRC_OUT_PQ 1
#define HDRC_OUT_SDR 2
#define droiddeck_log(...) ((void)0)
#define LOGE(...) ((void)0)
struct droiddeck_color { uint32_t identity; };
typedef struct AHardwareBuffer AHardwareBuffer;
'''
STUBS = r'''
static void quarantine_pending_work(VkResult result, const char *where) { (void)result; (void)where; }
static int noop(int handle, ...) { return VK_SUCCESS; }
static VkImageMemoryBarrier recorded_barriers[64];
static int barrier_count;
static int note_barriers(int cmd, int src_stage, int dst_stage, int flags,
unsigned memory_count, const VkMemoryBarrier *memory,
unsigned buffer_count, const void *buffers,
unsigned image_count, const VkImageMemoryBarrier *images) {
for (unsigned i = 0; i < image_count; i++) {
assert(barrier_count < 64);
recorded_barriers[barrier_count++] = images[i];
}
return VK_SUCCESS;
}
static struct {
int (*ResetCommandBuffer)(int, ...), (*BeginCommandBuffer)(int, ...);
int (*CmdPipelineBarrier)(int, int, int, int, unsigned, const VkMemoryBarrier *,
unsigned, const void *, unsigned, const VkImageMemoryBarrier *);
int (*CmdClearColorImage)(int, ...);
int (*EndCommandBuffer)(int, ...), (*ResetFences)(int, ...);
int (*QueueSubmit)(int, ...), (*QueuePresentKHR)(int, ...);
} g_vk = {noop, noop, note_barriers, noop, noop, noop, noop, noop};
static int g_dev_state = 1, g_window = 1, g_swapchain, g_swap_extra;
static int g_colorspace_ext, g_swap_hdr_unavailable, g_swap_is_hdr, g_swap_hdr_want;
static int g_plain_frame, g_first_frame_done, g_base_black;
static int g_qfam, g_queue, g_dev, g_fence, g_swap_fmt = SCENE_FMT;
static int g_cmds[3], g_acqs[3], g_rnds[3], images[1] = {2}, *g_images = images;
static uint32_t g_swap_md_identity;
static VkExtent2D g_extent = {1920, 1080};
static struct { float kx, ky, off_x, off_y; int rx, ry, rw, rh; } g_map;
static struct { VkImage img; int w, h; } g_scene;
struct vkp_img_slot { VkImage img; int w, h; };
static struct vkp_img_slot g_hdrscene, g_fgscene;
static struct { int active, rw, rh; VkImage result; } g_pass;
static struct { int64_t present_ns, present_max_ns; unsigned presents; } g_perf;
static int effects_active = 1, framegen, cardboard;
static struct { int scaling; } g_cur = {4};
static int copy_count, effects_count, screen_count, hdr_count, fail_scene, fail_effects, postprocessing;
static int copied_w, copied_h, target_w, target_h;
static int effects_w, effects_h, output_w, output_h, logical_w, logical_h;
static VkImageBlit copied;
static struct vkp_draw recorded_draws[16];
static VkImageBlit recorded_blits[16];
static VkImage recorded_targets[16];
static int recorded_after_effects[16], recorded_barrier_marks[16];
static void vkp_apply_window_request(void) {}
static void sc_layer_hide_base(void) {}
static void check_surface_changed(void) {}
static int dev_init(void) { return 0; }
static int vkp_framegen_extra_images(void) { return 0; }
static void destroy_swapchain(void) {}
static int acquire_image(int k, int wait, uint32_t *image, VkResult *result) {
*image = 0; *result = VK_SUCCESS; return 0;
}
static void update_map(int w, int h) {
g_map.kx = (float)g_extent.width / w; g_map.ky = (float)g_extent.height / h;
g_map.rw = g_extent.width; g_map.rh = g_extent.height;
}
static int vkp_update_map(int w, int h) { update_map(w, h); return 0; }
static void send_hdr_metadata(const struct droiddeck_color *color) {}
static int vkp_effects_active(void) { return effects_active; }
static int vkp_effects_sync(void) { return 0; }
static int effect_count(const void *settings) { return postprocessing; }
static int vkp_framegen_active(void) { return framegen; }
static int vkp_cardboard_active(void) { return cardboard; }
static void vkp_cardboard_begin_frame(void) {}
static int vkp_framegen_format_ok(VkFormat format) { return 0; }
static int ensure_img(struct vkp_img_slot *slot, int w, int h, int format, int usage, const char *name) {
slot->img = 3; slot->w = w; slot->h = h; return 0;
}
static void vk_format_short(int format, char *out, size_t size) { *out = 0; }
static int ensure_scene_image(int w, int h) {
if (fail_scene) return -1;
g_scene.img = 1; g_scene.w = w; g_scene.h = h; return 0;
}
static VkFilter vkp_effects_blit_filter(void) { return 0; }
static void blendp_begin_frame(void) {}
static int record_bars_clear(int cmd, int target, const VkImageBlit *blit) { return 1; }
static int compose_hdr(int cmd, const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hdr,
int w, int h, int target, int format, int output) {
hdr_count++; return 0;
}
static void record_draw(int cmd, const struct vkp_draw *draw, const VkImageBlit *blit, int target,
int format, int w, int h, int filter) {
assert(copy_count < 16);
recorded_draws[copy_count] = *draw; recorded_blits[copy_count] = *blit;
recorded_targets[copy_count] = target; recorded_after_effects[copy_count] = effects_count > 0;
recorded_barrier_marks[copy_count] = barrier_count;
copy_count++; copied = *blit;
copied_w = draw->dw; copied_h = draw->dh; target_w = w; target_h = h;
}
static void vkp_effects_set_formats(int input, int output) {}
static VkImage vkp_effects_run(int cmd, int source, int w, int h, int ow, int oh, int *rw, int *rh) {
effects_count++; effects_w = w; effects_h = h; output_w = ow; output_h = oh;
if (!hdr_count) assert(g_scene.w == w && g_scene.h == h);
if (fail_effects) { *rw = w; *rh = h; return source; }
*rw = ow; *rh = oh; return 4;
}
static int vkp_framegen_run(int cmd, int result, int depth, int w, int h, int format, int *generated) { return 0; }
static void record_screen_blit(int cmd, int result, int w, int h, int sw, int sh, int image, int filter, int cb) {
screen_count++; logical_w = sw; logical_h = sh;
}
static void device_lost(const char *reason) {}
static int64_t perf_now(void) { return 0; }
static void perf_add(int64_t *sum, int64_t *max, unsigned *count, int64_t duration) {}
static VkResult timed_wait(int fence, uint64_t timeout) { return VK_SUCCESS; }
static void vkp_framegen_presented(int frames) {}
static const char *vk_result_name(int result) { return "success"; }
static void droiddeck_on_first_frame(void) {}
static void vkp_pass_abort(void) { g_pass.active = 0; }
'''
CASES = r'''
static struct vkp_image image = {.image = 10, .w = 1280, .h = 720, .sampled = 1};
static struct vkp_draw fullscreen(void) {
return (struct vkp_draw){.img = &image, .sw = image.w, .sh = image.h, .dw = 1920, .dh = 1080};
}
static void reset(void) {
copy_count = effects_count = screen_count = hdr_count = barrier_count = 0;
effects_active = 1; g_cur.scaling = 4;
framegen = cardboard = fail_scene = fail_effects = postprocessing = g_plain_frame = 0;
g_pass.active = 0; g_extent = (VkExtent2D){1920, 1080};
image.w = 1280; image.h = 720;
}
static void check_helper(void) {
struct vkp_draw original = fullscreen(), before = original, selected;
struct vkp_image image_before = image;
assert(effects_source_draw(1920, 1080, &original, 1, &selected));
assert(memcmp(&original, &before, sizeof(original)) == 0);
assert(memcmp(&image, &image_before, sizeof(image)) == 0);
assert(selected.img == original.img && selected.sw == 1280 && selected.sh == 720);
assert(selected.dw == 1280 && selected.dh == 720);
VkImageBlit blit;
assert(draw_to_scene_blit(&selected, 1280, 720, &blit));
assert(blit.srcOffsets[0].x == 0 && blit.srcOffsets[0].y == 0);
assert(blit.dstOffsets[0].x == 0 && blit.dstOffsets[0].y == 0);
assert(blit.srcOffsets[1].x == 1280 && blit.srcOffsets[1].y == 720);
assert(blit.dstOffsets[1].x == 1280 && blit.dstOffsets[1].y == 720);
image.w = 1920; image.h = 720;
original = fullscreen();
assert(effects_source_draw(1920, 1080, &original, 1, &selected));
assert(selected.dw == 1920 && selected.dh == 720);
}
static void rejected(struct vkp_draw draw, int n) {
struct vkp_draw selected = {0}, before = selected;
assert(!effects_source_draw(1920, 1080, &draw, n, &selected));
assert(memcmp(&selected, &before, sizeof(selected)) == 0);
}
static void check_rejections(void) {
struct vkp_draw draw = fullscreen(), unused;
assert(!effects_source_draw(1920, 1080, NULL, 1, &unused));
rejected(draw, 0); rejected(draw, -1);
draw.img = NULL; rejected(draw, 1);
draw = fullscreen(); draw.blend = 1; rejected(draw, 1);
draw = fullscreen(); draw.dx = 1; rejected(draw, 1);
draw = fullscreen(); draw.dy = -1; rejected(draw, 1);
draw = fullscreen(); draw.dw--; rejected(draw, 1);
draw = fullscreen(); draw.dh++; rejected(draw, 1);
draw = fullscreen(); draw.sx = 1; rejected(draw, 1);
draw = fullscreen(); draw.sy = 0.5f; rejected(draw, 1);
draw = fullscreen(); draw.sw--; rejected(draw, 1);
draw = fullscreen(); draw.sh--; rejected(draw, 1);
const int sizes[][2] = {{1920, 1080}, {1921, 720}, {1280, 1081}, {0, 720}, {1280, 0}, {-1, 720}};
for (unsigned i = 0; i < sizeof(sizes) / sizeof(sizes[0]); i++) {
image.w = sizes[i][0]; image.h = sizes[i][1]; rejected(fullscreen(), 1);
}
reset();
struct vkp_image native = {.image = 13, .w = 1920, .h = 1080};
struct vkp_draw layers[] = {fullscreen(), fullscreen()};
layers[1].img = &native; layers[1].sw = 1920; layers[1].sh = 1080;
assert(!effects_source_draw(1920, 1080, layers, 2, &unused));
layers[1] = fullscreen(); layers[1].sx = 1; layers[1].sw--;
assert(!effects_source_draw(1920, 1080, layers, 2, &unused));
struct vkp_image pixel = {.image = 14, .w = 1, .h = 1};
layers[0] = fullscreen(); layers[0].img = &pixel; layers[0].sw = 1; layers[0].sh = 1;
layers[1] = fullscreen(); layers[1].dx = 240; layers[1].dw = 1440;
assert(!effects_source_draw(1920, 1080, layers, 2, &unused));
layers[1] = fullscreen(); layers[1].dx = 320; layers[1].dy = 180; layers[1].dw = 1280; layers[1].dh = 720;
assert(!effects_source_draw(1920, 1080, layers, 2, &unused));
layers[0] = fullscreen();
layers[1] = fullscreen(); layers[1].dx = 10; layers[1].dy = 10; layers[1].dw = 24; layers[1].dh = 24;
assert(effects_source_draw(1920, 1080, layers, 2, &unused) == 1);
}
static void check_near_full_source(void) {
struct vkp_draw draw = fullscreen(), selected;
draw.sw = 1279.5f;
assert(effects_source_draw(1920, 1080, &draw, 1, &selected));
assert(selected.dw == 1280 && selected.dh == 720 && selected.sw == 1279.5f);
draw = fullscreen(); draw.sh = 720.5f;
assert(effects_source_draw(1920, 1080, &draw, 1, &selected));
}
static void run_path(int offscreen, const struct vkp_draw *draw, int n, const struct vkp_hdr_frame *hdr) {
struct vkp_draw before[4];
assert(n > 0 && n <= 4);
memcpy(before, draw, n * sizeof(*draw));
int rw = 0, rh = 0;
assert((offscreen ? pass_begin_impl(1920, 1080, draw, n, hdr, &rw, &rh)
: render_impl(1920, 1080, draw, n, hdr, NULL)) == 0);
assert(memcmp(draw, before, n * sizeof(*draw)) == 0);
if (offscreen) assert(rw == (fail_effects ? effects_w : (int)g_extent.width) &&
rh == (fail_effects ? effects_h : (int)g_extent.height));
}
static void check_input(int w, int h) {
assert(effects_count == 1 && effects_w == w && effects_h == h);
assert(output_w == (int)g_extent.width && output_h == (int)g_extent.height);
}
static void check_path(int offscreen) {
struct vkp_draw draw = fullscreen();
run_path(offscreen, &draw, 1, NULL);
check_input(1280, 720);
assert(copy_count == 1 && copied_w == 1280 && copied_h == 720);
assert(target_w == 1280 && target_h == 720);
assert(copied.srcOffsets[1].x == copied.dstOffsets[1].x);
assert(copied.srcOffsets[1].y == copied.dstOffsets[1].y);
if (!offscreen) assert(screen_count == 1 && logical_w == 1920 && logical_h == 1080);
reset(); image.w = 1920; image.h = 1080; draw = fullscreen();
run_path(offscreen, &draw, 1, NULL); check_input(1920, 1080);
reset(); g_extent = (VkExtent2D){2560, 1440}; draw = fullscreen();
run_path(offscreen, &draw, 1, NULL); check_input(1280, 720);
reset(); draw = fullscreen(); draw.dw = 1280; draw.dh = 720;
int rw, rh;
assert((offscreen ? pass_begin_impl(1280, 720, &draw, 1, NULL, &rw, &rh)
: render_impl(1280, 720, &draw, 1, NULL, NULL)) == 0);
check_input(1280, 720);
}
static void check_gates(void) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset(); g_cur.scaling = 0;
struct vkp_draw draw = fullscreen();
run_path(offscreen, &draw, 1, NULL); check_input(1920, 1080);
assert(target_w == 1920 && target_h == 1080);
reset();
struct vkp_hdr_frame hdr = {0};
run_path(offscreen, &draw, 1, &hdr); check_input(1920, 1080);
assert(hdr_count == 1 && copy_count == 0);
reset();
struct vkp_draw desktop[] = {fullscreen(), fullscreen()};
desktop[0].dw = 960;
desktop[1].dx = 40; desktop[1].dy = 30; desktop[1].dw = 640; desktop[1].dh = 480;
run_path(offscreen, desktop, 2, NULL); check_input(1920, 1080);
reset(); draw = fullscreen(); draw.blend = 1;
run_path(offscreen, &draw, 1, NULL); check_input(1920, 1080);
}
reset(); effects_active = 0; framegen = 1;
struct vkp_draw draw = fullscreen();
run_path(0, &draw, 1, NULL);
assert(effects_count == 0 && target_w == 1920 && target_h == 1080);
reset(); fail_scene = 1;
run_path(0, &draw, 1, NULL);
assert(effects_count == 0 && copied.dstOffsets[1].x == 1920 && copied.dstOffsets[1].y == 1080);
}
static void check_modes(void) {
for (int mode = 0; mode <= 8; mode++) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset(); g_cur.scaling = mode;
int upscale = mode == 3 || mode == 4 || mode == 5 || mode == 7 || mode == 8;
assert(vkp_effects_upscaling() == upscale);
struct vkp_draw draw = fullscreen();
run_path(offscreen, &draw, 1, NULL);
check_input(upscale ? 1280 : 1920, upscale ? 720 : 1080);
}
}
}
static struct vkp_image background = {.image = 11, .w = 320, .h = 240, .sampled = 1};
static struct vkp_image cursor = {.image = 12, .w = 24, .h = 24, .dmabuf = 1, .sampled = 1};
static struct vkp_draw background_draw(void) {
return (struct vkp_draw){.img = &background, .sw = 320, .sh = 240,
.dx = 40, .dy = 30, .dw = 640, .dh = 480, .blend = 1};
}
static struct vkp_draw cursor_draw(void) {
return (struct vkp_draw){.img = &cursor, .sw = 24, .sh = 24,
.dx = 480, .dy = 270, .dw = 24, .dh = 24, .blend = 1};
}
static void check_occlusion(void) {
struct vkp_draw layers[] = {background_draw(), fullscreen()}, selected;
struct vkp_draw before[2];
memcpy(before, layers, sizeof(layers));
assert(effects_source_draw(1920, 1080, layers, 2, &selected) == 2);
assert(selected.img == &image && selected.dw == 1280 && selected.dh == 720);
assert(memcmp(layers, before, sizeof(layers)) == 0);
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset();
run_path(offscreen, layers, 2, NULL); check_input(1280, 720);
assert(copy_count == 1 && recorded_draws[0].img == &image);
assert(recorded_draws[0].dw == 1280 && recorded_draws[0].dh == 720);
assert(target_w == 1280 && target_h == 720);
assert(copied.srcOffsets[1].x == 1280 && copied.dstOffsets[1].x == 1280);
assert(copied.srcOffsets[1].y == 720 && copied.dstOffsets[1].y == 720);
if (!offscreen) assert(logical_w == 1920 && logical_h == 1080);
reset(); g_cur.scaling = 6;
run_path(offscreen, layers, 2, NULL); check_input(1920, 1080);
assert(copy_count == 2);
reset();
struct vkp_hdr_frame hdr = {0};
run_path(offscreen, layers, 2, &hdr); check_input(1920, 1080);
assert(hdr_count == 1 && copy_count == 0);
}
}
static void check_overlay(void) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
for (int larger_output = 0; larger_output <= 1; larger_output++) {
reset();
if (larger_output) g_extent = (VkExtent2D){2560, 1440};
struct vkp_draw layers[] = {background_draw(), fullscreen(), cursor_draw()}, selected;
assert(effects_source_draw(1920, 1080, layers, 3, &selected) == 2);
run_path(offscreen, layers, 3, NULL); check_input(1280, 720);
assert(copy_count == 2 && recorded_draws[0].img == &image);
assert(!recorded_after_effects[0] && recorded_targets[0] == g_scene.img);
assert(recorded_draws[1].img == &cursor && recorded_draws[1].blend);
assert(recorded_after_effects[1] && recorded_targets[1] == 4);
assert(recorded_blits[1].dstOffsets[0].x == (larger_output ? 640 : 480));
assert(recorded_blits[1].dstOffsets[0].y == (larger_output ? 360 : 270));
assert(recorded_blits[1].dstOffsets[1].x - recorded_blits[1].dstOffsets[0].x ==
(larger_output ? 32 : 24));
assert(recorded_blits[1].dstOffsets[1].y - recorded_blits[1].dstOffsets[0].y ==
(larger_output ? 32 : 24));
}
for (int blend = 0; blend <= 1; blend++) {
reset();
struct vkp_draw layers[] = {background_draw(), fullscreen(), background_draw(), cursor_draw()};
layers[2].blend = blend;
layers[3].sx = 4; layers[3].sy = 2; layers[3].sw = 12; layers[3].sh = 18;
run_path(offscreen, layers, 4, NULL); check_input(1280, 720);
assert(copy_count == 3 && recorded_draws[0].img == &image);
assert(recorded_draws[1].img == &background);
assert(recorded_draws[1].blend == blend && recorded_after_effects[1]);
assert(recorded_draws[2].img == &cursor && recorded_after_effects[2]);
assert(recorded_blits[1].dstOffsets[0].x == 40);
assert(recorded_blits[1].dstOffsets[0].y == 30);
assert(recorded_blits[2].srcOffsets[0].x == 4 && recorded_blits[2].srcOffsets[0].y == 2);
assert(recorded_blits[2].srcOffsets[1].x == 16 && recorded_blits[2].srcOffsets[1].y == 20);
assert(recorded_targets[1] == 4 && recorded_targets[2] == 4);
assert(target_w == 1920 && target_h == 1080);
}
}
}
static void check_effect_failure(void) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset(); fail_effects = 1;
struct vkp_draw layers[] = {background_draw(), fullscreen(), cursor_draw()};
run_path(offscreen, layers, 3, NULL); check_input(1280, 720);
assert(copy_count == 2 && recorded_targets[1] == g_scene.img && recorded_after_effects[1]);
assert(target_w == 1280 && target_h == 720);
assert(recorded_blits[1].dstOffsets[0].x == 320 && recorded_blits[1].dstOffsets[0].y == 180);
assert(recorded_blits[1].dstOffsets[1].x == 336 && recorded_blits[1].dstOffsets[1].y == 196);
}
}
static int find_barrier(VkImage image, int from, int to) {
for (int i = 0; i < barrier_count; i++)
if (recorded_barriers[i].image == image && recorded_barriers[i].oldLayout == from &&
recorded_barriers[i].newLayout == to) return i;
return -1;
}
static void check_overlay_barriers(void) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset();
struct vkp_draw layers[] = {background_draw(), fullscreen(), cursor_draw()};
run_path(offscreen, layers, 3, NULL); check_input(1280, 720);
int acquired = find_barrier(cursor.image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
assert(acquired >= 0 && recorded_barriers[acquired].srcQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
int writable = find_barrier(4, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
int readable = find_barrier(4, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
assert(writable > acquired && readable > writable);
int released = find_barrier(cursor.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL);
assert(released > acquired && recorded_barriers[released].dstQueueFamilyIndex == VK_QUEUE_FAMILY_FOREIGN_EXT);
int last_cursor_draw = -1;
for (int i = 0; i < copy_count; i++) if (recorded_draws[i].img == &cursor) last_cursor_draw = i;
assert(last_cursor_draw >= 0 && released >= recorded_barrier_marks[last_cursor_draw]);
}
}
static void check_postprocessing(void) {
for (int offscreen = 0; offscreen < 2; offscreen++) {
reset(); postprocessing = 1;
struct vkp_draw layers[] = {background_draw(), fullscreen(), cursor_draw()}, selected;
assert(vkp_effects_postprocessing());
assert(effects_source_draw(1920, 1080, layers, 2, &selected) == 2);
assert(!effects_source_draw(1920, 1080, layers, 3, &selected));
run_path(offscreen, layers, 3, NULL); check_input(1920, 1080);
assert(copy_count == 3);
for (int i = 0; i < copy_count; i++)
assert(!recorded_after_effects[i] && recorded_targets[i] == g_scene.img);
}
}
static void check_allocation(void) {
fail_scene = 1;
struct vkp_draw layers[] = {background_draw(), fullscreen()};
run_path(0, layers, 2, NULL);
assert(effects_count == 0 && copy_count == 2);
assert(recorded_draws[0].img == &background && recorded_draws[1].img == &image);
assert(recorded_draws[0].dw == 640 && recorded_draws[0].dh == 480);
assert(recorded_draws[1].dw == 1920 && recorded_draws[1].dh == 1080);
assert(recorded_blits[0].dstOffsets[0].x == 40 && recorded_blits[0].dstOffsets[0].y == 30);
assert(recorded_blits[1].dstOffsets[1].x == 1920 && recorded_blits[1].dstOffsets[1].y == 1080);
assert(target_w == 1920 && target_h == 1080);
}
int main(int argc, char **argv) {
assert(argc == 2); reset();
if (!strcmp(argv[1], "helper")) check_helper();
else if (!strcmp(argv[1], "near-full")) check_near_full_source();
else if (!strcmp(argv[1], "rejections")) check_rejections();
else if (!strcmp(argv[1], "render")) check_path(0);
else if (!strcmp(argv[1], "pass")) check_path(1);
else if (!strcmp(argv[1], "gates")) check_gates();
else if (!strcmp(argv[1], "modes")) check_modes();
else if (!strcmp(argv[1], "occlusion")) check_occlusion();
else if (!strcmp(argv[1], "overlay")) check_overlay();
else if (!strcmp(argv[1], "allocation")) check_allocation();
else if (!strcmp(argv[1], "effect-failure")) check_effect_failure();
else if (!strcmp(argv[1], "overlay-barriers")) check_overlay_barriers();
else if (!strcmp(argv[1], "postprocessing")) check_postprocessing();
else assert(0);
puts("PASS");
}
'''
if __name__ == '__main__':
unittest.main()