Skip to content

Run render tests against llvmpipe/lavapipe MESA rasterizers#21790

Merged
MrJul merged 4 commits into
mainfrom
feature/mesa-render-tests
Jul 21, 2026
Merged

Run render tests against llvmpipe/lavapipe MESA rasterizers#21790
MrJul merged 4 commits into
mainfrom
feature/mesa-render-tests

Conversation

@kekekeks

Copy link
Copy Markdown
Member

With this PR the tests are run against MESA's llvmpipe/lavapipe rasterizers compiled into a standalone library (not the system one, so results should be more or less reproducible).

There are some changes in vulkan/opengl support libs to make it to work:

  1. optional support window-less egl context
  2. optional support for swapchain-less/surface-less vulkan instances/devices.

Direct readback from GPU API is used to make sure that we don't need to expose/use backend-provided snapshot mechanisms.

It somewhat uncovered gpu state teardown problems that will be re-addressed later (see vulkan dispose diff + gpu teardown code in test helper).

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067502-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@kekekeks
kekekeks requested a review from Copilot July 17, 2026 16:19
@kekekeks
kekekeks marked this pull request as ready for review July 17, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the Skia render test suite runnable against deterministic MESA software rasterizers (llvmpipe for GL / lavapipe for Vulkan) by introducing offscreen GPU render paths with direct readback, and by loosening platform requirements around window/surface/swapchain support for those offscreen scenarios.

Changes:

  • Add a bundled MESA software-renderer dependency and wire render tests to optionally run additional GL/Vulkan GPU passes.
  • Add offscreen GL (FBO) and Vulkan (VkImage) render-target surfaces that read pixels back into a writable bitmap for image comparison.
  • Extend EGL and Vulkan initialization/device creation to support surfaceless EGL and surface/swapchain-less Vulkan instances/devices.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj Adds the MESA software-renderer NuGet dependency to the render test project.
tests/Avalonia.RenderTests/TestRenderHelper.cs Refactors render helper and adds GPU readback-based composited rendering + backend teardown.
tests/Avalonia.RenderTests/TestBase.cs Produces and compares additional Mesa GL/Vulkan outputs with optional error tolerance/skip controls.
tests/Avalonia.RenderTests/Shapes/PathTests.cs Relaxes allowed error for GPU outputs on a widened-path case.
tests/Avalonia.RenderTests/Shapes/EllipseTests.cs Relaxes allowed error for GPU outputs on aliased circle rendering.
tests/Avalonia.RenderTests/Mesa/VulkanReadbackPlatformSurface.cs New offscreen Vulkan render target that copies VkImage contents to CPU for comparisons.
tests/Avalonia.RenderTests/Mesa/MesaSoftwareRenderer.cs New helper to create llvmpipe/lavapipe-backed platform graphics from the bundled native library.
tests/Avalonia.RenderTests/Mesa/FboReadbackGlPlatformSurface.cs New offscreen GL render target that reads FBO pixels back to CPU for comparisons.
tests/Avalonia.RenderTests/Media/VisualBrushTests.cs Relaxes allowed error for GPU outputs on a DPI-sensitive visual brush case.
tests/Avalonia.RenderTests/Media/DrawingContentTests.cs Skips Mesa GPU comparisons for custom-flow change rendering cases.
tests/Avalonia.RenderTests/Controls/CommandBarTests.cs Adds a slightly higher allowed error for GPU outputs for a themed command bar case.
tests/Avalonia.RenderTests/Controls/AdornerTests.cs Prevents duplicate adorner insertion across repeated attach/detach cycles during composited renders.
tests/Avalonia.RenderTests/Composition/DirectFbCompositionTests.cs Skips Mesa GPU comparisons for direct-framebuffer composition tests.
src/Skia/Avalonia.Skia/Gpu/Vulkan/VulkanSkiaGpu.cs Improves Vulkan Skia GPU disposal behavior and recognizes swapchain-less Vulkan render target surfaces.
src/Avalonia.Vulkan/VulkanOptions.cs Adds options to allow creating Vulkan instances/devices without surface/swapchain extensions.
src/Avalonia.Vulkan/VulkanContext.cs Supports creating a render target directly from an IVulkanRenderTargetPlatformSurface.
src/Avalonia.Vulkan/UnmanagedInterop/VulkanStructs.cs Adds Vulkan structs needed for image-to-buffer copy readback support.
src/Avalonia.Vulkan/UnmanagedInterop/VulkanInstanceApi.cs Marks surface-related instance procs as optional to support offscreen-only instances.
src/Avalonia.Vulkan/UnmanagedInterop/VulkanEnums.cs Adds VkBufferUsageFlags needed for readback buffer creation.
src/Avalonia.Vulkan/UnmanagedInterop/VulkanDeviceApi.cs Adds buffer/mapping/copy APIs and marks swapchain-related procs as optional.
src/Avalonia.Vulkan/IVulkanPlatformSurface.cs Introduces IVulkanRenderTargetPlatformSurface for swapchain-less Vulkan rendering surfaces.
src/Avalonia.Vulkan/Interop/VulkanInstance.cs Makes VK_KHR_surface enabling configurable via options.
src/Avalonia.Vulkan/Interop/VulkanDevice.Create.cs Makes VK_KHR_swapchain enabling configurable via options.
src/Avalonia.Vulkan/Avalonia.Vulkan.csproj Grants test assembly access to Vulkan internals used by the new readback surface.
src/Avalonia.OpenGL/GlInterface.cs Adds glReadPixels binding needed for FBO readback.
src/Avalonia.OpenGL/Egl/EglDisplayUtils.cs Allows probing EGL configs that only support PBuffer surfaces when requested.
src/Avalonia.OpenGL/Egl/EglDisplayOptions.cs Adds an option to allow PBuffer-only EGL configs (surfaceless EGL scenarios).
src/Avalonia.OpenGL/Egl/EglDisplay.cs Threads through the new EGL option to config selection.
src/Avalonia.OpenGL/Egl/EglConsts.cs Adds EGL_PLATFORM_SURFACELESS_MESA constant.
Directory.Packages.props Pins the unofficial.mesa.softwarerenderer package version.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067505-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@kekekeks
kekekeks requested a review from MrJul July 19, 2026 10:51
@MrJul MrJul added enhancement area-rendering area-infrastructure Issues related to CI/tooling infrastructur labels Jul 20, 2026

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit efaa926 Jul 21, 2026
12 checks passed
@MrJul
MrJul deleted the feature/mesa-render-tests branch July 21, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-infrastructure Issues related to CI/tooling infrastructur area-rendering enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants