Skip to content

Commit 5b77a45

Browse files
committed
[docs] Adding DirectX target usage doc
This document is a work in progress to begin fleshing out documentation for the DirectX backend and related changes in the LLVM project. This is not intended to be exhaustive or complete, it is intended as a starting point so taht future changes have a place for documentation to land. Differential Revision: https://reviews.llvm.org/D127640
1 parent 0dd243f commit 5b77a45

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

llvm/docs/DirectXUsage.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
=================================
2+
User Guide for the DirectX Target
3+
=================================
4+
5+
.. warning::
6+
Disclaimer: The DirectX backend is experimental and under active development.
7+
It is not yet feature complete or ready to be used outside of experimental or
8+
demonstration contexts.
9+
10+
.. contents::
11+
:local:
12+
13+
.. toctree::
14+
:hidden:
15+
16+
Introduction
17+
============
18+
19+
The DirectX target implements the DirectX programmability interfaces. These
20+
interfaces are documented in the `DirectX Specifications. <https://github.com/Microsoft/DirectX-Specs>`_
21+
22+
Initially the backend is aimed at supporting DirectX 12, and support for DirectX
23+
11 is planned at a later date.
24+
25+
The DirectX backend is currently experimental and is not shipped with any
26+
release builds of LLVM tools. To enable building the DirectX backend locally add
27+
``DirectX`` to the ``LLVM_EXPERIMENTAL_TARGETS_TO_BUILD`` CMake option. For more
28+
information on building LLVM see the :doc:`CMake` documentation.
29+
30+
.. _dx-target-triples:
31+
32+
Target Triples
33+
==============
34+
35+
At present the DirectX target only supports the ``dxil`` architecture, which
36+
generates code for the
37+
`DirectX Intermediate Language. <https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst>`_
38+
39+
In addition to target architecture, the DirectX backend also needs to know the
40+
target runtime version and pipeline stage. These are expressed using the OS and
41+
Environment triple component.
42+
43+
Presently the DirectX backend requires targeting the ``shadermodel`` OS, and
44+
supports versions 6.0+ (at time of writing the latest announced version is 6.7).
45+
46+
.. table:: DirectX Environments
47+
48+
================== ========================================================
49+
Environment Description
50+
================== ========================================================
51+
``pixel`` Pixel shader
52+
``vertex`` Vertex shader
53+
``geometry`` Geometry shader
54+
``hull`` Hull shader (tesselation)
55+
``domain`` Domain shader (tesselation)
56+
``compute`` Compute kernel
57+
``library`` Linkable ``dxil`` library
58+
``raygeneration`` Ray generation (ray tracing)
59+
``intersection`` Ray intersection (ray tracing)
60+
``anyhit`` Ray any collision (ray tracing)
61+
``closesthit`` Ray closest collision (ray tracing)
62+
``miss`` Ray miss (ray tracing)
63+
``callable`` Callable shader (ray tracing)
64+
``mesh`` Mesh shader
65+
``amplification`` Amplification shader
66+
================== ========================================================
67+
68+
Output Binaries
69+
===============
70+
71+
The DirectX runtime APIs read a file format based on the
72+
`DirectX Specification. <https://github.com/Microsoft/DirectX-Specs>`_. In
73+
different codebases the file format is referred to by different names
74+
(specifically ``DXBC`` and ``DXILContainer``). Since the format is used to store
75+
both ``DXBC`` and ``DXIL`` outputs, and the ultimate goal is to support both as
76+
code generation targets in LLVM, the LLVM codebase uses a more neutral name,
77+
``DXContainer``.
78+
79+
The ``DXContainer`` format is sparsely documented in the functional
80+
specification, but a reference implementation exists in the
81+
`DirectXShaderCompiler. <https://github.com/microsoft/DirectXShaderCompiler>`_.
82+
83+
Support for generating ``DXContainer`` files in LLVM, is being added to the LLVM
84+
MC layer for object streamers and writers, and to the Object and ObjectYAML
85+
libraries for testing and object file tooling.
86+
87+
For ``dxil`` targeting, bitcode emission into ``DXContainer`` files follows a
88+
similar model to the ``-fembed-bitcode`` flag supported by clang for other
89+
targets.

llvm/docs/UserGuides.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ intermediate LLVM representation.
2929
CoverageMappingFormat
3030
CycleTerminology
3131
DebuggingJITedCode
32+
DirectXUsage
3233
Docker
3334
ExtendingLLVM
3435
GoldPlugin
@@ -247,3 +248,7 @@ Additional Topics
247248

248249
:doc:`SPIRVUsage`
249250
This document describes using the SPIR-V target to compile GPU kernels.
251+
252+
:doc:`DirectXUsage`
253+
This document describes using the DirectX target to compile GPU code for the
254+
DirectX runtime.

0 commit comments

Comments
 (0)