Skip to content

Run ganesh-gl on the Windows and Linux CI legs - #4605

Merged
mattleibow merged 36 commits into
mainfrom
mattleibow-dev-gpu-ganesh-gl-ci
Jul 31, 2026
Merged

mattleibow merged 36 commits into
mainfrom
mattleibow-dev-gpu-ganesh-gl-ci

Conversation

@mattleibow

@mattleibow mattleibow commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

#4575 made a GPU backend required on every platform GpuPolicy.RequiredOn names, turning a set of silent skips into an enumerable list. ganesh-gl was the largest entry on it: required on Windows, macOS and Linux, but opted out of both desktop legs that lacked a working GL stack. This closes those two gaps, so the Ganesh GL backend is now exercised on all three desktop platforms.

To be clear about the starting point — this is not "GL was untested until now". GL was already covered in several places, and this PR fills in the ones that were missing.

Where GL stands, per platform

Platform GL coverage Change here
macOS ganesh-gl via CGL, plus committed goldens none — already worked, and is why ganesh-gl.macos was the only golden set
Windows (netfx x64, netfx x86, .NET Core) none — no ICD on the agents enabled: Mesa registered as the system OpenGL driver
Linux GLX loaded but crashed the host enabled: the crash fixed, ganesh-gl now required
Android / iOS / Mac Catalyst SKGLView handler tests already run on device none — untouched, still passing
Nano Server + 4 container legs none, deliberately none — opt-out kept, comment reworded as a decision
WASM no ganesh-gl (not required on Browser); WebGPU is graphite-dawn, opted out none — tracked separately in #4591

The device legs are worth naming because they mean the views layer already had real GL surfaces under test — MemoryLeakTests.SKGLViewHandlerDoesNotLeak runs and passes on Android, iOS and Mac Catalyst (Catalyst: 1137 tests, 0 failed). What was missing was the low-level GRContext.CreateGl path on Windows and Linux, which is what the desktop console suite covers.

Two gaps this does not close, both pre-existing: SKGLView on WinUI has no device leg in this pipeline, and the Blazor SKGLView/WebGL test lives in SkiaSharp.Tests.Integration, which this pipeline does not run.


Windows — no OpenGL at all

The agents have no display driver carrying an OpenGL ICD, so opengl32.dll answers with the in-box generic implementation: GL 1.1, no WGL_ARB_pixel_format, no WGL_ARB_pbuffer. WglContext cannot come up on that, and Ganesh needs 3.0+ regardless.

scripts/infra/native/windows/install-mesa-gl.ps1 provisions Mesa the way Mesa documents for machines with no OpenGL driver: libgallium_wgl.dll becomes System32\mesadrv.dll and SysWOW64\mesadrv.dll, registered under OpenGLDrivers\MSOGL. It follows install-vulkan-icd.ps1 — pinned version, SHA-256 pin, both bitnesses, fatal on any failure.

It checks what provisioning is responsible for and no more: the driver is where opengl32 will look for it, its version resource matches the version just pinned (so a leftover from an earlier run is caught, not just a missing file), and the registration reads back. Proving it renders is the suite's job — GRContextTest.CreateDefaultContextIsValid already does that on every leg where the policy requires ganesh-gl.

SetPixelFormat and wglSetPixelFormat are not interchangeable. With Mesa registered, provisioning still failed, and the diagnostics named it:

mesadrv=C:\Windows\SYSTEM32\mesadrv.dll; pixelFormats=1332; chosenFormat=121
FAILED: wglCreateContext returned NULL (2000)

Mesa is loaded and serving its own 1332 pixel formats; 2000 is ERROR_INVALID_PIXEL_FORMAT. gdi32's ChoosePixelFormat reports Mesa's formats and SetPixelFormat returns true, but Mesa's per-HDC state is only created by its own wglSetPixelFormat, so wglCreateContext has nothing to look up.

The two APIs turn out to be exactly inverted, consistently per driver — a hardware ICD is set up through GDI and refuses a context when the format was set the other way; Mesa is the reverse. So the Wgl bootstrap tries GDI first (every real driver, and every developer running these tests locally) and falls back only when the context actually fails. A pixel format can be set once per DC and the class is CS_OWNDC, so the retry needs a fresh window; the first is destroyed before it is replaced.

Linux — the crash was one test, not a race

#4590 attributed the exit-7 host crash to nine test classes creating GLX contexts concurrently. That diagnosis was wrong. The crash reproduces with the suite serialized onto a single thread, and a trace shows every context created, used and destroyed on that one thread.

The real cause is GRGlInterfaceTest.AssembleInterfaceIsValid, which resolved Skia's proc addresses with glXGetProcAddress alone. Under GLVND — the vendor-neutral libGL every current distro ships — that returns a dispatch stub for any name at all; glTotallyNotARealFunction comes back non-null. Skia was handed pointers that are not functions and walked off the end of the extension list in GrGLExtensions::init. It now resolves through dlsym on libGL.so.1, exactly as the macOS branch already did.

The death point only looked random because the run order varied.

Both — llvmpipe cannot compile one of Skia's shaders

Mesa's LLVM shader JIT segfaults inside LLVMTypeOf, under GrGLOpsRenderPass::onDraw, building the fragment shader Skia generates for a runtime blender. Reproduced on two independent stacks — Mesa 25.2/LLVM 20 on Linux and 26.1/LLVM 22 on Windows — so both legs pin softpipe, the non-JIT gallium rasterizer, which runs the identical tests green on both and caps at GL 3.3, well past the 3.0 Ganesh needs. Filed as #4604.

Ruled out along the way, so nobody re-treads it: thread parallelism (--parallel none --max-threads 1 crashes identically), managed thread stack size at 2/16/64 MB, LP_NUM_THREADS of 0 and 1, file-descriptor limits at 256/1024/65536, and GL context churn (400 create/use/destroy cycles are fine).

Supporting changes

  • Every class that creates a GPU context joins the existing GpuRenderingCollection, mirroring VulkanGpuRenderingCollection. This is what [BUG] Concurrent GLX context creation crashes the Linux test host (exit 7, no results published) #4590 and [Tracking] Re-enable the GPU backends currently opted out of CI (no OpenGL or Metal coverage anywhere) #4591 asked for; it was not the crash fix, but concurrent GPU context use is a real hazard worth closing. Where only a nested class does GPU work (SKBlenderTest, SKRuntimeEffectTest) only that class joins, so its raster sibling stays parallel — roughly 300 of 6100 tests are serialized.
  • GlxContext shares one X11 connection for the process instead of opening and closing one per test. That is the leak XCloseDisplay was added for in Make GPU tests required; skip only when declared #4575, fixed at the source: one connection instead of 128 and counting, and no closing a display while a context minted from it is still current.
  • XInitThreads() runs before any other Xlib call.
  • ganesh-gl.windows and ganesh-gl.linux goldens are harvested and committed, since a backend that renders for the first time is unseeded and fails until they exist.
  • The five container legs keep their ganesh-gl opt-out, and the comment now reads as a decision rather than a pending item: those images exist to prove SkiaSharp works with the bare minimum installed, so giving them an X server and Mesa would defeat their purpose.

Related issues

Fixes #4590

Related to #4591 — this removes four of the opt-outs in that table.

Related to #4604 — the llvmpipe crash that forces softpipe.

Required skia PR

None.

Areas affected

  • Managed API (binding/)
  • Native / C API (externals/skia/src/c, include/c)
  • Generated P/Invoke bindings
  • Native dependency or Skia update (libpng, HarfBuzz, FreeType, zlib, milestone bump, …)
  • Views & integrations (MAUI, Uno, WPF, WinUI, Blazor, …)
  • Rendering output / visual behavior
  • Performance
  • Tests
  • Build, packaging, or CI
  • Documentation or samples

Changes

None — CI and test infrastructure only. No public API, and no change to the library itself: every source file touched is under tests/.

Testing

CI — ganesh-gl really runs on the two newly-enabled platforms, and every leg is green:

Leg Result
Windows (.NET Framework, x64) 7415 tests, 0 failed, 23 skipped
Windows (.NET Framework, x86) 7415 tests, 0 failed, 25 skipped
Windows (.NET Core) 6117 tests, 0 failed, 31 skipped
Linux 6117 tests, 0 failed, 34 skipped

Linux previously died with exit 7 and published nothing at all. The committed goldens matched on both platforms — no unseeded failures. macOS, Android, iOS, Mac Catalyst, WASM and all five container legs stayed green, including the SKGLView handler tests on the three device legs.

What the provisioning step prints, on both bitnesses:

Extracted mesa3d-26.1.3-release-msvc.7z with tar.
Installed the x64 Mesa megadriver into C:\Windows\System32\mesadrv.dll
Registered the x64 ICD under HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL
  [x64] C:\Windows\System32\mesadrv.dll -> Mesa3D 26.1.3.0
  [x64] registered as the MSOGL OpenGL driver
  [x86] C:\Windows\SysWOW64\mesadrv.dll -> Mesa3D 26.1.3.0
  [x86] registered as the MSOGL OpenGL driver
Mesa 26.1.3 (softpipe) provisioned for x64 and x86; ganesh-gl will execute.

Locally — Mesa softpipe on Windows, and Ubuntu 24.04 under WSL with Xvfb and Mesa 25.2.8 for Linux:

Run Result
Windows Category=Gpu on Mesa 165 / 165
Windows Category=Visual on Mesa 10 / 10 with the new goldens
Windows Category=Gpu on the real AMD driver unchanged — the GDI path still wins, no fallback
Linux full suite 6117 tests, no crash, 1m35s
Linux GL on vs off 6079 vs 5910 passing — 169 tests that had never run once

Driver comparison, the evidence behind softpipe:

Host Mesa / LLVM llvmpipe softpipe
Linux (GLX) 25.2.8 / 20.1.2 SIGSEGV, exit 139 116 / 116
Windows (WGL) 26.1.3 / 22.1.8 0xC0000005 116 / 116

The provisioning script's own checks were exercised against a simulated install: good, stale version, missing file, misregistered and unregistered — the good one passes and each failure throws with a specific message.

Not tested: macOS ganesh-gl, which already ran and is untouched here. Worth noting it runs against Apple's deprecated OpenGL (capped at 4.1), so the three desktop legs are covered but not equivalent.

Two local-only failures worth naming, both confirmed pre-existing by stashing this branch and re-running on main: ImageCanClearBackground is off by 1/255 in one channel on my AMD GPU, and the full Windows suite kills the test host at ~5700 tests when GL runs on that driver. Neither happens on Mesa, and CI is green.

Checklist

  • Tests added or updated (if omitted, explain why above)
  • Changes above lists all public API and behavioral changes (or "None.")
  • New/changed public API? Filed a docs issue in mono/SkiaSharp-API-docs so reference docs can be written later — n/a, no public API change
  • Native change? Companion mono/skia PR linked above and bindings regenerated — n/a, no native change

web-flow and others added 30 commits July 29, 2026 02:36
Every GPU code path in the test suite was written as "try to bring up the
backend; if anything throws, Assert.Skip". That made a genuine regression -- a
broken P/Invoke, a GRContext factory that starts returning null, a CI
provisioning step that silently stopped working -- indistinguishable from "this
agent has no GPU", so CI stayed green while coverage evaporated.

The committed goldens are the receipt: ganesh-gl had a golden for macOS only
(Windows and Linux had been skipping), and graphite-dawn had none at all.

Replace the catch-and-skip with a declared four-state model in GpuPolicy. Only
one state can fail, and only one is configured:

  Required     built and expected here    -> any failure is a test failure
  Disabled     opted out for this agent   -> SKIASHARP_TEST_SKIP_GPU
  Unsupported  API does not exist here    -> compiled in, never configured
  NotBuilt     API exists, we don't ship  -> compiled in, never configured

The matrix describes platforms; the environment variable describes agents.
Nothing about a platform's inherent capabilities is expressed as configuration:
Metal on Windows and Vulkan on macOS need no setup to skip. Each backend
declares ExistsOn and BuiltOn, with BuiltOn mirroring the gn args in
native/*/build.cake, so enabling macOS Vulkan later is a one-token change.

IRenderer.IsAvailable/UnavailableReason become a single Backend property and
RendererUnavailableException is deleted -- it existed only to launder failures
into skips. SKTest.CreateGlContext, VKTest, Direct3DTest and
SKGraphiteReleaseTestsBase now gate on the policy and let exceptions escape.
Failure messages carry GpuPolicy.OptOutHint so a red test names the exact
directive that would legitimise a skip.

The hidden TF_BUILD + x64 Metal sniff in the renderers is replaced by a visible
uname -m check in the macOS, iOS and Mac Catalyst CI legs. It is the only
pre-set opt-out, and it exists to avoid a two-hour shutdown hang on the
virtualized x64 Metal driver, not to hide a failure.

Device and browser hosts cannot read the agent environment, so the same value
reaches them as -p:SkiaSharpTestSkipGpu -> runtimeconfig -> AppContext.

GpuPolicyTests emits a ##SKIA-GPU-POLICY## line per backend into every TRX, so
each leg records which backends it required and why the rest were skipped. That
report is what makes a skip auditable.

Expect several legs to go red on the first run -- that is the point. Each
failure is coverage that was already missing and is now visible, and each comes
with the opt-out directive if the gap turns out to be legitimate.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
iOSExtensionsTests.GRContextDisposeDoesNotCrash still skipped when
MTLDevice.SystemDefault was null -- the exact pattern this change removes, just
in the iOS device host rather than the shared harness. Metal is Required on
every Apple platform, so a missing device there is a red test.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
Nano Server is now its own platform in the matrix. It runs a different native
build -- native/nanoserver/build.cake passes supportVulkan=false and
supportDirect3D=false -- so Vulkan and Direct3D are absent from libSkiaSharp.dll
there even though the OS is Windows. The matrix previously inherited the plain
Windows row and would have marked both Required. Not reachable today (the Nano
leg runs only the Console suite, which has no Vulkan/D3D tests), but the matrix
is the load-bearing artifact of this change and has to be factually right.
OpenGL stays Required there: it IS built for Nano, so a container with no
driver is an agent problem, which is the tier-3 case.

Normalise the opt-out list to commas before forwarding it. GpuPolicy documents
comma, semicolon or whitespace separators, but neither cake forwarding path
survived the last two: a space splits the /p: into two process arguments, and a
semicolon is MSBuild's own property-list separator. Only commas reached the test
host, so anyone following the documented contract by hand would have got a
broken build.

Drop the Trim metadata from the RuntimeHostConfigurationOption. ILLink collects
every option marked Trim=true as a feature switch and parses its value as a
bool; this one holds a backend-id list. Dormant today (no test project enables
trimming) but a latent landmine, and Trim metadata does not affect
runtimeconfig.json generation, so it bought nothing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The macOS test leg failed before running a single test:

    MSBUILD : error MSB1006: Property is not valid.
    Switch: graphite-metal

MSBuild's -p: switch splits on commas as well as semicolons, so the
/p:SkiaSharpTestSkipGpu=ganesh-metal,graphite-metal that RunDotNetTest built by
hand parsed as two properties. Confirmed directly: `-p:Foo=a,b` gives MSB1006
while `-p:Foo=a` evaluates fine.

RunDotNetTest never needed the property. Its test process is a child of the cake
process, so it already inherits SKIASHARP_TEST_SKIP_GPU and GpuPolicy reads it
straight from the environment; and with NoBuild=true no runtimeconfig.json is
regenerated, so the property was a no-op even when it parsed. Only the device and
browser hosts need it, and that path goes through Cake's DotNetMSBuildSettings,
which quotes the value properly -- proven by the iOS and Mac Catalyst legs, which
both applied the two-backend opt-out correctly.

Also drop the generic Vulkan sentence from the SharpVk not-built reason. On Linux
it read "Vulkan is not built for this host: the Apple builds have no MoltenVK..."
when Vulkan is in fact built there and only the SharpVk vehicle is Windows-only.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
Replaces the uname -m sniff added earlier with a declarative mechanism. The
script was the same mistake as the TF_BUILD sniff it replaced -- inferring a
policy at runtime, and silently adapting if the pool changed instead of failing
loudly. What a host can do is now stated up front in the pipeline definition.

Adds an `env:` parameter to azure-templates-jobs-bootstrapper.yml that flows to
all four bootstrapper invocations: the Windows and non-Windows direct runs (via
the step env) and both Docker runs. Containers inherit nothing from the agent,
so the env is materialised into an env-file and passed to `docker run
--env-file`; the file is always written, empty when nothing is declared, so the
run command stays uniform. This is generic infrastructure -- nothing about it is
GPU-specific.

Corrects the Metal opt-out scope. macOS and Mac Catalyst drive real Metal on the
x64 pool and passed CI, so they are no longer opted out. Only the iOS leg is,
because it runs the *simulator*, whose virtualized Metal leaves dispatch-queue
state that hangs the test host on shutdown.

Declares ganesh-gl opt-outs for the five container legs. Those images have no X
server, no Mesa and no ICD, so OpenGL genuinely cannot come up there.

Fixes two P/Invoke library names that were the actual cause of the Linux and
container GL failures. DllImport("libGL") and DllImport("libX11") probe the
unversioned .so, which is a linker symlink shipped only in the -dev packages; a
runtime-only host has libGL.so.1 and libX11.so.6 and nothing else. So the Linux
leg was failing to load Mesa even though CI provisions it correctly, and had
been silently skipping that cell for as long as the harness existed.

Provisions the software Vulkan ICD for x86 as well as x64. The .NET Framework
leg runs the suite once per bitness and a 32-bit process cannot load a 64-bit
vulkan-1.dll, so x86 Vulkan had no loader at all: CI showed 25/25 passing on x64
and 21/25 failing on x86. Bitness resolution is delegated to Windows the way the
official Vulkan Runtime installer does it -- loader into System32 and SysWOW64,
each ICD manifest registered in the matching registry view -- because PATH
cannot disambiguate two files with one name.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The Windows agents have no GPU driver, so Windows falls back to the GDI generic
OpenGL 1.1 implementation, which advertises no WGL_ARB_* extensions and cannot
satisfy WglContext. Declared as an opt-out rather than left red, since there is
no fix available to land today.

This is a provisioning gap, not a platform limit, and the gap is documented so
it does not quietly become permanent: Mesa's llvmpipe would fix it with no
test-code change (its WGL extension string statically advertises both
WGL_ARB_pixel_format and WGL_ARB_pbuffer, and it reports
WGL_FULL_ACCELERATION_ARB), but there is no trustworthy feed for Mesa's Windows
binaries yet. Silk.NET ships no desktop-GL package, and its ANGLE package is
unusable -- every published version has 32-bit binaries in runtimes/win-x64.

Vulkan and Direct3D stay required on Windows: CI showed both working, 25/25 and
5/5 respectively.

Also documents the complete set of declared CI opt-outs in gpu-test-policy.md,
so what each leg can and cannot do is discoverable without reading the pipeline.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The policy is a lookup table and one Assert.Skip; it did not need 611 lines
across four files. Now 280 across two, with no behaviour change.

Collapses GpuBackend.cs, TestPlatforms.cs and GpuPolicy.cs into one file. Drops
the GpuAvailability enum in favour of the state token the report already needed,
which removes the enum, its doc block and the token mapper. Replaces the Entry
class and its constructor with a tuple array, so a backend row is one line.

Generates the skip reasons from the id and platform name rather than storing a
hand-written paragraph per backend. The detail those paragraphs carried -- which
gn arg to flip, which file to edit -- belongs in gpu-test-policy.md, where it is
already written, not repeated in every skip message.

Trims the call-site comments. "No catch: the policy already decided" appeared at
seven sites; the rule is stated once on IRenderer and once in the doc, so the
repetitions were noise next to a self-evident RequireOrSkip call. Also drops a
stale <see cref="GpuAvailability.Required"/> and the duplicated policy paragraph
from the two Vulkan renderers.

Verified identical behaviour: same policy report, same typo-guard error, and the
same 6092 tests with the same 2 pre-existing failures.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The policy still carried more machinery than the decision it makes. A GPU test
either skips with a reason, fails, or passes; everything else was ceremony.

Replaces the GpuBackend enum with GpuBackends string consts. The enum and the id
string were the same fact twice, with Id() and Find() only to map between them --
and every renderer declared both, since IRenderer.Name was documented as equal to
the id. So IRenderer.Backend is gone entirely and the matrix gates on Name.

Replaces the ExistsOn/BuiltOn pair with a single Dictionary<string, TestPlatforms>
of where each backend must work. ExistsOn was read in exactly one place, to
choose between "does not exist on" and "is not built for" -- a whole platform set
per row to pick a verb. The surviving reason, "'ganesh-metal' is not required on
windows", is complete; why it is not required belongs in the doc's table, is not
actionable at a skip, and was the same per-row prose the previous pass deleted.

Moves TestPlatforms and platform detection to TestConfig, which already owns
IsWindows, IsApple and IsNanoServer. Neither is a GPU concept, and this removes a
third copy of the same #if ladder: VisualPlatform hand-wrote the identical probe
order to build golden directory tags, and its strings map exactly onto the enum
names, so it now derives from TestConfig. Golden tags verified byte-identical
before and after -- that path decides which reference PNG a cell compares to.

Drops the messaging helpers. OptOutHint appended "here is how to opt out" to
eleven failure messages; the exception already says what broke. Describe() and
the ##SKIA-GPU-POLICY## marker duplicated what xUnit already publishes, since a
skipped test carries its reason into the same TRX. OptOutSource, the state token
and the Cpu special case go with them.

Drops Lazy for plain static readonly fields. The runtime already gives the
guarantee the Lazy was hand-rolling: a throwing static initializer caches a
TypeInitializationException that every later access rethrows, so a malformed
opt-out list still fails every GPU test identically. Verified the message is
still legible through the wrapper. Startup cost is irrelevant here.

Public surface is now two consts, RequireOrSkip and Validate. GpuPolicy.cs goes
from 241 lines to 131, and a new test asserts every renderer name is a known id,
catching drift the enum could not express.

Behaviour verified unchanged: 5927 non-GPU tests still pass with 16 declared
skips, the visual matrix still reports 25/5/5/15, golden tags are identical,
=all still spares raster, and the typo guard still names the valid ids.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
Deletes documentation/dev/gpu-test-policy.md. The policy is a table and one
skip; it does not need a page of its own, and the visual matrix is the main
consumer, so the table, the opt-out syntax, the CI opt-out list and the Windows
software-GL gap now live in golden-image-tests.md.

Merges SkipReason into RequireOrSkip -- SkipReason had no other caller once the
report was gone.

Replaces Validate() with a public Disabled(). Validate read disabled.Count to
force a static initializer, which reads as counting a set that obviously cannot
throw; the throw came from class init. Disabled() parses on each call and throws
directly, so the typo guard is now a plain InvalidOperationException instead of
one wrapped in TypeInitializationException, and the static-init ordering
constraint is gone. Tests do not need the cache.

Uses the GpuBackends consts for every renderer Name, which were still literals.

Rewrites comments that told a story rather than describing the code as it is:
the simulator Snap() note said what it "used to be", the Vulkan ICD header
narrated the x86 gap as a discovery, test-shared.cake explained what it was
deliberately not doing, and Directory.Build.targets did the same for Trim
metadata. Also drops comments that only restated the call below them, and fixes
two that referenced the removed Unsupported state.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
660 lines across one file becomes 281 across two, and the content now matches
the code.

Splits the GPU policy into its own 77-line page. It gates five test families --
the visual matrix, the GL, Vulkan and Direct3D tests, and the Graphite release
tests -- so scoping it under "golden image tests" was wrong. The previous policy
page was deleted for length, not for existing; this one is a table, an opt-out
syntax and a pointer to the pipeline.

Presents raster, Ganesh and Graphite as three equal families. The old text
described Graphite as in-flight, including a whole "Graphite seam" section that
was a rebase plan for a PR that has since landed, and per-host tables that listed
Graphite renderers as follow-ups.

Corrects claims that no longer held:

  * "every cell emits its PNG on pass and fail" was wrong in the case that
    matters -- RenderAsync runs before the marker is emitted, so a render failure
    emits nothing. The lifecycle section now says which outcomes carry an image.
  * "compared strictly" -- comparison is tolerance-based, always.
  * golden lookup is three-deep on Nano Server (nanoserver, windows, shared),
    not two.
  * GpuRenderGate does not exist; serialization is an xUnit collection.
  * there is no Direct3D visual renderer, so the coverage table invented one.
  * VisualPlatform.Tag is Tags, the tag list omitted nanoserver, and Linux GL is
    GLX rather than "GLX/EGL".
  * the Desktop/ folder rule claimed to cover Metal, which is shared.

Replaces the host coverage matrix, which conflated compiled, required and seeded
and drifted immediately, with the renderer list plus a pointer to the policy
table and the goldens directory. Merges three overlapping seeding sections into
one, and drops the storage, tolerance and CI rationale essays.

Also removes a dead "direct3d" key from GoldenTolerance -- no renderer has that
name -- and the Ganesh entries that only restated the fallback, leaving raster as
the one special case.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The TRX markers used three inconsistent names and one was actively wrong:
##SKIA-GOLDEN-IMAGE## carried the *actual* rendered image, not the golden,
and ##SKIA-VISUAL-IMAGE## conflated the golden and the diff, distinguishing
them by a suffix baked into the path.

Rename to one role per marker, all sharing the golden key as their path:

  ##SKIA-VISUAL-ACTUAL## path=... outcome={pass|mismatch|unseeded} size=... base64=...
  ##SKIA-VISUAL-GOLDEN## path=... size=... base64=...
  ##SKIA-VISUAL-DIFF##   path=... size=... base64=...

This drops ##SKIA-VISUAL-CELL## by folding the verdict onto the actual image.
The verdict cannot be derived from the images alone -- a pass and an unseeded
test both emit only an actual -- so it still has to be stated, but it no longer
needs a marker of its own. Emitting it means the actual image now goes out
after the comparison rather than before.

The harvest script loses a regex, a dict and the key-mangling that rebuilt
'{scene}.golden.png' to look images up; the three roles are now just three
dicts keyed by the same path.

Vocabulary: 'cell' -> 'test', 'seam' -> 'interfaces', and 'lifecycle' /
'discipline' headings replaced with plain descriptions.

Verified: visual suite 25 total / 5 failed / 5 succeeded / 15 skipped
(unchanged); a forced mismatch emits all three markers and the script writes
actual+golden+diff into mismatch/ with correct bytes; seeding dry-run yields
the same 10 goldens; full non-GPU suite 5927 / 0 failed / 16 skipped.
The outcome= field on the actual-image marker duplicated what the markers
already imply. No golden marker means no golden was committed; a diff only
exists when there was something to diff against. The test result and its
message say whether a comparison passed -- the harvest script does not need
to re-derive that.

So drop the field, and emit the golden and diff whenever a golden was found
rather than only on a mismatch. A pass at 99.5% now ships its diff too, which
is the case actually worth eyeballing.

This deletes the outcome grouping in extract-visual-goldens.py: it no longer
sorts into unseeded/ and mismatch/, it just writes what it found, mirroring
the goldens tree as {renderer}.{platform}/{scene}.{actual,golden,diff}.png.
A scene with only an .actual.png had no golden. Renamed --failures-out to
--images-out to match, since it was never only failures.

Verified: with a forced mismatch, ganesh-gl.windows extracts 5 actual-only
images (unseeded) and raster.windows extracts actual+golden+diff for all 5,
the mismatch showing golden 4323 B against actual 4711 B. Seeding dry-run
unchanged at 10 goldens. Visual suite 25/5/5/15, full non-GPU suite
5927 / 0 failed / 16 skipped. YAML parses.
Two dictionaries, a composite string key and a three-branch lookup existed to
express 'raster is strict, everything else is not'. ByRendererScene was empty
and ByRenderer held a single entry, since the ganesh-* rows only restated the
fallback and the direct3d row named a renderer that does not exist.

Now it is a ternary, and sceneName leaves the signature because nothing read
it. If a scene ever needs its own tolerance, special-case it then.

Visual suite unchanged at 25/5/5/15.
Both said a missing display or ICD makes the GPU tests skip and that the
provisioning 'never turns the build red'. Under this policy ganesh-gl and
ganesh-vulkan are required on Linux, so missing provisioning fails.
A review against the code turned up five statements this change falsifies:

  * AGENTS.md said tests never skip 'except missing hardware' -- missing
    hardware is now precisely what fails.
  * native-dependency-update and update-skia (twice) told the reader that
    backends self-skip when unavailable.
  * golden-image-tests.md suggested special-casing a single scene in
    GoldenTolerance.For, which takes only the renderer name.
Graphite landed in #3968 and skia_enable_graphite=true on every platform, with
Vulkan on Windows/Linux/Android, Metal on Apple and Dawn on WASM. Six skills
still told the reader to filter those changes out:

  * security-audit classed Graphite, Vulkan and Dawn as NOT_REACHABLE compile
    flags 'we don't use', which would dismiss a live CVE. It now points at the
    gn args in native/*/build.cake instead of naming a fixed list.
  * update-skia scored Graphite changes as SKIP, marked skgpu::graphite:: and
    Dawn/wgpu as irrelevant, and framed shared GpuTypes.h changes as a
    Graphite-only trap rather than a change reaching both families.
  * skia-analyst excluded Graphite and Dawn changes outright.
  * sample-scout classified any file naming Graphite or Dawn as low and called
    Graphite 'not SkiaSharp'. Backend-internal GMs are still low; the test is
    now whether it exercises internals, not which backend it names.
  * api-docs used 'Vulkan (not yet supported)' as a formatting example.

Also documents the container legs' ganesh-gl opt-out, which this branch added
to five legs without saying so in containerized-testing.md.
The previous pass flipped 'exclude Graphite, we use Ganesh' into 'include
Graphite', which is the same mistake with the sign changed: naming one backend
as included implies the others are not, and the guidance still had to be
rewritten every time a backend lands. It also introduced three false claims --
skia_enable_graphite is not set on Tizen and is conditional on WASM, Nano Server
builds with Vulkan and Direct3D off, and Vulkan is not deprecated.

Rewritten around the real criteria instead:

  * update-skia's risk table categorises kinds of change, so the backend row is
    simply gone -- a GPU change is already Removed/Renamed/New/Behavior.
  * the relevance table now says relevance is whether our C API or a shipped
    build touches the code, and folds the four GPU prefixes into one row that
    points at native/*/build.cake rather than asserting a platform map.
  * skia-analyst just drops the exclusions: what is not excluded is included.
  * security-audit's NOT_REACHABLE names no backend at all. It asks for the
    platform and the flag, and notes a flag off in one build is often on in
    another -- which is the actual trap.
  * sample-scout keeps 'is it backend internals?' and drops the platform list.

Also fixes a pre-existing scope error: the 'full test suite' command ran
SkiaSharp.Tests.Console.csproj, which references neither the Vulkan nor the
Direct3D project, while claiming to run all three. It now runs the solution.
It was the only continueOnError: true in the repo (from #3247). A leg that
cannot turn the build red cannot report a regression either, which is the same
failure mode this branch exists to remove. The bootstrapper already defaults
the parameter to false, so deleting the line is the whole change.

Mac Catalyst has no graphite-metal.maccatalyst goldens, so this is expected to
surface as an unseeded failure until they are harvested.
Two findings from a review pass, both latent rather than live:

The bootstrapper's env: values were pasted into the generated shell and
PowerShell as source text, so a quote in a value would break out of the string,
and the file was cat'd to the build log before every containerised run. The
values are ours and are backend ids today, but the parameter is generic. Values
now travel in the step's own environment and are read at runtime, the contents
are no longer printed (the step's displayName already names the key), and the
file is removed in an always() step. Verified on both shells with a value
containing a double quote, dollar, backtick, apostrophe and %s.

SAFE_PATH_RE anchored with \$, which in Python also matches before a trailing
newline, so 'a/x.png\\n' passed the guard. Unreachable today because the marker
regex captures [^\\s]+, but the guard should not depend on its caller. Anchored
with \\Z instead.

Verified: 20 attack paths still blocked, valid keys still allowed, visual suite
25/5/5/15, extraction 20 images, seeding 10 goldens.
The published TRX from build 159115 shows graphite-dawn failing on both WASM
legs with 'navigator.gpu.requestAdapter returned null - WebGPU is unavailable in
this browser'. That is a hard failure, not a missing golden, so no amount of
harvesting turns it green.

The headless browser is launched by the DeviceRunners CLI, whose 'wasm test'
command accepts only --app, --results-directory, a logger, a filter and a
timeout. There is no browser-argument passthrough, so the WebGPU flags cannot be
supplied without an upstream change to that preview package.

Declared rather than left red, with the reason and the blocker recorded at the
opt-out. The gap is now named instead of being an invisible skip, which is the
point of the policy.
Three things CI surfaced once GPU backends became required. All three are
pre-existing; this branch only made them visible.

GlxContext.Destroy() released the context, the GLX pixmap and the pixmap, then
dropped the display handle without calling XCloseDisplay -- Xlib.cs did not even
bind it. Every GPU test builds a context, so a run leaked one X11 connection per
test along with the driver state behind it. The Linux leg then died with exit
code 7 partway through SKBitmapThreadingTest, the one test that deliberately
stresses allocation. WglContext and CglContext both release properly; GLX was
the outlier.

SKBlenderTest asserted that the blend-mode and blender paths produce an
identical colour. They are different shaders on a GPU and round independently:
llvmpipe returned #ff5e0000 and #ff5d0000 for Luminosity. Raster keeps exact
equality; the GPU subclass now allows one unit per channel, well under the 12
the golden comparison already allows.

Mac Catalyst cannot run Metal at all: a Catalyst app sees iOS-style GPU
families, never Mac2, so the device satisfies neither Ganesh nor Graphite and
bring-up throws. Declared as an opt-out with that reason recorded.

Verified: blend tests 232/232 (raster exact, GPU tolerant), non-GPU suite
5927 / 0 failed, visual unchanged at 25/5/5/15. The GLX fix is Linux-only and
cannot be exercised from this host.
The macOS test job hung for 168 minutes with no output and was killed at the
180 minute timeout, publishing no TRX at all -- so the whole leg was lost, not
just its Metal tests.

The cause was already known and documented in the renderers this branch
rewrote. GaneshMetalRenderer carried an IsAzureDevOpsX64Host check (TF_BUILD
plus OSArchitecture == X64) that short-circuited before touching Metal, because
'the mere act of calling MTLCreateSystemDefaultDevice + newCommandQueue on that
device leaves state that hangs the test host's post-session shutdown for 2h+'.
GraphiteMetalRenderer deferred to the same reasoning. Removing that sniff was
deliberate -- runtime detection is what this branch replaces -- but the
declaration that should have taken its place was missed for macOS, so the
observed 168 minutes is that comment coming true.

Declared per the policy, with the reason recorded at the opt-out. All three
Apple legs now opt out of Metal, which means CI has no Metal coverage at all;
issue #4555 has been broadened from the narrow iOS-simulator gradient bug to
track that, including the shutdown hang and the Catalyst GPU-family gap.
SKTest already exposes AssertSimilarColor(expected, actual, tolerance) with the
same per-channel logic and better failure messages. The private helper added
alongside the GPU tolerance duplicated it; SurfaceTestBase derives from SKTest,
so it was already in scope.

Blend tests unchanged at 232/232 -- raster exact, GPU within one unit.
Three changes, two from PR review and one from the CI run.

The Linux leg still crashes with exit code 7 after the XCloseDisplay fix: four
retries died at 523, 312, 5068 and 0 tests with zero failures each time, and
none published a TRX, so the whole leg is lost rather than just its GL tests.
The cause is that the nine classes calling CreateGlContext() are in no xUnit
collection, so they create and destroy llvmpipe contexts concurrently -- only
the visual tests are serialised. That race was unreachable until this branch
fixed the libGL SONAME. Declared as an opt-out and filed as #4590; the real fix
is one shared collection, which needs a Linux host to verify.

RequireOrSkip reported every skip as coming from SKIASHARP_TEST_SKIP_GPU, but
device and browser hosts never see that variable -- the value arrives through
AppContext from the MSBuild property. Split the read into OptOut() and Parse()
so a skip names whichever one actually set it. Verified both ways: the env var
path prints 'via SKIASHARP_TEST_SKIP_GPU' and a -p:SkiaSharpTestSkipGpu build
prints 'via SkiaSharp.Tests.SkipGpu'.

NormalizeGpuOptOut described its separators as whitespace but did not split on
newlines, unlike GpuPolicy, so a YAML block value could carry one into an
MSBuild property. Now consistent.

Also gave every opt-out a tracking issue (#4555 Metal, #4590 Linux GL, #4591
umbrella) and corrected the iOS comment, which still claimed macOS and Mac
Catalyst were not opted out.

Verified: opt-out parsing unchanged (case, separators, 'all', raster and typo
both throw), policy guards 3/3, visual 25/5/5/15, non-GPU 5927 with only the
documented GC-lifetime flakes, which reproduce identically on the unmodified
branch.
The netfx leg ran x86 and x64 in one job, so an opt-out could not differ between
them -- GpuPolicy models the OS, not the architecture. That mattered once the x86
Vulkan ICD was provisioned: SwiftShader's LLVM JIT cannot resolve __chkstk in a
32-bit process, so the software driver crashes the host outright rather than
failing a test:

    JIT session error: Symbols not found: [ __chkstk ]
    SkiaSharp.Vulkan.Tests.exe (.NET Framework 4.8|x86) - exit code is '7'

Four retries, all x86, all identical; x64 ran the same suite green. Before the
x86 ICD existed the loader was simply absent and the tests failed instead, so
this is provisioning revealing a real limitation rather than a new fault.

Two jobs now, each passing --arch and carrying its own opt-out: x64 skips only
ganesh-gl, x86 also skips the three Vulkan backends. Direct3D stays required on
both. The split also makes any future x64/x86 divergence visible on its own leg
instead of hidden inside a combined one.

The cake target already accepted --arch, so no script change was needed.
The image marker path carries the OS tag, not the architecture or the retry
number, so the same scene appears in several TRX files on one leg. extract_images
wrote each role independently as it found it, so a triple could pair one run's
actual with another run's golden -- misdirecting whoever reads the triage images.
Each path is now taken whole from the first TRX that has it. Verified against two
TRX with identical paths: 20 images written rather than 40, seeding unchanged at
10 goldens.

Two comments had drifted from the code. SKGraphiteReleaseVulkanTests still said
Vulkan 'skips cleanly otherwise', which is what this branch removes, and the
gpu-test-policy summary of current opt-outs never gained Linux after ganesh-gl
was opted out there.

Not addressed, and noted on #4591: extract-visual-goldens blocks lexical path
traversal but does not resolve symlinks under the output directory. That needs a
pre-existing hostile link inside a fresh agent workspace to matter.
Brings in #4588, which fixes the benchmark-source native build: vcvarsall was
handed a Windows SDK version the hosted runner does not have, and >nul hid the
error. That was the one red GitHub check.

A docs review against the code found four contradictions:

The Mac Catalyst comment still said macOS 'is NOT opted out'. That was true when
written and stopped being true when macOS was opted out — the same stale claim
already fixed on the iOS leg, missed here.

review-skia-update's C# checklist still allowed 'no skipped tests (except
hardware-dependent: GPU, display)', which is exactly the inference this branch
removes.

gpu-test-policy claimed a backend is required on every host we build it for, and
that RequiredOn mirrors the gn args. Neither is literally true: the browser build
enables Ganesh without ganesh-gl being required there, and Tizen builds Ganesh
with no test leg at all. RequiredOn lists test hosts, and now says so.

golden-image-tests placed the Vulkan renderers in the Console satellite. The
sources are under tests/VulkanTests/ and also build into the platform-restricted
SkiaSharp.Vulkan.Tests library that the Android and Windows device hosts
register.

Also notes that a platform tag need not have goldens yet — tvos and
graphite-dawn.browser have none, so their first run fails as unseeded by design.
OpenGL was opted out of every CI leg, so `ganesh-gl` -- required on Windows,
Linux and macOS by `GpuPolicy.RequiredOn` -- only ever ran on macOS. This turns
it on for the desktop Windows and Linux legs and fixes the three separate
problems that were in the way. All of it was reproduced and verified locally:
Mesa on Windows, and Ubuntu under WSL with Xvfb for Linux.

**Windows had no OpenGL at all.** Server agents have no display driver with an
OpenGL ICD, so `opengl32.dll` answers with the in-box generic implementation:
GL 1.1, no `WGL_ARB_pixel_format`, no `WGL_ARB_pbuffer`. `install-mesa-gl.ps1`
provisions Mesa the way Mesa itself documents for machines with no OpenGL
driver: `libgallium_wgl.dll` becomes `System32\mesadrv.dll` and
`SysWOW64\mesadrv.dll`, registered under `OpenGLDrivers\MSOGL`. Registering an
ICD rather than dropping an app-local `opengl32.dll` is what makes it work at
all -- gdi32's `ChoosePixelFormat`/`SetPixelFormat` only reach a registered
driver, so an app-local Mesa gets a pixel format it never learns about and every
`wglCreateContext` afterwards returns NULL. Measured both ways. Going through
the ICD needs no test-code change, and the script proves the result by creating
a real GL context in both bitnesses before it exits.

**One test crashed the Linux host.** `GRGlInterfaceTest.AssembleInterfaceIsValid`
resolved its proc addresses with `glXGetProcAddress` alone. Under GLVND that
returns a dispatch stub for *any* name -- `glTotallyNotARealFunction` included --
so Skia was handed pointers that are not functions and segfaulted in
`GrGLExtensions::init` walking the extension list. This was the whole of #4590:
a hard native crash, no failed test, no results published, at a point that
looked random only because the run order varied. It now resolves through `dlsym`
on `libGL.so.1`, exactly like the macOS branch already did.

**llvmpipe cannot compile one of Skia's shaders.** Mesa's LLVM shader JIT
segfaults building the fragment shader for a runtime blender, reproduced on
Mesa 25.2/LLVM 20 (Linux) and 26.1/LLVM 22 (Windows). Both legs select
`GALLIUM_DRIVER=softpipe`, the non-JIT gallium rasterizer, which runs the
identical tests green on both platforms in about ten seconds. Filed as #4604.

Alongside that, every class that creates a GPU context joins the existing
`GpuRenderingCollection` so no two ever run concurrently -- the fix #4590 asked
for, mirroring `VulkanGpuRenderingCollection`. Where only a nested class does
GPU work its raster sibling stays parallel, so this serializes about 300 of
6100 tests. `GlxContext` now shares one X11 connection for the process instead
of opening and closing one per test, and `XInitThreads` runs before any other
Xlib call.

The container legs stay opted out, and the comment there now says so as a
decision rather than a pending item: those images exist to prove SkiaSharp works
with the bare minimum installed, so giving them an X server and Mesa would
defeat their purpose.

Goldens for `ganesh-gl.windows` and `ganesh-gl.linux` are harvested and
committed, since a backend that renders for the first time is unseeded and fails
until they exist.

Verified: 165/165 GPU tests and 10/10 visual tests on Mesa softpipe on both
Windows and Linux; the full Linux suite runs 6117 tests with no crash, where it
previously died with exit 7 and published nothing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
@github-actions

Copy link
Copy Markdown
Contributor

📦 Try the packages from this PR

Warning

Do not run these scripts without first reviewing the code in this PR.

Step 1 — Download the packages

bash / macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4605

PowerShell / Windows:

iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4605"

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-4605/packages --name skiasharp-pr-4605
More options
Option Description
--successful-only / -SuccessfulOnly Only use successful builds
--force / -Force Overwrite previously downloaded packages
--list / -List List available artifacts without downloading
--build-id ID / -BuildId ID Download from a specific build

Or download manually from Azure Pipelines — look for the nuget artifact on the build for this PR.

Remove the source when you're done:

dotnet nuget remove source skiasharp-pr-4605

@mattleibow
mattleibow changed the base branch from mattleibow-gpu-test-skip-policy to main July 31, 2026 00:00
…d 7z

Two follow-ups on install-mesa-gl.ps1.

CreateWindowExW and SetPixelFormat were declared without SetLastError, so the
bring-up failure messages printed whatever stale value happened to be around --
"SetPixelFormat failed (0)" is worse than no number at all, and diagnostics are
the whole reason this script verifies rather than assuming.

The archive is 7-Zip, and tar.exe only reads that when its libarchive was built
with liblzma, which is not guaranteed on every agent image. It now tries tar and
then 7-Zip, which the Windows images carry, and throws naming both if neither
worked -- still fatal, never silent.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation for this PR has been deployed and is available at:

🔗 View Staging Site
🔗 View Staging Docs
🔗 View Staging Gallery (Blazor)
🔗 View Staging Gallery (Uno Platform)
🔗 View Staging SkiaFiddle

This preview will be updated automatically when you push new commits to this PR.


This comment is automatically updated by the documentation staging workflow.

@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #4605

⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS

Informational only — this never blocks the PR. 🟢 faster / less allocation · 🔴 slower / more allocation; moves under 5% are hidden as noise.

⏱️ Times are raw BenchmarkDotNet means, and the ⭐ PR and baseline legs run on separate CI runners, so microbenchmarks can swing run-to-run — treat small time deltas as noise. Allocations are deterministic and the reliable signal. The interactive perf-dashboard (linked below) applies smoothing for the trend view.

Highlights

⏱️ Time — 🔴 27 slower · 🟢 17 faster

  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 256) · Windows · 168.1 ns → 270.5 ns (+61%)
  • 🔴 BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) · macOS · 173.26 µs → 251.23 µs (+45%)
  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 4096) · Windows · 2.21 µs → 3.16 µs (+43%)
  • 🔴 RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) · Windows · 93.82 µs → 125.71 µs (+34%)
  • 🔴 ColorMathBenchmark.ToColorF(Colors: 4096) · Windows · 13.31 µs → 17.42 µs (+31%)
  • …and 39 more (see details below)
Full per-OS benchmark deltas

Linux

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.114)

Benchmark baseline this PR Δ
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 101.07 µs 125.53 µs 🔴 +24%
PathBoundsBenchmark.TightBounds(Points: 1024) 10.57 µs 12.88 µs 🔴 +22%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 258.92 µs 276.50 µs 🔴 +7%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 248.8 ns 233.9 ns 🟢 -6%

Windows

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.114)

Benchmark baseline this PR Δ
MatrixMapPointsBenchmark.MapPoints(Points: 256) 168.1 ns 270.5 ns 🔴 +61%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.21 µs 3.16 µs 🔴 +43%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 93.82 µs 125.71 µs 🔴 +34%
ColorMathBenchmark.ToColorF(Colors: 4096) 13.31 µs 17.42 µs 🔴 +31%
ColorMathBenchmark.ToColor(Colors: 4096) 14.61 µs 11.25 µs 🟢 -23%
RuntimeEffectShaderBenchmark.DrawFrame 1.13 ms 987.79 µs 🟢 -13%
PathBoundsBenchmark.TightBounds(Points: 64) 1.51 µs 1.70 µs 🔴 +13%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.90 ms 3.26 ms 🔴 +12%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 148.18 µs 132.23 µs 🟢 -11%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.85 µs 4.36 µs 🟢 -10%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 264.37 µs 288.06 µs 🔴 +9%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 76.49 µs 69.67 µs 🟢 -9%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 742.43 µs 802.50 µs 🔴 +8%
MatrixMapPointsBenchmark.MapVector(Points: 256) 8.19 µs 7.54 µs 🟢 -8%
ColorParseBenchmark.Parse(Iterations: 1000) 74.99 µs 80.71 µs 🔴 +8%
MatrixMapPointsBenchmark.MapRect(Points: 256) 7.39 µs 7.94 µs 🔴 +7%
PathBoundsBenchmark.TightBounds(Points: 1024) 15.94 µs 17.11 µs 🔴 +7%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 12.27 µs 11.39 µs 🟢 -7%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 8.94 µs 8.30 µs 🟢 -7%
CanvasDrawBenchmark.Draw(Shapes: 512) 21.25 ms 19.96 ms 🟢 -6%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.66 ms 2.50 ms 🟢 -6%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 118.25 µs 124.99 µs 🔴 +6%
MatrixOpsBenchmark.Invert(Count: 4096) 131.07 µs 124.21 µs 🟢 -5%

macOS

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.114)

Benchmark baseline this PR Δ
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 173.26 µs 251.23 µs 🔴 +45%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 796.54 µs 998.58 µs 🔴 +25%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 1.57 ms 1.94 ms 🔴 +24%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 142.4 ns 175.1 ns 🔴 +23%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 5.65 ms 6.95 ms 🔴 +23%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 1.24 ms 1.50 ms 🔴 +20%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.65 µs 1.89 µs 🔴 +15%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 72.30 µs 80.69 µs 🔴 +12%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.89 ms 3.21 ms 🔴 +11%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 6.09 ms 6.77 ms 🔴 +11%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 1.22 µs 1.34 µs 🔴 +10%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 692.93 µs 643.98 µs 🟢 -7%
ColorMathBenchmark.ToColorF(Colors: 4096) 5.78 µs 5.39 µs 🟢 -7%
MatrixMapPointsBenchmark.MapRect(Points: 256) 3.07 µs 3.26 µs 🔴 +6%
CanvasDrawBenchmark.Draw(Shapes: 64) 1.76 ms 1.66 ms 🟢 -6%
ColorMathBenchmark.ToColor(Colors: 4096) 21.71 µs 20.51 µs 🟢 -5%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 777.63 µs 737.91 µs 🟢 -5%

📈 Full interactive perf-dashboard & run details →

mattleibow and others added 2 commits July 31, 2026 03:50
The first CI run got Mesa installed and the MSOGL ICD registered on the Windows
agents, then failed at `wglCreateContext returned NULL` -- with no way to tell
from the log whether Mesa had been loaded at all, or had been loaded and could
not create a context.

So the verification now reports what actually answered: which opengl32 is
mapped, whether mesadrv.dll and libgallium_wgl.dll are in the process, how many
pixel formats the driver offered (four figures for Mesa, a couple of dozen for
the in-box generic one) and which one was chosen. That one line separates "the
registration did not take" from "Mesa is here and unhappy".

It also stops betting the leg on a single gallium driver. softpipe is still
tried first, for the llvmpipe crash in #4604, but llvmpipe, d3d12 and Mesa's own
default now follow, and the first that brings up a real Mesa context with the
WGL extensions WglContext needs is the one exported to the test step. Every
attempt is reported whether it worked or not, so a run where none of them work
still says why for each. A process can only ever create one OpenGL context, so
each attempt is its own child process.

dxil.dll now ships alongside mesadrv.dll, as Mesa's own system-wide deployment
does -- the d3d12 driver will not load without it -- and LIBGL_ALWAYS_SOFTWARE
is set, matching the Linux leg, so a layered driver stays on a software device
instead of hunting for hardware that is not there.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
…ot reach the driver

CI proved the Mesa deployment works and pinned down what was actually wrong. The
diagnostics from the Windows agents:

    mesadrv=C:\Windows\SYSTEM32\mesadrv.dll; pixelFormats=1332; chosenFormat=121
    FAILED: wglCreateContext returned NULL (2000)

So the MSOGL registration does take effect -- Mesa is loaded as the system ICD
and serving its own 1332 pixel formats, and a different count per gallium driver
proves GALLIUM_DRIVER is honoured too. Error 2000 is ERROR_INVALID_PIXEL_FORMAT:
GDI's SetPixelFormat returns true but never tells the driver which format was
picked, so the context creation that follows has nothing to build on.

opengl32's own wglSetPixelFormat is the entry point that does reach the driver.
It cannot simply replace the GDI call, though: a real hardware ICD wants the GDI
path and refuses a context when the format was set the other way, which is
exactly what a developer running these tests on a normal machine has. So the Wgl
bootstrap now tries GDI first and only falls back on failure, on a fresh window
since a pixel format can be set once per DC.

Measured both ways on one machine: with Mesa softpipe the fallback carries all
165 GPU tests and the 10 visual ones, and with the real AMD driver the GDI path
still wins and nothing changes. The provisioning script takes the same fallback
and now reports which path answered, so the log says which one a given agent
needed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

📦 Artifact size report

Packages from this PR (build 1534999) vs the latest nightly baseline 4.151.0-nightly.114 (observed 2026-07-31).

Total .nupkg size: 569.2 MB → 568.9 MB (−310.6 KB, -0.1%)

Packages

⚠️ marks growth over 500.0 KB or 2%. Changes under 50.0 KB are treated as noise.

Package baseline this PR Δ Δ%
SkiaSharp.NativeAssets.WinUI 109.0 MB 108.6 MB 🟢 −409.4 KB -0.4%

+39 package(s) unchanged (< 50.0 KB).

Per-file changes

SkiaSharp.NativeAssets.WinUI

File Size
runtimes/win-arm64/native/libGLESv2.pdb 64.5 MB → 64.4 MB (🟢 −128.0 KB)
runtimes/win-x86/native/libGLESv2.pdb 67.3 MB → 67.2 MB (🟢 −96.0 KB)
runtimes/win-x64/native/libGLESv2.pdb 66.6 MB → 66.6 MB (🟢 −80.0 KB)

Informational only — this never blocks the PR. Native binaries are labelled by os/arch.

mattleibow and others added 3 commits July 31, 2026 06:50
#4575 landed on main as a squash, so its content arrives again as commits this
branch already had. Conflicts resolved by taking main's reviewed version of
everything that belongs to #4575 and re-applying this branch's changes on top:

- gpu-test-policy.md goes back to main's wording exactly. Review deliberately
  removed the enumerated list of current opt-outs from that document -- it
  describes the mechanism, and the YAML is the live list -- so the paragraph
  this branch had grown there is dropped rather than updated.
- containerized-testing.md and the Apple tracking-issue references (#4598,
  #4599) take main's corrected text.
- The container-leg comments combine both: main's #4591 reference with this
  branch's point that the images have no GPU stack by design and the desktop
  legs carry the ganesh-gl coverage.

Two things the automatic merge got wrong and are fixed here: it reinstated the
three desktop `SKIASHARP_TEST_SKIP_GPU: ganesh-gl` opt-outs this branch removes
(Windows .NET Framework x64, Windows .NET Core, Linux), and it brought back the
XCloseDisplay binding that no longer has a caller now that GlxContext shares one
connection.

Re-verified after merging: 33/33 GL tests on a real driver, and 165/165 GPU plus
10/10 visual on Mesa softpipe.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
The provisioning script had grown a 250-line embedded C# verifier that created a
real WGL context and walked a matrix of gallium drivers. That was worth writing
while the Windows agents were a black box -- it is what identified the ICD as
loaded and the failure as ERROR_INVALID_PIXEL_FORMAT -- but keeping it means a
provisioning script that duplicates what the suite already does. Now that the
mechanism is understood and green, it earns its keep as a much smaller check,
in the spirit of the lavapipe verification on the Linux side.

It now confirms what provisioning is actually responsible for: the driver is
where opengl32 will look for it, it is the build just pinned rather than a
leftover from an earlier run, and the MSOGL registration reads back. Proving a
context can be created belongs to the tests, and
GRContextTest.CreateDefaultContextIsValid already does it on every leg where
GpuPolicy requires ganesh-gl -- a broken driver is a red test there, which is
the whole point of the policy.

The driver matrix goes with it: softpipe is pinned outright, the same as the
Linux leg, since that is what the run selected and llvmpipe is out for #4604.

458 lines down to 184. Each failure mode was exercised against a simulated
install: good, stale version, missing file, misregistered, and unregistered.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
The fallback that retries with opengl32's own wglSetPixelFormat had a verbatim
second copy of the CreateWindowEx call, which is exactly the shape where a later
edit fixes one copy and misses the other. Both now go through one local
function.

The comment claimed GDI's SetPixelFormat "does not always reach the driver",
which reads as if it were intermittent. It is not: it is consistent per driver,
and the two APIs are exactly inverted. A hardware ICD is set up through GDI and
refuses a context when the format was set with opengl32's wglSetPixelFormat;
Mesa is the other way round, because Mesa's per-HDC state is only created by its
own wglSetPixelFormat, so the GDI route leaves wglCreateContext nothing to look
up and it fails with ERROR_INVALID_PIXEL_FORMAT (2000). That is why this is a
fallback rather than a choice made up front.

No behaviour change, and no second window: the first is destroyed before it is
replaced, so only one is ever alive. The comment now also says why a new window
is needed rather than a new DC -- a pixel format can be set only once per DC,
and the class is registered CS_OWNDC, so re-getting the DC hands back the same
one.

Re-checked both paths: 165/165 GPU and 10/10 visual on Mesa softpipe, and the
GDI path still unchanged on a real driver.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
@mattleibow
mattleibow merged commit 05dfca5 into main Jul 31, 2026
113 of 116 checks passed
@mattleibow
mattleibow deleted the mattleibow-dev-gpu-ganesh-gl-ci branch July 31, 2026 19:45
mattleibow added a commit that referenced this pull request Aug 4, 2026
[tests] Run ganesh-gl on the Windows and Linux CI legs (#4605)

Context: #4605
Context: documentation/dev/gpu-test-policy.md
Fixes: #4590

#4575 made a GPU backend required on every platform GpuPolicy.RequiredOn names
and turned the silent skips into an enumerable list. ganesh-gl was the largest
entry on it: required on Windows, macOS and Linux, but opted out of the two
desktop legs that had no working GL stack. This closes those, so the Ganesh GL
backend now runs on all three desktop platforms.

This is not "GL was untested until now". GL was already covered in several
places, and this fills in the ones that were not:

  * macOS already ran ganesh-gl through CGL. That is why ganesh-gl.macos was
    the only committed golden set — under the rules #4575 introduced, an
    unseeded backend fails, so those goldens exist because macOS was rendering.
  * Android, iOS and Mac Catalyst already exercise the views layer against real
    GL surfaces: MemoryLeakTests.SKGLViewHandlerDoesNotLeak runs and passes on
    all three device legs.
  * Windows had no OpenGL implementation at all, and Linux had GLX loading and
    then killing the host. Both are the low-level GRContext.CreateGl path the
    desktop console suite covers, and both are what this fixes.

The five container legs and Nano Server keep their opt-out, and the comment now
reads as a decision rather than a pending item: those images exist to prove
SkiaSharp works with the bare minimum installed, so giving them an X server and
Mesa would defeat their purpose.

Two gaps this does not close, both pre-existing: SKGLView on WinUI has no device
leg in this pipeline, and the Blazor SKGLView/WebGL test lives in
SkiaSharp.Tests.Integration, which this pipeline does not run. ganesh-gl is not
required on Browser at all; WASM's GPU backend is graphite-dawn, still opted out
because the headless browser exposes no adapter. #4591 tracks the remainder.

Every problem below was reproduced and measured before it was fixed: Mesa on
Windows, and Ubuntu under WSL with Xvfb and GLX for Linux, which reproduced the
CI crash faithfully enough to bisect it.

~~ Windows: no OpenGL at all ~~

The agents have no display driver carrying an OpenGL ICD, so opengl32.dll
answers with the in-box generic implementation: OpenGL 1.1, no
WGL_ARB_pixel_format, no WGL_ARB_pbuffer. WglContext cannot come up on that, and
Ganesh needs 3.0+ regardless.

scripts/infra/native/windows/install-mesa-gl.ps1 provisions Mesa the way Mesa
documents for machines with no OpenGL driver [0]: libgallium_wgl.dll becomes
System32\mesadrv.dll and SysWOW64\mesadrv.dll, registered under
OpenGLDrivers\MSOGL. It follows install-vulkan-icd.ps1 — pinned version, SHA-256
pin, both bitnesses, fatal on any failure — and checks what provisioning is
responsible for and no more: the driver is where opengl32 will look for it, its
version resource matches the version just pinned rather than a leftover from an
earlier run, and the registration reads back. Proving it renders belongs to the
suite, and GRContextTest.CreateDefaultContextIsValid already does that on every
leg where the policy requires ganesh-gl.

~~ Windows: SetPixelFormat and wglSetPixelFormat are not interchangeable ~~

With Mesa registered, provisioning still failed, and the diagnostics named it:

    mesadrv=C:\Windows\SYSTEM32\mesadrv.dll; pixelFormats=1332; chosenFormat=121
    FAILED: wglCreateContext returned NULL (2000)

Mesa is loaded and serving its own 1332 pixel formats, and 2000 is
ERROR_INVALID_PIXEL_FORMAT. gdi32's ChoosePixelFormat reports Mesa's formats and
SetPixelFormat returns true, but Mesa's per-HDC state is only created by its own
wglSetPixelFormat, so wglCreateContext has nothing to look up.

The two APIs turn out to be exactly inverted, consistently per driver: a
hardware ICD is set up through GDI and refuses a context when the format was set
the other way, and Mesa is the reverse. So the Wgl bootstrap tries GDI first —
every real driver, and every developer running these tests locally — and falls
back only when the context actually fails. A pixel format can be set once per
DC and the class is CS_OWNDC, so the retry needs a fresh window; the first is
destroyed before it is replaced.

~~ Linux: the crash was one test, not a race ~~

#4590 attributed the exit-7 host crash to nine test classes creating GLX
contexts concurrently. That diagnosis was wrong. The crash reproduces with the
suite serialized onto a single thread, and a trace shows every context created,
used and destroyed on that one thread.

The real cause is GRGlInterfaceTest.AssembleInterfaceIsValid, which resolved
Skia's proc addresses with glXGetProcAddress alone. Under GLVND — the
vendor-neutral libGL every current distro ships — that returns a dispatch stub
for any name at all; glTotallyNotARealFunction comes back non-null. Skia was
handed pointers that are not functions and walked off the end of the extension
list in GrGLExtensions::init. It now resolves through dlsym on libGL.so.1,
exactly as the macOS branch already did.

The death point only looked random because the run order varied.

~~ Both: llvmpipe cannot compile one of Skia's shaders ~~

Mesa's LLVM shader JIT segfaults inside LLVMTypeOf, under
GrGLOpsRenderPass::onDraw, building the fragment shader Skia generates for a
runtime blender. Reproduced on two independent stacks — Mesa 25.2 with LLVM 20
on Linux, and 26.1 with LLVM 22 on Windows — so both legs pin softpipe, the
non-JIT gallium rasterizer, which runs the identical tests green on both and
caps at GL 3.3, well past the 3.0 Ganesh needs. Filed as #4604.

Ruled out along the way, so nobody re-treads it: thread parallelism
(--parallel none --max-threads 1 crashes identically), managed thread stack size
at 2, 16 and 64 MB, LP_NUM_THREADS of 0 and 1, file-descriptor limits at 256,
1024 and 65536, and GL context churn — 400 create/use/destroy cycles are fine.

~~ Supporting changes ~~

  * every class that creates a GPU context joins the existing
    GpuRenderingCollection, mirroring VulkanGpuRenderingCollection. This is what
    #4590 and #4591 asked for; it was not the crash fix, but concurrent GPU
    context use is a real hazard worth closing. Where only a nested class does
    GPU work (SKBlenderTest, SKRuntimeEffectTest) only that class joins, so its
    raster sibling stays parallel — roughly 300 of 6100 tests are serialized
  * GlxContext shares one X11 connection for the process instead of opening and
    closing one per test. That is the leak XCloseDisplay was added for in #4575,
    fixed at the source: one connection instead of 128 and counting, and no
    closing a display while a context minted from it is still current
  * XInitThreads runs before any other Xlib call
  * ganesh-gl.windows and ganesh-gl.linux goldens are harvested and committed,
    since a backend that renders for the first time is unseeded and fails until
    they exist

~~ Result ~~

  * Windows (.NET Framework, x64) — 7415 tests, 0 failed, 23 skipped
  * Windows (.NET Framework, x86) — 7415 tests, 0 failed, 25 skipped
  * Windows (.NET Core)           — 6117 tests, 0 failed, 31 skipped
  * Linux                         — 6117 tests, 0 failed, 34 skipped

Linux previously exited 7 and published nothing at all. Measured locally, GL on
versus off is 6079 against 5910 passing: 169 tests that had never run once.

[0]: https://docs.mesa3d.org/drivers/llvmpipe.html#windows

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@mattleibow mattleibow added this to the 4.152.0-preview.1 milestone Aug 8, 2026
mattleibow added a commit that referenced this pull request Oct 31, 2026
[Skia] Sync m150 region and texture fixes (#5543)

Context: mono/skia#417
Context: #5546
Context: #4605

Update release/4.150.x to native merge
95bed8d58d692e6268f05682f0a4926f41aaf5fb, incorporating chrome/m150 through
f05f0f5f8f3a2cbbcc3f48d887695398bf2584cf. Keep release-line versions and
managed API declarations unchanged.

~~ Prevent conic-region buffer underallocation ~~

Bring in the upstream correction for SkRegion::setPath allocating too few
scanline transitions for subdivided conics. Budget edges using the shared
conic subdivision limit and reject accumulation overflow before building
the region, preventing a heap out-of-bounds write.

~~ Correct BGRA-as-RGBx upload capabilities ~~

Disable the RGBA upload format for BGRA textures interpreted as RGBx,
matching the existing BGRA-as-RGBA restriction. The old capability was
permitted by desktop GL but unsupported by GLES.

~~ Preserve texture subset boundaries under nearest filtering ~~

Retain shader clamps when magnification or fractional mappings can round
sample coordinates into neighboring texels. Keep the touching-edge fast
path for one-to-one integer-relative mappings, including rotations and
flips, and account for sampling precision at approximate-proxy boundaries.

~~ Make Linux GL validation execute reliably ~~

Backport the Linux test-harness subset of #4605 rather than skipping
Ganesh GL on the validation host. Load versioned X11/GL libraries,
initialize Xlib threading, share the process GLX display and place the
affected GPU test classes in a nonparallel collection.

Resolve assembled-interface symbols from libGL.so.1 rather than relying
on glXGetProcAddress: GLVND can return non-null dispatch stubs for names
that are not real functions. Serialization is a separate context-lifetime
precaution, not the correction for that symbol-resolution failure.

The workflow reports that Ganesh GL executed with Mesa softpipe during
the unfiltered release-branch console solution run.

~~ Accept installed Linux emoji fallback families ~~

Allow Symbola, Noto Emoji and Noto Color Emoji on glibc Linux hosts, and
Noto Color Emoji on non-glibc hosts, instead of requiring Symbola for
every Linux environment. This changes test expectations, not product font
selection.

~~ Record the completed native merge consistently ~~

Update both externals/skia and the mono/skia Component Governance hash to
the actual native merge, and record the incorporated upstream commit.
Verify the two-parent merge directly contains reviewed head
49a7ef98174b2aa4d98de24e17d04d6b3018e9a9 and has the identical source tree.

The sync workflow reports a passing Linux x64 source build, unchanged
generated declarations, managed build and unfiltered console solution:
5,748 core tests, one singleton test, two Vulkan-host tests and two
Direct3D-host tests passed. Platform-policy skips remain; Linux execution
does not establish Windows Vulkan, Direct3D or Metal runtime coverage.

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Concurrent GLX context creation crashes the Linux test host (exit 7, no results published)

2 participants