Home

Awesome

YARI-V

Build status

Build status

yariv.h is a single C/C++ header to encode and decode SPIR-V shaders into a more compressed form I've called YARI-V.

YARI-V is an alternative encoding of the SPIR-V standard that seeks to reduce the bytes required to encode shaders/kernels. In its default mode, it will losslessly convert a SPIR-V shader module into a corresponding YARI-V encoding with an average compression ratio of 34.42%.

Usage

Simply include the yariv.h header in your code, and then to encode, first call:

size_t yariv_encode_size(
  uint32_t encode_flags,
  const void *spirv,
  size_t spirv_size);

To get the size (in bytes) of memory required to hold the encoded YARI-V shader module.

Then call:

int yariv_encode(
  uint32_t encode_flags,
  void *out_yariv,
  size_t yariv_size,
  const void *spirv,
  size_t spirv_size);

Which will return 0 on success, and out_yariv will contain the YARI-V shader module.

Then, to decode, first call:

size_t yariv_decode_size(
  const void *yariv,
  size_t yariv_size);

To get the size (in bytes) of memory required to hold the decoded SPIR-V shader module.

Then call:

int yariv_decode(
  void *out_spirv,
  size_t spirv_size,
  const void *yariv,
  size_t yariv_size);

Which will return 0 on success, and out_spirv will contain the SPIR-V shader module.

Results

ApproachSize (kilobytes)Compression (%)
SPIR-V4868.468750100.000000%
SPIR-V + zstd20590.57324212.130575%
SMOL-V1837.88183637.750717%
SMOL-V + zstd20386.8798837.946644%
YARI-V1675.95605534.424706%
YARI-V + zstd20390.5771488.022587%
SMOL-V(stripped)1629.11523433.462580%
SMOL-V(stripped) + zstd20348.0732427.149542%
YARI-V(stripped)1498.66601630.783108%
YARI-V(stripped) + zstd20364.0576177.477867%

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Exceptions

The following folders are held under their own licenses (used for testing purposes only):