drm-dotnet
2.4.134
dotnet add package drm-dotnet --version 2.4.134
NuGet\Install-Package drm-dotnet -Version 2.4.134
<PackageReference Include="drm-dotnet" Version="2.4.134" />
<PackageVersion Include="drm-dotnet" Version="2.4.134" />
<PackageReference Include="drm-dotnet" />
paket add drm-dotnet --version 2.4.134
#r "nuget: drm-dotnet, 2.4.134"
#:package drm-dotnet@2.4.134
#addin nuget:?package=drm-dotnet&version=2.4.134
#tool nuget:?package=drm-dotnet&version=2.4.134
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 | Versions 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. |
-
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 |