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

air: scope the patch's case to where a rounding mode is required

vcvkk2c639330a36c
diff --git a/docs/air.md b/docs/air.md
index fda6d5e..87ee0e4 100644
--- a/docs/air.md
+++ b/docs/air.md
@@ -205,6 +205,20 @@ functions and not entry points at all.
and `ushort` (2). **There is no `half4` among them.** The token does occur once somewhere in the
shared cache, which makes the spelling plausible and attests nothing about this use of it.
+ **And there is a second half to the f16 question that no harness can settle, because nothing is
+ required.** One F16 path through that `create_cov` branch is `pack_half_2x16`, and
+ `nir_lower_mediump.c` says of it, in Mesa's own words, "pack_half rounding is undefined". Where
+ the specification requires nothing, a truncating `packHalf2x16` is a permitted choice and not a
+ fault, so a measurement of it would be an observation about an implementation rather than an
+ argument about conformance — and the patch's header now scopes its case to the destinations where
+ a mode *is* required, integer to float, naming the `pack_half` path as a reviewer's question
+ instead of leaving it to be found. A peer session had planned to reach the F16 branch through
+ `packHalf2x16` for exactly that reason and dropped it on this, which is the better call: the
+ experiment would have answered our internal question and been useless for the report.
+
+ So the f16 question is two questions. For integer-to-half, round-to-nearest-even is required and
+ this instrument cannot ask. For `pack_half`, nothing is required and there is nothing to ask.
+
And the spelling is the smaller problem. A `half` render target appears in **no** module of the
corpus, so a shader built around one would exercise a path through this frontend that Apple's own
shaders never take and that nothing else here tests. A disagreement would then sit between two
diff --git a/tools/mesa/ir3-round-default.patch b/tools/mesa/ir3-round-default.patch
index 28c9a19..548fd8e 100644
--- a/tools/mesa/ir3-round-default.patch
+++ b/tools/mesa/ir3-round-default.patch
@@ -38,10 +38,24 @@ air.convert.f.{f32,v2f32,v3f32}.{u,s}.* disagree with C on exactly the inputs
that need rounding -- 5 declarations, and i2f truncates just as u2f does. Two
unrelated front ends reaching the same instruction return the same wrong number.
-Not verified: whether the same field is honoured for a 16-bit destination. That
-branch covers TYPE_F16 as well, but this port's harness cannot read a half back
-(air_run has no 16-bit render target), so the ten half-returning declarations of
-the corpus are set aside rather than claimed either way.
+The case for this change is the destinations where a rounding mode is REQUIRED:
+integer to float, where IEEE-754, GLSL and OpenCL all specify
+round-to-nearest-even, and which the measurements above cover. It is deliberately
+not argued from the rest of the branch.
+
+Not verified: whether the field is honoured for a 16-bit destination. The branch
+covers TYPE_F16 too, and the measurements do not reach it -- this port's harness
+packs every half result into a float4, so no shader it generates declares a half
+output, and a half render target appears in none of the 456 modules of the corpus
+it was built from.
+
+Worth a reviewer's attention rather than hidden: one F16 path through this branch
+is pack_half_2x16, and nir_lower_mediump.c says of it "pack_half rounding is
+undefined". Where nothing is required, setting ROUND_EVEN changes behaviour
+without correcting it -- permitted either way, and not part of the argument here.
+If that is unwelcome, the narrower change is to set the default only when the
+source is an integer type, which is where the requirement lives; the measurements
+above would be unaffected.
The block is byte-identical in Mesa 26.2.5, the newest release at the time of
writing, checked by extracting that one file from archive.mesa3d.org, so this is