Squashed 'third_party/SPIRV-Tools/' changes from 51892874b..dd4b663e1

dd4b663e1 Prepare release v2024.2 (#5651)
be6fb2a54 build(deps): bump the github-actions group across 1 directory with 4 updates (#5650)
dadb3012d Add SPIRV_TOOLS_EXPORT to public C++ API (#5591)
53c073606 A fix to support of SPV_QCOM_image_processing2 (#5646)
67a3ed670 opt: add GroupNonUniformPartitionedNV capability to trim pass (#5648)
2904985ae spirv-val: Add Vulkan check for Rect Dim in OpTypeImage (#5644)
02470f606 Validate duplicate decorations and execution modes (#5641)
6761288d3 Validator: Support SPV_NV_raw_access_chains (#5568)
3983d15a1 Fix rebuilding types with circular references (#5623). (#5637)
ade1f7cfd Add AliasedPointer decoration (#5635)
24f2cdad8 build(deps): bump the github-actions group with 1 update (#5634)
58ab8baf7 docs: explain LunarG is the source of truth for releases (#5627)
7fe5f75e5 Roll external/re2/ 6598a8ecd..917047f36 (3 commits) (#5626)
87721a100 Roll external/spirv-headers/ 7d500c4d7..4f7b471f1 (1 commit) (#5625)
fe7bae090 Minor fix to cmakelists to avoid rerunning command each build (#5620)
fc4286556 build(deps): bump the github-actions group with 2 updates (#5621)
67451ebf6 Roll external/spirv-headers/ 04db24d69..7d500c4d7 (1 commit) (#5619)
dda7731e9 build(deps): bump the github-actions group with 2 updates (#5618)
3fafcc20e Roll external/spirv-headers/ 8b246ff75..04db24d69 (1 commit) (#5617)
3a0471c3b build(deps): bump the github-actions group with 1 update (#5615)
6c3f632a2 roll deps (#5614)
c6615779e Roll external/googletest/ b479e7a3c..c231e6f5b (1 commit) (#5613)
f20663ca7 add support for vulkan-shader-profiler external passes (#5512)
f74f4e74c Roll external/re2/ ed9fc269e..d00d1e937 (2 commits) (#5589)
e39cabca2 build(deps): bump the github-actions group with 2 updates (#5610)
efb0fce2d Use bazel 7 and bzlmod (#5601)
02c79e908 kokoro: Update bazel to 7.0.2 for Linux builds (#5609)
f869d391a [OPT] Fix handling of analyses rebuild (#5608)
d15a7aa25 kokoro: Update bazel to 7.0.2 for Mac builds (#5606)
04896c462 Prepare release v2024.1 (#5605)
7c363050d Add operand types for SPV_NV_raw_access_chains (#5602)
5bc7c2876 build(deps): bump the github-actions group with 2 updates (#5598)
75ad1345d Remove redundant function declarations from source/operand.h (#5584)
9bd44d028 Suppot for SPV_QCOM_image_processing2 (#5582)
0b027bafa Support operand kind for SPV_INTEL_maximum_registers (#5580)
fbc7a14b3 Fix access chain struct checks (#5592)
99a3ad32f build(deps): bump the github-actions group with 1 update (#5594)
c3a9ffd74 build(deps): bump the github-actions group with 1 update (#5593)
1b643eac5 spirv-val: Make Constant evaluation consistent (#5587)
dc6676445 Roll external/googletest/ 6eb225cb8..5df0241ea (2 commits) (#5583)
7da2c941f Update WORKSPACE (#5588)
16af142c1 build(deps): bump the github-actions group with 1 update (#5586)
b0a5c4ac1 SPV_NV_shader_atomic_fp16_vector (#5581)
55cb3989e build(deps): bump the github-actions group with 1 update (#5578)
11afeb4bb roll deps (#5576)
7604147c2 [OPT] Add removed unused interface var pass to legalization passes (#5579)
f9184c650 spirv-val: Revert Validate PhysicalStorageBuffer Stage Interface (#5575)
20ad38c18 spirv-val: Multiple interface var with same SC (#5528)
e08c012b1 [OPT] Identify arrays with unknown length in copy prop arrays (#5570)
56a51dd94 Roll external/spirv-headers/ e77d03080..d3c2a6fa9 (1 commit) (#5574)
0c986f596 update image enum tests to remove Kernel capability (#5562)
b7413609c [OPT] Use new instruction folder for for all opcodes in spec consti folding (#5569)
784b064f9 spirv-val: Validate PhysicalStorageBuffer Stage Interface (#5539)
a8959dc65 Fold 64-bit int operations (#5561)
80926d97a roll deps (#5566)
9a7b1af90 build(deps): bump the github-actions group with 1 update (#5564)
1a2cbabd8 Roll external/googletest/ 48729681a..64be1c79f (1 commit) (#5563)
7657cb1c6 build(deps): bump the github-actions group with 3 updates (#5560)
032c15aaf [NFC] Refactor code to fold instruction in fold tests. (#5558)
9938f5bc2 Roll external/googletest/ 456574145..48729681a (1 commit) (#5559)
ab59dc608 opt: prevent meld to merge block with MaximalReconvergence (#5557)
6c11c2bd4 Roll external/re2/ 283636ffb..ab7c5918b (2 commits) (#5555)
a8afbe941 roll deps (#5550)
8d3ee2e8f spirv-opt: Fix OpCompositeExtract relaxation with struct operands (#5536)
61c51d4ba spirv-val: Add Mesh Primitive Built-In validaiton (#5529)
5d3c8b73f opt: Add OpEntryPoint to DescriptorScalarReplacement pass (#5553)
de65e8174 [NFC] Remove unused code (#5554)
ad11927e6 opt: add SPV_EXT_mesh_shader to opt allowlist (#5551)
27ffe976e build(deps): bump the github-actions group with 2 updates (#5549)
e5fcb7fac Roll external/re2/ 264e71e88..826ad10e5 (1 commit) (#5538)
80bc99c3d Skip entire test/ folder if SPIRV_SKIP_TESTS is set. (#5548)
0a6f0d189 opt: Add TrimCapabilities pass to spirv-opt tool (#5545)
b951948ea SPV_KHR_quad_control (#5547)
69197ba90 Add modify-maximal-reconvergence to spirv-opt help (#5546)
0045b01ff opt: Add VulkanMemoryModelDeviceScope to trim (#5544)
ef2f43236 Add support for SPV_KHR_float_controls2 (#5543)
de3d5acc0 Add tooling support for SPV_KHR_maximal_reconvergence (#5542)
14000ad47 Use python3 explicitly. (#5540)
359012927 workflow: add vulkan-sdk tags as release tags (#5518)
3e6bdd0f9 build(deps): bump the github-actions group with 3 updates (#5537)
ed6835aff Roll external/re2/ c042630ed..32c181e0a (1 commit) (#5532)
c96fe8b94 spirv-val: Re-enable OpControlBarrier VU (#5527)
5dbdc7b60 build(deps): bump the github-actions group with 4 updates (#5531)
155728b2e Add preserver-interface option to spirv-opt (#5524)
01ee1bf31 Roll external/googletest/ b10fad38c..76bb2afb8 (1 commit) (#5485)
36be541ee Remove unnecessary debug code (#5523)
c7affa170 opt: add Int16 and Float16 to capability trim pass (#5519)
0a9f3d1f2 Revert "Fix(cmake): CMake doesn't find system installed SPIRV-Headers (#5422)" (#5517)
7d2429594 Fix(cmake): CMake doesn't find system installed SPIRV-Headers (#5422)
f0cc85efd Prepare release v2023.6 (#5510)
e03c8f5c8 Fix broken build (#5505)
d75b3cfbb Zero initialize local variables (#5501)
6b4f0c9d0 instrument: Fix handling of gl_InvocationID (#5493)
b5d60826e printf: Remove stage specific info (#5495)
e7a52b70f build(deps): bump the github-actions group with 1 update (#5498)
2da75e152 Do not crash when tryingto fold unsupported spec constant (#5496)
0d8784553 Remove uses of std::system(nullptr) (#5494)
f4a73dd7a std::system requires include of <cstdlib> (#5486)
ffe645023 Add iOS build to CI (#5490)
afaf8fda2 Fix iOS / Android CMake builds (#5482)
7d2a618bf build(deps): bump the github-actions group with 1 update (#5484)
2a238ed24 Roll external/spirv-headers/ 38f39dae5..cca08c63c (2 commits) (#5480)
246e6d4c6 spirv-val: Loosen restriction on base type of DebugTypePointer and DebugTypeQualifier (#5479)
0df791f97 Fix nullptr argument in MarkInsertChain (#5465)
fb91e6f0e Flush stdout before changing mode back to text (#5477)
560eea6d7 build(deps): bump the github-actions group with 1 update (#5478)
c8510a5e8 Fix python warning seen on Fedora 39 (#5474)
8ee3ae524 Add comment to --inst-debug-printf option (#5466)
f43c464d5 opt: add PhysicalStorageBufferAddresses to trim (#5476)
c91e9d09b opt: add StorageImageReadWithoutFormat to cap trim (#5475)
d88742fbd fix(build): git describe all tagged versions (#5447)
6b1e609ef Support missing git in update_build_version.py (#5473)
fbf047cc8 Roll external/re2/ 24d460a9d..974f44c8d (4 commits) (#5470)
9e7a1f2dd Fix array size calculation (#5463)
eacc969b7 build(deps): bump the github-actions group with 2 updates (#5457)
7210d247c Roll external/googletest/ 518387203..5b7fd63d6 (1 commit) (#5454)
a08f648c8 Remove references to __FILE__ (#5462)
c87755bb9 spirv-val: Add WorkgroupMemoryExplicitLayoutKHR check for Block (#5461)
4f014aff9 Roll external/re2/ 601d9ea3e..a0b3bc60c (1 commit) (#5453)
33bac5144 Roll external/googletest/ 116b7e552..518387203 (1 commit) (#5450)
01e851be9 Roll external/re2/ 928a015e6..601d9ea3e (1 commit) (#5448)
1928c76cd Roll external/googletest/ 2dd1c1319..829c19901 (1 commit) (#5444)
73876defc opt: support 64-bit OpAccessChain index in FixStorageClass (#5446)
5084f58e5 build(deps): bump the github-actions group with 4 updates (#5445)
a9c61d137 update_build_version.py produce deterministic header. (#5426)
5bb595091 Add ComputeDerivativeGroup*NV capabilities to trim capabilities pass. (#5430)
3985f0da0 Roll external/spirv-headers/ e867c0663..4183b260f (1 commit) (#5439)
661f429b1 Roll external/re2/ b673de358..ece4cecab (2 commits) (#5437)
360d469b9 Prepare release v2023.5.rc1 (#5423)
74005dfa6 Roll external/re2/ 35bb195de..b673de358 (2 commits) (#5433)
933db564c roll deps (#5432)
ce995b319 Hash pin workflows and config dependabot (#5412)
df2f2a031 build(deps): bump get-func-name from 2.0.0 to 2.0.2 in /tools/sva (#5418)
866e60def Roll external/spirv-headers/ 79743b899..e867c0663 (2 commits) (#5427)
023a8c79e opt: add Float64 capability to trim pass (#5428)
4fab7435b Roll external/googletest/ e47544ad3..beb552fb4 (2 commits) (#5424)
847715d6c instrument: Ensure linking works even of nothing is changed (#5419)
dc9900967 Update BUILD.gn to include header for new pass (#5421)
1bc0e6f59 Add a new legalization pass to dedupe invocation interlock instructions (#5409)
48c97c131 roll deps (#5415)
27673a054 Remove reviewer from autoroller (#5414)
ee7598d49 instrument: Use Import linkage for instrumentation functions (#5355)
a40483d31 roll deps (#5408)
a996591b1 Update SPIRV-Headers, add cache control operand kinds (#5406)
fc54e178e Change autoroll pr review id (#5404)
2d6996f73 Check for git repository before git commands (#5403)
361638cfd Make sure that fragment shader interlock instructions are not removed by DCE (#5400)
5e6054c1c Roll external/re2/ e0077036c..a807e8a3a (6 commits) (#5401)
47b63a4d7 val: re-add ImageMSArray validation (#5394)
d660bb55b Add SPV_KHR_physical_storage_buffer to allowlists (#5402)
440f018cc Fix `AddMemberDecoration` variable names. (#5399)
4e0b94ed7 opt: add ImageMSArray capability to trim pass. (#5395)
d474a0708 Add SPV_EXT_fragment_shader_interlock to allow lists (#5393)
1f07f483e opt: add raytracing/rayquery to trim pass (#5397)
158bc7bd6 Roll external/re2/ 523f9b097..e0077036c (2 commits) (#5391)
1121c2319 opt: add Int64 capability to trim pass (#5398)
3cc7e1c4c NFC: rename tests using capability as prefix (#5396)
4c16c35b1 opt: add FragmentShader*InterlockEXT to capability trim pass (#5390)
9b923f7cc QNX has support for ANSI ESC codes, default terminal is QANSI. (#5387)
51367c40f Enable OpenSSF Scorecard and Badge (#5377)
d09c753a4 Roll external/re2/ 73031bbc0..523f9b097 (1 commit) (#5389)
b6893ccdf Roll external/googletest/ 460ae9826..8a6feabf0 (1 commit) (#5388)
1b3c4cb68 roll deps (#5386)
abd548b81 roll deps (#5384)
2601f644e Roll external/googletest/ 9fce54804..61332bd7e (2 commits) (#5383)
714966003 opt: Add SwitchDescriptorSetPass (#5375)
6520d83ef linker: Add --use-highest-version option (#5376)
bfc94f63a roll deps (#5382)
b12fc2904 Roll external/googletest/ 7e33b6a1c..987e22561 (5 commits) (#5381)
89ca3aa57 SPV_QCOM_image_processing support (#5223)
c55888661 Fix failing action when PR is already open. (#5380)
0f17d05c4 opt: add bitmask support for capability trimming (#5372)
fddcc8ced Roll external/re2/ 9dc7ae7b5..6148386f0 (3 commits) (#5379)
7ddc65c72 Support 2 Intel extensions (#5357)
43b888649 roll deps (#5374)
d6300ee92 Fix -Wunreachable-code-loop-increment warning (#5373)
8714d7fad enable StorageUniform16 (#5371)
8e3da01b4 Move token version/cap/ext checks from parsing to validation (#5370)
4788ff157 opt: add StorageUniformBufferBlock16 to trim pass (#5367)
ebda56e35 opt: add StoragePushConstant16 to trim pass (#5366)
3af4244ae Roll external/googletest/ 46db91ef6..89b25572d (1 commit) (#5365)
60e684fe7 opt: fix StorageInputOutput16 trimming. (#5359)
13892fe86 Roll external/googletest/ 6f6ab4212..e7fd109b5 (2 commits) (#5356)
727f4346d docs: update references to `main` branch (#5363)
e553b884c Prepare release for v2023.4.rc2 (#5362)
4a9881fe9 Use absolute path to depot_tools (#5360)
09b76c23e Update SPIRV-Headers; test some coop matrix enums (#5361)
1d14d84f2 opt: fix missing CreateTrimCapabilitiesPass definition (#5353)
47fff21d5 instrument: Reduce number of inst_bindless_stream_write_6 calls (#5327)
02cd71d41 roll deps (#5352)
e68fe9be4 Add SPV_EXT_shader_atomic_float_add to allow lists (#5348)
c6d0b0480 build: fix missing files in BUILD.gn (#5351)
b5f600c08 Roll external/googletest/ 01e18376e..40412d851 (1 commit) (#5347)
a0f1c8727 opt: Fix incorrect half float conversion (#5349)
35d8b05de opt: add capability trimming pass (not default). (#5278)
ec90d2872 roll deps (#5345)
d52c39c37 Do not crash when folding 16-bit OpFDiv (#5338)
17d9669d5 enumset: add iterator based constructor/insert (#5344)
daad2295c Roll external/googletest/ cc366710b..d66ce5851 (2 commits) (#5337)
45f7e55af Bump word-wrap from 1.2.3 to 1.2.4 in /tools/sva (#5343)
bf03d4092 opt: change Get* functions to return const& (#5331)
876ccc6cd Add /bigobj to test_opt for VS 2017 (#5336)
c50bc49f5 Fix link flags for Clang-based MinGW cross compile (#5342)
2813da268 kokoro: rename glslang (#5339)
883417544 Set cmake_policy CMP0128 (#5341)
6c7e1acc5 NFC: fix missing algorithm include in enumset file (#5334)
61221e7d6 Add python3 requirement for the script (#5326)
4b6bd5a66 Prepare release v2023.4 (#5330)
9e0b780ff Create SECURITY.md (#5325)
7dd5f95d2 [spirv-opt] Handle OpFunction in GetPtr (#5316)
6add9ccf0 Add support for LiteralFloat type (#5323)
85a448213 NFC: makes the FeatureManager immutable for users (#5329)
29431859f NFC: replace EnumSet::ForEach with range-based-for (#5322)
d6b9389f6 Roll external/spirv-headers/ d0006a393..f1ba373ef (2 commits) (#5320)
5b4fb072e enumset: fix bug in the new iterator class (#5321)
9ab811a12 NFC: fix missing comments on functions (#5318)
9266197c3 instrument: Cast gl_VertexIndex and InstanceIndex to uint (#5319)
ee50fa7d8 Roll external/googletest/ 4a1a299b2..cc366710b (1 commit) (#5317)
3424b16c1 enumset: STL-ize container (#5311)
7ff331af6 source: Give better message if using new Source Language (#5314)
abcd228d9 Update README to say Android NDK r25c is required (#5312)
0530a532f Validate GroupNonUniform instructions (#5296)
4594ffce9 Roll external/re2/ a57a1d646..e66463312 (1 commit) (#5313)
4be7d0e3c Use android ndk r25 (#5309)
e751c7e7d Treat spir-v.xml as utf-8 (#5306)
0f3bea06e NFC: rewrite EnumSet to handle larger enums. (#5289)
870fd1e17 spirv-val: Label SPV_KHR_cooperative_matrix VUID (#5301)
a1e8fff14 Roll external/re2/ 2d39b703d..1c1ffbe3c (1 commit) (#5304)
58459c2b1 roll deps (#5300)
d3b0a522c Roll external/googletest/ 687c58994..251e72039 (1 commit) (#5299)
ea5af2fb5 roll deps (#5297)
f83f50d23 Roll external/googletest/ ec4fed932..8e32de89c (2 commits) (#5294)
7520bfa6b build: remove last references of c++11 (#5295)
e090ce9c4 Update CMakeLists.txt (#5293)
bfb40a240 fix ndk build standard to c++17 (#5290)
310a67020 Validate layouts for PhysicalStorageBuffer pointers (#5291)
c640b1934 Update CMakeLists.txt (#5288)
cfb99efd7 Roll external/googletest/ af39146b4..ec4fed932 (1 commit) (#5287)
04cdb2d34 SPV_KHR_cooperative_matrix (#5286)
16098b3c1 Have effcee add abseil subdirectory (#5281)
daee1e7d3 instrument: Combine descriptor length and init state checking (#5274)
a68ef7b2c cmake: Remove unused SPIRV-Headers variables (#5284)
b12c0fe6f Roll external/googletest/ fb11778f4..af39146b4 (1 commit) (#5285)
54691dcd7 Migrate `exec_tools` back to `tools`. (#5280)
a6b57f2f0 Roll external/googletest/ 9b12f749f..fb11778f4 (4 commits) (#5279)
a63ac9f73 cmake: Use modern Python3 CMake support (#5277)
951980e5a Enable vector constant folding (#4913) (#5272)
a720a6926 Roll external/googletest/ 18fa6a4db..9b12f749f (1 commit) (#5276)
6b9fc7933 Fold negation of integer vectors (#5269)
285f6cefa roll deps (#5273)
d33bea584 instrument: Fix buffer address length calculations (#5257)
b4f352e54 Expose preserve_interface in Optimizer::Register*Passes. (#5268)
40dde04ca Roll external/googletest/ 65cfeca1a..e9078161e (1 commit) (#5267)
6d0e3cf6a Roll external/googletest/ 334704df2..65cfeca1a (1 commit) (#5265)
9c66587d1 spirv-diff: Update test expectations (#5264)
ae1843b67 spirv-diff: Leave undefined ids unpaired. (#5262)
93c13345e spirv-diff: Properly match SPV_KHR_ray_query types. (#5259)
9da026922 roll deps (#5263)
1d7dec3c5 Use windows 2019 to workaround bazel issue (#5261)
59b4febd8 Allow OpTypeBool in UniformConstant (#5237)
5ed21eb1e Add folding rule for OpTranspose (#5241)
ec244c859 Increase tested Android API level (#5253)
c7e436921 roll deps (#5243)
182fd9ebc Allow physical storage buffer pointer in IO (#5251)
226c3bbe6 Fix broken link in README (#5250)
9ed2ac257 Fix pairing of function parameters. (#5225)
8841d560c Add c++ version to .bazelrc (#5247)
cf62673e4 Error for invalid location type (#5249)
673d8bfcb Checkout abseil in the smoketest (#5248)
06bbd7f53 Update deps in sva (#5246)
23cb9b96c spirv-val: Remove VUID from 1.3.251 spec (#5244)
1021ec302 Add Abseil dep to the README (#5242)
3e82fa067 Revert "Disable RE2 autoroll (#5234)" (#5239)
e0936b646 Roll external/spirv-headers/ bdbfd019b..69155b22b (1 commit) (#5238)
af27ece75 Check if const is zero before getting components. (#5217)
235800182 Add Abseil as a dep and update RE2 (#5236)
f29e11dcb diff: Don't give up entry point matching too early. (#5224)
82b1a87b2 Add SPV_NV_bindless_texture to spirv optimizations (#5231)
60c546f3f Roll external/googletest/ bc860af08..bb2941fcc (1 commit) (#5220)
dcfea36ab Have the macos bazel build us git-sync-deps (#5235)
44c9da6fe Remove const zero image operands (#5232)
e357a36cc Disable RE2 autoroll (#5234)
e7c6084fd Prepare release 2023.3 (#5222)
17a26b45f Improve an error message in the assembler (#5219)
7c39951f6 spirv-val: Label Interface Location/Component VUIDs (#5221)

git-subtree-dir: third_party/SPIRV-Tools
git-subtree-split: dd4b663e13c07fea4fbb3f70c1c91c86731099f7
Change-Id: I7efa466f44ce461394a16f123cd326553bd0a5a2
232 files changed
tree: 945cd91d73566f0f93fff6e49067c8a0933d52ea
  1. .github/
  2. android_test/
  3. build_overrides/
  4. cmake/
  5. docs/
  6. examples/
  7. external/
  8. include/
  9. kokoro/
  10. source/
  11. test/
  12. tools/
  13. utils/
  14. .bazelrc
  15. .bazelversion
  16. .clang-format
  17. .gitignore
  18. .gn
  19. Android.mk
  20. BUILD.bazel
  21. BUILD.gn
  22. build_defs.bzl
  23. CHANGES
  24. CMakeLists.txt
  25. CODE_OF_CONDUCT.md
  26. codereview.settings
  27. CONTRIBUTING.md
  28. DEPS
  29. LICENSE
  30. MODULE.bazel
  31. PRESUBMIT.py
  32. README.md
  33. SECURITY.md
  34. WORKSPACE
README.md

SPIR-V Tools

OpenSSF Scorecard

NEWS 2023-01-11: Development occurs on the main branch.

Overview

The SPIR-V Tools project provides an API and commands for processing SPIR-V modules.

The project includes an assembler, binary module parser, disassembler, validator, and optimizer for SPIR-V. Except for the optimizer, all are based on a common static library. The library contains all of the implementation details, and is used in the standalone tools whilst also enabling integration into other code bases directly. The optimizer implementation resides in its own library, which depends on the core library.

The interfaces have stabilized: We don't anticipate making a breaking change for existing features.

SPIR-V is defined by the Khronos Group Inc. See the SPIR-V Registry for the SPIR-V specification, headers, and XML registry.

Downloads

The official releases for SPIRV-Tools can be found on LunarG's SDK download page.

For convenience, here are also links to the latest builds (HEAD). Those are untested automated builds. Those are not official releases, nor are guaranteed to work. Official releases builds are in the Vulkan SDK.

Linux Build Status MacOS Build Status Windows Build Status

More downloads

Versioning SPIRV-Tools

See CHANGES for a high level summary of recent changes, by version.

SPIRV-Tools project version numbers are of the form vyear.index and with an optional -dev suffix to indicate work in progress. For example, the following versions are ordered from oldest to newest:

  • v2016.0
  • v2016.1-dev
  • v2016.1
  • v2016.2-dev
  • v2016.2

Use the --version option on each command line tool to see the software version. An API call reports the software version as a C-style string.

Releases

The official releases for SPIRV-Tools can be found on LunarG's SDK download page.

You can find either the prebuilt, and QA tested binaries, or download the SDK Config, which lists the commits to use to build the release from scratch.

GitHub releases are deprecated, and we will not publish new releases until further notice.

Supported features

Assembler, binary parser, and disassembler

  • Support for SPIR-V 1.0, through 1.5
    • Based on SPIR-V syntax described by JSON grammar files in the SPIRV-Headers repository.
    • Usually, support for a new version of SPIR-V is ready within days after publication.
  • Support for extended instruction sets:
    • GLSL std450 version 1.0 Rev 3
    • OpenCL version 1.0 Rev 2
  • Assembler only does basic syntax checking. No cross validation of IDs or types is performed, except to check literal arguments to OpConstant, OpSpecConstant, and OpSwitch.

See docs/syntax.md for the assembly language syntax.

Validator

The validator checks validation rules described by the SPIR-V specification.

Khronos recommends that tools that create or transform SPIR-V modules use the validator to ensure their outputs are valid, and that tools that consume SPIR-V modules optionally use the validator to protect themselves from bad inputs. This is especially encouraged for debug and development scenarios.

The validator has one-sided error: it will only return an error when it has implemented a rule check and the module violates that rule.

The validator is incomplete. See the CHANGES file for reports on completed work, and the Validator sub-project for planned and in-progress work.

Note: The validator checks some Universal Limits, from section 2.17 of the SPIR-V spec. The validator will fail on a module that exceeds those minimum upper bound limits. The validator has been parameterized to allow larger values, for use when targeting a more-than-minimally-capable SPIR-V consumer.

See tools/val/val.cpp or run spirv-val --help for the command-line help.

Optimizer

The optimizer is a collection of code transforms, or “passes”. Transforms are written for a diverse set of reasons:

  • To restructure, simplify, or normalize the code for further processing.
  • To eliminate undesirable code.
  • To improve code quality in some metric such as size or performance. Note: These transforms are not guaranteed to actually improve any given metric. Users should always measure results for their own situation.

As of this writing, there are 67 transforms including examples such as:

  • Simplification
    • Strip debug info
    • Strip reflection info
  • Specialization Constants
    • Set spec constant default value
    • Freeze spec constant to default value
    • Fold OpSpecConstantOp and OpSpecConstantComposite
    • Unify constants
    • Eliminate dead constant
  • Code Reduction
    • Inline all function calls exhaustively
    • Convert local access chains to inserts/extracts
    • Eliminate local load/store in single block
    • Eliminate local load/store with single store
    • Eliminate local load/store with multiple stores
    • Eliminate local extract from insert
    • Eliminate dead instructions (aggressive)
    • Eliminate dead branches
    • Merge single successor / single predecessor block pairs
    • Eliminate common uniform loads
    • Remove duplicates: Capabilities, extended instruction imports, types, and decorations.
  • Normalization
    • Compact IDs
    • CFG cleanup
    • Flatten decorations
    • Merge returns
    • Convert AMD-specific instructions to KHR instructions
  • Code improvement
    • Conditional constant propagation
    • If-conversion
    • Loop fission
    • Loop fusion
    • Loop-invariant code motion
    • Loop unroll
  • Other
    • Graphics robust access
    • Upgrade memory model to VulkanKHR

Additionally, certain sets of transformations have been packaged into higher-level recipes. These include:

  • Optimization for size (spirv-opt -Os)
  • Optimization for performance (spirv-opt -O)

For the latest list with detailed documentation, please refer to include/spirv-tools/optimizer.hpp.

For suggestions on using the code reduction options, please refer to this white paper.

Linker

Note: The linker is still under development.

Current features:

  • Combine multiple SPIR-V binary modules together.
  • Combine into a library (exports are retained) or an executable (no symbols are exported).

See the CHANGES file for reports on completed work, and the General sub-project for planned and in-progress work.

Reducer

Note: The reducer is still under development.

The reducer simplifies and shrinks a SPIR-V module with respect to a user-supplied interestingness function. For example, given a large SPIR-V module that cause some SPIR-V compiler to fail with a given fatal error message, the reducer could be used to look for a smaller version of the module that causes the compiler to fail with the same fatal error message.

To suggest an additional capability for the reducer, file an issue with “Reducer:” as the start of its title.

Fuzzer

Note: The fuzzer is still under development.

The fuzzer applies semantics-preserving transformations to a SPIR-V binary module, to produce an equivalent module. The original and transformed modules should produce essentially identical results when executed on identical inputs: their results should differ only due to floating-point round-off, if at all. Significant differences in results can pinpoint bugs in tools that process SPIR-V binaries, such as miscompilations. This metamorphic testing approach is similar to the method used by the GraphicsFuzz project for fuzzing of GLSL shaders.

To suggest an additional capability for the fuzzer, file an issue with “Fuzzer:” as the start of its title.

Diff

Note: The diff tool is still under development.

The diff tool takes two SPIR-V files, either in binary or text format and produces a diff-style comparison between the two. The instructions between the src and dst modules are matched as best as the tool can, and output is produced (in src id-space) that shows which instructions are removed in src, added in dst or modified between them. The order of instructions are not retained.

Matching instructions between two SPIR-V modules is not trivial, and thus a number of heuristics are applied in this tool. In particular, without debug information, match functions is nontrivial as they can be reordered. As such, this tool is primarily useful to produce the diff of two SPIR-V modules derived from the same source, for example before and after a modification to the shader, before and after a transformation, or SPIR-V produced from different tools.

Extras

  • Utility filters
  • Build target spirv-tools-vimsyntax generates file spvasm.vim. Copy that file into your $HOME/.vim/syntax directory to get SPIR-V assembly syntax highlighting in Vim. This build target is not built by default.

Contributing

The SPIR-V Tools project is maintained by members of the The Khronos Group Inc., and is hosted at https://github.com/KhronosGroup/SPIRV-Tools.

Consider joining the public_spirv_tools_dev@khronos.org mailing list, via https://www.khronos.org/spir/spirv-tools-mailing-list/. The mailing list is used to discuss development plans for the SPIRV-Tools as an open source project. Once discussion is resolved, specific work is tracked via issues and sometimes in one of the projects.

(To provide feedback on the SPIR-V specification, file an issue on the SPIRV-Headers GitHub repository.)

See docs/projects.md to see how we use the GitHub Project feature to organize planned and in-progress work.

Contributions via merge request are welcome. Changes should:

We intend to maintain a linear history on the GitHub main branch.

Getting the source

Example of getting sources, assuming SPIRV-Tools is configured as a standalone project:

git clone https://github.com/KhronosGroup/SPIRV-Tools.git   spirv-tools
cd spirv-tools

# Check out sources for dependencies, at versions known to work together,
# as listed in the DEPS file.
python3 utils/git-sync-deps

For some kinds of development, you may need the latest sources from the third-party projects:

git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-tools/external/spirv-headers
git clone https://github.com/google/googletest.git          spirv-tools/external/googletest
git clone https://github.com/google/effcee.git              spirv-tools/external/effcee
git clone https://github.com/google/re2.git                 spirv-tools/external/re2
git clone https://github.com/abseil/abseil-cpp.git          spirv-tools/external/abseil_cpp

Dependency on Effcee

Some tests depend on the Effcee library for stateful matching. Effcee itself depends on RE2, and RE2 depends on Abseil.

  • If SPIRV-Tools is configured as part of a larger project that already uses Effcee, then that project should include Effcee before SPIRV-Tools.
  • Otherwise, SPIRV-Tools expects Effcee sources to appear in external/effcee, RE2 sources to appear in external/re2, and Abseil sources to appear in external/abseil_cpp.

Source code organization

  • example: demo code of using SPIRV-Tools APIs
  • external/googletest: Intended location for the googletest sources, not provided
  • external/effcee: Location of Effcee sources, if the effcee library is not already configured by an enclosing project.
  • external/re2: Location of RE2 sources, if the re2 library is not already configured by an enclosing project. (The Effcee project already requires RE2.)
  • external/abseil_cpp: Location of Abseil sources, if Abseil is not already configured by an enclosing project. (The RE2 project already requires Abseil.)
  • include/: API clients should add this directory to the include search path
  • external/spirv-headers: Intended location for SPIR-V headers, not provided
  • include/spirv-tools/libspirv.h: C API public interface
  • source/: API implementation
  • test/: Tests, using the googletest framework
  • tools/: Command line executables

Tests

The project contains a number of tests, used to drive development and ensure correctness. The tests are written using the googletest framework. The googletest source is not provided with this project. There are two ways to enable tests:

  • If SPIR-V Tools is configured as part of an enclosing project, then the enclosing project should configure googletest before configuring SPIR-V Tools.
  • If SPIR-V Tools is configured as a standalone project, then download the googletest source into the <spirv-dir>/external/googletest directory before configuring and building the project.

Build

Note: Prebuilt binaries are available from the downloads page.

First get the sources. Then build using CMake, Bazel, Android ndk-build, or the Emscripten SDK.

Build using CMake

You can build the project using CMake:

cd <spirv-dir>
mkdir build && cd build
cmake [-G <platform-generator>] <spirv-dir>

Once the build files have been generated, build using the appropriate build command (e.g. ninja, make, msbuild, etc.; this depends on the platform generator used above), or use your IDE, or use CMake to run the appropriate build command for you:

cmake --build . [--config Debug]  # runs `make` or `ninja` or `msbuild` etc.

Note about the fuzzer

The SPIR-V fuzzer, spirv-fuzz, can only be built via CMake, and is disabled by default. To build it, clone protobuf and use the SPIRV_BUILD_FUZZER CMake option, like so:

# In <spirv-dir> (the SPIRV-Tools repo root):
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf

# In your build directory:
cmake [-G <platform-generator>] <spirv-dir> -DSPIRV_BUILD_FUZZER=ON
cmake --build . --config Debug

You can also add -DSPIRV_ENABLE_LONG_FUZZER_TESTS=ON to build additional fuzzer tests.

Build using Bazel

You can also use Bazel to build the project.

bazel build :all

Build a node.js package using Emscripten

The SPIRV-Tools core library can be built to a WebAssembly node.js module. The resulting SpirvTools WebAssembly module only exports methods to assemble and disassemble SPIR-V modules.

First, make sure you have the Emscripten SDK. Then:

cd <spirv-dir>
./source/wasm/build.sh

The resulting node package, with JavaScript and TypeScript bindings, is written to <spirv-dir>/out/web.

Note: This builds the package locally. It does not publish it to npm.

To test the result:

node ./test/wasm/test.js

Tools you'll need

For building and testing SPIRV-Tools, the following tools should be installed regardless of your OS:

  • CMake: if using CMake for generating compilation targets, you need to install CMake Version 2.8.12 or later.
  • Python 3: for utility scripts and running the test suite.
  • Bazel (optional): if building the source with Bazel, you need to install Bazel Version 7.0.2 on your machine. Other versions may also work, but are not verified.
  • Emscripten SDK (optional): if building the WebAssembly module.

SPIRV-Tools is regularly tested with the following compilers:

On Linux

  • GCC version 9.3
  • Clang version 10.0

On MacOS

  • AppleClang 11.0

On Windows

  • Visual Studio 2017
  • Visual Studio 2019
  • Visual Studio 2022

Note: Visual Studio 2017 has incomplete c++17 support. We might stop testing it soon. Other compilers or later versions may work, but they are not tested.

CMake options

The following CMake options are supported:

  • SPIRV_BUILD_FUZZER={ON|OFF}, default OFF - Build the spirv-fuzz tool.
  • SPIRV_COLOR_TERMINAL={ON|OFF}, default ON - Enables color console output.
  • SPIRV_SKIP_TESTS={ON|OFF}, default OFF- Build only the library and the command line tools. This will prevent the tests from being built.
  • SPIRV_SKIP_EXECUTABLES={ON|OFF}, default OFF- Build only the library, not the command line tools and tests.
  • SPIRV_USE_SANITIZER=<sanitizer>, default is no sanitizing - On UNIX platforms with an appropriate version of clang this option enables the use of the sanitizers documented here. This should only be used with a debug build.
  • SPIRV_WARN_EVERYTHING={ON|OFF}, default OFF - On UNIX platforms enable more strict warnings. The code might not compile with this option enabled. For Clang, enables -Weverything. For GCC, enables -Wpedantic. See CMakeLists.txt for details.
  • SPIRV_WERROR={ON|OFF}, default ON - Forces a compilation error on any warnings encountered by enabling the compiler-specific compiler front-end option. No compiler front-end options are enabled when this option is OFF.

Additionally, you can pass additional C preprocessor definitions to SPIRV-Tools via setting SPIRV_TOOLS_EXTRA_DEFINITIONS. For example, by setting it to /D_ITERATOR_DEBUG_LEVEL=0 on Windows, you can disable checked iterators and iterator debugging.

Android ndk-build

SPIR-V Tools supports building static libraries libSPIRV-Tools.a and libSPIRV-Tools-opt.a for Android. Using the Android NDK r25c or later:

cd <spirv-dir>

export ANDROID_NDK=/path/to/your/ndk   # NDK r25c or later

mkdir build && cd build
mkdir libs
mkdir app

$ANDROID_NDK/ndk-build -C ../android_test     \
                      NDK_PROJECT_PATH=.      \
                      NDK_LIBS_OUT=`pwd`/libs \
                      NDK_APP_OUT=`pwd`/app

Updating DEPS

Occasionally the entries in DEPS will need to be updated. This is done on demand when there is a request to do this, often due to downstream breakages. To update DEPS, run utils/roll_deps.sh and confirm that tests pass. The script requires Chromium's depot_tools.

Library

Usage

The internals of the library use C++17 features, and are exposed via both a C and C++ API.

In order to use the library from an application, the include path should point to <spirv-dir>/include, which will enable the application to include the header <spirv-dir>/include/spirv-tools/libspirv.h{|pp} then linking against the static library in <spirv-build-dir>/source/libSPIRV-Tools.a or <spirv-build-dir>/source/SPIRV-Tools.lib. For optimization, the header file is <spirv-dir>/include/spirv-tools/optimizer.hpp, and the static library is <spirv-build-dir>/source/libSPIRV-Tools-opt.a or <spirv-build-dir>/source/SPIRV-Tools-opt.lib.

  • SPIRV-Tools CMake target: Creates the static library:
    • <spirv-build-dir>/source/libSPIRV-Tools.a on Linux and OS X.
    • <spirv-build-dir>/source/libSPIRV-Tools.lib on Windows.
  • SPIRV-Tools-opt CMake target: Creates the static library:
    • <spirv-build-dir>/source/libSPIRV-Tools-opt.a on Linux and OS X.
    • <spirv-build-dir>/source/libSPIRV-Tools-opt.lib on Windows.

Entry points

The interfaces are still under development, and are expected to change.

There are five main entry points into the library in the C interface:

  • spvTextToBinary: An assembler, translating text to a binary SPIR-V module.
  • spvBinaryToText: A disassembler, translating a binary SPIR-V module to text.
  • spvBinaryParse: The entry point to a binary parser API. It issues callbacks for the header and each parsed instruction. The disassembler is implemented as a client of spvBinaryParse.
  • spvValidate implements the validator functionality. Incomplete
  • spvValidateBinary implements the validator functionality. Incomplete

The C++ interface is comprised of three classes, SpirvTools, Optimizer and Linker, all in the spvtools namespace.

  • SpirvTools provides Assemble, Disassemble, and Validate methods.
  • Optimizer provides methods for registering and running optimization passes.
  • Linker provides methods for combining together multiple binaries.

Command line tools

Command line tools, which wrap the above library functions, are provided to assemble or disassemble shader files. It's a convention to name SPIR-V assembly and binary files with suffix .spvasm and .spv, respectively.

Assembler tool

The assembler reads the assembly language text, and emits the binary form.

The standalone assembler is the executable called spirv-as, and is located in <spirv-build-dir>/tools/spirv-as. The functionality of the assembler is implemented by the spvTextToBinary library function.

  • spirv-as - the standalone assembler
    • <spirv-dir>/tools/as

Use option -h to print help.

Disassembler tool

The disassembler reads the binary form, and emits assembly language text.

The standalone disassembler is the executable called spirv-dis, and is located in <spirv-build-dir>/tools/spirv-dis. The functionality of the disassembler is implemented by the spvBinaryToText library function.

  • spirv-dis - the standalone disassembler
    • <spirv-dir>/tools/dis

Use option -h to print help.

The output includes syntax colouring when printing to the standard output stream, on Linux, Windows, and OS X.

Linker tool

The linker combines multiple SPIR-V binary modules together, resulting in a single binary module as output.

This is a work in progress. The linker does not support OpenCL program linking options related to math flags. (See section 5.6.5.2 in OpenCL 1.2)

  • spirv-link - the standalone linker
    • <spirv-dir>/tools/link

Optimizer tool

The optimizer processes a SPIR-V binary module, applying transformations in the specified order.

This is a work in progress, with initially only few available transformations.

  • spirv-opt - the standalone optimizer
    • <spirv-dir>/tools/opt

Validator tool

Warning: This functionality is under development, and is incomplete.

The standalone validator is the executable called spirv-val, and is located in <spirv-build-dir>/tools/spirv-val. The functionality of the validator is implemented by the spvValidate library function.

The validator operates on the binary form.

  • spirv-val - the standalone validator
    • <spirv-dir>/tools/val

Reducer tool

The reducer shrinks a SPIR-V binary module, guided by a user-supplied interestingness test.

This is a work in progress, with initially only shrinks a module in a few ways.

  • spirv-reduce - the standalone reducer
    • <spirv-dir>/tools/reduce

Run spirv-reduce --help to see how to specify interestingness.

Fuzzer tool

The fuzzer transforms a SPIR-V binary module into a semantically-equivalent SPIR-V binary module by applying transformations in a randomized fashion.

This is a work in progress, with initially only a few semantics-preserving transformations.

  • spirv-fuzz - the standalone fuzzer
    • <spirv-dir>/tools/fuzz

Run spirv-fuzz --help for a detailed list of options.

Control flow dumper tool

The control flow dumper prints the control flow graph for a SPIR-V module as a GraphViz graph.

This is experimental.

  • spirv-cfg - the control flow graph dumper
    • <spirv-dir>/tools/cfg

Diff tool

Warning: This functionality is under development, and is incomplete.

The diff tool produces a diff-style comparison between two SPIR-V modules.

  • spirv-diff - the standalone diff tool
    • <spirv-dir>/tools/diff`

Utility filters

  • spirv-lesspipe.sh - Automatically disassembles .spv binary files for the less program, on compatible systems. For example, set the LESSOPEN environment variable as follows, assuming both spirv-lesspipe.sh and spirv-dis are on your executable search path:

     export LESSOPEN='| spirv-lesspipe.sh "%s"'
    

    Then you page through a disassembled module as follows:

    less foo.spv
    
    • The spirv-lesspipe.sh script will pass through any extra arguments to spirv-dis. So, for example, you can turn off colours and friendly ID naming as follows:
      export LESSOPEN='| spirv-lesspipe.sh "%s" --no-color --raw-id'
      
  • vim-spirv - A vim plugin which supports automatic disassembly of .spv files using the :edit command and assembly using the :write command. The plugin also provides additional features which include; syntax highlighting; highlighting of all ID's matching the ID under the cursor; and highlighting errors where the Instruction operand of OpExtInst is used without an appropriate OpExtInstImport.

  • 50spirv-tools.el - Automatically disassembles ‘.spv’ binary files when loaded into the emacs text editor, and re-assembles them when saved, provided any modifications to the file are valid. This functionality must be explicitly requested by defining the symbol SPIRV_TOOLS_INSTALL_EMACS_HELPERS as follows:

    cmake -DSPIRV_TOOLS_INSTALL_EMACS_HELPERS=true ...
    

    In addition, this helper is only installed if the directory /etc/emacs/site-start.d exists, which is typically true if emacs is installed on the system.

    Note that symbol IDs are not currently preserved through a load/edit/save operation. This may change if the ability is added to spirv-as.

Tests

Tests are only built when googletest is found.

Running test with CMake

Use ctest -j <num threads> to run all the tests. To run tests using all threads:

ctest -j$(nproc)

To run a single test target, use ctest [-j <N>] -R <test regex>. For example, you can run all opt tests with:

ctest -R 'spirv-tools-test_opt'

Running test with Bazel

Use bazel test :all to run all tests. This will run tests in parallel by default.

To run a single test target, specify :my_test_target instead of :all. Test target names get printed when you run bazel test :all. For example, you can run opt_def_use_test with:

on linux:

bazel test --cxxopt=-std=c++17 :opt_def_use_test

on windows:

bazel test --cxxopt=/std:c++17 :opt_def_use_test

Future Work

See the projects pages for more information.

Assembler and disassembler

  • The disassembler could emit helpful annotations in comments. For example:
    • Use variable name information from debug instructions to annotate key operations on variables.
    • Show control flow information by annotating OpLabel instructions with that basic block's predecessors.
  • Error messages could be improved.

Validator

This is a work in progress.

Linker

  • The linker could accept math transformations such as allowing MADs, or other math flags passed at linking-time in OpenCL.
  • Linkage attributes can not be applied through a group.
  • Check decorations of linked functions attributes.
  • Remove dead instructions, such as OpName targeting imported symbols.

Licence

Full license terms are in LICENSE

Copyright (c) 2015-2016 The Khronos Group Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.