Skip to content

terrymacdonald/ADLXWrapper

Repository files navigation

ADLXWrapper

Facade-first C# access to the AMD ADLX SDK, with native bindings available for low-level control.

Quick links

  • Facade guide (recommended): ADLXWrapper/README.md
  • Native guide: ADLXWrapper/README.Native.md
  • Samples (each offers Facade and Native menu options): Samples/
  • API docs (local HTML): APIDocs/_site/index.html
  • Native tests: ADLXWrapper.NativeTests/ (raw cs_generated APIs only)
  • Facade tests: ADLXWrapper.FacadeTests/ (helper/facade APIs)

Why facade-first?

Facades remove all pointer and memory management and expose strongly-typed helpers (ADLXSystemServicesHelper, ADLXDisplayServicesHelper, etc.) that wrap the highest supported ADLX interface version, handle AddRef/Release, and return *Dto objects for easy serialization (e.g. to JSON). No unsafe code is required. Use the native layer only when you need direct vtable access or to mirror ADLX SDK samples verbatim.

Getting started

  1. Prepare ADLX headers (once):
./prepare_adlx.ps1
  1. Build everything:
./build_adlx.ps1
  1. Run tests (hardware-aware; native first):
./test_adlx.ps1
dotnet test ADLXWrapper.FacadeTests/ADLXWrapper.FacadeTests.csproj --verbosity normal
  1. Explore samples: dotnet run --project Samples/DisplaySample/DisplaySample.csproj (menus show both Facade and Native flows).

Facade quick start

using ADLXWrapper;

using var adlx = ADLXApiHelper.Initialize();
using var sys = adlx.GetSystemServices();

// Enumerate displays — fully pointer-free, no unsafe required
var displays = sys.EnumerateDisplays();
foreach (var display in displays)
using (display)
{
    Console.WriteLine($"{display.Name} {display.NativeResolutionWidth}x{display.NativeResolutionHeight} @ {display.RefreshRate:F2} Hz");
    var vsr = display.GetVirtualSuperResolutionState();
    if (vsr.supported && !vsr.enabled) display.SetVirtualSuperResolution(true);
}

// GPU identity — EnumerateGPUs() returns IEnumerable<GpuDto> (plain DTOs, no disposal needed)
foreach (var gpu in sys.EnumerateGPUs())
    Console.WriteLine($"{gpu.Name} ({gpu.VRAMType}, {gpu.TotalVRAM} MB, UniqueId={gpu.UniqueId})");

// GPU-specific features use int gpuUniqueId — no pointers or handles
using var perf = sys.GetPerformanceMonitoringServices();
foreach (var gpu in sys.EnumerateGPUs())
{
    if (perf.TryGetCurrentGpuMetrics(gpu.UniqueId, out var m))
        Console.WriteLine($"{gpu.Name}: {m.Temperature:F1}°C, {m.Usage:F1}% usage, {m.ClockSpeed} MHz");
}

More in ADLXWrapper/README.md (per-feature examples: Display, Desktop, GPU identity, Perf, 3D settings, Tuning, Power, Color, Multimedia).

DTO naming

All data objects returned by the Facade layer follow the *Dto suffix convention (e.g. GpuDto, DisplayDto, GammaDto, GpuMetricsSnapshotDto). DTOs are readonly structs with init properties and [JsonConstructor] support for round-trip JSON serialisation.

Using the release ZIP

  • Build with ./create_adlx_release_zip.ps1 or download from GitHub Releases (artifact name adlxwrapper-<version>-Release.zip).
  • Contents: ADLXWrapper.dll, ADLXWrapper.pdb, ADLXWrapper.deps.json, ADLXWrapper.xml, top-level README/license; optional sources if built with -IncludeSources.
  • Reference in your project:
<ItemGroup>
  <Reference Include="ADLXWrapper">
    <HintPath>packages\\adlxwrapper\\ADLXWrapper.dll</HintPath>
  </Reference>
</ItemGroup>

The ADLX runtime ships with AMD drivers; no extra native payload is redistributed here.

Native path

If you need vtable-level access, see ADLXWrapper/README.Native.md for initialization patterns, lifetime rules, and raw pointer examples that mirror the ADLX SDK samples. Native tests (ADLXWrapper.NativeTests) demonstrate direct usage of the generated interfaces in ADLXWrapper/cs_generated/.

Project structure

ADLXWrapper/
|-- ADLX/                     # ADLX SDK headers (fetched by prepare script)
|-- ADLXWrapper/              # Library sources (helpers + cs_generated bindings)
|-- ADLXWrapper.NativeTests/  # Native xUnit tests
|-- ADLXWrapper.FacadeTests/  # Facade xUnit tests
|-- Samples/                  # Console samples (Facade and Native menus)
|-- APIDocs/_site/            # Generated API HTML docs
|-- scripts/                  # Prepare/build/test/release scripts

Need more? Start with ADLXWrapper/README.md for the Facade walkthrough, then branch to the Native guide if you need raw access. APIDocs in APIDocs/_site/index.html provide full API surface details.

About

A modern, high-performance C# wrapper for the AMD Display Library Extensions (ADLX) SDK, providing easy access to AMD GPU features and settings.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages