drm-dotnet 2.4.134

dotnet add package drm-dotnet --version 2.4.134
                    
NuGet\Install-Package drm-dotnet -Version 2.4.134
                    
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="drm-dotnet" Version="2.4.134" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="drm-dotnet" Version="2.4.134" />
                    
Directory.Packages.props
<PackageReference Include="drm-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 drm-dotnet --version 2.4.134
                    
#r "nuget: drm-dotnet, 2.4.134"
                    
#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 drm-dotnet@2.4.134
                    
#: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=drm-dotnet&version=2.4.134
                    
Install as a Cake Addin
#tool nuget:?package=drm-dotnet&version=2.4.134
                    
Install as a Cake Tool

drm-dotnet

drm-dotnet are .NET bindings for libdrm, the userspace library for the Linux Direct Rendering Manager.

Usage

using Drm;

using var device = DrmDevice.Open("/dev/dri/card0");
Console.WriteLine($"Driver: {device.GetVersion()}");

var resources = device.GetResources();
var connector = resources.ConnectorIds
    .Select(id => device.GetConnector(id))
    .First(c => c.Status == DrmConnectionStatus.Connected && c.Modes.Count > 0);
var mode = connector.Modes.First(m => m.IsPreferred);

using var buffer = device.CreateDumbBuffer(mode.HorizontalDisplay, mode.VerticalDisplay);
buffer.AsSpan().Fill(0xFF); // draw something

using var framebuffer = device.AddFramebuffer(buffer);
device.SetCrtc(resources.CrtcIds[0], framebuffer.Id, 0, 0, [connector.ConnectorId], mode);
using Drm.Native;

unsafe
{
    var res = Libdrm.drmModeGetResources(fd);
    // ...
    Libdrm.drmModeFreeResources(res);
}

You can get a seat from seatd, which is bound with seatd-dotnet.

using var seatDevice = seat.OpenDevice("/dev/dri/card0");
using var drm = DrmDevice.FromFd(seatDevice.Fd, ownsFd: false);

Testing

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

Sample

samples/Drm.NET.Sample picks the first connected connector, draws a gradient into a dumb buffer, scans it out for a few seconds and restores the previous state. Run it from a VT (or against vkms), not from inside a desktop session:

dotnet run --project samples/Drm.NET.Sample -- /dev/dri/card0 5

Regenerating the bindings

git submodule update --init
dotnet tool restore
sh eng/generate.sh

Requires a system clang for its builtin-header resource directory.

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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on drm-dotnet:

Package Downloads
liftoff-dotnet

.NET bindings for libliftoff, the KMS plane offloading library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.134 637 7/25/2026