Go to file
Bill Hollings 8f30f07eb5 Clarify CompileMSL config parameters and move to compile() function.
CompileMSL supports marking vertex attributes and resource bindings
as to whether they are used by the shader, and feeding back to caller.
2016-04-07 21:25:51 -04:00
include/spirv_cross Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
jni Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
msvc Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
reference/shaders Fix cases where SPIR-V conditionally branches to loop headers. 2016-04-04 08:53:37 +02:00
shaders Fix cases where SPIR-V conditionally branches to loop headers. 2016-04-04 08:53:37 +02:00
.gitignore Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
GLSL.std.450.h Initial commit. 2016-03-11 16:30:27 +01:00
LICENSE Initial commit. 2016-03-11 16:30:27 +01:00
main.cpp Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
Makefile Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
README.md Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_common.hpp Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_cpp.cpp Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
spirv_cpp.hpp Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00
spirv_cross.cpp Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_cross.hpp Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_glsl.cpp Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_glsl.hpp Initial support for Metal Shading Language. 2016-04-06 17:42:27 -04:00
spirv_msl.cpp Clarify CompileMSL config parameters and move to compile() function. 2016-04-07 21:25:51 -04:00
spirv_msl.hpp Clarify CompileMSL config parameters and move to compile() function. 2016-04-07 21:25:51 -04:00
spirv.hpp Initial commit. 2016-03-11 16:30:27 +01:00
test_shaders.py Rename project to SPIRV-Cross. 2016-04-04 15:42:30 +02:00

SPIRV-Cross

SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.

Features

  • Convert SPIR-V to readable, usable and efficient GLSL
  • Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL) [EXPERIMENTAL]
  • Convert SPIR-V to debuggable C++ [EXPERIMENTAL]
  • Reflection API to simplify the creation of Vulkan pipeline layouts
  • Reflection API to modify and tweak OpDecorations
  • Supports "all" of vertex, fragment, tessellation, geometry and compute shaders.

SPIRV-Cross tries hard to emit readable and clean output from the SPIR-V. The goal is to emit GLSL or MSL that looks like it was written by a human and not awkward IR/assembly-like code.

NOTE: Individual features are expected to be mostly complete, but it is possible that certain obscure GLSL features are not yet supported. However, most missing features are expected to be "trivial" improvements at this stage.

Occasionally, missing features is due to glslangValidator's lack of proper support for that feature making testing hard.

Building

SPIRV-Cross has been tested on Linux, OSX and Windows.

Linux and OSX

Just run make on the command line. A recent GCC (4.8+) or Clang (3.x+) compiler is required as SPIRV-Cross uses C++11 extensively.

Windows

MinGW-w64 based compilation works with make, and an MSVC 2013 solution is also included.

Usage

Creating a SPIR-V file from GLSL with glslang

glslangValidator -H -V -o test.spv test.frag

Converting a SPIR-V file to GLSL ES

glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 310 --es test.spv

Converting to desktop GLSL

glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 330 test.spv --output test.comp

Disable prettifying optimizations

glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 310 --es test.spv --output test.comp --force-temporary

ABI concerns

SPIR-V headers

The current repository uses the latest SPIR-V and GLSL.std.450 headers. SPIR-V files created from older headers could have ABI issues.

Regression testing

In shaders/ a collection of shaders are maintained for purposes of regression testing. The current reference output is contained in reference/. ./test_shaders.py shaders can be run to perform regression testing.

See ./test_shaders.py --help for more.

Updating regression tests

When legitimate changes are found, use --update flag to update regression files. Otherwise, ./test_shaders.py will fail with error code.

Mali Offline Compiler cycle counts

To obtain a CSV of static shader cycle counts before and after going through spirv-cross, add --malisc flag to ./test_shaders. This requires the Mali Offline Compiler to be installed in PATH.