This reference is for advanced integration work. Most app teams should stay on normal UseSkia() platform defaults and avoid direct graphics interop unless they must integrate native GPU surfaces.
Primary APIs:
IPlatformGraphicsIPlatformGraphicsContextIPlatformGraphicsWithFeaturesIPlatformGraphicsReadyStateFeatureIGlContext, GlInterface, GlVersionIGlPlatformSurface, IGlPlatformSurfaceRenderTarget, IGlPlatformSurfaceRenderingSessionIVulkanPlatformGraphicsContext, IVulkanDevice, IVulkanInstanceIVulkanRenderTarget, IVulkanRenderSessionVulkanOptions, VulkanInstanceCreationOptions, VulkanDeviceCreationOptionsLinuxFramebufferPlatformOptions, DrmOutputOptions, FbdevOutput, DrmCard, DrmResourcesReference source files:
src/Avalonia.Base/Platform/IPlatformGpu.cssrc/Avalonia.OpenGL/IGlContext.cssrc/Avalonia.OpenGL/GlInterface.cssrc/Avalonia.OpenGL/GlVersion.cssrc/Avalonia.OpenGL/Surfaces/*.cssrc/Avalonia.Vulkan/IVulkanDevice.cssrc/Avalonia.Vulkan/IVulkanRenderTarget.cssrc/Avalonia.Vulkan/VulkanOptions.cssrc/Linux/Avalonia.LinuxFramebuffer/*.cssrc/Linux/Avalonia.LinuxFramebuffer/Output/*.csIPlatformGraphics provides context creation and shared-context access.
using Avalonia;
using Avalonia.Platform;
IPlatformGraphics? TryGetPlatformGraphics()
{
return AvaloniaLocator.Current.GetService<IPlatformGraphics>();
}
IPlatformGraphicsContext defines:
IsLostEnsureCurrent()IOptionalFeatureProviderNotes:
[Unstable] in IPlatformGpu.cs.IGlContext extends IPlatformGraphicsContext and adds:
VersionGlInterfaceSampleCount, StencilSizeMakeCurrent()IsSharedWith(...)CreateSharedContext(...)GlInterface is a minimal Avalonia-facing OpenGL function loader (GetProcAddress, plus selected GL calls).
IGlPlatformSurface / IGlPlatformSurfaceRenderTarget / IGlPlatformSurfaceRenderingSession provide a render-target abstraction for GL-backed platform surfaces.
IVulkanPlatformGraphicsContext exposes:
Device (IVulkanDevice)Instance (IVulkanInstance)CreateRenderTarget(IEnumerable<object> surfaces)IVulkanRenderTarget.BeginDraw() returns IVulkanRenderSession with:
ScalingSizeIsYFlippedImageInfoIsRgbaVulkanOptions tuning surface:
VulkanInstanceCreationOptions (ApplicationName, VulkanVersion, InstanceExtensions, EnabledLayers, UseDebug)VulkanDeviceCreationOptions (DeviceExtensions, PreferDiscreteGpu, RequireComputeBit)CustomSharedDeviceLinux framebuffer stack exposes public options and backend types for embedded/kiosk scenarios:
LinuxFramebufferPlatformOptions (Fps, ShouldRenderOnUIThread)DrmOutputOptions (Scaling, Orientation, VideoMode, connector selection)FbdevOutputDrmCard, DrmResources, DrmConnector, DrmModeInfoThese are platform-specific and usually unsuitable for general desktop/mobile app deployments.
Configure advanced Vulkan options through AppBuilder.With<T>(...):
using Avalonia;
using Avalonia.Vulkan;
AppBuilder BuildAvaloniaApp()
{
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseSkia()
.With(new VulkanOptions
{
VulkanInstanceCreationOptions = new VulkanInstanceCreationOptions
{
ApplicationName = "MyApp",
UseDebug = false
},
VulkanDeviceCreationOptions = new VulkanDeviceCreationOptions
{
PreferDiscreteGpu = true
}
});
}
Keep this optional and behind environment/config flags when shipping across mixed hardware fleets.
IPlatformGraphics* is explicitly unstable; avoid exposing it in long-lived app-domain contracts.IsLost contexts and recreation flow.IPlatformGraphics may be absent for software or non-GPU backend scenarios.IPlatformGraphicsContext.IsLost and recreate resources/context.VulkanOptions.GlInterface.GetProcAddress(...)-aware capability checks before calling optional entry points./dev/fb* or /dev/dri/*), connector selection, and mode compatibility.