Skip to content
atcarter714Public

About

A modern DirectX SDK for C# and .NET, featuring Direct3D 12, GPU compute and DirectML integration with explicit GPU resource lifetime management.

Topics

Resources

Stars

18 stars

Watchers

1 watching

Forks

Latest commit

 

History

187 Commits

Folders and files

Repository files navigation

DXSharp

Direct3D 12, GPU compute, and DirectML for C# and .NET 10/11.

DXSharp exposes D3D12 devices, queues, resources, pipelines, and swap chains through typed .NET APIs. Use it to build a renderer, an engine, a graphics tool, or a GPU compute application with explicit control over command recording and resource lifetimes.

DXSharp logo

Samples · Tutorials · SDK qualification · Support matrix · Preview release · Publishing · Parity roadmap · MIT license

Start here

The current SDK is a preview for Windows x64. The repository pins the .NET 11 SDK for building both target frameworks in global.json and includes the Agility SDK, DXC, and optional DirectML runtime through package dependencies. Use Windows Graphics Tools for debug-layer validation. The --warp examples use Microsoft's software adapter.

git clone https://github.com/atcarter714/DXSharp.git
cd DXSharp
dotnet run --project samples/ModernTriangle -c Debug -- --warp --frames=4
dotnet run --project samples/ModernCompute -c Debug -- --warp --directml --gemm

The first command presents four frames and exits. The second verifies GPU compute readback and DirectML tensor addition and matrix inference. For a clean package consumer, start with Create your first DXSharp application.

Architecture

Package Responsibility
DXSharp.Native Public generated DirectX graphics, audio, input, DXC, and DirectML interfaces
DXSharp.Assets Static glTF/GLB models, materials, transforms, and decoded textures
DXSharp.Core D3D12, DXGI, DXC, and generated COM interop
DXSharp.Framework.Desktop WinForms presentation loop, swap-chain resize, and frame-slot retirement
DXSharp.DirectML Device and operator ownership, tensor binding, and DirectML execution
DXSharp, DXSharp.Framework, DXSharp.Dxc Compatibility packages for the original RCW-based SDK

The modern API uses public CsWin32 declarations from DXSharp.Native and .NET source-generated COM projections. API coverage records the pinned metadata coverage and remaining qualification. Managed owners release their native references deterministically. A command list takes its own references to the objects it records, and the queue holds them through fence completion. This lets applications give resources explicit lifetimes even when work is still in flight.

DXC returns owned compilation output and diagnostics. The desktop host supplies a small presentation loop while applications retain control of render and compute commands. The SDK architecture explains the binding, ownership and package boundaries, and the next rendering and tooling slices. See interop qualification for the native validation matrix.

Build and qualification

From an x64 Visual Studio Developer PowerShell with the C++ build tools and Windows SDK installed, run:

./build.ps1 -Configuration Release
./build/VerifySamples.ps1

The build uses locked dependencies, runs the Windows test gate and a native COM fixture, then packs and validates a fresh consumer. Windows CI also runs WARP graphics and numerical workloads. The native interop fixture runs with JIT and NativeAOT on Windows and Linux x64. The release checklist tracks hardware validation and remaining API coverage. See Azure Pipelines for the CI definition and artifact retention.

For an IDE build, open DXSharp.sln from the checkout root and restore with dotnet restore DXSharp.sln --locked-mode. Compatibility wrappers and Core use different CsWin32 and Win32 metadata versions. If an IDE reports missing D3D12 entry points or COM argument mismatches after switching branches, close the IDE and try the following from the checkout root.

dotnet restore DXSharp.sln --locked-mode --force
dotnet build DXSharp.sln -c Debug --no-restore -m:1

If the errors persist, compare the commit and build output from a fresh worktree. Start with the first error in DXSharp. Missing reference DLLs in dependent projects follow a failed build of that assembly.

For shader capability checks, run ModernCompute with --latest-shader-model. It checks the bundled compiler's Shader Model 6.9 target and dispatches at a profile supported by both the compiler and the selected device. The shader and fleet roadmap covers preview Shader Model support and the flagship sample.

History

Aaron Carter started DXSharp to prove that C# could support a full Direct3D 12 workflow with the feel of SlimDX and SharpDX. The original project brought up a broad set of DirectX bindings, examples, and build tools. Its hand-maintained COM wrappers also showed where ownership and interface projection needed to be simpler. The .NET 10 SDK builds on that experience with generated interop, explicit lifetimes, and repeatable GPU checks.

For contributions, open an issue or a pull request with a small reproduction and the adapter, runtime, and validation details. DXSharp is MIT licensed.

About

A modern DirectX SDK for C# and .NET, featuring Direct3D 12, GPU compute and DirectML integration with explicit GPU resource lifetime management.

Topics

Resources

Stars

18 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages