📝 Record the rows IOSurface works out on the oracles

oracle_rows ran on the 5300M, the 630 and the M3 Max: a surface made with no
rows named takes IOSurface's own 64-byte rows on the Intel Mac (192 bytes for
an RGhA surface 18 texels wide), whichever GPU's process made it, though both
GPUs align a linear texture's rows to 256; the M3 takes 128. So no Mac's GPU
sets the rows, and the rows a client names (CoreAnimation's, CoreVideo's)
stay its own. Q27 records the numbers; build.sh builds the probe and the
README lists it.
This commit is contained in:
Anees Iqbal committed 2026-11-12 07:56:02 -08:00
1 parent c60b4fd0ca
commit 580927122d
3 files changed
+37 -1

No files matched your search

+35
View File
@@ -1477,6 +1477,41 @@ before the draw, the read saw the texture as it was before the draw (Safari's We
about 2.5% of them on a 780M). The M3's `isWriteComplete` YES for a read-only use is not kept:
arm64 guests see NO, which only waits for readers too.
## Q27: the rows IOSurface works out where none are named
Probe: `oracle_rows DEVICE`, 11-12 (m3-max-21363, 21364 and 21365), the M3 Max on macOS 27.0.1
among them. Surfaces made by `IOSurfaceCreate` with a width, a height, bytes an element and an
OSType alone (`kIOSurfacePlaneInfo` with each plane's width, height and bytes an element for
`420v`), and CVPixelBuffers made with an empty `kCVPixelBufferIOSurfacePropertiesKey`. Rows are
`IOSurfaceGetBytesPerRow` (of each plane for `420v`), offsets each plane's base from the
surface's.
| asked | AMD | Intel 630 | M3 |
|---|---|---|---|
| `IOSurfaceGetPropertyAlignment` of `kIOSurfaceBytesPerRow` and `kIOSurfacePlaneBytesPerRow` | 64 | 64 | 128 |
| the same of `kIOSurfaceOffset` and `kIOSurfacePlaneOffset`; of `kIOSurfaceAllocSize` and `kIOSurfacePlaneSize` | 64; 1 | 64; 1 | 16384; 1 |
| `IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, N)` for N of 1, 8, 64, 144, 192, 384, 1336, 3840, 4004 | 64, 64, 64, 192, 192, 384, 1344, 3840, 4032 | the same | 128, 128, 128, 256, 256, 384, 1408, 3840, 4096 |
| `'RGhA'` (8 bytes) 1 x 1, 18 x 28, 48 x 48, 85 x 162, 167 x 161, 170 x 134: rows | 64, 192, 384, 704, 1344, 1408 | the same | 128, 256, 384, 768, 1408, 1408 |
| `'BGRA'` 96, 463, 1001 and 3662 wide: rows | 384, 1856, 4032, 14656 | the same | 384, 1920, 4096, 14720 |
| `'L008'` 1920 x 1080 and 1001 x 1: rows; size | 1920, 1024; 2073600, 1024 | the same | 1920, 1024; 2080768, 16384 |
| `420v` 1920 x 1080: each plane's rows; plane 1's offset | 1920, 1920; 2073600 | the same | 1920, 1920; 2080768 |
| `420v` 18 x 28 | 64, 64; 1792 | the same | 128, 128; 16384 |
| CVPixelBuffer `420v` 1920 x 1080: rows; the planes' offsets | 1920; 32, 2073632 | the same | 1920; 512, 2074112 |
| CVPixelBuffer `420v` 18 x 28 | 32; 32, 928 | the same | 64; 512, 2560 |
| CVPixelBuffer `32BGRA` 96 x 96, `64RGBAHalf` 18 x 28: rows | 384, 160 | the same | 384, 256 |
| `minimumLinearTextureAlignmentForPixelFormat:` of RGBA16Float, BGRA8Unorm and R8Unorm; `linearTextureAlignmentBytes`, `deviceLinearTextureAlignmentBytes` | 256 | 256 | 16 |
| `iosurfaceTextureAlignmentBytes`, `iosurfaceReadOnlyTextureAlignmentBytes` | 16 | 16 | 16 |
The rows of a surface with none named are IOSurface's own, byte for byte the same in the
AMD's process and the 630's: 64-byte rows and offsets, on a MacBook Pro whose AMD and Intel
accelerators are both loaded and whose GPUs both align a linear texture's rows to 256. Neither
accelerator raises IOSurface's alignment to its GPU's linear one *(class 2: 64 on x86, 128 and
16 KiB offsets on the M3)*. CoreVideo names its rows and plane offsets itself (on x86 rows at a
multiple of 32 bytes and the first plane 32 bytes in, on the M3 the first plane 512 bytes in),
and IOSurface keeps them. Our kext raises IOSurface's alignment to the host GPU's linear one,
256 on RADV (`RgfxSurfaceRows.hpp`); the rows a client names, CoreAnimation's and CoreVideo's
among them, stay as it names them, as on these Macs.
## Not measured
- Cross-process lock waits for pending GPU work: rgk-lock's `lock_probe` (x86 matches the M3,
+1
View File
@@ -31,6 +31,7 @@ Mac where it shows the gap. What they found is in
| `oracle_events` | a shared event made in one process and used in another: its Mach port (`eventPort`) and handle, the events made back from either, their coding (keyed and NSXPC), and the value, listeners and waits two holders share, in one process and across two; it runs the same on the guest's device |
| `oracle_reflection` | the reflection a render, mesh or compute pipeline is made with (`reflection:` and the completion handlers' argument), by options, over `oracle_reflection.metallib`: every getter of its bindings, built-in arguments, types and struct members, recursively, and with `ORACLE_IVARS` set their instance variables, then the reflection classes' members (shared with `../pipeline_reflection_check.mm` through `oracle_walk.h`) |
| `oracle_urls` | what each call of a device, a library and a binary archive that takes a URL answers for each form of URL: nil, a path of no scheme, a file URL, another scheme's URL of a path, a URL of no path, the file there and not: the object made, the error, whether a write left a file, or how the process ended |
| `oracle_rows` | the bytes per row, plane offsets and sizes IOSurface works out for a surface made with none named, by OSType and size, and the alignments it answers (`IOSurfaceGetPropertyAlignment`, `IOSurfaceAlignProperty`); the rows and plane offsets CoreVideo gives an IOSurface-backed pixel buffer; the device's linear and IOSurface texture alignments |
Each probe picks its device by a substring of its name from `MTLCopyAllDevices` (`AMD`,
`Intel`, `Apple`). It never calls `MTLCreateSystemDefaultDevice`, which switches a dual-GPU
+1 -1
View File
@@ -8,7 +8,7 @@ here=$(cd "$(dirname "$0")" && pwd)
out=${1:-/tmp/rgk-oracle/x86}
arch=${2:-x86_64}
mkdir -p "$out"
for p in oracle_iosurface oracle_storage oracle_passes oracle_cmdbuf oracle_caps oracle_errors oracle_source oracle_ycbcr oracle_ca_ycbcr oracle_sampler oracle_icb oracle_order oracle_names oracle_surftex oracle_texdesc oracle_nilbind oracle_reflection oracle_mesh oracle_spi_members oracle_complete oracle_urls; do
for p in oracle_iosurface oracle_storage oracle_passes oracle_cmdbuf oracle_caps oracle_errors oracle_source oracle_ycbcr oracle_ca_ycbcr oracle_sampler oracle_icb oracle_order oracle_names oracle_surftex oracle_texdesc oracle_nilbind oracle_reflection oracle_mesh oracle_spi_members oracle_complete oracle_urls oracle_rows; do
xcrun clang -arch "$arch" -mmacosx-version-min=26.0 -fobjc-arc -Wall \
-framework Metal -framework IOSurface -framework CoreVideo -framework QuartzCore \
-framework VideoToolbox -framework CoreGraphics -framework Foundation \