Skip to content

Graphics parity: Windows D3D11 reference, crawl admission fix, prepare-hook seam (G4 Task 7) - #1258

Merged
iamfatness merged 15 commits into
mainfrom
codex/win-d3d11-graphics-reference
Nov 27, 2026
Merged

iamfatness merged 15 commits into
mainfrom
codex/win-d3d11-graphics-reference

Conversation

@iamfatness

@iamfatness iamfatness commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Windows half of Metal graphics G4 Task 7 (plan docs/superpowers/plans/2026-11-22-mac-metal-graphics-g3-g5.md, Windows-session agenda items 1-3 in the outcomes doc). Off origin/main 0b5f04d. Do not merge without the owner.

Commits

  1. 9df7fe3f fix: CompositorOverlayRaster admits through the shared graphics::overlayAdmissionBytes, the same helper Metal uses. Long crawls (about 2+ raster widths) no longer fail with Graphics preparation exceeded its admitted budget. This is customer-visible on Windows today.
  2. 0e9b2d4b test seam: prepareRaster calls compositor::invokeOverlayRasterPrepareHook(), which does nothing unless a test installs a hook.
  3. 9248e6be D3D11GraphicsReferenceTest.cpp built for the first time. It compiled unchanged. Only its stale comments were updated to match what the run showed.
  4. 22107a59 The Windows reference (contracts/graphics-raster-reference.json) and the 23 PNGs plus catalog.json in native/tests/golden/windows-graphics/, with the environment block filled in:
    • Windows build 26300
    • d2d1 6.2.26100.9818, dwrite 6.2.26100.9974
    • font stamps

Evidence

All runs use Release (--config Release, build:native-dev), with D3D11 on, stub off and dev adapters on. The tests exe is 15,073,280 bytes.

Run Result
OverlayRasterContract.*:GraphicsRasterParity*:GraphicsCompositionPixel.*:ParityPng.* 46 passed, 2 failed, the same on two runs
CrawlAtTheItemLimitPreparesOrFailsWithAtlasWording (item 1 acceptance) PASS (ready after 36 calls)
Same case with commits 1-2 reverted in the working tree FAIL: Graphics preparation exceeded its admitted budget.
ScaleRetentionDrawsTheAcceptedRaster (needs item 2) PASS
WriteWindowsReference 23 fixtures, all ready, no warnings, 3 verbatim samples each
WindowsMatchesItsOwnReference, fresh process, writer env unset PASS
Catalog export (ThumbnailsAreExplicitWorkerProducts…) 9 rows, all ready / d3d11-native
Wider sweep Graphics*:D3D11*:OverlayRaster*:OverlayTile*:ParityPng.* 248 passed, 3 failed: the same corrupt-image cause, below

No comparison tolerance changed. The Windows raster was not edited to make anything pass.

Recorded Windows/Mac difference (red, NOT fixed here)

A PNG with a valid header and a zeroed IDAT payload (CRC repaired) comes back ready with an empty warning on D3D11. Metal fails it with Graphics image could not be decoded: <id> (outcomes bug 1, forced decode). The outcomes doc assumed Windows already failed this asset, but that was observed with the earlier fixture, which had the IDAT removed.

Three cases are red from this one cause:

  • OverlayRasterContract.FailedScaleKeepsTheAcceptedRaster (state ready, expected failed)
  • OverlayRasterContract.ImageDecodeFailureWording (same)
  • GraphicsTemplateRegistry.ABrokenTemplateThumbnailDoesNotBlockTheOthers (thumbnail ready, expected unavailable)

All three were already red on main: they fail the same way with commits 1-2 reverted. This branch did not cause them. Likely customer impact: a corrupt image could air blank while the UI says ready. The exact pixels drawn were not inspected.

The corrupt-PNG fix is its own PR, #1263 (owner OK 2026-11-27). The four agenda items are #1264, stacked on this PR.

Mac parity work (owner rulings 2026-11-27)

Task 8 ran on Mac CI. Each row below was root-caused before it was fixed. No tolerance changed, and no Windows drawing code changed except the text params, which were pinned.

Difference Root cause Fix
Text edge weight (most text fixtures) D2D took gamma and contrast from the PC's ClearType tuning Windows pins grayscale params (gamma 2.2, contrast 0.5/1.0); the Mac applies the same contrast curve; reference regenerated (173389a7, faa0bcd1, ab0e053b, d753d707)
Labels 2 px low D2D DrawTextLayout rounds each baseline to the nearest device pixel The Mac rounds the same way; outlines and shadows stay unrounded on both (f3f1e13c)
Table cells 8–9% light The judge grew each 40 px cell 7 px into the next row's text and fill The judge measures a text region only inside its clip, where both rasters clip (5a363e2e)
Layered-motion title 8.6% heavy The fixture used Segoe UI, so the Mac drew Selawik (Selawik through D2D: +12.9%) The fixture uses Arial, per spec 7.3; only that fixture's reference changed (d87e2746, f2fa476b)
Ellipse and rounded-corner edges D2D flattens curves to chords (0.25 px), which sit inside the true curve D2DCurveFlattening.h, a port of WPF's CBezierFlattener, proven point for point against ID2D1Geometry::Simplify (0ec54b2b)
Legacy plate corners Windows applies the rounded band as a layer mask and a fill, squaring corner coverage The Mac clips and fills the same polygon (0ec54b2b)
Image content edges D2D LINEAR is centre-aligned bilinear; Core Graphics Medium is sharper The Mac resamples bilinearly itself (1891f761)

Mac CI 46032144533 passed 21 of 23 fixtures. The other two are recorded differences (ef45a203): they are still rendered, judged and on the sheet, but they don't fail the test. IndexIsWellFormed keeps that list closed.

  • segoe-substitution: Selawik in place of Segoe UI. Owner decision 5 is still open.
  • text-emoji: colour emoji (plan default D6).

For the owner

  • Regenerate the Mac goldens on your Mac (COREVIDEO_WRITE_MAC_GOLDENS=1): the Mac's text, curve and image output all changed. They are advisory on CI runners and block only the release ctest on your Mac.
  • Decision 5 (Selawik on air) is judged from the graphics-parity-mac-vs-windows sheet artifact.
  • Candidate issue, not filed: plan Task 7 step 5 runs the thumbnail test before the writer creates windows-graphics/, so on a clean tree the catalog export cannot open its file (GraphicsTemplateTest.cpp:372).

Not verified

  • No installed-app or live Program check was done; this is test evidence only.
  • The Windows reference device (hardware or WARP) was not recorded.
  • MetalCompositor.VcamTapAbsorbsTheProgramInFlightDepthWhileTheTapIsBusy failed on two consecutive Mac runs (16:21 and 16:27 UTC) and passed on re-run. Graphics code is not in that test.

🤖 Generated with Claude Code

…Bytes

The D3D11 raster still inlined the layered-only admission bound, so a crawl
longer than about two raster widths was admitted at w*h*8 and the worker
then failed it with 'Graphics preparation exceeded its admitted budget.'
Switch to the shared graphics::overlayAdmissionBytes the Metal raster
already uses (identical layered term, plus the crawl atlas term).

Windows-session agenda item 1 from the G3-G5 outcomes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One-line seam, matching CoreTextOverlayRaster::prepareRaster, so
OverlayRasterContract.ScaleRetentionDrawsTheAcceptedRaster can block the
D3D11 preparation worker. No-op unless a test installs a hook.

Windows-session agenda item 2 from the G3-G5 outcomes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3D11GraphicsReferenceTest.cpp (written on the Mac) compiled unchanged in
Release on Windows build 26300. Run of
OverlayRasterContract.*:GraphicsRasterParity*:GraphicsCompositionPixel.*:ParityPng.*
on D3D11: 46 passed, 2 failed, repeat-stable.

- CrawlAtTheItemLimitPreparesOrFailsWithAtlasWording: PASS (agenda item 1).
- ScaleRetentionDrawsTheAcceptedRaster: PASS with the prepare-hook seam.
- FailedScaleKeepsTheAcceptedRaster, ImageDecodeFailureWording: RED, a
  recorded Windows/Mac difference. The corrupt-pixel PNG (valid header,
  zeroed IDAT payload) prepares 'ready' with an empty warning on D3D11;
  Metal fails it. Windows raster deliberately not changed.

Only comments change: the stale 'needs a seam' / 'expected red' notes
are replaced by what the run showed. No tolerance or assertion changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndard (G4)

Generated on Windows (build 26300; d2d1.dll 6.2.26100.9818, dwrite.dll
6.2.26100.9974; font stamps in the environment block) from a Release
corevideo-native-tests built at 9248e6b (the 'commit' field):

- contracts/graphics-raster-reference.json: 23 fixtures, every one
  'ready' with no warning, 3 verbatim samples each.
- native/tests/golden/windows-graphics/<fixture>.png: 23 PNGs, re-read
  through WIC and byte-checked by the writer.
- native/tests/golden/windows-graphics/catalog.json: 9 catalog rows with
  real D2D thumbnails (all ready, backend d3d11-native).

GraphicsRasterReference.WindowsMatchesItsOwnReference passes in a fresh
process without the writer env. Task 7 step 5 command note: the thumbnail
test runs before the writer creates windows-graphics/, so on a clean tree
the catalog export fails to open its file; it was re-run once the folder
existed. No tolerance changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no params set, D2D took gamma and grayscale enhanced contrast from the
PC's ClearType tuning, so the weight of on-air text could differ from one
customer PC to the next, and the Windows parity reference depended on the
machine that wrote it. Pin explicit grayscale params equal to the values
CreateRenderingParams() returns on the reference machine (gamma 2.2, enhanced
contrast 0.5, grayscale enhanced contrast 1.0).

The output is deterministic across runs. Against the old unpinned output, 3 of
23 reference PNGs move by 2-72 pixels and summed alpha changes by at most 0.01%.

Owner ruling 2026-11-27: pin today's Windows look; the Mac matches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Written by GraphicsRasterReference.WriteWindowsReference at 173389a. Three PNGs
move by 2-72 pixels; catalog.json is unchanged. WindowsMatchesItsOwnReference
passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…curve

The G4 Mac-vs-Windows run failed text-wrap-ellipsis-3-lines at 8.1% summed
alpha. Root cause: layout matched exactly (line breaks, line boxes, ellipsis),
but D2D lifts grayscale edge coverage (mean edge alpha 177) and Core Text
draws linear coverage (120). The Mac text was 7-10% light on the plain-text
fixtures and +19% heavy at 14 px, where D9's font smoothing over-dilates.

The Mac now draws text unsmoothed into an offscreen layer over the text clip,
maps each pixel's coverage through a*(k+1)/(a*k+1) with k = 1.0 (the grayscale
enhanced contrast now pinned on Windows), and composites at the primitive's
opacity. Offline, against the existing Mac goldens, the plain-text fixtures
move to 2-3.4% under Windows. The 14 px result needs a Mac run.

- MacMatchesWindowsReference reports every fixture and fails once at the end
  (the vendored EXPECT_* throws on the first failure). No tolerance changed.
- CI uploads the parity sheet (Windows / Mac / diff) from native-metal-macos.
- Mac goldens are NOT regenerated here: they need COREVIDEO_WRITE_MAC_GOLDENS=1
  on the owner's Mac (advisory in CI, blocking in release-macos.sh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ctToDeviceSpace

CI (run 45948538637) showed the text layer covering the text clip flipped
vertically against the CTM: text was drawn in the right place but cut off.
Single-line fixtures lost all their ink, and the 3-line fixture kept only
rows 31-160. The rect now comes from CGRectApplyAffineTransform with the same
CTM that the layer and the composite use.

On the rows the bug left intact, the new curve's summed alpha is within 0.04%
of Windows (old Mac: 6% light).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D2D's DrawTextLayout rounds each line's baseline to the nearest device
pixel (no D2D1_DRAW_TEXT_OPTIONS_NO_SNAP). Core Text drew at the exact
fractional baseline, so 28 px secondary labels (baseline .4 below a pixel)
landed 2 px low against the Windows reference once the coverage curve
lifted the partial row. Outlines and shadows stay unsnapped: on Windows
they come from a custom renderer with pixel snapping disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both rasters clip every primitive to its clip rect (aliased
PushAxisAlignedClip / CGContextClipToRect), so no ink of a text
primitive can fall outside it. The judge still grew the measured area
7 px past it: a 40 px table cell then counted the top of the next row's
text and took the neighbouring row's fill as its background, which
zeroed faint edge pixels. table-12x8 failed 17 cells at 8-9% light for
that reason. No tolerance changes; the geometry tier's text exclusion
is unchanged. Owner ruling 2026-11-27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd font

The parity judge's motion brand set brand.fontBody to Segoe UI, so on
the Mac the layered-motion title drew Selawik and read 8.6% heavy from
the font, not the rasterizer (Segoe UI through D2D matches the reference
exactly, 112574; Selawik through D2D is +12.9%). Spec 7.3 has fixtures
use fonts both platforms ship; Segoe UI to Selawik keeps its own fixture.
Only the judge's local motionBrand() changes. Owner ruling 2026-11-27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fixture

Written by GraphicsRasterReference.WriteWindowsReference at d87e274.
Only layered-motion-mid-entrance changed (PNG and metrics); the other 22
fixtures are byte-identical and WindowsMatchesItsOwnReference passes.
Windows raster code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D2D flattens every ellipse and rounded corner to line segments at 0.25
device px before rasterizing; the chords lie inside the true curve, so
its antialiased curved edges hold ~0.07 less coverage than exact. Core
Graphics fills true curves, so the Mac read heavier on every curved edge
(shapes-inset-strokes ellipse worst 71/255).

D2DCurveFlattening.h reproduces D2D's polygons exactly: the same four
cubics and traversal order as ID2D1EllipseGeometry and
ID2D1RoundedRectangleGeometry, flattened with WPF's CBezierFlattener
hybrid forward differencing (dotnet/wpf, MIT). D2DCurveFlatteningTest
checks every vertex against ID2D1Geometry::Simplify (1,000+ ellipses,
rounded rects at four tolerances). The Mac raster now builds its rect,
ellipse and stroke paths from it.

Legacy band: Windows pushes the rounded band as a layer mask and fills
the rounded band inside it, so corner coverage is applied twice; the Mac
filled a rectangle inside its rounded clip (legacy accent worst 96/255).
It now clips to and fills the same polygon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows raster draws images with D2D1_BITMAP_INTERPOLATION_MODE_LINEAR:
centre-aligned bilinear on premultiplied pixels, clamped edges, and a
fractional destination edge antialiased by area (probed: one white pixel
upscaled 8x reads 16, 48, ... 239 per column). The Mac used
kCGInterpolationMedium, whose filter Core Graphics does not specify; it
read sharper than bilinear, so image-contain-cover-align content edges
were up to 66/255 off. The Mac now resamples exactly that kernel from the
decoded pixels and composites the result 1:1 in device pixels, under the
primitive's clip and opacity. A non-axis-aligned CTM keeps the old draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nces

segoe-substitution (Selawik in place of Segoe UI, owner decision 5,
still open) and text-emoji (colour emoji, plan default D6) are marked
"recordedDifference" in the fixture index. They are still rendered,
judged and printed on the parity sheet, but their failures no longer
fail MacMatchesWindowsReference, which becomes blocking on main once the
Windows reference lands. Tolerances are unchanged and every other
fixture still blocks. IndexIsWellFormed keeps the list closed to these
two. Owner ruling 2026-11-27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamfatness
iamfatness marked this pull request as ready for review November 27, 2026 17:56
@iamfatness
iamfatness merged commit fe32e4f into main Nov 27, 2026
18 checks passed
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.

2 participants