Android: CNSDK display-processor plug-in (libdxrp050_leia_cnsdk.so)#11
Open
leaiss wants to merge 4 commits into
Open
Android: CNSDK display-processor plug-in (libdxrp050_leia_cnsdk.so)#11leaiss wants to merge 4 commits into
leaiss wants to merge 4 commits into
Conversation
5 tasks
Collaborator
Author
|
@dfattal — reposting from the closed #5 (which was sourced from my fork; now consolidated to upstream branches). Same content. Android CNSDK plug-in stack #11 → #14 ready for review, CI green, end-to-end validated on Android-36 emulator up to |
…me PR #268)
Companion to displayxr-runtime PR #268, which splits the Android POC
along the post-#263 plug-in boundary. Runtime side keeps the cross-
cutting infrastructure (is_self_submitting vtable flag, vk_native
Android plumbing, audit fixes); CNSDK + drv-side audit fixes live
here.
Adds `src/drv_leia_android/` as a sibling of the Windows drv_leia/,
sharing the same plug-in entry contract (xrtPluginNegotiate) but
selected at CMake configure time by `if(WIN32)` / `elseif(ANDROID)`.
Source files
leia_cnsdk.{cpp,h} — CNSDK C-ABI wrapper:
core init (worker thread),
interlacer lifecycle,
atlas weave, face-tracking
snapshot. Audit fixes
B2/B4/B5/B10/B11/B12.
leia_display_processor_cnsdk.{cpp,h} — xrt_display_processor vtable.
is_self_submitting=true,
atlas-mode only (no per-
tile blit), DXR_HW_DBG +
DXR_ATRACE blocks gated
on XRT_DEBUG_ANDROID_VERBOSE.
Audit B7 / B8 / B14.
leia_plugin_android.c — entry point + iface. Only
create_dp_vk is non-NULL
(no D3D/Metal/GL on Android).
id = "leia-cnsdk",
probe always succeeds (POC
pattern, async device init).
Build wiring
CMakeLists.txt (top-level) — relax `if(NOT WIN32) FATAL_ERROR`
into `if(NOT WIN32 AND NOT
ANDROID)`; branch
add_subdirectory between
src/drv_leia (Windows) and
src/drv_leia_android (Android).
Skip the NSIS installer on
Android (APK is the install).
src/drv_leia_android/CMakeLists.txt — new. find_package(CNSDK CONFIG
REQUIRED) on CNSDK_ROOT;
builds libdxrp050_leia_cnsdk.so
matching the runtime's plug-in
filename convention; symbol-
hidden except xrtPluginNegotiate.
Docs
docs/cnsdk-android-calibration.md — moved from displayxr-runtime
docs/cnsdk-axis-calibration
branch per PR #271 plan, with
file-path refs rewritten to
point at src/drv_leia_android/.
Status: compiles in the standalone repo; not yet wired into the runtime
APK's Gradle (manual jniLibs/ drop per README until the multi-module
gradle setup lands). First hardware install gated on Lume Pad arrival.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ndroid
The Android NDK toolchain (android.toolchain.cmake) defaults
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to ONLY, which restricts find_package()
to NDK sysroot dirs and silently ignores anything we add to
CMAKE_PREFIX_PATH outside that. Result:
find_package(CNSDK CONFIG REQUIRED)
found nothing even with CNSDK_ROOT set + appended to CMAKE_PREFIX_PATH,
breaking the standalone NDK build with "Could not find a package
configuration file provided by 'CNSDK'".
Flip the mode to BOTH at the top of src/drv_leia_android/CMakeLists.txt
so the CNSDK install at CNSDK_ROOT becomes searchable. Mirrors what the
runtime APK's gradle does via cmake.arguments
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH".
Also widen .gitignore to cover build-*/ so out-of-tree builds like
build-android/ don't end up staged.
Verified end-to-end:
cmake -B build-android -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
-DCMAKE_MAKE_PROGRAM=$NDK_CMAKE/bin/ninja.exe \
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-29 \
-DCNSDK_ROOT=$RUNTIME/cnsdk \
-DDXR_RUNTIME_SOURCE_DIR=$RUNTIME \
-DEigen3_DIR=$RUNTIME/.../intermediates/eigen/eigen-3.4.0/cmake
cmake --build build-android --target dxrp050_leia_cnsdk
Output: libdxrp050_leia_cnsdk.so (1.8 MB, xrtPluginNegotiate exported)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Android CNSDK display-processor factory wired six optional vtable slots (on_pause, on_resume, is_self_submitting, get_predicted_eye_positions, get_display_dimensions, get_display_pixel_info) but never set the struct_size header introduced by ABI v2. The impl is calloc'd, so it stayed 0 — under the v2 runtime, XRT_DP_HAS_SLOT bounds every optional slot against struct_size and reads them all as absent. Most damaging: is_self_submitting=true would be ignored, regressing the self-submitting atlas path into a per-frame double submit. Mirrors the drv_leia (Windows) migration in a6c0d7d. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
923a309 to
2f9b688
Compare
Collaborator
Author
|
Rebased the whole Android stack (#11→#18) onto current
Verified: builds clean against the |
… mono NULL-guard Post-ABI-v2 review pass: - leia_plugin_android.c: make the probe_displays omission deliberate with an explicit `.probe_displays = NULL` + rationale. struct_size spans the full v2 iface, so the runtime's gate sees the slot, finds NULL, and uses the synthesized primary claim — correct for a single-panel Android device with no monitor enumeration (Windows arm implements it over EDID; Android has none). - leia_display_processor_cnsdk.h: fix stale doc that described the obsolete per-tile-blit path; current code is atlas mode (SBS VkImage handed straight to leia_cnsdk_weave, no per-view blit). - leia_display_processor_cnsdk.cpp: NULL-guard vk / vk->main_queue in the mono 1x1 passthrough fallback before dereferencing main_queue->queue, mirroring the atlas-weave path's existing guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion to displayxr-runtime PR #268, which splits the Android POC along the post-#263 plug-in boundary. The runtime side keeps the cross-cutting infrastructure (
is_self_submittingvtable flag,vk_nativeAndroid plumbing, audit fixes); CNSDK + driver-side audit fixes live here.Adds
src/drv_leia_android/as a sibling of the Windowssrc/drv_leia/, sharing the same plug-in entry contract (xrtPluginNegotiate) but selected at CMake configure time byif(WIN32)/elseif(ANDROID).Source files (new
src/drv_leia_android/)leia_cnsdk.{cpp,h}leia_display_processor_cnsdk.{cpp,h}xrt_display_processorvtable wired to the wrapper.is_self_submitting=true, atlas-mode only (no per-tile blit — CNSDK splits the SBS atlas internally viaset_interlace_view_texture_atlas),DXR_HW_DBG+DXR_ATRACEblocks gated onXRT_DEBUG_ANDROID_VERBOSE. Audit fixes: B7 (vkDeviceWaitIdle between weave + HUD record — masked on Android, future-proof), B8 (mono 1×1 passthrough), B14 (pause/resume from session begin/end).leia_plugin_android.cxrtPluginNegotiateentry point +xrt_plugin_ifacevtable. Onlycreate_dp_vkis non-NULL (no D3D/Metal/GL on Android).id = "leia-cnsdk".probealways succeeds (POC pattern — CNSDK device-config is async, so synchronous probing isn't possible atxrCreateInstancetime). Minimalleia_android_hmd_create()with hardcoded Lume Pad 2 defaults; CNSDK metrics surface lazily via the DP'sget_display_dimensions/get_display_pixel_infoonce the async core init completes.Build wiring
CMakeLists.txt(top-level): relaxif(NOT WIN32) FATAL_ERRORtoif(NOT WIN32 AND NOT ANDROID). Branchadd_subdirectorybetweensrc/drv_leia(Windows) andsrc/drv_leia_android(Android). Skip the NSIS installer on Android — APK + jniLibs/ is the install path.src/drv_leia_android/CMakeLists.txt:find_package(CNSDK CONFIG REQUIRED)onCNSDK_ROOTenv var or CMake var. Buildslibdxrp050_leia_cnsdk.so, matching the runtime's plug-in filename convention (libdxrp<NNN>_<id>.so). Symbol-hidden exceptxrtPluginNegotiate.Docs
docs/cnsdk-android-calibration.md— moved from displayxr-runtime PR #271'sdocs/cnsdk-axis-calibrationbranch, with file-path refs rewritten tosrc/drv_leia_android/…. Three CNSDK convention assumptions (face axis signs/units, tile-to-eye mapping, UV vertical flip) with symptom→fix tables for on-device bring-up.How this slots into the runtime APK (POC mode)
The runtime's
target_plugin_loader.cAndroid branch (PR #309, commitc96c93ce8onmain) discovers the plug-in viadladdr-of-self + dirname enumeration atxrCreateInstancetime. v2 multi-APK discovery (separate vendor APKs each shipping plug-ins) is tracked at runtime #310.Status
jniLibs/drop per the README until multi-module Gradle integration lands — follow-up).docs/getting-started/android-bringup-checklist.mdin the runtime repo.Test plan
cmake -B build-android -DCMAKE_TOOLCHAIN_FILE=...configures cleanly withCNSDK_ROOTset.cmake --build build-android --target dxrp050_leia_cnsdkproduces a.sowhose only exported symbol isxrtPluginNegotiate(llvm-nm --defined-only --extern-only libdxrp050_leia_cnsdk.so)..sointo the runtime APK'sjniLibs/arm64-v8a/,assembleInProcessDebugproduces a single APK that contains bothlibopenxr_displayxr.soandlibdxrp050_leia_cnsdk.so.adb logcat | grep target_plugin_loadershows the loader discoveringlibdxrp050_leia_cnsdk.soand successfully callingxrtPluginNegotiate.android-bringup-checklist.mdTest A).🤖 Generated with Claude Code