Files
ncnn/docs
securekim cb137e07dc docs: add guide for AHB zero-copy input on Android (#6733)
* docs: add guide for AHB zero-copy input on Android

Address #5531 - the AHB import API (VkAndroidHardwareBufferImageAllocator,
ImportAndroidHardwareBufferPipeline) has no user-facing docs today and
existing users hit linker errors against the official prebuilt because
build-android.cmd targets -DANDROID_PLATFORM=android-21 which strips the
AHB symbols.

The new page covers build prerequisites (__ANDROID_API__ >= 26),
AImageReader_newWithUsage setup, the per-frame call sequence, per-AHB-
pointer pipeline caching (~5000x setup-cost reduction), and trouble-
shooting for #5531 / #5190.

* docs(ahb): add ex.input(VkMat) format-matching caveat + soften cache bound

Two findings from a follow-up spike on Adreno 830:

- ex.input(VkMat) does NOT auto-convert format. The previous draft's hint
  "// ex.input(\"data\", dst, cmd);" actually crashes if the network was
  loaded with use_fp16_storage / use_fp16_packed (common on Vulkan path) -
  NetPrivate::forward_layer recurses on itself looking for an implicit
  converter that doesn't exist, observed as a ~180-frame stack overflow at
  net.cpp:251. Add a dedicated caveat explaining the failure mode and the
  vkdev->convert_packing workaround, and weaken the snippet hint accordingly.

- AImageReader's AHB pool isn't strictly bounded by maxImages. Under steady
  state it stays at maxImages (3 -> 3 cache_n in 36 consecutive cycles), but
  surface/focus events can transiently push it higher (observed cache_n=7
  with maxImages=3 in one run). Soften the "<= maxImages entries" claim.

* docs(ahb): note cross-vendor validation (Adreno + Mali)

Same import path verified end-to-end on:
  - Adreno 830, Vulkan 1.3.284 (Galaxy S25 Ultra)
  - Mali-G925 Immortalis MC12, Vulkan 1.3.278 (Galaxy Tab S11)

Both report VK_ANDROID_external_memory_android_hardware_buffer spec
version 5 and surface AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 AHBs from the
camera HAL. Only auxiliary usage bits differ between vendors and are
not consumed by this path (Adreno: 0x20103, Mali: 0x20133).
2026-05-25 16:12:29 +08:00
..
2025-09-23 19:06:07 +08:00
2025-09-23 19:06:07 +08:00
2026-01-06 16:47:10 +08:00