liftoff-dotnet 0.5.1

dotnet add package liftoff-dotnet --version 0.5.1
                    
NuGet\Install-Package liftoff-dotnet -Version 0.5.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="liftoff-dotnet" Version="0.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="liftoff-dotnet" Version="0.5.1" />
                    
Directory.Packages.props
<PackageReference Include="liftoff-dotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add liftoff-dotnet --version 0.5.1
                    
#r "nuget: liftoff-dotnet, 0.5.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package liftoff-dotnet@0.5.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=liftoff-dotnet&version=0.5.1
                    
Install as a Cake Addin
#tool nuget:?package=liftoff-dotnet&version=0.5.1
                    
Install as a Cake Tool

liftoff-dotnet

liftoff-dotnet are .NET bindings for libliftoff.

Usage

using Drm;
using Liftoff;

using var drm = DrmDevice.Open("/dev/dri/card0");
drm.SetClientCapability(DrmClientCapability.Atomic);

using var device = LiftoffDevice.Create(drm);
device.RegisterAllPlanes();

using var output = device.CreateOutput(crtcId);
using var layer = output.CreateLayer();
layer.SetFramebuffer(framebuffer);
layer.SetCrtcRect(0, 0, 1920, 1080);
layer.SetSourceRect(0, 0, 1920, 1080);
layer.SetZPos(1);

using var request = new DrmAtomicRequest();
output.Apply(request, DrmAtomicCommitFlags.Nonblock);
drm.AtomicCommit(request, DrmAtomicCommitFlags.Nonblock);

Console.WriteLine(layer.Plane is { } plane
    ? $"Scanned out directly on plane {plane.Id}"
    : "Needs composition");
layer.SetProperty(LiftoffProperty.SrcW, LiftoffLayer.ToFixed16(1.5));  // raw, 16.16 fixed point
layer.SetProperty("IN_FENCE_FD", (ulong)fenceFd);                      // any other plane property
layer.UnsetProperty("IN_FENCE_FD");
output.SetCompositionLayer(compositionLayer);
output.Apply(request, flags);

foreach (var layer in output.Layers)
{
    if (layer.NeedsComposition)
    {
        BlendIntoCompositionBuffer(layer);
    }
}
if (!output.TryApply(request, flags, out int errno))
{
    FallBackToFullComposition();
}
LiftoffLog.Priority = LiftoffLogPriority.Debug;
LiftoffLog.SetHandler((priority, message) => Console.Error.WriteLine($"[{priority}] {message}"));
using Liftoff.Native;

unsafe
{
    var plane = Libliftoff.liftoff_layer_get_plane((liftoff_layer*)layer.Handle);
    uint id = Libliftoff.liftoff_plane_get_id(plane);
}

Testing

sudo modprobe vkms
sudo chmod a+rw /dev/dri/card*   # or run as a user with access
dotnet test

Samples

dotnet run --project samples/Liftoff.NET.Sample -- /dev/dri/card0
dotnet run --project samples/Liftoff.NET.CompositorSample -- /dev/dri/card0 -l6
dotnet run --project samples/Liftoff.NET.DynamicSample -- /dev/dri/card0

Regenerating the bindings

src/Liftoff.NET/Native/Generated is checked-in ClangSharp output; regenerate it only when bumping the external/libliftoff submodule.

git submodule update --init
dotnet tool restore
sh eng/generate.sh
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.1 129 9/5/2026
0.5.0 500 7/31/2026