Official DirectX headers available under an open source license
This repository hosts the official Direct3D 12 headers. These headers are made available under the MIT license rather than the traditional Windows SDK license.
Additionally, this repository hosts several helpers for using these headers.
/: Build files are available here for quick integration. CMake is provided, and can be referenced either via
subdirectory()or after installation to a system location. Meson is also available for inclusion as a subproject/wrap.
/include/directx: These files are the core headers for using D3D12, plus d3dx12.h, which is a helper and does not cross the boundaries of the D3D12 API.
/include/wsl: These files are provided as a shim to be able to include the D3D12 headers from a Linux build environment, without requiring the rest of the Windows SDK.
/include/dxguids: This header allows an application to use
uuidof()consistently between Windows and WSL, instead of
/src/dxguids.cpp: This cpp file can be used as a replacement for linking against
dxguid.libon Windows, and as a convenient translation unit to define GUIDs without multiple definitions for WSL.
/test: Simple CMake/Meson projects for validating the headers can be included in a given environment
Note that these headers may conflict with the headers from the Windows SDK, depending on include ordering. These headers should be added to the include directory list before the SDK, and should be included before other graphics headers (e.g.
d3d11.h) from the Windows SDK. Otherwise, the corresponding header from the Windows SDK may be included first, and will define the include guards which prevents these headers from being used.
Note: WSL support is not intended for general purpose application development. At this time, the only recommended usage is for frameworks wishing to provide hardware acceleration for a Linux graphics/compute API in a WSL2 virtualization environment.
Note: WSL support is only available for 64-bit binaries.
The headers in the
/include/wsldirectory provide alternative definitions to macros and typedefs normally found in the Windows SDK. For the most part, they should be straightforward, but there are a couple to call attention to:
|Type|Reason| |---|---| |
ULONG|On 64-bit Windows, a
longis 4 bytes, but on Linux it is typically 8 bytes. The D3D12 ABI for WSL uses
longand therefore these should be 8 bytes.| |
WCSTR|On Windows, a
wchar_tis 2 bytes, but on Linux it is typically 4 bytes. The D3D12 ABI for WSL uses the native 4-byte
wchar_t, to enable applications and the runtime to use the system C library to perform string manipulation.|
Additionally, APIs taking
void*) for Win32 types should instead use
reinterpret_cast(fd)for an appropriate type of file descriptor. For
ID3D12Fence::SetEventOnCompletionthis should be an
eventfd, and for shared resources will be an opaque fd.
There are various ways to consume the headers in this project:
add_subdirectoryinto it. Use the resulting
DirectX-Guidstargets as a link dependency
find_packagefunctionality and will expose the same
dependencyto consume it.
Contributions for new mechanisms are welcome.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.