Skip to main content

ironaccelerator_dx12/
lib.rs

1//! # `ironaccelerator-dx12`
2//!
3//! Direct3D 12 backend. Covers the one GPU API on Windows that no other
4//! IronAccelerator backend reaches: NVIDIA, AMD, Intel, and Qualcomm parts all
5//! expose D3D12 on Windows whether or not a Vulkan ICD is installed, and on
6//! Arm-based Windows devices it is frequently the only path.
7//!
8//! Scope is the driver line, as everywhere else in this workspace: enumerate
9//! adapters, probe feature support, report capability bits, allocate buffers,
10//! submit work, and synchronise. [`compute::Context`] covers the submission
11//! side — a COMPUTE queue, allocator, command list, and fence, plus buffers in
12//! the three standard heaps and dispatch of a compute pipeline.
13//!
14//! It does **not** compile shaders. Bring DXIL, the same way the CUDA backend
15//! takes PTX:
16//!
17//! ```text
18//! dxc -T cs_6_0 -E main kernel.hlsl -Fo kernel.dxil
19//! ```
20//!
21//! Note that `dxc` only signs its output when `dxil.dll` sits beside it, and
22//! D3D12 rejects unsigned DXIL. The Windows SDK ships that pair; the Vulkan
23//! SDK's `dxc` does not.
24//!
25//! `d3d12.dll` and `dxgi.dll` are resolved with `libloading`, never linked, so
26//! the crate builds on any target that has dynamic loading — Windows, Linux,
27//! macOS. Where the libraries are absent, which is every non-Windows host and
28//! Windows installs predating D3D12, [`Backend::is_available`] reports `false`
29//! and enumeration returns empty. `wasm32` is the exception: it has no dynamic
30//! loader, so this crate does not build there. Only `ironaccelerator-core` and
31//! `ironaccelerator-webgpu` target WASM.
32//!
33//! [`Backend::is_available`]: ironaccelerator_core::Backend::is_available
34
35#![warn(missing_docs)]
36pub mod backend;
37pub mod compute;
38pub mod drv;
39
40pub use backend::{Dx12Backend, DX12_BACKEND};
41pub use compute::{BoundPipeline, Buffer, CommandQueue, Context, PipelineState, RootSignature};
42pub use drv::{Device, EnumeratedAdapter};
43
44/// Register the D3D12 backend into the given registry. Idempotent.
45pub fn register(reg: &mut ironaccelerator_core::BackendRegistry) {
46    reg.register(&DX12_BACKEND);
47}