This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Перейти к файлу
Steve Urquhart 74e3256484
[SPIRV] Always provide original source to debug (#6085)
This PR improves the experience for debugging tools that consume SPIR-V
produced by passing in-memory strings to dxcompiler.dll. When dxc.exe is
used, OpSource and OpDebugSource are populated by reading original
source from the filesystem. dxcompiler.dll users instead find their
input string is preprocessed, which is confusing behavior.
Contrary to the leading comment in the code this change modifies,
debugging tools do not want preprocessed source. Such tools show and
allow editing of include files. If everything is pasted into a single
source string, finding what to edit is difficult. Editing the
preprocessed source has the additional complication that a user would
have to edit also the #line markers, which is hard to get right
manually. In the preprocessed source, all comments are lost, which makes
it hard to read the code. Finally in preprocessed source, all macros and
code under conditional compilation are lost. That will make it
impossible to modify those parts in an edit.

Co-authored-by: Steve Urquhart <stevur01@ntd.nintendo.com>
2024-02-02 10:19:49 -05:00
.github Bump tj-actions/changed-files from 39 to 41 in /.github/workflows (#6141) 2024-01-09 21:45:24 +00:00
autoconf Added e2k support (MCST Elbrus 2000) (#5222) 2023-09-11 14:09:48 -07:00
azure-pipelines Remove DXC.Release pipeline (#5073) 2023-03-01 17:56:34 -08:00
cmake Make clang-format happy (#6177) 2024-01-22 11:57:34 -08:00
docs [Validation] Add validation and tests for invalid system values in incompatible node launch type (#6108) 2024-01-24 12:45:19 -08:00
examples Clean up mistakes made when fixing copyright banners. 2017-01-25 14:36:50 -08:00
external Update submodules (#6237) 2024-02-02 10:07:08 -05:00
gcp-pipelines Enable lit by default. (#5133) 2023-06-05 10:35:24 -07:00
include [SPIRV] Always provide original source to debug (#6085) 2024-02-02 10:19:49 -05:00
lib [SM6.8] Add validation for sampleCmpBias/Grad. (#6204) 2024-01-27 00:20:43 +00:00
projects [ClangCL] Cleanup rest clang-cl warnings (#5847) 2023-10-16 19:40:51 +00:00
resources Generate new version for each DX Compiler build (#2200) 2019-06-28 15:16:34 -07:00
test [bug] Fix crash when lowering multi-dimension groupshared variable (#5895) 2023-10-23 11:00:36 -07:00
tools [SPIRV] Always provide original source to debug (#6085) 2024-02-02 10:19:49 -05:00
unittests [ClangCL] Fix warning for rest part except clang. (#5705) 2023-10-09 16:59:01 -04:00
utils Update version to 1.8.2403 (#6210) 2024-01-26 14:50:48 -08:00
.clang-format first commit 2016-12-28 11:52:27 -08:00
.clang-tidy first commit 2016-12-28 11:52:27 -08:00
.gitattributes Adding line ending settings to .gitattributes (#4026) 2021-10-20 20:58:43 -05:00
.gitignore Update build to Visual Studio 2022 (new default); remove VS 2017 support (#4726) 2022-10-17 18:49:35 -07:00
.gitmodules [lit][SPIRV] convert runCodeTest to lit and remove dependence on effcee (#6077) 2023-12-14 06:50:32 -08:00
CMakeLists.txt CMake dxc as subproject fixes (#6050) 2023-11-22 14:33:09 -05:00
CMakeSettings.json [BUILD] add clang-cl to CMakeSettings (#5596) 2023-08-28 20:13:06 +00:00
CONTRIBUTING.md [Docs] Update contributing doc for clang-format (#5873) 2023-10-16 22:23:53 +00:00
LICENSE.TXT Inline sub-licenses into root license file (#5569) 2023-08-21 10:05:09 -04:00
LLVMBuild.txt Revert license text in banner comments to original llvm verbage (#33) 2017-01-24 17:54:00 -08:00
README.md Remove AppVeyor (#6176) 2024-01-22 19:12:32 +00:00
SECURITY.md Adding Microsoft SECURITY.MD (#4464) 2022-05-19 11:49:07 -07:00
ThirdPartyNotices.txt Add heading text for ThirdPartyNotices.txt 2017-02-24 16:30:31 -08:00
azure-pipelines.yml Run CI builds only on main and release branches (#6026) 2023-11-16 03:44:45 +00:00

README.md

DirectX Shader Compiler

The DirectX Shader Compiler project includes a compiler and related tools used to compile High-Level Shader Language (HLSL) programs into DirectX Intermediate Language (DXIL) representation. Applications that make use of DirectX for graphics, games, and computation can use it to generate shader programs.

For more information, see the Wiki.

Visit the DirectX Landing Page for more resources for DirectX developers.

Features and Goals

The starting point of the project is a fork of the LLVM and Clang projects, modified to accept HLSL and emit a validated container that can be consumed by GPU drivers.

At the moment, the DirectX HLSL Compiler provides the following components:

  • dxc.exe, a command-line tool that can compile HLSL programs for shader model 6.0 or higher

  • dxcompiler.dll, a DLL providing a componentized compiler, assembler, disassembler, and validator

  • dxilconv.dll, a DLL providing a converter from DXBC (older shader bytecode format)

  • various other tools based on the above components

The Microsoft Windows SDK releases include a supported version of the compiler and validator.

The goal of the project is to allow the broader community of shader developers to contribute to the language and representation of shader programs, maintaining the principles of compatibility and supportability for the platform. It's currently in active development across two axes: language evolution (with no impact to DXIL representation), and surfacing hardware capabilities (with impact to DXIL, and thus requiring coordination with GPU implementations).

Pre-built Releases

Development kits containing only the dxc.exe driver app, the dxcompiler.dll, and the dxil.dll signing binary are available here, or in the releases tab.

SPIR-V CodeGen

As an example of community contribution, this project can also target the SPIR-V intermediate representation. Please see the doc for how HLSL features are mapped to SPIR-V, and the wiki page for how to build, use, and contribute to the SPIR-V CodeGen.

Building Sources

Building DXC requires:

  • Git.
  • Python - version 3.x is required
  • CMake - version >= 3.17.2
    • The bundled version with Visual Studio works for Windows.
  • The C++ 14 compiler and runtime of your choosing.
    • DXC is known to compile with recent versions of GCC, Clang and MSVC.

Building on windows additionally requires:

A new experimental simplified build and test workflow is documented here.

Before you build, you will need to have some additional software installed. This is the most straightforward path - see Building Sources on the Wiki for more options, including Visual Studio 2015 and Ninja support.

After cloning the project, you can set up a build environment shortcut by double-clicking the utils\hct\hctshortcut.js file. This will create a shortcut on your desktop with a default configuration. If your system doesn't have the requisite association for .js files, this may not work. If so, open a cmd window and invoke: wscript.exe utils\hct\hctshortcut.js.

Tests are built using the TAEF framework which is included in the Windows Driver Kit.

To build, run this command on the HLSL Console.

hctbuild

You can also run tests with this command.

hcttest

To see a list of additional commands available, run hcthelp

Running Tests

To run tests, open the HLSL Console and run this command after a successful build.

hcttest

Some tests will run shaders and verify their behavior. These tests also involve a driver that can execute these shaders. See the next section on how this should be currently set up.

Running Shaders

To run shaders compiled as DXIL, you will need support from the operating system as well as from the driver for your graphics adapter. Windows 10 Creators Update is the first version to support DXIL shaders. See the Wiki for information on using experimental support or the software adapter.

Hardware Support

Hardware GPU support for DXIL is provided by the following vendors:

NVIDIA

NVIDIA's r396 drivers (r397.64 and later) provide release mode support for DXIL 1.1 and Shader Model 6.1 on Win10 1709 and later, and experimental mode support for DXIL 1.2 and Shader Model 6.2 on Win10 1803 and later. These drivers also support DXR in experimental mode.

Drivers can be downloaded from geforce.com.

AMD

AMDs driver (Radeon Software Adrenalin Edition 18.4.1 or later) provides release mode support for DXIL 1.1 and Shader Model 6.1. Drivers can be downloaded from AMD's download site.

Intel

Intel's 15.60 drivers (15.60.0.4849 and later) support release mode for DXIL 1.0 and Shader Model 6.0 as well as release mode for DXIL 1.1 and Shader Model 6.1 (View Instancing support only).

Drivers can be downloaded from the following link Intel Graphics Drivers

Direct access to 15.60 driver (latest as of of this update) is provided below:

Installer

Release Notes related to DXIL

Making Changes

To make contributions, see the CONTRIBUTING.md file in this project.

Documentation

You can find documentation for this project in the docs directory. These contain the original LLVM documentation files, as well as two new files worth nothing:

License

DirectX Shader Compiler is distributed under the terms of the University of Illinois Open Source License.

See LICENSE.txt and ThirdPartyNotices.txt for details.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.