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

Andrei Alexeyev 91de4dfcf7 meson: fix build_info crap пре 3 година
External cb261e3c21 License headers: s/Google/The Khronos Group пре 4 година
OGLCompilersDLL 3b495226ac Add a basic Meson build system for use as a subproject пре 3 година
SPIRV ff570efbb5 meson: build_info.h braindeath пре 3 година
StandAlone b73afa8631 Prevent HLSL input under OpenGL semantics пре 3 година
Test b0f8a0c3ab Merge pull request #2458 from ShchchowAMD/unique_id-fix пре 3 година
build_overrides dac38b8fce Add basic GN configurations пре 3 година
glslang 91de4dfcf7 meson: fix build_info crap пре 3 година
gtests 4bfbf62794 Add support for GL_EXT_shared_memory_block пре 3 година
hlsl cb261e3c21 License headers: s/Google/The Khronos Group пре 4 година
kokoro 0f52e7ef12 Fix GN build and presubmits пре 3 година
ndk_test cb261e3c21 License headers: s/Google/The Khronos Group пре 4 година
.appveyor.yml 23f3bdfea1 Build/Test: Dropping 2013 allows using the latest googletests. пре 4 година
.clang-format 0e5d1bb66a clang-format correction and typo (clang format likely not complete) пре 5 година
.gitattributes 69d0c1acc2 Remove executable bits from code/data files (#2420) пре 3 година
.gitignore 0f52e7ef12 Fix GN build and presubmits пре 3 година
.gn dac38b8fce Add basic GN configurations пре 3 година
.travis.yml 862ddcb291 Fix Travis to use pre-breakage googletest (#2481) пре 3 година
Android.mk fbe9a23baf Generate build information from CHANGES.md пре 4 година
BUILD.bazel 983698bb34 Revert "Merge pull request #2371 from RafaelMarinheiro/master" пре 4 година
BUILD.gn d550bebee9 Fix build error with Chromium & ANGLE (#2446) пре 3 година
CHANGES.md 82a37a3531 Update CHANGES.md to 11.2.0 to sync with current tagging. пре 3 година
CMakeLists.txt 05798c17fb Fixed issues 2496. Used option 4: parse_version.cmake to avoid python3 usage. пре 3 година
CODE_OF_CONDUCT.md 4685f3246e Create CODE_OF_CONDUCT.md пре 6 година
ChooseMSVCCRT.cmake cb261e3c21 License headers: s/Google/The Khronos Group пре 4 година
DEPS 0f52e7ef12 Fix GN build and presubmits пре 3 година
LICENSE.txt 14a2cfbc72 Add bison license to LICENSE.txt пре 4 година
README-spirv-remap.txt a8456415b8 WIP: SPV Remapper: add remapper test framework пре 8 година
README.md 4f074aed75 Update README to avoid googletest breakage пре 3 година
WORKSPACE 23f3bdfea1 Build/Test: Dropping 2013 allows using the latest googletests. пре 4 година
_config.yml c8274e941e Make file formatting comply with POSIX and Unix standards пре 4 година
build_info.h.tmpl 05798c17fb Fixed issues 2496. Used option 4: parse_version.cmake to avoid python3 usage. пре 3 година
build_info.py 05798c17fb Fixed issues 2496. Used option 4: parse_version.cmake to avoid python3 usage. пре 3 година
known_good.json 6866807d6a Update spirv-tools and spirv-header known good. пре 3 година
known_good_khr.json d03da06ac1 Remove execute permissions пре 6 година
license-checker.cfg 752028582f license-checker.cfg: Update rules пре 3 година
meson.build 91de4dfcf7 meson: fix build_info crap пре 3 година
meson_options.txt 3b495226ac Add a basic Meson build system for use as a subproject пре 3 година
parse_version.cmake e3dab6f0d2 Code review. Thx ben-clayton for comments. пре 3 година
standalone.gclient dac38b8fce Add basic GN configurations пре 3 година
update_glslang_sources.py 0cb8ad55f6 tooling: Fix update sources script for Python 3 пре 6 година

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)