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

Andrei Alexeyev 2ee96a37f6 Expose setResourceSetBinding() method to the C API 4 dni temu
.github 12a17b7ce4 Bump actions/upload-artifact from 4.3.6 to 4.4.0 1 tydzień temu
External 72b403ad71 Fix continous_deployment 9 miesięcy temu
SPIRV 36ccaa31bd Explicitly export symbols from libSPVRemapper 6 dni temu
StandAlone 592de6cf78 Clean up unused includes. 1 miesiąc temu
Test 708d560c23 Allow compute derivative modes when the workgroup dimensions are spec constants 1 tydzień temu
build_overrides dac38b8fce Add basic GN configurations 3 lat temu
glslang 2ee96a37f6 Expose setResourceSetBinding() method to the C API 4 dni temu
gtests 02bc074ac4 Update tests to use the new iomapper interface 5 dni temu
kokoro 4a516f28a1 kokoro: use Python 3.12 for Linux builds 2 miesięcy temu
ndk_test 4f01996c9d Merge ancillary libraries into main glslang library and stub originals 1 miesiąc temu
.clang-format 0e5d1bb66a clang-format correction and typo (clang format likely not complete) 5 lat temu
.gitattributes 69d0c1acc2 Remove executable bits from code/data files (#2420) 3 lat temu
.gitignore 4aa56496d6 git: Ignore CMakeUserPresets.json 1 rok temu
.gn dac38b8fce Add basic GN configurations 3 lat temu
.mailmap 45405e1d94 Add a .mailmap file 1 rok temu
Android.mk d59c84d388 Fix typo in Android.mk 1 miesiąc temu
BUILD.gn ffd454c57b Add visibility.h to build scripts 4 tygodni temu
CHANGES.md fa9c3deb49 Update CHANGES for 14.3.0 2 miesięcy temu
CMakeLists.txt 4f01996c9d Merge ancillary libraries into main glslang library and stub originals 1 miesiąc temu
CODE_OF_CONDUCT.md 4685f3246e Create CODE_OF_CONDUCT.md 6 lat temu
DEPS 0f52e7ef12 Fix GN build and presubmits 3 lat temu
LICENSE.txt d465ac12dd Update LICENSE.txt 2 lat temu
README-spirv-remap.txt 05ba15169e Update the README-spirv-remap.txt 5 miesięcy temu
README.md 4f01996c9d Merge ancillary libraries into main glslang library and stub originals 1 miesiąc temu
SECURITY.md d9a6fb2247 Create a Security Policy (#3169) 1 rok temu
_config.yml c8274e941e Make file formatting comply with POSIX and Unix standards 4 lat temu
build_info.h.tmpl 6fdf03e4d1 Fix version check macros 2 lat temu
build_info.py 25555a7f62 Explicitly use Python 3 for scripts 2 lat temu
gen_extension_headers.py a7603c132d Use nullptr where possible instead of NULL or 0 1 rok temu
known_good.json 0d6be86cf1 Update known_good.json 2 miesięcy temu
known_good_khr.json 302a663a38 Use googletest version 1.14.0 10 miesięcy temu
license-checker.cfg 7a914ce926 Implement NonSemantic.Shader.DebugInfo.100 2 lat temu
parse_version.cmake e3dab6f0d2 Code review. Thx ben-clayton for comments. 3 lat temu
standalone.gclient dac38b8fce Add basic GN configurations 3 lat temu
update_glslang_sources.py f102d0f4fa Fix update_glslang_sources.py to not use distutils 10 miesięcy temu

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, enhancement requests, code improvements, etc by creating
issues in the glslang repository at https://github.com/KhronosGroup/glslang

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 glslang 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)