Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

docs/air: the diagnosis for the texture-as-parameter crash, which was the missing piece

vcvkk1bc97784d5b0
diff --git a/docs/air.md b/docs/air.md
index 8da9866..eb63994 100644
--- a/docs/air.md
+++ b/docs/air.md
@@ -329,10 +329,32 @@ functions and not entry points at all.
is what that predicate is about — is **wrong**: these callees have no `unreachable`
terminator at all.
- So the work is reverted rather than left half-built, and the state above is the committed one.
- What is missing is a diagnosis, not another fix: two speculative ones have already failed, and
- a third would be guessing. Each of the four has exactly one call site, so specialising per site
- costs nothing in duplication when it does work.
+ **The diagnosis is now complete, and it is the second bullet above that causes the third.** A
+ peer session read `nir_dominance.c` and pointed out what the assertion actually says:
+ `nir_block_is_unreachable` asks *the block's own* `nir_function_impl` for its dominance
+ metadata, and `nir_repair_ssa` requires that metadata only on the impl it was called for. So a
+ use sitting in another function's block makes it ask the wrong function — nothing to do with a
+ block being unreachable, which is why that hypothesis failed.
+
+ Their proposed test, `nir_validate_shader` before `nir_lower_goto_ifs`, did not settle it and
+ taught something anyway: it fails identically on `fbs_slice_trilinear`, which translates
+ perfectly. Its complaints are about block indices in an unstructured impl, which nothing indexes
+ before `nir_lower_goto_ifs` — pre-existing and benign, and they masked the real thing.
+
+ The carrier is the `module_values` copy. A probe printing any copied value that holds an
+ `nir_def` found five in `FilmGrainLumaKernel_Uint` alone, of both kinds: a pointer with a byte
+ offset and a plain SSA value. Those defs were created in the *entry point's* impl by
+ `translate_globals`, so copying the values into a callee leaves the callee using the caller's
+ values — exactly the cross-function def/use the peer described, arriving through the globals
+ rather than through an argument. An argument cannot carry one: a guard refusing a pointer
+ argument with an offset never fired, so every pointer argument here has none.
+
+ **So the fix is known and is not a third guess**: `translate_globals` must be split, the part
+ that assigns bindings and appends to `info->resources` running once, and the part that
+ materialises `nir_def`s running per impl, so each callee builds its own. That is a change to
+ shared code that handles six kinds of global, and it is not started. The state above is the
+ committed one; each of the four modules has exactly one call site, so specialising per site
+ costs nothing in duplication once this is done.
- **Of Apple's own 47 kernels, 6 are dispatched, all on software.** `tools/air/kernelcheck.py`
prints where each one stops, as a table whose rows are checked against the total before it is