Git Product home page Git Product logo

google / directxshadercompiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/directxshadercompiler

52.0 12.0 14.0 50.21 MB

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

License: Other

CMake 0.37% C++ 76.31% C 3.77% Roff 0.01% Shell 0.09% Assembly 0.07% LLVM 7.92% Makefile 0.01% Python 1.06% Perl 0.03% Batchfile 0.08% JavaScript 0.04% HLSL 9.14% PowerShell 0.01% Objective-C 0.36% HTML 0.23% Cuda 0.05% C# 0.44% AppleScript 0.01% Emacs Lisp 0.02%

directxshadercompiler's Introduction

DirectX Shader Compiler

Build status Build Status

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.

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

Binary packages containing the output of this project are available from appveyor. 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

Note: Instead of building manually, you can download the artifacts built by Appveyor for the latest master branch at here.

Note: If you intend to build from sources on Linux/macOS, follow these instructions.

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.

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 clean, build and run tests with this command.

hctcheckin

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 run these 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

AMD’s 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 [email protected] with any additional questions or comments.

directxshadercompiler's People

Contributors

adam-yang avatar alelenv avatar amarpmsft avatar antiagainst avatar dmpots avatar ehsannas avatar gongminmin avatar hekota avatar jaebaek avatar jaspernv avatar jeffnn avatar jholewinski avatar johnmcpms avatar jpporto avatar kingofthebongo2008 avatar marcelolr avatar markherdeg avatar mrvux avatar patricevignola avatar pow2clk avatar python3kgae avatar s-perron avatar sparmarnv avatar tafuri avatar tex3d avatar tgjones avatar tristanlabelle avatar vcsharma avatar yskim1501 avatar yurido1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

directxshadercompiler's Issues

Handle for statement

Goal

  • Support basic for statements
  • Support nested for statements
  • No need to support early returns and loop breaks for now

Add support for Linux

Goal:

  • Compile clang libraries on Linux
  • Compile supporting LLVM libraries on Linux
  • Bring up hlsl2spirv on Linux
  • Don't care about DXIL codegen

Blocker: None

Simplify file parsing in tests

Right now we read in the test source code line by line, create a string for each line and then append the strings to a stream. We can instead read in the whole file and search for the RUN directive. Then only one temporary string for holding the RUN directive needs to be created.

Avoid emitting OpVariable for constant variables

when facing
const int a = 10;
we could theoretically just translate to:
%const_id = OpConstant %int 10

and we can use %const_id anywhere a is used.

We currently create the constant as well as a variable, and we use %var

%const_id = OpConstant %int 10
%var = OpVariable %_ptr_Function_int Function %int_10

Handle entry point

Goals

  • Emit the correct OpEntryPoint for void main() {} as pixel shader

Handle if statement

Goal

  • Support basic if statement without early returns
  • Support nested if statements

Add SPIR-V module builder

Goal:

  • Add a SPIR-V module builder
  • Directly generate SPIR-V words
  • Handle module, function, and basic block structures

Add SPIR-V instruction builder

Goal:

  • Add a low-level SPIR-V instruction builder
  • Have one builder method for each instruction
  • Builder methods should reflect instruction layout
  • Optimally generate this builder from the grammar

Blocker: #1

Handle compound bitwise assignment for boolean values

E.g., for the following HLSL:

void main() {
  bool2 a, b;
  b &= a;
}

The AST is

    `-CompoundAssignOperator 0x1947ba00300 <line:6:3, col:8> 'bool2':'vector<bool, 2>' lvalue '&=' ComputeLHSTy='vector<bool, 2>' ComputeResultTy='vector<bool, 2>'
      |-DeclRefExpr 0x1947b9ffa50 <col:3> 'bool2':'vector<bool, 2>' lvalue Var 0x1947b9ff9b0 'b' 'bool2':'vector<bool, 2>'
      `-ImplicitCastExpr 0x1947ba002e8 <col:8> 'vector<bool, 2>' <HLSLCC_IntegralToBoolean>
        `-ImplicitCastExpr 0x1947ba002d0 <col:8> 'vector<int, 2>' <HLSLCC_IntegralCast>
          `-ImplicitCastExpr 0x1947b9ffaa0 <col:8> 'bool2':'vector<bool, 2>' <LValueToRValue>
            `-DeclRefExpr 0x1947b9ffa78 <col:8> 'bool2':'vector<bool, 2>' lvalue Var 0x1947b9ff930 'a' 'bool2':'vector<bool, 2>

Current codegen will emit OpBitwiseAnd for boolean types, which is forbidden by SPIR-V spec. Should fix this.

Consider simplifying the InstBuilder API

@antiagainst
At some point we should think again about whether it still makes sense to use a "word consumer" for the instruction builder. Instead, we could have the ".x()" function return the word vector.

For instance, I just wrote the following code in a pull request:

std::vector<uint32_t> execModeInstr;
spirv::InstBuilder ib([&execModeInstr](std::vector<uint32_t> &&words) {
  execModeInstr = std::move(words);
});
ib.opExecutionMode(funcId, spv::ExecutionMode::OriginUpperLeft).x();

If the above change is made, the above code would be simplified to:

auto& instr = InstrBuilder().opExecutionMode(funcId, spv::ExecutionMode::OriginUpperLeft).x();

If there is any good example of the WordConsumer functor being useful, we can keep things as they are.

Add bare bone code to dump SPIR-V header

Goal:

  • Add a bare bone Emit SPIR-V ASTFrontendAction
  • Add a bare bone SPIR-V module builder
  • Add option to dxc to call the new action and builder to dump SPIR-V header

Blocker: None

Set up unit testing mechanism

Goal:

  • Investigate existing testing mechanisms
  • Gate testing SPIR-V unit tests with a new option
  • Add test for dumping SPIR-V header

Blocker: #1

Add separate command line tool hlsl2spirv

Goal:

  • Add a separate command line tool hlsl2spirv for SPIR-V generation
  • Using CompilerInstance and FrontendAction directly
  • No need to support dxc command line options yet

Blocker: None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.