Skip to content

pvr/g5p: Apple A8 (T7000) Vulkan - #18

Draft
brkosebay wants to merge 72 commits into
OrchardLinux:mainfrom
brkosebay:a8-gpu
Draft

brkosebay wants to merge 72 commits into
OrchardLinux:mainfrom
brkosebay:a8-gpu

Conversation

@brkosebay

@brkosebay brkosebay commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR goes together with OrchardLinux/orchard#196, which carries the kernel driver (powervr's A8 variant), the device data and the test payload. This PR is the userspace half.

What works (iPod touch 6)

The GPU has been tested on the iPod touch 6 only. The iPad mini 4 and iPhone 6 have the same GPU, and testers are wanted (see the orchard PR).

  • The A8 (GX6450, BVNC 3.10.4.5) is a third Apple chip on the G5P (A9) paths. Where the A8 differs, apple_g4p selects its form; the forms are taken from Apple's A8 Metal driver output.
  • Vulkan 1.2 works with the device name "PowerVR Apple A8". Every Vulkan pixel test in the orchard example's ladder passes.
  • OpenGL ES 3.1 works through unmodified Zink.
  • vkmark scores 804 at 256x256 and 332 at 750x1334.
  • glmark2 (OpenGL ES through Zink, A8 scene list) scores 611 at 256x256 and 311 at 750x1334.
  • A soak of 514k jobs ran without a fault.

What the A8 has

  • Compute: the A8's launch, its load and store forms and its address build.
  • Render: the A8's draw control and colour target words, its end of tile, and its region-header ring (one mirrored ring per render target, as AGXG4P allocates it).
  • Colour targets: BGRA8/RGBA8 UNORM, RGBA16F, RGB10A2, R8, RG8, R32F, RGBA8UI, and two colour targets.
  • Depth/stencil: D32F and D32F_S8 only.
  • Textures: twiddled single-level colour images, cube maps, and colour LOAD.
  • What the A8 has no form for yet is refused by name instead of risking a lockup: indirect draws and dispatches, other depth formats, 4x MSAA, sRGB targets, and other sample forms. vkCmdBlitImage stays a CPU transfer.

Preliminary

  • Two debug switches are left in. Both are off unless set: PVR_G5P_TEXDIAG (texture diagnostics, read once) and PVR_G5P_CPU_CLEAR (clears on the CPU).
  • Per-job submission overhead is not optimized yet.
  • Before merge, some small follow-ups may be folded into the commits they fix, e.g. "drop has_astc from the A8 entry".

How to test

  1. Build on aarch64 Linux. The tested build used -Dvulkan-drivers=imagination -Dgallium-drivers= with -Dplatforms=x11,wayland. The headless line below has not been run from scratch yet:

    meson setup build . --buildtype=release -Dvulkan-drivers=imagination -Dgallium-drivers= -Dplatforms= \
      -Dglx=disabled -Degl=disabled -Dgbm=disabled -Dllvm=disabled
    ninja -C build
  2. Follow the orchard PR's test steps. examples/ipod-gpu-drm/vk/make-bundle.sh build OUT packs this build, the Vulkan smoke test, the ladder and vkmark into the /opt/a8vk bundle that the RAM payload carries.

  3. For OpenGL ES, build Zink from this tree (-Dgallium-drivers=zink) over the same Vulkan driver.

What's new (seven commits on top of 8f75907)

Qt Quick runs on the GPU. The desktop shell, the control center and Qt apps (Files, a calculator, an activity monitor) draw through Zink on the A8, with no refused shaders. That includes Qt Quick Effects' MultiEffect: shadow, blur, mask and colorize.

Multi-texture programs. Before this, the A8 sampled one image slot only. A program now samples two to seven textures, with one shared sampler or with one sampler per texture. The layout also starts after the blend colour and storage-buffer pointers, so constant-colour blends of textured draws work.

  • The encoding is Apple's own. On a jailbroken iPod touch 6 (iOS 12.4), a small Metal app runs test passes that sample 2, 3, 4, 5 and 7 solid-colour textures, with one shared sampler and with one per texture. It then reads back AGXMetalA8's compiled programs and PDS data from its own GPU memory. In that capture:
    • byte 4 of the sample is the image's common-store dword × 2;
    • the sampler's four-dword slot is byte 1 bits 7:6 plus byte 5 bits 2:1;
    • byte 6 is constant;
    • between samples of different images Apple's programs wait 4d 04;
    • the seven-texture program's PDS loads 28 dwords of image state to common 0 and its sampler to dword 28.
      The driver uses the same layout.
  • Hardware evidence (iPod touch 6).
    • A multi-texture test reads the right texels with 2, 3, 4 and 5 textures, and with 1, 2 and 4 textures under a constant-colour blend. Each texture is a different solid colour, so every output channel names the image it came from.
    • Checker-texture cases give one texture a NEAREST or LINEAR filter that differs from texture 0's. They pass, so each sample reads its own sampler state.
    • Qt Quick's item grabs pass 29 of 29 materials, MultiEffect included.
  • Not captured yet. One sampler per texture with seven images would need sampler slots 12 and 13, which the capture does not show. Seven images therefore share texture 0's sampler, as Apple's seven-texture program does.

Also new

  • Linear colour targets (every GBM/dma-buf buffer, so a compositor's output) LOAD through their stride texture state. labwc's damage-only redraws used to be refused.
  • Saturated varyings take the general path: iterate, then saturate in the ALU. Qt's vertex-colour shaders used them.
  • Zink on the A8 blits without texel fetch and without the no-perspective iterator, neither of which has an A8 form yet. The desktop's glReadPixels readback works.
  • A refused texture sample names its image and sampler bindings, common-store positions, image count and sample kind.
  • PVR_A8_A9_FORMS (default on): texture slots that Apple's form does not reach take the A9's sample instead of being refused. This form has no A8 capture behind it. PVR_A8_A9_FORMS=0 refuses them.

What's new (22 commits on top of 77753d6)

Texture reads that WebRender needs. On the A8 these were all refused before; all but vertex-stage textures work now.

  • texelFetch. A fragment texelFetch of a 2D texture is drawn the way Apple's A8 compiler draws a Metal read(): the integer coordinate as a float, sampled with the read bit (byte 6 bit 2) through a fetch sampler. The fetch sampler is the binding's sampler made point-filtered, non-normalized and clamped to the edge and the level. Integer textures return the texel's bits. On an iPod touch 6, RGBA8, RGBA32F and RGBA32I fetches at level 0 read every texel right. A level above 0 stays refused unless PVR_A8_TEXFETCH_LEVEL is set.
  • Vertex-stage textures: opt-in, not working yet, refused by default. PVR_A8_VTEX=1 lets a vertex texture take the A9's qualified vertex recipe over the A8's four-dword image and sampler words. On the iPod a vertex texelFetch read zeros and a vertex textureLod locked the TA, so it is off. Apple's form, below, is the next candidate.
  • Uniform texel buffers in fragment programs. st/mesa draws glTexSubImage2D from a pixel-unpack buffer with a fragment program that texelFetches a texture buffer, and WebRender uploads that way on desktop GL. On the A8 a buffer view is now a plain linear 2D image 4096 texels wide, following the A9's texel-buffer contract. The program folds the index to 2D and reads it with the A8's texelFetch. On the iPod, an RGBA8 upload from a pixel buffer at offset 16 reads back right. PVR_A8_TBO=0 refuses these reads.
  • Varying reads. Programs with more than eight varying reads stay on dependent-read counter 0 and wait for each batch of eight, as Apple's A8 programs do. The counter-1 iterator has no capture. This refused 14 of WebRender's 31 GLES shader variants.

WebRender's fragment programs compile for the A8, in their GLES form and with WebRender's desktop-GL texelFetchOffset form. Its vertex programs still need vertex-stage textures.

A refused shader no longer loses the context. A refused program or render pass used to fail its command buffer at vkEndCommandBuffer. Zink then dropped the batch, and the whole application's GL context was lost. Firefox lost its context after a refused upload program, with vkEndCommandBuffer failing. That failing call has not been pinned down yet; the per-reason printing below should name it.

  • The A8 now uses the driver's existing skip-refused-work mode by default. The refused work loses its draws, and the command buffer stays valid. PVR_A8_STRICT=1 restores the failure.
  • Every distinct refusal reason is now printed once. Before, a call site printed only on occurrences 1, 2, 4 and so on, which could hide a second, different reason.
  • A fragment texture form with no A8 capture now names its op, dimension, result type, level, offset and texel-buffer origin.

Depth/stencil reloads. A depth or stencil buffer stored by one render and loaded by the next read back wrong on the A8 at every size whose 32-pixel tile count is not a power of two on both sides. That covers the full screen, 640x1136. The cause was ZLSCTL's extents, which carried the plain tile count. Rogue's ZLSCTL documents that in twiddled mode the extent is the tile count rounded up to a power of two. With that change, every size from 640x1136 down to 37x29 reads back right on the iPod.

Memory

  • The A9 driver's memory work is ported to the A8:
    • submit and bind retries while the kernel makes a VM resident;
    • purgeable cached suballocator chunks;
    • a larger render-target dataset cache;
    • the parameter-manager pool request;
    • separate suballocators for command-buffer uploads;
    • suballocator buffer reuse;
    • empty-tile skipping;
    • BO log summaries;
    • a swapchain image-count override for Zink.
  • The A8 gets its own sizes for these caches. Its kernel sizes its own parameter-manager pool, and the iPod has 1 GB shared by CPU and GPU.
  • Depth/stencil planes take the ZLS's rectangle instead of the larger side's square. A 640x1136 D32F_S8 takes 10 MiB instead of 20.
  • Single-level colour images whose sides are not both powers of two stay linear, as on the A9. A 2018x1136 BGRA8 takes 8.8 MiB instead of 16. They render, reload and sample right on the iPod.
  • With PVR_DEBUG=bo_log, the summary counts the renders that load or store a depth/stencil attachment, by size.

Opt-in, from Apple's binaries, not yet run on the hardware. Apple's A8 compiler samples at an explicit level in stages without derivatives, and its driver builds vertex texture state the same way as fragment state. An iOS capture shows the explicit-level form: mode 2, byte 7 0x09, and the f32 level in the register after the coordinate.

  • PVR_A8_VTEX_APPLE=1 enables vertex textures in that form, instead of the A9's recipe.
  • PVR_A8_TEXFETCH_LEVEL=apple draws every fragment texelFetch, at any constant level, in Apple's read form, through Apple's constant read sampler.

Known open items

  • Vertex-stage textures do not work yet (above).
  • texelFetch above level 0 is opt-in.
  • The TA lockup from the vertex textureLod was recovered once by the kernel's lockup recovery, and froze the whole SoC on a second run. That is a kernel issue, tracked separately. With vertex textures off by default, nothing in this series reaches it.
  • Two of the ported commits add proposed kernel UAPI to include/drm-uapi/pvr_drm.h: a capability query and BO_MADVISE. Their commit messages say so. That UAPI must be replaced by the merged kernel header before this lands.

🤖 Generated with Claude Code

Add the device-info entry for the A8 GPU, BVNC 3.10.4.5 as the kernel's
legacy decode gives it for the CORE_REVISION 0x00030a00 and CORE_ID
0x011b0405 measured on an iPod touch 6. It sets apple_g5p, so the A8
takes the A9's paths (the same firmware job protocol, seven-word Rogue
CDM records, an ISA of the same Apple family), and a new apple_g4p bit
that marks where the A8 differs.

Compute pipelines are refused by name on the A8 until Apple's
residency limits for it are known, instead of reaching the
UNREACHABLE in pvr_compute_wg_residency_ok().

Generated-by: LLM
The A8 encodes the PDS DOUT instruction the stock Rogue way (src0 at
bits 8-14, src1 at 16-23), where the A9 and A10 use Apple's extended
form. Metal's PDS programs on an A8 decode to the A10's operands in
that layout: DOUTW q0, c2 is 0xf0024001 there and 0xf0000a01 on the
A10, the binding DMA is f0040000 f4060100 d3000000 against f0001000
f4001808 d3000000. The A9 graphics paths now take the PDS features
from the device (PVR_G5P_PDS_FEATURES()); pdsc emits exactly those A8
words without DOUT_EXT. Data words are packed the same in both forms.

The A8 iOS driver writes EVENT_PIXEL_PDS_INFO 0x202 for a one-target
64x64 BGRA8 pass where the A9 writes 0x402: the USC shared size is in
Rogue's 16-dword unit, not twice it. g5p_mrt_eot_info_g4p() gives that.

Generated-by: LLM
Nothing reads it; ASTC is reported through apple_g5p, as for the A9.

Generated-by: LLM
… A8 output

Compute (AGXMetalA8, iOS 12.4):
- residency limits from ComputeProgramVariant (0x1a13eb034 -> +0x790,
  maxTotalThreadsPerThreadgroup): budgets 3585 and 262144, the A9's
  routine with other constants;
- PDS DOUT in Rogue's layout (G5P_PDS_DOUT()), from its compute PDS
  encoder (0x1a1453d44);
- the kernel launch in that encoder's order: branch past the coefficient
  task's writes, no END in that part, no padding HALTs;
- KERNEL8 max_instances as it computes them (0x1a1428938); 8 for a 1x1x1
  kernel, Metal's 0x40000000.

Fragment (Apple's A8 compiler output, a8-shadercap on an iPod touch 6):
- emitpix takes byte 3 bit 0 and the extension halfword 0x8200;
- varyings iterate with opcode 0x18 (the four captured shapes);
- texture samples are another form, refused by name;
- the background program is the A9's but for the emitpix;
- the end of tile is 1e 01 00 70 plus the branch, fed the target's
  address and 2, 0 (one float target; others refused by name).

The vertex programs Apple compiles for the A8 are the A9's byte for byte.

Generated-by: LLM
The A8 samples a 2D texture with an implicit LOD and a packed-f16
result in a 12-byte form (Apple's A8 f_tex: 1a 59 00 41 00 01 88 01 00
01 00 80; the A9's 18 f5 00 01 08 80 for the same source). Destination
half, coordinate dword and sampler qword are placed as Metal's blit
program's eight samples show them; only that shape with the image
descriptor at common qword 0 is taken, the others stay refused.

AGXMetalA8's one-workgroup-per-task flag (ComputeProgramVariant +0x79b)
is field 30 of the kernel's compute metadata table, which Apple's
compiler sets, of 25 test kernels, only for the one with a device
atomic, not for the barrier kernel: KERNEL8 max_instances now keys on
device/SSBO/image atomics instead of barriers.

Generated-by: LLM
The A8 takes its colour target's format, size and layout from the 3D
record (W+0x118 + 16 i), where AGXMetalA8 writes Rogue's
PBESTATE_REG_WORD0/1 per target and an empty clip rectangle for the
unused ones. Mesa sends them in the
Rogue fragment command's pbe_word[8][3], which the merged kernel's G5P
fragment stream already parses into cmd.regs: target 0's pair from
g5p_pbe_a8_reg_words(), then the empty pair, word 2 zero. The formats
captured on the A8, BGRA8 and RGBA8 UNORM, are taken; others are
refused by name.

Generated-by: LLM
The A9's firmware takes a PDS and a USC execution base (PLATFORM
+0x10/+0x18, powervr's two heap bases), so DOUTU's USC offsets count
from the USC heap. The A8's takes one: Apple writes 0x3_00000000 to
both words of its pair (PLATFORM +0x20/+0x28), and code runs there and
faults at 0x1_ (device run). On the A8 the USC offsets therefore count
from the PDS heap's base (PVR_G5P_USC_EXEC_BASE()); the kernel puts the
PDS heap at the execution base and the USC heap above it in the same
4 GiB window.

Generated-by: LLM
Three words the G5P path took from the A9 captures, now in the A8's form
from AGXMetalA8 (iOS 12.4):

- PPP_CTRL drawclippededges: the render encoder init writes 0x6a0
  (0x1a1450cb8) and no setter clears bit 9 (cull 0x1a1449a90, clip mode
  0x1a1449b00, 0x1a144ac2c, 0x1a144ac90).
- INDEX_LIST: no split count, index_size 0 when not indexed
  (0x1a144b3c8, 0x1a144b484; indexed 0x1a144b684, 0x1a144b830).
- STATE_STREAM_OUT1: PDS data 1, temps 1, no bit 14 (0x1a144f654, over a
  default of 0 at 0x1a1459500; same 16-byte + HALT program).

Our triangle's words now equal Apple's captured A8 draw.

Generated-by: LLM
- Indirect draws: AGXMetalA8 has none. Both render encoders raise
  APINotSupported for drawPrimitives:indirectBuffer: and the indexed form
  (0x1a144b89c, 0x1a144b8dc; sampled 0x1a145176c, 0x1a14517ac), so there is
  no A8 form and the VDM indirect index list is unproven there.
  multiDrawIndirect and drawIndirectFirstInstance are off on the A8.
- Depth/stencil attachments: the A8 3D record's ZLS words are only partly
  placed (tail copies only); refused until a depth pass's record is read
  on iOS.

Generated-by: LLM
AGXMetalA8's dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:
threadsPerThreadgroup: is a bare return on the A8 (0x1a14458d4; the
sampled encoder's 0x1a1447638 only books statistics): Apple's A8 driver
has no indirect dispatch, so there is no A8 form to follow.

Generated-by: LLM
The iPod touch 6 (iOS 12.4) depth passes give the A8's ZLS words:
ZLSCTL carries Rogue's extent (32-pixel tiles minus 1, zlsextent_x_z /
zlsextent_y_z) and there is no ZLS_PIXELS word: 0x080e200c for
D32F_S8 clear/store at 64x64, 0x080ee00e loaded, 0x080a200c depth only.
The stencil plane (depth + 0x4000, enable bit), BGOBJVALS (0x35a) and
the draw's ISP words (0x03cc0000 / 0x03c00000) were already the A9's
and equal Apple's A8 values.

D32F and D32F_S8 at one sample are unrefused on the A8; other formats
and MSAA depth stay refused by name.

Generated-by: LLM
From the iPod touch 6 capture and runs on the device:
- no fence bit on a kernel record: Apple's 25 kernels never set it, and
  adding it to Apple's working job locks it up;
- PDS data units counted directly in KERNEL0 (Apple's one-unit records
  carry 1);
- a kernel that reads neither the workgroup ID nor threadgroup memory
  gets Apple's plain launch (c2c00002 d3000000 f0024001 fc000002
  d3000000, one unit, no common store: KERNEL0 0x2106); one that reads
  the ID gets Apple's layout (control words at c2/c3, KERNEL0 0x42106),
  keeping the 64-bit ID write tested on the device;
- the pass end is Apple's K3 (empty USC task, 0x4) and K4 (fenced
  DOUTC task, 0x7) instead of the A9's barrier task and type-3 fence
  blocks, which lock the A8 up. K0 + K4 alone completes on the
  A8.
The query kernel record drops the fence bit too.

Generated-by: LLM
The A8 does not take the A9's memory instruction as a store: Mesa's
k_store_lid ran to completion inside Apple's proven job and stored
nothing (bmut=0x02). Every load and store of AGXMetalA8's 25
captured kernels has the form W0 size << 11 | 0x0510, W1 0x0500 |
data << 1, W2 address register << 1 | 0x0100 (| 0x8000 store), W3
0x0020 (| 0x4000 store): k_store_one's store is 2510 0504 8100 4020.
Compute code for the A8 (g5p_usc_g4p) now emits it.

The prologue's second word clears bit 15 on the A8 when the kernel's
record has a common store (workgroup ID or threadgroup memory), as
Apple's: 8189 under common size 0, 0189 under 1 or more.

Generated-by: LLM
g9p_addr()'s single 64-bit add of a uniform pair (1189 .. 01a1 0600) does
not form the address on the A8: with the A8 store form, Mesa's
k_store_lid takes a caught fault inside Apple's proven job
(bmut=0x02). AGXMetalA8 builds base + offset from the carry of the low add
(119d, op a5) added to the high uniform, then the low add (k_store_tid,
k_store_const, k_iadd):
  119d 0304 0101 4100 00a5   r2 = carry(s0 + r0)
  1199 0302 8585 4100 00a1   r1 = s1 + r1
  1199 0300 8181 4100 00a1   r0 = s0 + r0
A8 compute code now emits that for a 32-bit byte offset (every caller
passes shift 0).

Generated-by: LLM
From AGXMetalA8's 25 captured kernels:
- the workgroup ID (threadgroup word 0, written by the kernel task's
  PDS) is read with 1516 <2*dst> (k_store_const/tid 1516 0004,
  k_threadgroup 1516 0002), not the A9's 2314 form; only word 0 has a
  captured form, so a y/z read is refused by name on the A8;
- shifts take a literal amount: 119a <0x8000|dst> 0101|a<<10 0120
  0101|n<<1 0120 14f0 (left) and 519e .. 14f4 (right). A constant shift
  on the A8 now uses that form instead of the A9's shift by a register
  (199e .. 04f0), which no A8 kernel has.

Generated-by: LLM
AGXMetalA8's binding task reads the thread count from a 16-byte block of
its own (iPod touch 6 capture: the address table at 0x1_00014100, the
count at 0x1_00014140). Mesa read it 8 bytes into the uniforms, an
8-byte-aligned DMA source for an odd buffer count. On the A8 the count
now goes in its own cache-line-aligned upload.

Generated-by: LLM
The iPod touch 6 capture (a8-passcap) shows the A8's end-of-tile state is
{target, packmode << 16 | conversion, 0}: Rogue's PBE packmode and 2 for
normalised, 0 for float formats (BGRA8 0x00000002, RGBA16F 0x000a0000,
RGB10A2 0x000e0002). Every 4-channel single-target pass uses BGRA8's
fragment program, clear program and end-of-tile USC, and the PBE word 0
swizzle is the identity (0x688) for RGBA16F and RGB10A2.

The A8 now writes that format word (was a fixed 2) and accepts
R16G16B16A16_SFLOAT and A2B10G10R10_UNORM_PACK32 targets. Under a fake powervr device
our state word, PBE words, fragment and clear programs for both equal
Apple's captured ones.

Generated-by: LLM
AGXMetalA8 (iPod touch 6, a8-passcap) writes one output word for an R8
or RG8 target: the fragment program packs R and G (R8: G zero) into one
register and emits 111c 0900 8200; the background program converts one
or two channels (R8 also zeroes half 1: 0188 0101 0101 0120 0128 0039)
and emits the same. The end-of-tile state's format word is 0x002f0002
(U8) / 0x00230002 (U8U8), the PBE swizzle 0x968 / 0x948.

The A8 now compiles such a target with a one-word output (key
a8_narrow_halves), builds the two clear programs at device init, allows
the one-word A8 emitpix, and writes the format words and swizzles.
Under a fake powervr device the fragment program, clear, end-of-tile word and PBE
word 0 equal Apple's for both formats.

Generated-by: LLM
From AGXMetalA8's two-target pass (iPod touch 6, a8-passcap mrt2):
- the end of tile is 1c 01 00 70, 4c 04, 1e 01 00 71 08 00 and the
  branch to the END at byte 64; its state is one 8-dword DMA,
  {t0, 2, 0, t1, 0x122, 0} (target 1's word carries 0x120, not decoded,
  so only RGBA8/BGRA8 targets are admitted);
- the fragment program writes the last target's output dwords first
  and emits 411c 0900 8200;
- the background program converts the last target first and reads
  target t's clear colour from slot n - 1 - t (the colours uploaded in
  reverse target order);
- target 1's PBE pair goes in the fragment stream's pbe_word[1].

Under a fake powervr device (two BGRA8 targets: G5P admits homogeneous sets only)
the fragment, clear and end-of-tile programs equal Apple's byte for
byte, and the EOT state and restore size match.

Generated-by: LLM
AGXMetalA8's RGBA8UI clear (a8-passcap rgba8u) clamps each clear uint
with umin(255, common dword) in the three-source literal form (routing
0xb0) and packs two clamped channels into a 16-bit half with opcode
0xf1 (dst = B | C << 8). Add both encoders and the A8 RGBA8UI
background program; it reproduces Apple's program byte for byte.

Generated-by: LLM
AGXMetalA8 renders RGBA8UI as the float pass shape (a8-passcap rgba8u):
the one-target end of tile with state word 0x00000008 (U8U8U8U8,
integer conversion) and BGRA8's PBE swizzle 0x60a, one packed output
word (emitpix 111c), and an integer background program that clamps and
packs the four clear uints. On the A8, route RGBA8UI there instead of
the A9's raw path: a one-word packed output in the compiler
(a8_packed_word), the A8 RGBA8UI clear, and the format admitted as a
render target. Fragment program, clear, end-of-tile USC and state match
Apple's bytes under a fake powervr device.

Generated-by: LLM
…zzle

AGXMetalA8 renders R32F as the float pass shape (a8-passcap r32f): one
output word holding the red f32 (emitpix 111c), a clear that moves the
red clear f32 from common-store dword 0, the one-target end of tile with
state word 0x00360000 (F32) and swizzle 0x968. Add the f32 one-word
output kind (PCO_G5P_COLOR_F32), the A8 R32F clear, and admit R32F (and
RGBA8UI) as A8 render targets beside the A9 format table. Fragment
program, clear, end-of-tile USC, state and PBE words match Apple's under a
fake powervr device.

The previous commit gave RGBA8UI BGRA8's swizzle from another client's
record (SpringBoard's frame); the rgba8u pass's own record has the
identity 0x688, which the default swizzle already is.

Generated-by: LLM
AGXG4P keeps a render target's region headers in one ring (kext):
its size is the power of two
>= 16 x the per-frame bytes (region headers rounded up to 0x1000), it
lives in the general 0x1_ heap, and the kext maps every page twice back
to back (0x847d738, resources created with flag 0x200000) so a frame's
slice may run past the end; each frame takes the next slice (RTM
+0x1a0), the first at offset 0.

On the A8, allocate the region headers that way: one buffer of the ring
size, a VA range twice as long, and two VM_MAPs of the buffer (new
winsys vma_map_mirror(), pvr_bo_alloc_mirrored()); both render-target
datas name the ring's base and the kernel picks the slice. The ring is
allocated before the TPC, which then follows it in the heap as in
Apple's allocation (ring 0x1_00460000, TPC 0x1_00484000).

Generated-by: LLM
Device-confirmed (iPod): the A8 address build added half
2t of the carry result (r2.lo), so the high address word was s1 +
s0[31:16] and stores landed at 0x11_00100000 for 0x1_00100000. The
carry (op a5) leaves it in the high half: AGXMetalA8's k_store_tid
(USC heap 0x1ec0) adds r2.hi with the register form 99 31 .. .. 84 8b
a1 08. Build the high word as Apple does: the carry into r[dst + 1],
s1 into r[dst] with Apple's common-store move (98 01 .. 03 85 01 00 41
54 01 38 00), r[dst + 1] = r[dst] + r[dst + 1].hi, then the low add.

The graphics address adds (g5p_usc_address_add(_shift): indexed
UBO/SSBO/XFB in VS/FS) use the A9's 64-bit class-0x89 add, which
AGXMetalA8 never emits and which faulted in A8 compute: refuse
them on the A8 until Apple's carry build is ported there.

Generated-by: LLM
powervr's A8 variant refuses a geometry job whose region headers are
not a mirrored ring of at least pow2(16 x align(px * py * 5, 4 KiB))
(s8003_rt_derive(): five bytes per tile of the padded tile grid, the
header size of Apple's record). Size the A8 ring's slice by the larger
of that and Mesa's own region-header array, so the two agree beyond
64x64.

Generated-by: LLM
Each Vulkan process opened the render node for its physical device
and again for its VkDevice, and both winsys instances created a VM
context and mapped the static-memory BOs into it: two VMs per process,
one of which never submits. powervr's A8 variant gives every VM the
hardware-object window, the zero and data pages and a user slot.

Let the physical device's winsys be query-only on the A8: it keeps its
fd for DEV_QUERY and page size, and creates no VM context, heaps or
static memory. A process now holds one VM. A9/A10 are unchanged.

Generated-by: LLM
The A8 (GX6450) TPU takes Rogue's TEXSTATE words: every texture state in
the a8-passcap capture (the tex_* and load passes) decodes exactly as
TEXSTATE_IMAGE_WORD0/1 and TEXSTATE_SAMPLER_WORD0/1, e.g. a 64x64 BGRA8
twiddled target 60008861 003f00fc 40000001 0000403d with sampler
00000fff 02022400. Mesa's G5P path replaced upstream's Rogue words with
the A9's three-qword image state and one-qword sampler, so every A8
sample read a malformed state (the live ladder's texnearest, texlinear
and rtt faulted in the fragment job).

On the A8:
- image views, samplers, combined descriptors, storage views and texel
  buffers keep upstream's Rogue words (the G5P hooks skip apple_g4p);
- alpha_msb stays clear for 8-bit-per-channel formats, as in every
  Apple state (upstream sets it for any alpha-in-W format);
- the fragment program takes the image state (4 dwords) and the sampler
  (4 dwords) right after it, Apple's layout, and the A8 sample names the
  sampler by its common dword (Apple's 0x88 reads dword 4 in tex_plain
  and the load background), where the A9 counts qwords;
- a samplerless read is refused (its fetch sampler is the A9's word);
- PVR_G5P_TEXDIAG=1 logs each texture/sampler upload's words.

Generated-by: LLM
AGXMetalA8's load pass (a8-passcap load) draws the background with a
fixed fragment-style program (passcap USC 0x2180): the position through
a 2x3 matrix, the A8 narrow sample of the target, emitpix of two words.
Its data is three DOUTDs: the target's Rogue texture state into common
dwords 0..3, the sampler 00000fff 02022400 into 4..7 and the identity
matrix into 8..13 (controls 10000004 10008004 90010006, uniform size 3
units, common size 14 dwords). Upload Apple's program at device init and
build that background for an A8 LOAD of one single-sample twiddled
BGRA8/RGBA8 target; the texture state, sampler, DMA code and controls
match Apple's under a fake powervr device.

Generated-by: LLM
AGXMetalA8 sets TEXSTATE_IMAGE_WORD1.mipmaps_present only for a state of
several levels: 0 for the one-level load target (40000001 0000403d), 1
with seven levels in tex_plain (30008007). Upstream set it for a
one-level view of a mipmapped image (the ladder's texture: 58008001),
the last bit in which our A8 state differed from Apple's. Follow Apple
on the A8.

Generated-by: LLM
The A8 iterates a texture coordinate with its plain iterator, a
dependent read on counter 0. AGXMetalA8's f_tex and every tex_*
fragment program in the captures wait for it before the sample:
18 11 00 81 04 00, 4d 00, 1a 59 ... (the A9's coordinate iterator feeds
its sample directly, so the shared path emitted no wait). Without it
the sample read the coordinate register before the iteration landed:
on the live iPod the texture rungs got clamped corner texels, a
different count on every run, while a colour varying (waited for in the
varying batch) interpolated exactly. Emit the wait on the A8; the
texture fragment program is now byte-identical to Apple's f_tex.

Generated-by: LLM
Qt Quick's vertex-colour shaders (smoothcolor, vertexcolor) were refused
on the A8: fsat(varying) into a blended target takes the narrow
saturating iterator, whose A8 form is not captured. On the A8 it now takes
the A9's general path: iterate the varying, then the shader's own
saturate in the ALU, as the A9 does wherever the narrow form does not
apply. The A9 is unchanged.

Generated-by: LLM
…tate

Every image shared outside the driver (GBM, dmabuf) is linear on the A8,
and the A8's LOAD refused a linear target. A compositor redraws only the
damaged part of its output buffer, which LOADs it: on the iPod, labwc's
damage frames were refused and their command buffers failed
(vkEndCommandBuffer), so a fresh composite stayed black and the panel
kept an old frame.

Apple's load program samples the target through the view's Rogue texture
state words (TEXSTATE_IMAGE_WORD0/1, DMA'd to common dwords 0..3). A
linear view has the stride form of the same two words, the ones the A8
already samples linear textures with (host-linear textures, client
buffers), so the LOAD takes them for linear targets too.

Device-confirmed (iPod): every dmabuf check passes (28 of 28) and labwc
composites on the GPU. Under a fake powervr device the GLES smoke tests
and the probe compile to the same programs as before.

Generated-by: LLM
The A8 sample taken from Apple's compiler names its image at common qword
0 and its sampler in three bits of dwords, so a program whose texture
state sits anywhere else (a vertex texture, more than four textures in
the compact plan) was refused.

On the A8 such a sample is now emitted as the A9's six-byte instruction,
image and sampler qwords in bytes 3 and 4, over the A8's state words at
the same common-store positions. PVR_A8_A9_FORMS=0 keeps the refusal.
This form has no A8 capture behind it, and a two-image program written
this way read the wrong texels on the iPod; the multi-image programs
therefore take Apple's own form (following commits), and this remains
the fallback for the shapes that form does not reach.

The compact plan spaces the A8's four-dword image states eight dwords
apart, as plan_common() places them, so the common-store plan and the
layout agree.

Generated-by: LLM
Qt Quick's multi-texture shaders (MultiEffect's shadow, blur and mask,
up to seven images) could not run on the A8: its captured sample named
one image slot only.

AGXMetalA8's own programs settle the form. An iOS 12.4 capture of test
programs sampling two to seven textures, with one shared sampler and with
one sampler per texture, shows the sample's fields:

- byte 4 is the image's common dword * 2, the images in four-dword slots
  from dword 0;
- the sampler's four-dword slot S is byte 1 bits 7:6 | byte 5 bits 2:1
  << 2, with byte 6 0x88 in every sample. The four-texture programs with
  one sampler and with four differ only in byte 1 bits 7:6; five
  samplers take slots 5 to 9; the seven-texture program's PDS DMAs its
  28 dwords of image state to common 0 and its sampler to dword 28. The
  existing single-image forms (byte 1 0x59, 0x79) are slot 1, dword 4.

A fragment program sampling two or more images from common dword 0 now
takes that layout: the images, then a sampler per texture while the last
slot is at most 11 (slots 10 and 11 combine byte values seen at other
slots), else texture 0's sampler shared, as Apple's seven-texture
program. Between samples of different images the A8 waits 4d 04, as
Apple's multi-texture programs do. Single-image programs are unchanged.

On the iPod touch 6, two to five images with one sampler or a sampler
each read the right texels, including checker textures whose own
NEAREST/LINEAR filter differs from texture 0's, and MultiEffect's shadow,
blur, mask and colorize render.

Generated-by: LLM
A program whose common store starts with other data (the blend colour
at dwords 0..3 for a constant-colour blend, storage-buffer pointers)
placed its first image at dword 8 and sampled it in the A9's form,
which the A8 does not run: the desktop wallpaper's shader and a constant-colour
blend of one or two textures were refused or read the wrong texels.

Apple's multi-image form names any four-dword image slot and sampler
slot, so the same layout now starts at the next four-dword boundary
after that data: one image or more, then their samplers, as long as the
last sampler slot is at most 11.

On the iPod touch 6, one, two and four textures under a
constant-colour blend (images at dwords 4 to 16) read the right
texels.

Generated-by: LLM
A refused A8 texture sample said only which encoder check failed, so a
refusal in a real application's shader could not be matched to a
missing form without rebuilding the driver with extra prints.

The refusal now names the image's set, binding, element and common
dword, the sampler's binding and dword, the image count and layout, the
common store's start, and the sample's dimension, array, op, LOD, bias,
gradient, offset, compare and result width. No program is encoded
differently.

Generated-by: LLM
Gate ENOMEM retries on the kernel capability query, with unknown queries
leaving capabilities disabled. Back off from 0.5 ms to 50 ms with a 2 s
budget. No submit-thread error deferral is used.

Zink may attempt vkQueueSubmit five times through VRAM_ALLOC_LOOP: a real
OOM can therefore take about 11.5 s in the worst case.

The capability query added to include/drm-uapi/pvr_drm.h is the proposed
kernel interface. It must be replaced by the merged kernel header before
this lands.

Generated-by: LLM
Advise only non-current chunks displaced into the cache, gated by the
kernel capability bit. On reuse, a purged chunk is freed and replaced
before either CPU or GPU access. Warn once per winsys if DONTNEED fails.

The BO_MADVISE ioctl added to include/drm-uapi/pvr_drm.h is the proposed
kernel interface. It must be replaced by the merged kernel header, naming
that kernel commit, before this lands.

Generated-by: LLM
Each render pass holds its own dataset until its command buffer is reset.
Keeping only four released datasets makes multipass rendering repeatedly
allocate and destroy datasets, even when target sizes are unchanged.

Keep up to 64 unused datasets so a completed batch can supply the next
one. Limit their owned buffer objects to 32 MiB, excluding shared device
free lists, and retain one oversized dataset to avoid repeated allocation.
Evict the oldest entries and destroy them outside the cache lock.

Matching remains exact in width, height, sample count and layer count.
Shader compilation and command encoding are unchanged; only dataset
reuse changes. Device performance measurements are still pending.

Generated-by: LLM
Apple's A9 Metal job record controls empty-tile processing with byte
+0x640. Captured clear, LOAD, MRT and 4x-store passes set it to zero;
a 4x resolve sets it to one. The kernel maps it to ISP_CTL bit 17.

Request skipping only when no colour, depth or stencil attachment is
cleared and no colour or depth/stencil resolve is needed. An untouched
LOAD tile keeps its stored memory; a don't-care tile is undefined.
Keep processing every tile for clears, since the clear must reach tiles
without geometry, and for resolves. G5P_ALL_TILES restores all tiles.

Send the existing non-zero ISP_CTL form for both single-sample and 4x
passes. Kernels supporting this opt-in read only bit 17 and preserve
their other control bits and MSAA form, with resolves always retained.
Older kernels ignore the field, so their existing all-tile behaviour
is unchanged. No UAPI change or capability query is needed.

Generated-by: LLM
On the A9 the render's free list holds no pages: its size is the
smallest parameter manager pool the kernel builds for the render. The
kernel raises that to what the render target's tiles need, at most 128
blocks of 128 KiB, and grows it only between scenes, from the
firmware's feedback. It has no partial render, so a scene that needs
more parameter memory than its pool cannot finish: the geometry job
stops without a firmware fault, its stamp never moves and the job
times out, which loses the device.

4 MiB is enough for a full-screen 2D client, whose tiles already raise
the pool to 98 blocks. It may not be enough for a 3D scene drawn into
a smaller target, which can get as few as 32 blocks: a WebGPU game lost
its device on a geometry job that stopped in exactly this way. Ask for the 16 MiB the
kernel can build, so that a small target gets the pool a large one
has. A VM keeps up to two pools, so this costs at most 24 MiB more per
VM whose targets are small, until partial renders let the pool start
small, as Apple's does.

PVR_G5P_FREE_LIST_MB selects another size, 1 to 16 MiB.

Generated-by: LLM
Track live suballocations, backing BO capacity and peak capacity while BO logging is enabled. Sample the counters atomically to avoid taking an allocator mutex from a BO log callback that already holds it.

Add PVR_BO_LOG_PERIOD_S to emit full summaries during allocation and free activity, with zero disabling periodic output.

Generated-by: LLM
Read PVR_G5P_SWAPCHAIN_IMAGES once on G5P. Values from 2 through 8 override the frames-in-flight image count within surface limits; zero and invalid values preserve the existing rule.

Generated-by: LLM
The general, PDS and USC suballocators carve buffers of 512 KiB (128 KiB
for USC) linearly and free a buffer only when its last sub-allocation
goes. Command buffer uploads, which live until their command buffer is
reset, shared those buffers with pipeline programs, descriptor pools and
query pools, which live as long as the application keeps them. One
long-lived allocation made while a buffer was filling with uploads kept
the whole buffer once the uploads were freed, so a device that records
every frame and creates pipelines as it goes accumulated buffers that
are mostly empty.

Give command buffer uploads their own general, PDS and USC
suballocators, with the same heaps and sizes. Each holds at most one
current buffer and one cached, purgeable one. PVR_CMD_SUBALLOC=0 shares
the device-lifetime allocators as before. PVR_DEBUG=bo_log reports the
new allocators as cmd_general, cmd_pds and cmd_usc.

Generated-by: LLM
When a request did not fit in the rest of the current buffer, the
suballocator dropped its reference and created a new buffer, even when
every sub-allocation of the old one had already been freed. The old
buffer was then freed, so an allocator whose sub-allocations are short
lived, such as command buffer uploads, created and destroyed a kernel
buffer object every time it wrapped.

If the allocator holds the only reference and the request fits in the
buffer, carve it from the start of the same buffer instead.

Generated-by: LLM
- The render-target dataset cache (64 datasets) keeps at most 8 MiB of
  buffer objects on the A8 instead of 32 MiB: an A8 dataset owns the
  region-header ring (16 frames of the target's headers, 128 KiB at
  640x1136) besides the small BOs, and the iPod has 1 GB for the CPU
  and the GPU together.
- The parameter-manager free list stays 4 MiB on the A8 (16 MiB on the
  A9): the A8's kernel sizes its pool itself (powervr.a8_pm_blocks) and
  does not read the list. PVR_G5P_FREE_LIST_MB still overrides it.

Generated-by: LLM
The A8's kernel writes its own ISP_CTL (0x0001700f with
PROCESS_EMPTY_TILES, record +0x3c8) and the stream word is not one it
reads, so the empty-tile skip ported from the A9 sends 0 there on the
A8, as before, until a kernel takes bit 17 from the stream for
the A8 too.

Generated-by: LLM
PVR_BO_LOG_PERIOD_S printed its summary only from a BO allocation or
free, so a client whose buffer set is steady (a desktop shell between
windows) never reported. Each queue submission now checks the period as
well; with bo_log off it is one predicted branch.

Generated-by: LLM
…achment

Lazily allocated (memoryless) depth/stencil saves memory only if the
attachment is never loaded or stored. With PVR_DEBUG=bo_log the G5P
fragment stream now counts every render with a depth/stencil attachment
and whether its ZLS loads or stores it, and the summary prints
"summary-zls passes=N load=L store=S neither=M": M renders would never
commit lazily allocated memory.

Generated-by: LLM
…unded to powers of two

A depth or stencil buffer stored by one render and loaded by the next
read back wrong on the A8 at every size whose 32-pixel tile count is
not a power of two on both sides (640x1136, 528x80, 640x52, 528x464 and
100x75 failed; 37x29 and 64x64 passed). ZLSCTL's extents carried the
plain tile count minus one. Rogue's ZLSCTL documents that in twiddled
mode the extent is the tile count rounded up to a power of two, and
Apple's only A8 capture (64x64) is the same either way. With the
rounded extents every size reads back right on the iPod touch 6.

Each depth/stencil plane now also takes the rectangle the ZLS
addresses, with each side 32-aligned and padded to its own power of
two, instead of the larger side's square. A 640x1136 D32F_S8 image
takes 10 MiB instead of 20. The A9 already samples and copies such
unequal-side planes in that rectangular order. The A9's layout is
unchanged.

Generated-by: LLM
The A8 twiddled every single-level colour image not shared outside the
driver, which pads each side to a power of two: a 2018x1136 BGRA8 image
took 16 MiB. Such an image now stays linear, as on the A9, and takes
8.8 MiB. The A8 renders, LOADs and samples linear colour images, since
shared buffers already take that path. On the iPod touch 6, linear
non-power-of-two images render, reload and sample right, and the
texture and Qt Quick checks match.

Power-of-two images stay twiddled.

Generated-by: LLM
With PVR_DEBUG=bo_log, summary-zls now also prints the renders, loads
and stores of each of the first eight depth/stencil attachment sizes,
as summary-zls-size WxH, so the sizes worth a lazily allocated
attachment can be told apart.

Generated-by: LLM
A fragment program with more than eight varying reads put the ninth and
later on counter 1, and the A8 refused the iterator because its
counter-1 form has no capture. That refused 14 of WebRender's 31 GLES
shader variants: they have many varyings, and the A8 iterates three-
and four-component f32 varyings in pieces. On the A8 the reads now stay
on counter 0, and a full batch of eight is waited for (4d 00) before
the next, which is the wait Apple's A8 programs use.

Programs with eight varying reads or fewer are unchanged.

Generated-by: LLM
The A8 refused every texelFetch, because its texel-read form has no
capture. WebRender reads its data textures with texelFetch.

An iOS capture of a Metal fragment read() shows Apple's form. The
integer coordinate is converted to a float, then sampled with byte 6
bit 2 set. A fragment texelFetch of a 2D texture at a constant level is
now drawn that way. A NIR pass turns it into a sample of the same
binding, marked G5P_TEX_FETCH. The sample reads through a fetch
sampler in its own slot. That sampler is the binding's sampler words
made point-filtered, non-normalized, clamped to the edge and clamped to
the level, so the application's sampler state cannot change the texel
(PCO_G5P_UPLOAD_SAMPLER_FETCH on the sampler upload). Integer textures
take the 32-bit result, which holds the texel's bits.

On the iPod touch 6, texelFetch of RGBA8, RGBA32F and RGBA32I textures
at level 0 reads every texel right. A level above 0 has no capture, so
it is refused unless PVR_A8_TEXFETCH_LEVEL is set. With "level" the
coordinate is in the level's texels. With "scale" it is in level 0's,
times 2^level.

Generated-by: LLM
WebRender's vertex shaders fetch their transforms, primitive headers
and GPU cache with texelFetch. The A8 refuses every vertex-stage
texture, because no capture shows one.

The A8's vertex programs are otherwise the A9's. PVR_A8_VTEX=1 lets a
vertex texture take the A9's qualified vertex recipe over the A8's
state words: four dwords each of image and sampler. A samplerless read
gets a fetch sampler of Rogue words: point-filtered, non-normalized,
clamped, level 0.

This does not work yet, so it stays off by default. On the iPod touch
6 a vertex texelFetch read zeros, and a vertex textureLod locked the
TA. It is here so the form can be tested and compared with Apple's
(the explicit-level form later in this series).

Generated-by: LLM
When a program or a render pass was refused, the draws that used it
failed their command buffer. vkEndCommandBuffer then returned
VK_ERROR_OUT_OF_HOST_MEMORY, and Zink dropped the batch and lost the
whole application's context. A refused pipeline was followed by a lost context in Firefox; the link
between the two is not proven yet.

- The A8 now skips refused work by default. The driver already has a
  skip-refused-work mode behind a driconf option. With it, a refused
  program's pipeline is created without programs, and its draws, or a
  refused pass, are lost while the command buffer stays valid.
  PVR_A8_STRICT=1 restores the failure.
- G5P_REFUSE printed a call site's refusals only on occurrences 1, 2,
  4 and so on, so a second, different reason at the same site could go
  unprinted. Each distinct reason is now printed once, and repeats of
  one reason still follow the count rule.
- A fragment texture form the A8 has no capture of names its op,
  dimension, result type, level, offset and whether it reads a texel
  buffer.

Generated-by: LLM
st/mesa draws a texture upload from a pixel-unpack buffer
(glTexSubImage2D with a bound GL_PIXEL_UNPACK_BUFFER) with a fragment
program that texelFetches a texture buffer. The A8 refused that read,
so every such upload failed. WebRender uploads its textures that way
on desktop GL.

A uniform texel buffer on the A8 now follows the A9's contract over
Rogue's state words:

- The view is a plain linear 2D image 4096 texels wide, without
  index lookup. The element count and a marker go in the descriptor's
  software words.
- The program folds the element index to 2D, as on the A9, and the
  A8's texelFetch reads it as a 2D fetch of that state through the
  fetch sampler.
- The fragment upload of such a binding takes the four state dwords,
  the element count for the size query, and the fetch sampler.

The base must be 64-byte aligned and the view must have 1 to 65536
elements, as on the A9. On the iPod touch 6, an RGBA8 upload from a
pixel buffer at offset 16 reads back right. PVR_A8_TBO=0 refuses
fragment texel-buffer reads again.

Generated-by: LLM
… texelFetch levels (opt-in)

Apple's A8 compiler (AGXCompilerCore, agc_lower_air_texture_sample_read)
samples at an explicit level, 0.0 when the source names none, in a
stage without derivatives. Its read() is that sample with the read bit,
through a constant sampler. AGXMetalA8 builds the vertex stage's image
and sampler state exactly as the fragment stage's
(a8_emit_vertex_stage_pds_data and a8_emit_fragment_stage_pds_data).
An iOS capture of a Metal sample at a varying level shows the
explicit-level form: mode 2, byte 7 0x09, and the level as an f32 in
the register after the coordinate.

Two variables use that form. Neither has run on the hardware yet:

- PVR_A8_VTEX_APPLE=1 draws a vertex 2D sample or texelFetch as the
  A8's own 12-byte sample in that form, instead of the A9's recipe.
  - The image and sampler are named by their common dwords: four-dword
    images, then the samplers.
  - A fetch is the read form (byte 6 0xac) through one shared copy of
    Apple's read sampler.
  - The operands are bank-0 temps, as in the A8's fragment programs.
    Each used result component moves to bank 1.
- PVR_A8_TEXFETCH_LEVEL=apple draws every fragment texelFetch, at any
  constant level, in the same read form.

Apple's read sampler, PCO_G5P_UPLOAD_SAMPLER_READ, is the compiler's
constant 0x807bff0000002049 as Rogue words: clamp to edge, point,
nearest mip, normalized, LOD 0 to max.

By default no program is encoded differently.

Generated-by: LLM
An iOS capture of AGXMetalA8's vertex programs (a sample, and reads of
RGBA32Float and RGBA32Sint) shows Apple's vertex-stage sample. The
previous commit's PVR_A8_VTEX_APPLE form was inferred from the binaries
and differs from it:

  Apple:    1a 7d 00 41 00 01 a8|ac|a4 05 00 01 1c 80
  inferred: 1a 79 00 41 00 01 a8|ac 09 00 01 00 80

- Apple's coordinate is two f32 in bank-1 temps, and the result is
  written over it in bank 1 (byte 1 bit 2, byte 7 bit 2). The inferred
  form used bank-0 temps.
- Apple samples at its constant level 0 (byte 10 0x1c). The inferred
  form passed the level in a register (byte 7 0x09).
- Byte 6 is 0xa8 for a sample, 0xac for a read of a float texture and
  0xa4 for a read of an integer one.
- The read's constant sampler is 0x0202240000000fff: point,
  non-normalized, clamped to the edge, LOD 0 to 0. Those are exactly the
  fetch sampler's words, so vertex reads now share the fetch sampler.
  They no longer use the normalized sampler read from the compiler
  binary, which is not in the capture.

PVR_A8_VTEX_APPLE=1 now emits Apple's bytes for a vertex 2D sample or
texelFetch at level 0, and refuses other levels by name. The fragment
explicit-level read of PVR_A8_TEXFETCH_LEVEL=apple is unchanged.
Vertex textures stay off by default, and by default no program is
encoded differently.

Generated-by: LLM
On the iPod touch 6, a fragment ivec2(gl_FragCoord.xy) % 3 read back x
itself. That broke WebRender's desktop-GL texelFetchOffset addressing.

- The cause is the subtract. Our isub and ineg are the A9's
  two-register subtract (op a5; a negate is 0 - x), and on the A8 it
  gives x - y = x. A remainder a - 3q read back a, while 3q and the
  quotient alone read right. In A8 fragment programs, x - y is now
  x + y * -1 and -x is x * -1, with the integer multiply and add the A8
  runs right; -1 is a MOVI. Vertex programs keep their own forms.
- A remainder (umod, irem, imod) is built from the quotient as
  a - (a / b) * b, a constant divisor's product in shifts and adds, and
  imod then takes the divisor's sign. A constant divisor uses the float
  reciprocal and two integer corrections (nir_lower_idiv).

With these, integer modulo, division and multiply by 3 and
texelFetchOffset read every pixel right on the iPod.

Generated-by: LLM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant