Run render tests against llvmpipe/lavapipe MESA rasterizers#21790
Conversation
|
You can test this PR using the following package version. |
There was a problem hiding this comment.
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. |
|
You can test this PR using the following package version. |
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:
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).