Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator

John Kessenich 3e8e9f7bbd PP: Implement locale-independent strtod, using istringstream and a fast path. 6 jaren geleden
External b56366ab75 Legalization: Skip spirv-tools tests 7 jaren geleden
OGLCompilersDLL 74bde98778 Memory: Restore unused interfaces, in case other tools called them. 6 jaren geleden
SPIRV b4a2a6cf94 Fix issue #1376: SPV_AMD_gpu_shader_half_float is not emitted under 6 jaren geleden
StandAlone 1199cf92f7 Fixed install for SPIRV, glslang, and hlsl when building shared libs 6 jaren geleden
Test 1ea1b13f38 Testing: Add new tests, and new ways of testing, for floating-point. 6 jaren geleden
glslang 3e8e9f7bbd PP: Implement locale-independent strtod, using istringstream and a fast path. 6 jaren geleden
gtests 1ea1b13f38 Testing: Add new tests, and new ways of testing, for floating-point. 6 jaren geleden
hlsl c59916710e HLSL: allow self-type cast (as no-op passthrough) 6 jaren geleden
.appveyor.yml 9a65c6a98e Appveyor: avoid double testing on master commits 6 jaren geleden
.clang-format e592652665 Increase column limit to 120. 8 jaren geleden
.gitattributes cc16fa0720 Tests: Move to just linefeed to simply cross-platform test changes. 8 jaren geleden
.gitignore cd1f169c6a Enable HLSL legalization 7 jaren geleden
.travis.yml fba299a25b Travis: auto deploy build artifacts to GitHub Releases 6 jaren geleden
CMakeLists.txt b9e9e57f12 Merge pull request #1326 from mattparks/patch1 6 jaren geleden
ChooseMSVCCRT.cmake 71241d8221 Allow choice of DLL or static CRT libraries through CMake options. 10 jaren geleden
README-spirv-remap.txt a8456415b8 WIP: SPV Remapper: add remapper test framework 8 jaren geleden
README.md 88a6a18119 README: Expand on the C++11 compiler requirement for MSVS. 6 jaren geleden
known_good.json d2b55801b9 Update spirv-tools known-good 6 jaren geleden
known_good_khr.json 5611c6d27b GLSL/SPV: Implement SPV_EXT_descriptor_indexing and GL_EXT_nonuniform_qualifier 6 jaren geleden
make-revision c6c80a6e48 Versioning: Address #1255: Move to semantic versioning. 6 jaren geleden
update_glslang_sources.py 484cbd0484 Upgrade update_glslang_sources.py to work with gitlab branch 6 jaren geleden

README-spirv-remap.txt


VERSION
--------------------------------------------------------------------------------
spirv-remap 0.97

INTRO:
--------------------------------------------------------------------------------
spirv-remap is a utility to improve compression of SPIR-V binary files via
entropy reduction, plus optional stripping of debug information and
load/store optimization. It transforms SPIR-V to SPIR-V, remapping IDs. The
resulting modules have an increased ID range (IDs are not as tightly packed
around zero), but will compress better when multiple modules are compressed
together, since compressor's dictionary can find better cross module
commonality.

Remapping is accomplished via canonicalization. Thus, modules can be
compressed one at a time with no loss of quality relative to operating on
many modules at once. The command line tool operates on multiple modules
only in the trivial repetition sense, for ease of use. The remapper API
only accepts a single module at a time.

There are two modes of use: command line, and a C++11 API. Both are
described below.

spirv-remap is currently in an alpha state. Although there are no known
remapping defects, it has only been exercised on one real world game shader
workload.


FEEDBACK
--------------------------------------------------------------------------------
Report defects, enhancements requests, code improvements, etc to:
spvremapper@lunarg.com


COMMAND LINE USAGE:
--------------------------------------------------------------------------------
Examples are given with a verbosity of one (-v), but more verbosity can be
had via -vv, -vvv, etc, or an integer parameter to --verbose, such as
"--verbose 4". With no verbosity, the command is silent and returns 0 on
success, and a positive integer error on failure.

Pre-built binaries for several OSs are available. Examples presented are
for Linux. Command line arguments can be provided in any order.

1. Basic ID remapping

Perform ID remapping on all shaders in "*.spv", writing new files with
the same basenames to /tmp/out_dir.

spirv-remap -v --map all --input *.spv --output /tmp/out_dir

2. Perform all possible size reductions

spirv-remap-linux-64 -v --do-everything --input *.spv --output /tmp/out_dir

Note that --do-everything is a synonym for:

--map all --dce all --opt all --strip all

API USAGE:
--------------------------------------------------------------------------------

The public interface to the remapper is defined in SPIRV/SPVRemapper.h as follows:

namespace spv {

class spirvbin_t
{
public:
enum Options { ... };
spirvbin_t(int verbose = 0); // construct

// remap an existing binary in memory
void remap(std::vector& spv, std::uint32_t opts = DO_EVERYTHING);

// Type for error/log handler functions
typedef std::function errorfn_t;
typedef std::function logfn_t;

// Register error/log handling functions (can be c/c++ fn, lambda fn, or functor)
static void registerErrorHandler(errorfn_t handler) { errorHandler = handler; }
static void registerLogHandler(logfn_t handler) { logHandler = handler; }
};

} // namespace spv

The class definition is in SPVRemapper.cpp.

remap() accepts an std::vector of SPIR-V words, modifies them per the
request given in 'opts', and leaves the 'spv' container with the result.
It is safe to instantiate one spirvbin_t per thread and process a different
SPIR-V in each.

The "opts" parameter to remap() accepts a bit mask of desired remapping
options. See REMAPPING AND OPTIMIZATION OPTIONS.

On error, the function supplied to registerErrorHandler() will be invoked.
This can be a standard C/C++ function, a lambda function, or a functor.
The default handler simply calls exit(5); The error handler is a static
member, so need only be set up once, not once per spirvbin_t instance.

Log messages are supplied to registerLogHandler(). By default, log
messages are eaten silently. The log handler is also a static member.

BUILD DEPENDENCIES:
--------------------------------------------------------------------------------
1. C++11 compatible compiler
2. cmake
3. glslang


BUILDING
--------------------------------------------------------------------------------
The standalone remapper is built along side glslangValidator through its
normal build process.


REMAPPING AND OPTIMIZATION OPTIONS
--------------------------------------------------------------------------------
API:
These are bits defined under spv::spirvbin_t::, and can be
bitwise or-ed together as desired.

MAP_TYPES = canonicalize type IDs
MAP_NAMES = canonicalize named data
MAP_FUNCS = canonicalize function bodies
DCE_FUNCS = remove dead functions
DCE_VARS = remove dead variables
DCE_TYPES = remove dead types
OPT_LOADSTORE = optimize unneeded load/stores
MAP_ALL = (MAP_TYPES | MAP_NAMES | MAP_FUNCS)
DCE_ALL = (DCE_FUNCS | DCE_VARS | DCE_TYPES)
OPT_ALL = (OPT_LOADSTORE)
ALL_BUT_STRIP = (MAP_ALL | DCE_ALL | OPT_ALL)
DO_EVERYTHING = (STRIP | ALL_BUT_STRIP)