All Projects → shader-slang → Slang

shader-slang / Slang

Licence: mit
Making it easier to work with shaders

Projects that are alternatives of or similar to Slang

Reshade
A generic post-processing injector for games and video software.
Stars: ✭ 2,285 (+264.43%)
Mutual labels:  glsl, vulkan, shaders, hlsl, d3d12
Shadergen
Proof-of-concept library for generating HLSL, GLSL, and Metal shader code from C#,
Stars: ✭ 395 (-37%)
Mutual labels:  glsl, vulkan, shaders, hlsl
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+1765.71%)
Mutual labels:  glsl, vulkan, shaders, hlsl
CPP-Programming
Various C/C++ examples. DirectX, OpenGL, CUDA, Vulkan, OpenCL.
Stars: ✭ 30 (-95.22%)
Mutual labels:  vulkan, glsl, cuda, hlsl
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+82.78%)
Mutual labels:  glsl, vulkan, hlsl, d3d12
Shaderc
A collection of tools, libraries, and tests for Vulkan shader compilation.
Stars: ✭ 1,016 (+62.04%)
Mutual labels:  glsl, vulkan, hlsl
Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (-81.98%)
Mutual labels:  glsl, vulkan, hlsl
Spirv Vm
Virtual machine for executing SPIR-V
Stars: ✭ 173 (-72.41%)
Mutual labels:  glsl, shaders, hlsl
Shaderc Rs
Rust bindings for the shaderc library.
Stars: ✭ 143 (-77.19%)
Mutual labels:  glsl, vulkan, hlsl
Shadered
Lightweight, cross-platform & full-featured shader IDE
Stars: ✭ 3,247 (+417.86%)
Mutual labels:  glsl, shaders, hlsl
YALCT
Yet Another Live Coding Tool - Powered by Veldrid and elbow grease
Stars: ✭ 25 (-96.01%)
Mutual labels:  shaders, vulkan, glsl
Hlsl2glslfork
HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
Stars: ✭ 488 (-22.17%)
Mutual labels:  glsl, shaders, hlsl
Hlslexplorer
See how hardware understands your HLSL
Stars: ✭ 91 (-85.49%)
Mutual labels:  shaders, hlsl, d3d12
Diligentcore
Core functionality of Diligent Engine
Stars: ✭ 263 (-58.05%)
Mutual labels:  vulkan, shaders, d3d12
pilka
Another live-coding tool for creating shader demos, Vulkan+Wgpu powered.
Stars: ✭ 84 (-86.6%)
Mutual labels:  shaders, vulkan, glsl
MoravaEngine
2D/3D graphics engine written in C++ language. It currently supports the following graphics APIs: OpenGL 3.3+, Vulkan 1.2, DirectX 11. Its current purpose is to experiment with various CG concepts and techniques.
Stars: ✭ 129 (-79.43%)
Mutual labels:  shaders, vulkan, glsl
Pmtech
Lightweight, multi-platform, data-oriented game engine.
Stars: ✭ 478 (-23.76%)
Mutual labels:  glsl, vulkan, hlsl
Vuda
VUDA is a header-only library based on Vulkan that provides a CUDA Runtime API interface for writing GPU-accelerated applications.
Stars: ✭ 373 (-40.51%)
Mutual labels:  vulkan, cuda
Shader Doodle
A friendly web-component for writing and rendering shaders.
Stars: ✭ 356 (-43.22%)
Mutual labels:  glsl, shaders
Vulkan minimal compute
Minimal Example of Using Vulkan for Compute Operations. Only ~400LOC.
Stars: ✭ 603 (-3.83%)
Mutual labels:  glsl, vulkan

Slang

AppVeyor build status Travis build status

Slang is a shading language that extends HLSL with new capabilities for building modular, extensible, and high-performance real-time shading systems. This repository provides a command-line compiler and a C/C++ API for loading, compiling, and reflecting shader code in Slang or plain HLSL.

The extensions provided by the Slang language make it easier for you to write high-performance shader codebases with a maintainable and modular structure. For example:

  • Parameter blocks (exposed as ParameterBlock<T>) let you group together related shader parameters -- both simple uniform values and resources like samplers/textures - in ordinary struct types, and then specify that they should be passed to the GPU as a single coherent block. Your application code can easily map a parameter block to abstractions like descriptor tables/sets on D3D12/Vulkan, or to the facilities provided by other APIs.

  • Generics and interfaces can be used to perform static specialization of your shader code without resort to preprocessor techniques or string-pasting. Unlike C++ templates, Slang's generics can be checked ahead of time and don't produce cascading error messages that are difficult to diagnose. The same generic shader can be specialized for a variety of different types to produce specialized code ahead of time, or on the fly, completely under application control.

The Slang implementation in this repository provides a library and a stand-alone compiler for Slang that can be used to:

  • Compile your HLSL or Slang code to DX bytecode, DXIL, SPIR-V, or plain source code in HLSL or GLSL.

  • Get full reflection information about the parameters of your shader code, with a consistent interface no matter the target graphics API. Slang doesn't silently drop unused or "dead" shader parameters from the reflection data, so you can always see the full picture.

  • Take ordinary HLSL code that neglects to include all those tedious register and layout bindings, and transform it into code that includes explicit bindings on every shader parameter. This frees you to write simple and clean code, while still getting completely deterministic binding locations.

Trying Out Slang

A fast and simple way to try out Slang is by using the Shader Playground website. This site allows easy and interactive testing of shader code across several compilers including Slang without having to install anything on your local machine.

Using the Slang compiler is as simple as selecting 'Slang' from the list of compilers in box underneath 'Compiler #1'. The output of the Slang compilation is shown in the right hand panel with the default 'Output format' of HLSL. To see the input source compiled to GLSL, select 'GLSL' from the 'Output format' box.

To compile using the Slang language (as opposed to the default input language of HLSL) select 'Slang' from the combo box underneath 'Shader Playground'. It may be necessary to change the Entry Point name from 'PSMain' to 'computeMain' for successful compilation of the sample.

For compute based shaders Slang can compile to C++, CUDA and PTX. Seeing this output is as simple as selecting the option via 'Output Format'. Note that C++ and CUDA output include a 'prelude'. The prelude remains the same across compilations, with the code generated for the input Slang source placed at the very end of the output.

Getting Started

The fastest way to get started with Slang is to use a pre-built binary package, available through GitHub releases. There are packages built for 32- and 64-bit Windows, as well as 64-bit Ubuntu. A binary release includes the command-line slangc compiler, a shared library for the compiler, and the slang.h header.

If you would like to build Slang from source, please consult the instructions here.

Documentation

For users getting started with Slang, it may help to start by looking at our example programs:

  • The hello-world example shows the basics for integrating the Slang API into an application as a more-or-less drop-in replacement for D3DCompile.

  • The model-viewer example shows a more involved rendering application that uses Slang's new language features to perform efficient shader specialization and parameter binding while maintaining clear and modular shader code.

  • The cpu-hello-world example shows how to compile and execute Slang code directly on the CPU.

A paper on the Slang system was accepted into SIGGRAPH 2018, and it provides an overview of the language and the compiler implementation. See also Yong He's dissertation for the detailed thinking behind the design of the Slang system.

The Slang language guide provides information on extended language features that Slang provides for user code.

The API user's guide gives information on how to drive Slang programmatically from an application.

The target compatibility guide gives an overview of feature compatibility for targets.

The CPU target guide gives information on compiling Slang or C++ source into shared libraries/executables or functions that can be directly executed. It also covers how to generate C++ code from Slang source.

The CUDA target guide provides information on compiling Slang/HLSL or CUDA source. Slang can compile to equivalent CUDA source, as well as to PTX via the nvrtc CUDA complier.

If you want to try out the slangc command-line tool, then you will want to read its documentation. Be warned, however, that the command-line tool is primarily intended for experimenting, testing, and debugging; serious applications will likely want to use the API interface.

Limitations

The Slang project is in an early state, so there are many rough edges to be aware of. Slang is not currently recommended for production use. The project is intentionally on a pre-1.0.0 version to reflect the fact that interfaces and features may change at any time (though we try not to break user code without good reason).

Major limitations to be aware of (beyond everything files in the issue tracker):

  • Slang only officially supports outputting GLSL/SPIR-V for Vulkan, not OpenGL

  • Slang's current approach to automatically assigning registers is appropriate to D3D12, and is not ideal for D3D11

  • Slang-to-GLSL cross-compilation only supports vertex, fragment, and compute shaders. Geometry and tessellation shader cross-compilation is not yet implemented.

  • The Slang front-end does best-effort checking of HLSL input, but it is challenging to achieve 100% compatibility. Bug reports and pull requests related to HLSL feature support are welcome.

  • Translations from Slang/HLSL constructs to GLSL equivalents has been done on as as-needed basis, so it is likely that new users will run into unimplemented cases.

Contributing

If you'd like to contribute to the project, we are excited to have your input. We don't currently have a formal set of guidelines for contributors, but here's the long/short of it:

  • Please follow the contributor Code of Conduct.
  • Bugs reports and feature requests should go through the GitHub issue tracker
  • Changes should ideally come in as small pull requests on top of master, coming from your own personal fork of the project
  • Large features that will involve multiple contributors or a long development time should be discussed in issues, and broken down into smaller pieces that can be implemented and checked in in stages

License

The Slang code itself is under the MIT license (see LICENSE).

The Slang projet can be compiled to use the glslang project as a submodule (under external/glslang), and glslang is under a BSD license.

The Slang tests (which are not distributed with source/binary releases) include example HLSL shaders extracted from the Microsoft DirectX SDK, which has its own license

Some of the Slang examples and tests use the stb_image and stb_image_write libraries (under external/stb) which have been placed in the public domain by their author(s).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].