Android: track disjoint mip layouts and add Vulkan validation tools
This commit is contained in:
+27
-3
@@ -12,7 +12,7 @@ Layout (a sibling of `dm/ios/`):
|
||||
| `tests/` | Vulkan backend device test `t_vk_perf` |
|
||||
| `../gfx/vulkan/` | The Vulkan graphics backend `nvn_vk.c` (counterpart of the Metal backend `gfx/nvn/nvn_mtl.m`) |
|
||||
|
||||
The backend (`gfx/vulkan/nvn_vk.c`) retains the NVN recorder's `mtl_*` interface. Headless rendering is verified on OnePlus 13 / Adreno 830. A minimal GameActivity app (window, raw touch, gamepad, text input) is in `app/`; AAudio and the touch HUD remain subsequent work.
|
||||
The backend (`gfx/vulkan/nvn_vk.c`) retains the NVN recorder's `mtl_*` interface. Headless rendering is verified on OnePlus 13 / Adreno 830. The app includes window management, a touch HUD, gamepad and text input, AAudio and lifecycle suspend/resume. Integration does not establish validation on every device.
|
||||
|
||||
## Build and test
|
||||
|
||||
@@ -32,6 +32,7 @@ Use `NDK=...` or `ANDROID_NDK_HOME` to override the newest local SDK NDK. The de
|
||||
| `DM_VK_SHADERS` | Vulkan shader pack generated by `dmsh_vk.py` |
|
||||
| `DM_VK_PIPELINE_CACHE` | Driver cache file; defaults to the shader directory with vendor / device / driver version in its name |
|
||||
| `DM_DISABLE_PIPELINE_CACHE=1` | Disable the driver cache; the state-to-pipeline memory cache remains active |
|
||||
| `DM_VK_SUBRES=0` | Disable disjoint-mip layouts and use the original whole-image path for device A/B; enabled by default |
|
||||
| `DM_VK_SYNC=1` | Submit and wait at every logical commit for comparison |
|
||||
| `DM_FRAME_DIR` | Existing PPM frame capture and requested diagnostics |
|
||||
| `DM_VULKAN_VALIDATION=1` | Request the Khronos layer, which must be discoverable by Android's loader |
|
||||
@@ -59,7 +60,7 @@ adb shell am start -n org.d2rmobile.app/.GameActivity
|
||||
adb shell run-as org.d2rmobile.app cat files/d2r/run.log
|
||||
```
|
||||
|
||||
The data root is `files/d2r` (`dm/main.patched.bin`, `romfs`, `rt64` required). stderr goes to `run.log`; optional `env.txt` lines `KEY=VALUE` are exported before start (e.g. `DM_VK_VRS=2x2`). Audio is off (`DM_AUDIO=0`) until AAudio lands. Render resolution is 720 lines times the screen aspect (`DM_GAME_RES` overrides). Without a window (app in background) the render thread holds at Present and resumes when a new surface arrives. On front-end pages (main menu, character select / creation) the first finger becomes UI mouse clicks via `dm_ui_touch` (tap = click at the lift point, vertical drag = scroll), as on iOS; in a run touch goes to the game's raw touchscreen until the touch HUD is ported. Gamepad buttons and sticks go to the pad.
|
||||
The data root is `files/d2r` (`dm/main.patched.bin`, `romfs`, `rt64` required). stderr goes to `run.log`; optional `env.txt` lines `KEY=VALUE` are exported before start (e.g. `DM_VK_VRS=2x2`). AAudio is on by default (`DM_AUDIO=0` mutes). UI output follows screen aspect and native height (900–1080 lines); the default 3D target is approximately 720 lines (`DM_GAME_RES` / `DM_3D_SCALE` override). Without a window (app in background) the render thread holds at Present and resumes when a new surface arrives. On front-end pages (main menu, character select / creation) the first finger becomes UI mouse clicks via `dm_ui_touch` (tap = click at the lift point, vertical drag = scroll), as on iOS; in a run the touch HUD and game-state bridge handle gestures, with unclaimed touches available to the raw touchscreen. Gamepad buttons and sticks go to the pad.
|
||||
|
||||
## Implementation and boundaries
|
||||
|
||||
@@ -70,9 +71,32 @@ The data root is `files/d2r` (`dm/main.patched.bin`, `romfs`, `rt64` required).
|
||||
- Build the shader pack with `SB_ALIGN=64` (the `dmsh_vk.py` default). Shaders then derive SSBO offsets from `base & -64`, and vkmeta flag bit 1 lets the host bind storage buffers directly from `addr & -64` with no copy. vkmeta storage flag bit 0 means writable. Packs built with `SB_ALIGN=16` still work through the copy path.
|
||||
- CPU inputs use immutable snapshots. GPU-authored inputs stay in shared GPU buffers; ordered staging copies supply uncovered CPU bytes. Each batch snapshots its GPU writebacks to prevent subsequent batches contaminating earlier results.
|
||||
- Capacity splits retain the logical fence until the final piece completes. Explicit Flush / wait boundaries prevent a strict one-submit-per-frame guarantee.
|
||||
- The current real-window path still waits for presentation and queue idle to preserve temporary WSI semaphore lifetimes. This performance work targets headless rendering.
|
||||
- Windowed present does not drain: each batch slot reuses its acquire semaphore and each swapchain image has its own present semaphore. `VK_ERROR_OUT_OF_DATE_KHR` on acquire recreates the swapchain and retries; on present it marks the swapchain for recreation at the next frame. Surface changes wait for the queue to idle before the swapchain is dropped.
|
||||
|
||||
`RENDER_PROFILE` counts actual Vulkan submissions including Present; the old counter excluded Present. `RENDER_CACHE_PROFILE` records cache reuse, pass count, pass breaks, transient buffer use and `gpu_ms` (GPU time of the interval from timestamp queries). `RENDER_INPUT_PROFILE` records uploads and shared GPU reads. `WAIT_PROFILE` splits CPU-side GPU wait time by origin (sync / event / present / slot / readtex / texrel / sampler / pooldel / finish / capture, as `ms/count`), plus `sync_lag_max` and `event_queued` / `event_blocked`.
|
||||
|
||||
See [PERFORMANCE.md](PERFORMANCE.md) for measurements and validation limits. Keep binaries, caches, logs and game screenshots under ignored `dm/android/build/` or device test directories.
|
||||
|
||||
|
||||
## Subresource layouts and cross-GPU verification
|
||||
|
||||
See [VALIDATION.md](VALIDATION.md) for this change's completed checks and outstanding device/package validation.
|
||||
|
||||
Inspired by [dodola/d2r-mobile at 642480b](https://github.com/dodola/d2r-mobile/blob/642480b7606cf4adda30bcf009eb56f87745c908/dm/gfx/nvn/nvn_vk.c), this backend tracks per-mip layouts for disjoint sampling/rendering on drivers without feedback-layout support. The bounded path covers single-layer 2D color images with 2–16 mips. Every sampled view in both graphics stages must avoid every attachment mip. Overlap, storage images, comparison sampling, depth/stencil, arrays and volumes retain the original path. Whole-image operations consolidate each run using its actual old layout, preserving pixels during upload, copies and readback.
|
||||
|
||||
No build91738 addresses, resource paths or input services were imported. The build94012 HUD/save/build integration remains in place. **Existing Adreno validation remains the supported scope. Mali requires device validation; a successful capability probe does not prove game compatibility.**
|
||||
|
||||
Game-free checks (each output directory must be new):
|
||||
|
||||
```sh
|
||||
# Host layout regression + ASan/UBSan + NDK test binary build; no device access
|
||||
python3 dm/android/tests/run_checks.py --output dm/android/build/checks-local
|
||||
# Host checks only; NDK Vulkan headers are still required
|
||||
make -C dm/android host-tests
|
||||
# Explicit device opt-in: runs test binaries, does not install/start the game
|
||||
python3 dm/android/tests/run_checks.py --output dm/android/build/checks-device --run-device --serial DEVICE_SERIAL
|
||||
```
|
||||
|
||||
Use `--ndk /path/to/ndk` and `HOST_CC` to select toolchains. `result.json` records commands, exit codes, source/binary SHA-256 and whether device/GPU checks actually ran. `t_vk_caps` emits system-driver GPU/features/extensions/formats/memory JSON; it does not inspect the app's private driver. `t_vk_perf` includes cross-stage overlap checks and real GPU multi-mip readback. Run `t_vk_perf mips` for only the added cases.
|
||||
|
||||
Compare `DM_VK_SUBRES=0` / `1` on the same build94012 game, character, location, output extent and fixed 3D scale. Record driver, actual refresh rate, SurfaceFlinger display intervals and temperature. Check pixels and save/resume before evaluating speed. Different builds/drivers and submission-only FPS are not controlled comparisons.
|
||||
|
||||
Reference in New Issue
Block a user