Update SPIR-V Tools to dd4b663e1
Changes:
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)
Commands:
./third_party/update-spirvtools.sh
Bug: b/123642959
Change-Id: I4e497c6d70e17beb10e859266dbfa905d1f99136
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/73373
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Tested-by: Romaric Jodin <rjodin@chromium.org>
Presubmit-Ready: Romaric Jodin <rjodin@chromium.org>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/.clang-format b/.clang-format
index 1d43c4e..5a7a390 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,6 +1,118 @@
---
-Language: Cpp
-BasedOnStyle: Google
+Language: Cpp
+# BasedOnStyle: Google
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterCaseLabel: true
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterExternBlock: false
+ AfterFunction: true
+ AfterNamespace: false
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyNamespace: false
+ SplitEmptyRecord: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeComma
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 0
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: false
DerivePointerAlignment: false
-SortIncludes: true
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - Q_FOREACH
+ - BOOST_FOREACH
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^"[^/]*"'
+ Priority: 1
+ - Regex: '^".*/.*"'
+ Priority: 2
+ - Regex: '^<.*\..*>'
+ Priority: 3
+ - Regex: '^<[^.]*>'
+ Priority: 4
+ - Regex: '.*'
+ Priority: 5
+IncludeIsMainRegex: '([-_](test|unittest))?$'
+IndentCaseBlocks: true
+IndentCaseLabels: false
+IndentPPDirectives: AfterHash
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 1
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 200
+PointerAlignment: Right
+RawStringFormats:
+ - Language: TextProto
+ BasedOnStyle: google
+ReflowComments: true
+SortIncludes: true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: Never
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 2
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Auto
+TabWidth: 4
+UseTab: ForIndentation
...
+
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..fe208a4
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,165 @@
+;;; Directory Local Variables
+;;; See Info node `(emacs) Directory Variables' for more information.
+
+((c++-mode
+ (tab-width . 4)
+ (indent-tabs-mode . t)
+ (c-basic-offset . 4)
+ (show-trailing-whitespace . t)
+ (indicate-empty-lines . t)
+ (c-offsets-alist
+ (inexpr-class . +)
+ (inexpr-statement . +)
+ (lambda-intro-cont . +)
+ (inlambda . c-lineup-inexpr-block)
+ (template-args-cont c-lineup-template-args +)
+ (incomposition . +)
+ (inmodule . +)
+ (innamespace . +)
+ (inextern-lang . 0)
+ (composition-close . 0)
+ (module-close . 0)
+ (namespace-close . 0)
+ (extern-lang-close . 0)
+ (composition-open . 0)
+ (module-open . 0)
+ (namespace-open . 0)
+ (extern-lang-open . 0)
+ (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
+ (objc-method-args-cont . c-lineup-ObjC-method-args)
+ (objc-method-intro .
+ [0])
+ (friend . 0)
+ (cpp-define-intro c-lineup-cpp-define +)
+ (cpp-macro-cont . +)
+ (cpp-macro .
+ [0])
+ (inclass . +)
+ (stream-op . c-lineup-streamop)
+ (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
+ (arglist-cont c-lineup-gcc-asm-reg 0)
+ (comment-intro . 0)
+ (catch-clause . 0)
+ (else-clause . 0)
+ (do-while-closure . 0)
+ (access-label . -)
+ (case-label . +)
+ (substatement . +)
+ (statement-case-intro . +)
+ (statement . 0)
+ (brace-entry-open . 0)
+ (brace-list-entry . 0)
+ (brace-list-intro . +)
+ (brace-list-close . 0)
+ (block-close . 0)
+ (block-open . 0)
+ (inher-cont . c-lineup-multi-inher)
+ (inher-intro . ++)
+ (member-init-cont . c-lineup-multi-inher)
+ (member-init-intro . ++)
+ (annotation-var-cont . +)
+ (annotation-top-cont . 0)
+ (topmost-intro . 0)
+ (knr-argdecl . 0)
+ (func-decl-cont . ++)
+ (inline-close . 0)
+ (class-close . 0)
+ (class-open . 0)
+ (defun-block-intro . +)
+ (defun-close . 0)
+ (defun-open . 0)
+ (c . c-lineup-C-comments)
+ (string . c-lineup-dont-change)
+ (topmost-intro-cont . c-lineup-topmost-intro-cont)
+ (brace-list-open . 0)
+ (inline-open . 0)
+ (arglist-close . c-lineup-arglist)
+ (arglist-intro google-c-lineup-expression-plus-4)
+ (statement-cont nil nil ++)
+ (statement-case-open . +)
+ (label . /)
+ (substatement-label . 2)
+ (substatement-open . 0)
+ (knr-argdecl-intro . +)
+ (statement-block-intro . +)))
+(c-mode
+ (tab-width . 4)
+ (indent-tabs-mode . t)
+ (c-basic-offset . 4)
+ (show-trailing-whitespace . t)
+ (indicate-empty-lines . t)
+ (c-offsets-alist
+ (inexpr-class . +)
+ (inexpr-statement . +)
+ (lambda-intro-cont . +)
+ (inlambda . c-lineup-inexpr-block)
+ (template-args-cont c-lineup-template-args +)
+ (incomposition . +)
+ (inmodule . +)
+ (innamespace . +)
+ (inextern-lang . 0)
+ (composition-close . 0)
+ (module-close . 0)
+ (namespace-close . 0)
+ (extern-lang-close . 0)
+ (composition-open . 0)
+ (module-open . 0)
+ (namespace-open . 0)
+ (extern-lang-open . 0)
+ (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
+ (objc-method-args-cont . c-lineup-ObjC-method-args)
+ (objc-method-intro .
+ [0])
+ (friend . 0)
+ (cpp-define-intro c-lineup-cpp-define +)
+ (cpp-macro-cont . +)
+ (cpp-macro .
+ [0])
+ (inclass . +)
+ (stream-op . c-lineup-streamop)
+ (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
+ (arglist-cont c-lineup-gcc-asm-reg 0)
+ (comment-intro . 0)
+ (catch-clause . 0)
+ (else-clause . 0)
+ (do-while-closure . 0)
+ (access-label . -)
+ (case-label . +)
+ (substatement . +)
+ (statement-case-intro . +)
+ (statement . 0)
+ (brace-entry-open . 0)
+ (brace-list-entry . 0)
+ (brace-list-intro . +)
+ (brace-list-close . 0)
+ (block-close . 0)
+ (block-open . 0)
+ (inher-cont . c-lineup-multi-inher)
+ (inher-intro . ++)
+ (member-init-cont . c-lineup-multi-inher)
+ (member-init-intro . ++)
+ (annotation-var-cont . +)
+ (annotation-top-cont . 0)
+ (topmost-intro . 0)
+ (knr-argdecl . 0)
+ (func-decl-cont . ++)
+ (inline-close . 0)
+ (class-close . 0)
+ (class-open . 0)
+ (defun-block-intro . +)
+ (defun-close . 0)
+ (defun-open . 0)
+ (c . c-lineup-C-comments)
+ (string . c-lineup-dont-change)
+ (topmost-intro-cont . c-lineup-topmost-intro-cont)
+ (brace-list-open . 0)
+ (inline-open . 0)
+ (arglist-close . c-lineup-arglist)
+ (arglist-intro google-c-lineup-expression-plus-4)
+ (statement-cont nil nil ++)
+ (statement-case-open . +)
+ (label . /)
+ (substatement-label . 2)
+ (substatement-open . 0)
+ (knr-argdecl-intro . +)
+ (statement-block-intro . +))))
diff --git a/.gitignore b/.gitignore
index e85cea9..065adea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,37 +1,47 @@
-.clang_complete
-.ycm_extra_conf.py*
-*.pyc
-compile_commands.json
-/build*/
-/buildtools/
-/external/abseil_cpp/
-/external/googletest
-/external/SPIRV-Headers
-/external/spirv-headers
-/external/effcee
-/external/re2
-/external/protobuf
-/out
-/TAGS
-/third_party/llvm-build/
-/testing
-/tools/clang/
-/utils/clang-format-diff.py
-bazel-bin
-bazel-genfiles
-bazel-out
-bazel-spirv-tools
-bazel-SPIRV-Tools
-bazel-testlogs
-MODULE.bazel.lock
+# Ignored folders #
+/cache/
+/lib/
+/obj/
+/bin/
+/out/
+.vs
+.vscode/ipch
+CMakeFiles/
+.idea/
+cmake-build-debug/
-# Vim
-[._]*.s[a-w][a-z]
+# Per user vscode config files.
+.vscode/launch.json
+.vscode/settings.json
+
+# The /build/ directory is recommended for CMake build output
+!/build
+/build/*
+
+
+# Ignored files #
+*.obj
+*.lib
+*.log
+*.tlog
+*.exe
+*.ilk
+*.pdb
+*.sbr
+*.bsc
+*.dll
+*.res
+*.idb
+*.sdf
+*.suo
+*.o
+*.depend
+*.layout
+*.opensdf
+*.aps
+*.opendb
+*.db
*~
-
-# C-Lion
-/.idea/
-/cmake-build-*/
-
-# VSCode
-/.vscode/*
+.*.sw*
+.sw*
+CMakeCache.txt
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..cb86c5c
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,27 @@
+[submodule "third_party/cppdap"]
+ path = third_party/cppdap
+ url = https://github.com/google/cppdap
+[submodule "third_party/googletest"]
+ path = third_party/googletest
+ url = https://github.com/google/googletest.git
+[submodule "third_party/json"]
+ path = third_party/json
+ url = https://github.com/nlohmann/json.git
+[submodule "third_party/libbacktrace/src"]
+ path = third_party/libbacktrace/src
+ url = https://github.com/ianlancetaylor/libbacktrace.git
+[submodule "third_party/PowerVR_Examples"]
+ path = third_party/PowerVR_Examples
+ url = https://github.com/powervr-graphics/Native_SDK.git
+[submodule "third_party/benchmark"]
+ path = third_party/benchmark
+ url = https://github.com/google/benchmark.git
+[submodule "third_party/glslang"]
+ path = third_party/glslang
+ url = https://github.com/KhronosGroup/glslang.git
+[submodule "third_party/git-hooks"]
+ path = third_party/git-hooks
+ url = https://swiftshader.googlesource.com/git-hooks
+[submodule "third_party/llvm-project"]
+ path = third_party/llvm-project
+ url = https://github.com/llvm/llvm-project.git
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..32bda13
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,76 @@
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "defines": [
+ "ENABLE_VK_DEBUGGER=1",
+ "ENABLE_RR_DEBUG_INFO=1",
+ "ENABLE_RR_PRINT=1",
+ "VERIFY_LLVM_IR=1"
+ ],
+ "includePath": [
+ "${workspaceFolder}/build/spirv-tools-ext/include",
+ "${workspaceFolder}/include",
+ "${workspaceFolder}/src",
+ "${workspaceFolder}/third_party/benchmark/include",
+ "${workspaceFolder}/third_party/cppdap/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/common/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/windows/include",
+ "${workspaceFolder}/third_party/llvm-10.0/llvm/include",
+ "${workspaceFolder}/third_party/marl/include",
+ "${workspaceFolder}/third_party/SPIRV-Headers/include",
+ "${workspaceFolder}/third_party/SPIRV-Tools/include"
+ ],
+ "cStandard": "c11",
+ "cppStandard": "c++17"
+ },
+ {
+ "name": "Mac",
+ "defines": [
+ "ENABLE_VK_DEBUGGER=1",
+ "ENABLE_RR_DEBUG_INFO=1",
+ "ENABLE_RR_PRINT=1",
+ "VERIFY_LLVM_IR=1"
+ ],
+ "includePath": [
+ "${workspaceFolder}/build/spirv-tools-ext/include",
+ "${workspaceFolder}/include",
+ "${workspaceFolder}/src",
+ "${workspaceFolder}/third_party/benchmark/include",
+ "${workspaceFolder}/third_party/cppdap/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/common/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/windows/include",
+ "${workspaceFolder}/third_party/llvm-10.0/llvm/include",
+ "${workspaceFolder}/third_party/marl/include",
+ "${workspaceFolder}/third_party/SPIRV-Headers/include",
+ "${workspaceFolder}/third_party/SPIRV-Tools/include"
+ ],
+ "cStandard": "c11",
+ "cppStandard": "c++17"
+ },
+ {
+ "name": "Win32",
+ "defines": [
+ "ENABLE_VK_DEBUGGER=1",
+ "ENABLE_RR_DEBUG_INFO=1",
+ "ENABLE_RR_PRINT=1",
+ "VERIFY_LLVM_IR=1"
+ ],
+ "includePath": [
+ "${workspaceFolder}/include",
+ "${workspaceFolder}/src",
+ "${workspaceFolder}/third_party/benchmark/include",
+ "${workspaceFolder}/third_party/cppdap/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/common/include",
+ "${workspaceFolder}/third_party/llvm-10.0/configs/windows/include",
+ "${workspaceFolder}/third_party/llvm-10.0/llvm/include",
+ "${workspaceFolder}/third_party/marl/include",
+ "${workspaceFolder}/third_party/SPIRV-Headers/include",
+ "${workspaceFolder}/third_party/SPIRV-Tools/include"
+ ],
+ "cStandard": "c11",
+ "cppStandard": "c++17"
+ }
+ ],
+ "version": 4
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..11a1dc3
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,109 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ // Available variables which can be used inside of strings.
+ // ${workspaceRoot}: the root folder of the team
+ // ${file}: the current opened file
+ // ${fileBasename}: the current opened file's basename
+ // ${fileDirname}: the current opened file's dirname
+ // ${fileExtname}: the current opened file's extension
+ // ${cwd}: the current working directory of the spawned process
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "make",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "type": "shell",
+ "command": "sh",
+ "osx": {
+ "args": [
+ "-c",
+ "cmake --build . && echo Done"
+ ]
+ },
+ "linux": {
+ "args": [
+ "-c",
+ "cmake --build . && echo Done"
+ ]
+ },
+ "windows": {
+ "args": [
+ "-c",
+ "cmake --build . && echo Done"
+ ]
+ },
+ "options": {
+ "cwd": "${workspaceRoot}/build",
+ },
+ "presentation": {
+ "echo": false,
+ "reveal": "always",
+ "focus": false,
+ "panel": "shared",
+ "showReuseMessage": false,
+ "clear": true,
+ },
+ "problemMatcher": {
+ "owner": "cpp",
+ "fileLocation": "absolute",
+ "pattern": {
+ "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
+ "file": 1,
+ "line": 2,
+ "column": 3,
+ "severity": 4,
+ "message": 5
+ }
+ }
+ },
+ {
+ "label": "cmake",
+ "type": "shell",
+ "command": "cmake",
+ "args": [
+ "..",
+ "-GNinja",
+ "-DCMAKE_BUILD_TYPE=${input:buildType}",
+ "-DSWIFTSHADER_WARNINGS_AS_ERRORS=1",
+ "-DSWIFTSHADER_DCHECK_ALWAYS_ON=1",
+ "-DREACTOR_VERIFY_LLVM_IR=1",
+ ],
+ "options": {
+ "cwd": "${workspaceRoot}/build"
+ },
+ "problemMatcher": [],
+ },
+ {
+ "label": "Push branch for review",
+ "type": "shell",
+ "command": "git",
+ "args": [
+ "push",
+ "origin",
+ "HEAD:refs/for/master"
+ ],
+ "options": {
+ "cwd": "${workspaceRoot}"
+ },
+ "problemMatcher": [],
+ }
+ ],
+ "inputs": [
+ {
+ "id": "buildType",
+ "type": "pickString",
+ "options": [
+ "Debug",
+ "Release",
+ "MinSizeRel",
+ "RelWithDebInfo",
+ ],
+ "default": "Debug",
+ "description": "The type of build",
+ },
+ ]
+}
diff --git a/AUTHORS.txt b/AUTHORS.txt
new file mode 100644
index 0000000..faa8822
--- /dev/null
+++ b/AUTHORS.txt
@@ -0,0 +1,9 @@
+# This is the official list of SwiftShader authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+# Names should be added to this file as:
+# Name or Organization <email address>
+# The email address is not required for organizations.
+
+Google Inc.
+The ANGLE Project Authors <angleproject@googlegroups.com>
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..6a0d6ff
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,142 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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.
+//
+
+package {
+ default_applicable_licenses: ["external_swiftshader_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'filegroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change filtered out the below license kinds as false-positives:
+// SPDX-license-identifier-GPL
+// SPDX-license-identifier-GPL-3.0
+// http://go/android-license-faq
+license {
+ name: "external_swiftshader_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-MIT",
+ "SPDX-license-identifier-NCSA",
+ "legacy_unencumbered",
+ ],
+ license_text: [
+ "LICENSE.txt",
+ ],
+}
+
+cc_defaults {
+ name: "swiftshader_common",
+
+ gnu_extensions: false,
+
+ cflags: [
+ "-Werror",
+ "-Wwrite-strings",
+ ],
+
+ cppflags: [
+ "-Woverloaded-virtual",
+ "-DVK_EXPORT= ",
+ ],
+ cpp_std: "c++17",
+
+ arch: {
+ x86: {
+ cflags: [
+ "-msse2",
+ ],
+ },
+ x86_64: {
+ cflags: [
+ "-msse2",
+ ],
+ },
+ },
+
+ target: {
+ android: {
+ cppflags: [
+ "-DVK_USE_PLATFORM_ANDROID_KHR",
+ ],
+ },
+ host: {
+ cppflags: [
+ "-fno-rtti",
+ "-fno-exceptions",
+ ],
+ compile_multilib: "64",
+ },
+
+ // We don't need Darwin host-side builds
+ darwin: {
+ enabled: false,
+ },
+ },
+}
+
+cc_defaults {
+ name: "swiftshader_common_release",
+
+ defaults: [ "swiftshader_common" ],
+
+ cflags: [
+ "-Os",
+ "-fomit-frame-pointer",
+ "-ffunction-sections",
+ "-fdata-sections",
+ ],
+}
+
+cc_defaults {
+ name: "swiftshader_common_debug",
+
+ defaults: [ "swiftshader_common" ],
+
+ cflags: [
+ "-O0",
+ "-g",
+ "-UNDEBUG",
+ ],
+}
+
+cc_library_headers {
+ name: "swiftshader_platform_headers",
+ host_supported: true,
+ device_supported: true,
+ vendor_available: true,
+ export_include_dirs: ["include"],
+}
+
+cc_library_headers {
+ name: "swiftshader_host_headers",
+ device_supported: false,
+ host_supported: true,
+ export_include_dirs: ["include/Android"],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index e3e30bb..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,362 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-SPVTOOLS_OUT_PATH=$(if $(call host-path-is-absolute,$(TARGET_OUT)),$(TARGET_OUT),$(abspath $(TARGET_OUT)))
-
-ifeq ($(SPVHEADERS_LOCAL_PATH),)
- SPVHEADERS_LOCAL_PATH := $(LOCAL_PATH)/external/spirv-headers
-endif
-
-SPVTOOLS_SRC_FILES := \
- source/assembly_grammar.cpp \
- source/binary.cpp \
- source/diagnostic.cpp \
- source/disassemble.cpp \
- source/ext_inst.cpp \
- source/enum_string_mapping.cpp \
- source/extensions.cpp \
- source/libspirv.cpp \
- source/name_mapper.cpp \
- source/opcode.cpp \
- source/operand.cpp \
- source/parsed_operand.cpp \
- source/print.cpp \
- source/software_version.cpp \
- source/spirv_endian.cpp \
- source/spirv_optimizer_options.cpp \
- source/spirv_target_env.cpp \
- source/spirv_validator_options.cpp \
- source/table.cpp \
- source/text.cpp \
- source/text_handler.cpp \
- source/util/bit_vector.cpp \
- source/util/parse_number.cpp \
- source/util/string_utils.cpp \
- source/util/timer.cpp \
- source/val/basic_block.cpp \
- source/val/construct.cpp \
- source/val/function.cpp \
- source/val/instruction.cpp \
- source/val/validation_state.cpp \
- source/val/validate.cpp \
- source/val/validate_adjacency.cpp \
- source/val/validate_annotation.cpp \
- source/val/validate_arithmetics.cpp \
- source/val/validate_atomics.cpp \
- source/val/validate_barriers.cpp \
- source/val/validate_bitwise.cpp \
- source/val/validate_builtins.cpp \
- source/val/validate_capability.cpp \
- source/val/validate_cfg.cpp \
- source/val/validate_composites.cpp \
- source/val/validate_constants.cpp \
- source/val/validate_conversion.cpp \
- source/val/validate_debug.cpp \
- source/val/validate_decorations.cpp \
- source/val/validate_derivatives.cpp \
- source/val/validate_extensions.cpp \
- source/val/validate_execution_limitations.cpp \
- source/val/validate_function.cpp \
- source/val/validate_id.cpp \
- source/val/validate_image.cpp \
- source/val/validate_interfaces.cpp \
- source/val/validate_instruction.cpp \
- source/val/validate_memory.cpp \
- source/val/validate_memory_semantics.cpp \
- source/val/validate_mesh_shading.cpp \
- source/val/validate_misc.cpp \
- source/val/validate_mode_setting.cpp \
- source/val/validate_layout.cpp \
- source/val/validate_literals.cpp \
- source/val/validate_logicals.cpp \
- source/val/validate_non_uniform.cpp \
- source/val/validate_primitives.cpp \
- source/val/validate_ray_query.cpp \
- source/val/validate_ray_tracing.cpp \
- source/val/validate_ray_tracing_reorder.cpp \
- source/val/validate_scopes.cpp \
- source/val/validate_small_type_uses.cpp \
- source/val/validate_type.cpp
-
-SPVTOOLS_OPT_SRC_FILES := \
- source/opt/aggressive_dead_code_elim_pass.cpp \
- source/opt/amd_ext_to_khr.cpp \
- source/opt/analyze_live_input_pass.cpp \
- source/opt/basic_block.cpp \
- source/opt/block_merge_pass.cpp \
- source/opt/block_merge_util.cpp \
- source/opt/build_module.cpp \
- source/opt/cfg.cpp \
- source/opt/cfg_cleanup_pass.cpp \
- source/opt/ccp_pass.cpp \
- source/opt/code_sink.cpp \
- source/opt/combine_access_chains.cpp \
- source/opt/compact_ids_pass.cpp \
- source/opt/composite.cpp \
- source/opt/const_folding_rules.cpp \
- source/opt/constants.cpp \
- source/opt/control_dependence.cpp \
- source/opt/convert_to_sampled_image_pass.cpp \
- source/opt/convert_to_half_pass.cpp \
- source/opt/copy_prop_arrays.cpp \
- source/opt/dataflow.cpp \
- source/opt/dead_branch_elim_pass.cpp \
- source/opt/dead_insert_elim_pass.cpp \
- source/opt/dead_variable_elimination.cpp \
- source/opt/decoration_manager.cpp \
- source/opt/debug_info_manager.cpp \
- source/opt/def_use_manager.cpp \
- source/opt/desc_sroa.cpp \
- source/opt/desc_sroa_util.cpp \
- source/opt/dominator_analysis.cpp \
- source/opt/dominator_tree.cpp \
- source/opt/eliminate_dead_constant_pass.cpp \
- source/opt/eliminate_dead_functions_pass.cpp \
- source/opt/eliminate_dead_functions_util.cpp \
- source/opt/eliminate_dead_io_components_pass.cpp \
- source/opt/eliminate_dead_members_pass.cpp \
- source/opt/eliminate_dead_output_stores_pass.cpp \
- source/opt/feature_manager.cpp \
- source/opt/fix_func_call_arguments.cpp \
- source/opt/fix_storage_class.cpp \
- source/opt/flatten_decoration_pass.cpp \
- source/opt/fold.cpp \
- source/opt/folding_rules.cpp \
- source/opt/fold_spec_constant_op_and_composite_pass.cpp \
- source/opt/freeze_spec_constant_value_pass.cpp \
- source/opt/function.cpp \
- source/opt/graphics_robust_access_pass.cpp \
- source/opt/if_conversion.cpp \
- source/opt/inline_pass.cpp \
- source/opt/inline_exhaustive_pass.cpp \
- source/opt/inline_opaque_pass.cpp \
- source/opt/inst_bindless_check_pass.cpp \
- source/opt/inst_buff_addr_check_pass.cpp \
- source/opt/inst_debug_printf_pass.cpp \
- source/opt/instruction.cpp \
- source/opt/instruction_list.cpp \
- source/opt/instrument_pass.cpp \
- source/opt/interface_var_sroa.cpp \
- source/opt/interp_fixup_pass.cpp \
- source/opt/invocation_interlock_placement_pass.cpp \
- source/opt/ir_context.cpp \
- source/opt/ir_loader.cpp \
- source/opt/licm_pass.cpp \
- source/opt/liveness.cpp \
- source/opt/local_access_chain_convert_pass.cpp \
- source/opt/local_redundancy_elimination.cpp \
- source/opt/local_single_block_elim_pass.cpp \
- source/opt/local_single_store_elim_pass.cpp \
- source/opt/loop_dependence.cpp \
- source/opt/loop_dependence_helpers.cpp \
- source/opt/loop_descriptor.cpp \
- source/opt/loop_fission.cpp \
- source/opt/loop_fusion.cpp \
- source/opt/loop_fusion_pass.cpp \
- source/opt/loop_peeling.cpp \
- source/opt/loop_unroller.cpp \
- source/opt/loop_unswitch_pass.cpp \
- source/opt/loop_utils.cpp \
- source/opt/mem_pass.cpp \
- source/opt/merge_return_pass.cpp \
- source/opt/modify_maximal_reconvergence.cpp \
- source/opt/module.cpp \
- source/opt/optimizer.cpp \
- source/opt/pass.cpp \
- source/opt/pass_manager.cpp \
- source/opt/private_to_local_pass.cpp \
- source/opt/propagator.cpp \
- source/opt/reduce_load_size.cpp \
- source/opt/redundancy_elimination.cpp \
- source/opt/register_pressure.cpp \
- source/opt/relax_float_ops_pass.cpp \
- source/opt/remove_dontinline_pass.cpp \
- source/opt/remove_duplicates_pass.cpp \
- source/opt/remove_unused_interface_variables_pass.cpp \
- source/opt/replace_desc_array_access_using_var_index.cpp \
- source/opt/replace_invalid_opc.cpp \
- source/opt/scalar_analysis.cpp \
- source/opt/scalar_analysis_simplification.cpp \
- source/opt/scalar_replacement_pass.cpp \
- source/opt/set_spec_constant_default_value_pass.cpp \
- source/opt/simplification_pass.cpp \
- source/opt/spread_volatile_semantics.cpp \
- source/opt/ssa_rewrite_pass.cpp \
- source/opt/strength_reduction_pass.cpp \
- source/opt/strip_debug_info_pass.cpp \
- source/opt/strip_nonsemantic_info_pass.cpp \
- source/opt/struct_cfg_analysis.cpp \
- source/opt/switch_descriptorset_pass.cpp \
- source/opt/trim_capabilities_pass.cpp \
- source/opt/type_manager.cpp \
- source/opt/types.cpp \
- source/opt/unify_const_pass.cpp \
- source/opt/upgrade_memory_model.cpp \
- source/opt/value_number_table.cpp \
- source/opt/vector_dce.cpp \
- source/opt/workaround1209.cpp \
- source/opt/wrap_opkill.cpp
-
-# Locations of grammar files.
-#
-SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json
-SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.glsl.std.450.grammar.json
-SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.std.100.grammar.json
-SPV_DEBUGINFO_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.debuginfo.grammar.json
-SPV_CLDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json
-SPV_VKDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json
-
-define gen_spvtools_grammar_tables
-$(call generate-file-dir,$(1)/core.insts-unified1.inc)
-$(1)/core.insts-unified1.inc $(1)/operand.kinds-unified1.inc \
-$(1)/glsl.std.450.insts.inc \
-$(1)/opencl.std.insts.inc \
-: \
- $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- $(SPV_COREUNIFIED1_GRAMMAR) \
- $(SPV_GLSL_GRAMMAR) \
- $(SPV_OpenCL_GRAMMAR) \
- $(SPV_DEBUGINFO_GRAMMAR) \
- $(SPV_CLDEBUGINFO100_GRAMMAR)
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
- --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
- --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
- --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
- --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
- --core-insts-output=$(1)/core.insts-unified1.inc \
- --glsl-insts-output=$(1)/glsl.std.450.insts.inc \
- --opencl-insts-output=$(1)/opencl.std.insts.inc \
- --operand-kinds-output=$(1)/operand.kinds-unified1.inc \
- --output-language=c++
- @echo "[$(TARGET_ARCH_ABI)] Grammar (from unified1) : instructions & operands <= grammar JSON files"
-$(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-unified1.inc
-$(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-unified1.inc
-$(LOCAL_PATH)/source/ext_inst.cpp: \
- $(1)/glsl.std.450.insts.inc \
- $(1)/opencl.std.insts.inc \
- $(1)/debuginfo.insts.inc \
- $(1)/opencl.debuginfo.100.insts.inc \
- $(1)/nonsemantic.shader.debuginfo.100.insts.inc \
- $(1)/spv-amd-gcn-shader.insts.inc \
- $(1)/spv-amd-shader-ballot.insts.inc \
- $(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
- $(1)/spv-amd-shader-trinary-minmax.insts.inc
-$(LOCAL_PATH)/source/opt/amd_ext_to_khr.cpp: \
- $(1)/spv-amd-shader-ballot.insts.inc
-endef
-$(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
-
-
-define gen_spvtools_lang_headers
-# Generate language-specific headers. So far we only generate C headers
-# $1 is the output directory.
-# $2 is the base name of the header file, e.g. "DebugInfo".
-# $3 is the grammar file containing token definitions.
-$(call generate-file-dir,$(1)/$(2).h)
-$(1)/$(2).h : \
- $(LOCAL_PATH)/utils/generate_language_headers.py \
- $(3)
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_language_headers.py \
- --extinst-grammar=$(3) \
- --extinst-output-path=$(1)/$(2).h
- @echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar"
-$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
- : $(1)/$(2).h
-endef
-# We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
-$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
-
-
-define gen_spvtools_vendor_tables
-$(call generate-file-dir,$(1)/$(2).insts.inc)
-$(1)/$(2).insts.inc : \
- $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- $(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- --extinst-vendor-grammar=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json \
- --vendor-insts-output=$(1)/$(2).insts.inc \
- --vendor-operand-kind-prefix=$(3)
- @echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
-$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
-endef
-# Vendor and debug extended instruction sets, with grammars from SPIRV-Tools source tree.
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.shader.debuginfo.100,"SHDEBUG100_"))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.clspvreflection,""))
-$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.vkspreflection,""))
-
-define gen_spvtools_enum_string_mapping
-$(call generate-file-dir,$(1)/extension_enum.inc.inc)
-$(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \
- $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- $(SPV_COREUNIFIED1_GRAMMAR)
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
- --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
- --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
- --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
- --extension-enum-output=$(1)/extension_enum.inc \
- --enum-string-mapping-output=$(1)/enum_string_mapping.inc \
- --output-language=c++
- @echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files"
-# Generated header extension_enum.inc is transitively included by table.h, which is
-# used pervasively. Capture the pervasive dependency.
-$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
- : $(1)/extension_enum.inc
-$(LOCAL_PATH)/source/enum_string_mapping.cpp: $(1)/enum_string_mapping.inc
-endef
-$(eval $(call gen_spvtools_enum_string_mapping,$(SPVTOOLS_OUT_PATH)))
-
-define gen_spvtools_build_version_inc
-$(call generate-file-dir,$(1)/dummy_filename)
-$(1)/build-version.inc: \
- $(LOCAL_PATH)/utils/update_build_version.py \
- $(LOCAL_PATH)/CHANGES
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/update_build_version.py \
- $(LOCAL_PATH)/CHANGES $(1)/build-version.inc
- @echo "[$(TARGET_ARCH_ABI)] Generate : build-version.inc <= CHANGES"
-$(LOCAL_PATH)/source/software_version.cpp: $(1)/build-version.inc
-endef
-$(eval $(call gen_spvtools_build_version_inc,$(SPVTOOLS_OUT_PATH)))
-
-define gen_spvtools_generators_inc
-$(call generate-file-dir,$(1)/dummy_filename)
-$(1)/generators.inc: \
- $(LOCAL_PATH)/utils/generate_registry_tables.py \
- $(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml
- @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_registry_tables.py \
- --xml=$(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml \
- --generator-output=$(1)/generators.inc
- @echo "[$(TARGET_ARCH_ABI)] Generate : generators.inc <= spir-v.xml"
-$(LOCAL_PATH)/source/opcode.cpp: $(1)/generators.inc
-endef
-$(eval $(call gen_spvtools_generators_inc,$(SPVTOOLS_OUT_PATH)))
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- $(SPVHEADERS_LOCAL_PATH)/include \
- $(SPVTOOLS_OUT_PATH)
-LOCAL_EXPORT_C_INCLUDES := \
- $(LOCAL_PATH)/include
-LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror
-LOCAL_SRC_FILES:= $(SPVTOOLS_SRC_FILES)
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools-opt
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/source \
- $(SPVHEADERS_LOCAL_PATH)/include \
- $(SPVTOOLS_OUT_PATH)
-LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror
-LOCAL_STATIC_LIBRARIES:=SPIRV-Tools
-LOCAL_SRC_FILES:= $(SPVTOOLS_OPT_SRC_FILES)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/BUILD.gn b/BUILD.gn
index 5d0ab86..b405f51 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1,10 +1,10 @@
-# Copyright 2018 Google Inc. All rights reserved.
+# Copyright 2016 The SwiftShader Authors. All Rights Reserved.
#
# 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
+# 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,
@@ -12,1587 +12,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build_overrides/build.gni")
-import("//build_overrides/spirv_tools.gni")
-if (build_with_chromium) {
- import("//testing/test.gni")
- import("//third_party/protobuf/proto_library.gni")
-}
+import("src/Reactor/reactor.gni")
-# SPIRV-Tools may be part of multiple projects in the Chromium tree.
-# Only enable building executables if this is the main copy.
-abspath = get_path_info(".", "abspath")
-spvtools_chromium_third_party = (abspath == "//third_party/vulkan-deps/spirv-tools/src/")
-spvtools_build_executables = build_with_chromium && spvtools_chromium_third_party
-# Fuchsia also requires building the executables.
-# TODO(b/158002593): Avoid the use of dependent-specific variables.
-if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
- spvtools_build_executables = true
-}
-
-spirv_headers = spirv_tools_spirv_headers_dir
-spirv_is_winuwp = is_win && target_os == "winuwp"
-
-template("spvtools_core_tables") {
- assert(defined(invoker.version), "Need version in $target_name generation.")
-
- action("spvtools_core_tables_" + target_name) {
- script = "utils/generate_grammar_tables.py"
-
- version = invoker.version
-
- core_json_file =
- "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
- core_insts_file = "${target_gen_dir}/core.insts-$version.inc"
- operand_kinds_file = "${target_gen_dir}/operand.kinds-$version.inc"
- debuginfo_insts_file =
- "${spirv_headers}/include/spirv/unified1/extinst.debuginfo.grammar.json"
- cldebuginfo100_insts_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
-
- sources = [
- cldebuginfo100_insts_file,
- core_json_file,
- debuginfo_insts_file,
- ]
- outputs = [
- core_insts_file,
- operand_kinds_file,
- ]
- args = [
- "--spirv-core-grammar",
- rebase_path(core_json_file, root_build_dir),
- "--core-insts-output",
- rebase_path(core_insts_file, root_build_dir),
- "--extinst-debuginfo-grammar",
- rebase_path(debuginfo_insts_file, root_build_dir),
- "--extinst-cldebuginfo100-grammar",
- rebase_path(cldebuginfo100_insts_file, root_build_dir),
- "--operand-kinds-output",
- rebase_path(operand_kinds_file, root_build_dir),
- "--output-language",
- "c++"
- ]
- }
-}
-
-template("spvtools_core_enums") {
- assert(defined(invoker.version), "Need version in $target_name generation.")
-
- action("spvtools_core_enums_" + target_name) {
- script = "utils/generate_grammar_tables.py"
-
- version = invoker.version
-
- core_json_file =
- "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
- debuginfo_insts_file =
- "${spirv_headers}/include/spirv/unified1/extinst.debuginfo.grammar.json"
- cldebuginfo100_insts_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
-
- extension_enum_file = "${target_gen_dir}/extension_enum.inc"
- extension_map_file = "${target_gen_dir}/enum_string_mapping.inc"
-
- args = [
- "--spirv-core-grammar",
- rebase_path(core_json_file, root_build_dir),
- "--extinst-debuginfo-grammar",
- rebase_path(debuginfo_insts_file, root_build_dir),
- "--extinst-cldebuginfo100-grammar",
- rebase_path(cldebuginfo100_insts_file, root_build_dir),
- "--extension-enum-output",
- rebase_path(extension_enum_file, root_build_dir),
- "--enum-string-mapping-output",
- rebase_path(extension_map_file, root_build_dir),
- "--output-language",
- "c++"
- ]
- inputs = [
- core_json_file,
- debuginfo_insts_file,
- cldebuginfo100_insts_file,
- ]
- outputs = [
- extension_enum_file,
- extension_map_file,
- ]
- }
-}
-
-template("spvtools_glsl_tables") {
- assert(defined(invoker.version), "Need version in $target_name generation.")
-
- action("spvtools_glsl_tables_" + target_name) {
- script = "utils/generate_grammar_tables.py"
-
- version = invoker.version
-
- core_json_file =
- "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
- glsl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.glsl.std.450.grammar.json"
- debuginfo_insts_file =
- "${spirv_headers}/include/spirv/unified1/extinst.debuginfo.grammar.json"
- cldebuginfo100_insts_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
-
- glsl_insts_file = "${target_gen_dir}/glsl.std.450.insts.inc"
-
- args = [
- "--spirv-core-grammar",
- rebase_path(core_json_file, root_build_dir),
- "--extinst-debuginfo-grammar",
- rebase_path(debuginfo_insts_file, root_build_dir),
- "--extinst-cldebuginfo100-grammar",
- rebase_path(cldebuginfo100_insts_file, root_build_dir),
- "--extinst-glsl-grammar",
- rebase_path(glsl_json_file, root_build_dir),
- "--glsl-insts-output",
- rebase_path(glsl_insts_file, root_build_dir),
- "--output-language",
- "c++"
- ]
- inputs = [
- core_json_file,
- glsl_json_file,
- debuginfo_insts_file,
- cldebuginfo100_insts_file,
- ]
- outputs = [ glsl_insts_file ]
- }
-}
-
-template("spvtools_opencl_tables") {
- assert(defined(invoker.version), "Need version in $target_name generation.")
-
- action("spvtools_opencl_tables_" + target_name) {
- script = "utils/generate_grammar_tables.py"
-
- version = invoker.version
-
- core_json_file =
- "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
- opencl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.opencl.std.100.grammar.json"
- debuginfo_insts_file =
- "${spirv_headers}/include/spirv/unified1/extinst.debuginfo.grammar.json"
- cldebuginfo100_insts_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
-
- opencl_insts_file = "${target_gen_dir}/opencl.std.insts.inc"
-
- args = [
- "--spirv-core-grammar",
- rebase_path(core_json_file, root_build_dir),
- "--extinst-debuginfo-grammar",
- rebase_path(debuginfo_insts_file, root_build_dir),
- "--extinst-cldebuginfo100-grammar",
- rebase_path(cldebuginfo100_insts_file, root_build_dir),
- "--extinst-opencl-grammar",
- rebase_path(opencl_json_file, root_build_dir),
- "--opencl-insts-output",
- rebase_path(opencl_insts_file, root_build_dir),
- ]
- inputs = [
- core_json_file,
- opencl_json_file,
- debuginfo_insts_file,
- cldebuginfo100_insts_file,
- ]
- outputs = [ opencl_insts_file ]
- }
-}
-
-template("spvtools_language_header") {
- assert(defined(invoker.name), "Need name in $target_name generation.")
-
- action("spvtools_language_header_" + target_name) {
- script = "utils/generate_language_headers.py"
-
- name = invoker.name
- extinst_output_path = "${target_gen_dir}/${name}.h"
-
- args = [
- "--extinst-grammar",
- rebase_path(invoker.grammar_file, root_build_dir),
- "--extinst-output-path",
- rebase_path(extinst_output_path, root_build_dir),
- ]
- inputs = [ invoker.grammar_file ]
- outputs = [ "${extinst_output_path}" ]
- }
-}
-
-template("spvtools_vendor_table") {
- assert(defined(invoker.name), "Need name in $target_name generation.")
-
- action("spvtools_vendor_tables_" + target_name) {
- script = "utils/generate_grammar_tables.py"
-
- name = invoker.name
- extinst_vendor_grammar =
- "${spirv_headers}/include/spirv/unified1/extinst.${name}.grammar.json"
- extinst_file = "${target_gen_dir}/${name}.insts.inc"
-
- args = [
- "--extinst-vendor-grammar",
- rebase_path(extinst_vendor_grammar, root_build_dir),
- "--vendor-insts-output",
- rebase_path(extinst_file, root_build_dir),
- "--vendor-operand-kind-prefix",
- invoker.operand_kind_prefix,
- ]
- inputs = [ extinst_vendor_grammar ]
- outputs = [ extinst_file ]
- }
-}
-
-action("spvtools_generators_inc") {
- script = "utils/generate_registry_tables.py"
-
- # TODO(dsinclair): Make work for chrome
- xml_file = "${spirv_headers}/include/spirv/spir-v.xml"
- inc_file = "${target_gen_dir}/generators.inc"
-
- sources = [ xml_file ]
- outputs = [ inc_file ]
- args = [
- "--xml",
- rebase_path(xml_file, root_build_dir),
- "--generator",
- rebase_path(inc_file, root_build_dir),
- ]
-}
-
-action("spvtools_build_version") {
- script = "utils/update_build_version.py"
-
- changes_file = "CHANGES"
- inc_file = "${target_gen_dir}/build-version.inc"
-
- outputs = [ inc_file ]
- args = [
- rebase_path(changes_file, root_build_dir),
- rebase_path(inc_file, root_build_dir),
- ]
-}
-
-spvtools_core_tables("unified1") {
- version = "unified1"
-}
-spvtools_core_enums("unified1") {
- version = "unified1"
-}
-spvtools_glsl_tables("glsl1-0") {
- version = "1.0"
-}
-spvtools_opencl_tables("opencl1-0") {
- version = "1.0"
-}
-spvtools_language_header("debuginfo") {
- name = "DebugInfo"
- grammar_file =
- "${spirv_headers}/include/spirv/unified1/extinst.debuginfo.grammar.json"
-}
-spvtools_language_header("cldebuginfo100") {
- name = "OpenCLDebugInfo100"
- grammar_file = "${spirv_headers}/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"
-}
-spvtools_language_header("vkdebuginfo100") {
- name = "NonSemanticShaderDebugInfo100"
- grammar_file = "${spirv_headers}/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json"
-}
-
-spvtools_vendor_tables = [
- [
- "spv-amd-shader-explicit-vertex-parameter",
- "...nil...",
- ],
- [
- "spv-amd-shader-trinary-minmax",
- "...nil...",
- ],
- [
- "spv-amd-gcn-shader",
- "...nil...",
- ],
- [
- "spv-amd-shader-ballot",
- "...nil...",
- ],
- [
- "debuginfo",
- "...nil...",
- ],
- [
- "opencl.debuginfo.100",
- "CLDEBUG100_",
- ],
- [
- "nonsemantic.clspvreflection",
- "...nil...",
- ],
- [
- "nonsemantic.vkspreflection",
- "...nil...",
- ],
- [
- "nonsemantic.shader.debuginfo.100",
- "SHDEBUG100_",
- ],
-]
-
-foreach(table_def, spvtools_vendor_tables) {
- spvtools_vendor_table(table_def[0]) {
- name = table_def[0]
- operand_kind_prefix = table_def[1]
- }
-}
-
-config("spvtools_public_config") {
- include_dirs = [ "include" ]
-}
-
-config("spvtools_include_gen_dirs") {
- include_dirs = [ "$target_gen_dir" ]
-}
-
-config("spvtools_internal_config") {
- include_dirs = [
- ".",
- "${spirv_headers}/include",
- ]
-
- configs = [
- ":spvtools_public_config",
- ":spvtools_include_gen_dirs",
- ]
-
+config("swiftshader_config") {
cflags = []
+ defines = []
+ asmflags = []
+
if (is_clang) {
- cflags += [
- "-Wno-implicit-fallthrough",
- "-Wno-newline-eof",
- "-Wno-unreachable-code-break",
- "-Wno-unreachable-code-return",
- ]
- } else if (!is_win) {
- # Work around a false-positive on a Skia GCC 10 builder.
- cflags += [ "-Wno-format-truncation" ]
- } else {
- # Make MSVC report the correct value for __cplusplus
- cflags += [ "/Zc:__cplusplus" ]
+ cflags += [ "-Wno-shadow" ]
}
- if (!is_win) {
- cflags += [ "-std=c++17" ]
- } else {
- cflags += [ "/std:c++17" ]
+ if (is_debug) {
+ if (swiftshader_startup_dialog) {
+ defines += [ "DEBUGGER_WAIT_DIALOG" ]
+ }
}
-}
+ if (is_win) {
+ # Disable MSVC warnings about std::aligned_storage being broken before
+ # VS 2017 15.8
+ defines += [ "_ENABLE_EXTENDED_ALIGNED_STORAGE" ]
-source_set("spvtools_headers") {
- sources = [
- "include/spirv-tools/instrument.hpp",
- "include/spirv-tools/libspirv.h",
- "include/spirv-tools/libspirv.hpp",
- "include/spirv-tools/linker.hpp",
- "include/spirv-tools/optimizer.hpp",
- ]
-
- public_configs = [ ":spvtools_public_config" ]
-}
-
-group("spvtools_language_headers") {
- public_deps = [
- ":spvtools_language_header_cldebuginfo100",
- ":spvtools_language_header_debuginfo",
- ":spvtools_language_header_vkdebuginfo100",
- ]
-}
-
-static_library("spvtools") {
- deps = [
- ":spvtools_core_tables_unified1",
- ":spvtools_generators_inc",
- ":spvtools_glsl_tables_glsl1-0",
- ":spvtools_language_header_cldebuginfo100",
- ":spvtools_language_header_debuginfo",
- ":spvtools_language_header_vkdebuginfo100",
- ":spvtools_opencl_tables_opencl1-0",
- ]
- foreach(table_def, spvtools_vendor_tables) {
- target_name = table_def[0]
- deps += [ ":spvtools_vendor_tables_$target_name" ]
+ # Diable some MSVC warnings.
+ if (!is_clang) {
+ cflags += [
+ "/wd4065", # switch statement contains 'default' but no 'case' labels
+ "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts
+ # of signed shorts.
+ ]
+ }
+ } else if (!is_debug) {
+ cflags += [ "-Os" ]
}
- sources = [
- "source/assembly_grammar.cpp",
- "source/assembly_grammar.h",
- "source/binary.cpp",
- "source/binary.h",
- "source/cfa.h",
- "source/common_debug_info.h",
- "source/diagnostic.cpp",
- "source/diagnostic.h",
- "source/disassemble.cpp",
- "source/disassemble.h",
- "source/enum_set.h",
- "source/enum_string_mapping.cpp",
- "source/enum_string_mapping.h",
- "source/ext_inst.cpp",
- "source/ext_inst.h",
- "source/extensions.cpp",
- "source/extensions.h",
- "source/instruction.h",
- "source/latest_version_glsl_std_450_header.h",
- "source/latest_version_opencl_std_header.h",
- "source/latest_version_spirv_header.h",
- "source/libspirv.cpp",
- "source/macro.h",
- "source/name_mapper.cpp",
- "source/name_mapper.h",
- "source/opcode.cpp",
- "source/opcode.h",
- "source/operand.cpp",
- "source/operand.h",
- "source/parsed_operand.cpp",
- "source/parsed_operand.h",
- "source/print.cpp",
- "source/print.h",
- "source/spirv_constant.h",
- "source/spirv_definition.h",
- "source/spirv_endian.cpp",
- "source/spirv_endian.h",
- "source/spirv_fuzzer_options.cpp",
- "source/spirv_fuzzer_options.h",
- "source/spirv_optimizer_options.cpp",
- "source/spirv_optimizer_options.h",
- "source/spirv_reducer_options.cpp",
- "source/spirv_reducer_options.h",
- "source/spirv_target_env.cpp",
- "source/spirv_target_env.h",
- "source/spirv_validator_options.cpp",
- "source/spirv_validator_options.h",
- "source/table.cpp",
- "source/table.h",
- "source/text.cpp",
- "source/text.h",
- "source/text_handler.cpp",
- "source/text_handler.h",
- "source/util/bit_vector.cpp",
- "source/util/bit_vector.h",
- "source/util/bitutils.h",
- "source/util/hash_combine.h",
- "source/util/hex_float.h",
- "source/util/ilist.h",
- "source/util/ilist_node.h",
- "source/util/make_unique.h",
- "source/util/parse_number.cpp",
- "source/util/parse_number.h",
- "source/util/small_vector.h",
- "source/util/string_utils.cpp",
- "source/util/string_utils.h",
- "source/util/timer.cpp",
- "source/util/timer.h",
- ]
-
- public_deps = [
- ":spvtools_core_enums_unified1",
- ":spvtools_headers",
- "${spirv_headers}:spv_headers",
- ]
-
if (build_with_chromium) {
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- }
- configs += [ ":spvtools_internal_config" ]
-}
-
-static_library("spvtools_val") {
- sources = [
- "source/val/basic_block.cpp",
- "source/val/basic_block.h",
- "source/val/construct.cpp",
- "source/val/construct.h",
- "source/val/decoration.h",
- "source/val/function.cpp",
- "source/val/function.h",
- "source/val/instruction.cpp",
- "source/val/validate.cpp",
- "source/val/validate.h",
- "source/val/validate_adjacency.cpp",
- "source/val/validate_annotation.cpp",
- "source/val/validate_arithmetics.cpp",
- "source/val/validate_atomics.cpp",
- "source/val/validate_barriers.cpp",
- "source/val/validate_bitwise.cpp",
- "source/val/validate_builtins.cpp",
- "source/val/validate_capability.cpp",
- "source/val/validate_cfg.cpp",
- "source/val/validate_composites.cpp",
- "source/val/validate_constants.cpp",
- "source/val/validate_conversion.cpp",
- "source/val/validate_debug.cpp",
- "source/val/validate_decorations.cpp",
- "source/val/validate_derivatives.cpp",
- "source/val/validate_execution_limitations.cpp",
- "source/val/validate_extensions.cpp",
- "source/val/validate_function.cpp",
- "source/val/validate_id.cpp",
- "source/val/validate_image.cpp",
- "source/val/validate_instruction.cpp",
- "source/val/validate_interfaces.cpp",
- "source/val/validate_layout.cpp",
- "source/val/validate_literals.cpp",
- "source/val/validate_logicals.cpp",
- "source/val/validate_memory.cpp",
- "source/val/validate_memory_semantics.cpp",
- "source/val/validate_memory_semantics.h",
- "source/val/validate_mesh_shading.cpp",
- "source/val/validate_misc.cpp",
- "source/val/validate_mode_setting.cpp",
- "source/val/validate_non_uniform.cpp",
- "source/val/validate_primitives.cpp",
- "source/val/validate_ray_query.cpp",
- "source/val/validate_ray_tracing.cpp",
- "source/val/validate_ray_tracing_reorder.cpp",
- "source/val/validate_scopes.cpp",
- "source/val/validate_scopes.h",
- "source/val/validate_small_type_uses.cpp",
- "source/val/validate_type.cpp",
- "source/val/validation_state.cpp",
- "source/val/validation_state.h",
- ]
-
- deps = [
- ":spvtools",
- ":spvtools_language_header_cldebuginfo100",
- ":spvtools_language_header_debuginfo",
- ":spvtools_language_header_vkdebuginfo100",
- ]
- public_deps = [ ":spvtools_headers" ]
-
- if (build_with_chromium) {
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- }
- configs += [ ":spvtools_internal_config" ]
-}
-
-static_library("spvtools_opt") {
- sources = [
- "source/opt/aggressive_dead_code_elim_pass.cpp",
- "source/opt/aggressive_dead_code_elim_pass.h",
- "source/opt/amd_ext_to_khr.cpp",
- "source/opt/amd_ext_to_khr.h",
- "source/opt/analyze_live_input_pass.cpp",
- "source/opt/analyze_live_input_pass.h",
- "source/opt/basic_block.cpp",
- "source/opt/basic_block.h",
- "source/opt/block_merge_pass.cpp",
- "source/opt/block_merge_pass.h",
- "source/opt/block_merge_util.cpp",
- "source/opt/block_merge_util.h",
- "source/opt/build_module.cpp",
- "source/opt/build_module.h",
- "source/opt/ccp_pass.cpp",
- "source/opt/ccp_pass.h",
- "source/opt/cfg.cpp",
- "source/opt/cfg.h",
- "source/opt/cfg_cleanup_pass.cpp",
- "source/opt/cfg_cleanup_pass.h",
- "source/opt/code_sink.cpp",
- "source/opt/code_sink.h",
- "source/opt/combine_access_chains.cpp",
- "source/opt/combine_access_chains.h",
- "source/opt/compact_ids_pass.cpp",
- "source/opt/compact_ids_pass.h",
- "source/opt/composite.cpp",
- "source/opt/composite.h",
- "source/opt/const_folding_rules.cpp",
- "source/opt/const_folding_rules.h",
- "source/opt/constants.cpp",
- "source/opt/constants.h",
- "source/opt/control_dependence.cpp",
- "source/opt/control_dependence.h",
- "source/opt/convert_to_half_pass.cpp",
- "source/opt/convert_to_half_pass.h",
- "source/opt/convert_to_sampled_image_pass.cpp",
- "source/opt/convert_to_sampled_image_pass.h",
- "source/opt/copy_prop_arrays.cpp",
- "source/opt/copy_prop_arrays.h",
- "source/opt/dataflow.cpp",
- "source/opt/dataflow.h",
- "source/opt/dead_branch_elim_pass.cpp",
- "source/opt/dead_branch_elim_pass.h",
- "source/opt/dead_insert_elim_pass.cpp",
- "source/opt/dead_insert_elim_pass.h",
- "source/opt/dead_variable_elimination.cpp",
- "source/opt/dead_variable_elimination.h",
- "source/opt/debug_info_manager.cpp",
- "source/opt/debug_info_manager.h",
- "source/opt/decoration_manager.cpp",
- "source/opt/decoration_manager.h",
- "source/opt/def_use_manager.cpp",
- "source/opt/def_use_manager.h",
- "source/opt/desc_sroa.cpp",
- "source/opt/desc_sroa.h",
- "source/opt/desc_sroa_util.cpp",
- "source/opt/desc_sroa_util.h",
- "source/opt/dominator_analysis.cpp",
- "source/opt/dominator_analysis.h",
- "source/opt/dominator_tree.cpp",
- "source/opt/dominator_tree.h",
- "source/opt/eliminate_dead_constant_pass.cpp",
- "source/opt/eliminate_dead_constant_pass.h",
- "source/opt/eliminate_dead_functions_pass.cpp",
- "source/opt/eliminate_dead_functions_pass.h",
- "source/opt/eliminate_dead_functions_util.cpp",
- "source/opt/eliminate_dead_functions_util.h",
- "source/opt/eliminate_dead_io_components_pass.cpp",
- "source/opt/eliminate_dead_io_components_pass.h",
- "source/opt/eliminate_dead_members_pass.cpp",
- "source/opt/eliminate_dead_members_pass.h",
- "source/opt/eliminate_dead_output_stores_pass.cpp",
- "source/opt/eliminate_dead_output_stores_pass.h",
- "source/opt/empty_pass.h",
- "source/opt/feature_manager.cpp",
- "source/opt/feature_manager.h",
- "source/opt/fix_func_call_arguments.cpp",
- "source/opt/fix_func_call_arguments.h",
- "source/opt/fix_storage_class.cpp",
- "source/opt/fix_storage_class.h",
- "source/opt/flatten_decoration_pass.cpp",
- "source/opt/flatten_decoration_pass.h",
- "source/opt/fold.cpp",
- "source/opt/fold.h",
- "source/opt/fold_spec_constant_op_and_composite_pass.cpp",
- "source/opt/fold_spec_constant_op_and_composite_pass.h",
- "source/opt/folding_rules.cpp",
- "source/opt/folding_rules.h",
- "source/opt/freeze_spec_constant_value_pass.cpp",
- "source/opt/freeze_spec_constant_value_pass.h",
- "source/opt/function.cpp",
- "source/opt/function.h",
- "source/opt/graphics_robust_access_pass.cpp",
- "source/opt/graphics_robust_access_pass.h",
- "source/opt/if_conversion.cpp",
- "source/opt/if_conversion.h",
- "source/opt/inline_exhaustive_pass.cpp",
- "source/opt/inline_exhaustive_pass.h",
- "source/opt/inline_opaque_pass.cpp",
- "source/opt/inline_opaque_pass.h",
- "source/opt/inline_pass.cpp",
- "source/opt/inline_pass.h",
- "source/opt/inst_bindless_check_pass.cpp",
- "source/opt/inst_bindless_check_pass.h",
- "source/opt/inst_buff_addr_check_pass.cpp",
- "source/opt/inst_buff_addr_check_pass.h",
- "source/opt/inst_debug_printf_pass.cpp",
- "source/opt/inst_debug_printf_pass.h",
- "source/opt/instruction.cpp",
- "source/opt/instruction.h",
- "source/opt/instruction_list.cpp",
- "source/opt/instruction_list.h",
- "source/opt/instrument_pass.cpp",
- "source/opt/instrument_pass.h",
- "source/opt/interface_var_sroa.cpp",
- "source/opt/interface_var_sroa.h",
- "source/opt/interp_fixup_pass.cpp",
- "source/opt/interp_fixup_pass.h",
- "source/opt/invocation_interlock_placement_pass.cpp",
- "source/opt/invocation_interlock_placement_pass.h",
- "source/opt/ir_builder.h",
- "source/opt/ir_context.cpp",
- "source/opt/ir_context.h",
- "source/opt/ir_loader.cpp",
- "source/opt/ir_loader.h",
- "source/opt/iterator.h",
- "source/opt/licm_pass.cpp",
- "source/opt/licm_pass.h",
- "source/opt/liveness.cpp",
- "source/opt/liveness.h",
- "source/opt/local_access_chain_convert_pass.cpp",
- "source/opt/local_access_chain_convert_pass.h",
- "source/opt/local_redundancy_elimination.cpp",
- "source/opt/local_redundancy_elimination.h",
- "source/opt/local_single_block_elim_pass.cpp",
- "source/opt/local_single_block_elim_pass.h",
- "source/opt/local_single_store_elim_pass.cpp",
- "source/opt/local_single_store_elim_pass.h",
- "source/opt/log.h",
- "source/opt/loop_dependence.cpp",
- "source/opt/loop_dependence.h",
- "source/opt/loop_dependence_helpers.cpp",
- "source/opt/loop_descriptor.cpp",
- "source/opt/loop_descriptor.h",
- "source/opt/loop_fission.cpp",
- "source/opt/loop_fission.h",
- "source/opt/loop_fusion.cpp",
- "source/opt/loop_fusion.h",
- "source/opt/loop_fusion_pass.cpp",
- "source/opt/loop_fusion_pass.h",
- "source/opt/loop_peeling.cpp",
- "source/opt/loop_peeling.h",
- "source/opt/loop_unroller.cpp",
- "source/opt/loop_unroller.h",
- "source/opt/loop_unswitch_pass.cpp",
- "source/opt/loop_unswitch_pass.h",
- "source/opt/loop_utils.cpp",
- "source/opt/loop_utils.h",
- "source/opt/mem_pass.cpp",
- "source/opt/mem_pass.h",
- "source/opt/merge_return_pass.cpp",
- "source/opt/merge_return_pass.h",
- "source/opt/modify_maximal_reconvergence.cpp",
- "source/opt/modify_maximal_reconvergence.h",
- "source/opt/module.cpp",
- "source/opt/module.h",
- "source/opt/null_pass.h",
- "source/opt/optimizer.cpp",
- "source/opt/pass.cpp",
- "source/opt/pass.h",
- "source/opt/pass_manager.cpp",
- "source/opt/pass_manager.h",
- "source/opt/passes.h",
- "source/opt/private_to_local_pass.cpp",
- "source/opt/private_to_local_pass.h",
- "source/opt/propagator.cpp",
- "source/opt/propagator.h",
- "source/opt/reduce_load_size.cpp",
- "source/opt/reduce_load_size.h",
- "source/opt/redundancy_elimination.cpp",
- "source/opt/redundancy_elimination.h",
- "source/opt/reflect.h",
- "source/opt/register_pressure.cpp",
- "source/opt/register_pressure.h",
- "source/opt/relax_float_ops_pass.cpp",
- "source/opt/relax_float_ops_pass.h",
- "source/opt/remove_dontinline_pass.cpp",
- "source/opt/remove_dontinline_pass.h",
- "source/opt/remove_duplicates_pass.cpp",
- "source/opt/remove_duplicates_pass.h",
- "source/opt/remove_unused_interface_variables_pass.cpp",
- "source/opt/remove_unused_interface_variables_pass.h",
- "source/opt/replace_desc_array_access_using_var_index.cpp",
- "source/opt/replace_desc_array_access_using_var_index.h",
- "source/opt/replace_invalid_opc.cpp",
- "source/opt/replace_invalid_opc.h",
- "source/opt/scalar_analysis.cpp",
- "source/opt/scalar_analysis.h",
- "source/opt/scalar_analysis_nodes.h",
- "source/opt/scalar_analysis_simplification.cpp",
- "source/opt/scalar_replacement_pass.cpp",
- "source/opt/scalar_replacement_pass.h",
- "source/opt/set_spec_constant_default_value_pass.cpp",
- "source/opt/set_spec_constant_default_value_pass.h",
- "source/opt/simplification_pass.cpp",
- "source/opt/simplification_pass.h",
- "source/opt/spread_volatile_semantics.cpp",
- "source/opt/spread_volatile_semantics.h",
- "source/opt/ssa_rewrite_pass.cpp",
- "source/opt/ssa_rewrite_pass.h",
- "source/opt/strength_reduction_pass.cpp",
- "source/opt/strength_reduction_pass.h",
- "source/opt/strip_debug_info_pass.cpp",
- "source/opt/strip_debug_info_pass.h",
- "source/opt/strip_nonsemantic_info_pass.cpp",
- "source/opt/strip_nonsemantic_info_pass.h",
- "source/opt/struct_cfg_analysis.cpp",
- "source/opt/struct_cfg_analysis.h",
- "source/opt/switch_descriptorset_pass.cpp",
- "source/opt/switch_descriptorset_pass.h",
- "source/opt/tree_iterator.h",
- "source/opt/trim_capabilities_pass.cpp",
- "source/opt/trim_capabilities_pass.h",
- "source/opt/type_manager.cpp",
- "source/opt/type_manager.h",
- "source/opt/types.cpp",
- "source/opt/types.h",
- "source/opt/unify_const_pass.cpp",
- "source/opt/unify_const_pass.h",
- "source/opt/upgrade_memory_model.cpp",
- "source/opt/upgrade_memory_model.h",
- "source/opt/value_number_table.cpp",
- "source/opt/value_number_table.h",
- "source/opt/vector_dce.cpp",
- "source/opt/vector_dce.h",
- "source/opt/workaround1209.cpp",
- "source/opt/workaround1209.h",
- "source/opt/wrap_opkill.cpp",
- "source/opt/wrap_opkill.h",
- ]
-
- deps = [
- ":spvtools",
- ":spvtools_language_header_debuginfo",
- ":spvtools_vendor_tables_spv-amd-shader-ballot",
- ]
- public_deps = [
- ":spvtools_headers",
- ":spvtools_language_header_cldebuginfo100",
- ":spvtools_language_header_vkdebuginfo100",
- ]
-
- if (build_with_chromium) {
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- }
- configs += [ ":spvtools_internal_config" ]
-}
-
-static_library("spvtools_link") {
- sources = [ "source/link/linker.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_opt",
- ":spvtools_val",
- ]
- public_deps = [ ":spvtools_headers" ]
- if (build_with_chromium) {
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- }
- configs += [ ":spvtools_internal_config" ]
-}
-
-static_library("spvtools_reduce") {
- sources = [
- "source/reduce/change_operand_reduction_opportunity.cpp",
- "source/reduce/change_operand_reduction_opportunity.h",
- "source/reduce/change_operand_to_undef_reduction_opportunity.cpp",
- "source/reduce/change_operand_to_undef_reduction_opportunity.h",
- "source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.cpp",
- "source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.h",
- "source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.cpp",
- "source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.h",
- "source/reduce/merge_blocks_reduction_opportunity.cpp",
- "source/reduce/merge_blocks_reduction_opportunity.h",
- "source/reduce/merge_blocks_reduction_opportunity_finder.cpp",
- "source/reduce/merge_blocks_reduction_opportunity_finder.h",
- "source/reduce/operand_to_const_reduction_opportunity_finder.cpp",
- "source/reduce/operand_to_const_reduction_opportunity_finder.h",
- "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.cpp",
- "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h",
- "source/reduce/operand_to_undef_reduction_opportunity_finder.cpp",
- "source/reduce/operand_to_undef_reduction_opportunity_finder.h",
- "source/reduce/reducer.cpp",
- "source/reduce/reducer.h",
- "source/reduce/reduction_opportunity.cpp",
- "source/reduce/reduction_opportunity.h",
- "source/reduce/reduction_opportunity_finder.cpp",
- "source/reduce/reduction_opportunity_finder.h",
- "source/reduce/reduction_pass.cpp",
- "source/reduce/reduction_pass.h",
- "source/reduce/reduction_util.cpp",
- "source/reduce/reduction_util.h",
- "source/reduce/remove_block_reduction_opportunity.cpp",
- "source/reduce/remove_block_reduction_opportunity.h",
- "source/reduce/remove_block_reduction_opportunity_finder.cpp",
- "source/reduce/remove_block_reduction_opportunity_finder.h",
- "source/reduce/remove_function_reduction_opportunity.cpp",
- "source/reduce/remove_function_reduction_opportunity.h",
- "source/reduce/remove_function_reduction_opportunity_finder.cpp",
- "source/reduce/remove_function_reduction_opportunity_finder.h",
- "source/reduce/remove_instruction_reduction_opportunity.cpp",
- "source/reduce/remove_instruction_reduction_opportunity.h",
- "source/reduce/remove_selection_reduction_opportunity.cpp",
- "source/reduce/remove_selection_reduction_opportunity.h",
- "source/reduce/remove_selection_reduction_opportunity_finder.cpp",
- "source/reduce/remove_selection_reduction_opportunity_finder.h",
- "source/reduce/remove_struct_member_reduction_opportunity.cpp",
- "source/reduce/remove_struct_member_reduction_opportunity.h",
- "source/reduce/remove_unused_instruction_reduction_opportunity_finder.cpp",
- "source/reduce/remove_unused_instruction_reduction_opportunity_finder.h",
- "source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp",
- "source/reduce/remove_unused_struct_member_reduction_opportunity_finder.h",
- "source/reduce/simple_conditional_branch_to_branch_opportunity_finder.cpp",
- "source/reduce/simple_conditional_branch_to_branch_opportunity_finder.h",
- "source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.cpp",
- "source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.h",
- "source/reduce/structured_construct_to_block_reduction_opportunity.cpp",
- "source/reduce/structured_construct_to_block_reduction_opportunity.h",
- "source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp",
- "source/reduce/structured_construct_to_block_reduction_opportunity_finder.h",
- "source/reduce/structured_loop_to_selection_reduction_opportunity.cpp",
- "source/reduce/structured_loop_to_selection_reduction_opportunity.h",
- "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.cpp",
- "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h",
- ]
- deps = [
- ":spvtools",
- ":spvtools_opt",
- ]
- public_deps = [ ":spvtools_headers" ]
- if (build_with_chromium) {
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- }
- configs += [ ":spvtools_internal_config" ]
-}
-
-if (build_with_chromium && spvtools_build_executables) {
- # The spirv-fuzz library is only built when in a Chromium checkout
- # due to its dependency on protobuf.
-
- proto_library("spvtools_fuzz_proto") {
- sources = [ "source/fuzz/protobufs/spvtoolsfuzz.proto" ]
- generate_python = false
- use_protobuf_full = true
- }
-
- static_library("spvtools_fuzz") {
- sources = [
- "source/fuzz/added_function_reducer.cpp",
- "source/fuzz/added_function_reducer.h",
- "source/fuzz/available_instructions.cpp",
- "source/fuzz/available_instructions.h",
- "source/fuzz/call_graph.cpp",
- "source/fuzz/call_graph.h",
- "source/fuzz/comparator_deep_blocks_first.h",
- "source/fuzz/counter_overflow_id_source.cpp",
- "source/fuzz/counter_overflow_id_source.h",
- "source/fuzz/data_descriptor.cpp",
- "source/fuzz/data_descriptor.h",
- "source/fuzz/equivalence_relation.h",
- "source/fuzz/fact_manager/constant_uniform_facts.cpp",
- "source/fuzz/fact_manager/constant_uniform_facts.h",
- "source/fuzz/fact_manager/data_synonym_and_id_equation_facts.cpp",
- "source/fuzz/fact_manager/data_synonym_and_id_equation_facts.h",
- "source/fuzz/fact_manager/dead_block_facts.cpp",
- "source/fuzz/fact_manager/dead_block_facts.h",
- "source/fuzz/fact_manager/fact_manager.cpp",
- "source/fuzz/fact_manager/fact_manager.h",
- "source/fuzz/fact_manager/irrelevant_value_facts.cpp",
- "source/fuzz/fact_manager/irrelevant_value_facts.h",
- "source/fuzz/fact_manager/livesafe_function_facts.cpp",
- "source/fuzz/fact_manager/livesafe_function_facts.h",
- "source/fuzz/force_render_red.cpp",
- "source/fuzz/force_render_red.h",
- "source/fuzz/fuzzer.cpp",
- "source/fuzz/fuzzer.h",
- "source/fuzz/fuzzer_context.cpp",
- "source/fuzz/fuzzer_context.h",
- "source/fuzz/fuzzer_pass.cpp",
- "source/fuzz/fuzzer_pass.h",
- "source/fuzz/fuzzer_pass_add_access_chains.cpp",
- "source/fuzz/fuzzer_pass_add_access_chains.h",
- "source/fuzz/fuzzer_pass_add_bit_instruction_synonyms.cpp",
- "source/fuzz/fuzzer_pass_add_bit_instruction_synonyms.h",
- "source/fuzz/fuzzer_pass_add_composite_extract.cpp",
- "source/fuzz/fuzzer_pass_add_composite_extract.h",
- "source/fuzz/fuzzer_pass_add_composite_inserts.cpp",
- "source/fuzz/fuzzer_pass_add_composite_inserts.h",
- "source/fuzz/fuzzer_pass_add_composite_types.cpp",
- "source/fuzz/fuzzer_pass_add_composite_types.h",
- "source/fuzz/fuzzer_pass_add_copy_memory.cpp",
- "source/fuzz/fuzzer_pass_add_copy_memory.h",
- "source/fuzz/fuzzer_pass_add_dead_blocks.cpp",
- "source/fuzz/fuzzer_pass_add_dead_blocks.h",
- "source/fuzz/fuzzer_pass_add_dead_breaks.cpp",
- "source/fuzz/fuzzer_pass_add_dead_breaks.h",
- "source/fuzz/fuzzer_pass_add_dead_continues.cpp",
- "source/fuzz/fuzzer_pass_add_dead_continues.h",
- "source/fuzz/fuzzer_pass_add_equation_instructions.cpp",
- "source/fuzz/fuzzer_pass_add_equation_instructions.h",
- "source/fuzz/fuzzer_pass_add_function_calls.cpp",
- "source/fuzz/fuzzer_pass_add_function_calls.h",
- "source/fuzz/fuzzer_pass_add_global_variables.cpp",
- "source/fuzz/fuzzer_pass_add_global_variables.h",
- "source/fuzz/fuzzer_pass_add_image_sample_unused_components.cpp",
- "source/fuzz/fuzzer_pass_add_image_sample_unused_components.h",
- "source/fuzz/fuzzer_pass_add_loads.cpp",
- "source/fuzz/fuzzer_pass_add_loads.h",
- "source/fuzz/fuzzer_pass_add_local_variables.cpp",
- "source/fuzz/fuzzer_pass_add_local_variables.h",
- "source/fuzz/fuzzer_pass_add_loop_preheaders.cpp",
- "source/fuzz/fuzzer_pass_add_loop_preheaders.h",
- "source/fuzz/fuzzer_pass_add_loops_to_create_int_constant_synonyms.cpp",
- "source/fuzz/fuzzer_pass_add_loops_to_create_int_constant_synonyms.h",
- "source/fuzz/fuzzer_pass_add_no_contraction_decorations.cpp",
- "source/fuzz/fuzzer_pass_add_no_contraction_decorations.h",
- "source/fuzz/fuzzer_pass_add_opphi_synonyms.cpp",
- "source/fuzz/fuzzer_pass_add_opphi_synonyms.h",
- "source/fuzz/fuzzer_pass_add_parameters.cpp",
- "source/fuzz/fuzzer_pass_add_parameters.h",
- "source/fuzz/fuzzer_pass_add_relaxed_decorations.cpp",
- "source/fuzz/fuzzer_pass_add_relaxed_decorations.h",
- "source/fuzz/fuzzer_pass_add_stores.cpp",
- "source/fuzz/fuzzer_pass_add_stores.h",
- "source/fuzz/fuzzer_pass_add_synonyms.cpp",
- "source/fuzz/fuzzer_pass_add_synonyms.h",
- "source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.cpp",
- "source/fuzz/fuzzer_pass_add_vector_shuffle_instructions.h",
- "source/fuzz/fuzzer_pass_adjust_branch_weights.cpp",
- "source/fuzz/fuzzer_pass_adjust_branch_weights.h",
- "source/fuzz/fuzzer_pass_adjust_function_controls.cpp",
- "source/fuzz/fuzzer_pass_adjust_function_controls.h",
- "source/fuzz/fuzzer_pass_adjust_loop_controls.cpp",
- "source/fuzz/fuzzer_pass_adjust_loop_controls.h",
- "source/fuzz/fuzzer_pass_adjust_memory_operands_masks.cpp",
- "source/fuzz/fuzzer_pass_adjust_memory_operands_masks.h",
- "source/fuzz/fuzzer_pass_adjust_selection_controls.cpp",
- "source/fuzz/fuzzer_pass_adjust_selection_controls.h",
- "source/fuzz/fuzzer_pass_apply_id_synonyms.cpp",
- "source/fuzz/fuzzer_pass_apply_id_synonyms.h",
- "source/fuzz/fuzzer_pass_construct_composites.cpp",
- "source/fuzz/fuzzer_pass_construct_composites.h",
- "source/fuzz/fuzzer_pass_copy_objects.cpp",
- "source/fuzz/fuzzer_pass_copy_objects.h",
- "source/fuzz/fuzzer_pass_donate_modules.cpp",
- "source/fuzz/fuzzer_pass_donate_modules.h",
- "source/fuzz/fuzzer_pass_duplicate_regions_with_selections.cpp",
- "source/fuzz/fuzzer_pass_duplicate_regions_with_selections.h",
- "source/fuzz/fuzzer_pass_expand_vector_reductions.cpp",
- "source/fuzz/fuzzer_pass_expand_vector_reductions.h",
- "source/fuzz/fuzzer_pass_flatten_conditional_branches.cpp",
- "source/fuzz/fuzzer_pass_flatten_conditional_branches.h",
- "source/fuzz/fuzzer_pass_inline_functions.cpp",
- "source/fuzz/fuzzer_pass_inline_functions.h",
- "source/fuzz/fuzzer_pass_interchange_signedness_of_integer_operands.cpp",
- "source/fuzz/fuzzer_pass_interchange_signedness_of_integer_operands.h",
- "source/fuzz/fuzzer_pass_interchange_zero_like_constants.cpp",
- "source/fuzz/fuzzer_pass_interchange_zero_like_constants.h",
- "source/fuzz/fuzzer_pass_invert_comparison_operators.cpp",
- "source/fuzz/fuzzer_pass_invert_comparison_operators.h",
- "source/fuzz/fuzzer_pass_make_vector_operations_dynamic.cpp",
- "source/fuzz/fuzzer_pass_make_vector_operations_dynamic.h",
- "source/fuzz/fuzzer_pass_merge_blocks.cpp",
- "source/fuzz/fuzzer_pass_merge_blocks.h",
- "source/fuzz/fuzzer_pass_merge_function_returns.cpp",
- "source/fuzz/fuzzer_pass_merge_function_returns.h",
- "source/fuzz/fuzzer_pass_mutate_pointers.cpp",
- "source/fuzz/fuzzer_pass_mutate_pointers.h",
- "source/fuzz/fuzzer_pass_obfuscate_constants.cpp",
- "source/fuzz/fuzzer_pass_obfuscate_constants.h",
- "source/fuzz/fuzzer_pass_outline_functions.cpp",
- "source/fuzz/fuzzer_pass_outline_functions.h",
- "source/fuzz/fuzzer_pass_permute_blocks.cpp",
- "source/fuzz/fuzzer_pass_permute_blocks.h",
- "source/fuzz/fuzzer_pass_permute_function_parameters.cpp",
- "source/fuzz/fuzzer_pass_permute_function_parameters.h",
- "source/fuzz/fuzzer_pass_permute_function_variables.cpp",
- "source/fuzz/fuzzer_pass_permute_function_variables.h",
- "source/fuzz/fuzzer_pass_permute_instructions.cpp",
- "source/fuzz/fuzzer_pass_permute_instructions.h",
- "source/fuzz/fuzzer_pass_permute_phi_operands.cpp",
- "source/fuzz/fuzzer_pass_permute_phi_operands.h",
- "source/fuzz/fuzzer_pass_propagate_instructions_down.cpp",
- "source/fuzz/fuzzer_pass_propagate_instructions_down.h",
- "source/fuzz/fuzzer_pass_propagate_instructions_up.cpp",
- "source/fuzz/fuzzer_pass_propagate_instructions_up.h",
- "source/fuzz/fuzzer_pass_push_ids_through_variables.cpp",
- "source/fuzz/fuzzer_pass_push_ids_through_variables.h",
- "source/fuzz/fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.cpp",
- "source/fuzz/fuzzer_pass_replace_adds_subs_muls_with_carrying_extended.h",
- "source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.cpp",
- "source/fuzz/fuzzer_pass_replace_branches_from_dead_blocks_with_exits.h",
- "source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.cpp",
- "source/fuzz/fuzzer_pass_replace_copy_memories_with_loads_stores.h",
- "source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.cpp",
- "source/fuzz/fuzzer_pass_replace_copy_objects_with_stores_loads.h",
- "source/fuzz/fuzzer_pass_replace_irrelevant_ids.cpp",
- "source/fuzz/fuzzer_pass_replace_irrelevant_ids.h",
- "source/fuzz/fuzzer_pass_replace_linear_algebra_instructions.cpp",
- "source/fuzz/fuzzer_pass_replace_linear_algebra_instructions.h",
- "source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.cpp",
- "source/fuzz/fuzzer_pass_replace_loads_stores_with_copy_memories.h",
- "source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.cpp",
- "source/fuzz/fuzzer_pass_replace_opphi_ids_from_dead_predecessors.h",
- "source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.cpp",
- "source/fuzz/fuzzer_pass_replace_opselects_with_conditional_branches.h",
- "source/fuzz/fuzzer_pass_replace_parameter_with_global.cpp",
- "source/fuzz/fuzzer_pass_replace_parameter_with_global.h",
- "source/fuzz/fuzzer_pass_replace_params_with_struct.cpp",
- "source/fuzz/fuzzer_pass_replace_params_with_struct.h",
- "source/fuzz/fuzzer_pass_split_blocks.cpp",
- "source/fuzz/fuzzer_pass_split_blocks.h",
- "source/fuzz/fuzzer_pass_swap_commutable_operands.cpp",
- "source/fuzz/fuzzer_pass_swap_commutable_operands.h",
- "source/fuzz/fuzzer_pass_swap_conditional_branch_operands.cpp",
- "source/fuzz/fuzzer_pass_swap_conditional_branch_operands.h",
- "source/fuzz/fuzzer_pass_swap_functions.cpp",
- "source/fuzz/fuzzer_pass_swap_functions.h",
- "source/fuzz/fuzzer_pass_toggle_access_chain_instruction.cpp",
- "source/fuzz/fuzzer_pass_toggle_access_chain_instruction.h",
- "source/fuzz/fuzzer_pass_wrap_regions_in_selections.cpp",
- "source/fuzz/fuzzer_pass_wrap_regions_in_selections.h",
- "source/fuzz/fuzzer_pass_wrap_vector_synonym.cpp",
- "source/fuzz/fuzzer_pass_wrap_vector_synonym.h",
- "source/fuzz/fuzzer_util.cpp",
- "source/fuzz/fuzzer_util.h",
- "source/fuzz/id_use_descriptor.cpp",
- "source/fuzz/id_use_descriptor.h",
- "source/fuzz/instruction_descriptor.cpp",
- "source/fuzz/instruction_descriptor.h",
- "source/fuzz/instruction_message.cpp",
- "source/fuzz/instruction_message.h",
- "source/fuzz/overflow_id_source.cpp",
- "source/fuzz/overflow_id_source.h",
- "source/fuzz/pass_management/repeated_pass_instances.h",
- "source/fuzz/pass_management/repeated_pass_manager.cpp",
- "source/fuzz/pass_management/repeated_pass_manager.h",
- "source/fuzz/pass_management/repeated_pass_manager_looped_with_recommendations.cpp",
- "source/fuzz/pass_management/repeated_pass_manager_looped_with_recommendations.h",
- "source/fuzz/pass_management/repeated_pass_manager_random_with_recommendations.cpp",
- "source/fuzz/pass_management/repeated_pass_manager_random_with_recommendations.h",
- "source/fuzz/pass_management/repeated_pass_manager_simple.cpp",
- "source/fuzz/pass_management/repeated_pass_manager_simple.h",
- "source/fuzz/pass_management/repeated_pass_recommender.cpp",
- "source/fuzz/pass_management/repeated_pass_recommender.h",
- "source/fuzz/pass_management/repeated_pass_recommender_standard.cpp",
- "source/fuzz/pass_management/repeated_pass_recommender_standard.h",
- "source/fuzz/protobufs/spirvfuzz_protobufs.h",
- "source/fuzz/pseudo_random_generator.cpp",
- "source/fuzz/pseudo_random_generator.h",
- "source/fuzz/random_generator.cpp",
- "source/fuzz/random_generator.h",
- "source/fuzz/replayer.cpp",
- "source/fuzz/replayer.h",
- "source/fuzz/shrinker.cpp",
- "source/fuzz/shrinker.h",
- "source/fuzz/transformation.cpp",
- "source/fuzz/transformation.h",
- "source/fuzz/transformation_access_chain.cpp",
- "source/fuzz/transformation_access_chain.h",
- "source/fuzz/transformation_add_bit_instruction_synonym.cpp",
- "source/fuzz/transformation_add_bit_instruction_synonym.h",
- "source/fuzz/transformation_add_constant_boolean.cpp",
- "source/fuzz/transformation_add_constant_boolean.h",
- "source/fuzz/transformation_add_constant_composite.cpp",
- "source/fuzz/transformation_add_constant_composite.h",
- "source/fuzz/transformation_add_constant_null.cpp",
- "source/fuzz/transformation_add_constant_null.h",
- "source/fuzz/transformation_add_constant_scalar.cpp",
- "source/fuzz/transformation_add_constant_scalar.h",
- "source/fuzz/transformation_add_copy_memory.cpp",
- "source/fuzz/transformation_add_copy_memory.h",
- "source/fuzz/transformation_add_dead_block.cpp",
- "source/fuzz/transformation_add_dead_block.h",
- "source/fuzz/transformation_add_dead_break.cpp",
- "source/fuzz/transformation_add_dead_break.h",
- "source/fuzz/transformation_add_dead_continue.cpp",
- "source/fuzz/transformation_add_dead_continue.h",
- "source/fuzz/transformation_add_early_terminator_wrapper.cpp",
- "source/fuzz/transformation_add_early_terminator_wrapper.h",
- "source/fuzz/transformation_add_function.cpp",
- "source/fuzz/transformation_add_function.h",
- "source/fuzz/transformation_add_global_undef.cpp",
- "source/fuzz/transformation_add_global_undef.h",
- "source/fuzz/transformation_add_global_variable.cpp",
- "source/fuzz/transformation_add_global_variable.h",
- "source/fuzz/transformation_add_image_sample_unused_components.cpp",
- "source/fuzz/transformation_add_image_sample_unused_components.h",
- "source/fuzz/transformation_add_local_variable.cpp",
- "source/fuzz/transformation_add_local_variable.h",
- "source/fuzz/transformation_add_loop_preheader.cpp",
- "source/fuzz/transformation_add_loop_preheader.h",
- "source/fuzz/transformation_add_loop_to_create_int_constant_synonym.cpp",
- "source/fuzz/transformation_add_loop_to_create_int_constant_synonym.h",
- "source/fuzz/transformation_add_no_contraction_decoration.cpp",
- "source/fuzz/transformation_add_no_contraction_decoration.h",
- "source/fuzz/transformation_add_opphi_synonym.cpp",
- "source/fuzz/transformation_add_opphi_synonym.h",
- "source/fuzz/transformation_add_parameter.cpp",
- "source/fuzz/transformation_add_parameter.h",
- "source/fuzz/transformation_add_relaxed_decoration.cpp",
- "source/fuzz/transformation_add_relaxed_decoration.h",
- "source/fuzz/transformation_add_spec_constant_op.cpp",
- "source/fuzz/transformation_add_spec_constant_op.h",
- "source/fuzz/transformation_add_synonym.cpp",
- "source/fuzz/transformation_add_synonym.h",
- "source/fuzz/transformation_add_type_array.cpp",
- "source/fuzz/transformation_add_type_array.h",
- "source/fuzz/transformation_add_type_boolean.cpp",
- "source/fuzz/transformation_add_type_boolean.h",
- "source/fuzz/transformation_add_type_float.cpp",
- "source/fuzz/transformation_add_type_float.h",
- "source/fuzz/transformation_add_type_function.cpp",
- "source/fuzz/transformation_add_type_function.h",
- "source/fuzz/transformation_add_type_int.cpp",
- "source/fuzz/transformation_add_type_int.h",
- "source/fuzz/transformation_add_type_matrix.cpp",
- "source/fuzz/transformation_add_type_matrix.h",
- "source/fuzz/transformation_add_type_pointer.cpp",
- "source/fuzz/transformation_add_type_pointer.h",
- "source/fuzz/transformation_add_type_struct.cpp",
- "source/fuzz/transformation_add_type_struct.h",
- "source/fuzz/transformation_add_type_vector.cpp",
- "source/fuzz/transformation_add_type_vector.h",
- "source/fuzz/transformation_adjust_branch_weights.cpp",
- "source/fuzz/transformation_adjust_branch_weights.h",
- "source/fuzz/transformation_composite_construct.cpp",
- "source/fuzz/transformation_composite_construct.h",
- "source/fuzz/transformation_composite_extract.cpp",
- "source/fuzz/transformation_composite_extract.h",
- "source/fuzz/transformation_composite_insert.cpp",
- "source/fuzz/transformation_composite_insert.h",
- "source/fuzz/transformation_compute_data_synonym_fact_closure.cpp",
- "source/fuzz/transformation_compute_data_synonym_fact_closure.h",
- "source/fuzz/transformation_context.cpp",
- "source/fuzz/transformation_context.h",
- "source/fuzz/transformation_duplicate_region_with_selection.cpp",
- "source/fuzz/transformation_duplicate_region_with_selection.h",
- "source/fuzz/transformation_equation_instruction.cpp",
- "source/fuzz/transformation_equation_instruction.h",
- "source/fuzz/transformation_expand_vector_reduction.cpp",
- "source/fuzz/transformation_expand_vector_reduction.h",
- "source/fuzz/transformation_flatten_conditional_branch.cpp",
- "source/fuzz/transformation_flatten_conditional_branch.h",
- "source/fuzz/transformation_function_call.cpp",
- "source/fuzz/transformation_function_call.h",
- "source/fuzz/transformation_inline_function.cpp",
- "source/fuzz/transformation_inline_function.h",
- "source/fuzz/transformation_invert_comparison_operator.cpp",
- "source/fuzz/transformation_invert_comparison_operator.h",
- "source/fuzz/transformation_load.cpp",
- "source/fuzz/transformation_load.h",
- "source/fuzz/transformation_make_vector_operation_dynamic.cpp",
- "source/fuzz/transformation_make_vector_operation_dynamic.h",
- "source/fuzz/transformation_merge_blocks.cpp",
- "source/fuzz/transformation_merge_blocks.h",
- "source/fuzz/transformation_merge_function_returns.cpp",
- "source/fuzz/transformation_merge_function_returns.h",
- "source/fuzz/transformation_move_block_down.cpp",
- "source/fuzz/transformation_move_block_down.h",
- "source/fuzz/transformation_move_instruction_down.cpp",
- "source/fuzz/transformation_move_instruction_down.h",
- "source/fuzz/transformation_mutate_pointer.cpp",
- "source/fuzz/transformation_mutate_pointer.h",
- "source/fuzz/transformation_outline_function.cpp",
- "source/fuzz/transformation_outline_function.h",
- "source/fuzz/transformation_permute_function_parameters.cpp",
- "source/fuzz/transformation_permute_function_parameters.h",
- "source/fuzz/transformation_permute_phi_operands.cpp",
- "source/fuzz/transformation_permute_phi_operands.h",
- "source/fuzz/transformation_propagate_instruction_down.cpp",
- "source/fuzz/transformation_propagate_instruction_down.h",
- "source/fuzz/transformation_propagate_instruction_up.cpp",
- "source/fuzz/transformation_propagate_instruction_up.h",
- "source/fuzz/transformation_push_id_through_variable.cpp",
- "source/fuzz/transformation_push_id_through_variable.h",
- "source/fuzz/transformation_record_synonymous_constants.cpp",
- "source/fuzz/transformation_record_synonymous_constants.h",
- "source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.cpp",
- "source/fuzz/transformation_replace_add_sub_mul_with_carrying_extended.h",
- "source/fuzz/transformation_replace_boolean_constant_with_constant_binary.cpp",
- "source/fuzz/transformation_replace_boolean_constant_with_constant_binary.h",
- "source/fuzz/transformation_replace_branch_from_dead_block_with_exit.cpp",
- "source/fuzz/transformation_replace_branch_from_dead_block_with_exit.h",
- "source/fuzz/transformation_replace_constant_with_uniform.cpp",
- "source/fuzz/transformation_replace_constant_with_uniform.h",
- "source/fuzz/transformation_replace_copy_memory_with_load_store.cpp",
- "source/fuzz/transformation_replace_copy_memory_with_load_store.h",
- "source/fuzz/transformation_replace_copy_object_with_store_load.cpp",
- "source/fuzz/transformation_replace_copy_object_with_store_load.h",
- "source/fuzz/transformation_replace_id_with_synonym.cpp",
- "source/fuzz/transformation_replace_id_with_synonym.h",
- "source/fuzz/transformation_replace_irrelevant_id.cpp",
- "source/fuzz/transformation_replace_irrelevant_id.h",
- "source/fuzz/transformation_replace_linear_algebra_instruction.cpp",
- "source/fuzz/transformation_replace_linear_algebra_instruction.h",
- "source/fuzz/transformation_replace_load_store_with_copy_memory.cpp",
- "source/fuzz/transformation_replace_load_store_with_copy_memory.h",
- "source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.cpp",
- "source/fuzz/transformation_replace_opphi_id_from_dead_predecessor.h",
- "source/fuzz/transformation_replace_opselect_with_conditional_branch.cpp",
- "source/fuzz/transformation_replace_opselect_with_conditional_branch.h",
- "source/fuzz/transformation_replace_parameter_with_global.cpp",
- "source/fuzz/transformation_replace_parameter_with_global.h",
- "source/fuzz/transformation_replace_params_with_struct.cpp",
- "source/fuzz/transformation_replace_params_with_struct.h",
- "source/fuzz/transformation_set_function_control.cpp",
- "source/fuzz/transformation_set_function_control.h",
- "source/fuzz/transformation_set_loop_control.cpp",
- "source/fuzz/transformation_set_loop_control.h",
- "source/fuzz/transformation_set_memory_operands_mask.cpp",
- "source/fuzz/transformation_set_memory_operands_mask.h",
- "source/fuzz/transformation_set_selection_control.cpp",
- "source/fuzz/transformation_set_selection_control.h",
- "source/fuzz/transformation_split_block.cpp",
- "source/fuzz/transformation_split_block.h",
- "source/fuzz/transformation_store.cpp",
- "source/fuzz/transformation_store.h",
- "source/fuzz/transformation_swap_commutable_operands.cpp",
- "source/fuzz/transformation_swap_commutable_operands.h",
- "source/fuzz/transformation_swap_conditional_branch_operands.cpp",
- "source/fuzz/transformation_swap_conditional_branch_operands.h",
- "source/fuzz/transformation_swap_function_variables.cpp",
- "source/fuzz/transformation_swap_function_variables.h",
- "source/fuzz/transformation_swap_two_functions.cpp",
- "source/fuzz/transformation_swap_two_functions.h",
- "source/fuzz/transformation_toggle_access_chain_instruction.cpp",
- "source/fuzz/transformation_toggle_access_chain_instruction.h",
- "source/fuzz/transformation_vector_shuffle.cpp",
- "source/fuzz/transformation_vector_shuffle.h",
- "source/fuzz/transformation_wrap_early_terminator_in_function.cpp",
- "source/fuzz/transformation_wrap_early_terminator_in_function.h",
- "source/fuzz/transformation_wrap_region_in_selection.cpp",
- "source/fuzz/transformation_wrap_region_in_selection.h",
- "source/fuzz/transformation_wrap_vector_synonym.cpp",
- "source/fuzz/transformation_wrap_vector_synonym.h",
- "source/fuzz/uniform_buffer_element_descriptor.cpp",
- "source/fuzz/uniform_buffer_element_descriptor.h",
- ]
- deps = [
- ":spvtools",
- ":spvtools_fuzz_proto",
- ":spvtools_opt",
- ":spvtools_reduce",
- "//third_party/protobuf:protobuf_full",
- ]
- public_deps = [ ":spvtools_headers" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- configs += [ ":spvtools_internal_config" ]
- }
-}
-
-group("SPIRV-Tools") {
- public_deps = [
- ":spvtools",
- ":spvtools_link",
- ":spvtools_opt",
- ":spvtools_reduce",
- ":spvtools_val",
- ]
-}
-
-# The tests are scoped to Chromium to avoid needing to write gtest integration.
-# See Chromium's third_party/googletest/BUILD.gn for a complete integration.
-if (build_with_chromium && spvtools_build_executables) {
- test("spvtools_test") {
- sources = [
- "test/assembly_context_test.cpp",
- "test/assembly_format_test.cpp",
- "test/binary_destroy_test.cpp",
- "test/binary_endianness_test.cpp",
- "test/binary_header_get_test.cpp",
- "test/binary_parse_test.cpp",
- "test/binary_strnlen_s_test.cpp",
- "test/binary_to_text.literal_test.cpp",
- "test/binary_to_text_test.cpp",
- "test/comment_test.cpp",
- "test/enum_set_test.cpp",
- "test/enum_string_mapping_test.cpp",
- "test/ext_inst.cldebug100_test.cpp",
- "test/ext_inst.debuginfo_test.cpp",
- "test/ext_inst.glsl_test.cpp",
- "test/ext_inst.opencl_test.cpp",
- "test/fix_word_test.cpp",
- "test/generator_magic_number_test.cpp",
- "test/hex_float_test.cpp",
- "test/immediate_int_test.cpp",
- "test/libspirv_macros_test.cpp",
- "test/name_mapper_test.cpp",
- "test/named_id_test.cpp",
- "test/opcode_make_test.cpp",
- "test/opcode_require_capabilities_test.cpp",
- "test/opcode_split_test.cpp",
- "test/opcode_table_get_test.cpp",
- "test/operand_capabilities_test.cpp",
- "test/operand_pattern_test.cpp",
- "test/operand_test.cpp",
- "test/target_env_test.cpp",
- "test/test_fixture.h",
- "test/text_advance_test.cpp",
- "test/text_destroy_test.cpp",
- "test/text_literal_test.cpp",
- "test/text_start_new_inst_test.cpp",
- "test/text_to_binary.annotation_test.cpp",
- "test/text_to_binary.barrier_test.cpp",
- "test/text_to_binary.constant_test.cpp",
- "test/text_to_binary.control_flow_test.cpp",
- "test/text_to_binary.debug_test.cpp",
- "test/text_to_binary.device_side_enqueue_test.cpp",
- "test/text_to_binary.extension_test.cpp",
- "test/text_to_binary.function_test.cpp",
- "test/text_to_binary.group_test.cpp",
- "test/text_to_binary.image_test.cpp",
- "test/text_to_binary.literal_test.cpp",
- "test/text_to_binary.memory_test.cpp",
- "test/text_to_binary.misc_test.cpp",
- "test/text_to_binary.mode_setting_test.cpp",
- "test/text_to_binary.pipe_storage_test.cpp",
- "test/text_to_binary.reserved_sampling_test.cpp",
- "test/text_to_binary.subgroup_dispatch_test.cpp",
- "test/text_to_binary.type_declaration_test.cpp",
- "test/text_to_binary_test.cpp",
- "test/text_word_get_test.cpp",
- "test/unit_spirv.cpp",
- "test/unit_spirv.h",
- ]
-
- deps = [
- ":spvtools",
- ":spvtools_language_header_cldebuginfo100",
- ":spvtools_language_header_debuginfo",
- ":spvtools_language_header_vkdebuginfo100",
- ":spvtools_val",
- "//testing/gmock",
- "//testing/gtest",
- "//testing/gtest:gtest_main",
- "//third_party/googletest:gmock",
- "//third_party/googletest:gtest",
- ]
-
if (is_clang) {
- cflags_cc = [ "-Wno-self-assign" ]
- }
+ if (current_cpu == "arm64") {
+ import("//build/config/arm.gni")
- configs += [ ":spvtools_internal_config" ]
+ if (arm_control_flow_integrity == "standard") {
+ cflags += [ "-mbranch-protection=standard" ]
+ asmflags += [ "-mbranch-protection=standard" ]
+ } else if (arm_control_flow_integrity == "pac") {
+ cflags += [ "-mbranch-protection=pac-ret" ]
+ asmflags += [ "-mbranch-protection=pac-ret" ]
+ } else {
+ assert(arm_control_flow_integrity == "none",
+ "Invalid branch protection option!")
+ }
+ }
+ }
}
}
-if (spirv_tools_standalone) {
- group("fuzzers") {
+group("swiftshader") {
+ data_deps = [
+ "src/Vulkan:icd_file",
+ "src/Vulkan:swiftshader_libvulkan",
+ ]
+}
+
+if (build_with_chromium) {
+ group("swiftshader_tests") {
testonly = true
- deps = [ "test/fuzzers" ]
- }
-}
-source_set("spvtools_software_version") {
- sources = [ "source/software_version.cpp" ]
- deps = [
- ":spvtools_build_version",
- ":spvtools_headers",
- ]
- configs += [ ":spvtools_internal_config" ]
-}
+ data_deps = [ "tests/SystemUnitTests:swiftshader_system_unittests" ]
-source_set("spvtools_tools_util") {
- sources = [
- "tools/util/flags.cpp",
- "tools/util/cli_consumer.cpp",
- "tools/util/cli_consumer.h",
- ]
- deps = [ ":spvtools_headers" ]
- configs += [ ":spvtools_internal_config" ]
-}
-
-if (spvtools_build_executables) {
- executable("spirv-as") {
- sources = [ "tools/as/as.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-
- executable("spirv-dis") {
- sources = [ "tools/dis/dis.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-
- executable("spirv-val") {
- sources = [ "tools/val/val.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ":spvtools_val",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-
- executable("spirv-cfg") {
- sources = [
- "tools/cfg/bin_to_dot.cpp",
- "tools/cfg/bin_to_dot.h",
- "tools/cfg/cfg.cpp",
- ]
- deps = [
- ":spvtools",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-
- executable("spirv-opt") {
- sources = [ "tools/opt/opt.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_opt",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ":spvtools_val",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-
- executable("spirv-link") {
- sources = [ "tools/link/linker.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_link",
- ":spvtools_opt",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ":spvtools_val",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-}
-
-if (!is_ios && !spirv_is_winuwp && build_with_chromium && spvtools_build_executables) {
- # iOS and UWP do not allow std::system calls which spirv-fuzz
- # requires. Additionally, spirv-fuzz is only built when in a
- # Chromium checkout due to its dependency on protobuf.
-
- executable("spirv-fuzz") {
- sources = [ "tools/fuzz/fuzz.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_fuzz",
- ":spvtools_opt",
- ":spvtools_reduce",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ":spvtools_val",
- "//third_party/protobuf:protobuf_full",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-}
-
-if (!is_ios && !spirv_is_winuwp && spvtools_build_executables) {
- # iOS and UWP do not allow std::system calls which spirv-reduce
- # requires.
-
- executable("spirv-reduce") {
- sources = [ "tools/reduce/reduce.cpp" ]
- deps = [
- ":spvtools",
- ":spvtools_opt",
- ":spvtools_reduce",
- ":spvtools_software_version",
- ":spvtools_tools_util",
- ":spvtools_val",
- ]
- configs += [ ":spvtools_internal_config" ]
- }
-}
-
-if (spvtools_build_executables){
- group("all_spirv_tools") {
- deps = [
- ":spirv-as",
- ":spirv-cfg",
- ":spirv-dis",
- ":spirv-link",
- ":spirv-opt",
- ":spirv-val",
- ]
- if (!is_ios && !spirv_is_winuwp && build_with_chromium) {
- deps += [ ":spirv-fuzz" ]
+ if (supports_llvm) {
+ data_deps +=
+ [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
}
- if (!is_ios && !spirv_is_winuwp) {
- deps += [ ":spirv-reduce" ]
+
+ if (supports_subzero) {
+ data_deps +=
+ [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
}
}
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ba173f..434fbb7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,10 @@
-# Copyright (c) 2015-2023 The Khronos Group Inc.
+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
#
# 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
+# 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,
@@ -12,415 +12,967 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.17.2)
+cmake_minimum_required(VERSION 3.13)
-project(spirv-tools)
+project(SwiftShader C CXX ASM)
-# Avoid a bug in CMake 3.22.1. By default it will set -std=c++11 for
-# targets in test/*, when those tests need -std=c++17.
-# https://github.com/KhronosGroup/SPIRV-Tools/issues/5340
-# The bug is fixed in CMake 3.22.2
-if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.22.1")
- if (${CMAKE_VERSION} VERSION_LESS "3.22.2")
- cmake_policy(SET CMP0128 NEW)
- endif()
+set(CMAKE_CXX_STANDARD 17)
+set(CXX_STANDARD_REQUIRED ON)
+# MSVC doesn't define __cplusplus by default
+if(MSVC)
+ string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus")
endif()
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+###########################################################
+# Detect system
+###########################################################
-enable_testing()
-set(SPIRV_TOOLS "SPIRV-Tools")
-
-include(GNUInstallDirs)
-
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-
-# Require at least C++17
-if(NOT CMAKE_CXX_STANDARD)
- set(CMAKE_CXX_STANDARD 17)
-endif()
-if(${CMAKE_CXX_STANDARD} LESS 17)
- message(FATAL_ERROR "SPIRV-Tools requires C++17 or later, but is configured for C++${CMAKE_CXX_STANDARD})")
-endif()
-set(CMAKE_CXX_EXTENSIONS OFF)
-
-
-option(ENABLE_RTTI "Enables RTTI" OFF)
-option(SPIRV_ALLOW_TIMERS "Allow timers via clock_gettime on supported platforms" ON)
-
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
- add_definitions(-DSPIRV_LINUX)
- set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS})
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
- add_definitions(-DSPIRV_EMSCRIPTEN)
-elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
- add_definitions(-DSPIRV_WINDOWS)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
- add_definitions(-DSPIRV_WINDOWS)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- add_definitions(-DSPIRV_MAC)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS")
- add_definitions(-DSPIRV_IOS)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "tvOS")
- add_definitions(-DSPIRV_TVOS)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "visionOS")
- add_definitions(-DSPIRV_VISIONOS)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
- add_definitions(-DSPIRV_ANDROID)
- set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS})
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
- add_definitions(-DSPIRV_FREEBSD)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
- add_definitions(-DSPIRV_OPENBSD)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
- add_definitions(-DSPIRV_FUCHSIA)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
- add_definitions(-DSPIRV_GNU)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "QNX")
- add_definitions(-DSPIRV_QNX)
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(LINUX TRUE)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+ set(ANDROID TRUE)
+ set(CMAKE_CXX_FLAGS "-DANDROID_NDK_BUILD")
+elseif(WIN32)
+elseif(APPLE)
+elseif(FUCHSIA)
+ # NOTE: Building for Fuchsia requires a Fuchsia CMake-based SDK.
+ # See https://fuchsia-review.googlesource.com/c/fuchsia/+/379673
+ find_package(FuchsiaLibraries)
else()
- message(FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!")
+ message(FATAL_ERROR "Platform is not supported")
endif()
-if (${SPIRV_TIMER_ENABLED})
- add_definitions(-DSPIRV_TIMER_ENABLED)
-endif()
-
-if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
- message(STATUS "No build type selected, default to Debug")
- set(CMAKE_BUILD_TYPE "Debug")
-endif()
-
-option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL})
-if(NOT ${SKIP_SPIRV_TOOLS_INSTALL})
- set(ENABLE_SPIRV_TOOLS_INSTALL ON)
-endif()
-
-option(SPIRV_BUILD_COMPRESSION "Build SPIR-V compressing codec" OFF)
-if(SPIRV_BUILD_COMPRESSION)
- message(FATAL_ERROR "SPIR-V compression codec has been removed from SPIR-V tools. "
- "Please remove SPIRV_BUILD_COMPRESSION from your build options.")
-endif(SPIRV_BUILD_COMPRESSION)
-
-option(SPIRV_BUILD_FUZZER "Build spirv-fuzz" OFF)
-
-set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
-
-option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF)
-
-option(SPIRV_WERROR "Enable error on warning" ON)
-if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
- set(COMPILER_IS_LIKE_GNU TRUE)
-endif()
-if(${COMPILER_IS_LIKE_GNU})
- set(SPIRV_WARNINGS -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers)
-
- if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Wno-self-assign)
- endif()
-
- option(SPIRV_WARN_EVERYTHING "Enable -Weverything" ${SPIRV_WARN_EVERYTHING})
- if(${SPIRV_WARN_EVERYTHING})
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(SPIRV_WARNINGS ${SPIRV_WARNINGS}
- -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded)
- elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Wpedantic -pedantic-errors)
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH "aarch64")
else()
- message(STATUS "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, "
- "so SPIRV_WARN_EVERYTHING has no effect")
+ set(ARCH "arm")
endif()
- endif()
-
- if(${SPIRV_WERROR})
- set(SPIRV_WARNINGS ${SPIRV_WARNINGS} -Werror)
- endif()
-elseif(MSVC)
- set(SPIRV_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4800 /wd4819)
-
- if(${SPIRV_WERROR})
- set(SPIRV_WARNINGS ${SPIRV_WARNINGS} /WX)
- endif()
-endif()
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
-
-option(SPIRV_COLOR_TERMINAL "Enable color terminal output" ON)
-if(${SPIRV_COLOR_TERMINAL})
- add_definitions(-DSPIRV_COLOR_TERMINAL)
-endif()
-
-option(SPIRV_LOG_DEBUG "Enable excessive debug output" OFF)
-if(${SPIRV_LOG_DEBUG})
- add_definitions(-DSPIRV_LOG_DEBUG)
-endif()
-
-if (DEFINED SPIRV_TOOLS_EXTRA_DEFINITIONS)
- add_definitions(${SPIRV_TOOLS_EXTRA_DEFINITIONS})
-endif()
-
-# Library build setting definitions:
-#
-# * SPIRV_TOOLS_BUILD_STATIC - ON or OFF - Defaults to ON.
-# If enabled the following targets will be created:
-# ${SPIRV_TOOLS}-static - STATIC library.
-# Has full public symbol visibility.
-# ${SPIRV_TOOLS}-shared - SHARED library.
-# Has default-hidden symbol visibility.
-# ${SPIRV_TOOLS} - will alias to one of above, based on BUILD_SHARED_LIBS.
-# If disabled the following targets will be created:
-# ${SPIRV_TOOLS} - either STATIC or SHARED based on SPIRV_TOOLS_LIBRARY_TYPE.
-# Has full public symbol visibility.
-# ${SPIRV_TOOLS}-shared - SHARED library.
-# Has default-hidden symbol visibility.
-#
-# * SPIRV_TOOLS_LIBRARY_TYPE - SHARED or STATIC.
-# Specifies the library type used for building SPIRV-Tools libraries.
-# Defaults to SHARED when BUILD_SHARED_LIBS=1, otherwise STATIC.
-#
-# * SPIRV_TOOLS_FULL_VISIBILITY - "${SPIRV_TOOLS}-static" or "${SPIRV_TOOLS}"
-# Evaluates to the SPIRV_TOOLS target library name that has no hidden symbols.
-# This is used by internal targets for accessing symbols that are non-public.
-# Note this target provides no API stability guarantees.
-#
-# Ideally, all of these will go away - see https://github.com/KhronosGroup/SPIRV-Tools/issues/3909.
-option(ENABLE_EXCEPTIONS_ON_MSVC "Build SPIRV-TOOLS with c++ exceptions enabled in MSVC" ON)
-option(SPIRV_TOOLS_BUILD_STATIC "Build ${SPIRV_TOOLS}-static target. ${SPIRV_TOOLS} will alias to ${SPIRV_TOOLS}-static or ${SPIRV_TOOLS}-shared based on BUILD_SHARED_LIBS" ON)
-if(SPIRV_TOOLS_BUILD_STATIC)
- set(SPIRV_TOOLS_FULL_VISIBILITY ${SPIRV_TOOLS}-static)
- set(SPIRV_TOOLS_LIBRARY_TYPE "STATIC")
-else(SPIRV_TOOLS_BUILD_STATIC)
- set(SPIRV_TOOLS_FULL_VISIBILITY ${SPIRV_TOOLS})
- if (NOT DEFINED SPIRV_TOOLS_LIBRARY_TYPE)
- if(BUILD_SHARED_LIBS)
- set(SPIRV_TOOLS_LIBRARY_TYPE "SHARED")
- else()
- set(SPIRV_TOOLS_LIBRARY_TYPE "STATIC")
- endif()
- endif()
-endif(SPIRV_TOOLS_BUILD_STATIC)
-
-function(spvtools_default_compile_options TARGET)
- target_compile_options(${TARGET} PRIVATE ${SPIRV_WARNINGS})
-
- if (${COMPILER_IS_LIKE_GNU})
- target_compile_options(${TARGET} PRIVATE
- -Wall -Wextra -Wno-long-long -Wshadow -Wundef -Wconversion
- -Wno-sign-conversion -fno-exceptions)
-
- if(NOT ENABLE_RTTI)
- add_compile_options(-fno-rtti)
- endif()
- # For good call stacks in profiles, keep the frame pointers.
- if(NOT "${SPIRV_PERF}" STREQUAL "")
- target_compile_options(${TARGET} PRIVATE -fno-omit-frame-pointer)
- endif()
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
- set(SPIRV_USE_SANITIZER "" CACHE STRING
- "Use the clang sanitizer [address|memory|thread|...]")
- if(NOT "${SPIRV_USE_SANITIZER}" STREQUAL "")
- target_compile_options(${TARGET} PRIVATE
- -fsanitize=${SPIRV_USE_SANITIZER})
- set_target_properties(${TARGET} PROPERTIES
- LINK_FLAGS -fsanitize=${SPIRV_USE_SANITIZER})
- endif()
- target_compile_options(${TARGET} PRIVATE
- -ftemplate-depth=1024)
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips.*")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH "mips64el")
else()
- target_compile_options(${TARGET} PRIVATE
- -Wno-missing-field-initializers)
+ set(ARCH "mipsel")
endif()
- endif()
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc.*")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH "ppc64le")
+ else()
+ message(FATAL_ERROR "Architecture is not supported")
+ endif()
+else()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ARCH "x86_64")
+ else()
+ set(ARCH "x86")
+ endif()
+endif()
- if (MSVC)
- # Specify /EHs for exception handling. This makes using SPIRV-Tools as
- # dependencies in other projects easier.
- if(ENABLE_EXCEPTIONS_ON_MSVC)
- target_compile_options(${TARGET} PRIVATE /EHs)
+# Cross compiling on macOS. The cross compiling architecture should override
+# auto-detected system architecture settings.
+if(CMAKE_OSX_ARCHITECTURES)
+ if(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
+ set(ARCH "aarch64")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
+ set(ARCH "x86_64")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
+ set(ARCH "x86")
+ else()
+ message(FATAL_ERROR "Architecture ${CMAKE_OSX_ARCHITECTURES} is not "
+ "supported. Only one architecture (arm64, x86_64 "
+ "or i386) could be specified at build time.")
endif()
- endif()
+endif()
- # For MinGW cross compile, statically link to the C++ runtime.
- # But it still depends on MSVCRT.dll.
- if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
- if (NOT MSVC)
- set_target_properties(${TARGET} PROPERTIES
- LINK_FLAGS -static -static-libgcc -static-libstdc++)
+# Cross compiling with `cmake -A <arch>`.
+if(CMAKE_GENERATOR_PLATFORM)
+ if(CMAKE_GENERATOR_PLATFORM MATCHES "^(Win32|win32|X86|x86)$")
+ set(ARCH "x86")
+ elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^(Win64|win64|X64|x64)$")
+ set(ARCH "x86_64")
+ elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^(ARM64|Arm64|arm64)$")
+ set(ARCH "aarch64")
endif()
- endif()
+endif()
+
+set(CMAKE_MACOSX_RPATH TRUE)
+
+if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
+ message(WARNING "Visual Studio generators use the x86 host compiler by "
+ "default, even for 64-bit targets. This can result in linker "
+ "instability and out of memory errors. To use the 64-bit "
+ "host compiler, pass -Thost=x64 on the CMake command line.")
+endif()
+
+# Use CCache if available
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ message(STATUS "Using ccache")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+endif()
+
+###########################################################
+# Install Gerrit commit hook
+###########################################################
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg)
+ message(WARNING "
+ .git/hooks/commit-msg was not found.
+ Downloading from https://gerrit-review.googlesource.com/tools/hooks/commit-msg...
+ ")
+
+ file(DOWNLOAD https://gerrit-review.googlesource.com/tools/hooks/commit-msg ${CMAKE_SOURCE_DIR}/commit-msg)
+
+ file(COPY ${CMAKE_SOURCE_DIR}/commit-msg
+ DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks/
+ FILE_PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_WRITE GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
+ file(REMOVE ${CMAKE_SOURCE_DIR}/commit-msg)
+endif()
+
+###########################################################
+# Host libraries
+###########################################################
+
+if(LINUX)
+ include(CheckSymbolExists)
+ check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
+ check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2)
+endif()
+
+if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
+ find_library(DIRECTFB directfb)
+ find_path(DIRECTFB_INCLUDE_DIR directfb/directfb.h)
+endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
+if(SWIFTSHADER_BUILD_WSI_D2D)
+ find_library(D2D drm)
+ find_path(D2D_INCLUDE_DIR libdrm/drm.h)
+endif(SWIFTSHADER_BUILD_WSI_D2D)
+
+###########################################################
+# Options
+###########################################################
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build: Debug Release MinSizeRel RelWithDebInfo." FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
+endif()
+
+function(option_if_not_defined name description default)
+ if(NOT DEFINED ${name})
+ option(${name} ${description} ${default})
+ endif()
endfunction()
-if(NOT COMMAND find_host_package)
- macro(find_host_package)
- find_package(${ARGN})
- endmacro()
-endif()
-if(NOT COMMAND find_host_program)
- macro(find_host_program)
- find_program(${ARGN})
- endmacro()
+if(LINUX)
+ option_if_not_defined(SWIFTSHADER_BUILD_WSI_XCB "Build the XCB WSI support" TRUE)
+ option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" TRUE)
+ option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE)
+ option_if_not_defined(SWIFTSHADER_BUILD_WSI_D2D "Build the Direct-to-Display WSI support" FALSE)
endif()
-# Tests require Python3
-find_host_package(Python3 REQUIRED)
+option_if_not_defined(SWIFTSHADER_BUILD_PVR "Build the PowerVR examples" FALSE)
+option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build unit tests" TRUE)
+option_if_not_defined(SWIFTSHADER_BUILD_BENCHMARKS "Build benchmarks" FALSE)
-# Check for symbol exports on Linux.
-# At the moment, this check will fail on the OSX build machines for the Android NDK.
-# It appears they don't have objdump.
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
- macro(spvtools_check_symbol_exports TARGET)
- if (NOT "${SPIRV_SKIP_TESTS}")
- add_test(NAME spirv-tools-symbol-exports-${TARGET}
- COMMAND Python3::Interpreter
- ${spirv-tools_SOURCE_DIR}/utils/check_symbol_exports.py "$<TARGET_FILE:${TARGET}>")
+option_if_not_defined(SWIFTSHADER_USE_GROUP_SOURCES "Group the source files in a folder tree for Visual Studio" TRUE)
+
+option_if_not_defined(SWIFTSHADER_MSAN "Build with memory sanitizer" FALSE)
+option_if_not_defined(SWIFTSHADER_ASAN "Build with address sanitizer" FALSE)
+option_if_not_defined(SWIFTSHADER_TSAN "Build with thread sanitizer" FALSE)
+option_if_not_defined(SWIFTSHADER_UBSAN "Build with undefined behavior sanitizer" FALSE)
+option_if_not_defined(SWIFTSHADER_EMIT_COVERAGE "Emit code coverage information" FALSE)
+option_if_not_defined(SWIFTSHADER_WARNINGS_AS_ERRORS "Treat all warnings as errors" TRUE)
+option_if_not_defined(SWIFTSHADER_DCHECK_ALWAYS_ON "Check validation macros even in release builds" FALSE)
+option_if_not_defined(REACTOR_EMIT_DEBUG_INFO "Emit debug info for JIT functions" FALSE)
+option_if_not_defined(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location info for JIT functions" FALSE)
+option_if_not_defined(REACTOR_EMIT_ASM_FILE "Emit asm files for JIT functions" FALSE)
+option_if_not_defined(REACTOR_ENABLE_PRINT "Enable RR_PRINT macros" FALSE)
+option_if_not_defined(REACTOR_VERIFY_LLVM_IR "Check reactor-generated LLVM IR is valid even in release builds" FALSE)
+option_if_not_defined(SWIFTSHADER_LESS_DEBUG_INFO "Generate less debug info to reduce file size" FALSE)
+# option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable Vulkan debugger support" FALSE) # TODO(b/251802301)
+option_if_not_defined(SWIFTSHADER_ENABLE_ASTC "Enable ASTC compressed textures support" TRUE) # TODO(b/150130101)
+
+if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
+ set(SWIFTSHADER_BUILD_CPPDAP TRUE)
+endif()
+
+set(DEFAULT_REACTOR_BACKEND "LLVM")
+set(REACTOR_BACKEND ${DEFAULT_REACTOR_BACKEND} CACHE STRING "JIT compiler back-end used by Reactor")
+set_property(CACHE REACTOR_BACKEND PROPERTY STRINGS LLVM LLVM-Submodule Subzero)
+
+set(DEFAULT_SWIFTSHADER_LLVM_VERSION "10.0")
+set(SWIFTSHADER_LLVM_VERSION ${DEFAULT_SWIFTSHADER_LLVM_VERSION} CACHE STRING "LLVM version to use")
+set_property(CACHE SWIFTSHADER_LLVM_VERSION PROPERTY STRINGS "10.0")
+
+# If defined, overrides the default optimization level of the current reactor backend.
+# Set to one of the rr::Optimization::Level enum values.
+set(REACTOR_DEFAULT_OPT_LEVEL "" CACHE STRING "Reactor default optimization level")
+set_property(CACHE REACTOR_DEFAULT_OPT_LEVEL PROPERTY STRINGS "None" "Less" "Default" "Aggressive")
+
+if(NOT DEFINED SWIFTSHADER_LOGGING_LEVEL)
+ set(SWIFTSHADER_LOGGING_LEVEL "Info" CACHE STRING "SwiftShader logging level")
+ set_property(CACHE SWIFTSHADER_LOGGING_LEVEL PROPERTY STRINGS "Verbose" "Debug" "Info" "Warn" "Error" "Fatal" "Disabled")
+endif()
+
+# LLVM disallows calling cmake . from the main LLVM dir, the reason is that
+# it builds header files that could overwrite the orignal ones. Here we
+# want to include LLVM as a subdirectory and even though it wouldn't cause
+# the problem, if cmake . is called from the main dir, the condition that
+# LLVM checkes, "CMAKE_CURRENT_SOURCE_DIR == CMAKE_CURRENT_BINARY_DIR" will be true. So we
+# disallow it ourselves too to. In addition if there are remining CMakeFiles
+# and CMakeCache in the directory, cmake .. from a subdirectory will still
+# try to build from the main directory so we instruct users to delete these
+# files when they get the error.
+if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
+ message(FATAL_ERROR "In source builds are not allowed by LLVM, please create a build/ directory and build from there. You may have to delete the CMakeCache.txt file and CMakeFiles directory that are next to the CMakeLists.txt.")
+endif()
+
+set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
+
+###########################################################
+# Directories
+###########################################################
+
+set(SWIFTSHADER_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(SOURCE_DIR ${SWIFTSHADER_DIR}/src)
+set(THIRD_PARTY_DIR ${SWIFTSHADER_DIR}/third_party)
+set(TESTS_DIR ${SWIFTSHADER_DIR}/tests)
+
+###########################################################
+# Initialize submodules
+###########################################################
+
+function(InitSubmodule target submodule_dir)
+ if (NOT TARGET ${target})
+ if(NOT EXISTS ${submodule_dir}/.git)
+ message(WARNING "
+ Target ${target} from submodule ${submodule_dir} missing.
+ Running 'git submodule update --init' to download it:
+ ")
+
+ execute_process(COMMAND git -C ${SWIFTSHADER_DIR} submodule update --init ${submodule_dir})
+ endif()
endif()
- endmacro()
+endfunction()
+
+if (SWIFTSHADER_BUILD_TESTS OR SWIFTSHADER_BUILD_BENCHMARKS)
+ set(BUILD_VULKAN_WRAPPER TRUE)
+endif()
+
+if (BUILD_VULKAN_WRAPPER)
+ InitSubmodule(glslang ${THIRD_PARTY_DIR}/glslang)
+endif()
+
+if (SWIFTSHADER_BUILD_TESTS)
+ InitSubmodule(gtest ${THIRD_PARTY_DIR}/googletest)
+endif()
+
+if(SWIFTSHADER_BUILD_BENCHMARKS)
+ InitSubmodule(benchmark::benchmark ${THIRD_PARTY_DIR}/benchmark)
+endif()
+
+if(REACTOR_EMIT_DEBUG_INFO)
+ InitSubmodule(libbacktrace ${THIRD_PARTY_DIR}/libbacktrace/src)
+endif()
+
+if(SWIFTSHADER_BUILD_PVR)
+ InitSubmodule(PVRCore ${THIRD_PARTY_DIR}/PowerVR_Examples)
+endif()
+
+if(SWIFTSHADER_BUILD_CPPDAP)
+ InitSubmodule(json ${THIRD_PARTY_DIR}/json)
+ InitSubmodule(cppdap ${THIRD_PARTY_DIR}/cppdap)
+endif()
+
+if(${REACTOR_BACKEND} STREQUAL "LLVM-Submodule")
+ InitSubmodule(llvm-submodule ${THIRD_PARTY_DIR}/llvm-project)
+endif()
+
+###########################################################
+# Convenience macros
+###########################################################
+
+# Recursively calls source_group on the files of the directory
+# so that Visual Studio has the files in a folder tree
+macro(group_all_sources directory)
+ file(GLOB files RELATIVE ${SWIFTSHADER_DIR}/${directory} ${SWIFTSHADER_DIR}/${directory}/*)
+ foreach(file ${files})
+ if(IS_DIRECTORY ${SWIFTSHADER_DIR}/${directory}/${file})
+ group_all_sources(${directory}/${file})
+ else()
+ string(REPLACE "/" "\\" groupname ${directory})
+ source_group(${groupname} FILES ${SWIFTSHADER_DIR}/${directory}/${file})
+ endif()
+ endforeach()
+endmacro()
+
+# Takes target library and a directory where the export map is
+# and add the linker options so that only the API symbols are
+# exported.
+macro(set_shared_library_export_map TARGET DIR)
+ if(MSVC)
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:\"${DIR}/${TARGET}.def\"")
+ elseif(APPLE)
+ # The exported symbols list only exports the API functions and
+ # hides all the others.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS "-exported_symbols_list ${DIR}/${TARGET}.exports")
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${TARGET}.exports;")
+ # Don't allow undefined symbols, unless it's a Sanitizer build.
+ if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN)
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-undefined,error")
+ endif()
+ elseif(LINUX OR FUCHSIA)
+ # NOTE: The Fuchsia linker script is needed to export the vk_icdInitializeConnectToServiceCallback
+ # entry point (a private implementation detail betwen the Fuchsia Vulkan loader and the ICD).
+ if ((FUCHSIA) AND ("${TARGET}" STREQUAL "vk_swiftshader"))
+ set(LINKER_VERSION_SCRIPT "fuchsia_vk_swiftshader.lds")
+ else()
+ set(LINKER_VERSION_SCRIPT "${TARGET}.lds")
+ endif()
+
+ # The version script only exports the API functions and
+ # hides all the others.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--version-script=${DIR}/${LINKER_VERSION_SCRIPT}")
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${LINKER_VERSION_SCRIPT};")
+
+ # -Bsymbolic binds symbol references to their global definitions within
+ # a shared object, thereby preventing symbol preemption.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-Bsymbolic")
+
+ if(ARCH STREQUAL "mipsel" OR ARCH STREQUAL "mips64el")
+ # MIPS supports sysv hash-style only.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=sysv")
+ elseif(LINUX)
+ # Both hash-style are needed, because we want both gold and
+ # GNU ld to be able to read our libraries.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=both")
+ endif()
+
+ if(NOT ${SWIFTSHADER_EMIT_COVERAGE})
+ # Gc sections is used in combination with each functions being
+ # in its own section, to reduce the binary size.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--gc-sections")
+ endif()
+
+ # Don't allow undefined symbols, unless it's a Sanitizer build.
+ if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN)
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined")
+ endif()
+ endif()
+endmacro()
+
+if(SWIFTSHADER_USE_GROUP_SOURCES)
+ group_all_sources(src)
+endif()
+
+###########################################################
+# Compile flags
+###########################################################
+
+# Flags for project code (non 3rd party)
+set(SWIFTSHADER_COMPILE_OPTIONS "")
+set(SWIFTSHADER_LINK_FLAGS "")
+set(SWIFTSHADER_LIBS "")
+
+macro(set_cpp_flag FLAG)
+ if(${ARGC} GREATER 1)
+ set(CMAKE_CXX_FLAGS_${ARGV1} "${CMAKE_CXX_FLAGS_${ARGV1}} ${FLAG}")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
+ endif()
+endmacro()
+
+macro(set_linker_flag FLAG)
+ if(${ARGC} GREATER 1)
+ set(CMAKE_EXE_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1}} ${FLAG}")
+ set(CMAKE_SHARED_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1}} ${FLAG}")
+ else()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
+ endif()
+endmacro()
+
+if(MSVC)
+ set_cpp_flag("/MP")
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D_SCL_SECURE_NO_WARNINGS)
+ add_definitions(-D_SBCS) # Single Byte Character Set (ASCII)
+ add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
+
+ set_linker_flag("/DEBUG:FASTLINK" DEBUG)
+ set_linker_flag("/DEBUG:FASTLINK" RELWITHDEBINFO)
+
+ # Disable specific warnings
+ # TODO: Not all of these should be disabled, but for now, we want a warning-free msvc build. Remove these one by one
+ # and fix the actual warnings in code.
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "/wd4005" # 'identifier' : macro redefinition
+ "/wd4018" # 'expression' : signed/unsigned mismatch
+ "/wd4065" # switch statement contains 'default' but no 'case' labels
+ "/wd4141" # 'modifier' : used more than once
+ "/wd4244" # 'conversion' conversion from 'type1' to 'type2', possible loss of data
+ "/wd4267" # 'var' : conversion from 'size_t' to 'type', possible loss of data
+ "/wd4291" # 'void X new(size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception
+ "/wd4309" # 'conversion' : truncation of constant value
+ "/wd4624" # 'derived class' : destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted
+ "/wd4800" # 'type' : forcing value to bool 'true' or 'false' (performance warning)
+ "/wd4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
+ "/wd5030" # attribute 'attribute' is not recognized
+ "/wd5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
+ "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
+ )
+
+ # Treat specific warnings as errors
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "/we4018" # 'expression' : signed/unsigned mismatch
+ "/we4062" # enumerator 'identifier' in switch of enum 'enumeration' is not handled
+ "/we4471" # 'enumeration': a forward declaration of an unscoped enumeration must have an underlying type (int assumed)
+ "/we4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
+ "/we5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
+ "/we4101" # 'identifier' : unreferenced local variable
+ )
else()
- macro(spvtools_check_symbol_exports TARGET)
- if (NOT "${SPIRV_SKIP_TESTS}")
- message("Skipping symbol exports test for ${TARGET}")
+ # Explicitly enable these warnings.
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wall"
+ "-Wreorder"
+ "-Wsign-compare"
+ "-Wmissing-braces"
+ )
+
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wdeprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator.
+ )
+ endif()
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wextra"
+ "-Wunreachable-code-loop-increment"
+ "-Wunused-lambda-capture"
+ "-Wstring-conversion"
+ "-Wextra-semi"
+ "-Wignored-qualifiers"
+ "-Wdeprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator.
+ # TODO(b/208256248): Avoid exit-time destructor.
+ #"-Wexit-time-destructors" # declaration requires an exit-time destructor
+ )
endif()
- endmacro()
+
+ if (SWIFTSHADER_EMIT_COVERAGE)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "--coverage")
+ list(APPEND SWIFTSHADER_LIBS "gcov")
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fprofile-instr-generate" "-fcoverage-mapping")
+ list(APPEND SWIFTSHADER_LINK_FLAGS "-fprofile-instr-generate" "-fcoverage-mapping")
+ else()
+ message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain")
+ endif()
+ endif()
+
+ # Disable pedantic warnings
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wno-ignored-attributes" # ignoring attributes on template argument 'X'
+ "-Wno-attributes" # 'X' attribute ignored
+ "-Wno-strict-aliasing" # dereferencing type-punned pointer will break strict-aliasing rules
+ "-Wno-comment" # multi-line comment
+ )
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wno-init-list-lifetime" # assignment from temporary initializer_list does not extend the lifetime of the underlying array
+ )
+ endif()
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+ "-Wno-unneeded-internal-declaration" # function 'X' is not needed and will not be emitted
+ "-Wno-unused-private-field" # private field 'offset' is not used - TODO: Consider enabling this once Vulkan is further implemented.
+ "-Wno-comment" # multi-line comment
+ "-Wno-extra-semi" # extra ';' after member function definition
+ "-Wno-unused-parameter" # unused parameter 'X'
+
+ # Silence errors caused by unknown warnings when building with older
+ # versions of Clang. This demands checking that warnings added above
+ # are spelled correctly and work as intended!
+ "-Wno-unknown-warning-option"
+ )
+ endif()
+
+ if(ARCH STREQUAL "x86")
+ set_cpp_flag("-m32")
+ set_cpp_flag("-msse2")
+ set_cpp_flag("-mfpmath=sse")
+ set_cpp_flag("-march=pentium4")
+ set_cpp_flag("-mtune=generic")
+ endif()
+ if(ARCH STREQUAL "x86_64")
+ set_cpp_flag("-m64")
+ set_cpp_flag("-fPIC")
+ set_cpp_flag("-march=x86-64")
+ set_cpp_flag("-mtune=generic")
+ endif()
+ if(ARCH STREQUAL "mipsel")
+ set_cpp_flag("-EL")
+ set_cpp_flag("-march=mips32r2")
+ set_cpp_flag("-fPIC")
+ set_cpp_flag("-mhard-float")
+ set_cpp_flag("-mfp32")
+ set_cpp_flag("-mxgot")
+ endif()
+ if(ARCH STREQUAL "mips64el")
+ set_cpp_flag("-EL")
+ set_cpp_flag("-march=mips64r2")
+ set_cpp_flag("-mabi=64")
+ set_cpp_flag("-fPIC")
+ set_cpp_flag("-mxgot")
+ endif()
+
+ if(SWIFTSHADER_LESS_DEBUG_INFO)
+ # Use -g1 to be able to get stack traces
+ set_cpp_flag("-g -g1" DEBUG)
+ set_cpp_flag("-g -g1" RELWITHDEBINFO)
+ else()
+ # Use -g3 to have even more debug info
+ set_cpp_flag("-g -g3" DEBUG)
+ set_cpp_flag("-g -g3" RELWITHDEBINFO)
+ endif()
+
+ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # Treated as an unused argument with clang
+ set_cpp_flag("-s" RELEASE)
+ endif()
+
+ # For distribution it is more important to be slim than super optimized
+ set_cpp_flag("-Os" RELEASE)
+ set_cpp_flag("-Os" RELWITHDEBINFO)
+
+ set_cpp_flag("-DNDEBUG" RELEASE)
+ set_cpp_flag("-DNDEBUG" RELWITHDEBINFO)
+
+ # Put each variable and function in its own section so that when linking
+ # with -gc-sections unused functions and variables are removed.
+ set_cpp_flag("-ffunction-sections" RELEASE)
+ set_cpp_flag("-fdata-sections" RELEASE)
+ set_cpp_flag("-fomit-frame-pointer" RELEASE)
+
+ if(SWIFTSHADER_MSAN)
+ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ message(FATAL_ERROR " \n"
+ " MemorySanitizer usage requires compiling with Clang.")
+ endif()
+
+ if(NOT DEFINED ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH})
+ message(FATAL_ERROR " \n"
+ " MemorySanitizer usage requires an instrumented build of libc++.\n"
+ " Set the SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH environment variable to the\n"
+ " build output path. See\n"
+ " https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo#instrumented-libc\n"
+ " for details on how to build an MSan instrumented libc++.")
+ endif()
+
+ set_cpp_flag("-fsanitize=memory")
+ set_linker_flag("-fsanitize=memory")
+ set_cpp_flag("-stdlib=libc++")
+ set_linker_flag("-L$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/lib")
+ set_cpp_flag("-I$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/include")
+ set_cpp_flag("-I$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/include/c++/v1")
+ set_linker_flag("-Wl,-rpath,$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/lib")
+ elseif(SWIFTSHADER_ASAN)
+ set_cpp_flag("-fsanitize=address")
+ set_linker_flag("-fsanitize=address")
+ elseif(SWIFTSHADER_TSAN)
+ set_cpp_flag("-fsanitize=thread")
+ set_linker_flag("-fsanitize=thread")
+ elseif(SWIFTSHADER_UBSAN)
+ set_cpp_flag("-fsanitize=undefined")
+ set_linker_flag("-fsanitize=undefined")
+ endif()
endif()
-if(ENABLE_SPIRV_TOOLS_INSTALL)
- if(WIN32 AND NOT MINGW)
- macro(spvtools_config_package_dir TARGET PATH)
- set(${PATH} ${TARGET}/cmake)
- endmacro()
- else()
- macro(spvtools_config_package_dir TARGET PATH)
- set(${PATH} ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET})
- endmacro()
- endif()
-
- macro(spvtools_generate_config_file TARGET)
- file(WRITE ${CMAKE_BINARY_DIR}/${TARGET}Config.cmake
- "include(CMakeFindDependencyMacro)\n"
- "find_dependency(${SPIRV_TOOLS})\n"
- "include(\${CMAKE_CURRENT_LIST_DIR}/${TARGET}Targets.cmake)\n"
- "set(${TARGET}_LIBRARIES ${TARGET})\n"
- "get_target_property(${TARGET}_INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)\n")
- endmacro()
+if(SWIFTSHADER_DCHECK_ALWAYS_ON)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DDCHECK_ALWAYS_ON")
endif()
-# Currently iOS and Android are very similar.
-# They both have their own packaging (APP/APK).
-# Which makes regular executables/testing problematic.
-#
-# Currently the only deliverables for these platforms are
-# libraries (either STATIC or SHARED).
-#
-# Furthermore testing is equally problematic.
-if (IOS OR ANDROID)
- set(SPIRV_SKIP_EXECUTABLES ON)
+if(SWIFTSHADER_WARNINGS_AS_ERRORS)
+ if(MSVC)
+ set(WARNINGS_AS_ERRORS "/WX") # Treat all warnings as errors
+ else()
+ set(WARNINGS_AS_ERRORS "-Werror") # Treat all warnings as errors
+ endif()
endif()
-option(SPIRV_SKIP_EXECUTABLES "Skip building the executable and tests along with the library")
-if (SPIRV_SKIP_EXECUTABLES)
- set(SPIRV_SKIP_TESTS ON)
-endif()
-option(SPIRV_SKIP_TESTS "Skip building tests along with the library")
-
-# Defaults to ON. The checks can be time consuming.
-# Turn off if they take too long.
-option(SPIRV_CHECK_CONTEXT "In a debug build, check if the IR context is in a valid state." ON)
-if (${SPIRV_CHECK_CONTEXT})
- add_compile_options($<$<CONFIG:Debug>:-DSPIRV_CHECK_CONTEXT>)
+# Enable Reactor Print() functionality in Debug/RelWithDebInfo builds or when explicitly enabled.
+if(CMAKE_BUILD_TYPE MATCHES "Deb")
+ set(REACTOR_ENABLE_PRINT TRUE)
endif()
-# Precompiled header macro. Parameters are source file list and filename for pch cpp file.
-macro(spvtools_pch SRCS PCHPREFIX)
- if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- set(PCH_NAME "$(IntDir)\\${PCHPREFIX}.pch")
- # make source files use/depend on PCH_NAME
- set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yu${PCHPREFIX}.h /FI${PCHPREFIX}.h /Fp${PCH_NAME} /Zm300" OBJECT_DEPENDS "${PCH_NAME}")
- # make PCHPREFIX.cpp file compile and generate PCH_NAME
- set_source_files_properties("${PCHPREFIX}.cpp" PROPERTIES COMPILE_FLAGS "/Yc${PCHPREFIX}.h /Fp${PCH_NAME} /Zm300" OBJECT_OUTPUTS "${PCH_NAME}")
- list(APPEND ${SRCS} "${PCHPREFIX}.cpp")
- endif()
-endmacro(spvtools_pch)
-
-add_subdirectory(external)
-
-# Warning about extra semi-colons.
-#
-# This is not supported on all compilers/versions. so enabling only
-# for clang, since that works for all versions that our bots run.
-#
-# This is intentionally done after adding the external subdirectory,
-# so we don't enforce this flag on our dependencies, some of which do
-# not pass it.
-#
-# If the minimum version of CMake supported is updated to 3.0 or
-# later, then check_cxx_compiler_flag could be used instead.
-if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- add_compile_options("-Wextra-semi")
+if(REACTOR_EMIT_PRINT_LOCATION)
+ # This feature depends on REACTOR_EMIT_DEBUG_INFO and REACTOR_ENABLE_PRINT
+ set(REACTOR_EMIT_DEBUG_INFO TRUE)
+ set(REACTOR_ENABLE_PRINT TRUE)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_EMIT_PRINT_LOCATION")
endif()
-add_subdirectory(source)
-add_subdirectory(tools)
-
-add_subdirectory(test)
-add_subdirectory(examples)
-
-if(ENABLE_SPIRV_TOOLS_INSTALL)
- install(
- FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.h
- ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/optimizer.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/linker.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/instrument.hpp
- DESTINATION
- ${CMAKE_INSTALL_INCLUDEDIR}/spirv-tools/)
-endif(ENABLE_SPIRV_TOOLS_INSTALL)
-
-if (NOT "${SPIRV_SKIP_TESTS}")
- add_test(NAME spirv-tools-copyrights
- COMMAND Python3::Interpreter utils/check_copyright.py
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+if(REACTOR_EMIT_ASM_FILE)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_EMIT_ASM_FILE")
endif()
-set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link")
-set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared")
+if(REACTOR_EMIT_DEBUG_INFO)
+ message(WARNING "REACTOR_EMIT_DEBUG_INFO is enabled. This will likely affect performance.")
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_DEBUG_INFO")
+endif()
-# Build pkg-config file
-# Use a first-class target so it's regenerated when relevant files are updated.
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc
- COMMAND ${CMAKE_COMMAND}
- -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES
- -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in
- -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc
- -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
- -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
- -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
- -DSPIRV_LIBRARIES=${SPIRV_LIBRARIES}
- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake
- DEPENDS "CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools.pc.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake")
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc
- COMMAND ${CMAKE_COMMAND}
- -DCHANGES_FILE=${CMAKE_CURRENT_SOURCE_DIR}/CHANGES
- -DTEMPLATE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in
- -DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc
- -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
- -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
- -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
- -DSPIRV_SHARED_LIBRARIES=${SPIRV_SHARED_LIBRARIES}
- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake
- DEPENDS "CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPIRV-Tools-shared.pc.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake")
-add_custom_target(spirv-tools-pkg-config
- ALL
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc)
+if(REACTOR_ENABLE_PRINT)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_PRINT")
+endif()
-# Install pkg-config file
-if (ENABLE_SPIRV_TOOLS_INSTALL)
- install(
- FILES
- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc
- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc
- DESTINATION
- ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+if(REACTOR_VERIFY_LLVM_IR)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_LLVM_IR_VERIFICATION")
+endif()
+
+if(REACTOR_DEFAULT_OPT_LEVEL)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DREACTOR_DEFAULT_OPT_LEVEL=${REACTOR_DEFAULT_OPT_LEVEL}")
+endif()
+
+if(DEFINED SWIFTSHADER_LOGGING_LEVEL)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DSWIFTSHADER_LOGGING_LEVEL=${SWIFTSHADER_LOGGING_LEVEL}")
+endif()
+
+if(WIN32)
+ add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT)
+ set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib")
+endif()
+
+set(USE_EXCEPTIONS
+ ${REACTOR_EMIT_DEBUG_INFO} # boost::stacktrace uses exceptions
+)
+if(NOT MSVC)
+ if (${USE_EXCEPTIONS})
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fexceptions")
+ else()
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fno-exceptions")
+ endif()
+endif()
+unset(USE_EXCEPTIONS)
+
+###########################################################
+# libbacktrace and boost
+###########################################################
+if(REACTOR_EMIT_DEBUG_INFO)
+ add_subdirectory(${THIRD_PARTY_DIR}/libbacktrace EXCLUDE_FROM_ALL)
+ add_subdirectory(${THIRD_PARTY_DIR}/boost EXCLUDE_FROM_ALL)
+endif()
+
+###########################################################
+# LLVM
+###########################################################
+add_subdirectory(${THIRD_PARTY_DIR}/llvm-${SWIFTSHADER_LLVM_VERSION} EXCLUDE_FROM_ALL)
+set_target_properties(llvm PROPERTIES FOLDER "third_party")
+
+###########################################################
+# LLVM-Submodule
+###########################################################
+if(${REACTOR_BACKEND} STREQUAL "LLVM-Submodule")
+ set(LLVM_INCLUDE_TESTS FALSE)
+ set(LLVM_ENABLE_RTTI TRUE)
+ add_subdirectory(${THIRD_PARTY_DIR}/llvm-project/llvm EXCLUDE_FROM_ALL)
+ if(ARCH STREQUAL "aarch64")
+ llvm_map_components_to_libnames(llvm_libs orcjit aarch64asmparser aarch64codegen)
+ elseif(ARCH STREQUAL "arm")
+ llvm_map_components_to_libnames(llvm_libs orcjit armasmparser armcodegen)
+ elseif(ARCH MATCHES "^mips.*")
+ llvm_map_components_to_libnames(llvm_libs orcjit mipsasmparser mipscodegen)
+ elseif(ARCH STREQUAL "ppc64le")
+ llvm_map_components_to_libnames(llvm_libs orcjit powerpcasmparser powerpccodegen)
+ elseif(ARCH MATCHES "^x86.*")
+ llvm_map_components_to_libnames(llvm_libs orcjit x86asmparser x86codegen)
+ endif()
+ set_target_properties(${llvm_libs} PROPERTIES FOLDER "third_party")
+endif()
+
+###########################################################
+# Subzero
+###########################################################
+add_subdirectory(${THIRD_PARTY_DIR}/llvm-subzero EXCLUDE_FROM_ALL)
+add_subdirectory(${THIRD_PARTY_DIR}/subzero EXCLUDE_FROM_ALL)
+set_target_properties(llvm-subzero PROPERTIES FOLDER "third_party")
+set_target_properties(subzero PROPERTIES FOLDER "third_party")
+
+###########################################################
+# marl
+###########################################################
+set(MARL_THIRD_PARTY_DIR ${THIRD_PARTY_DIR})
+add_subdirectory(${THIRD_PARTY_DIR}/marl)
+set_target_properties(marl PROPERTIES FOLDER "third_party")
+
+if(MARL_THREAD_SAFETY_ANALYSIS_SUPPORTED)
+ list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-Wthread-safety")
+endif()
+
+###########################################################
+# cppdap
+###########################################################
+if(SWIFTSHADER_BUILD_CPPDAP)
+ set(CPPDAP_THIRD_PARTY_DIR ${THIRD_PARTY_DIR})
+ add_subdirectory(${THIRD_PARTY_DIR}/cppdap)
+endif()
+
+###########################################################
+# astc-encoder
+###########################################################
+if(SWIFTSHADER_ENABLE_ASTC)
+ add_subdirectory(${THIRD_PARTY_DIR}/astc-encoder)
+ set_target_properties(astc-encoder PROPERTIES FOLDER "third_party")
+endif()
+
+###########################################################
+# gtest and gmock
+###########################################################
+if(SWIFTSHADER_BUILD_TESTS)
+ # For Win32, force gtest to match our CRT (shared)
+ set(gtest_force_shared_crt TRUE CACHE BOOL "" FORCE)
+ set(INSTALL_GTEST FALSE CACHE BOOL "" FORCE)
+ add_subdirectory(${THIRD_PARTY_DIR}/googletest EXCLUDE_FROM_ALL)
+ # gtest finds python, which picks python 2 first, if present.
+ # We need to undo this so that SPIR-V can later find python3.
+ unset(PYTHON_EXECUTABLE CACHE)
+ set_target_properties(gmock PROPERTIES FOLDER "third_party")
+ set_target_properties(gmock_main PROPERTIES FOLDER "third_party")
+ set_target_properties(gtest PROPERTIES FOLDER "third_party")
+ set_target_properties(gtest_main PROPERTIES FOLDER "third_party")
+endif()
+
+###########################################################
+# File Lists
+###########################################################
+
+###########################################################
+# Append OS specific files to lists
+###########################################################
+
+if(WIN32)
+ set(OS_LIBS odbc32 odbccp32 WS2_32 dxguid)
+elseif(LINUX)
+ set(OS_LIBS dl pthread)
+ if(SWIFTSHADER_BUILD_WSI_WAYLAND)
+ include_directories("${SWIFTSHADER_DIR}/include/Wayland")
+ endif()
+ if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
+ list(APPEND OS_LIBS "${DIRECTFB}")
+ include_directories(${DIRECTFB_INCLUDE_DIR}/directfb)
+ endif()
+ if(SWIFTSHADER_BUILD_WSI_D2D)
+ list(APPEND OS_LIBS "${D2D}")
+ include_directories(${D2D_INCLUDE_DIR}/libdrm)
+ endif()
+elseif(FUCHSIA)
+ set(OS_LIBS zircon)
+elseif(APPLE)
+ find_library(COCOA_FRAMEWORK Cocoa)
+ find_library(QUARTZ_FRAMEWORK Quartz)
+ find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
+ find_library(IOSURFACE_FRAMEWORK IOSurface)
+ find_library(METAL_FRAMEWORK Metal)
+ set(OS_LIBS "${COCOA_FRAMEWORK}" "${QUARTZ_FRAMEWORK}" "${CORE_FOUNDATION_FRAMEWORK}" "${IOSURFACE_FRAMEWORK}" "${METAL_FRAMEWORK}")
+endif()
+
+###########################################################
+# SwiftShader Targets
+###########################################################
+
+add_subdirectory(src/Reactor) # Add ReactorSubzero and ReactorLLVM targets
+
+if(${REACTOR_BACKEND} STREQUAL "LLVM")
+ add_library(Reactor ALIAS ReactorLLVM)
+elseif(${REACTOR_BACKEND} STREQUAL "LLVM-Submodule")
+ add_library(Reactor ALIAS ReactorLLVMSubmodule)
+elseif(${REACTOR_BACKEND} STREQUAL "Subzero")
+ add_library(Reactor ALIAS ReactorSubzero)
+else()
+ message(FATAL_ERROR "REACTOR_BACKEND must be 'LLVM', 'LLVM-Submodule' or 'Subzero'")
+endif()
+
+if (NOT TARGET SPIRV-Tools)
+ # This variable is also used by SPIRV-Tools to locate SPIRV-Headers
+ set(SPIRV-Headers_SOURCE_DIR "${THIRD_PARTY_DIR}/SPIRV-Headers")
+ set(SPIRV_SKIP_TESTS TRUE CACHE BOOL "" FORCE)
+ set(SPIRV_SKIP_EXECUTABLES TRUE CACHE BOOL "" FORCE)
+ add_subdirectory(${THIRD_PARTY_DIR}/SPIRV-Tools) # Add SPIRV-Tools target
+endif()
+
+# Add a vk_base interface library for shared vulkan build options.
+# TODO: Create src/Base and make this a lib target, and move stuff from
+# src/Vulkan into it that is needed by vk_pipeline, vk_device, and vk_wsi.
+add_library(vk_base INTERFACE)
+
+if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
+ target_compile_definitions(vk_base INTERFACE "ENABLE_VK_DEBUGGER")
+endif()
+
+if(WIN32)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WIN32_KHR")
+elseif(LINUX)
+ if(SWIFTSHADER_BUILD_WSI_XCB)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XCB_KHR")
+ endif()
+ if(SWIFTSHADER_BUILD_WSI_WAYLAND)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WAYLAND_KHR")
+ endif()
+ if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
+ if(DIRECTFB AND DIRECTFB_INCLUDE_DIR)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_DIRECTFB_EXT")
+ endif()
+ endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
+ if(SWIFTSHADER_BUILD_WSI_D2D)
+ if(D2D)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_DISPLAY_KHR")
+ endif()
+ endif(SWIFTSHADER_BUILD_WSI_D2D)
+elseif(APPLE)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_MACOS_MVK")
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_METAL_EXT")
+elseif(FUCHSIA)
+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_FUCHSIA")
+else()
+ message(FATAL_ERROR "Platform does not support Vulkan yet")
+endif()
+
+add_subdirectory(src/System) # Add vk_system target
+add_subdirectory(src/Pipeline) # Add vk_pipeline target
+add_subdirectory(src/WSI) # Add vk_wsi target
+add_subdirectory(src/Device) # Add vk_device target
+add_subdirectory(src/Vulkan) # Add vk_swiftshader target
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND # turbo-cov is only useful for clang coverage info
+ SWIFTSHADER_EMIT_COVERAGE)
+ add_subdirectory(${TESTS_DIR}/regres/cov/turbo-cov)
+endif()
+
+###########################################################
+# Sample programs and tests
+###########################################################
+
+# TODO(b/161976310): Add support for building PowerVR on MacOS
+if(APPLE AND SWIFTSHADER_BUILD_PVR)
+ message(WARNING "Building PowerVR examples for SwiftShader is not yet supported on Apple platforms.")
+ set(SWIFTSHADER_BUILD_PVR FALSE)
+endif()
+
+if(SWIFTSHADER_BUILD_PVR)
+ if(UNIX AND NOT APPLE)
+ set(PVR_WINDOW_SYSTEM XCB)
+
+ # Set the RPATH of the next defined build targets to $ORIGIN,
+ # allowing them to load shared libraries from the execution directory.
+ set(CMAKE_BUILD_RPATH "$ORIGIN")
+ endif()
+
+ set(PVR_BUILD_EXAMPLES TRUE CACHE BOOL "Build the PowerVR SDK Examples" FORCE)
+ set(PVR_BUILD_VULKAN_EXAMPLES TRUE CACHE BOOL "Build the Vulkan PowerVR SDK Examples" FORCE)
+ add_subdirectory(${THIRD_PARTY_DIR}/PowerVR_Examples)
+
+ # Samples known to work well
+ set(PVR_VULKAN_TARGET_GOOD
+ VulkanBumpmap
+ VulkanExampleUI
+ VulkanGaussianBlur
+ VulkanGlass
+ VulkanGnomeHorde
+ VulkanHelloAPI
+ VulkanImageBasedLighting
+ VulkanIntroducingPVRUtils
+ VulkanMultiSampling
+ VulkanNavigation2D
+ VulkanParticleSystem
+ VulkanSkinning
+ )
+
+ set(PVR_VULKAN_TARGET_OTHER
+ VulkanDeferredShading
+ VulkanDeferredShadingPFX
+ VulkanGameOfLife
+ VulkanIBLMapsGenerator
+ VulkanIMGTextureFilterCubic
+ VulkanIntroducingPVRShell
+ VulkanIntroducingPVRVk
+ VulkanIntroducingUIRenderer
+ VulkanMultithreading
+ VulkanNavigation3D
+ VulkanPostProcessing
+ VulkanPVRScopeExample
+ VulkanPVRScopeRemote
+ )
+
+ set(PVR_TARGET_OTHER
+ glslang
+ glslangValidator
+ glslang-default-resource-limits
+ OSDependent
+ pugixml
+ PVRAssets
+ PVRCamera
+ PVRCore
+ PVRPfx
+ PVRShell
+ PVRUtilsVk
+ PVRVk
+ SPIRV
+ spirv-remap
+ SPVRemapper
+ uninstall
+ )
+
+ set(PVR_VULKAN_TARGET
+ ${PVR_VULKAN_TARGET_GOOD}
+ ${PVR_VULKAN_TARGET_OTHER}
+ )
+
+ foreach(pvr_target ${PVR_VULKAN_TARGET})
+ add_dependencies(${pvr_target} vk_swiftshader)
+ endforeach()
+
+ foreach(pvr_target ${PVR_VULKAN_TARGET_GOOD})
+ set_target_properties(${pvr_target} PROPERTIES FOLDER Samples)
+ endforeach()
+
+ foreach(pvr_target ${PVR_TARGET_OTHER} ${PVR_VULKAN_TARGET_OTHER})
+ set_target_properties(${pvr_target} PROPERTIES FOLDER Samples/PowerVR-Build)
+ endforeach()
+endif()
+
+if(BUILD_VULKAN_WRAPPER)
+ if (NOT TARGET glslang)
+ add_subdirectory(${THIRD_PARTY_DIR}/glslang)
+ endif()
+ add_subdirectory(${TESTS_DIR}/VulkanWrapper) # Add VulkanWrapper target
+endif()
+
+if(SWIFTSHADER_BUILD_TESTS)
+ add_subdirectory(${TESTS_DIR}/ReactorUnitTests) # Add ReactorUnitTests target
+ add_subdirectory(${TESTS_DIR}/MathUnitTests) # Add math-unittests target
+ add_subdirectory(${TESTS_DIR}/SystemUnitTests) # Add system-unittests target
+endif()
+
+if(SWIFTSHADER_BUILD_BENCHMARKS)
+ if (NOT TARGET benchmark::benchmark)
+ set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE)
+ add_subdirectory(${THIRD_PARTY_DIR}/benchmark)
+ set_target_properties(benchmark PROPERTIES FOLDER "third_party")
+ set_target_properties(benchmark_main PROPERTIES FOLDER "third_party")
+ endif()
+
+ add_subdirectory(${TESTS_DIR}/PipelineBenchmarks) # Add PipelineBenchmarks target
+ add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target
+ add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target
+ add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target
+endif()
+
+if(SWIFTSHADER_BUILD_TESTS)
+ add_subdirectory(${TESTS_DIR}/VulkanUnitTests) # Add VulkanUnitTests target
endif()
diff --git a/CMakeSettings.json b/CMakeSettings.json
new file mode 100644
index 0000000..23c622f
--- /dev/null
+++ b/CMakeSettings.json
@@ -0,0 +1,55 @@
+{
+ "configurations": [
+ {
+ "name": "x64-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "inheritEnvironments": [ "msvc_x64_x64" ],
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "variables": [
+ {
+ "name": "REACTOR_BACKEND",
+ "value": "Subzero",
+ "type": "STRING"
+ }
+ ]
+ },
+ {
+ "name": "x86-Debug",
+ "generator": "Ninja",
+ "configurationType": "Debug",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": [ "msvc_x86" ]
+ },
+ {
+ "name": "x86-Release",
+ "generator": "Ninja",
+ "configurationType": "RelWithDebInfo",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": [ "msvc_x86" ]
+ },
+ {
+ "name": "x64-Release",
+ "generator": "Ninja",
+ "configurationType": "RelWithDebInfo",
+ "buildRoot": "${projectDir}\\out\\build\\${name}",
+ "installRoot": "${projectDir}\\out\\install\\${name}",
+ "cmakeCommandArgs": "",
+ "buildCommandArgs": "-v",
+ "ctestCommandArgs": "",
+ "inheritEnvironments": [ "msvc_x64_x64" ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt
new file mode 100644
index 0000000..2cedc8e
--- /dev/null
+++ b/CONTRIBUTING.txt
@@ -0,0 +1,28 @@
+Want to contribute? Great! First, read this page (including the small print at the end).
+
+### Before you contribute
+Before we can use your code, you must sign the
+[Google Individual Contributor License Agreement]
+(https://cla.developers.google.com/about/google-individual)
+(CLA), which you can do online. The CLA is necessary mainly because you own the
+copyright to your changes, even after your contribution becomes part of our
+codebase, so we need your permission to use and distribute your code. We also
+need to be sure of various other things—for instance that you'll tell us if you
+know that your code infringes on other people's patents. You don't have to sign
+the CLA until after you've submitted your code for review and a member has
+approved it, but you must do it before we can put your code into our codebase.
+Before you start working on a larger contribution, you should get in touch with
+us first through the issue tracker with your idea so that we can help out and
+possibly guide you. Coordinating up front makes it much easier to avoid
+frustration later on.
+
+### Code reviews
+All submissions, including submissions by project members, require review.
+
+Information on how to sumbit changes for review is provided in README.md.
+
+### The small print
+Contributions made by corporations are covered by a different agreement than
+the one above, the
+[Software Grant and Corporate Contributor License Agreement]
+(https://cla.developers.google.com/about/google-corporate).
\ No newline at end of file
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
new file mode 100644
index 0000000..5e930c8
--- /dev/null
+++ b/CONTRIBUTORS.txt
@@ -0,0 +1,42 @@
+# People who have agreed to one of the CLAs and can contribute patches.
+# The AUTHORS file lists the copyright holders; this file
+# lists people. For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# https://developers.google.com/open-source/cla/individual
+# https://developers.google.com/open-source/cla/corporate
+#
+# Names should be added to this file as:
+# Name <email address>
+
+Google Inc.
+ Nicolas Capens <capn@google.com>
+ Alexis Hétu <sugoi@google.com>
+ Shannon Woods <shannonwoods@google.com>
+ Corentin Wallez <cwallez@google.com>
+ Greg Hartman <ghartman@google.com>
+ Ping-Hao Wu <pinghao@google.com>
+ Maxime Grégoire <mgregoire@google.com>
+ Veranika Liaukevich <veranika@google.com>
+ John Bauman <jbauman@google.com>
+ Keun Soo Yim <yim@google.com>
+ John Sheu <sheu@google.com>
+ Philippe Hamel <hamelphi@google.com>
+ Daniel Toyama <kenjitoyama@google.com>
+ Meng-Lin Wu <marleymoo@google.com>
+ Krzysztof Kosiński <krzysio@google.com>
+ Chris Forbes <chrisforbes@google.com>
+ Ben Clayton <bclayton@google.com>
+ Hernan Liatis <hliatis@google.com>
+ Logan (Tzu-hsiang) Chien <loganchien@google.com>
+ Stephen White <senorblanco@google.com>
+ Raymond Chiu <chiur@google.com>
+ Shahbaz Youssefi <syoussefi@google.com>
+
+TransGaming Inc.
+ Nicolas Capens
+ Gavriel State
+ Jim MacArthur
+ Daniel Koch
+ Luther Johnson
+ Rob Stepinski
diff --git a/DIR_METADATA b/DIR_METADATA
new file mode 100644
index 0000000..72bfcd7
--- /dev/null
+++ b/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Internals>GPU>SwiftShader"
+}
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..75b5248
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..95a8620
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,19 @@
+# This is the list of people with commit rights actively working on SwiftShader
+#
+# This list is used by Chromium and Android to make sure that one of the owners
+# in this list has approved a SwiftShader related change before landing it.
+#
+# Note that the upstream source-of-truth git repository at
+# swiftshader.googlesource.com/SwiftShader has ownership and access control
+# seperate from those controlled by this OWNERS file.
+
+syoussefi@google.com
+geofflang@google.com
+
+sugoi@google.com #{LAST_RESORT_SUGGESTION}
+chrisforbes@google.com #{LAST_RESORT_SUGGESTION}
+cwallez@google.com #{LAST_RESORT_SUGGESTION}
+amaiorano@google.com #{LAST_RESORT_SUGGESTION}
+natsu@google.com #{LAST_RESORT_SUGGESTION}
+schuffelen@google.com #{LAST_RESORT_SUGGESTION}
+bclayton@google.com #{LAST_RESORT_SUGGESTION}
diff --git a/README.md b/README.md
index 7db5bd4..de5e1ce 100644
--- a/README.md
+++ b/README.md
@@ -1,807 +1,127 @@
-# SPIR-V Tools
-[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/KhronosGroup/SPIRV-Tools/badge)](https://securityscorecards.dev/viewer/?uri=github.com/KhronosGroup/SPIRV-Tools)
-
-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][spirv-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](https://vulkan.lunarg.com/sdk/home).
-
-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.
-
-<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>[![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html)
-<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>[![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html)
-<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2019_release.html)
-
-[More downloads](docs/downloads.md)
-
-## Versioning SPIRV-Tools
-
-See [`CHANGES`](CHANGES) for a high level summary of recent changes, by version.
-
-SPIRV-Tools project version numbers are of the form `v`*year*`.`*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](https://vulkan.lunarg.com/sdk/home).
-
-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](https://github.com/KhronosGroup/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`](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](CHANGES) file for reports on completed work, and
-the [Validator
-sub-project](https://github.com/KhronosGroup/SPIRV-Tools/projects/1) 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`](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`](include/spirv-tools/optimizer.hpp).
-
-For suggestions on using the code reduction options, please refer to this [white paper](https://www.lunarg.com/shader-compiler-technologies/white-paper-spirv-opt/).
-
-
-### 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](CHANGES) file for reports on completed work, and the [General
-sub-project](https://github.com/KhronosGroup/SPIRV-Tools/projects/2) 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](https://github.com/KhronosGroup/SPIRV-Tools/issues]) 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](https://github.com/google/graphicsfuzz) for fuzzing of GLSL shaders.
-
-To suggest an additional capability for the fuzzer, [file an
-issue](https://github.com/KhronosGroup/SPIRV-Tools/issues]) 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](#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/](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][spirv-tools-projects].
-
-(To provide feedback on the SPIR-V _specification_, file an issue on the
-[SPIRV-Headers][spirv-headers] GitHub repository.)
-
-See [`docs/projects.md`](docs/projects.md) to see how we use the
-[GitHub Project
-feature](https://help.github.com/articles/tracking-the-progress-of-your-work-with-projects/)
-to organize planned and in-progress work.
-
-Contributions via merge request are welcome. Changes should:
-* Be provided under the [Apache 2.0](#license).
-* You'll be prompted with a one-time "click-through"
- [Khronos Open Source Contributor License Agreement][spirv-tools-cla]
- (CLA) dialog as part of submitting your pull request or
- other contribution to GitHub.
-* Include tests to cover updated functionality.
-* C++ code should follow the [Google C++ Style Guide][cpp-style-guide].
-* Code should be formatted with `clang-format`.
- [kokoro/check-format/build.sh](kokoro/check-format/build.sh)
- shows how to download it. Note that we currently use
- `clang-format version 5.0.0` for SPIRV-Tools. Settings are defined by
- the included [.clang-format](.clang-format) file.
-
-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][effcee] library for stateful matching.
-Effcee itself depends on [RE2][re2], and RE2 depends on [Abseil][abseil-cpp].
-
-* 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][googletest] sources, not provided
-* `external/effcee`: Location of [Effcee][effcee] sources, if the `effcee` library
- is not already configured by an enclosing project.
-* `external/re2`: Location of [RE2][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][abseil-cpp] 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][spirv-headers], not provided
-* `include/spirv-tools/libspirv.h`: C API public interface
-* `source/`: API implementation
-* `test/`: Tests, using the [googletest][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][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](docs/downloads.md) page.
-
-First [get the sources](#getting-the-source).
-Then build using CMake, Bazel, Android ndk-build, or the Emscripten SDK.
-
-### Build using CMake
-You can build the project using [CMake][cmake]:
-
-```sh
-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:
-
-```sh
-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:
-
-```sh
-# 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](https://bazel.build/) to build the project.
-
-```sh
-bazel build :all
-```
-
-### Build a node.js package using Emscripten
-
-The SPIRV-Tools core library can be built to a WebAssembly [node.js](https://nodejs.org)
-module. The resulting `SpirvTools` WebAssembly module only exports methods to
-assemble and disassemble SPIR-V modules.
-
-First, make sure you have the [Emscripten SDK](https://emscripten.org).
-Then:
-
-```sh
-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](https://npmjs.org).
-
-To test the result:
-
-```sh
-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](http://www.cmake.org/): if using CMake for generating compilation
-targets, you need to install CMake Version 2.8.12 or later.
-- [Python 3](http://www.python.org/): for utility scripts and running the test
-suite.
-- [Bazel](https://bazel.build/) (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](https://emscripten.org) (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][clang-sanitizers].
- 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`](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](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`](https://chromium.googlesource.com/chromium/tools/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](http://www.graphviz.org/) 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](https://github.com/kbenzie/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:
-```shell
-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:
-```shell
-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:
-```shell
-bazel test --cxxopt=-std=c++17 :opt_def_use_test
-```
-
-on windows:
-```shell
-bazel test --cxxopt=/std:c++17 :opt_def_use_test
-```
-
-## Future Work
-<a name="future"></a>
-
-_See the [projects pages](https://github.com/KhronosGroup/SPIRV-Tools/projects)
-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
-<a name="license"></a>
-Full license terms are in [LICENSE](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.
-```
-
-[spirv-tools-cla]: https://cla-assistant.io/KhronosGroup/SPIRV-Tools
-[spirv-tools-projects]: https://github.com/KhronosGroup/SPIRV-Tools/projects
-[spirv-tools-mailing-list]: https://www.khronos.org/spir/spirv-tools-mailing-list
-[spirv-registry]: https://www.khronos.org/registry/spir-v/
-[spirv-headers]: https://github.com/KhronosGroup/SPIRV-Headers
-[googletest]: https://github.com/google/googletest
-[googletest-pull-612]: https://github.com/google/googletest/pull/612
-[googletest-issue-610]: https://github.com/google/googletest/issues/610
-[effcee]: https://github.com/google/effcee
-[re2]: https://github.com/google/re2
-[abseil-cpp]: https://github.com/abseil/abseil-cpp
-[CMake]: https://cmake.org/
-[cpp-style-guide]: https://google.github.io/styleguide/cppguide.html
-[clang-sanitizers]: http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
+# SwiftShader
+
+[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
+
+Introduction
+------------
+
+SwiftShader[^1] is a high-performance CPU-based implementation[^2] of the Vulkan[^3] 1.3 graphics API. Its goal is to provide hardware independence for advanced 3D graphics.
+
+> NOTE: The [ANGLE](http://angleproject.org/) project can be used to achieve a layered implementation[^4] of OpenGL ES 3.1 (aka. "SwANGLE").
+
+Building
+--------
+
+SwiftShader libraries can be built for Windows, Linux, and macOS.\
+Android and Chrome (OS) build environments are also supported.
+
+* **CMake**
+\
+ [Install CMake](https://cmake.org/download/) for Linux, macOS, or Windows and use either [the GUI](https://cmake.org/runningcmake/) or run the following terminal commands:
+ ```
+ cd build
+ cmake ..
+ cmake --build . --parallel
+
+ ./vk-unittests
+ ```
+ Tip: Set the [CMAKE_BUILD_PARALLEL_LEVEL](https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html) environment variable to control the level of parallelism.
+
+
+* **Visual Studio**
+\
+ To build the Vulkan ICD library, use [Visual Studio 2019](https://visualstudio.microsoft.com/vs/community/) to open the project folder and wait for it to run CMake. Open the [CMake Targets View](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019#ide-integration) in the Solution Explorer and select the vk_swiftshader project to [build](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019#building-cmake-projects) it.
+
+
+Usage
+-----
+
+The SwiftShader libraries act as drop-in replacements for graphics drivers.
+
+On Windows, most applications can be made to use SwiftShader's DLLs by placing them in the same folder as the executable. On Linux, the `LD_LIBRARY_PATH` environment variable or `-rpath` linker option can be used to direct applications to search for shared libraries in the indicated directory first.
+
+In general, Vulkan applications look for a shared library named `vulkan-1.dll` on Windows (`vulkan-1.so` on Linux). This 'loader' library then redirects API calls to the actual Installable Client Driver (ICD). SwiftShader's ICD is named `libvk_swiftshader.dll`, but it can be renamed to `vulkan-1.dll` to be loaded directly by the application. Alternatively, you can set the `VK_ICD_FILENAMES` environment variable to the path to `vk_swiftshader_icd.json` file that is generated under the build directory (e.g. `.\SwiftShader\build\Windows\vk_swiftshader_icd.json`). To learn more about how Vulkan loading works, read the [official documentation here](https://github.com/KhronosGroup/Vulkan-Loader/blob/master/loader/LoaderAndLayerInterface.md).
+
+Contributing
+------------
+
+See [CONTRIBUTING.txt](CONTRIBUTING.txt) for important contributing requirements.
+
+The canonical repository for SwiftShader is hosted at:
+https://swiftshader.googlesource.com/SwiftShader.
+
+All changes must be reviewed and approved in the [Gerrit](https://www.gerritcodereview.com/) review tool at:
+https://swiftshader-review.googlesource.com. You must sign in to this site with a Google Account before changes can be uploaded.
+
+Next, authenticate your account here:
+https://swiftshader.googlesource.com/new-password (use the same e-mail address as the one configured as the [Git commit author](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup#_your_identity)).
+
+All changes require a [Change-ID](https://gerrit-review.googlesource.com/Documentation/user-changeid.html) tag in the commit message. A [commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) may be used to add this tag automatically, and can be found at:
+https://gerrit-review.googlesource.com/tools/hooks/commit-msg. You can execute `git clone https://swiftshader.googlesource.com/SwiftShader` and manually place the commit hook in `SwiftShader/.git/hooks/`, or to clone the repository and install the commit hook in one go:
+
+ git clone https://swiftshader.googlesource.com/SwiftShader && (cd SwiftShader && git submodule update --init --recursive third_party/git-hooks && ./third_party/git-hooks/install_hooks.sh)
+
+On Windows, this command line requires using the [Git Bash Shell](https://www.atlassian.com/git/tutorials/git-bash).
+
+Changes are uploaded to Gerrit by executing:
+
+ git push origin HEAD:refs/for/master
+
+When ready, [add](https://gerrit-review.googlesource.com/Documentation/intro-user.html#adding-reviewers) a project [owner](OWNERS) as a reviewer on your change.
+
+Some tests will automatically be run against the change. Notably, [presubmit.sh](tests/presubmit.sh) verifies the change has been formatted using [clang-format 11.0.1](tests/kokoro/gcp_ubuntu/check_style.sh). Most IDEs come with clang-format support, but may require upgrading/downgrading to the [clang-format version 11.0.0](https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.0) *release* version (notably Chromium's buildtools has a clang-format binary which can be an in-between revision which produces different formatting results).
+
+Testing
+-------
+
+SwiftShader's Vulkan implementation can be tested using the [dEQP](https://github.com/KhronosGroup/VK-GL-CTS) test suite.
+
+See [docs/dEQP.md](docs/dEQP.md) for details.
+
+Third-Party Dependencies
+------------------------
+
+The [third_party](third_party/) directory contains projects which originated outside of SwiftShader:
+
+[subzero](third_party/subzero/) contains a fork of the [Subzero](https://chromium.googlesource.com/native_client/pnacl-subzero/) project. It originates from Google Chrome's (Portable) [Native Client](https://developer.chrome.com/native-client) project. The fork was made using [git-subtree](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt) to include all of Subzero's history.
+
+[llvm-subzero](third_party/llvm-subzero/) contains a minimized set of LLVM dependencies of the Subzero project.
+
+[PowerVR_SDK](third_party/PowerVR_SDK/) contains a subset of the [PowerVR Graphics Native SDK](https://github.com/powervr-graphics/Native_SDK) for running several sample applications.
+
+[googletest](third_party/googletest/) contains the [Google Test](https://github.com/google/googletest) project, as a Git submodule. It is used for running unit tests for Chromium, and Reactor unit tests. Run `git submodule update --init` to obtain/update the code. Any contributions should be made upstream.
+
+Documentation
+-------------
+
+See [docs/Index.md](docs/Index.md).
+
+Contact
+-------
+
+Public mailing list: [swiftshader@googlegroups.com](https://groups.google.com/forum/#!forum/swiftshader)
+
+General bug tracker: https://g.co/swiftshaderbugs \
+Chrome specific bugs: https://bugs.chromium.org/p/swiftshader
+
+License
+-------
+
+The SwiftShader project is licensed under the Apache License Version 2.0. You can find a copy of it in [LICENSE.txt](LICENSE.txt).
+
+Files in the third_party folder are subject to their respective license.
+
+Authors and Contributors
+------------------------
+
+The legal authors for copyright purposes are listed in [AUTHORS.txt](AUTHORS.txt).
+
+[CONTRIBUTORS.txt](CONTRIBUTORS.txt) contains a list of names of individuals who have contributed to SwiftShader. If you're not on the list, but you've signed the [Google CLA](https://cla.developers.google.com/clas) and have contributed more than a formatting change, feel free to request to be added.
+
+Notes and Disclaimers
+---------------------
+
+[^1]: This is not an official Google product.
+[^2]: Vulkan 1.3 conformance: https://www.khronos.org/conformance/adopters/conformant-products#submission_717
+[^3]: Trademarks are the property of their respective owners.
+[^4]: OpenGL ES 3.1 conformance: https://www.khronos.org/conformance/adopters/conformant-products/opengles#submission_906
\ No newline at end of file
diff --git a/android_test/Android.mk b/android_test/Android.mk
deleted file mode 100644
index b9a0014..0000000
--- a/android_test/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc .cpp .cxx
-LOCAL_SRC_FILES:=test.cpp
-LOCAL_MODULE:=spirvtools_test
-LOCAL_LDLIBS:=-landroid
-LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror
-LOCAL_STATIC_LIBRARIES=SPIRV-Tools SPIRV-Tools-opt
-include $(BUILD_SHARED_LIBRARY)
-
-include $(LOCAL_PATH)/../Android.mk
diff --git a/android_test/jni/Application.mk b/android_test/jni/Application.mk
deleted file mode 100644
index 47c0acf..0000000
--- a/android_test/jni/Application.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-APP_ABI := all
-APP_BUILD_SCRIPT := Android.mk
-APP_STL := c++_static
-APP_PLATFORM := android-24
-NDK_TOOLCHAIN_VERSION := 4.9
diff --git a/build/android.toolchain.cmake b/build/android.toolchain.cmake
new file mode 100644
index 0000000..d9806e3
--- /dev/null
+++ b/build/android.toolchain.cmake
@@ -0,0 +1,13 @@
+set(CMAKE_SYSTEM_NAME Android)
+if(NOT $ENV{ANDROID_HOME} STREQUAL "")
+ set(CMAKE_ANDROID_NDK $ENV{ANDROID_HOME}/ndk-bundle)
+else()
+ set(CMAKE_ANDROID_NDK $ENV{HOME}/Android/Sdk/ndk-bundle)
+endif()
+set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
+set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
+set(CMAKE_ANDROID_STL_TYPE c++_shared)
+if(APPLE)
+ set(CMAKE_RANLIB "${CMAKE_ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ranlib")
+ set(CMAKE_AR "${CMAKE_ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/ar")
+endif()
diff --git a/build/strip_cmakelists.sh b/build/strip_cmakelists.sh
new file mode 100755
index 0000000..161fd3d
--- /dev/null
+++ b/build/strip_cmakelists.sh
@@ -0,0 +1,2 @@
+cd $(dirname $0)
+go run strip_unneeded.go --file=../CMakeLists.txt --test="cmake -DREACTOR_BACKEND=LLVM -DREACTOR_EMIT_DEBUG_INFO=1 .. && cmake --build ."
\ No newline at end of file
diff --git a/build/strip_unneeded.go b/build/strip_unneeded.go
new file mode 100644
index 0000000..a4a1bf5
--- /dev/null
+++ b/build/strip_unneeded.go
@@ -0,0 +1,123 @@
+// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
+//
+// 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.
+
+// strip_unneeded is a tool that attempts to remove unnecessary lines from a
+// file by running a test script after each marked line is removed.
+//
+// strip_unneeded will scan the file specified by the --file argument for lines
+// that contain the substring specified by the --marker argument. One-by-one
+// those marked lines will be removed from the file, after which the test script
+// specified by --test will be run. If the test passes (the process completes
+// with a 0 return code), then the line will remain removed, otherwise it is
+// restored. This will repeat for every line in the file containing the marker,
+// until all lines are tested.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "strings"
+)
+
+var (
+ file = flag.String("file", "", "file to modify")
+ marker = flag.String("marker", "CHECK_NEEDED", "line token")
+ test = flag.String("test", "", "test script to run with each change")
+)
+
+func main() {
+ if err := run(); err != nil {
+ fmt.Println(err.Error())
+ os.Exit(1)
+ }
+}
+
+func run() error {
+ flag.Parse()
+ if *file == "" {
+ return fmt.Errorf("Missing --file argument")
+ }
+ if *marker == "" {
+ return fmt.Errorf("Missing --marker argument")
+ }
+ if *test == "" {
+ return fmt.Errorf("Missing --test argument")
+ }
+
+ // make sure the test passes with no modifications
+ if err := runTest(); err != nil {
+ return fmt.Errorf("Test fails with no modifications.\n%v", err)
+ }
+
+ // load the test file
+ body, err := ioutil.ReadFile(*file)
+ if err != nil {
+ return fmt.Errorf("Couldn't load file '%v'", *file)
+ }
+
+ // gather all the lines
+ allLines := strings.Split(string(body), "\n")
+
+ // find all the lines with the marker
+ markerLines := make([]int, 0, len(allLines))
+ for i, l := range allLines {
+ if strings.Contains(l, *marker) {
+ markerLines = append(markerLines, i)
+ }
+ }
+
+ omit := map[int]bool{}
+
+ save := func() error {
+ f, err := os.Create(*file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ for i, l := range allLines {
+ if !omit[i] {
+ f.WriteString(l)
+ f.WriteString("\n")
+ }
+ }
+ return nil
+ }
+
+ for i, l := range markerLines {
+ omit[l] = true
+ if err := save(); err != nil {
+ return err
+ }
+ if err := runTest(); err != nil {
+ omit[l] = false
+ fmt.Printf("%d/%d: Test fails when removing line %v: %v\n", i, len(markerLines), l, allLines[l])
+ } else {
+ fmt.Printf("%d/%d: Test passes when removing line %v: %v\n", i, len(markerLines), l, allLines[l])
+ }
+ }
+
+ return save()
+}
+
+func runTest() error {
+ cmd := exec.Command("sh", "-c", *test)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("Test failed with error: %v\n%v", err, string(out))
+ }
+ return nil
+}
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index cf3d6b7..e2af644 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -1,10 +1,10 @@
-# Copyright 2018 Google Inc.
+# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
#
# 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
#
-# https://www.apache.org/licenses/LICENSE-2.0
+# 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,
@@ -12,32 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Variable that can be used to support multiple build scenarios, like having
-# Chromium specific targets in a client project's GN file etc.
build_with_chromium = false
-
-declare_args() {
- # Android 32-bit non-component, non-clang builds cannot have symbol_level=2
- # due to 4GiB file size limit, see https://crbug.com/648948.
- # Set this flag to true to skip the assertion.
- ignore_elf32_limitations = false
-
- # Use the system install of Xcode for tools like ibtool, libtool, etc.
- # This does not affect the compiler. When this variable is false, targets will
- # instead use a hermetic install of Xcode. [The hermetic install can be
- # obtained with gclient sync after setting the environment variable
- # FORCE_MAC_TOOLCHAIN].
- use_system_xcode = ""
-}
-
-if (use_system_xcode == "") {
- if (target_os == "mac") {
- _result = exec_script("//build/mac/should_use_hermetic_xcode.py",
- [ target_os ],
- "value")
- use_system_xcode = _result == 0
- }
- if (target_os == "ios") {
- use_system_xcode = true
- }
-}
diff --git a/build_overrides/spirv_tools.gni b/build_overrides/spirv_tools.gni
index 24aa033..7364b5c 100644
--- a/build_overrides/spirv_tools.gni
+++ b/build_overrides/spirv_tools.gni
@@ -1,10 +1,10 @@
-# Copyright 2018 Google Inc. All rights reserved.
+# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
#
# 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
+# 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,
@@ -12,14 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# These are variables that are overridable by projects that include
-# SPIRV-Tools. The values in this file are the defaults for when we are
-# building from SPIRV-Tools' repository.
+# We are building inside SwiftShader
+spirv_tools_standalone = false
-# Whether we are building from SPIRV-Tools' repository.
-# MUST be set to false in other projects.
-spirv_tools_standalone = true
-
-# The path to SPIRV-Tools' dependencies
-spirv_tools_googletest_dir = "//external/googletest"
-spirv_tools_spirv_headers_dir = "//external/spirv-headers"
+# Paths to SPIRV-Tools dependencies in SwiftShader
+spirv_tools_googletest_dir = "//third_party/googletest"
+spirv_tools_spirv_headers_dir = "//third_party/SPIRV-Headers"
diff --git a/build_overrides/swiftshader.gni b/build_overrides/swiftshader.gni
new file mode 100644
index 0000000..e2eda47
--- /dev/null
+++ b/build_overrides/swiftshader.gni
@@ -0,0 +1,19 @@
+# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
+#
+# 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.
+
+# We are building SwiftShader standalone
+swiftshader_standalone = true
+
+# Path to SwiftShader
+swiftshader_dir = "//"
diff --git a/build_overrides/wayland.gni b/build_overrides/wayland.gni
new file mode 100644
index 0000000..e50b0fd
--- /dev/null
+++ b/build_overrides/wayland.gni
@@ -0,0 +1,18 @@
+# Copyright 2022 The SwiftShader Authors. All Rights Reserved.
+#
+# 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.
+
+ozone_platform_wayland = true
+
+# SwiftShader has no wayland third-party dir
+wayland_gn_dir = ""
diff --git a/codereview.settings b/codereview.settings
index ef84cf8..4ff2001 100644
--- a/codereview.settings
+++ b/codereview.settings
@@ -1,2 +1,4 @@
# This file is used by git cl to get repository specific information.
-CODE_REVIEW_SERVER: github.com
+PROJECT: swiftshader
+GERRIT_HOST: True
+GERRIT_SQUASH_UPLOADS: False
diff --git a/docs/ArchitectureLayers.png b/docs/ArchitectureLayers.png
new file mode 100644
index 0000000..8049804
--- /dev/null
+++ b/docs/ArchitectureLayers.png
Binary files differ
diff --git a/docs/Exp-Log-Optimization.pdf b/docs/Exp-Log-Optimization.pdf
new file mode 100644
index 0000000..a2424d0
--- /dev/null
+++ b/docs/Exp-Log-Optimization.pdf
Binary files differ
diff --git a/docs/Index.md b/docs/Index.md
new file mode 100644
index 0000000..2ec49f5
--- /dev/null
+++ b/docs/Index.md
@@ -0,0 +1,65 @@
+> :warning: **Out of date**
+
+SwiftShader Documentation
+=========================
+
+SwiftShader provides high-performance graphics rendering on the CPU. It eliminates the dependency on graphics hardware capabilities.
+
+Architecture
+------------
+
+SwiftShader provides shared libraries (DLLs) which implement standardized graphics APIs. Applications already using these APIs thus don't require any changes to use SwiftShader. It can run entirely in user space, or as a driver (for Android), and output to either a frame buffer, a window, or an offscreen buffer.
+
+To achieve exceptional performance, SwiftShader is built around two major optimizations that affect its architecture: dynamic code generation, and parallel processing. Generating code at run-time allows to eliminate code branches and optimizes register usage, specializing the processing routines for exactly the operations required by each draw call. Parallel processing means both utilizing the CPU's multiple cores and processing multiple elements accoss the width of the SIMD vector units.
+
+Structurally there are four major layers:
+
+![API, Renderer, Reactor, JIT](/docs/ArchitectureLayers.png "Architecture Layers")
+
+The API layer is an implementation of a graphics API, such as OpenGL (ES) or Direct3D, on top of the Renderer interface. It is responsible for managing API-level resources and rendering state, as well as compiling high-level shaders to bytecode form.
+
+The Renderer layer generates specialized processing routines for draw calls and coordinates the execution of rendering tasks. It defines the data structures used and how the processing is performed.
+
+Reactor is an embedded language for C++ to dynamically generate code in a WYSIWYG fashion. It allows to specialize the processing routines for the state and shaders used by each draw call. Its syntax closely resembles C and shading languages, to make the code generation easily readable.
+
+The JIT layer is a run-time compiler, such as [LLVM](http://llvm.org/)'s JIT, or [Subzero](Subzero.md). Reactor records its operations in an in-memory intermediate form which can be materialized by the JIT into a function which can be called directly.
+
+Design
+------
+
+### Reactor
+
+To generate code for an expression such as `float y = 1 - x;` directly with LLVM, we'd need code like `Value *valueY = BinaryOperator::CreateSub(ConstantInt::get(Type::getInt32Ty(Context), 1), valueX, "y", basicBlock);`. This is very verbose and becomes hard to read for longer expressions. Using C++ operator overloading, [Reactor](../src/Reactor/) simplifies this to `Float y = 1 - x;`. Note that Reactor types have the same names as C types, but starting with a capital letter. Likewise `If()`, `Else`, and `For(,,)` implement their C counterparts.
+
+While making Reactor's syntax so similar to the C++ in which it is written might cause some confusion at first, it provides a powerful abstraction for code specialization. For example to produce the code for an addition or a subtraction, one could write `x = addOrSub ? x + y : x - y;`. Note that only one operation ends up in the generated code.
+
+We refer to the functions generated by Reactor code as [Routine](../src/Reactor/Routine.hpp)s.
+
+More details on Reactor can be found in [Reactor.md](Reactor.md).
+
+### Renderer
+
+The [Renderer](../src/Renderer/) layer is implemented in three main parts: the [VertexProcessor](../src/Renderer/VertexProcessor.cpp), [SetupProcessor](../src/Renderer/SetupProcessor.cpp), and [PixelProcessor](../src/Renderer/PixelProcessor.cpp). Each "processor" produces a corresponding Reactor routine, and manages the relevant graphics state. They also keep a cache of already generated routines, so that when a combination of states is encountered again it will reuse the routine that performs the desired processing.
+
+The [VertexRoutine](../src/Shader/VertexRoutine.cpp) produces a function for processing a batch of vertices. The fixed-function T&L pipeline is implemented by [VertexPipeline](../src/Shader/VertexPipeline.cpp), while programmable vertex processing with a shader is implemented by [VertexProgram](../src/Shader/VertexProgram.cpp). Note that the vertex routine also performs vertex attribute reading, vertex caching, viewport transform, and clip flag calculation all in the same function.
+
+The [SetupRoutine](../src/Shader/SetupRoutine.cpp) performs primitive setup. This constitutes back-face culling, computing gradients, and rasterization.
+
+The [PixelRoutine](../src/Shader/PixelRoutine.cpp) takes a batch of primitives and performs per-pixel operations. The fixed-function texture stages and legacy integer shaders are implemented by [PixelPipeline](../src/Shader/PixelPipeline.cpp), while programmable pixel processing with a shader is implemented by [PixelProgram](../src/Shader/PixelProgram.cpp). All other per-pixel operations such as the depth test, alpha test, stenciling, and alpha blending are also performed in the pixel routine. Together with the traversal of the pixels in [QuadRasterizer](../src/Renderer/QuadRasterizer.cpp), it forms one function.
+
+The PixelProgram and VertexProgram share some common functionality in [ShaderCore](../src/Shader/ShaderCore.cpp). Likewise, texture sampling is implemented by [SamplerCore](../src/Shader/SamplerCore.cpp).
+
+Aside from creating and managing the processing routines with the help of the Processor classes, the Renderer also subdivides and schedules rendering tasks onto multiple threads.
+
+### OpenGL
+
+The OpenGL (ES) and EGL APIs are implemented in [src/OpenGL/](../src/OpenGL/).
+
+The GLSL compiler is implemented in [src/OpenGL/compiler/](../src/OpenGL/compiler/). It uses [Flex](http://flex.sourceforge.net/) and [Bison](https://www.gnu.org/software/bison/) to tokenize and parse GLSL shader source. It produces an [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (AST), which is then traversed to output assembly-level instructions in [OutputASM.cpp](../src/OpenGL/compiler/OutputASM.cpp).
+
+The [EGL](https://www.khronos.org/registry/egl/specs/eglspec.1.4.20110406.pdf) API is implemented in [src/OpenGL/libEGL/](../src/OpenGL/libEGL/). Its entry functions are listed in [libEGL.def](../src/OpenGL/libEGL/libEGL.def) (for Windows) and [libEGL.lds](../src/OpenGL/libEGL/libEGL.lds) (for Linux), and defined in [main.cpp](../src/OpenGL/libEGL/main.cpp) and implemented in [libEGL.cpp](../src/OpenGL/libEGL/libEGL.cpp). The [Display](../src/OpenGL/libEGL/Display.h), [Surface](../src/OpenGL/libEGL/Surface.h), and [Config](../src/OpenGL/libEGL/Config.h) classes are respective implementations of the abstract EGLDisplay, EGLSurface, and EGLConfig types.
+
+[OpenGL ES 2.0](https://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf) is implemented in [src/OpenGL/libGLESv2/](../src/OpenGL/libGLESv2/). Note that while [OpenGL ES 3.0](https://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf) functions are implemented in [libGLESv3.cpp](../src/OpenGL/libGLESv2/libGLESv3.cpp), it is compiled into the libGLESv2 library as standard among most implementations (some platforms have a libGLESv3 symbolically link to libGLESv2). We'll focus on OpenGL ES 2.0 in this documentation.
+
+When the application calls an OpenGL function, it lands in the C entry functions at [main.cpp](../src/OpenGL/libGLESv2/main.cpp). It then gets dispatched to [libGLESv2.cpp](../src/OpenGL/libGLESv2/libGLESv2.cpp) functions in the es2 namespace. These functions obtain the thread's OpenGL context, and perform validation of the call's parameters. Most functions then call a corresponding [Context](../src/OpenGL/libGLESv2/Context.h) method to perform the call's main operations (changing state or queuing a draw task).
+
diff --git a/docs/LLVM.md b/docs/LLVM.md
new file mode 100644
index 0000000..ce504c2
--- /dev/null
+++ b/docs/LLVM.md
@@ -0,0 +1,114 @@
+LLVM Dependency
+===============
+
+Overview
+--------
+
+SwiftShader's [Reactor](Reactor.md) library uses LLVM
+as one of its JIT-compiler backends. This page contains notes about building and
+upgrading LLVM.
+
+Directory structure
+-------------------
+
+The current version of LLVM we use is 10, and can be found in
+`third_party/llvm-10.0`.
+
+In this folder you will find the following directories:
+
+* configs : Contains per-platform headers that LLVM sources include to
+ configure the build. These are generated by running `scripts/update.py`
+ (more on that below).
+* llvm : Contains a subset of the LLVM source code needed to build the JIT
+ support required by SwiftShader.
+* scripts : Contains `update.py`, which is used to update the files in the
+ `configs` folder. More on that below.
+
+Updating the current version of LLVM to latest
+----------------------------------------------
+
+Updating to the latest version of LLVM can be tricky to do manually, especially
+because the [llvm-project repo](https://github.com/llvm/llvm-project) includes
+much more than just LLVM (e.g. it includes all the Clang source). Furthermore,
+we may have local changes to our copy of LLVM that must be maintained, or at
+least considered across updates.
+
+To ease this pain, run the script `third_party/update-llvm-10.sh` on Linux. This
+script works by updating a separate branch of SwiftShader, `llvm10-clean`, on
+which the latest snapshot of LLVM is fetched and committed, and then this branch
+is merged back into `master`. During the merge, if there are conflicts to
+resolve because of local changes we've made, these can be resolved in the usual
+manner, and the merge can be resumed.
+
+The script is configured to fetch from the branch in `LLVM_REPO_BRANCH`, and
+will automatically grab the latest commit on that branch.
+
+Although not always necessary, if there were new configuration variables added
+or modified, you may need to run `update.py` as described below. Otherwise, if
+all goes well, the update to LLVM can be committed and pushed.
+
+Updating LLVM configuration files
+---------------------------------
+
+The script `third_party/llvm-10.0/scripts/update.py` is used to update the
+config files in `third_party/llvm-10.0/configs`.
+
+Before running this script, you must make sure to update two variables in it
+(and commit this change):
+
+```
+# LLVM_BRANCH must match the value of the same variable in third_party/update-llvm-10.sh
+LLVM_BRANCH = "release/10.x"
+
+# LLVM_COMMIT must be set to the commit hash that we last updated to when running third_party/update-llvm-10.sh.
+# Run 'git show -s origin/llvm10-clean' and look for 'llvm-10-update: <hash>' to retrieve it.
+LLVM_COMMIT = "d32170dbd5b0d54436537b6b75beaf44324e0c28"
+```
+
+The script takes a platform as argument, and extra CMake args. For example, to
+update the Linux configs, run:
+
+```
+python3 update.py linux -j 200
+```
+
+This script does the following:
+
+* Clones the LLVM repo and checks out `LLVM_COMMIT` from `LLVM_BRANCH`.
+* Builds LLVM specifically for the target architectures specified in
+ `LLVM_TRIPLES` dictionary.
+* Copies the specified platform config files to
+ `third_party/llvm-10.0/configs`, applying certain transformations to the
+ files, such as undefining macros listed in `LLVM_UNDEF_MACROS` (see the
+ `copy_platform_file` function).
+
+Note that certain configuration options depend on the host OS, you will need to
+run the script on the right host OS. See the `LLVM_PLATFORM_TO_HOST_SYSTEM`
+dictionary for the mapping, which looks like this at the time of this writing:
+
+```
+# Mapping of target platform to the host it must be built on
+LLVM_PLATFORM_TO_HOST_SYSTEM = {
+ 'android': 'Linux',
+ 'darwin': 'Darwin',
+ 'linux': 'Linux',
+ 'windows': 'Windows',
+ 'fuchsia': 'Linux'
+}
+```
+
+Generally, Windows to build Window, Darwin to build Darwin (MacOS), and Linux
+for everything else. Also note that for android and fuchsia, the config is
+closest to that of Linux, but you will likely have to manually tweak the configs
+(in particular, `configs/<platform>/include/llvm/Config/config.h`).
+
+Supported platforms, architectures, and build systems
+-----------------------------------------------------
+
+SwiftShader is used by many products on many architectures:
+
+* OS: Windows, Linux, MacOS, Android, Fuchsia
+* Architecture: x64, x86, ARM, ARM64, MIPS, MIPS64
+* Build systems: CMake, GN, Soong, Blaze
+
+Upgrading/updating LLVM usually entails making sure it builds for all of these.
\ No newline at end of file
diff --git a/docs/Reactor.md b/docs/Reactor.md
new file mode 100644
index 0000000..5666851
--- /dev/null
+++ b/docs/Reactor.md
@@ -0,0 +1,311 @@
+Reactor Documentation
+=====================
+
+Reactor is an embedded language for C++ to facilitate dynamic code generation and specialization.
+
+Introduction
+------------
+
+To generate the code for an expression such as
+```C++
+float y = 1 - x;
+```
+using the LLVM compiler framework, one needs to execute
+```C++
+Value *valueY = BinaryOperator::CreateSub(ConstantInt::get(Type::getInt32Ty(Context), 1), valueX, "y", basicBlock);
+```
+
+For large expressions this quickly becomes hard to read, and tedious to write and modify.
+
+With Reactor, it becomes as simple as writing
+```C++
+Float y = 1 - x;
+```
+Note the capital letter for the type. This is not the code to perform the calculation. It's the code that when executed will record the calculation to be performed.
+
+This is possible through the use of C++ operator overloading. Reactor also supports control flow constructs and pointer arithmetic with C-like syntax.
+
+Motivation
+----------
+
+Just-in-time (JIT) compiled code has the potential to be faster than statically compiled code, through [run-time specialization](http://en.wikipedia.org/wiki/Run-time_algorithm_specialisation). However, this is rarely achieved in practice.
+
+Specialization in general is the use of a more optimal routine that is specific for a certain set of conditions. For example when sorting two numbers it is faster to swap them if they are not yet in order, than to call a generic quicksort function. Specialization can be done statically, by explicitly writing each variant or by using metaprogramming to generate multiple variants at static compile time, or dynamically by examining the parameters at run-time and generating a specialized path.
+
+Because specialization can be done statically, sometimes aided by metaprogramming, the ability of a JIT-compiler to do it at run-time is often disregarded. Specialized benchmarks show no advantage of JIT code over static code. However, having a specialized benchmark does not take into account that a typical real-world application deals with many unpredictable conditions. Systems can have one core or several dozen cores, and many different ISA extensions. This alone can make it impractical to write fully specialized routines manually, and with the help of metaprogramming it results in code bloat. Worse yet, any non-trivial application has a layered architecture in which lower layers (e.g. framework APIs) know very little or nothing about the usage by higher layers. Various parameters also depend on user input. Run-time specialization can have access to the full context in which each routine executes, and although the optimization contribution of specialization for a single parameter is small, the combined speedup can be huge. As an extreme example, interpreters can execute any kind of program in any language, but by specializing for a specific program you get a compiled version of that program. But you don't need a full-blown language to observe a huge difference between interpretation and specialization through compilation. Most applications process some form of list of commands in an interpreted fashion, and even the series of calls into a framework API can be compiled into a more efficient whole at run-time.
+
+While the benefit of run-time specialization should now be apparent, JIT-compiled languages lack many of the practical advantages of static compilation. JIT-compilers are very constrained in how much time they can spend on compiling the bytecode into machine code. This limits their ability to even reach parity with static compilation, let alone attempt to exceed it by performing run-time specialization. Also, even if the compilation time was not as constrained, they can't specialize at every opportunity because it would result in an explosive growth of the amount of generated code. There's a need to be very selective in only specializing the hotspots for often recurring conditions, and to manage a cache of the different variants. Even just selecting the size of the set of variables that form the entire condition to specialize for can get immensely complicated.
+
+Clearly we need a manageable way to benefit from run-time specialization where it would help significantly, while still resorting to static compilation for anything else. A crucial observation is that the developer has expectations about the application's behavior, which is valuable information which can be exploited to choose between static or JIT-compilation. One way to do that is to use an API which JIT-compiles the commands provided by the application developer. An example of this is an advanced DBMS which compiles the query into an optimized sequence of routines, each specialized to the data types involved, the sizes of the CPU caches, etc. Another example is a modern graphics API, which takes shaders (a routine executed per pixel or other element) and a set of parameters which affect their execution, and compiles them into GPU-specific code. However, these examples have a very hard divide between what goes on inside the API and outside. You can't exchange data between the statically compiled outside world and the JIT-compiled routines, unless through the API, and they have very different execution models. In other words they are highly domain specific and not generic ways to exploit run-time specialization in arbitrary code.
+
+This is becoming especially problematic for GPUs, as they are now just as programmable as CPUs but you can still only command them through an API. Attempts to disguise this by using a single language, such as C++AMP and SYCL, still have difficulties expressing how data is exchanged, don't actually provide control over the specialization, they have hidden overhead, and they have unpredictable performance characteristics across devices. Meanwhile CPUs gain ever more cores and wider SIMD vector units, but statically compiled languages don't readily exploit this and can't deal with the many code paths required to extract optimal performance. A different language and framework is required.
+
+Concepts and Syntax
+-------------------
+
+### Routine and Function<>
+
+Reactor allows you to create new functions at run-time. Their generation happens in C++, and after materializing them they can be called during the execution of the same C++ program. We call these dynamically generated functions "routines", to discern them from statically compiled functions and methods. Reactor's `Routine` class encapsulates a routine. Deleting a Routine object also frees the memory used to store the routine.
+
+To declare the function signature of a routine, use the `Function<>` template. The template argument is the signature of a function, using Reactor variable types. Here's a complete definition of a routine taking no arguments and returning an integer:
+
+`C++
+Function<Int(Void)> function;
+{
+ Return(1);
+}
+`
+
+The braces are superfluous. They just make the syntax look more like regular C++, and they offer a new scope for Reactor variables.
+
+The Routine is obtained and materialized by "calling" the `Function<>` object to give it a name:
+
+```C++
+auto routine = function("one");
+```
+
+Finally, we can obtain the function pointer to the entry point of the routine, and call it:
+
+```C++
+int (*callable)() = (int(*)())routine->getEntry();
+
+int result = callable();
+assert(result == 1);
+```
+
+Note that `Function<>` objects are relatively heavyweight, since they have the entire JIT-compiler behind them, while `Routine` objects are lightweight and merely provide storage and lifetime management of generated routines. So we typically allow the `Function<>` object to be destroyed (by going out of scope), while the `Routine` object is retained until we no longer need to call the routine. Hence the distinction between them and the need for a couple of lines of boilerplate code.
+
+### Arguments and Expressions
+
+Routines can take various arguments. The following example illustrates the syntax for accessing the arguments of a routine which takes two integer arguments and returns their sum:
+
+```C++
+Function<Int(Int, Int)> function;
+{
+ Int x = function.Arg<0>();
+ Int y = function.Arg<1>();
+
+ Int sum = x + y;
+
+ Return(sum);
+}
+```
+
+Reactor supports various types which correspond to C++ types:
+
+| Class name | C++ equivalent |
+| ------------- |----------------|
+| Int | int32_t |
+| UInt | uint32_t |
+| Short | int16_t |
+| UShort | uint16_t |
+| Byte | uint8_t |
+| SByte | int8_t |
+| Long | int64_t |
+| ULong | uint64_t |
+| Float | float |
+
+Note that bytes are unsigned unless prefixed with S, while larger integers are signed unless prefixed with U.
+
+These scalar types support all of the C++ arithmetic operations.
+
+Reactor also supports several vector types. For example `Float4` is a vector of four floats. They support a select number of C++ operators, and several "intrinsic" functions such as `Max()` to compute the element-wise maximum and return a bit mask. Check [Reactor.hpp](../src/Reactor/Reactor.hpp) for all the types, operators and intrinsics.
+
+### Casting and Reinterpreting
+
+Types can be cast using the constructor-style syntax:
+
+```C++
+Function<Int(Float)> function;
+{
+ Float x = function.Arg<0>();
+
+ Int cast = Int(x);
+
+ Return(cast);
+}
+```
+
+You can reinterpret-cast a variable using `As<>`:
+
+```C++
+Function<Int(Float)> function;
+{
+ Float x = function.Arg<0>();
+
+ Int reinterpret = As<Int>(x);
+
+ Return(reinterpret);
+}
+```
+
+Note that this is a bitwise cast. Unlike C++'s `reinterpret_cast<>`, it does not allow casting between different sized types. Think of it as storing the value in memory and then loading from that same address into the casted type.
+
+An important exception is that 16-, 8-, and 4-byte vectors can be cast to other vectors of one of these sizes. Casting to a longer vector leaves the upper contents undefined.
+
+### Pointers
+
+Pointers also use a template class:
+
+```C++
+Function<Int(Pointer<Int>)> function;
+{
+ Pointer<Int> x = function.Arg<0>();
+
+ Int dereference = *x;
+
+ Return(dereference);
+}
+```
+
+Pointer arithmetic is only supported on `Pointer<Byte>`, and can be used to access structure fields:
+
+```C++
+struct S
+{
+ int x;
+ int y;
+};
+
+Function<Int(Pointer<Byte>)> function;
+{
+ Pointer<Byte> s = function.Arg<0>();
+
+ Int y = *Pointer<Int>(s + offsetof(S, y));
+
+ Return(y);
+}
+```
+
+Reactor also defines an `OFFSET()` macro, which is a generalization of the `offsetof()` macro defined in `<cstddef>`. It allows e.g. getting the offset of array elements, even when indexed dynamically.
+
+### Conditionals
+
+To generate for example the [unit step](https://en.wikipedia.org/wiki/Heaviside_step_function) function:
+
+```C++
+Function<Float(Float)> function;
+{
+ Pointer<Float> x = function.Arg<0>();
+
+ If(x > 0.0f)
+ {
+ Return(1.0f);
+ }
+ Else If(x < 0.0f)
+ {
+ Return(0.0f);
+ }
+ Else
+ {
+ Return(0.5f);
+ }
+}
+```
+
+There's also an IfThenElse() intrinsic function which corresponds with the C++ ?: operator.
+
+### Loops
+
+Loops also have a syntax similar to C++:
+
+```C++
+Function<Int(Pointer<Int>, Int)> function;
+{
+ Pointer<Int> p = function.Arg<0>();
+ Int n = function.Arg<1>();
+ Int total = 0;
+
+ For(Int i = 0, i < n, i++)
+ {
+ total += p[i];
+ }
+
+ Return(total);
+}
+```
+
+Note the use of commas instead of semicolons to separate the loop expressions.
+
+`While(expr) {}` also works as expected, but there is no `Do {} While(expr)` equivalent because we can't discern between them. Instead, there's a `Do {} Until(expr)` where you can use the inverse expression to exit the loop.
+
+Specialization
+--------------
+
+The above examples don't illustrate anything that can't be written as regular C++ function. The real power of Reactor is to generate routines that are specialized for a certain set of conditions, or "state".
+
+```C++
+Function<Int(Pointer<Int>, Int)> function;
+{
+ Pointer<Int> p = function.Arg<0>();
+ Int n = function.Arg<1>();
+ Int total = 0;
+
+ For(Int i = 0, i < n, i++)
+ {
+ if(state.operation == ADD)
+ {
+ total += p[i];
+ }
+ else if(state.operation == SUBTRACT)
+ {
+ total -= p[i];
+ }
+ else if(state.operation == AND)
+ {
+ total &= p[i];
+ }
+ else if(...)
+ {
+ ...
+ }
+ }
+
+ Return(total);
+}
+```
+
+Note that this example uses regular C++ `if` and `else` constructs. They only determine which code ends up in the generated routine, and don't end up in the generated code themselves. Thus the routine contains a loop with just one arithmetic or logical operation, making it more efficient than if this was written in regular C++.
+
+Of course one could write an equivalent efficient function in regular C++ like this:
+
+```C++
+int function(int *p, int n)
+{
+ int total = 0;
+
+ if(state.operation == ADD)
+ {
+ for(int i = 0; i < n; i++)
+ {
+ total += p[i];
+ }
+ }
+ else if(state.operation == SUBTRACT)
+ {
+ for(int i = 0; i < n; i++)
+ {
+ total -= p[i];
+ }
+ }
+ else if(state.operation == AND)
+ {
+ for(int i = 0; i < n; i++)
+ {
+ total &= p[i];
+ }
+ }
+ else if(...)
+ {
+ ...
+ }
+
+ return total;
+}
+```
+
+But now there's a lot of repeated code. It could be made more manageable using macros or templates, but that doesn't help reduce the binary size of the statically compiled code. That's fine when there are only a handful of state conditions to specialize for, but when you have multiple state variables with many possible values each, the total number of combinations can be prohibitive.
+
+This is especially the case when implementing APIs which offer a broad set of features but developers are likely to only use a select set. The quintessential example is graphics processing, where there are are long pipelines of optional operations and both fixed-function and programmable stages. Applications configure the state of these stages between each draw call.
+
+With Reactor, we can write the code for such pipelines in a syntax that is as easy to read as a naive unoptimized implementation, while at the same time specializing the code for exactly the operations required by the pipeline configuration.
diff --git a/docs/ReactorDebugInfo.md b/docs/ReactorDebugInfo.md
new file mode 100644
index 0000000..3b612d4
--- /dev/null
+++ b/docs/ReactorDebugInfo.md
@@ -0,0 +1,237 @@
+# Reactor Debug Info Generation
+
+## Introduction
+
+Reactor produces Just In Time compiled dynamic executable code and can be used to JIT high performance functions specialized for runtime
+configurations, or to even build a compiler.
+
+In order to debug executable code at a higher level than disassembly, source code files are required.
+
+Reactor has two potential sources of source code:
+
+1. The C++ source code of the program that calls into Reactor.
+2. External source files read by the program and passed to Reactor.
+
+While case (2) is preferable for implementing a compiler, this is currently not
+implemented.
+
+Reactor implements case (1) and this can be used by GDB to single line step and
+inspect variables.
+
+## Supported Platforms
+
+Currently:
+
+* Debug info generation is only supported on Linux with the LLVM 7
+backend.
+* GDB is the only supported debugger.
+* The program must be compiled with debug info iteself.
+
+## Enabling
+
+Debug generation is enabled with `REACTOR_EMIT_DEBUG_INFO` CMake flag (defaults
+to disabled).
+
+## Implementation details
+
+### Source Location
+
+All Reactor functions begin with a call to `RR_DEBUG_INFO_UPDATE_LOC()`, which calls into `rr::DebugInfo::EmitLocation()`.
+
+`rr::DebugInfo::EmitLocation()` calls `rr::DebugInfo::getCallerBacktrace()`,
+which in turn uses [`libbacktrace`](https://github.com/ianlancetaylor/libbacktrace)
+to unwind the stack and find the file, function and line of the caller.
+
+This information is passed to `llvm::IRBuilder<>::SetCurrentDebugLocation`
+to emit source line information for the next LLVM instructions to be built.
+
+### Variables
+
+There are 3 aspects to generating variable debug information:
+
+#### 1. Variable names
+
+Constructing a Reactor `LValue`:
+
+```C++
+rr::Int a = 1;
+```
+
+Will emit an LLVM `alloca` instruction to allocate the storage of the variable,
+and emit another to initialize it to the constant `1`. While fluent, none of the
+Reactor calls see the name of the C++ local variable "`a`", and the LLVM `alloca`
+value gets a meaningless numerical value.
+
+There are two potential ways that Reactor can obtain the variable name:
+
+1. Use the running executable's own debug information to examine the local
+ declaration and extract the local variable's name.
+2. Use the backtrace information to parse the name from the source file.
+
+While (1) is arguably a cleaner and more robust solution, (2) is
+easier to implement and can work for the majority of use cases.
+
+(2) is the current solution implemented.
+
+`rr::DebugInfo::getOrParseFileTokens()` scans a source file line by line, and
+uses a regular expression to look for patterns of `<type> <name>`. Matching is not
+precise, but is adequate to find locals constructed with and without assignment.
+
+#### 2. Variable binding
+
+Given that we can find a variable name for a given source line, we need a way of
+binding the LLVM values to the name.
+
+Given our trivial example:
+
+```C++
+rr::Int a = 1
+```
+
+The `rr::Int` constructor calls `RR_DEBUG_INFO_EMIT_VAR()` passing the storage
+value as single argument. `RR_DEBUG_INFO_EMIT_VAR()` performs the backtrace
+to find the source file and line and uses the token information produced by
+`rr::DebugInfo::getOrParseFileTokens()` to identify the variable name.
+
+However, things get a bit more complicated when there are multiple variables
+being constructed on the same line.
+
+Take for example:
+
+```C++
+rr::Int a = rr::Int(1) + rr::Int(2)
+```
+
+Here we have 3 calls to the `rr::Int` constructor, each calling down
+to `RR_DEBUG_INFO_EMIT_VAR()`.
+
+To disambiguate which of these should be bound to the variable name "`a`",
+`rr::DebugInfo::EmitVariable()` buffers the binding into
+`scope.pending` and the last binding for a given line is used by
+`DebugInfo::emitPending()`. For variable construction and assignment, C++
+guarantees that the LHS is the last value to be constructed.
+
+This solution is not perfect.
+
+Multi-line expressions, multiple assignments on a single line, macro obfuscation
+can all break variable bindings - however the majority of typical cases work.
+
+#### 3. Variable scope
+
+`rr::DebugInfo` maintains a stack of `llvm::DIScope`s and `llvm::DILocation`s
+that mirrors the current backtrace for function being called.
+
+A synthetic call stack is produced by chaining `llvm::DILocation`s with
+`InlinedAt`s.
+
+For example, at the declaration of `i`:
+
+```C++
+void B()
+{
+ rr::Int i; // <- here
+}
+
+void A()
+{
+ B();
+}
+
+int main(int argc, const char* argv[])
+{
+ A();
+}
+```
+
+The `DIScope` hierarchy would be:
+
+```C++
+ DIFile: "foo.cpp"
+rr::DebugInfo::diScope[0].di: ↳ DISubprogram: "main"
+rr::DebugInfo::diScope[1].di: ↳ DISubprogram: "A"
+rr::DebugInfo::diScope[2].di: ↳ DISubprogram: "B"
+```
+
+The `DILocation` hierarchy would be:
+
+```C++
+rr::DebugInfo::diRootLocation: DILocation(DISubprogram: "ReactorFunction")
+rr::DebugInfo::diScope[0].location: ↳ DILocation(DISubprogram: "main")
+rr::DebugInfo::diScope[1].location: ↳ DILocation(DISubprogram: "A")
+rr::DebugInfo::diScope[2].location: ↳ DILocation(DISubprogram: "B")
+```
+
+Where '↳' represents an `InlinedAt`.
+
+
+`rr::DebugInfo::diScope` is updated by `rr::DebugInfo::syncScope()`.
+
+`llvm::DIScope`s typically do not nest - there is usually a separate
+`llvm::DISubprogram` for each function in the callstack. All local variables
+within a function will typically share the same scope, regardless of whether
+they are declared within a sub-block.
+
+Loops and jumps within a function add complexity. Consider:
+
+```C++
+void B()
+{
+ rr::Int i = 0;
+}
+
+void A()
+{
+ for (int i = 0; i < 3; i++)
+ {
+ rr::Int x = 0;
+ }
+ B();
+}
+
+int main(int argc, const char* argv[])
+{
+ A();
+}
+```
+
+In this particular example Reactor will not be aware of the `for` loop, and will
+attempt to create three variables called "`x`" in the same function scope for `A()`.
+Duplicate symbols in the same `llvm::DIScope` result in undefined behavior.
+
+To solve this, `rr::DebugInfo::syncScope()` observes when a function jumps
+backwards, and forks the current `llvm::DILexicalBlock` for the function. This
+results in a number of `llvm::DILexicalBlock` chains, each declaring variables
+that shadow the previous block.
+
+At the declaration of `i`, the `DIScope` hierarchy would be:
+
+```C++
+ DIFile: "foo.cpp"
+rr::DebugInfo::diScope[0].di: ↳ DISubprogram: "main"
+ ↳ DISubprogram: "A"
+ | ↳ DILexicalBlock: "A".1
+rr::DebugInfo::diScope[1].di: | ↳ DILexicalBlock: "A".2
+rr::DebugInfo::diScope[2].di: ↳ DISubprogram: "B"
+```
+
+The `DILocation` hierarchy would be:
+
+```C++
+rr::DebugInfo::diRootLocation: DILocation(DISubprogram: "ReactorFunction")
+rr::DebugInfo::diScope[0].location: ↳ DILocation(DISubprogram: "main")
+rr::DebugInfo::diScope[1].location: ↳ DILocation(DILexicalBlock: "A".2)
+rr::DebugInfo::diScope[2].location: ↳ DILocation(DISubprogram: "B")
+```
+
+### Debugger integration
+
+Once the debug information has been generated, it needs to be handed to the
+debugger.
+
+Reactor uses [`llvm::JITEventListener::createGDBRegistrationListener()`](http://llvm.org/doxygen/classllvm_1_1JITEventListener.html#a004abbb5a0d48ac376dfbe3e3c97c306)
+to inform GDB of the JIT'd program and its debugging information.
+More information [can be found here](https://llvm.org/docs/DebuggingJITedCode.html).
+
+LLDB should be able to support this same mechanism, but at the time of writing
+this does not appear to work.
+
diff --git a/docs/Regres.md b/docs/Regres.md
new file mode 100644
index 0000000..c752a72
--- /dev/null
+++ b/docs/Regres.md
@@ -0,0 +1,442 @@
+# Regres - SwiftShader automated testing
+
+## Introduction
+
+Regres is a collection of tools to perform [dEQP](https://github.com/KhronosGroup/VK-GL-CTS)
+presubmit and continuous integration testing and code coverage evaluation for
+SwiftShader.
+
+Regres provides:
+
+* [Presubmit testing](#presubmit-testing) - An automatic Vulkan
+ dEQP test run for each Gerrit patchset put up for review.
+* [Continuous integration testing](#daily-run-continuous-integration-testing) -
+ A Vulkan dEQP test run performed against the `master` branch each night. \
+ This nightly run also produces code coverage information which can be viewed at
+ [swiftshader-regres.github.io/swiftshader-coverage](https://swiftshader-regres.github.io/swiftshader-coverage/).
+* [Local dEQP test runner](#local-dEQP-test-runner) Provides a local tool for
+ efficiently running a number of dEQP tests based wildcard or regex name
+ matching.
+
+The Regres source root directory is at [`<swiftshader>/tests/regres/`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/).
+
+## Presubmit testing
+
+Regres monitors changes that have been [put up for review with Gerrit](https://swiftshader-review.googlesource.com/q/status:open).
+
+Once a new [qualifying](#qualifying) patchset has been found, regres will
+checkout, build and test the change against the parent changelist. \
+Any differences in results are reported as a review comment on the change
+[[example]](https://swiftshader-review.googlesource.com/c/SwiftShader/+/46369/5#message-4f09ea3e6d01ed94ae26183c8b6c547c90492c12).
+
+### Qualifying
+
+As Regres may be running externally authored code on Google hardware,
+Regres will only test a change if it is authored by or reviewed by a Googler.
+
+Only the most recent patchset of a change will be tested. If a new patchset is
+pushed while the previous is currently being tested, then testing will continue
+to completion and the previous patchsets will be posted, and the new patchset
+will be queued for testing.
+
+### Prioritization
+
+At the time of writing a Regres presubmit run takes a little over 20 minutes to
+complete, and there is a single Regres machine servicing all changes.
+To keep Regres responsive, changes are prioritized based on their 'readiness to
+land', which is determined by the change's `Kokoro-Presubmit`, `Code-Review` and
+`Presubmit-Ready` Gerrit labels.
+
+### Test Filtering
+
+By default, Regres will run all the test lists declared in the
+[`<swiftshader>/tests/regres/ci-tests.json`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/ci-tests.json) file.\
+As new functionally is being implemented, the test lists in `ci-tests.json` may
+reference known-passing test lists updated by the [daily run](#daily-run-continuous-integration-testing),
+so that failing tests for incomplete functionality are skipped, but tests that
+pass for new functionality *are tested* to ensure they do not regres.
+
+Additional tests names found in the files referenced by
+[`<swiftshader>/tests/regres/full-tests.json`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/full-tests.json)
+can be explicitly included in the change's presubmit run
+by including a line in the change description with the signature:
+
+```text
+Test: <dEQP-test-pattern>
+```
+
+`<dEQP-test-pattern>` can be a single dEQP test name, or you can use wildcards
+[as documented here](https://golang.org/pkg/path/filepath/#Match).
+
+You can repeat `Test:` as many times as you like. `Tests:` is also acccepted.
+
+[For example](https://swiftshader-review.googlesource.com/c/SwiftShader/+/26574):
+
+```text
+Add support for OpLogicalEqual, OpLogicalNotEqual
+
+Test: dEQP-VK.glsl.operator.bool_compare.*
+Test: dEQP-VK.glsl.operator.binary_operator.equal.*
+Test: dEQP-VK.glsl.operator.binary_operator.not_equal.*
+Bug: b/126870789
+Change-Id: I9d33444d67792274d8027b7d1632235533cfc079
+```
+
+## Daily-run continuous integration testing
+
+Once a day, regres will also test another set of tests from [`<swiftshader>/tests/regres/full-tests.json`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/full-tests.json),
+and post the test result lists as a Gerrit changelist
+[[example]](https://swiftshader-review.googlesource.com/c/SwiftShader/+/46448).
+
+The daily run also performs code coverage instrumentation per dEQP test,
+automatically uploading the results of all the dEQP tests to the viewer at
+[swiftshader-regres.github.io/swiftshader-coverage](https://swiftshader-regres.github.io/swiftshader-coverage/).
+
+## Local dEQP test runner
+
+Regres also provides a multi-threaded, [process sandboxed](#process-sandboxing),
+local dEQP test runner with a wild-card / regex based test name matcher.
+
+The local test runner can be run with:
+
+[`<swiftshader>/tests/regres/run_testlist.sh`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/run_testlist.sh) `--deqp-vk=<path to deqp-vk> [--filter=<test name filter>]`
+
+`<test name filter>` can be a single dEQP test name, or you can use wildcards
+[as documented here](https://golang.org/pkg/path/filepath/#Match).
+Alternatively, start with a `/` to use a regex filter.
+
+Other useful flags:
+
+```text
+ -limit int
+ only run a maximum of this number of tests
+ -no-results
+ disable generation of results.json file
+ -output string
+ path to an output JSON results file (default "results.json")
+ -shuffle
+ shuffle tests
+ -test-list string
+ path to a test list file (default "vk-master-PASS.txt")
+```
+
+Run [`<swiftshader>/tests/regres/run_testlist.sh`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/run_testlist.sh) with `--help` to see all available flags.
+
+## Process sandboxing
+
+Regres will run each dEQP test in a separate process to prevent state
+leakage between tests.
+
+Tests are run concurrently, and crashing processes will not take down the test
+runner.
+
+Some dEQP tests are known to perform excessive memory allocations (i.e. keep
+allocating until no more can be claimed from the OS). \
+In order to prevent a single test starving other test processes of memory, each
+process is restricted to a fraction of the system's memory using [linux resource limits](https://man7.org/linux/man-pages/man2/getrlimit.2.html).
+
+Tests may also deadlock, so each test process has a time limit before they are
+automatically killed.
+
+## Implementation details
+
+### Presubmit & daily run process
+
+Regres runs until stopped, and will:
+
+* Download a known compatible version of Clang to a cache directory. This will
+ be used for all compilation stages below.
+* Periodically poll Gerrit for recently opened changes
+* Periodically query Gerrit for details about each tracked change, determining
+ [whether it should be tested](#qualifying), and determine its current
+ [priority](#prioritization).
+* A qualifying change with the highest priority will be picked, and the
+ following is performed for the change:
+ 1. The change is `git fetch`ed into a temporary directory.
+ 2. If not already cached, the dEQP version described in the
+ change's [`<swiftshader>/tests/regres/deqp.json`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/deqp.json) file is downloaded and built the into a cached directory.
+ 3. The source for the change is built into a temporary build directory.
+ 4. The built dEQP binaries are used to test the change. The full test results
+ are stored in a cached directory.
+ 5. If the parent change's test results aren't already cached, then steps 3 and
+ 4 are repeated for the parent change.
+ 6. The results of the two changes are diffed, and the results of the diff are
+ posted to the change as a Gerrit review comment.
+* The above is repeated until it is time to perform a daily run, upon which:
+ 1. The `HEAD` change of `master` is fetched into a temporary directory.
+ 2. If not already cached, the dEQP version described in the
+ change's [`<swiftshader>/tests/regres/deqp.json`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/deqp.json) file is downloaded and built the into a cached directory.
+ 3. The `HEAD` change is built into a temporary directory, optionally with code
+ coverage instrumenting.
+ 4. The build dEQP binaries are used to test the change. The full test results
+ are stored in a cached directory, and the each test is binned by status and
+ written to the [`<swiftshader>/tests/regres/testlists`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/testlists) directory.
+ 5. A new Gerrit change is created containing the updated test lists and put up
+ for review, along with a summary of test result changes [[example]](https://swiftshader-review.googlesource.com/c/SwiftShader/+/46448).
+ If there's an existing daily test change up for review then this is reused
+ instead of creating another.
+ 6. If the build included code coverage instrumentation, then the coverage
+ results are collated from all test runs, processed and compressed, and
+ uploaded to [github.com/swiftshader-regres/swiftshader-coverage](https://github.com/swiftshader-regres/swiftshader-coverage)
+ which is immediately reflected at [swiftshader-regres.github.io/swiftshader-coverage](https://swiftshader-regres.github.io/swiftshader-coverage).
+ This process is [described in more detail below](#code-coverage).
+ 7. Stages 3 - 5 are repeated for both the LLVM and Subzero backends.
+
+### Caching
+
+The cache directory is heavily used to avoid duplicated work. For example, it
+is common for patchsets to be repeatedly pushed with the same parent change, so
+the test results of the parent can be calculated once and stored. A tested
+patchset that is merged into master would also be cached when used as a parent
+of another change.
+
+The cache needs to consider more than just the change identifier as the
+cache-key for storing and retrieving data. Both the test lists and version of
+dEQP used are dictated by the change being tested, and so both used as part of
+the cache key.
+
+### Vulkan Loader usage
+
+Applications make use of the Vulkan API by loading the [Vulkan Loader](https://github.com/KhronosGroup/Vulkan-Loader)
+library (`libvulkan.so.1` on Linux), which enumerates available Vulkan
+implementations (typically GPUs and their drivers) before an actual 'instance'
+is created to communicate with a specific Installable Client Driver (ICD).
+
+However, SwiftShader can build into libvulkan.so.1 itself, which implements the
+same API entry functions as the Vulkan Loader. Regres by default will make dEQP
+load this SwiftShader library instead of the system's Vulkan Loader. It ensures
+test results are independent of the system's Vulkan setup.
+
+To override this, one can set LD_LIBRARY_PATH to point to the location of a
+Loader's libvulkan.so.1.
+
+### Code coverage
+
+The [daily run](#daily-run-continuous-integration-testing) produces code
+coverage information that can be examined for each individual dEQP test at
+[swiftshader-regres.github.io/swiftshader-coverage](https://swiftshader-regres.github.io/swiftshader-coverage/).
+
+The process for generating this information is complex, and is described in
+detail below:
+
+#### Per-test generation
+
+Code coverage instrumentation is generated with
+[clang's `--coverage`](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html)
+functionality. This compiler option is enabled by using SwiftShader's
+`SWIFTSHADER_EMIT_COVERAGE` CMake flag.
+
+Each dEQP test process is run with a unique `LLVM_PROFILE_FILE` environment
+variable value which dictates where the process writes its raw coverage profile
+file. Each process gets a different path so that we can emit coverage from
+multiple, concurrent dEQP test processes.
+
+#### Parsing
+
+[Clang provides two tools](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#creating-coverage-reports) for processing coverage data:
+
+* `llvm-profdata` indexes the raw `.profraw` coverage profile file and emits a
+ `.profdata` file.
+* `llvm-cov` further processes the `.profdata` file into something human
+ readable or machine parsable.
+
+`llvm-cov` provides many options, including emitting an pretty HTML file, but is
+remarkably slow at producing easily machine-parsable data. Fortunately the core
+of `llvm-cov` is [a few hundreds of lines of code](https://github.com/llvm/llvm-project/tree/master/llvm/tools/llvm-cov), as it relies on LLVM libraries to do the heavy lifting. Regres
+replaces `llvm-cov` with ["`turbo-cov`"](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/cov/turbo-cov/) which efficiently converts a `.profdata` into a simple binary stream which can
+be consumed by Regres.
+
+#### Processing
+
+At the time of writing there are over 560,000 individual dEQP tests, and around
+176,000 lines of C++ code in [`<swiftshader>/src`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:src/).
+If you used 1 bit for each source line, per-line source coverage for all dEQP
+tests would require over 11GiB of storage. That's just for one snapshot.
+
+The processing and compression schemes described below reduces this down to
+around 10 MiB (~1100x reduction in size), and supports sub-line coverage scopes.
+
+##### Spans
+
+Code coverage information is described in spans.
+
+A span is a described as an interval of source locations, where a location is a
+line-column pair:
+
+```go
+type Location struct {
+ Line, Column int
+}
+
+type Span struct {
+ Start, End Location
+}
+```
+
+##### Test tree construction
+
+Each dEQP test is uniquely identified by a fully qualified name.
+Each test belongs to a group, and that group may be nested within any number of
+parent groups. The groups are described in the test name, using dots (`.`) to
+delimit the groups and leaf test name.
+
+For example, the fully qualified test name:
+
+`dEQP-VK.fragment_shader_interlock.basic.discard.ssbo.sample_unordered.4xaa.sample_shading.16x16`
+
+Can be broken down into the following groups and test name:
+
+```text
+dEQP-VK <-- root group name
+â•° fragment_shader_interlock
+ â•° basic.discard
+ â•° ssbo
+ â•° sample_unordered
+ â•° 4xaa
+ â•° sample_shading
+ â•° 16x16 <-- leaf test name
+```
+
+Breaking down fully qualified test names into groups provide a natural way to
+structure coverage data, as tests of the same group are likely to have similar
+coverage spans.
+
+So, for each source file in the codebase, we create a tree with test groups as
+non-leaf nodes, and tests as leaf nodes.
+
+For example, given the following test list:
+
+```text
+a.b.d.h
+a.b.d.i.n
+a.b.d.i.o
+a.b.e.j
+a.b.e.k.p
+a.b.e.k.q
+a.c.f
+a.c.g.l.r
+a.c.g.m
+```
+
+We would construct the following tree:
+
+```text
+ a
+ â•â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â•®
+ b c
+ â•â”€â”€â”€â”´â”€â”€â”€â•® â•â”€â”€â”€â”´â”€â”€â”€â•®
+ d e f g
+ â•â”€â”´â”€â•® â•â”€â”´â”€â•® â•â”€â”´â”€â•®
+ h i j k l m
+ â•â”´â•® â•â”´â•® │
+ n o p q r
+
+```
+
+Each leaf node in this tree (`h`, `n`, `o`, `j`, `p`, `q`, `f`, `r`, `m`)
+represent a test, and non-leaf nodes (`a`, `b`, `c`, `d`, `e`, `g`, `i`, `k`,
+`l`) are a groups.
+
+To begin, we create a test tree structure, and associate the full list of test
+coverage spans with every leaf node (test) in this tree.
+
+This data structure hasn't given us any compression benefits yet, but we can
+now do a few tricks to dramatically reduce number of spans needed to describe
+the graph:
+
+##### Optimization 1: Common span promotion
+
+The first compression scheme is to promote common spans up the tree when they
+are common for all children. This will reduce the number of spans needed to be
+encoded in the final file.
+
+For example, if the test group `a` has 4 children that all share the same span
+`X`:
+
+```text
+ a
+ â•â”€â”€â”€â”¬â”€â”´â”€â”¬â”€â”€â”€â•®
+ b c d e
+ [X,Y] [X] [X] [X,Z]
+```
+
+Then span `X` can be promoted up to `a`:
+
+```text
+ [X]
+ a
+ â•â”€â”€â”€â”¬â”€â”´â”€â”¬â”€â”€â”€â•®
+ b c d e
+ [Y] [] [] [Z]
+```
+
+##### Optimization 2: Span XOR promotion
+
+This idea can be extended further, by not requiring all the children to share
+the same span before promotion. If **most** child nodes share the same span, we
+can still promote the span, but this time we **remove** the span from the
+children **if they had it**, and **add** the span to children **if they didn't
+have it**.
+
+For example, if the test group `a` has 4 children with 3 that share the span
+`X`:
+
+```text
+ a
+ â•â”€â”€â”€â”¬â”€â”´â”€â”¬â”€â”€â”€â•®
+ b c d e
+ [X,Y] [X] [] [X,Z]
+```
+
+Then span `X` can be promoted up to `a` by flipping the presence of `X` on the
+child nodes:
+
+```text
+ [X]
+ a
+ â•â”€â”€â”€â”¬â”€â”´â”€â”¬â”€â”€â”€â•®
+ b c d e
+ [Y] [] [X] [Z]
+```
+
+This process repeats up the tree.
+
+With this optimization applied, we now need to traverse the tree from root to
+leaf in order to know whether a given span is in use for the leaf node (test):
+
+* If the span is encountered an **odd** number of times during traversal, then
+ the span is **covered**.
+* If the span is encountered an **even** number of times during traversal, then
+ the span is **not covered**.
+
+See [`tests/regres/cov/coverage_test.go`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/cov/coverage_test.go) for more examples of this optimization.
+
+##### Optimization 3: Common span grouping
+
+With real world data, we encounter groups of spans that are commonly found
+together. To further reduce coverage data, the whole graph is scanned for common
+span patterns, and are indexed by each tree node.
+The XOR'ing of spans as described above is performed as if the spans were not
+grouped.
+
+##### Optimization 4: Lookup tables
+
+All spans, span-groups and strings are stored in de-duplicated tables, and are
+indexed wherever possible.
+
+The final serialization is performed by [`tests/regres/cov/serialization.go`](https://cs.opensource.google/swiftshader/SwiftShader/+/master:tests/regres/cov/serialization.go).
+
+##### Optimization 5: zlib compression
+
+The coverage data is encoded into JSON for parsing by the web page.
+
+Before writing the JSON file, the text data is zlib compressed.
+
+#### Presentation
+
+The zlib-compressed JSON coverage data is decompressed using
+[`pako`](https://github.com/nodeca/pako), and consumed by some
+[vanilla JavaScript](https://github.com/swiftshader-regres/swiftshader-coverage/blob/gh-pages/index.html).
+
+[`codemirror`](https://codemirror.net/) is used to perform coverage span and C++
+syntax highlighting
diff --git a/docs/RuntimeConfiguration.md b/docs/RuntimeConfiguration.md
new file mode 100644
index 0000000..5083a8a
--- /dev/null
+++ b/docs/RuntimeConfiguration.md
@@ -0,0 +1,34 @@
+Runtime Configuration
+=========================
+
+SwiftShader provides a simple configuration mechanism based on a configuration file to control a variety of runtime options without needing to re-compile from source.
+
+Configuration file
+------------
+
+SwiftShader looks for a file named `SwiftShader.ini` (case-sensitive) in the working directory. At startup, SwiftShader reads this file, if it exists, and sets the options specified in it.
+
+The configuration file syntax is a series of key-value pairs, divided into sections. The following example shows three key-value pairs in two sections (`ThreadCount` and `AffinityMask` in the `[Processor]` section, and `EnableSpirvProfiling` in the `[Profiler]` section):
+```
+[Processor]
+ThreadCount=4
+AffinityMask=0xf
+
+# Comment
+[Profiler]
+EnableSpirvProfiling=true
+```
+
+The syntax rules are as follows:
+* Sections are defined via a name in brackets, e.g. `[Processor]`.
+* Key-value pairs are in the format `Key=Value`.
+* Keys are always strings, while values can be strings, booleans or integers depending on the semantics of the option:
+ * For integer options, both decimal and hexademical values are supported.
+ * For boolean options, both decimal (`1` and `0`) and alphabetical (`true` and `false`) values are supported.
+* Comments are supported through the use of the `#` character at the beginning of a line.
+
+Options
+------------
+
+Refer to the [SwiftConfig.hpp](../src/System/SwiftConfig.hpp) header for an up-to-date overview of available options.
+
diff --git a/docs/SamplingRoutines.md b/docs/SamplingRoutines.md
new file mode 100644
index 0000000..9c4716a
--- /dev/null
+++ b/docs/SamplingRoutines.md
@@ -0,0 +1,36 @@
+Sampling Routines
+=================
+
+Introduction
+------------
+
+Like other modern real-time graphics APIs, Vulkan has support for [sampler objects](https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#samplers) which provide the sampling state to be used by image reading and sampling instructions in the shaders. [Sampler descriptors](https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#descriptorsets-sampler) contain or reference this state. The sampler descriptor is [combined](https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpSampledImage) with an image descriptor, and this combination may only be known at shader execution time.
+
+This poses a challenge to SwiftShader's use of [dynamic code generation](Reactor.md), where we wish to specialize the sampling code for both the image's properties (most notably the format) and the sampler state. Historically, sampler state was either part of the texture objects or both the texture and sampler object were bound to a texture unit, ahead of shader execution.
+
+JIT Trampolines
+---------------
+
+The solution is to defer code generation for the sampling instructions until shader execution. For each image sampling operation we generate a call to a C++ function which will provide the specialized routine based on the image and sampler descriptor used at run-time. Then we call the returned routine.
+
+Note that this differs from typical JIT-compilers' use of trampoline functions in that we generate code specific to the combination of state, and adapt it to changes in state dynamically.
+
+3-Level Caching
+---------------
+
+We cache the generated sampling routines, using the descriptors as well as the type of sampling instruction, as the key. This is done at three levels, described in reverse order for easier understanding:
+
+L3: At the third and last level, we use a generic least-recently-used (LRU) cache, just like the caches of the pipeline stages' routines. It is protected by a mutex, which may experience high contention due to all shader worker threads needing the sampling routines.
+
+L2: To mitigate that, there's a second-level cache which contains a 'snapshot' of the last-level cache, which can be queried concurrently without locking. The snapshot is updated at pipeline barriers. While much faster than the last-level cache's critical section, the hash table lookup is still a lot of work per sampling instruction.
+
+L1: Often the descriptors being used don't change between executions of the sampling instruction. Which is where the first-level or '[inline](https://en.wikipedia.org/wiki/Inline_caching)' cache comes in. It is a single-entry cache implemented at the compiled sampling instruction level. Before calling out to the C++ function to retrieve the routine, we check if the sampler and image descriptor haven't changed since the last execution of the instruction. Note that this cache doesn't use the instruction type as part of the lookup key, since each sampling instruction instance gets its own inline cache.
+
+Descriptor Identifiers
+----------------------
+
+To make testing whether the descriptor state remained the same fast, they have unique 32-bit identifiers. Note that sampler object state and image view state that is relevant to sampling routine specialization may not be unique among sampler and image view objects. For image views we're able to compress the state into the 32-bit identifier itself to avoid unnecessary recompiles.
+
+For sampler state, which is considerably larger than 32-bit, we keep a map of it to the unique identifiers. We keep count of how many sampler objects share each identifier, so we know when we can remove the entry.
+
+Both these 32-bit identifiers are the only thing used as the key of the first-level sampling routine cache.
\ No newline at end of file
diff --git a/docs/Sin-Cos-Optimization.pdf b/docs/Sin-Cos-Optimization.pdf
new file mode 100644
index 0000000..56150b8
--- /dev/null
+++ b/docs/Sin-Cos-Optimization.pdf
Binary files differ
diff --git a/docs/Subzero.md b/docs/Subzero.md
new file mode 100644
index 0000000..c66c15a
--- /dev/null
+++ b/docs/Subzero.md
@@ -0,0 +1,19 @@
+Subzero Documentation
+=====================
+
+Subzero is a JIT compiler used as a back-end for [Reactor](Reactor.md). It originates from Chrome's [Portable Native Client](https://developer.chrome.com/native-client) project. Its authoritative repository is at [https://chromium.googlesource.com/native_client/pnacl-subzero/](https://chromium.googlesource.com/native_client/pnacl-subzero/).
+
+Subzero for SwiftShader
+-----------------------
+
+SwiftShader contains a fork of the Subzero source code (at the time of writing they are in sync). It is an alternative JIT compiler back-end, with LLVM still being the default for CMake builds. To build SwiftShader with Subzero instead of LLVM, specify -DREACTOR_BACKEND=Subzero in your CMake command (or change LLVM to Subzero in the CMake GUI). For Chrome builds that use the BUILD.gn files, Subzero is the default as it produces significantly smaller binaries than with LLVM.
+
+Subzero Development
+-------------------
+
+Development on Subzero itself requires setting up the NaCl environment on a Linux system to be able to run its unit tests:
+
+* Install Chrome's [depot_tools](http://dev.chromium.org/developers/how-tos/install-depot-tools).
+* Run `mkdir nacl && cd nacl && fetch nacl` ([ref](http://www.chromium.org/nativeclient/how-tos/how-to-use-git-svn-with-native-client)).
+* Run `native_client/toolchain_build/toolchain_build_pnacl.py --verbose --sync --clobber --install toolchain/linux_x86/pnacl_newlib_raw` ([ref](https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/developing-pnacl#TOC-TL-DR-for-checking-out-PNaCl-sources-building-and-testing)).
+* Run all unit tests with `make -f Makefile.standalone check` ([ref](https://chromium.googlesource.com/native_client/pnacl-subzero/+/master/docs/README.rst)).
diff --git a/docs/TimelineSemaphores.md b/docs/TimelineSemaphores.md
new file mode 100644
index 0000000..c36bc85
--- /dev/null
+++ b/docs/TimelineSemaphores.md
@@ -0,0 +1,44 @@
+# Vulkan Timeline Semaphores
+
+[Vulkan Timeline
+Semaphores](https://www.khronos.org/blog/vulkan-timeline-semaphores) are a
+synchronization primitive accessible both from the device and the host. A
+timeline semaphore represents a monotonically increasing 64-bit unsigned
+value. Whereas binary Vulkan semaphores are waited on just to become signaled,
+timeline semaphores are waited on to reach a specific value. Once a timeline
+semaphore reaches a certain value, it is considered signaled for every value
+less than or equal to that
+value. [`vkWaitSemaphores`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkWaitSemaphores.html)
+is used to wait for semaphores on the host. It can operate in one of two modes:
+"wait for all" and "wait for any".
+
+In SwiftShader, Vulkan Timeline Semaphores are implemented as an unsigned 64-bit
+integer protected by a mutex with changes signaled by a condition
+variable. Waiting for all timeline semaphores in a set is implemented by simply
+waiting for each of the semaphores in turn. Waiting for any semaphore in a set
+is a bit more complex.
+
+## Wait for any semaphore
+
+A "wait for any" of a set of semaphores is represented by a
+`TimelineSemaphore::WaitForAny` object. Additionally, `TimelineSemaphore`
+contains an internal list of all `WaitForAny` objects that wait for it, as well
+as for which values they wait. When signaled, the timeline semaphore looks
+through this list and, in turn, signals any `WaitForAny` objects that are
+waiting for a value less than or equal to the timeline semaphore's new value.
+
+A `WaitForAny` object is created from a `VkSemaphoreWaitInfo`. During
+construction, it checks the value of each timeline semaphore provided against
+the value for which it is waiting. If it has not yet been reached, the wait
+object registers itself with the timeline semaphore. If it _has_ been reached,
+the wait object is immediately signaled and no further timeline semaphores are
+checked.
+
+Once a `WaitForAny` object is signaled, it remains signaled. There is no way to
+change what semaphores or values to wait for after construction. Any subsequent
+calls to `wait()` will return `VK_SUCCESS` immediately.
+
+When a `WaitForAny` object is destroyed, it unregisters itself from every
+`TimelineSemaphore` it was waiting for. It is expected that the number of
+concurrent waits are few, and that the wait objects are short-lived, so there
+should not be a build-up of wait objects in any timeline semaphore.
diff --git a/docs/VulkanShaderDebugging.md b/docs/VulkanShaderDebugging.md
new file mode 100644
index 0000000..c47a56a
--- /dev/null
+++ b/docs/VulkanShaderDebugging.md
@@ -0,0 +1,51 @@
+# Vulkan Shader Debugging
+
+SwiftShader implements a Vulkan shader debugger that uses the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol).
+
+This debugger is still actively being developed. Please see the [Known Issues](#Known-Issues).
+
+# Enabling
+
+To enable the debugger functionality, SwiftShader needs to be built using the CMake `SWIFTSHADER_ENABLE_VULKAN_DEBUGGER` flag (`-DSWIFTSHADER_ENABLE_VULKAN_DEBUGGER=1`):
+
+Once SwiftShader is built with the debugger functionality, there are two environment flags that control the runtime behavior:
+
+* `VK_DEBUGGER_PORT` - set to an unused port number that will be used to create the DAP localhost socket. If this environment variable is not set, then the debugger functionality will not be enabled.
+* `VK_WAIT_FOR_DEBUGGER` - if defined, the debugger will block on `vkCreateDevice()` until a debugger connection is established, before allowing `vkCreateDevice()` to return. This allows breakpoints to be set before execution continues.
+
+# Connecting using Visual Studio Code
+
+Once you have built SwiftShader with the debugger functionality enabled, and the `VK_DEBUGGER_PORT` environment variable set, you can connect to the debugger using the following Visual Studio Code `"debugServer"` [Launch Configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations):
+
+```json
+ {
+ "name": "Vulkan Shader Debugger",
+ "type": "node",
+ "request": "launch",
+ "debugServer": 19020,
+ }
+```
+
+Note that the `"type": "node"` field is unused, but is required.
+
+[TODO](https://issuetracker.google.com/issues/148373102): Create a Visual Studio Code extension that provides a pre-built SwiftShader driver and debugger type.
+
+# Shader entry breakpoints
+
+You can use the following function breakpoint names to set a breakpoint on the entry to all shaders of the corresponding shader type:
+* `"VertexShader"`
+* `"FragmentShader"`
+* `"ComputeShader"`
+
+# High-level Shader debugging
+
+The debugger, will by default, automatically disassemble the SPIR-V shader code, and provide this as the source for the shader program.
+
+However, if the shader program contains [`OpenCL.DebugInfo.100`](https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.DebugInfo.100.mobile.html) debug info instructions, then the debugger will allow you to debug the high-level shader source (please see [Known Issues](#Known-Issues)).
+
+
+# Known Issues
+
+* Currently enabling the debugger dramatically affects performance for all shader invocations. We may want to just-in-time recompile shaders that are actively being debugged to keep the invocations of non-debugged shaders performant. [Tracker bug](https://issuetracker.google.com/issues/148372410)
+* Support for [`OpenCL.DebugInfo.100`](https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.DebugInfo.100.mobile.html) is still in early, but active development. Many features are still incomplete.
+* Shader subgroup invocations are currently presented as a single thread, with each invocation presented as `Lane N` groups in the watch window(s). This approach is still being evaluated, and may be reworked.
\ No newline at end of file
diff --git a/docs/dEQP.md b/docs/dEQP.md
new file mode 100644
index 0000000..537f3c9
--- /dev/null
+++ b/docs/dEQP.md
@@ -0,0 +1,246 @@
+dEQP
+====
+
+These steps are specifically for testing SwiftShader's Vulkan implementation using dEQP on Windows (steps for Linux below the Windows instructions).
+
+Prerequisites
+-------------
+
+1. Install the latest [Python 3](https://www.python.org/downloads/)
+2. Install [Visual Studio](https://visualstudio.microsoft.com/vs/community/)
+3. Install [CMake](https://cmake.org/download/)
+4. Install [Go](https://golang.org/doc/install)
+5. Install [MinGW-W64](http://mingw-w64.org/doku.php/download)
+ * Select 'x86_64' as Architecture during setup
+6. Install [Git](https://git-scm.com/download/win)
+7. Set environment variables: Config Panel -> System and Security -> System -> Advanced system settigns -> Environment Variables
+ * Add `<path to python>` to your PATH environment variable
+ * Add `<path to MinGW-W64>\bin` to your PATH environment variable
+
+8. (Optional) Install [TortoiseGit](https://tortoisegit.org/)
+
+Getting the Code
+----------------
+
+12. Get dEQP (either in 'cmd' or by using TortoiseGit):
+
+ `git clone https://github.com/KhronosGroup/VK-GL-CTS`
+
+ You may wish to check out a stable vulkan-cts-* branch.
+
+13. Get dEQP's dependencies. In your dEQP root directory, open 'cmd' and run:
+
+ `python3 external\fetch_sources.py`
+
+14. Get Cherry (either in 'cmd' or by using TortoiseGit):
+
+ `git clone https://android.googlesource.com/platform/external/cherry`
+
+15. Set environment variable (see point 9):
+
+ Add new variable GOPATH='`<path to cherry>`'
+
+Building the code
+-----------------
+
+16. Build dEQP's Visual Studio files using the CMake GUI, or, in the dEQP root dir, run:
+ ```
+ mkdir build
+ cd build
+ cmake ..
+ ```
+ Note: don't call 'cmake .' directly in the root directory. It will make things fails later on. If you do, simply erase the files created by CMake and follow the steps above.
+
+17. Build dEQP:
+
+ Open `<path to dEQP>\build\dEQP-Core-default.sln` in Visual Studio and Build Solution
+
+ Note: Choose a 'Debug' build.
+
+18. Generate test cases:
+ ```
+ mkdir <path to cherry>\data
+ cd <path to dEQP>
+ python3 scripts\build_caselists.py <path to cherry>\data
+ ```
+
+ Note: you need to run `python3 scripts\build_caselists.py <path to cherry>\data` every time you update dEQP.
+
+Preparing the server
+--------------------
+
+19. Edit `<path to cherry>\cherry\data.go`
+* Search for `../candy-build/deqp-wgl` and replace that by `<path to deqp>/build`
+* Just above, add an option to CommandLine: `--deqp-gl-context-type=egl`
+* Remove `--deqp-watchdog=enable` to avoid timeouts during debugging.
+
+ Note: If you chose a Release build at step 17, modify the BinaryPath from 'Debug' to 'Release'.
+
+Testing Vulkan
+--------------
+
+20. Assuming you already built SwiftShader, copy and rename this file:
+
+ `<path to SwiftShader>\build\Release_x64\vk_swiftshader.dll` or\
+ `<path to SwiftShader>\build\Debug_x64\vk_swiftshader.dll`
+
+ To:
+
+ `<path to dEQP>\build\external\vulkancts\modules\vulkan\Debug\vulkan-1.dll`
+
+ This will cause dEQP to load SwiftShader's Vulkan implementatin directly, without going through a system-provided [loader](https://github.com/KhronosGroup/Vulkan-Loader/blob/master/loader/LoaderAndLayerInterface.md#the-loader) library or any layers.
+
+ This step can also be automated by setting the `SWIFTSHADER_VULKAN_API_LIBRARY_INSTALL_PATH` environment variable to a path where we'd like the drop-in API library to be installed. For example `<path to dEQP>/build/external/vulkancts/modules/vulkan/Debug/`.
+
+ To use SwiftShader as an [Installable Client Driver](https://github.com/KhronosGroup/Vulkan-Loader/blob/master/loader/LoaderAndLayerInterface.md#installable-client-drivers) (ICD) instead:
+ * Edit environment variables:
+ * Define VK_ICD_FILENAMES to `<path to SwiftShader>\src\Vulkan\vk_swiftshader_icd.json`
+ * If the location of `vk_swiftshader.dll` you're using is different than the one specified in `src\Vulkan\vk_swiftshader_icd.json`, modify it to point to the `vk_swiftshader.dll` file you want to use.
+
+Running the tests
+-----------------
+
+21. Start the test server. Go to `<path to cherry>` and run:
+
+ `go run server.go`
+
+22. Open your favorite browser and navigate to `localhost:8080`
+
+ Get Started -> Choose Device 'localhost' -> Select Tests 'dEQP-VK' -> Execute tests!
+
+Mustpass sets
+-------------
+
+dEQP contains more tests than what is expected to pass by a conformant implementation (e.g. some tests are considered too strict, or assume certain undefined behavior). The [android/cts/master/vk-master.txt](https://android.googlesource.com/platform/external/deqp/+/master/android/cts/master/vk-master.txt) text file which can be loaded in Cherry's 'Test sets' tab to only run the latest tests expected to pass by certified Android devices.
+
+Linux
+-----
+
+The Linux process is similar to Windows. However it doesn't use Release or Debug variants, paths use forward slashes, and it uses shared object files instead of DLLs.
+
+1. Install the latest [Python 3](https://www.python.org/downloads/)
+2. Install GCC and Make. In a terminal, run:
+
+ `sudo apt-get install gcc make`
+
+3. Install [CMake](https://cmake.org/download/)
+4. Install [Go](https://golang.org/doc/install)
+5. Install Git. In a terminal, run:
+
+ `sudo apt-get install git`
+
+6. Download the [Vulkan SDK](https://vulkan.lunarg.com/) and unpack it into a location you like.
+
+Getting the Code
+----------------
+
+7. Get Swiftshader. In a terminal, go to the location you want to keep Swiftshader, and run:
+
+ ```
+ git clone https://swiftshader.googlesource.com/SwiftShader && (cd SwiftShader && curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x `git rev-parse --git-dir`/hooks/commit-msg)
+ ```
+
+ This will also install the commit hooks you need for committing to SwiftShader.
+
+8. Get dEQP:
+
+ `git clone https://github.com/KhronosGroup/VK-GL-CTS`
+
+9. Get dEQP's dependencies. In your dEQP root directory, run:
+
+ `python3 external/fetch_sources.py`
+
+10. Get Cherry, similar to step 8:
+
+ `git clone https://android.googlesource.com/platform/external/cherry`
+
+11. Set environment variable. Open ~/.bashrc in your preferred editor and add the following line:
+
+ GOPATH='`<path to cherry>`'
+
+Building the code
+-----------------
+
+12. Build Swiftshader. In the Swiftshader root dir, run:
+ ```
+ cd build
+ cmake ..
+ make --jobs=$(nproc)
+ ```
+
+13. Set your environment variables. In the terminal in which you'll be building dEQP, run the following commands:
+
+ ```
+ export LD_LIBRARY_PATH="<Vulkan SDK location>/x86_64/lib:$LD_LIBRARY_PATH"
+ export LD_LIBRARY_PATH="<Swiftshader location>/build:$LD_LIBRARY_PATH"
+ ```
+
+14. Build dEQP. In the dEQP root dir, run:
+ ```
+ mkdir build
+ cd build
+ cmake ..
+ make --jobs=$(nproc)
+ ```
+
+ Also: don't call 'cmake .' directly in the root directory. It will make things fails later on. If you do, simply erase the files created by CMake and follow the steps above.
+
+15. Generate test cases:
+ ```
+ mkdir <path to cherry>/data
+ cd <path to dEQP>
+ python3 scripts/build_caselists.py <path to cherry>/data
+ ```
+
+ Note: you need to run `python3 scripts/build_caselists.py <path to cherry>/data` every time you update dEQP.
+
+Preparing the server
+--------------------
+
+16. Edit `<path to cherry>/cherry/data.go`
+* Search for ".exe" and remove all instances.
+* Search for `../candy-build/deqp-wgl/execserver/Release` and replace that by `<path to deqp>/build/execserver/execserver`
+* Just above, add an option to CommandLine: `--deqp-gl-context-type=egl`
+* Just below, remove 'Debug/' from the BinaryPath.
+* Just one more line below, replace `../candy-build/deqp-wgl/` with `<path to deqp>/build/modules/${TestPackageDir}`.
+* Remove `--deqp-watchdog=enable` to avoid timeouts during debugging.
+
+Testing Vulkan
+--------------
+
+17. Use SwiftShader as an [Installable Client Driver](https://github.com/KhronosGroup/Vulkan-Loader/blob/master/loader/LoaderAndLayerInterface.md#installable-client-drivers) (ICD). Add the following line to your `~/.bashrc`:
+
+ `export VK_ICD_FILENAMES="<path to SwiftShader>/build/Linux/vk_swiftshader_icd.json"`
+
+ Then run `source ~/.bashrc` in the terminal(s) you'll be running tests from.
+
+
+Running the tests
+-----------------
+
+18. Start the test server. Go to `<path to cherry>` and run:
+
+ `go run server.go`
+
+19. Open your favorite browser and navigate to `localhost:8080`
+
+ Get Started -> Choose Device 'localhost' -> Select Tests 'dEQP-VK' -> Execute tests!
+
+20. To make sure that you're running SwiftShader's drivers, select only the dEQP-VK->info->device test. In the next window, click on these tests in the left pane. If you see SwiftShader in the deviceName field, then you've set your suite up properly.
+
+21. If you want to run Vulkan tests in the command line, go to the build directory in dEQP root. Then run the following command:
+
+ `external/vulkanacts/modules/vulkan/deqp-vk`
+
+ You can also run individual tests with:
+
+ `external/vulkanacts/modules/vulkan/deqp-vk --deqp-case=<test name>`
+
+ And you can find a list of the test names in `<Swiftshader root>/tests/regres/testlists/vk-master.txt` However, deqp-vk will cease upon the first failure. It's recommended that you use cherry for your testing needs unless you know what you're doing.
+
+22. To check that you're running SwiftShader in cherry, start the server
+
+Mustpass sets
+-------------
+
+dEQP contains more tests than what is expected to pass by a conformant implementation (e.g. some tests are considered too strict, or assume certain undefined behavior). The [android/cts/master/vk-master.txt](https://android.googlesource.com/platform/external/deqp/+/master/android/cts/master/vk-master.txt) text file which can be loaded in Cherry's 'Test sets' tab to only run the latest tests expected to pass by certified Android devices.
diff --git a/include/Android/android/api-level.h b/include/Android/android/api-level.h
new file mode 100644
index 0000000..2d2f096
--- /dev/null
+++ b/include/Android/android/api-level.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_API_LEVEL_H
+#define ANDROID_API_LEVEL_H
+
+/*
+ * Magic version number for a current development build, which has
+ * not yet turned into an official release.
+ */
+#define __ANDROID_API__ 10000
+
+#endif /* ANDROID_API_LEVEL_H */
diff --git a/include/Android/android/sync.h b/include/Android/android/sync.h
new file mode 100644
index 0000000..1ae728a
--- /dev/null
+++ b/include/Android/android/sync.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+extern "C" {
+int sync_wait(int fd, int timeout);
+};
diff --git a/include/Android/cutils/native_handle.h b/include/Android/cutils/native_handle.h
new file mode 100644
index 0000000..b92a663
--- /dev/null
+++ b/include/Android/cutils/native_handle.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+struct native_handle_t;
+
+typedef const struct native_handle_t* buffer_handle_t;
diff --git a/include/Android/hardware/gralloc.h b/include/Android/hardware/gralloc.h
new file mode 100644
index 0000000..013e86a
--- /dev/null
+++ b/include/Android/hardware/gralloc.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <cutils/native_handle.h>
+
+#include <hardware/hardware.h>
+
+struct android_ycbcr;
+
+enum {
+ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003U,
+ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030U,
+ GRALLOC_USAGE_HW_TEXTURE = 0x00000100U,
+ GRALLOC_USAGE_HW_RENDER = 0x00000200U,
+};
+
+struct gralloc_module_t {
+ hw_module_t common;
+ int (*registerBuffer)(gralloc_module_t const*, buffer_handle_t);
+ int (*unregisterBuffer)(gralloc_module_t const*, buffer_handle_t);
+ int (*lock)(gralloc_module_t const*, buffer_handle_t, int, int, int, int, int, void**);
+ int (*unlock)(gralloc_module_t const*, buffer_handle_t);
+ int (*perform)(gralloc_module_t const*, int, ...);
+ int (*lock_ycbcr)(gralloc_module_t const*, buffer_handle_t, int, int, int, int, int,
+ android_ycbcr*);
+ int (*lockAsync)(gralloc_module_t const*, buffer_handle_t, int, int, int, int, int, void**, int);
+ int (*unlockAsync)(gralloc_module_t const*, buffer_handle_t, int*);
+ int (*lockAsync_ycbcr)(gralloc_module_t const*, buffer_handle_t, int, int, int, int, int,
+ android_ycbcr*, int);
+ int32_t (*getTransportSize)(gralloc_module_t const*, buffer_handle_t, uint32_t, uint32_t);
+ int32_t (*validateBufferSize)(gralloc_module_t const*, buffer_handle_t, uint32_t, uint32_t, int32_t, int, uint32_t);
+
+ void* reserved_proc[1];
+};
diff --git a/include/Android/hardware/gralloc1.h b/include/Android/hardware/gralloc1.h
new file mode 100644
index 0000000..b02decf
--- /dev/null
+++ b/include/Android/hardware/gralloc1.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <hardware/hardware.h>
+
+#include <cutils/native_handle.h>
+
+#define GRALLOC_MODULE_API_VERSION_1_0 HARDWARE_MAKE_API_VERSION(1, 0)
+
+#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
+
+enum {
+ GRALLOC1_ERROR_NONE = 0,
+ GRALLOC1_ERROR_BAD_HANDLE = 2,
+ GRALLOC1_ERROR_BAD_VALUE = 3,
+ GRALLOC1_ERROR_UNDEFINED = 6,
+};
+
+enum {
+ GRALLOC1_FUNCTION_LOCK = 18,
+ GRALLOC1_FUNCTION_UNLOCK = 20,
+};
+
+enum {
+ GRALLOC1_CONSUMER_USAGE_CPU_READ = 1ULL << 1,
+ GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN = 1ULL << 2 | GRALLOC1_CONSUMER_USAGE_CPU_READ,
+ GRALLOC1_CONSUMER_USAGE_CPU_WRITE = 1ULL << 5,
+ GRALLOC1_CONSUMER_USAGE_CPU_WRITE_OFTEN = 1ULL << 6 | GRALLOC1_CONSUMER_USAGE_CPU_WRITE,
+ GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE = 1ULL << 8,
+};
+
+enum {
+ GRALLOC1_PRODUCER_USAGE_CPU_READ = 1ULL << 1,
+ GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN = 1ULL << 2 | GRALLOC1_PRODUCER_USAGE_CPU_READ,
+ GRALLOC1_PRODUCER_USAGE_CPU_WRITE = 1ULL << 5,
+ GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN = 1ULL << 6 | GRALLOC1_PRODUCER_USAGE_CPU_WRITE,
+ GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET = 1ULL << 9,
+};
+
+typedef void (*gralloc1_function_pointer_t)();
+
+struct gralloc1_rect_t {
+ int32_t left;
+ int32_t top;
+ int32_t width;
+ int32_t height;
+};
+
+struct gralloc1_device_t {
+ hw_device_t common;
+ void (*getCapabilities)(gralloc1_device_t*, uint32_t*, int32_t*);
+ gralloc1_function_pointer_t (*getFunction)(gralloc1_device_t*, int32_t);
+};
+
+typedef int32_t (*GRALLOC1_PFN_LOCK)(gralloc1_device_t*, buffer_handle_t, uint64_t, uint64_t,
+ const gralloc1_rect_t*, void**, int32_t);
+typedef int32_t (*GRALLOC1_PFN_UNLOCK)(gralloc1_device_t*, buffer_handle_t, int32_t*);
+
+static inline int gralloc1_open(const hw_module_t* module, gralloc1_device_t** device) {
+ return module->methods->open(module, GRALLOC_HARDWARE_MODULE_ID,
+ reinterpret_cast<hw_device_t**>(device));
+}
diff --git a/include/Android/hardware/hardware.h b/include/Android/hardware/hardware.h
new file mode 100644
index 0000000..21d6dc4
--- /dev/null
+++ b/include/Android/hardware/hardware.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <cstdint>
+
+#define MAKE_TAG_CONSTANT(A, B, C, D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
+
+#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
+#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
+
+#define HARDWARE_MAKE_API_VERSION(maj, min) ((((maj)&0xff) << 8) | ((min)&0xff))
+
+#define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0)
+
+struct hw_module_methods_t;
+
+struct hw_module_t {
+ uint32_t tag;
+ uint16_t module_api_version;
+ uint16_t hal_api_version;
+ const char* id;
+ const char* name;
+ const char* author;
+ hw_module_methods_t* methods;
+ void* dso;
+#ifdef __LP64__
+ uint64_t reserved[32 - 7];
+#else
+ uint32_t reserved[32 - 7];
+#endif
+};
+
+struct hw_device_t {
+ uint32_t tag;
+ uint32_t version;
+ struct hw_module_t* module;
+#ifdef __LP64__
+ uint64_t reserved[12];
+#else
+ uint32_t reserved[12];
+#endif
+ int (*close)(hw_device_t* device);
+};
+
+struct hw_module_methods_t {
+ int (*open)(const hw_module_t*, const char*, hw_device_t**);
+};
+
+extern "C" {
+int hw_get_module(const char* id, const hw_module_t** module);
+};
diff --git a/include/Android/nativebase/nativebase.h b/include/Android/nativebase/nativebase.h
new file mode 100644
index 0000000..c2e84d7
--- /dev/null
+++ b/include/Android/nativebase/nativebase.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <cutils/native_handle.h>
+
+#include <cstdint>
+#include <cstring>
+
+// clang-format off
+#define ANDROID_NATIVE_MAKE_CONSTANT(a, b, c, d) \
+ ((static_cast<unsigned int>(a) << 24) | \
+ (static_cast<unsigned int>(b) << 16) | \
+ (static_cast<unsigned int>(c) << 8) | \
+ (static_cast<unsigned int>(d) << 0))
+// clang-format on
+
+struct android_native_base_t {
+ int magic;
+ int version;
+ void* reserved[4];
+ void (*incRef)(android_native_base_t*);
+ void (*decRef)(android_native_base_t*);
+};
+
+#define ANDROID_NATIVE_BUFFER_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_', 'b', 'f', 'r')
+
+struct ANativeWindowBuffer {
+ ANativeWindowBuffer() {
+ common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
+ common.version = sizeof(ANativeWindowBuffer);
+ memset(common.reserved, 0, sizeof(common.reserved));
+ }
+
+ android_native_base_t common;
+
+ int width;
+ int height;
+ int stride;
+ int format;
+ int usage_deprecated;
+ uintptr_t layerCount;
+
+ void* reserved[1];
+
+ const native_handle_t* handle;
+ uint64_t usage;
+
+ void* reserved_proc[8 - (sizeof(uint64_t) / sizeof(void*))];
+};
diff --git a/include/Android/sync/sync.h b/include/Android/sync/sync.h
new file mode 100644
index 0000000..1ae728a
--- /dev/null
+++ b/include/Android/sync/sync.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+extern "C" {
+int sync_wait(int fd, int timeout);
+};
diff --git a/include/Android/system/graphics.h b/include/Android/system/graphics.h
new file mode 100644
index 0000000..563287a
--- /dev/null
+++ b/include/Android/system/graphics.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+enum {
+ HAL_PIXEL_FORMAT_RGBA_8888 = 1,
+ HAL_PIXEL_FORMAT_RGBX_8888 = 2,
+ HAL_PIXEL_FORMAT_RGB_888 = 3,
+ HAL_PIXEL_FORMAT_RGB_565 = 4,
+ HAL_PIXEL_FORMAT_BGRA_8888 = 5,
+ HAL_PIXEL_FORMAT_RGBA_FP16 = 22,
+ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34,
+ HAL_PIXEL_FORMAT_YV12 = 842094169,
+};
diff --git a/include/Android/vndk/window.h b/include/Android/vndk/window.h
new file mode 100644
index 0000000..8b5965f
--- /dev/null
+++ b/include/Android/vndk/window.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <nativebase/nativebase.h>
+
+struct ANativeWindow;
+typedef struct ANativeWindow ANativeWindow;
+
+void ANativeWindow_acquire(ANativeWindow* window);
+void ANativeWindow_release(ANativeWindow* window);
+int32_t ANativeWindow_getWidth(ANativeWindow* window);
+int32_t ANativeWindow_getHeight(ANativeWindow* window);
+int ANativeWindow_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
+int ANativeWindow_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
+int ANativeWindow_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
+int ANativeWindow_setUsage(ANativeWindow* window, uint64_t usage);
diff --git a/include/Wayland/wayland-client-core.h b/include/Wayland/wayland-client-core.h
new file mode 100644
index 0000000..ce91a6f
--- /dev/null
+++ b/include/Wayland/wayland-client-core.h
@@ -0,0 +1,292 @@
+/*
+ * Copyright © 2008 Kristian Høgsberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * 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 OR COPYRIGHT HOLDERS
+ * 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.
+ */
+
+#ifndef WAYLAND_CLIENT_CORE_H
+#define WAYLAND_CLIENT_CORE_H
+
+#include <stdint.h>
+#include "wayland-util.h"
+#include "wayland-version.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \class wl_proxy
+ *
+ * \brief Represents a protocol object on the client side.
+ *
+ * A wl_proxy acts as a client side proxy to an object existing in the
+ * compositor. The proxy is responsible for converting requests made by the
+ * clients with \ref wl_proxy_marshal() into Wayland's wire format. Events
+ * coming from the compositor are also handled by the proxy, which will in
+ * turn call the handler set with \ref wl_proxy_add_listener().
+ *
+ * \note With the exception of function \ref wl_proxy_set_queue(), functions
+ * accessing a wl_proxy are not normally used by client code. Clients
+ * should normally use the higher level interface generated by the scanner to
+ * interact with compositor objects.
+ *
+ */
+struct wl_proxy;
+
+/** \class wl_display
+ *
+ * \brief Represents a connection to the compositor and acts as a proxy to
+ * the wl_display singleton object.
+ *
+ * A wl_display object represents a client connection to a Wayland
+ * compositor. It is created with either \ref wl_display_connect() or
+ * \ref wl_display_connect_to_fd(). A connection is terminated using
+ * \ref wl_display_disconnect().
+ *
+ * A wl_display is also used as the \ref wl_proxy for the wl_display
+ * singleton object on the compositor side.
+ *
+ * A wl_display object handles all the data sent from and to the
+ * compositor. When a \ref wl_proxy marshals a request, it will write its wire
+ * representation to the display's write buffer. The data is sent to the
+ * compositor when the client calls \ref wl_display_flush().
+ *
+ * Incoming data is handled in two steps: queueing and dispatching. In the
+ * queue step, the data coming from the display fd is interpreted and
+ * added to a queue. On the dispatch step, the handler for the incoming
+ * event set by the client on the corresponding \ref wl_proxy is called.
+ *
+ * A wl_display has at least one event queue, called the <em>default
+ * queue</em>. Clients can create additional event queues with \ref
+ * wl_display_create_queue() and assign \ref wl_proxy's to it. Events
+ * occurring in a particular proxy are always queued in its assigned queue.
+ * A client can ensure that a certain assumption, such as holding a lock
+ * or running from a given thread, is true when a proxy event handler is
+ * called by assigning that proxy to an event queue and making sure that
+ * this queue is only dispatched when the assumption holds.
+ *
+ * The default queue is dispatched by calling \ref wl_display_dispatch().
+ * This will dispatch any events queued on the default queue and attempt
+ * to read from the display fd if it's empty. Events read are then queued
+ * on the appropriate queues according to the proxy assignment.
+ *
+ * A user created queue is dispatched with \ref wl_display_dispatch_queue().
+ * This function behaves exactly the same as wl_display_dispatch()
+ * but it dispatches given queue instead of the default queue.
+ *
+ * A real world example of event queue usage is Mesa's implementation of
+ * eglSwapBuffers() for the Wayland platform. This function might need
+ * to block until a frame callback is received, but dispatching the default
+ * queue could cause an event handler on the client to start drawing
+ * again. This problem is solved using another event queue, so that only
+ * the events handled by the EGL code are dispatched during the block.
+ *
+ * This creates a problem where a thread dispatches a non-default
+ * queue, reading all the data from the display fd. If the application
+ * would call \em poll(2) after that it would block, even though there
+ * might be events queued on the default queue. Those events should be
+ * dispatched with \ref wl_display_dispatch_pending() or \ref
+ * wl_display_dispatch_queue_pending() before flushing and blocking.
+ */
+struct wl_display;
+
+/** \class wl_event_queue
+ *
+ * \brief A queue for \ref wl_proxy object events.
+ *
+ * Event queues allows the events on a display to be handled in a thread-safe
+ * manner. See \ref wl_display for details.
+ *
+ */
+struct wl_event_queue;
+
+/** Destroy proxy after marshalling
+ * @ingroup wl_proxy
+ */
+#define WL_MARSHAL_FLAG_DESTROY (1 << 0)
+
+void
+wl_event_queue_destroy(struct wl_event_queue *queue);
+
+struct wl_proxy *
+wl_proxy_marshal_flags(struct wl_proxy *proxy, uint32_t opcode,
+ const struct wl_interface *interface,
+ uint32_t version,
+ uint32_t flags, ...);
+
+struct wl_proxy *
+wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode,
+ const struct wl_interface *interface,
+ uint32_t version,
+ uint32_t flags,
+ union wl_argument *args);
+
+void
+wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
+
+void
+wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,
+ union wl_argument *args);
+
+struct wl_proxy *
+wl_proxy_create(struct wl_proxy *factory,
+ const struct wl_interface *interface);
+
+void *
+wl_proxy_create_wrapper(void *proxy);
+
+void
+wl_proxy_wrapper_destroy(void *proxy_wrapper);
+
+struct wl_proxy *
+wl_proxy_marshal_constructor(struct wl_proxy *proxy,
+ uint32_t opcode,
+ const struct wl_interface *interface,
+ ...);
+
+struct wl_proxy *
+wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy,
+ uint32_t opcode,
+ const struct wl_interface *interface,
+ uint32_t version,
+ ...);
+
+struct wl_proxy *
+wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
+ uint32_t opcode, union wl_argument *args,
+ const struct wl_interface *interface);
+
+struct wl_proxy *
+wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
+ uint32_t opcode,
+ union wl_argument *args,
+ const struct wl_interface *interface,
+ uint32_t version);
+
+void
+wl_proxy_destroy(struct wl_proxy *proxy);
+
+int
+wl_proxy_add_listener(struct wl_proxy *proxy,
+ void (**implementation)(void), void *data);
+
+const void *
+wl_proxy_get_listener(struct wl_proxy *proxy);
+
+int
+wl_proxy_add_dispatcher(struct wl_proxy *proxy,
+ wl_dispatcher_func_t dispatcher_func,
+ const void * dispatcher_data, void *data);
+
+void
+wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
+
+void *
+wl_proxy_get_user_data(struct wl_proxy *proxy);
+
+uint32_t
+wl_proxy_get_version(struct wl_proxy *proxy);
+
+uint32_t
+wl_proxy_get_id(struct wl_proxy *proxy);
+
+void
+wl_proxy_set_tag(struct wl_proxy *proxy,
+ const char * const *tag);
+
+const char * const *
+wl_proxy_get_tag(struct wl_proxy *proxy);
+
+const char *
+wl_proxy_get_class(struct wl_proxy *proxy);
+
+void
+wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue);
+
+struct wl_display *
+wl_display_connect(const char *name);
+
+struct wl_display *
+wl_display_connect_to_fd(int fd);
+
+void
+wl_display_disconnect(struct wl_display *display);
+
+int
+wl_display_get_fd(struct wl_display *display);
+
+int
+wl_display_dispatch(struct wl_display *display);
+
+int
+wl_display_dispatch_queue(struct wl_display *display,
+ struct wl_event_queue *queue);
+
+int
+wl_display_dispatch_queue_pending(struct wl_display *display,
+ struct wl_event_queue *queue);
+
+int
+wl_display_dispatch_pending(struct wl_display *display);
+
+int
+wl_display_get_error(struct wl_display *display);
+
+uint32_t
+wl_display_get_protocol_error(struct wl_display *display,
+ const struct wl_interface **interface,
+ uint32_t *id);
+
+int
+wl_display_flush(struct wl_display *display);
+
+int
+wl_display_roundtrip_queue(struct wl_display *display,
+ struct wl_event_queue *queue);
+
+int
+wl_display_roundtrip(struct wl_display *display);
+
+struct wl_event_queue *
+wl_display_create_queue(struct wl_display *display);
+
+int
+wl_display_prepare_read_queue(struct wl_display *display,
+ struct wl_event_queue *queue);
+
+int
+wl_display_prepare_read(struct wl_display *display);
+
+void
+wl_display_cancel_read(struct wl_display *display);
+
+int
+wl_display_read_events(struct wl_display *display);
+
+void
+wl_log_set_handler_client(wl_log_func_t handler);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/Wayland/wayland-client-protocol.h b/include/Wayland/wayland-client-protocol.h
new file mode 100644
index 0000000..1f3481c
--- /dev/null
+++ b/include/Wayland/wayland-client-protocol.h
@@ -0,0 +1,6106 @@
+/* Generated by wayland-scanner 1.21.0 */
+
+#ifndef WAYLAND_CLIENT_PROTOCOL_H
+#define WAYLAND_CLIENT_PROTOCOL_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @page page_wayland The wayland protocol
+ * @section page_ifaces_wayland Interfaces
+ * - @subpage page_iface_wl_display - core global object
+ * - @subpage page_iface_wl_registry - global registry object
+ * - @subpage page_iface_wl_callback - callback object
+ * - @subpage page_iface_wl_compositor - the compositor singleton
+ * - @subpage page_iface_wl_shm_pool - a shared memory pool
+ * - @subpage page_iface_wl_shm - shared memory support
+ * - @subpage page_iface_wl_buffer - content for a wl_surface
+ * - @subpage page_iface_wl_data_offer - offer to transfer data
+ * - @subpage page_iface_wl_data_source - offer to transfer data
+ * - @subpage page_iface_wl_data_device - data transfer device
+ * - @subpage page_iface_wl_data_device_manager - data transfer interface
+ * - @subpage page_iface_wl_shell - create desktop-style surfaces
+ * - @subpage page_iface_wl_shell_surface - desktop-style metadata interface
+ * - @subpage page_iface_wl_surface - an onscreen surface
+ * - @subpage page_iface_wl_seat - group of input devices
+ * - @subpage page_iface_wl_pointer - pointer input device
+ * - @subpage page_iface_wl_keyboard - keyboard input device
+ * - @subpage page_iface_wl_touch - touchscreen input device
+ * - @subpage page_iface_wl_output - compositor output region
+ * - @subpage page_iface_wl_region - region interface
+ * - @subpage page_iface_wl_subcompositor - sub-surface compositing
+ * - @subpage page_iface_wl_subsurface - sub-surface interface to a wl_surface
+ * @section page_copyright_wayland Copyright
+ * <pre>
+ *
+ * Copyright © 2008-2011 Kristian Høgsberg
+ * Copyright © 2010-2011 Intel Corporation
+ * Copyright © 2012-2013 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * 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 OR COPYRIGHT HOLDERS
+ * 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.
+ * </pre>
+ */
+struct wl_buffer;
+struct wl_callback;
+struct wl_compositor;
+struct wl_data_device;
+struct wl_data_device_manager;
+struct wl_data_offer;
+struct wl_data_source;
+struct wl_display;
+struct wl_keyboard;
+struct wl_output;
+struct wl_pointer;
+struct wl_region;
+struct wl_registry;
+struct wl_seat;
+struct wl_shell;
+struct wl_shell_surface;
+struct wl_shm;
+struct wl_shm_pool;
+struct wl_subcompositor;
+struct wl_subsurface;
+struct wl_surface;
+struct wl_touch;
+
+#ifndef WL_DISPLAY_INTERFACE
+#define WL_DISPLAY_INTERFACE
+/**
+ * @page page_iface_wl_display wl_display
+ * @section page_iface_wl_display_desc Description
+ *
+ * The core global object. This is a special singleton object. It
+ * is used for internal Wayland protocol features.
+ * @section page_iface_wl_display_api API
+ * See @ref iface_wl_display.
+ */
+/**
+ * @defgroup iface_wl_display The wl_display interface
+ *
+ * The core global object. This is a special singleton object. It
+ * is used for internal Wayland protocol features.
+ */
+extern const struct wl_interface wl_display_interface;
+#endif
+#ifndef WL_REGISTRY_INTERFACE
+#define WL_REGISTRY_INTERFACE
+/**
+ * @page page_iface_wl_registry wl_registry
+ * @section page_iface_wl_registry_desc Description
+ *
+ * The singleton global registry object. The server has a number of
+ * global objects that are available to all clients. These objects
+ * typically represent an actual object in the server (for example,
+ * an input device) or they are singleton objects that provide
+ * extension functionality.
+ *
+ * When a client creates a registry object, the registry object
+ * will emit a global event for each global currently in the
+ * registry. Globals come and go as a result of device or
+ * monitor hotplugs, reconfiguration or other events, and the
+ * registry will send out global and global_remove events to
+ * keep the client up to date with the changes. To mark the end
+ * of the initial burst of events, the client can use the
+ * wl_display.sync request immediately after calling
+ * wl_display.get_registry.
+ *
+ * A client can bind to a global object by using the bind
+ * request. This creates a client-side handle that lets the object
+ * emit events to the client and lets the client invoke requests on
+ * the object.
+ * @section page_iface_wl_registry_api API
+ * See @ref iface_wl_registry.
+ */
+/**
+ * @defgroup iface_wl_registry The wl_registry interface
+ *
+ * The singleton global registry object. The server has a number of
+ * global objects that are available to all clients. These objects
+ * typically represent an actual object in the server (for example,
+ * an input device) or they are singleton objects that provide
+ * extension functionality.
+ *
+ * When a client creates a registry object, the registry object
+ * will emit a global event for each global currently in the
+ * registry. Globals come and go as a result of device or
+ * monitor hotplugs, reconfiguration or other events, and the
+ * registry will send out global and global_remove events to
+ * keep the client up to date with the changes. To mark the end
+ * of the initial burst of events, the client can use the
+ * wl_display.sync request immediately after calling
+ * wl_display.get_registry.
+ *
+ * A client can bind to a global object by using the bind
+ * request. This creates a client-side handle that lets the object
+ * emit events to the client and lets the client invoke requests on
+ * the object.
+ */
+extern const struct wl_interface wl_registry_interface;
+#endif
+#ifndef WL_CALLBACK_INTERFACE
+#define WL_CALLBACK_INTERFACE
+/**
+ * @page page_iface_wl_callback wl_callback
+ * @section page_iface_wl_callback_desc Description
+ *
+ * Clients can handle the 'done' event to get notified when
+ * the related request is done.
+ * @section page_iface_wl_callback_api API
+ * See @ref iface_wl_callback.
+ */
+/**
+ * @defgroup iface_wl_callback The wl_callback interface
+ *
+ * Clients can handle the 'done' event to get notified when
+ * the related request is done.
+ */
+extern const struct wl_interface wl_callback_interface;
+#endif
+#ifndef WL_COMPOSITOR_INTERFACE
+#define WL_COMPOSITOR_INTERFACE
+/**
+ * @page page_iface_wl_compositor wl_compositor
+ * @section page_iface_wl_compositor_desc Description
+ *
+ * A compositor. This object is a singleton global. The
+ * compositor is in charge of combining the contents of multiple
+ * surfaces into one displayable output.
+ * @section page_iface_wl_compositor_api API
+ * See @ref iface_wl_compositor.
+ */
+/**
+ * @defgroup iface_wl_compositor The wl_compositor interface
+ *
+ * A compositor. This object is a singleton global. The
+ * compositor is in charge of combining the contents of multiple
+ * surfaces into one displayable output.
+ */
+extern const struct wl_interface wl_compositor_interface;
+#endif
+#ifndef WL_SHM_POOL_INTERFACE
+#define WL_SHM_POOL_INTERFACE
+/**
+ * @page page_iface_wl_shm_pool wl_shm_pool
+ * @section page_iface_wl_shm_pool_desc Description
+ *
+ * The wl_shm_pool object encapsulates a piece of memory shared
+ * between the compositor and client. Through the wl_shm_pool
+ * object, the client can allocate shared memory wl_buffer objects.
+ * All objects created through the same pool share the same
+ * underlying mapped memory. Reusing the mapped memory avoids the
+ * setup/teardown overhead and is useful when interactively resizing
+ * a surface or for many small buffers.
+ * @section page_iface_wl_shm_pool_api API
+ * See @ref iface_wl_shm_pool.
+ */
+/**
+ * @defgroup iface_wl_shm_pool The wl_shm_pool interface
+ *
+ * The wl_shm_pool object encapsulates a piece of memory shared
+ * between the compositor and client. Through the wl_shm_pool
+ * object, the client can allocate shared memory wl_buffer objects.
+ * All objects created through the same pool share the same
+ * underlying mapped memory. Reusing the mapped memory avoids the
+ * setup/teardown overhead and is useful when interactively resizing
+ * a surface or for many small buffers.
+ */
+extern const struct wl_interface wl_shm_pool_interface;
+#endif
+#ifndef WL_SHM_INTERFACE
+#define WL_SHM_INTERFACE
+/**
+ * @page page_iface_wl_shm wl_shm
+ * @section page_iface_wl_shm_desc Description
+ *
+ * A singleton global object that provides support for shared
+ * memory.
+ *
+ * Clients can create wl_shm_pool objects using the create_pool
+ * request.
+ *
+ * On binding the wl_shm object one or more format events
+ * are emitted to inform clients about the valid pixel formats
+ * that can be used for buffers.
+ * @section page_iface_wl_shm_api API
+ * See @ref iface_wl_shm.
+ */
+/**
+ * @defgroup iface_wl_shm The wl_shm interface
+ *
+ * A singleton global object that provides support for shared
+ * memory.
+ *
+ * Clients can create wl_shm_pool objects using the create_pool
+ * request.
+ *
+ * On binding the wl_shm object one or more format events
+ * are emitted to inform clients about the valid pixel formats
+ * that can be used for buffers.
+ */
+extern const struct wl_interface wl_shm_interface;
+#endif
+#ifndef WL_BUFFER_INTERFACE
+#define WL_BUFFER_INTERFACE
+/**
+ * @page page_iface_wl_buffer wl_buffer
+ * @section page_iface_wl_buffer_desc Description
+ *
+ * A buffer provides the content for a wl_surface. Buffers are
+ * created through factory interfaces such as wl_shm, wp_linux_buffer_params
+ * (from the linux-dmabuf protocol extension) or similar. It has a width and
+ * a height and can be attached to a wl_surface, but the mechanism by which a
+ * client provides and updates the contents is defined by the buffer factory
+ * interface.
+ *
+ * If the buffer uses a format that has an alpha channel, the alpha channel
+ * is assumed to be premultiplied in the color channels unless otherwise
+ * specified.
+ * @section page_iface_wl_buffer_api API
+ * See @ref iface_wl_buffer.
+ */
+/**
+ * @defgroup iface_wl_buffer The wl_buffer interface
+ *
+ * A buffer provides the content for a wl_surface. Buffers are
+ * created through factory interfaces such as wl_shm, wp_linux_buffer_params
+ * (from the linux-dmabuf protocol extension) or similar. It has a width and
+ * a height and can be attached to a wl_surface, but the mechanism by which a
+ * client provides and updates the contents is defined by the buffer factory
+ * interface.
+ *
+ * If the buffer uses a format that has an alpha channel, the alpha channel
+ * is assumed to be premultiplied in the color channels unless otherwise
+ * specified.
+ */
+extern const struct wl_interface wl_buffer_interface;
+#endif
+#ifndef WL_DATA_OFFER_INTERFACE
+#define WL_DATA_OFFER_INTERFACE
+/**
+ * @page page_iface_wl_data_offer wl_data_offer
+ * @section page_iface_wl_data_offer_desc Description
+ *
+ * A wl_data_offer represents a piece of data offered for transfer
+ * by another client (the source client). It is used by the
+ * copy-and-paste and drag-and-drop mechanisms. The offer
+ * describes the different mime types that the data can be
+ * converted to and provides the mechanism for transferring the
+ * data directly from the source client.
+ * @section page_iface_wl_data_offer_api API
+ * See @ref iface_wl_data_offer.
+ */
+/**
+ * @defgroup iface_wl_data_offer The wl_data_offer interface
+ *
+ * A wl_data_offer represents a piece of data offered for transfer
+ * by another client (the source client). It is used by the
+ * copy-and-paste and drag-and-drop mechanisms. The offer
+ * describes the different mime types that the data can be
+ * converted to and provides the mechanism for transferring the
+ * data directly from the source client.
+ */
+extern const struct wl_interface wl_data_offer_interface;
+#endif
+#ifndef WL_DATA_SOURCE_INTERFACE
+#define WL_DATA_SOURCE_INTERFACE
+/**
+ * @page page_iface_wl_data_source wl_data_source
+ * @section page_iface_wl_data_source_desc Description
+ *
+ * The wl_data_source object is the source side of a wl_data_offer.
+ * It is created by the source client in a data transfer and
+ * provides a way to describe the offered data and a way to respond
+ * to requests to transfer the data.
+ * @section page_iface_wl_data_source_api API
+ * See @ref iface_wl_data_source.
+ */
+/**
+ * @defgroup iface_wl_data_source The wl_data_source interface
+ *
+ * The wl_data_source object is the source side of a wl_data_offer.
+ * It is created by the source client in a data transfer and
+ * provides a way to describe the offered data and a way to respond
+ * to requests to transfer the data.
+ */
+extern const struct wl_interface wl_data_source_interface;
+#endif
+#ifndef WL_DATA_DEVICE_INTERFACE
+#define WL_DATA_DEVICE_INTERFACE
+/**
+ * @page page_iface_wl_data_device wl_data_device
+ * @section page_iface_wl_data_device_desc Description
+ *
+ * There is one wl_data_device per seat which can be obtained
+ * from the global wl_data_device_manager singleton.
+ *
+ * A wl_data_device provides access to inter-client data transfer
+ * mechanisms such as copy-and-paste and drag-and-drop.
+ * @section page_iface_wl_data_device_api API
+ * See @ref iface_wl_data_device.
+ */
+/**
+ * @defgroup iface_wl_data_device The wl_data_device interface
+ *
+ * There is one wl_data_device per seat which can be obtained
+ * from the global wl_data_device_manager singleton.
+ *
+ * A wl_data_device provides access to inter-client data transfer
+ * mechanisms such as copy-and-paste and drag-and-drop.
+ */
+extern const struct wl_interface wl_data_device_interface;
+#endif
+#ifndef WL_DATA_DEVICE_MANAGER_INTERFACE
+#define WL_DATA_DEVICE_MANAGER_INTERFACE
+/**
+ * @page page_iface_wl_data_device_manager wl_data_device_manager
+ * @section page_iface_wl_data_device_manager_desc Description
+ *
+ * The wl_data_device_manager is a singleton global object that
+ * provides access to inter-client data transfer mechanisms such as
+ * copy-and-paste and drag-and-drop. These mechanisms are tied to
+ * a wl_seat and this interface lets a client get a wl_data_device
+ * corresponding to a wl_seat.
+ *
+ * Depending on the version bound, the objects created from the bound
+ * wl_data_device_manager object will have different requirements for
+ * functioning properly. See wl_data_source.set_actions,
+ * wl_data_offer.accept and wl_data_offer.finish for details.
+ * @section page_iface_wl_data_device_manager_api API
+ * See @ref iface_wl_data_device_manager.
+ */
+/**
+ * @defgroup iface_wl_data_device_manager The wl_data_device_manager interface
+ *
+ * The wl_data_device_manager is a singleton global object that
+ * provides access to inter-client data transfer mechanisms such as
+ * copy-and-paste and drag-and-drop. These mechanisms are tied to
+ * a wl_seat and this interface lets a client get a wl_data_device
+ * corresponding to a wl_seat.
+ *
+ * Depending on the version bound, the objects created from the bound
+ * wl_data_device_manager object will have different requirements for
+ * functioning properly. See wl_data_source.set_actions,
+ * wl_data_offer.accept and wl_data_offer.finish for details.
+ */
+extern const struct wl_interface wl_data_device_manager_interface;
+#endif
+#ifndef WL_SHELL_INTERFACE
+#define WL_SHELL_INTERFACE
+/**
+ * @page page_iface_wl_shell wl_shell
+ * @section page_iface_wl_shell_desc Description
+ *
+ * This interface is implemented by servers that provide
+ * desktop-style user interfaces.
+ *
+ * It allows clients to associate a wl_shell_surface with
+ * a basic surface.
+ *
+ * Note! This protocol is deprecated and not intended for production use.
+ * For desktop-style user interfaces, use xdg_shell. Compositors and clients
+ * should not implement this interface.
+ * @section page_iface_wl_shell_api API
+ * See @ref iface_wl_shell.
+ */
+/**
+ * @defgroup iface_wl_shell The wl_shell interface
+ *
+ * This interface is implemented by servers that provide
+ * desktop-style user interfaces.
+ *
+ * It allows clients to associate a wl_shell_surface with
+ * a basic surface.
+ *
+ * Note! This protocol is deprecated and not intended for production use.
+ * For desktop-style user interfaces, use xdg_shell. Compositors and clients
+ * should not implement this interface.
+ */
+extern const struct wl_interface wl_shell_interface;
+#endif
+#ifndef WL_SHELL_SURFACE_INTERFACE
+#define WL_SHELL_SURFACE_INTERFACE
+/**
+ * @page page_iface_wl_shell_surface wl_shell_surface
+ * @section page_iface_wl_shell_surface_desc Description
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like toplevel, fullscreen
+ * or popup windows, move, resize or maximize them, associate
+ * metadata like title and class, etc.
+ *
+ * On the server side the object is automatically destroyed when
+ * the related wl_surface is destroyed. On the client side,
+ * wl_shell_surface_destroy() must be called before destroying
+ * the wl_surface object.
+ * @section page_iface_wl_shell_surface_api API
+ * See @ref iface_wl_shell_surface.
+ */
+/**
+ * @defgroup iface_wl_shell_surface The wl_shell_surface interface
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like toplevel, fullscreen
+ * or popup windows, move, resize or maximize them, associate
+ * metadata like title and class, etc.
+ *
+ * On the server side the object is automatically destroyed when
+ * the related wl_surface is destroyed. On the client side,
+ * wl_shell_surface_destroy() must be called before destroying
+ * the wl_surface object.
+ */
+extern const struct wl_interface wl_shell_surface_interface;
+#endif
+#ifndef WL_SURFACE_INTERFACE
+#define WL_SURFACE_INTERFACE
+/**
+ * @page page_iface_wl_surface wl_surface
+ * @section page_iface_wl_surface_desc Description
+ *
+ * A surface is a rectangular area that may be displayed on zero
+ * or more outputs, and shown any number of times at the compositor's
+ * discretion. They can present wl_buffers, receive user input, and
+ * define a local coordinate system.
+ *
+ * The size of a surface (and relative positions on it) is described
+ * in surface-local coordinates, which may differ from the buffer
+ * coordinates of the pixel content, in case a buffer_transform
+ * or a buffer_scale is used.
+ *
+ * A surface without a "role" is fairly useless: a compositor does
+ * not know where, when or how to present it. The role is the
+ * purpose of a wl_surface. Examples of roles are a cursor for a
+ * pointer (as set by wl_pointer.set_cursor), a drag icon
+ * (wl_data_device.start_drag), a sub-surface
+ * (wl_subcompositor.get_subsurface), and a window as defined by a
+ * shell protocol (e.g. wl_shell.get_shell_surface).
+ *
+ * A surface can have only one role at a time. Initially a
+ * wl_surface does not have a role. Once a wl_surface is given a
+ * role, it is set permanently for the whole lifetime of the
+ * wl_surface object. Giving the current role again is allowed,
+ * unless explicitly forbidden by the relevant interface
+ * specification.
+ *
+ * Surface roles are given by requests in other interfaces such as
+ * wl_pointer.set_cursor. The request should explicitly mention
+ * that this request gives a role to a wl_surface. Often, this
+ * request also creates a new protocol object that represents the
+ * role and adds additional functionality to wl_surface. When a
+ * client wants to destroy a wl_surface, they must destroy this 'role
+ * object' before the wl_surface.
+ *
+ * Destroying the role object does not remove the role from the
+ * wl_surface, but it may stop the wl_surface from "playing the role".
+ * For instance, if a wl_subsurface object is destroyed, the wl_surface
+ * it was created for will be unmapped and forget its position and
+ * z-order. It is allowed to create a wl_subsurface for the same
+ * wl_surface again, but it is not allowed to use the wl_surface as
+ * a cursor (cursor is a different role than sub-surface, and role
+ * switching is not allowed).
+ * @section page_iface_wl_surface_api API
+ * See @ref iface_wl_surface.
+ */
+/**
+ * @defgroup iface_wl_surface The wl_surface interface
+ *
+ * A surface is a rectangular area that may be displayed on zero
+ * or more outputs, and shown any number of times at the compositor's
+ * discretion. They can present wl_buffers, receive user input, and
+ * define a local coordinate system.
+ *
+ * The size of a surface (and relative positions on it) is described
+ * in surface-local coordinates, which may differ from the buffer
+ * coordinates of the pixel content, in case a buffer_transform
+ * or a buffer_scale is used.
+ *
+ * A surface without a "role" is fairly useless: a compositor does
+ * not know where, when or how to present it. The role is the
+ * purpose of a wl_surface. Examples of roles are a cursor for a
+ * pointer (as set by wl_pointer.set_cursor), a drag icon
+ * (wl_data_device.start_drag), a sub-surface
+ * (wl_subcompositor.get_subsurface), and a window as defined by a
+ * shell protocol (e.g. wl_shell.get_shell_surface).
+ *
+ * A surface can have only one role at a time. Initially a
+ * wl_surface does not have a role. Once a wl_surface is given a
+ * role, it is set permanently for the whole lifetime of the
+ * wl_surface object. Giving the current role again is allowed,
+ * unless explicitly forbidden by the relevant interface
+ * specification.
+ *
+ * Surface roles are given by requests in other interfaces such as
+ * wl_pointer.set_cursor. The request should explicitly mention
+ * that this request gives a role to a wl_surface. Often, this
+ * request also creates a new protocol object that represents the
+ * role and adds additional functionality to wl_surface. When a
+ * client wants to destroy a wl_surface, they must destroy this 'role
+ * object' before the wl_surface.
+ *
+ * Destroying the role object does not remove the role from the
+ * wl_surface, but it may stop the wl_surface from "playing the role".
+ * For instance, if a wl_subsurface object is destroyed, the wl_surface
+ * it was created for will be unmapped and forget its position and
+ * z-order. It is allowed to create a wl_subsurface for the same
+ * wl_surface again, but it is not allowed to use the wl_surface as
+ * a cursor (cursor is a different role than sub-surface, and role
+ * switching is not allowed).
+ */
+extern const struct wl_interface wl_surface_interface;
+#endif
+#ifndef WL_SEAT_INTERFACE
+#define WL_SEAT_INTERFACE
+/**
+ * @page page_iface_wl_seat wl_seat
+ * @section page_iface_wl_seat_desc Description
+ *
+ * A seat is a group of keyboards, pointer and touch devices. This
+ * object is published as a global during start up, or when such a
+ * device is hot plugged. A seat typically has a pointer and
+ * maintains a keyboard focus and a pointer focus.
+ * @section page_iface_wl_seat_api API
+ * See @ref iface_wl_seat.
+ */
+/**
+ * @defgroup iface_wl_seat The wl_seat interface
+ *
+ * A seat is a group of keyboards, pointer and touch devices. This
+ * object is published as a global during start up, or when such a
+ * device is hot plugged. A seat typically has a pointer and
+ * maintains a keyboard focus and a pointer focus.
+ */
+extern const struct wl_interface wl_seat_interface;
+#endif
+#ifndef WL_POINTER_INTERFACE
+#define WL_POINTER_INTERFACE
+/**
+ * @page page_iface_wl_pointer wl_pointer
+ * @section page_iface_wl_pointer_desc Description
+ *
+ * The wl_pointer interface represents one or more input devices,
+ * such as mice, which control the pointer location and pointer_focus
+ * of a seat.
+ *
+ * The wl_pointer interface generates motion, enter and leave
+ * events for the surfaces that the pointer is located over,
+ * and button and axis events for button presses, button releases
+ * and scrolling.
+ * @section page_iface_wl_pointer_api API
+ * See @ref iface_wl_pointer.
+ */
+/**
+ * @defgroup iface_wl_pointer The wl_pointer interface
+ *
+ * The wl_pointer interface represents one or more input devices,
+ * such as mice, which control the pointer location and pointer_focus
+ * of a seat.
+ *
+ * The wl_pointer interface generates motion, enter and leave
+ * events for the surfaces that the pointer is located over,
+ * and button and axis events for button presses, button releases
+ * and scrolling.
+ */
+extern const struct wl_interface wl_pointer_interface;
+#endif
+#ifndef WL_KEYBOARD_INTERFACE
+#define WL_KEYBOARD_INTERFACE
+/**
+ * @page page_iface_wl_keyboard wl_keyboard
+ * @section page_iface_wl_keyboard_desc Description
+ *
+ * The wl_keyboard interface represents one or more keyboards
+ * associated with a seat.
+ * @section page_iface_wl_keyboard_api API
+ * See @ref iface_wl_keyboard.
+ */
+/**
+ * @defgroup iface_wl_keyboard The wl_keyboard interface
+ *
+ * The wl_keyboard interface represents one or more keyboards
+ * associated with a seat.
+ */
+extern const struct wl_interface wl_keyboard_interface;
+#endif
+#ifndef WL_TOUCH_INTERFACE
+#define WL_TOUCH_INTERFACE
+/**
+ * @page page_iface_wl_touch wl_touch
+ * @section page_iface_wl_touch_desc Description
+ *
+ * The wl_touch interface represents a touchscreen
+ * associated with a seat.
+ *
+ * Touch interactions can consist of one or more contacts.
+ * For each contact, a series of events is generated, starting
+ * with a down event, followed by zero or more motion events,
+ * and ending with an up event. Events relating to the same
+ * contact point can be identified by the ID of the sequence.
+ * @section page_iface_wl_touch_api API
+ * See @ref iface_wl_touch.
+ */
+/**
+ * @defgroup iface_wl_touch The wl_touch interface
+ *
+ * The wl_touch interface represents a touchscreen
+ * associated with a seat.
+ *
+ * Touch interactions can consist of one or more contacts.
+ * For each contact, a series of events is generated, starting
+ * with a down event, followed by zero or more motion events,
+ * and ending with an up event. Events relating to the same
+ * contact point can be identified by the ID of the sequence.
+ */
+extern const struct wl_interface wl_touch_interface;
+#endif
+#ifndef WL_OUTPUT_INTERFACE
+#define WL_OUTPUT_INTERFACE
+/**
+ * @page page_iface_wl_output wl_output
+ * @section page_iface_wl_output_desc Description
+ *
+ * An output describes part of the compositor geometry. The
+ * compositor works in the 'compositor coordinate system' and an
+ * output corresponds to a rectangular area in that space that is
+ * actually visible. This typically corresponds to a monitor that
+ * displays part of the compositor space. This object is published
+ * as global during start up, or when a monitor is hotplugged.
+ * @section page_iface_wl_output_api API
+ * See @ref iface_wl_output.
+ */
+/**
+ * @defgroup iface_wl_output The wl_output interface
+ *
+ * An output describes part of the compositor geometry. The
+ * compositor works in the 'compositor coordinate system' and an
+ * output corresponds to a rectangular area in that space that is
+ * actually visible. This typically corresponds to a monitor that
+ * displays part of the compositor space. This object is published
+ * as global during start up, or when a monitor is hotplugged.
+ */
+extern const struct wl_interface wl_output_interface;
+#endif
+#ifndef WL_REGION_INTERFACE
+#define WL_REGION_INTERFACE
+/**
+ * @page page_iface_wl_region wl_region
+ * @section page_iface_wl_region_desc Description
+ *
+ * A region object describes an area.
+ *
+ * Region objects are used to describe the opaque and input
+ * regions of a surface.
+ * @section page_iface_wl_region_api API
+ * See @ref iface_wl_region.
+ */
+/**
+ * @defgroup iface_wl_region The wl_region interface
+ *
+ * A region object describes an area.
+ *
+ * Region objects are used to describe the opaque and input
+ * regions of a surface.
+ */
+extern const struct wl_interface wl_region_interface;
+#endif
+#ifndef WL_SUBCOMPOSITOR_INTERFACE
+#define WL_SUBCOMPOSITOR_INTERFACE
+/**
+ * @page page_iface_wl_subcompositor wl_subcompositor
+ * @section page_iface_wl_subcompositor_desc Description
+ *
+ * The global interface exposing sub-surface compositing capabilities.
+ * A wl_surface, that has sub-surfaces associated, is called the
+ * parent surface. Sub-surfaces can be arbitrarily nested and create
+ * a tree of sub-surfaces.
+ *
+ * The root surface in a tree of sub-surfaces is the main
+ * surface. The main surface cannot be a sub-surface, because
+ * sub-surfaces must always have a parent.
+ *
+ * A main surface with its sub-surfaces forms a (compound) window.
+ * For window management purposes, this set of wl_surface objects is
+ * to be considered as a single window, and it should also behave as
+ * such.
+ *
+ * The aim of sub-surfaces is to offload some of the compositing work
+ * within a window from clients to the compositor. A prime example is
+ * a video player with decorations and video in separate wl_surface
+ * objects. This should allow the compositor to pass YUV video buffer
+ * processing to dedicated overlay hardware when possible.
+ * @section page_iface_wl_subcompositor_api API
+ * See @ref iface_wl_subcompositor.
+ */
+/**
+ * @defgroup iface_wl_subcompositor The wl_subcompositor interface
+ *
+ * The global interface exposing sub-surface compositing capabilities.
+ * A wl_surface, that has sub-surfaces associated, is called the
+ * parent surface. Sub-surfaces can be arbitrarily nested and create
+ * a tree of sub-surfaces.
+ *
+ * The root surface in a tree of sub-surfaces is the main
+ * surface. The main surface cannot be a sub-surface, because
+ * sub-surfaces must always have a parent.
+ *
+ * A main surface with its sub-surfaces forms a (compound) window.
+ * For window management purposes, this set of wl_surface objects is
+ * to be considered as a single window, and it should also behave as
+ * such.
+ *
+ * The aim of sub-surfaces is to offload some of the compositing work
+ * within a window from clients to the compositor. A prime example is
+ * a video player with decorations and video in separate wl_surface
+ * objects. This should allow the compositor to pass YUV video buffer
+ * processing to dedicated overlay hardware when possible.
+ */
+extern const struct wl_interface wl_subcompositor_interface;
+#endif
+#ifndef WL_SUBSURFACE_INTERFACE
+#define WL_SUBSURFACE_INTERFACE
+/**
+ * @page page_iface_wl_subsurface wl_subsurface
+ * @section page_iface_wl_subsurface_desc Description
+ *
+ * An additional interface to a wl_surface object, which has been
+ * made a sub-surface. A sub-surface has one parent surface. A
+ * sub-surface's size and position are not limited to that of the parent.
+ * Particularly, a sub-surface is not automatically clipped to its
+ * parent's area.
+ *
+ * A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
+ * and the parent surface is mapped. The order of which one happens
+ * first is irrelevant. A sub-surface is hidden if the parent becomes
+ * hidden, or if a NULL wl_buffer is applied. These rules apply
+ * recursively through the tree of surfaces.
+ *
+ * The behaviour of a wl_surface.commit request on a sub-surface
+ * depends on the sub-surface's mode. The possible modes are
+ * synchronized and desynchronized, see methods
+ * wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
+ * mode caches the wl_surface state to be applied when the parent's
+ * state gets applied, and desynchronized mode applies the pending
+ * wl_surface state directly. A sub-surface is initially in the
+ * synchronized mode.
+ *
+ * Sub-surfaces also have another kind of state, which is managed by
+ * wl_subsurface requests, as opposed to wl_surface requests. This
+ * state includes the sub-surface position relative to the parent
+ * surface (wl_subsurface.set_position), and the stacking order of
+ * the parent and its sub-surfaces (wl_subsurface.place_above and
+ * .place_below). This state is applied when the parent surface's
+ * wl_surface state is applied, regardless of the sub-surface's mode.
+ * As the exception, set_sync and set_desync are effective immediately.
+ *
+ * The main surface can be thought to be always in desynchronized mode,
+ * since it does not have a parent in the sub-surfaces sense.
+ *
+ * Even if a sub-surface is in desynchronized mode, it will behave as
+ * in synchronized mode, if its parent surface behaves as in
+ * synchronized mode. This rule is applied recursively throughout the
+ * tree of surfaces. This means, that one can set a sub-surface into
+ * synchronized mode, and then assume that all its child and grand-child
+ * sub-surfaces are synchronized, too, without explicitly setting them.
+ *
+ * If the wl_surface associated with the wl_subsurface is destroyed, the
+ * wl_subsurface object becomes inert. Note, that destroying either object
+ * takes effect immediately. If you need to synchronize the removal
+ * of a sub-surface to the parent surface update, unmap the sub-surface
+ * first by attaching a NULL wl_buffer, update parent, and then destroy
+ * the sub-surface.
+ *
+ * If the parent wl_surface object is destroyed, the sub-surface is
+ * unmapped.
+ * @section page_iface_wl_subsurface_api API
+ * See @ref iface_wl_subsurface.
+ */
+/**
+ * @defgroup iface_wl_subsurface The wl_subsurface interface
+ *
+ * An additional interface to a wl_surface object, which has been
+ * made a sub-surface. A sub-surface has one parent surface. A
+ * sub-surface's size and position are not limited to that of the parent.
+ * Particularly, a sub-surface is not automatically clipped to its
+ * parent's area.
+ *
+ * A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
+ * and the parent surface is mapped. The order of which one happens
+ * first is irrelevant. A sub-surface is hidden if the parent becomes
+ * hidden, or if a NULL wl_buffer is applied. These rules apply
+ * recursively through the tree of surfaces.
+ *
+ * The behaviour of a wl_surface.commit request on a sub-surface
+ * depends on the sub-surface's mode. The possible modes are
+ * synchronized and desynchronized, see methods
+ * wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
+ * mode caches the wl_surface state to be applied when the parent's
+ * state gets applied, and desynchronized mode applies the pending
+ * wl_surface state directly. A sub-surface is initially in the
+ * synchronized mode.
+ *
+ * Sub-surfaces also have another kind of state, which is managed by
+ * wl_subsurface requests, as opposed to wl_surface requests. This
+ * state includes the sub-surface position relative to the parent
+ * surface (wl_subsurface.set_position), and the stacking order of
+ * the parent and its sub-surfaces (wl_subsurface.place_above and
+ * .place_below). This state is applied when the parent surface's
+ * wl_surface state is applied, regardless of the sub-surface's mode.
+ * As the exception, set_sync and set_desync are effective immediately.
+ *
+ * The main surface can be thought to be always in desynchronized mode,
+ * since it does not have a parent in the sub-surfaces sense.
+ *
+ * Even if a sub-surface is in desynchronized mode, it will behave as
+ * in synchronized mode, if its parent surface behaves as in
+ * synchronized mode. This rule is applied recursively throughout the
+ * tree of surfaces. This means, that one can set a sub-surface into
+ * synchronized mode, and then assume that all its child and grand-child
+ * sub-surfaces are synchronized, too, without explicitly setting them.
+ *
+ * If the wl_surface associated with the wl_subsurface is destroyed, the
+ * wl_subsurface object becomes inert. Note, that destroying either object
+ * takes effect immediately. If you need to synchronize the removal
+ * of a sub-surface to the parent surface update, unmap the sub-surface
+ * first by attaching a NULL wl_buffer, update parent, and then destroy
+ * the sub-surface.
+ *
+ * If the parent wl_surface object is destroyed, the sub-surface is
+ * unmapped.
+ */
+extern const struct wl_interface wl_subsurface_interface;
+#endif
+
+#ifndef WL_DISPLAY_ERROR_ENUM
+#define WL_DISPLAY_ERROR_ENUM
+/**
+ * @ingroup iface_wl_display
+ * global error values
+ *
+ * These errors are global and can be emitted in response to any
+ * server request.
+ */
+enum wl_display_error {
+ /**
+ * server couldn't find object
+ */
+ WL_DISPLAY_ERROR_INVALID_OBJECT = 0,
+ /**
+ * method doesn't exist on the specified interface or malformed request
+ */
+ WL_DISPLAY_ERROR_INVALID_METHOD = 1,
+ /**
+ * server is out of memory
+ */
+ WL_DISPLAY_ERROR_NO_MEMORY = 2,
+ /**
+ * implementation error in compositor
+ */
+ WL_DISPLAY_ERROR_IMPLEMENTATION = 3,
+};
+#endif /* WL_DISPLAY_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_display
+ * @struct wl_display_listener
+ */
+struct wl_display_listener {
+ /**
+ * fatal error event
+ *
+ * The error event is sent out when a fatal (non-recoverable)
+ * error has occurred. The object_id argument is the object where
+ * the error occurred, most often in response to a request to that
+ * object. The code identifies the error and is defined by the
+ * object interface. As such, each interface defines its own set of
+ * error codes. The message is a brief description of the error,
+ * for (debugging) convenience.
+ * @param object_id object where the error occurred
+ * @param code error code
+ * @param message error description
+ */
+ void (*error)(void *data,
+ struct wl_display *wl_display,
+ void *object_id,
+ uint32_t code,
+ const char *message);
+ /**
+ * acknowledge object ID deletion
+ *
+ * This event is used internally by the object ID management
+ * logic. When a client deletes an object that it had created, the
+ * server will send this event to acknowledge that it has seen the
+ * delete request. When the client receives this event, it will
+ * know that it can safely reuse the object ID.
+ * @param id deleted object ID
+ */
+ void (*delete_id)(void *data,
+ struct wl_display *wl_display,
+ uint32_t id);
+};
+
+/**
+ * @ingroup iface_wl_display
+ */
+static inline int
+wl_display_add_listener(struct wl_display *wl_display,
+ const struct wl_display_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_display,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DISPLAY_SYNC 0
+#define WL_DISPLAY_GET_REGISTRY 1
+
+/**
+ * @ingroup iface_wl_display
+ */
+#define WL_DISPLAY_ERROR_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_display
+ */
+#define WL_DISPLAY_DELETE_ID_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_display
+ */
+#define WL_DISPLAY_SYNC_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_display
+ */
+#define WL_DISPLAY_GET_REGISTRY_SINCE_VERSION 1
+
+/** @ingroup iface_wl_display */
+static inline void
+wl_display_set_user_data(struct wl_display *wl_display, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_display, user_data);
+}
+
+/** @ingroup iface_wl_display */
+static inline void *
+wl_display_get_user_data(struct wl_display *wl_display)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_display);
+}
+
+static inline uint32_t
+wl_display_get_version(struct wl_display *wl_display)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_display);
+}
+
+/**
+ * @ingroup iface_wl_display
+ *
+ * The sync request asks the server to emit the 'done' event
+ * on the returned wl_callback object. Since requests are
+ * handled in-order and events are delivered in-order, this can
+ * be used as a barrier to ensure all previous requests and the
+ * resulting events have been handled.
+ *
+ * The object returned by this request will be destroyed by the
+ * compositor after the callback is fired and as such the client must not
+ * attempt to use it after that point.
+ *
+ * The callback_data passed in the callback is the event serial.
+ */
+static inline struct wl_callback *
+wl_display_sync(struct wl_display *wl_display)
+{
+ struct wl_proxy *callback;
+
+ callback = wl_proxy_marshal_flags((struct wl_proxy *) wl_display,
+ WL_DISPLAY_SYNC, &wl_callback_interface, wl_proxy_get_version((struct wl_proxy *) wl_display), 0, NULL);
+
+ return (struct wl_callback *) callback;
+}
+
+/**
+ * @ingroup iface_wl_display
+ *
+ * This request creates a registry object that allows the client
+ * to list and bind the global objects available from the
+ * compositor.
+ *
+ * It should be noted that the server side resources consumed in
+ * response to a get_registry request can only be released when the
+ * client disconnects, not when the client side proxy is destroyed.
+ * Therefore, clients should invoke get_registry as infrequently as
+ * possible to avoid wasting memory.
+ */
+static inline struct wl_registry *
+wl_display_get_registry(struct wl_display *wl_display)
+{
+ struct wl_proxy *registry;
+
+ registry = wl_proxy_marshal_flags((struct wl_proxy *) wl_display,
+ WL_DISPLAY_GET_REGISTRY, &wl_registry_interface, wl_proxy_get_version((struct wl_proxy *) wl_display), 0, NULL);
+
+ return (struct wl_registry *) registry;
+}
+
+/**
+ * @ingroup iface_wl_registry
+ * @struct wl_registry_listener
+ */
+struct wl_registry_listener {
+ /**
+ * announce global object
+ *
+ * Notify the client of global objects.
+ *
+ * The event notifies the client that a global object with the
+ * given name is now available, and it implements the given version
+ * of the given interface.
+ * @param name numeric name of the global object
+ * @param interface interface implemented by the object
+ * @param version interface version
+ */
+ void (*global)(void *data,
+ struct wl_registry *wl_registry,
+ uint32_t name,
+ const char *interface,
+ uint32_t version);
+ /**
+ * announce removal of global object
+ *
+ * Notify the client of removed global objects.
+ *
+ * This event notifies the client that the global identified by
+ * name is no longer available. If the client bound to the global
+ * using the bind request, the client should now destroy that
+ * object.
+ *
+ * The object remains valid and requests to the object will be
+ * ignored until the client destroys it, to avoid races between the
+ * global going away and a client sending a request to it.
+ * @param name numeric name of the global object
+ */
+ void (*global_remove)(void *data,
+ struct wl_registry *wl_registry,
+ uint32_t name);
+};
+
+/**
+ * @ingroup iface_wl_registry
+ */
+static inline int
+wl_registry_add_listener(struct wl_registry *wl_registry,
+ const struct wl_registry_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_registry,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_REGISTRY_BIND 0
+
+/**
+ * @ingroup iface_wl_registry
+ */
+#define WL_REGISTRY_GLOBAL_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_registry
+ */
+#define WL_REGISTRY_GLOBAL_REMOVE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_registry
+ */
+#define WL_REGISTRY_BIND_SINCE_VERSION 1
+
+/** @ingroup iface_wl_registry */
+static inline void
+wl_registry_set_user_data(struct wl_registry *wl_registry, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_registry, user_data);
+}
+
+/** @ingroup iface_wl_registry */
+static inline void *
+wl_registry_get_user_data(struct wl_registry *wl_registry)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_registry);
+}
+
+static inline uint32_t
+wl_registry_get_version(struct wl_registry *wl_registry)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_registry);
+}
+
+/** @ingroup iface_wl_registry */
+static inline void
+wl_registry_destroy(struct wl_registry *wl_registry)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_registry);
+}
+
+/**
+ * @ingroup iface_wl_registry
+ *
+ * Binds a new, client-created object to the server using the
+ * specified name as the identifier.
+ */
+static inline void *
+wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_registry,
+ WL_REGISTRY_BIND, interface, version, 0, name, interface->name, version, NULL);
+
+ return (void *) id;
+}
+
+/**
+ * @ingroup iface_wl_callback
+ * @struct wl_callback_listener
+ */
+struct wl_callback_listener {
+ /**
+ * done event
+ *
+ * Notify the client when the related request is done.
+ * @param callback_data request-specific data for the callback
+ */
+ void (*done)(void *data,
+ struct wl_callback *wl_callback,
+ uint32_t callback_data);
+};
+
+/**
+ * @ingroup iface_wl_callback
+ */
+static inline int
+wl_callback_add_listener(struct wl_callback *wl_callback,
+ const struct wl_callback_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_callback,
+ (void (**)(void)) listener, data);
+}
+
+/**
+ * @ingroup iface_wl_callback
+ */
+#define WL_CALLBACK_DONE_SINCE_VERSION 1
+
+
+/** @ingroup iface_wl_callback */
+static inline void
+wl_callback_set_user_data(struct wl_callback *wl_callback, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_callback, user_data);
+}
+
+/** @ingroup iface_wl_callback */
+static inline void *
+wl_callback_get_user_data(struct wl_callback *wl_callback)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_callback);
+}
+
+static inline uint32_t
+wl_callback_get_version(struct wl_callback *wl_callback)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_callback);
+}
+
+/** @ingroup iface_wl_callback */
+static inline void
+wl_callback_destroy(struct wl_callback *wl_callback)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_callback);
+}
+
+#define WL_COMPOSITOR_CREATE_SURFACE 0
+#define WL_COMPOSITOR_CREATE_REGION 1
+
+
+/**
+ * @ingroup iface_wl_compositor
+ */
+#define WL_COMPOSITOR_CREATE_SURFACE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_compositor
+ */
+#define WL_COMPOSITOR_CREATE_REGION_SINCE_VERSION 1
+
+/** @ingroup iface_wl_compositor */
+static inline void
+wl_compositor_set_user_data(struct wl_compositor *wl_compositor, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_compositor, user_data);
+}
+
+/** @ingroup iface_wl_compositor */
+static inline void *
+wl_compositor_get_user_data(struct wl_compositor *wl_compositor)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_compositor);
+}
+
+static inline uint32_t
+wl_compositor_get_version(struct wl_compositor *wl_compositor)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_compositor);
+}
+
+/** @ingroup iface_wl_compositor */
+static inline void
+wl_compositor_destroy(struct wl_compositor *wl_compositor)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_compositor);
+}
+
+/**
+ * @ingroup iface_wl_compositor
+ *
+ * Ask the compositor to create a new surface.
+ */
+static inline struct wl_surface *
+wl_compositor_create_surface(struct wl_compositor *wl_compositor)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_compositor,
+ WL_COMPOSITOR_CREATE_SURFACE, &wl_surface_interface, wl_proxy_get_version((struct wl_proxy *) wl_compositor), 0, NULL);
+
+ return (struct wl_surface *) id;
+}
+
+/**
+ * @ingroup iface_wl_compositor
+ *
+ * Ask the compositor to create a new region.
+ */
+static inline struct wl_region *
+wl_compositor_create_region(struct wl_compositor *wl_compositor)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_compositor,
+ WL_COMPOSITOR_CREATE_REGION, &wl_region_interface, wl_proxy_get_version((struct wl_proxy *) wl_compositor), 0, NULL);
+
+ return (struct wl_region *) id;
+}
+
+#define WL_SHM_POOL_CREATE_BUFFER 0
+#define WL_SHM_POOL_DESTROY 1
+#define WL_SHM_POOL_RESIZE 2
+
+
+/**
+ * @ingroup iface_wl_shm_pool
+ */
+#define WL_SHM_POOL_CREATE_BUFFER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shm_pool
+ */
+#define WL_SHM_POOL_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shm_pool
+ */
+#define WL_SHM_POOL_RESIZE_SINCE_VERSION 1
+
+/** @ingroup iface_wl_shm_pool */
+static inline void
+wl_shm_pool_set_user_data(struct wl_shm_pool *wl_shm_pool, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_shm_pool, user_data);
+}
+
+/** @ingroup iface_wl_shm_pool */
+static inline void *
+wl_shm_pool_get_user_data(struct wl_shm_pool *wl_shm_pool)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_shm_pool);
+}
+
+static inline uint32_t
+wl_shm_pool_get_version(struct wl_shm_pool *wl_shm_pool)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_shm_pool);
+}
+
+/**
+ * @ingroup iface_wl_shm_pool
+ *
+ * Create a wl_buffer object from the pool.
+ *
+ * The buffer is created offset bytes into the pool and has
+ * width and height as specified. The stride argument specifies
+ * the number of bytes from the beginning of one row to the beginning
+ * of the next. The format is the pixel format of the buffer and
+ * must be one of those advertised through the wl_shm.format event.
+ *
+ * A buffer will keep a reference to the pool it was created from
+ * so it is valid to destroy the pool immediately after creating
+ * a buffer from it.
+ */
+static inline struct wl_buffer *
+wl_shm_pool_create_buffer(struct wl_shm_pool *wl_shm_pool, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_shm_pool,
+ WL_SHM_POOL_CREATE_BUFFER, &wl_buffer_interface, wl_proxy_get_version((struct wl_proxy *) wl_shm_pool), 0, NULL, offset, width, height, stride, format);
+
+ return (struct wl_buffer *) id;
+}
+
+/**
+ * @ingroup iface_wl_shm_pool
+ *
+ * Destroy the shared memory pool.
+ *
+ * The mmapped memory will be released when all
+ * buffers that have been created from this pool
+ * are gone.
+ */
+static inline void
+wl_shm_pool_destroy(struct wl_shm_pool *wl_shm_pool)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shm_pool,
+ WL_SHM_POOL_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shm_pool), WL_MARSHAL_FLAG_DESTROY);
+}
+
+/**
+ * @ingroup iface_wl_shm_pool
+ *
+ * This request will cause the server to remap the backing memory
+ * for the pool from the file descriptor passed when the pool was
+ * created, but using the new size. This request can only be
+ * used to make the pool bigger.
+ *
+ * This request only changes the amount of bytes that are mmapped
+ * by the server and does not touch the file corresponding to the
+ * file descriptor passed at creation time. It is the client's
+ * responsibility to ensure that the file is at least as big as
+ * the new pool size.
+ */
+static inline void
+wl_shm_pool_resize(struct wl_shm_pool *wl_shm_pool, int32_t size)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shm_pool,
+ WL_SHM_POOL_RESIZE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shm_pool), 0, size);
+}
+
+#ifndef WL_SHM_ERROR_ENUM
+#define WL_SHM_ERROR_ENUM
+/**
+ * @ingroup iface_wl_shm
+ * wl_shm error values
+ *
+ * These errors can be emitted in response to wl_shm requests.
+ */
+enum wl_shm_error {
+ /**
+ * buffer format is not known
+ */
+ WL_SHM_ERROR_INVALID_FORMAT = 0,
+ /**
+ * invalid size or stride during pool or buffer creation
+ */
+ WL_SHM_ERROR_INVALID_STRIDE = 1,
+ /**
+ * mmapping the file descriptor failed
+ */
+ WL_SHM_ERROR_INVALID_FD = 2,
+};
+#endif /* WL_SHM_ERROR_ENUM */
+
+#ifndef WL_SHM_FORMAT_ENUM
+#define WL_SHM_FORMAT_ENUM
+/**
+ * @ingroup iface_wl_shm
+ * pixel formats
+ *
+ * This describes the memory layout of an individual pixel.
+ *
+ * All renderers should support argb8888 and xrgb8888 but any other
+ * formats are optional and may not be supported by the particular
+ * renderer in use.
+ *
+ * The drm format codes match the macros defined in drm_fourcc.h, except
+ * argb8888 and xrgb8888. The formats actually supported by the compositor
+ * will be reported by the format event.
+ *
+ * For all wl_shm formats and unless specified in another protocol
+ * extension, pre-multiplied alpha is used for pixel values.
+ */
+enum wl_shm_format {
+ /**
+ * 32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_ARGB8888 = 0,
+ /**
+ * 32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_XRGB8888 = 1,
+ /**
+ * 8-bit color index format, [7:0] C
+ */
+ WL_SHM_FORMAT_C8 = 0x20203843,
+ /**
+ * 8-bit RGB format, [7:0] R:G:B 3:3:2
+ */
+ WL_SHM_FORMAT_RGB332 = 0x38424752,
+ /**
+ * 8-bit BGR format, [7:0] B:G:R 2:3:3
+ */
+ WL_SHM_FORMAT_BGR233 = 0x38524742,
+ /**
+ * 16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_XRGB4444 = 0x32315258,
+ /**
+ * 16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_XBGR4444 = 0x32314258,
+ /**
+ * 16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_RGBX4444 = 0x32315852,
+ /**
+ * 16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_BGRX4444 = 0x32315842,
+ /**
+ * 16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_ARGB4444 = 0x32315241,
+ /**
+ * 16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_ABGR4444 = 0x32314241,
+ /**
+ * 16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_RGBA4444 = 0x32314152,
+ /**
+ * 16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian
+ */
+ WL_SHM_FORMAT_BGRA4444 = 0x32314142,
+ /**
+ * 16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian
+ */
+ WL_SHM_FORMAT_XRGB1555 = 0x35315258,
+ /**
+ * 16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian
+ */
+ WL_SHM_FORMAT_XBGR1555 = 0x35314258,
+ /**
+ * 16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian
+ */
+ WL_SHM_FORMAT_RGBX5551 = 0x35315852,
+ /**
+ * 16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian
+ */
+ WL_SHM_FORMAT_BGRX5551 = 0x35315842,
+ /**
+ * 16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian
+ */
+ WL_SHM_FORMAT_ARGB1555 = 0x35315241,
+ /**
+ * 16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian
+ */
+ WL_SHM_FORMAT_ABGR1555 = 0x35314241,
+ /**
+ * 16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian
+ */
+ WL_SHM_FORMAT_RGBA5551 = 0x35314152,
+ /**
+ * 16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian
+ */
+ WL_SHM_FORMAT_BGRA5551 = 0x35314142,
+ /**
+ * 16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian
+ */
+ WL_SHM_FORMAT_RGB565 = 0x36314752,
+ /**
+ * 16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian
+ */
+ WL_SHM_FORMAT_BGR565 = 0x36314742,
+ /**
+ * 24-bit RGB format, [23:0] R:G:B little endian
+ */
+ WL_SHM_FORMAT_RGB888 = 0x34324752,
+ /**
+ * 24-bit BGR format, [23:0] B:G:R little endian
+ */
+ WL_SHM_FORMAT_BGR888 = 0x34324742,
+ /**
+ * 32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_XBGR8888 = 0x34324258,
+ /**
+ * 32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_RGBX8888 = 0x34325852,
+ /**
+ * 32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_BGRX8888 = 0x34325842,
+ /**
+ * 32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_ABGR8888 = 0x34324241,
+ /**
+ * 32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_RGBA8888 = 0x34324152,
+ /**
+ * 32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_BGRA8888 = 0x34324142,
+ /**
+ * 32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_XRGB2101010 = 0x30335258,
+ /**
+ * 32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_XBGR2101010 = 0x30334258,
+ /**
+ * 32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian
+ */
+ WL_SHM_FORMAT_RGBX1010102 = 0x30335852,
+ /**
+ * 32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian
+ */
+ WL_SHM_FORMAT_BGRX1010102 = 0x30335842,
+ /**
+ * 32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_ARGB2101010 = 0x30335241,
+ /**
+ * 32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_ABGR2101010 = 0x30334241,
+ /**
+ * 32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian
+ */
+ WL_SHM_FORMAT_RGBA1010102 = 0x30334152,
+ /**
+ * 32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian
+ */
+ WL_SHM_FORMAT_BGRA1010102 = 0x30334142,
+ /**
+ * packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_YUYV = 0x56595559,
+ /**
+ * packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_YVYU = 0x55595659,
+ /**
+ * packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_UYVY = 0x59565955,
+ /**
+ * packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_VYUY = 0x59555956,
+ /**
+ * packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_AYUV = 0x56555941,
+ /**
+ * 2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane
+ */
+ WL_SHM_FORMAT_NV12 = 0x3231564e,
+ /**
+ * 2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane
+ */
+ WL_SHM_FORMAT_NV21 = 0x3132564e,
+ /**
+ * 2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane
+ */
+ WL_SHM_FORMAT_NV16 = 0x3631564e,
+ /**
+ * 2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane
+ */
+ WL_SHM_FORMAT_NV61 = 0x3136564e,
+ /**
+ * 3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes
+ */
+ WL_SHM_FORMAT_YUV410 = 0x39565559,
+ /**
+ * 3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes
+ */
+ WL_SHM_FORMAT_YVU410 = 0x39555659,
+ /**
+ * 3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes
+ */
+ WL_SHM_FORMAT_YUV411 = 0x31315559,
+ /**
+ * 3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes
+ */
+ WL_SHM_FORMAT_YVU411 = 0x31315659,
+ /**
+ * 3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes
+ */
+ WL_SHM_FORMAT_YUV420 = 0x32315559,
+ /**
+ * 3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes
+ */
+ WL_SHM_FORMAT_YVU420 = 0x32315659,
+ /**
+ * 3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes
+ */
+ WL_SHM_FORMAT_YUV422 = 0x36315559,
+ /**
+ * 3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes
+ */
+ WL_SHM_FORMAT_YVU422 = 0x36315659,
+ /**
+ * 3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes
+ */
+ WL_SHM_FORMAT_YUV444 = 0x34325559,
+ /**
+ * 3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes
+ */
+ WL_SHM_FORMAT_YVU444 = 0x34325659,
+ /**
+ * [7:0] R
+ */
+ WL_SHM_FORMAT_R8 = 0x20203852,
+ /**
+ * [15:0] R little endian
+ */
+ WL_SHM_FORMAT_R16 = 0x20363152,
+ /**
+ * [15:0] R:G 8:8 little endian
+ */
+ WL_SHM_FORMAT_RG88 = 0x38384752,
+ /**
+ * [15:0] G:R 8:8 little endian
+ */
+ WL_SHM_FORMAT_GR88 = 0x38385247,
+ /**
+ * [31:0] R:G 16:16 little endian
+ */
+ WL_SHM_FORMAT_RG1616 = 0x32334752,
+ /**
+ * [31:0] G:R 16:16 little endian
+ */
+ WL_SHM_FORMAT_GR1616 = 0x32335247,
+ /**
+ * [63:0] x:R:G:B 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_XRGB16161616F = 0x48345258,
+ /**
+ * [63:0] x:B:G:R 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_XBGR16161616F = 0x48344258,
+ /**
+ * [63:0] A:R:G:B 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_ARGB16161616F = 0x48345241,
+ /**
+ * [63:0] A:B:G:R 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_ABGR16161616F = 0x48344241,
+ /**
+ * [31:0] X:Y:Cb:Cr 8:8:8:8 little endian
+ */
+ WL_SHM_FORMAT_XYUV8888 = 0x56555958,
+ /**
+ * [23:0] Cr:Cb:Y 8:8:8 little endian
+ */
+ WL_SHM_FORMAT_VUY888 = 0x34325556,
+ /**
+ * Y followed by U then V, 10:10:10. Non-linear modifier only
+ */
+ WL_SHM_FORMAT_VUY101010 = 0x30335556,
+ /**
+ * [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels
+ */
+ WL_SHM_FORMAT_Y210 = 0x30313259,
+ /**
+ * [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels
+ */
+ WL_SHM_FORMAT_Y212 = 0x32313259,
+ /**
+ * [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels
+ */
+ WL_SHM_FORMAT_Y216 = 0x36313259,
+ /**
+ * [31:0] A:Cr:Y:Cb 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_Y410 = 0x30313459,
+ /**
+ * [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian
+ */
+ WL_SHM_FORMAT_Y412 = 0x32313459,
+ /**
+ * [63:0] A:Cr:Y:Cb 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_Y416 = 0x36313459,
+ /**
+ * [31:0] X:Cr:Y:Cb 2:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_XVYU2101010 = 0x30335658,
+ /**
+ * [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian
+ */
+ WL_SHM_FORMAT_XVYU12_16161616 = 0x36335658,
+ /**
+ * [63:0] X:Cr:Y:Cb 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_XVYU16161616 = 0x38345658,
+ /**
+ * [63:0] A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian
+ */
+ WL_SHM_FORMAT_Y0L0 = 0x304c3059,
+ /**
+ * [63:0] X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian
+ */
+ WL_SHM_FORMAT_X0L0 = 0x304c3058,
+ /**
+ * [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_Y0L2 = 0x324c3059,
+ /**
+ * [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian
+ */
+ WL_SHM_FORMAT_X0L2 = 0x324c3058,
+ WL_SHM_FORMAT_YUV420_8BIT = 0x38305559,
+ WL_SHM_FORMAT_YUV420_10BIT = 0x30315559,
+ WL_SHM_FORMAT_XRGB8888_A8 = 0x38415258,
+ WL_SHM_FORMAT_XBGR8888_A8 = 0x38414258,
+ WL_SHM_FORMAT_RGBX8888_A8 = 0x38415852,
+ WL_SHM_FORMAT_BGRX8888_A8 = 0x38415842,
+ WL_SHM_FORMAT_RGB888_A8 = 0x38413852,
+ WL_SHM_FORMAT_BGR888_A8 = 0x38413842,
+ WL_SHM_FORMAT_RGB565_A8 = 0x38413552,
+ WL_SHM_FORMAT_BGR565_A8 = 0x38413542,
+ /**
+ * non-subsampled Cr:Cb plane
+ */
+ WL_SHM_FORMAT_NV24 = 0x3432564e,
+ /**
+ * non-subsampled Cb:Cr plane
+ */
+ WL_SHM_FORMAT_NV42 = 0x3234564e,
+ /**
+ * 2x1 subsampled Cr:Cb plane, 10 bit per channel
+ */
+ WL_SHM_FORMAT_P210 = 0x30313250,
+ /**
+ * 2x2 subsampled Cr:Cb plane 10 bits per channel
+ */
+ WL_SHM_FORMAT_P010 = 0x30313050,
+ /**
+ * 2x2 subsampled Cr:Cb plane 12 bits per channel
+ */
+ WL_SHM_FORMAT_P012 = 0x32313050,
+ /**
+ * 2x2 subsampled Cr:Cb plane 16 bits per channel
+ */
+ WL_SHM_FORMAT_P016 = 0x36313050,
+ /**
+ * [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian
+ */
+ WL_SHM_FORMAT_AXBXGXRX106106106106 = 0x30314241,
+ /**
+ * 2x2 subsampled Cr:Cb plane
+ */
+ WL_SHM_FORMAT_NV15 = 0x3531564e,
+ WL_SHM_FORMAT_Q410 = 0x30313451,
+ WL_SHM_FORMAT_Q401 = 0x31303451,
+ /**
+ * [63:0] x:R:G:B 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_XRGB16161616 = 0x38345258,
+ /**
+ * [63:0] x:B:G:R 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_XBGR16161616 = 0x38344258,
+ /**
+ * [63:0] A:R:G:B 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_ARGB16161616 = 0x38345241,
+ /**
+ * [63:0] A:B:G:R 16:16:16:16 little endian
+ */
+ WL_SHM_FORMAT_ABGR16161616 = 0x38344241,
+};
+#endif /* WL_SHM_FORMAT_ENUM */
+
+/**
+ * @ingroup iface_wl_shm
+ * @struct wl_shm_listener
+ */
+struct wl_shm_listener {
+ /**
+ * pixel format description
+ *
+ * Informs the client about a valid pixel format that can be used
+ * for buffers. Known formats include argb8888 and xrgb8888.
+ * @param format buffer pixel format
+ */
+ void (*format)(void *data,
+ struct wl_shm *wl_shm,
+ uint32_t format);
+};
+
+/**
+ * @ingroup iface_wl_shm
+ */
+static inline int
+wl_shm_add_listener(struct wl_shm *wl_shm,
+ const struct wl_shm_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_shm,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_SHM_CREATE_POOL 0
+
+/**
+ * @ingroup iface_wl_shm
+ */
+#define WL_SHM_FORMAT_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_shm
+ */
+#define WL_SHM_CREATE_POOL_SINCE_VERSION 1
+
+/** @ingroup iface_wl_shm */
+static inline void
+wl_shm_set_user_data(struct wl_shm *wl_shm, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_shm, user_data);
+}
+
+/** @ingroup iface_wl_shm */
+static inline void *
+wl_shm_get_user_data(struct wl_shm *wl_shm)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_shm);
+}
+
+static inline uint32_t
+wl_shm_get_version(struct wl_shm *wl_shm)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_shm);
+}
+
+/** @ingroup iface_wl_shm */
+static inline void
+wl_shm_destroy(struct wl_shm *wl_shm)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_shm);
+}
+
+/**
+ * @ingroup iface_wl_shm
+ *
+ * Create a new wl_shm_pool object.
+ *
+ * The pool can be used to create shared memory based buffer
+ * objects. The server will mmap size bytes of the passed file
+ * descriptor, to use as backing memory for the pool.
+ */
+static inline struct wl_shm_pool *
+wl_shm_create_pool(struct wl_shm *wl_shm, int32_t fd, int32_t size)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_shm,
+ WL_SHM_CREATE_POOL, &wl_shm_pool_interface, wl_proxy_get_version((struct wl_proxy *) wl_shm), 0, NULL, fd, size);
+
+ return (struct wl_shm_pool *) id;
+}
+
+/**
+ * @ingroup iface_wl_buffer
+ * @struct wl_buffer_listener
+ */
+struct wl_buffer_listener {
+ /**
+ * compositor releases buffer
+ *
+ * Sent when this wl_buffer is no longer used by the compositor.
+ * The client is now free to reuse or destroy this buffer and its
+ * backing storage.
+ *
+ * If a client receives a release event before the frame callback
+ * requested in the same wl_surface.commit that attaches this
+ * wl_buffer to a surface, then the client is immediately free to
+ * reuse the buffer and its backing storage, and does not need a
+ * second buffer for the next surface content update. Typically
+ * this is possible, when the compositor maintains a copy of the
+ * wl_surface contents, e.g. as a GL texture. This is an important
+ * optimization for GL(ES) compositors with wl_shm clients.
+ */
+ void (*release)(void *data,
+ struct wl_buffer *wl_buffer);
+};
+
+/**
+ * @ingroup iface_wl_buffer
+ */
+static inline int
+wl_buffer_add_listener(struct wl_buffer *wl_buffer,
+ const struct wl_buffer_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_buffer,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_BUFFER_DESTROY 0
+
+/**
+ * @ingroup iface_wl_buffer
+ */
+#define WL_BUFFER_RELEASE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_buffer
+ */
+#define WL_BUFFER_DESTROY_SINCE_VERSION 1
+
+/** @ingroup iface_wl_buffer */
+static inline void
+wl_buffer_set_user_data(struct wl_buffer *wl_buffer, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_buffer, user_data);
+}
+
+/** @ingroup iface_wl_buffer */
+static inline void *
+wl_buffer_get_user_data(struct wl_buffer *wl_buffer)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_buffer);
+}
+
+static inline uint32_t
+wl_buffer_get_version(struct wl_buffer *wl_buffer)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_buffer);
+}
+
+/**
+ * @ingroup iface_wl_buffer
+ *
+ * Destroy a buffer. If and how you need to release the backing
+ * storage is defined by the buffer factory interface.
+ *
+ * For possible side-effects to a surface, see wl_surface.attach.
+ */
+static inline void
+wl_buffer_destroy(struct wl_buffer *wl_buffer)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_buffer,
+ WL_BUFFER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wl_buffer), WL_MARSHAL_FLAG_DESTROY);
+}
+
+#ifndef WL_DATA_OFFER_ERROR_ENUM
+#define WL_DATA_OFFER_ERROR_ENUM
+enum wl_data_offer_error {
+ /**
+ * finish request was called untimely
+ */
+ WL_DATA_OFFER_ERROR_INVALID_FINISH = 0,
+ /**
+ * action mask contains invalid values
+ */
+ WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK = 1,
+ /**
+ * action argument has an invalid value
+ */
+ WL_DATA_OFFER_ERROR_INVALID_ACTION = 2,
+ /**
+ * offer doesn't accept this request
+ */
+ WL_DATA_OFFER_ERROR_INVALID_OFFER = 3,
+};
+#endif /* WL_DATA_OFFER_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_data_offer
+ * @struct wl_data_offer_listener
+ */
+struct wl_data_offer_listener {
+ /**
+ * advertise offered mime type
+ *
+ * Sent immediately after creating the wl_data_offer object. One
+ * event per offered mime type.
+ * @param mime_type offered mime type
+ */
+ void (*offer)(void *data,
+ struct wl_data_offer *wl_data_offer,
+ const char *mime_type);
+ /**
+ * notify the source-side available actions
+ *
+ * This event indicates the actions offered by the data source.
+ * It will be sent right after wl_data_device.enter, or anytime the
+ * source side changes its offered actions through
+ * wl_data_source.set_actions.
+ * @param source_actions actions offered by the data source
+ * @since 3
+ */
+ void (*source_actions)(void *data,
+ struct wl_data_offer *wl_data_offer,
+ uint32_t source_actions);
+ /**
+ * notify the selected action
+ *
+ * This event indicates the action selected by the compositor
+ * after matching the source/destination side actions. Only one
+ * action (or none) will be offered here.
+ *
+ * This event can be emitted multiple times during the
+ * drag-and-drop operation in response to destination side action
+ * changes through wl_data_offer.set_actions.
+ *
+ * This event will no longer be emitted after wl_data_device.drop
+ * happened on the drag-and-drop destination, the client must honor
+ * the last action received, or the last preferred one set through
+ * wl_data_offer.set_actions when handling an "ask" action.
+ *
+ * Compositors may also change the selected action on the fly,
+ * mainly in response to keyboard modifier changes during the
+ * drag-and-drop operation.
+ *
+ * The most recent action received is always the valid one. Prior
+ * to receiving wl_data_device.drop, the chosen action may change
+ * (e.g. due to keyboard modifiers being pressed). At the time of
+ * receiving wl_data_device.drop the drag-and-drop destination must
+ * honor the last action received.
+ *
+ * Action changes may still happen after wl_data_device.drop,
+ * especially on "ask" actions, where the drag-and-drop destination
+ * may choose another action afterwards. Action changes happening
+ * at this stage are always the result of inter-client negotiation,
+ * the compositor shall no longer be able to induce a different
+ * action.
+ *
+ * Upon "ask" actions, it is expected that the drag-and-drop
+ * destination may potentially choose a different action and/or
+ * mime type, based on wl_data_offer.source_actions and finally
+ * chosen by the user (e.g. popping up a menu with the available
+ * options). The final wl_data_offer.set_actions and
+ * wl_data_offer.accept requests must happen before the call to
+ * wl_data_offer.finish.
+ * @param dnd_action action selected by the compositor
+ * @since 3
+ */
+ void (*action)(void *data,
+ struct wl_data_offer *wl_data_offer,
+ uint32_t dnd_action);
+};
+
+/**
+ * @ingroup iface_wl_data_offer
+ */
+static inline int
+wl_data_offer_add_listener(struct wl_data_offer *wl_data_offer,
+ const struct wl_data_offer_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_data_offer,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DATA_OFFER_ACCEPT 0
+#define WL_DATA_OFFER_RECEIVE 1
+#define WL_DATA_OFFER_DESTROY 2
+#define WL_DATA_OFFER_FINISH 3
+#define WL_DATA_OFFER_SET_ACTIONS 4
+
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_OFFER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION 3
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_ACTION_SINCE_VERSION 3
+
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_ACCEPT_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_RECEIVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_FINISH_SINCE_VERSION 3
+/**
+ * @ingroup iface_wl_data_offer
+ */
+#define WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION 3
+
+/** @ingroup iface_wl_data_offer */
+static inline void
+wl_data_offer_set_user_data(struct wl_data_offer *wl_data_offer, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_data_offer, user_data);
+}
+
+/** @ingroup iface_wl_data_offer */
+static inline void *
+wl_data_offer_get_user_data(struct wl_data_offer *wl_data_offer)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_data_offer);
+}
+
+static inline uint32_t
+wl_data_offer_get_version(struct wl_data_offer *wl_data_offer)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_data_offer);
+}
+
+/**
+ * @ingroup iface_wl_data_offer
+ *
+ * Indicate that the client can accept the given mime type, or
+ * NULL for not accepted.
+ *
+ * For objects of version 2 or older, this request is used by the
+ * client to give feedback whether the client can receive the given
+ * mime type, or NULL if none is accepted; the feedback does not
+ * determine whether the drag-and-drop operation succeeds or not.
+ *
+ * For objects of version 3 or newer, this request determines the
+ * final result of the drag-and-drop operation. If the end result
+ * is that no mime types were accepted, the drag-and-drop operation
+ * will be cancelled and the corresponding drag source will receive
+ * wl_data_source.cancelled. Clients may still use this event in
+ * conjunction with wl_data_source.action for feedback.
+ */
+static inline void
+wl_data_offer_accept(struct wl_data_offer *wl_data_offer, uint32_t serial, const char *mime_type)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_offer,
+ WL_DATA_OFFER_ACCEPT, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_offer), 0, serial, mime_type);
+}
+
+/**
+ * @ingroup iface_wl_data_offer
+ *
+ * To transfer the offered data, the client issues this request
+ * and indicates the mime type it wants to receive. The transfer
+ * happens through the passed file descriptor (typically created
+ * with the pipe system call). The source client writes the data
+ * in the mime type representation requested and then closes the
+ * file descriptor.
+ *
+ * The receiving client reads from the read end of the pipe until
+ * EOF and then closes its end, at which point the transfer is
+ * complete.
+ *
+ * This request may happen multiple times for different mime types,
+ * both before and after wl_data_device.drop. Drag-and-drop destination
+ * clients may preemptively fetch data or examine it more closely to
+ * determine acceptance.
+ */
+static inline void
+wl_data_offer_receive(struct wl_data_offer *wl_data_offer, const char *mime_type, int32_t fd)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_offer,
+ WL_DATA_OFFER_RECEIVE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_offer), 0, mime_type, fd);
+}
+
+/**
+ * @ingroup iface_wl_data_offer
+ *
+ * Destroy the data offer.
+ */
+static inline void
+wl_data_offer_destroy(struct wl_data_offer *wl_data_offer)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_offer,
+ WL_DATA_OFFER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_offer), WL_MARSHAL_FLAG_DESTROY);
+}
+
+/**
+ * @ingroup iface_wl_data_offer
+ *
+ * Notifies the compositor that the drag destination successfully
+ * finished the drag-and-drop operation.
+ *
+ * Upon receiving this request, the compositor will emit
+ * wl_data_source.dnd_finished on the drag source client.
+ *
+ * It is a client error to perform other requests than
+ * wl_data_offer.destroy after this one. It is also an error to perform
+ * this request after a NULL mime type has been set in
+ * wl_data_offer.accept or no action was received through
+ * wl_data_offer.action.
+ *
+ * If wl_data_offer.finish request is received for a non drag and drop
+ * operation, the invalid_finish protocol error is raised.
+ */
+static inline void
+wl_data_offer_finish(struct wl_data_offer *wl_data_offer)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_offer,
+ WL_DATA_OFFER_FINISH, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_offer), 0);
+}
+
+/**
+ * @ingroup iface_wl_data_offer
+ *
+ * Sets the actions that the destination side client supports for
+ * this operation. This request may trigger the emission of
+ * wl_data_source.action and wl_data_offer.action events if the compositor
+ * needs to change the selected action.
+ *
+ * This request can be called multiple times throughout the
+ * drag-and-drop operation, typically in response to wl_data_device.enter
+ * or wl_data_device.motion events.
+ *
+ * This request determines the final result of the drag-and-drop
+ * operation. If the end result is that no action is accepted,
+ * the drag source will receive wl_data_source.cancelled.
+ *
+ * The dnd_actions argument must contain only values expressed in the
+ * wl_data_device_manager.dnd_actions enum, and the preferred_action
+ * argument must only contain one of those values set, otherwise it
+ * will result in a protocol error.
+ *
+ * While managing an "ask" action, the destination drag-and-drop client
+ * may perform further wl_data_offer.receive requests, and is expected
+ * to perform one last wl_data_offer.set_actions request with a preferred
+ * action other than "ask" (and optionally wl_data_offer.accept) before
+ * requesting wl_data_offer.finish, in order to convey the action selected
+ * by the user. If the preferred action is not in the
+ * wl_data_offer.source_actions mask, an error will be raised.
+ *
+ * If the "ask" action is dismissed (e.g. user cancellation), the client
+ * is expected to perform wl_data_offer.destroy right away.
+ *
+ * This request can only be made on drag-and-drop offers, a protocol error
+ * will be raised otherwise.
+ */
+static inline void
+wl_data_offer_set_actions(struct wl_data_offer *wl_data_offer, uint32_t dnd_actions, uint32_t preferred_action)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_offer,
+ WL_DATA_OFFER_SET_ACTIONS, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_offer), 0, dnd_actions, preferred_action);
+}
+
+#ifndef WL_DATA_SOURCE_ERROR_ENUM
+#define WL_DATA_SOURCE_ERROR_ENUM
+enum wl_data_source_error {
+ /**
+ * action mask contains invalid values
+ */
+ WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK = 0,
+ /**
+ * source doesn't accept this request
+ */
+ WL_DATA_SOURCE_ERROR_INVALID_SOURCE = 1,
+};
+#endif /* WL_DATA_SOURCE_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_data_source
+ * @struct wl_data_source_listener
+ */
+struct wl_data_source_listener {
+ /**
+ * a target accepts an offered mime type
+ *
+ * Sent when a target accepts pointer_focus or motion events. If
+ * a target does not accept any of the offered types, type is NULL.
+ *
+ * Used for feedback during drag-and-drop.
+ * @param mime_type mime type accepted by the target
+ */
+ void (*target)(void *data,
+ struct wl_data_source *wl_data_source,
+ const char *mime_type);
+ /**
+ * send the data
+ *
+ * Request for data from the client. Send the data as the
+ * specified mime type over the passed file descriptor, then close
+ * it.
+ * @param mime_type mime type for the data
+ * @param fd file descriptor for the data
+ */
+ void (*send)(void *data,
+ struct wl_data_source *wl_data_source,
+ const char *mime_type,
+ int32_t fd);
+ /**
+ * selection was cancelled
+ *
+ * This data source is no longer valid. There are several reasons
+ * why this could happen:
+ *
+ * - The data source has been replaced by another data source. -
+ * The drag-and-drop operation was performed, but the drop
+ * destination did not accept any of the mime types offered through
+ * wl_data_source.target. - The drag-and-drop operation was
+ * performed, but the drop destination did not select any of the
+ * actions present in the mask offered through
+ * wl_data_source.action. - The drag-and-drop operation was
+ * performed but didn't happen over a surface. - The compositor
+ * cancelled the drag-and-drop operation (e.g. compositor dependent
+ * timeouts to avoid stale drag-and-drop transfers).
+ *
+ * The client should clean up and destroy this data source.
+ *
+ * For objects of version 2 or older, wl_data_source.cancelled will
+ * only be emitted if the data source was replaced by another data
+ * source.
+ */
+ void (*cancelled)(void *data,
+ struct wl_data_source *wl_data_source);
+ /**
+ * the drag-and-drop operation physically finished
+ *
+ * The user performed the drop action. This event does not
+ * indicate acceptance, wl_data_source.cancelled may still be
+ * emitted afterwards if the drop destination does not accept any
+ * mime type.
+ *
+ * However, this event might however not be received if the
+ * compositor cancelled the drag-and-drop operation before this
+ * event could happen.
+ *
+ * Note that the data_source may still be used in the future and
+ * should not be destroyed here.
+ * @since 3
+ */
+ void (*dnd_drop_performed)(void *data,
+ struct wl_data_source *wl_data_source);
+ /**
+ * the drag-and-drop operation concluded
+ *
+ * The drop destination finished interoperating with this data
+ * source, so the client is now free to destroy this data source
+ * and free all associated data.
+ *
+ * If the action used to perform the operation was "move", the
+ * source can now delete the transferred data.
+ * @since 3
+ */
+ void (*dnd_finished)(void *data,
+ struct wl_data_source *wl_data_source);
+ /**
+ * notify the selected action
+ *
+ * This event indicates the action selected by the compositor
+ * after matching the source/destination side actions. Only one
+ * action (or none) will be offered here.
+ *
+ * This event can be emitted multiple times during the
+ * drag-and-drop operation, mainly in response to destination side
+ * changes through wl_data_offer.set_actions, and as the data
+ * device enters/leaves surfaces.
+ *
+ * It is only possible to receive this event after
+ * wl_data_source.dnd_drop_performed if the drag-and-drop operation
+ * ended in an "ask" action, in which case the final
+ * wl_data_source.action event will happen immediately before
+ * wl_data_source.dnd_finished.
+ *
+ * Compositors may also change the selected action on the fly,
+ * mainly in response to keyboard modifier changes during the
+ * drag-and-drop operation.
+ *
+ * The most recent action received is always the valid one. The
+ * chosen action may change alongside negotiation (e.g. an "ask"
+ * action can turn into a "move" operation), so the effects of the
+ * final action must always be applied in
+ * wl_data_offer.dnd_finished.
+ *
+ * Clients can trigger cursor surface changes from this point, so
+ * they reflect the current action.
+ * @param dnd_action action selected by the compositor
+ * @since 3
+ */
+ void (*action)(void *data,
+ struct wl_data_source *wl_data_source,
+ uint32_t dnd_action);
+};
+
+/**
+ * @ingroup iface_wl_data_source
+ */
+static inline int
+wl_data_source_add_listener(struct wl_data_source *wl_data_source,
+ const struct wl_data_source_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_data_source,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DATA_SOURCE_OFFER 0
+#define WL_DATA_SOURCE_DESTROY 1
+#define WL_DATA_SOURCE_SET_ACTIONS 2
+
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_TARGET_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_SEND_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_CANCELLED_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION 3
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION 3
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_ACTION_SINCE_VERSION 3
+
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_OFFER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_source
+ */
+#define WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION 3
+
+/** @ingroup iface_wl_data_source */
+static inline void
+wl_data_source_set_user_data(struct wl_data_source *wl_data_source, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_data_source, user_data);
+}
+
+/** @ingroup iface_wl_data_source */
+static inline void *
+wl_data_source_get_user_data(struct wl_data_source *wl_data_source)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_data_source);
+}
+
+static inline uint32_t
+wl_data_source_get_version(struct wl_data_source *wl_data_source)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_data_source);
+}
+
+/**
+ * @ingroup iface_wl_data_source
+ *
+ * This request adds a mime type to the set of mime types
+ * advertised to targets. Can be called several times to offer
+ * multiple types.
+ */
+static inline void
+wl_data_source_offer(struct wl_data_source *wl_data_source, const char *mime_type)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_source,
+ WL_DATA_SOURCE_OFFER, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_source), 0, mime_type);
+}
+
+/**
+ * @ingroup iface_wl_data_source
+ *
+ * Destroy the data source.
+ */
+static inline void
+wl_data_source_destroy(struct wl_data_source *wl_data_source)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_source,
+ WL_DATA_SOURCE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_source), WL_MARSHAL_FLAG_DESTROY);
+}
+
+/**
+ * @ingroup iface_wl_data_source
+ *
+ * Sets the actions that the source side client supports for this
+ * operation. This request may trigger wl_data_source.action and
+ * wl_data_offer.action events if the compositor needs to change the
+ * selected action.
+ *
+ * The dnd_actions argument must contain only values expressed in the
+ * wl_data_device_manager.dnd_actions enum, otherwise it will result
+ * in a protocol error.
+ *
+ * This request must be made once only, and can only be made on sources
+ * used in drag-and-drop, so it must be performed before
+ * wl_data_device.start_drag. Attempting to use the source other than
+ * for drag-and-drop will raise a protocol error.
+ */
+static inline void
+wl_data_source_set_actions(struct wl_data_source *wl_data_source, uint32_t dnd_actions)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_source,
+ WL_DATA_SOURCE_SET_ACTIONS, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_source), 0, dnd_actions);
+}
+
+#ifndef WL_DATA_DEVICE_ERROR_ENUM
+#define WL_DATA_DEVICE_ERROR_ENUM
+enum wl_data_device_error {
+ /**
+ * given wl_surface has another role
+ */
+ WL_DATA_DEVICE_ERROR_ROLE = 0,
+};
+#endif /* WL_DATA_DEVICE_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_data_device
+ * @struct wl_data_device_listener
+ */
+struct wl_data_device_listener {
+ /**
+ * introduce a new wl_data_offer
+ *
+ * The data_offer event introduces a new wl_data_offer object,
+ * which will subsequently be used in either the data_device.enter
+ * event (for drag-and-drop) or the data_device.selection event
+ * (for selections). Immediately following the
+ * data_device.data_offer event, the new data_offer object will
+ * send out data_offer.offer events to describe the mime types it
+ * offers.
+ * @param id the new data_offer object
+ */
+ void (*data_offer)(void *data,
+ struct wl_data_device *wl_data_device,
+ struct wl_data_offer *id);
+ /**
+ * initiate drag-and-drop session
+ *
+ * This event is sent when an active drag-and-drop pointer enters
+ * a surface owned by the client. The position of the pointer at
+ * enter time is provided by the x and y arguments, in
+ * surface-local coordinates.
+ * @param serial serial number of the enter event
+ * @param surface client surface entered
+ * @param x surface-local x coordinate
+ * @param y surface-local y coordinate
+ * @param id source data_offer object
+ */
+ void (*enter)(void *data,
+ struct wl_data_device *wl_data_device,
+ uint32_t serial,
+ struct wl_surface *surface,
+ wl_fixed_t x,
+ wl_fixed_t y,
+ struct wl_data_offer *id);
+ /**
+ * end drag-and-drop session
+ *
+ * This event is sent when the drag-and-drop pointer leaves the
+ * surface and the session ends. The client must destroy the
+ * wl_data_offer introduced at enter time at this point.
+ */
+ void (*leave)(void *data,
+ struct wl_data_device *wl_data_device);
+ /**
+ * drag-and-drop session motion
+ *
+ * This event is sent when the drag-and-drop pointer moves within
+ * the currently focused surface. The new position of the pointer
+ * is provided by the x and y arguments, in surface-local
+ * coordinates.
+ * @param time timestamp with millisecond granularity
+ * @param x surface-local x coordinate
+ * @param y surface-local y coordinate
+ */
+ void (*motion)(void *data,
+ struct wl_data_device *wl_data_device,
+ uint32_t time,
+ wl_fixed_t x,
+ wl_fixed_t y);
+ /**
+ * end drag-and-drop session successfully
+ *
+ * The event is sent when a drag-and-drop operation is ended
+ * because the implicit grab is removed.
+ *
+ * The drag-and-drop destination is expected to honor the last
+ * action received through wl_data_offer.action, if the resulting
+ * action is "copy" or "move", the destination can still perform
+ * wl_data_offer.receive requests, and is expected to end all
+ * transfers with a wl_data_offer.finish request.
+ *
+ * If the resulting action is "ask", the action will not be
+ * considered final. The drag-and-drop destination is expected to
+ * perform one last wl_data_offer.set_actions request, or
+ * wl_data_offer.destroy in order to cancel the operation.
+ */
+ void (*drop)(void *data,
+ struct wl_data_device *wl_data_device);
+ /**
+ * advertise new selection
+ *
+ * The selection event is sent out to notify the client of a new
+ * wl_data_offer for the selection for this device. The
+ * data_device.data_offer and the data_offer.offer events are sent
+ * out immediately before this event to introduce the data offer
+ * object. The selection event is sent to a client immediately
+ * before receiving keyboard focus and when a new selection is set
+ * while the client has keyboard focus. The data_offer is valid
+ * until a new data_offer or NULL is received or until the client
+ * loses keyboard focus. Switching surface with keyboard focus
+ * within the same client doesn't mean a new selection will be
+ * sent. The client must destroy the previous selection data_offer,
+ * if any, upon receiving this event.
+ * @param id selection data_offer object
+ */
+ void (*selection)(void *data,
+ struct wl_data_device *wl_data_device,
+ struct wl_data_offer *id);
+};
+
+/**
+ * @ingroup iface_wl_data_device
+ */
+static inline int
+wl_data_device_add_listener(struct wl_data_device *wl_data_device,
+ const struct wl_data_device_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_data_device,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DATA_DEVICE_START_DRAG 0
+#define WL_DATA_DEVICE_SET_SELECTION 1
+#define WL_DATA_DEVICE_RELEASE 2
+
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_DATA_OFFER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_ENTER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_LEAVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_MOTION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_DROP_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_SELECTION_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_START_DRAG_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_SET_SELECTION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device
+ */
+#define WL_DATA_DEVICE_RELEASE_SINCE_VERSION 2
+
+/** @ingroup iface_wl_data_device */
+static inline void
+wl_data_device_set_user_data(struct wl_data_device *wl_data_device, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_data_device, user_data);
+}
+
+/** @ingroup iface_wl_data_device */
+static inline void *
+wl_data_device_get_user_data(struct wl_data_device *wl_data_device)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_data_device);
+}
+
+static inline uint32_t
+wl_data_device_get_version(struct wl_data_device *wl_data_device)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_data_device);
+}
+
+/** @ingroup iface_wl_data_device */
+static inline void
+wl_data_device_destroy(struct wl_data_device *wl_data_device)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_data_device);
+}
+
+/**
+ * @ingroup iface_wl_data_device
+ *
+ * This request asks the compositor to start a drag-and-drop
+ * operation on behalf of the client.
+ *
+ * The source argument is the data source that provides the data
+ * for the eventual data transfer. If source is NULL, enter, leave
+ * and motion events are sent only to the client that initiated the
+ * drag and the client is expected to handle the data passing
+ * internally. If source is destroyed, the drag-and-drop session will be
+ * cancelled.
+ *
+ * The origin surface is the surface where the drag originates and
+ * the client must have an active implicit grab that matches the
+ * serial.
+ *
+ * The icon surface is an optional (can be NULL) surface that
+ * provides an icon to be moved around with the cursor. Initially,
+ * the top-left corner of the icon surface is placed at the cursor
+ * hotspot, but subsequent wl_surface.attach request can move the
+ * relative position. Attach requests must be confirmed with
+ * wl_surface.commit as usual. The icon surface is given the role of
+ * a drag-and-drop icon. If the icon surface already has another role,
+ * it raises a protocol error.
+ *
+ * The current and pending input regions of the icon wl_surface are
+ * cleared, and wl_surface.set_input_region is ignored until the
+ * wl_surface is no longer used as the icon surface. When the use
+ * as an icon ends, the current and pending input regions become
+ * undefined, and the wl_surface is unmapped.
+ */
+static inline void
+wl_data_device_start_drag(struct wl_data_device *wl_data_device, struct wl_data_source *source, struct wl_surface *origin, struct wl_surface *icon, uint32_t serial)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_device,
+ WL_DATA_DEVICE_START_DRAG, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_device), 0, source, origin, icon, serial);
+}
+
+/**
+ * @ingroup iface_wl_data_device
+ *
+ * This request asks the compositor to set the selection
+ * to the data from the source on behalf of the client.
+ *
+ * To unset the selection, set the source to NULL.
+ */
+static inline void
+wl_data_device_set_selection(struct wl_data_device *wl_data_device, struct wl_data_source *source, uint32_t serial)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_device,
+ WL_DATA_DEVICE_SET_SELECTION, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_device), 0, source, serial);
+}
+
+/**
+ * @ingroup iface_wl_data_device
+ *
+ * This request destroys the data device.
+ */
+static inline void
+wl_data_device_release(struct wl_data_device *wl_data_device)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_data_device,
+ WL_DATA_DEVICE_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_data_device), WL_MARSHAL_FLAG_DESTROY);
+}
+
+#ifndef WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM
+#define WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM
+/**
+ * @ingroup iface_wl_data_device_manager
+ * drag and drop actions
+ *
+ * This is a bitmask of the available/preferred actions in a
+ * drag-and-drop operation.
+ *
+ * In the compositor, the selected action is a result of matching the
+ * actions offered by the source and destination sides. "action" events
+ * with a "none" action will be sent to both source and destination if
+ * there is no match. All further checks will effectively happen on
+ * (source actions ∩ destination actions).
+ *
+ * In addition, compositors may also pick different actions in
+ * reaction to key modifiers being pressed. One common design that
+ * is used in major toolkits (and the behavior recommended for
+ * compositors) is:
+ *
+ * - If no modifiers are pressed, the first match (in bit order)
+ * will be used.
+ * - Pressing Shift selects "move", if enabled in the mask.
+ * - Pressing Control selects "copy", if enabled in the mask.
+ *
+ * Behavior beyond that is considered implementation-dependent.
+ * Compositors may for example bind other modifiers (like Alt/Meta)
+ * or drags initiated with other buttons than BTN_LEFT to specific
+ * actions (e.g. "ask").
+ */
+enum wl_data_device_manager_dnd_action {
+ /**
+ * no action
+ */
+ WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE = 0,
+ /**
+ * copy action
+ */
+ WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY = 1,
+ /**
+ * move action
+ */
+ WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE = 2,
+ /**
+ * ask action
+ */
+ WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK = 4,
+};
+#endif /* WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM */
+
+#define WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE 0
+#define WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE 1
+
+
+/**
+ * @ingroup iface_wl_data_device_manager
+ */
+#define WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_data_device_manager
+ */
+#define WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE_SINCE_VERSION 1
+
+/** @ingroup iface_wl_data_device_manager */
+static inline void
+wl_data_device_manager_set_user_data(struct wl_data_device_manager *wl_data_device_manager, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_data_device_manager, user_data);
+}
+
+/** @ingroup iface_wl_data_device_manager */
+static inline void *
+wl_data_device_manager_get_user_data(struct wl_data_device_manager *wl_data_device_manager)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_data_device_manager);
+}
+
+static inline uint32_t
+wl_data_device_manager_get_version(struct wl_data_device_manager *wl_data_device_manager)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_data_device_manager);
+}
+
+/** @ingroup iface_wl_data_device_manager */
+static inline void
+wl_data_device_manager_destroy(struct wl_data_device_manager *wl_data_device_manager)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_data_device_manager);
+}
+
+/**
+ * @ingroup iface_wl_data_device_manager
+ *
+ * Create a new data source.
+ */
+static inline struct wl_data_source *
+wl_data_device_manager_create_data_source(struct wl_data_device_manager *wl_data_device_manager)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_data_device_manager,
+ WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE, &wl_data_source_interface, wl_proxy_get_version((struct wl_proxy *) wl_data_device_manager), 0, NULL);
+
+ return (struct wl_data_source *) id;
+}
+
+/**
+ * @ingroup iface_wl_data_device_manager
+ *
+ * Create a new data device for a given seat.
+ */
+static inline struct wl_data_device *
+wl_data_device_manager_get_data_device(struct wl_data_device_manager *wl_data_device_manager, struct wl_seat *seat)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_data_device_manager,
+ WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE, &wl_data_device_interface, wl_proxy_get_version((struct wl_proxy *) wl_data_device_manager), 0, NULL, seat);
+
+ return (struct wl_data_device *) id;
+}
+
+#ifndef WL_SHELL_ERROR_ENUM
+#define WL_SHELL_ERROR_ENUM
+enum wl_shell_error {
+ /**
+ * given wl_surface has another role
+ */
+ WL_SHELL_ERROR_ROLE = 0,
+};
+#endif /* WL_SHELL_ERROR_ENUM */
+
+#define WL_SHELL_GET_SHELL_SURFACE 0
+
+
+/**
+ * @ingroup iface_wl_shell
+ */
+#define WL_SHELL_GET_SHELL_SURFACE_SINCE_VERSION 1
+
+/** @ingroup iface_wl_shell */
+static inline void
+wl_shell_set_user_data(struct wl_shell *wl_shell, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_shell, user_data);
+}
+
+/** @ingroup iface_wl_shell */
+static inline void *
+wl_shell_get_user_data(struct wl_shell *wl_shell)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_shell);
+}
+
+static inline uint32_t
+wl_shell_get_version(struct wl_shell *wl_shell)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_shell);
+}
+
+/** @ingroup iface_wl_shell */
+static inline void
+wl_shell_destroy(struct wl_shell *wl_shell)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_shell);
+}
+
+/**
+ * @ingroup iface_wl_shell
+ *
+ * Create a shell surface for an existing surface. This gives
+ * the wl_surface the role of a shell surface. If the wl_surface
+ * already has another role, it raises a protocol error.
+ *
+ * Only one shell surface can be associated with a given surface.
+ */
+static inline struct wl_shell_surface *
+wl_shell_get_shell_surface(struct wl_shell *wl_shell, struct wl_surface *surface)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_shell,
+ WL_SHELL_GET_SHELL_SURFACE, &wl_shell_surface_interface, wl_proxy_get_version((struct wl_proxy *) wl_shell), 0, NULL, surface);
+
+ return (struct wl_shell_surface *) id;
+}
+
+#ifndef WL_SHELL_SURFACE_RESIZE_ENUM
+#define WL_SHELL_SURFACE_RESIZE_ENUM
+/**
+ * @ingroup iface_wl_shell_surface
+ * edge values for resizing
+ *
+ * These values are used to indicate which edge of a surface
+ * is being dragged in a resize operation. The server may
+ * use this information to adapt its behavior, e.g. choose
+ * an appropriate cursor image.
+ */
+enum wl_shell_surface_resize {
+ /**
+ * no edge
+ */
+ WL_SHELL_SURFACE_RESIZE_NONE = 0,
+ /**
+ * top edge
+ */
+ WL_SHELL_SURFACE_RESIZE_TOP = 1,
+ /**
+ * bottom edge
+ */
+ WL_SHELL_SURFACE_RESIZE_BOTTOM = 2,
+ /**
+ * left edge
+ */
+ WL_SHELL_SURFACE_RESIZE_LEFT = 4,
+ /**
+ * top and left edges
+ */
+ WL_SHELL_SURFACE_RESIZE_TOP_LEFT = 5,
+ /**
+ * bottom and left edges
+ */
+ WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT = 6,
+ /**
+ * right edge
+ */
+ WL_SHELL_SURFACE_RESIZE_RIGHT = 8,
+ /**
+ * top and right edges
+ */
+ WL_SHELL_SURFACE_RESIZE_TOP_RIGHT = 9,
+ /**
+ * bottom and right edges
+ */
+ WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT = 10,
+};
+#endif /* WL_SHELL_SURFACE_RESIZE_ENUM */
+
+#ifndef WL_SHELL_SURFACE_TRANSIENT_ENUM
+#define WL_SHELL_SURFACE_TRANSIENT_ENUM
+/**
+ * @ingroup iface_wl_shell_surface
+ * details of transient behaviour
+ *
+ * These flags specify details of the expected behaviour
+ * of transient surfaces. Used in the set_transient request.
+ */
+enum wl_shell_surface_transient {
+ /**
+ * do not set keyboard focus
+ */
+ WL_SHELL_SURFACE_TRANSIENT_INACTIVE = 0x1,
+};
+#endif /* WL_SHELL_SURFACE_TRANSIENT_ENUM */
+
+#ifndef WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM
+#define WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM
+/**
+ * @ingroup iface_wl_shell_surface
+ * different method to set the surface fullscreen
+ *
+ * Hints to indicate to the compositor how to deal with a conflict
+ * between the dimensions of the surface and the dimensions of the
+ * output. The compositor is free to ignore this parameter.
+ */
+enum wl_shell_surface_fullscreen_method {
+ /**
+ * no preference, apply default policy
+ */
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT = 0,
+ /**
+ * scale, preserve the surface's aspect ratio and center on output
+ */
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE = 1,
+ /**
+ * switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch
+ */
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER = 2,
+ /**
+ * no upscaling, center on output and add black borders to compensate size mismatch
+ */
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL = 3,
+};
+#endif /* WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM */
+
+/**
+ * @ingroup iface_wl_shell_surface
+ * @struct wl_shell_surface_listener
+ */
+struct wl_shell_surface_listener {
+ /**
+ * ping client
+ *
+ * Ping a client to check if it is receiving events and sending
+ * requests. A client is expected to reply with a pong request.
+ * @param serial serial number of the ping
+ */
+ void (*ping)(void *data,
+ struct wl_shell_surface *wl_shell_surface,
+ uint32_t serial);
+ /**
+ * suggest resize
+ *
+ * The configure event asks the client to resize its surface.
+ *
+ * The size is a hint, in the sense that the client is free to
+ * ignore it if it doesn't resize, pick a smaller size (to satisfy
+ * aspect ratio or resize in steps of NxM pixels).
+ *
+ * The edges parameter provides a hint about how the surface was
+ * resized. The client may use this information to decide how to
+ * adjust its content to the new size (e.g. a scrolling area might
+ * adjust its content position to leave the viewable content
+ * unmoved).
+ *
+ * The client is free to dismiss all but the last configure event
+ * it received.
+ *
+ * The width and height arguments specify the size of the window in
+ * surface-local coordinates.
+ * @param edges how the surface was resized
+ * @param width new width of the surface
+ * @param height new height of the surface
+ */
+ void (*configure)(void *data,
+ struct wl_shell_surface *wl_shell_surface,
+ uint32_t edges,
+ int32_t width,
+ int32_t height);
+ /**
+ * popup interaction is done
+ *
+ * The popup_done event is sent out when a popup grab is broken,
+ * that is, when the user clicks a surface that doesn't belong to
+ * the client owning the popup surface.
+ */
+ void (*popup_done)(void *data,
+ struct wl_shell_surface *wl_shell_surface);
+};
+
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+static inline int
+wl_shell_surface_add_listener(struct wl_shell_surface *wl_shell_surface,
+ const struct wl_shell_surface_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_shell_surface,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_SHELL_SURFACE_PONG 0
+#define WL_SHELL_SURFACE_MOVE 1
+#define WL_SHELL_SURFACE_RESIZE 2
+#define WL_SHELL_SURFACE_SET_TOPLEVEL 3
+#define WL_SHELL_SURFACE_SET_TRANSIENT 4
+#define WL_SHELL_SURFACE_SET_FULLSCREEN 5
+#define WL_SHELL_SURFACE_SET_POPUP 6
+#define WL_SHELL_SURFACE_SET_MAXIMIZED 7
+#define WL_SHELL_SURFACE_SET_TITLE 8
+#define WL_SHELL_SURFACE_SET_CLASS 9
+
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_PING_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_CONFIGURE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_POPUP_DONE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_PONG_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_MOVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_RESIZE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_TOPLEVEL_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_TRANSIENT_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_POPUP_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_TITLE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_shell_surface
+ */
+#define WL_SHELL_SURFACE_SET_CLASS_SINCE_VERSION 1
+
+/** @ingroup iface_wl_shell_surface */
+static inline void
+wl_shell_surface_set_user_data(struct wl_shell_surface *wl_shell_surface, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_shell_surface, user_data);
+}
+
+/** @ingroup iface_wl_shell_surface */
+static inline void *
+wl_shell_surface_get_user_data(struct wl_shell_surface *wl_shell_surface)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_shell_surface);
+}
+
+static inline uint32_t
+wl_shell_surface_get_version(struct wl_shell_surface *wl_shell_surface)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_shell_surface);
+}
+
+/** @ingroup iface_wl_shell_surface */
+static inline void
+wl_shell_surface_destroy(struct wl_shell_surface *wl_shell_surface)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_shell_surface);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * A client must respond to a ping event with a pong request or
+ * the client may be deemed unresponsive.
+ */
+static inline void
+wl_shell_surface_pong(struct wl_shell_surface *wl_shell_surface, uint32_t serial)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_PONG, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, serial);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Start a pointer-driven move of the surface.
+ *
+ * This request must be used in response to a button press event.
+ * The server may ignore move requests depending on the state of
+ * the surface (e.g. fullscreen or maximized).
+ */
+static inline void
+wl_shell_surface_move(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_MOVE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, seat, serial);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Start a pointer-driven resizing of the surface.
+ *
+ * This request must be used in response to a button press event.
+ * The server may ignore resize requests depending on the state of
+ * the surface (e.g. fullscreen or maximized).
+ */
+static inline void
+wl_shell_surface_resize(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_RESIZE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, seat, serial, edges);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Map the surface as a toplevel surface.
+ *
+ * A toplevel surface is not fullscreen, maximized or transient.
+ */
+static inline void
+wl_shell_surface_set_toplevel(struct wl_shell_surface *wl_shell_surface)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_TOPLEVEL, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Map the surface relative to an existing surface.
+ *
+ * The x and y arguments specify the location of the upper left
+ * corner of the surface relative to the upper left corner of the
+ * parent surface, in surface-local coordinates.
+ *
+ * The flags argument controls details of the transient behaviour.
+ */
+static inline void
+wl_shell_surface_set_transient(struct wl_shell_surface *wl_shell_surface, struct wl_surface *parent, int32_t x, int32_t y, uint32_t flags)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_TRANSIENT, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, parent, x, y, flags);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Map the surface as a fullscreen surface.
+ *
+ * If an output parameter is given then the surface will be made
+ * fullscreen on that output. If the client does not specify the
+ * output then the compositor will apply its policy - usually
+ * choosing the output on which the surface has the biggest surface
+ * area.
+ *
+ * The client may specify a method to resolve a size conflict
+ * between the output size and the surface size - this is provided
+ * through the method parameter.
+ *
+ * The framerate parameter is used only when the method is set
+ * to "driver", to indicate the preferred framerate. A value of 0
+ * indicates that the client does not care about framerate. The
+ * framerate is specified in mHz, that is framerate of 60000 is 60Hz.
+ *
+ * A method of "scale" or "driver" implies a scaling operation of
+ * the surface, either via a direct scaling operation or a change of
+ * the output mode. This will override any kind of output scaling, so
+ * that mapping a surface with a buffer size equal to the mode can
+ * fill the screen independent of buffer_scale.
+ *
+ * A method of "fill" means we don't scale up the buffer, however
+ * any output scale is applied. This means that you may run into
+ * an edge case where the application maps a buffer with the same
+ * size of the output mode but buffer_scale 1 (thus making a
+ * surface larger than the output). In this case it is allowed to
+ * downscale the results to fit the screen.
+ *
+ * The compositor must reply to this request with a configure event
+ * with the dimensions for the output on which the surface will
+ * be made fullscreen.
+ */
+static inline void
+wl_shell_surface_set_fullscreen(struct wl_shell_surface *wl_shell_surface, uint32_t method, uint32_t framerate, struct wl_output *output)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, method, framerate, output);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Map the surface as a popup.
+ *
+ * A popup surface is a transient surface with an added pointer
+ * grab.
+ *
+ * An existing implicit grab will be changed to owner-events mode,
+ * and the popup grab will continue after the implicit grab ends
+ * (i.e. releasing the mouse button does not cause the popup to
+ * be unmapped).
+ *
+ * The popup grab continues until the window is destroyed or a
+ * mouse button is pressed in any other client's window. A click
+ * in any of the client's surfaces is reported as normal, however,
+ * clicks in other clients' surfaces will be discarded and trigger
+ * the callback.
+ *
+ * The x and y arguments specify the location of the upper left
+ * corner of the surface relative to the upper left corner of the
+ * parent surface, in surface-local coordinates.
+ */
+static inline void
+wl_shell_surface_set_popup(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial, struct wl_surface *parent, int32_t x, int32_t y, uint32_t flags)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_POPUP, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, seat, serial, parent, x, y, flags);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Map the surface as a maximized surface.
+ *
+ * If an output parameter is given then the surface will be
+ * maximized on that output. If the client does not specify the
+ * output then the compositor will apply its policy - usually
+ * choosing the output on which the surface has the biggest surface
+ * area.
+ *
+ * The compositor will reply with a configure event telling
+ * the expected new surface size. The operation is completed
+ * on the next buffer attach to this surface.
+ *
+ * A maximized surface typically fills the entire output it is
+ * bound to, except for desktop elements such as panels. This is
+ * the main difference between a maximized shell surface and a
+ * fullscreen shell surface.
+ *
+ * The details depend on the compositor implementation.
+ */
+static inline void
+wl_shell_surface_set_maximized(struct wl_shell_surface *wl_shell_surface, struct wl_output *output)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, output);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Set a short title for the surface.
+ *
+ * This string may be used to identify the surface in a task bar,
+ * window list, or other user interface elements provided by the
+ * compositor.
+ *
+ * The string must be encoded in UTF-8.
+ */
+static inline void
+wl_shell_surface_set_title(struct wl_shell_surface *wl_shell_surface, const char *title)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_TITLE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, title);
+}
+
+/**
+ * @ingroup iface_wl_shell_surface
+ *
+ * Set a class for the surface.
+ *
+ * The surface class identifies the general class of applications
+ * to which the surface belongs. A common convention is to use the
+ * file name (or the full path if it is a non-standard location) of
+ * the application's .desktop file as the class.
+ */
+static inline void
+wl_shell_surface_set_class(struct wl_shell_surface *wl_shell_surface, const char *class_)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_shell_surface,
+ WL_SHELL_SURFACE_SET_CLASS, NULL, wl_proxy_get_version((struct wl_proxy *) wl_shell_surface), 0, class_);
+}
+
+#ifndef WL_SURFACE_ERROR_ENUM
+#define WL_SURFACE_ERROR_ENUM
+/**
+ * @ingroup iface_wl_surface
+ * wl_surface error values
+ *
+ * These errors can be emitted in response to wl_surface requests.
+ */
+enum wl_surface_error {
+ /**
+ * buffer scale value is invalid
+ */
+ WL_SURFACE_ERROR_INVALID_SCALE = 0,
+ /**
+ * buffer transform value is invalid
+ */
+ WL_SURFACE_ERROR_INVALID_TRANSFORM = 1,
+ /**
+ * buffer size is invalid
+ */
+ WL_SURFACE_ERROR_INVALID_SIZE = 2,
+ /**
+ * buffer offset is invalid
+ */
+ WL_SURFACE_ERROR_INVALID_OFFSET = 3,
+};
+#endif /* WL_SURFACE_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_surface
+ * @struct wl_surface_listener
+ */
+struct wl_surface_listener {
+ /**
+ * surface enters an output
+ *
+ * This is emitted whenever a surface's creation, movement, or
+ * resizing results in some part of it being within the scanout
+ * region of an output.
+ *
+ * Note that a surface may be overlapping with zero or more
+ * outputs.
+ * @param output output entered by the surface
+ */
+ void (*enter)(void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *output);
+ /**
+ * surface leaves an output
+ *
+ * This is emitted whenever a surface's creation, movement, or
+ * resizing results in it no longer having any part of it within
+ * the scanout region of an output.
+ *
+ * Clients should not use the number of outputs the surface is on
+ * for frame throttling purposes. The surface might be hidden even
+ * if no leave event has been sent, and the compositor might expect
+ * new surface content updates even if no enter event has been
+ * sent. The frame event should be used instead.
+ * @param output output left by the surface
+ */
+ void (*leave)(void *data,
+ struct wl_surface *wl_surface,
+ struct wl_output *output);
+};
+
+/**
+ * @ingroup iface_wl_surface
+ */
+static inline int
+wl_surface_add_listener(struct wl_surface *wl_surface,
+ const struct wl_surface_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_surface,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_SURFACE_DESTROY 0
+#define WL_SURFACE_ATTACH 1
+#define WL_SURFACE_DAMAGE 2
+#define WL_SURFACE_FRAME 3
+#define WL_SURFACE_SET_OPAQUE_REGION 4
+#define WL_SURFACE_SET_INPUT_REGION 5
+#define WL_SURFACE_COMMIT 6
+#define WL_SURFACE_SET_BUFFER_TRANSFORM 7
+#define WL_SURFACE_SET_BUFFER_SCALE 8
+#define WL_SURFACE_DAMAGE_BUFFER 9
+#define WL_SURFACE_OFFSET 10
+
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_ENTER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_LEAVE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_ATTACH_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_DAMAGE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_FRAME_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_SET_OPAQUE_REGION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_SET_INPUT_REGION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_COMMIT_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_SET_BUFFER_TRANSFORM_SINCE_VERSION 2
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION 3
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION 4
+/**
+ * @ingroup iface_wl_surface
+ */
+#define WL_SURFACE_OFFSET_SINCE_VERSION 5
+
+/** @ingroup iface_wl_surface */
+static inline void
+wl_surface_set_user_data(struct wl_surface *wl_surface, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_surface, user_data);
+}
+
+/** @ingroup iface_wl_surface */
+static inline void *
+wl_surface_get_user_data(struct wl_surface *wl_surface)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_surface);
+}
+
+static inline uint32_t
+wl_surface_get_version(struct wl_surface *wl_surface)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_surface);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * Deletes the surface and invalidates its object ID.
+ */
+static inline void
+wl_surface_destroy(struct wl_surface *wl_surface)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), WL_MARSHAL_FLAG_DESTROY);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * Set a buffer as the content of this surface.
+ *
+ * The new size of the surface is calculated based on the buffer
+ * size transformed by the inverse buffer_transform and the
+ * inverse buffer_scale. This means that at commit time the supplied
+ * buffer size must be an integer multiple of the buffer_scale. If
+ * that's not the case, an invalid_size error is sent.
+ *
+ * The x and y arguments specify the location of the new pending
+ * buffer's upper left corner, relative to the current buffer's upper
+ * left corner, in surface-local coordinates. In other words, the
+ * x and y, combined with the new surface size define in which
+ * directions the surface's size changes. Setting anything other than 0
+ * as x and y arguments is discouraged, and should instead be replaced
+ * with using the separate wl_surface.offset request.
+ *
+ * When the bound wl_surface version is 5 or higher, passing any
+ * non-zero x or y is a protocol violation, and will result in an
+ * 'invalid_offset' error being raised. To achieve equivalent semantics,
+ * use wl_surface.offset.
+ *
+ * Surface contents are double-buffered state, see wl_surface.commit.
+ *
+ * The initial surface contents are void; there is no content.
+ * wl_surface.attach assigns the given wl_buffer as the pending
+ * wl_buffer. wl_surface.commit makes the pending wl_buffer the new
+ * surface contents, and the size of the surface becomes the size
+ * calculated from the wl_buffer, as described above. After commit,
+ * there is no pending buffer until the next attach.
+ *
+ * Committing a pending wl_buffer allows the compositor to read the
+ * pixels in the wl_buffer. The compositor may access the pixels at
+ * any time after the wl_surface.commit request. When the compositor
+ * will not access the pixels anymore, it will send the
+ * wl_buffer.release event. Only after receiving wl_buffer.release,
+ * the client may reuse the wl_buffer. A wl_buffer that has been
+ * attached and then replaced by another attach instead of committed
+ * will not receive a release event, and is not used by the
+ * compositor.
+ *
+ * If a pending wl_buffer has been committed to more than one wl_surface,
+ * the delivery of wl_buffer.release events becomes undefined. A well
+ * behaved client should not rely on wl_buffer.release events in this
+ * case. Alternatively, a client could create multiple wl_buffer objects
+ * from the same backing storage or use wp_linux_buffer_release.
+ *
+ * Destroying the wl_buffer after wl_buffer.release does not change
+ * the surface contents. Destroying the wl_buffer before wl_buffer.release
+ * is allowed as long as the underlying buffer storage isn't re-used (this
+ * can happen e.g. on client process termination). However, if the client
+ * destroys the wl_buffer before receiving the wl_buffer.release event and
+ * mutates the underlying buffer storage, the surface contents become
+ * undefined immediately.
+ *
+ * If wl_surface.attach is sent with a NULL wl_buffer, the
+ * following wl_surface.commit will remove the surface content.
+ */
+static inline void
+wl_surface_attach(struct wl_surface *wl_surface, struct wl_buffer *buffer, int32_t x, int32_t y)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_ATTACH, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, buffer, x, y);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request is used to describe the regions where the pending
+ * buffer is different from the current surface contents, and where
+ * the surface therefore needs to be repainted. The compositor
+ * ignores the parts of the damage that fall outside of the surface.
+ *
+ * Damage is double-buffered state, see wl_surface.commit.
+ *
+ * The damage rectangle is specified in surface-local coordinates,
+ * where x and y specify the upper left corner of the damage rectangle.
+ *
+ * The initial value for pending damage is empty: no damage.
+ * wl_surface.damage adds pending damage: the new pending damage
+ * is the union of old pending damage and the given rectangle.
+ *
+ * wl_surface.commit assigns pending damage as the current damage,
+ * and clears pending damage. The server will clear the current
+ * damage as it repaints the surface.
+ *
+ * Note! New clients should not use this request. Instead damage can be
+ * posted with wl_surface.damage_buffer which uses buffer coordinates
+ * instead of surface coordinates.
+ */
+static inline void
+wl_surface_damage(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_DAMAGE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, x, y, width, height);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * Request a notification when it is a good time to start drawing a new
+ * frame, by creating a frame callback. This is useful for throttling
+ * redrawing operations, and driving animations.
+ *
+ * When a client is animating on a wl_surface, it can use the 'frame'
+ * request to get notified when it is a good time to draw and commit the
+ * next frame of animation. If the client commits an update earlier than
+ * that, it is likely that some updates will not make it to the display,
+ * and the client is wasting resources by drawing too often.
+ *
+ * The frame request will take effect on the next wl_surface.commit.
+ * The notification will only be posted for one frame unless
+ * requested again. For a wl_surface, the notifications are posted in
+ * the order the frame requests were committed.
+ *
+ * The server must send the notifications so that a client
+ * will not send excessive updates, while still allowing
+ * the highest possible update rate for clients that wait for the reply
+ * before drawing again. The server should give some time for the client
+ * to draw and commit after sending the frame callback events to let it
+ * hit the next output refresh.
+ *
+ * A server should avoid signaling the frame callbacks if the
+ * surface is not visible in any way, e.g. the surface is off-screen,
+ * or completely obscured by other opaque surfaces.
+ *
+ * The object returned by this request will be destroyed by the
+ * compositor after the callback is fired and as such the client must not
+ * attempt to use it after that point.
+ *
+ * The callback_data passed in the callback is the current time, in
+ * milliseconds, with an undefined base.
+ */
+static inline struct wl_callback *
+wl_surface_frame(struct wl_surface *wl_surface)
+{
+ struct wl_proxy *callback;
+
+ callback = wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_FRAME, &wl_callback_interface, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, NULL);
+
+ return (struct wl_callback *) callback;
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request sets the region of the surface that contains
+ * opaque content.
+ *
+ * The opaque region is an optimization hint for the compositor
+ * that lets it optimize the redrawing of content behind opaque
+ * regions. Setting an opaque region is not required for correct
+ * behaviour, but marking transparent content as opaque will result
+ * in repaint artifacts.
+ *
+ * The opaque region is specified in surface-local coordinates.
+ *
+ * The compositor ignores the parts of the opaque region that fall
+ * outside of the surface.
+ *
+ * Opaque region is double-buffered state, see wl_surface.commit.
+ *
+ * wl_surface.set_opaque_region changes the pending opaque region.
+ * wl_surface.commit copies the pending region to the current region.
+ * Otherwise, the pending and current regions are never changed.
+ *
+ * The initial value for an opaque region is empty. Setting the pending
+ * opaque region has copy semantics, and the wl_region object can be
+ * destroyed immediately. A NULL wl_region causes the pending opaque
+ * region to be set to empty.
+ */
+static inline void
+wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_SET_OPAQUE_REGION, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, region);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request sets the region of the surface that can receive
+ * pointer and touch events.
+ *
+ * Input events happening outside of this region will try the next
+ * surface in the server surface stack. The compositor ignores the
+ * parts of the input region that fall outside of the surface.
+ *
+ * The input region is specified in surface-local coordinates.
+ *
+ * Input region is double-buffered state, see wl_surface.commit.
+ *
+ * wl_surface.set_input_region changes the pending input region.
+ * wl_surface.commit copies the pending region to the current region.
+ * Otherwise the pending and current regions are never changed,
+ * except cursor and icon surfaces are special cases, see
+ * wl_pointer.set_cursor and wl_data_device.start_drag.
+ *
+ * The initial value for an input region is infinite. That means the
+ * whole surface will accept input. Setting the pending input region
+ * has copy semantics, and the wl_region object can be destroyed
+ * immediately. A NULL wl_region causes the input region to be set
+ * to infinite.
+ */
+static inline void
+wl_surface_set_input_region(struct wl_surface *wl_surface, struct wl_region *region)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_SET_INPUT_REGION, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, region);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * Surface state (input, opaque, and damage regions, attached buffers,
+ * etc.) is double-buffered. Protocol requests modify the pending state,
+ * as opposed to the current state in use by the compositor. A commit
+ * request atomically applies all pending state, replacing the current
+ * state. After commit, the new pending state is as documented for each
+ * related request.
+ *
+ * On commit, a pending wl_buffer is applied first, and all other state
+ * second. This means that all coordinates in double-buffered state are
+ * relative to the new wl_buffer coming into use, except for
+ * wl_surface.attach itself. If there is no pending wl_buffer, the
+ * coordinates are relative to the current surface contents.
+ *
+ * All requests that need a commit to become effective are documented
+ * to affect double-buffered state.
+ *
+ * Other interfaces may add further double-buffered surface state.
+ */
+static inline void
+wl_surface_commit(struct wl_surface *wl_surface)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_COMMIT, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request sets an optional transformation on how the compositor
+ * interprets the contents of the buffer attached to the surface. The
+ * accepted values for the transform parameter are the values for
+ * wl_output.transform.
+ *
+ * Buffer transform is double-buffered state, see wl_surface.commit.
+ *
+ * A newly created surface has its buffer transformation set to normal.
+ *
+ * wl_surface.set_buffer_transform changes the pending buffer
+ * transformation. wl_surface.commit copies the pending buffer
+ * transformation to the current one. Otherwise, the pending and current
+ * values are never changed.
+ *
+ * The purpose of this request is to allow clients to render content
+ * according to the output transform, thus permitting the compositor to
+ * use certain optimizations even if the display is rotated. Using
+ * hardware overlays and scanning out a client buffer for fullscreen
+ * surfaces are examples of such optimizations. Those optimizations are
+ * highly dependent on the compositor implementation, so the use of this
+ * request should be considered on a case-by-case basis.
+ *
+ * Note that if the transform value includes 90 or 270 degree rotation,
+ * the width of the buffer will become the surface height and the height
+ * of the buffer will become the surface width.
+ *
+ * If transform is not one of the values from the
+ * wl_output.transform enum the invalid_transform protocol error
+ * is raised.
+ */
+static inline void
+wl_surface_set_buffer_transform(struct wl_surface *wl_surface, int32_t transform)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_SET_BUFFER_TRANSFORM, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, transform);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request sets an optional scaling factor on how the compositor
+ * interprets the contents of the buffer attached to the window.
+ *
+ * Buffer scale is double-buffered state, see wl_surface.commit.
+ *
+ * A newly created surface has its buffer scale set to 1.
+ *
+ * wl_surface.set_buffer_scale changes the pending buffer scale.
+ * wl_surface.commit copies the pending buffer scale to the current one.
+ * Otherwise, the pending and current values are never changed.
+ *
+ * The purpose of this request is to allow clients to supply higher
+ * resolution buffer data for use on high resolution outputs. It is
+ * intended that you pick the same buffer scale as the scale of the
+ * output that the surface is displayed on. This means the compositor
+ * can avoid scaling when rendering the surface on that output.
+ *
+ * Note that if the scale is larger than 1, then you have to attach
+ * a buffer that is larger (by a factor of scale in each dimension)
+ * than the desired surface size.
+ *
+ * If scale is not positive the invalid_scale protocol error is
+ * raised.
+ */
+static inline void
+wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_SET_BUFFER_SCALE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, scale);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * This request is used to describe the regions where the pending
+ * buffer is different from the current surface contents, and where
+ * the surface therefore needs to be repainted. The compositor
+ * ignores the parts of the damage that fall outside of the surface.
+ *
+ * Damage is double-buffered state, see wl_surface.commit.
+ *
+ * The damage rectangle is specified in buffer coordinates,
+ * where x and y specify the upper left corner of the damage rectangle.
+ *
+ * The initial value for pending damage is empty: no damage.
+ * wl_surface.damage_buffer adds pending damage: the new pending
+ * damage is the union of old pending damage and the given rectangle.
+ *
+ * wl_surface.commit assigns pending damage as the current damage,
+ * and clears pending damage. The server will clear the current
+ * damage as it repaints the surface.
+ *
+ * This request differs from wl_surface.damage in only one way - it
+ * takes damage in buffer coordinates instead of surface-local
+ * coordinates. While this generally is more intuitive than surface
+ * coordinates, it is especially desirable when using wp_viewport
+ * or when a drawing library (like EGL) is unaware of buffer scale
+ * and buffer transform.
+ *
+ * Note: Because buffer transformation changes and damage requests may
+ * be interleaved in the protocol stream, it is impossible to determine
+ * the actual mapping between surface and buffer damage until
+ * wl_surface.commit time. Therefore, compositors wishing to take both
+ * kinds of damage into account will have to accumulate damage from the
+ * two requests separately and only transform from one to the other
+ * after receiving the wl_surface.commit.
+ */
+static inline void
+wl_surface_damage_buffer(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_DAMAGE_BUFFER, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, x, y, width, height);
+}
+
+/**
+ * @ingroup iface_wl_surface
+ *
+ * The x and y arguments specify the location of the new pending
+ * buffer's upper left corner, relative to the current buffer's upper
+ * left corner, in surface-local coordinates. In other words, the
+ * x and y, combined with the new surface size define in which
+ * directions the surface's size changes.
+ *
+ * Surface location offset is double-buffered state, see
+ * wl_surface.commit.
+ *
+ * This request is semantically equivalent to and the replaces the x and y
+ * arguments in the wl_surface.attach request in wl_surface versions prior
+ * to 5. See wl_surface.attach for details.
+ */
+static inline void
+wl_surface_offset(struct wl_surface *wl_surface, int32_t x, int32_t y)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_surface,
+ WL_SURFACE_OFFSET, NULL, wl_proxy_get_version((struct wl_proxy *) wl_surface), 0, x, y);
+}
+
+#ifndef WL_SEAT_CAPABILITY_ENUM
+#define WL_SEAT_CAPABILITY_ENUM
+/**
+ * @ingroup iface_wl_seat
+ * seat capability bitmask
+ *
+ * This is a bitmask of capabilities this seat has; if a member is
+ * set, then it is present on the seat.
+ */
+enum wl_seat_capability {
+ /**
+ * the seat has pointer devices
+ */
+ WL_SEAT_CAPABILITY_POINTER = 1,
+ /**
+ * the seat has one or more keyboards
+ */
+ WL_SEAT_CAPABILITY_KEYBOARD = 2,
+ /**
+ * the seat has touch devices
+ */
+ WL_SEAT_CAPABILITY_TOUCH = 4,
+};
+#endif /* WL_SEAT_CAPABILITY_ENUM */
+
+#ifndef WL_SEAT_ERROR_ENUM
+#define WL_SEAT_ERROR_ENUM
+/**
+ * @ingroup iface_wl_seat
+ * wl_seat error values
+ *
+ * These errors can be emitted in response to wl_seat requests.
+ */
+enum wl_seat_error {
+ /**
+ * get_pointer, get_keyboard or get_touch called on seat without the matching capability
+ */
+ WL_SEAT_ERROR_MISSING_CAPABILITY = 0,
+};
+#endif /* WL_SEAT_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_seat
+ * @struct wl_seat_listener
+ */
+struct wl_seat_listener {
+ /**
+ * seat capabilities changed
+ *
+ * This is emitted whenever a seat gains or loses the pointer,
+ * keyboard or touch capabilities. The argument is a capability
+ * enum containing the complete set of capabilities this seat has.
+ *
+ * When the pointer capability is added, a client may create a
+ * wl_pointer object using the wl_seat.get_pointer request. This
+ * object will receive pointer events until the capability is
+ * removed in the future.
+ *
+ * When the pointer capability is removed, a client should destroy
+ * the wl_pointer objects associated with the seat where the
+ * capability was removed, using the wl_pointer.release request. No
+ * further pointer events will be received on these objects.
+ *
+ * In some compositors, if a seat regains the pointer capability
+ * and a client has a previously obtained wl_pointer object of
+ * version 4 or less, that object may start sending pointer events
+ * again. This behavior is considered a misinterpretation of the
+ * intended behavior and must not be relied upon by the client.
+ * wl_pointer objects of version 5 or later must not send events if
+ * created before the most recent event notifying the client of an
+ * added pointer capability.
+ *
+ * The above behavior also applies to wl_keyboard and wl_touch with
+ * the keyboard and touch capabilities, respectively.
+ * @param capabilities capabilities of the seat
+ */
+ void (*capabilities)(void *data,
+ struct wl_seat *wl_seat,
+ uint32_t capabilities);
+ /**
+ * unique identifier for this seat
+ *
+ * In a multi-seat configuration the seat name can be used by
+ * clients to help identify which physical devices the seat
+ * represents.
+ *
+ * The seat name is a UTF-8 string with no convention defined for
+ * its contents. Each name is unique among all wl_seat globals. The
+ * name is only guaranteed to be unique for the current compositor
+ * instance.
+ *
+ * The same seat names are used for all clients. Thus, the name can
+ * be shared across processes to refer to a specific wl_seat
+ * global.
+ *
+ * The name event is sent after binding to the seat global. This
+ * event is only sent once per seat object, and the name does not
+ * change over the lifetime of the wl_seat global.
+ *
+ * Compositors may re-use the same seat name if the wl_seat global
+ * is destroyed and re-created later.
+ * @param name seat identifier
+ * @since 2
+ */
+ void (*name)(void *data,
+ struct wl_seat *wl_seat,
+ const char *name);
+};
+
+/**
+ * @ingroup iface_wl_seat
+ */
+static inline int
+wl_seat_add_listener(struct wl_seat *wl_seat,
+ const struct wl_seat_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_seat,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_SEAT_GET_POINTER 0
+#define WL_SEAT_GET_KEYBOARD 1
+#define WL_SEAT_GET_TOUCH 2
+#define WL_SEAT_RELEASE 3
+
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_CAPABILITIES_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_NAME_SINCE_VERSION 2
+
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_GET_POINTER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_GET_KEYBOARD_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_GET_TOUCH_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_seat
+ */
+#define WL_SEAT_RELEASE_SINCE_VERSION 5
+
+/** @ingroup iface_wl_seat */
+static inline void
+wl_seat_set_user_data(struct wl_seat *wl_seat, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_seat, user_data);
+}
+
+/** @ingroup iface_wl_seat */
+static inline void *
+wl_seat_get_user_data(struct wl_seat *wl_seat)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_seat);
+}
+
+static inline uint32_t
+wl_seat_get_version(struct wl_seat *wl_seat)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_seat);
+}
+
+/** @ingroup iface_wl_seat */
+static inline void
+wl_seat_destroy(struct wl_seat *wl_seat)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_seat);
+}
+
+/**
+ * @ingroup iface_wl_seat
+ *
+ * The ID provided will be initialized to the wl_pointer interface
+ * for this seat.
+ *
+ * This request only takes effect if the seat has the pointer
+ * capability, or has had the pointer capability in the past.
+ * It is a protocol violation to issue this request on a seat that has
+ * never had the pointer capability. The missing_capability error will
+ * be sent in this case.
+ */
+static inline struct wl_pointer *
+wl_seat_get_pointer(struct wl_seat *wl_seat)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_seat,
+ WL_SEAT_GET_POINTER, &wl_pointer_interface, wl_proxy_get_version((struct wl_proxy *) wl_seat), 0, NULL);
+
+ return (struct wl_pointer *) id;
+}
+
+/**
+ * @ingroup iface_wl_seat
+ *
+ * The ID provided will be initialized to the wl_keyboard interface
+ * for this seat.
+ *
+ * This request only takes effect if the seat has the keyboard
+ * capability, or has had the keyboard capability in the past.
+ * It is a protocol violation to issue this request on a seat that has
+ * never had the keyboard capability. The missing_capability error will
+ * be sent in this case.
+ */
+static inline struct wl_keyboard *
+wl_seat_get_keyboard(struct wl_seat *wl_seat)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_seat,
+ WL_SEAT_GET_KEYBOARD, &wl_keyboard_interface, wl_proxy_get_version((struct wl_proxy *) wl_seat), 0, NULL);
+
+ return (struct wl_keyboard *) id;
+}
+
+/**
+ * @ingroup iface_wl_seat
+ *
+ * The ID provided will be initialized to the wl_touch interface
+ * for this seat.
+ *
+ * This request only takes effect if the seat has the touch
+ * capability, or has had the touch capability in the past.
+ * It is a protocol violation to issue this request on a seat that has
+ * never had the touch capability. The missing_capability error will
+ * be sent in this case.
+ */
+static inline struct wl_touch *
+wl_seat_get_touch(struct wl_seat *wl_seat)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_flags((struct wl_proxy *) wl_seat,
+ WL_SEAT_GET_TOUCH, &wl_touch_interface, wl_proxy_get_version((struct wl_proxy *) wl_seat), 0, NULL);
+
+ return (struct wl_touch *) id;
+}
+
+/**
+ * @ingroup iface_wl_seat
+ *
+ * Using this request a client can tell the server that it is not going to
+ * use the seat object anymore.
+ */
+static inline void
+wl_seat_release(struct wl_seat *wl_seat)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_seat,
+ WL_SEAT_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_seat), WL_MARSHAL_FLAG_DESTROY);
+}
+
+#ifndef WL_POINTER_ERROR_ENUM
+#define WL_POINTER_ERROR_ENUM
+enum wl_pointer_error {
+ /**
+ * given wl_surface has another role
+ */
+ WL_POINTER_ERROR_ROLE = 0,
+};
+#endif /* WL_POINTER_ERROR_ENUM */
+
+#ifndef WL_POINTER_BUTTON_STATE_ENUM
+#define WL_POINTER_BUTTON_STATE_ENUM
+/**
+ * @ingroup iface_wl_pointer
+ * physical button state
+ *
+ * Describes the physical state of a button that produced the button
+ * event.
+ */
+enum wl_pointer_button_state {
+ /**
+ * the button is not pressed
+ */
+ WL_POINTER_BUTTON_STATE_RELEASED = 0,
+ /**
+ * the button is pressed
+ */
+ WL_POINTER_BUTTON_STATE_PRESSED = 1,
+};
+#endif /* WL_POINTER_BUTTON_STATE_ENUM */
+
+#ifndef WL_POINTER_AXIS_ENUM
+#define WL_POINTER_AXIS_ENUM
+/**
+ * @ingroup iface_wl_pointer
+ * axis types
+ *
+ * Describes the axis types of scroll events.
+ */
+enum wl_pointer_axis {
+ /**
+ * vertical axis
+ */
+ WL_POINTER_AXIS_VERTICAL_SCROLL = 0,
+ /**
+ * horizontal axis
+ */
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL = 1,
+};
+#endif /* WL_POINTER_AXIS_ENUM */
+
+#ifndef WL_POINTER_AXIS_SOURCE_ENUM
+#define WL_POINTER_AXIS_SOURCE_ENUM
+/**
+ * @ingroup iface_wl_pointer
+ * axis source types
+ *
+ * Describes the source types for axis events. This indicates to the
+ * client how an axis event was physically generated; a client may
+ * adjust the user interface accordingly. For example, scroll events
+ * from a "finger" source may be in a smooth coordinate space with
+ * kinetic scrolling whereas a "wheel" source may be in discrete steps
+ * of a number of lines.
+ *
+ * The "continuous" axis source is a device generating events in a
+ * continuous coordinate space, but using something other than a
+ * finger. One example for this source is button-based scrolling where
+ * the vertical motion of a device is converted to scroll events while
+ * a button is held down.
+ *
+ * The "wheel tilt" axis source indicates that the actual device is a
+ * wheel but the scroll event is not caused by a rotation but a
+ * (usually sideways) tilt of the wheel.
+ */
+enum wl_pointer_axis_source {
+ /**
+ * a physical wheel rotation
+ */
+ WL_POINTER_AXIS_SOURCE_WHEEL = 0,
+ /**
+ * finger on a touch surface
+ */
+ WL_POINTER_AXIS_SOURCE_FINGER = 1,
+ /**
+ * continuous coordinate space
+ */
+ WL_POINTER_AXIS_SOURCE_CONTINUOUS = 2,
+ /**
+ * a physical wheel tilt
+ * @since 6
+ */
+ WL_POINTER_AXIS_SOURCE_WHEEL_TILT = 3,
+};
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION 6
+#endif /* WL_POINTER_AXIS_SOURCE_ENUM */
+
+/**
+ * @ingroup iface_wl_pointer
+ * @struct wl_pointer_listener
+ */
+struct wl_pointer_listener {
+ /**
+ * enter event
+ *
+ * Notification that this seat's pointer is focused on a certain
+ * surface.
+ *
+ * When a seat's focus enters a surface, the pointer image is
+ * undefined and a client should respond to this event by setting
+ * an appropriate pointer image with the set_cursor request.
+ * @param serial serial number of the enter event
+ * @param surface surface entered by the pointer
+ * @param surface_x surface-local x coordinate
+ * @param surface_y surface-local y coordinate
+ */
+ void (*enter)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t serial,
+ struct wl_surface *surface,
+ wl_fixed_t surface_x,
+ wl_fixed_t surface_y);
+ /**
+ * leave event
+ *
+ * Notification that this seat's pointer is no longer focused on
+ * a certain surface.
+ *
+ * The leave notification is sent before the enter notification for
+ * the new focus.
+ * @param serial serial number of the leave event
+ * @param surface surface left by the pointer
+ */
+ void (*leave)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t serial,
+ struct wl_surface *surface);
+ /**
+ * pointer motion event
+ *
+ * Notification of pointer location change. The arguments
+ * surface_x and surface_y are the location relative to the focused
+ * surface.
+ * @param time timestamp with millisecond granularity
+ * @param surface_x surface-local x coordinate
+ * @param surface_y surface-local y coordinate
+ */
+ void (*motion)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t time,
+ wl_fixed_t surface_x,
+ wl_fixed_t surface_y);
+ /**
+ * pointer button event
+ *
+ * Mouse button click and release notifications.
+ *
+ * The location of the click is given by the last motion or enter
+ * event. The time argument is a timestamp with millisecond
+ * granularity, with an undefined base.
+ *
+ * The button is a button code as defined in the Linux kernel's
+ * linux/input-event-codes.h header file, e.g. BTN_LEFT.
+ *
+ * Any 16-bit button code value is reserved for future additions to
+ * the kernel's event code list. All other button codes above
+ * 0xFFFF are currently undefined but may be used in future
+ * versions of this protocol.
+ * @param serial serial number of the button event
+ * @param time timestamp with millisecond granularity
+ * @param button button that produced the event
+ * @param state physical state of the button
+ */
+ void (*button)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t button,
+ uint32_t state);
+ /**
+ * axis event
+ *
+ * Scroll and other axis notifications.
+ *
+ * For scroll events (vertical and horizontal scroll axes), the
+ * value parameter is the length of a vector along the specified
+ * axis in a coordinate space identical to those of motion events,
+ * representing a relative movement along the specified axis.
+ *
+ * For devices that support movements non-parallel to axes multiple
+ * axis events will be emitted.
+ *
+ * When applicable, for example for touch pads, the server can
+ * choose to emit scroll events where the motion vector is
+ * equivalent to a motion event vector.
+ *
+ * When applicable, a client can transform its content relative to
+ * the scroll distance.
+ * @param time timestamp with millisecond granularity
+ * @param axis axis type
+ * @param value length of vector in surface-local coordinate space
+ */
+ void (*axis)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t time,
+ uint32_t axis,
+ wl_fixed_t value);
+ /**
+ * end of a pointer event sequence
+ *
+ * Indicates the end of a set of events that logically belong
+ * together. A client is expected to accumulate the data in all
+ * events within the frame before proceeding.
+ *
+ * All wl_pointer events before a wl_pointer.frame event belong
+ * logically together. For example, in a diagonal scroll motion the
+ * compositor will send an optional wl_pointer.axis_source event,
+ * two wl_pointer.axis events (horizontal and vertical) and finally
+ * a wl_pointer.frame event. The client may use this information to
+ * calculate a diagonal vector for scrolling.
+ *
+ * When multiple wl_pointer.axis events occur within the same
+ * frame, the motion vector is the combined motion of all events.
+ * When a wl_pointer.axis and a wl_pointer.axis_stop event occur
+ * within the same frame, this indicates that axis movement in one
+ * axis has stopped but continues in the other axis. When multiple
+ * wl_pointer.axis_stop events occur within the same frame, this
+ * indicates that these axes stopped in the same instance.
+ *
+ * A wl_pointer.frame event is sent for every logical event group,
+ * even if the group only contains a single wl_pointer event.
+ * Specifically, a client may get a sequence: motion, frame,
+ * button, frame, axis, frame, axis_stop, frame.
+ *
+ * The wl_pointer.enter and wl_pointer.leave events are logical
+ * events generated by the compositor and not the hardware. These
+ * events are also grouped by a wl_pointer.frame. When a pointer
+ * moves from one surface to another, a compositor should group the
+ * wl_pointer.leave event within the same wl_pointer.frame.
+ * However, a client must not rely on wl_pointer.leave and
+ * wl_pointer.enter being in the same wl_pointer.frame.
+ * Compositor-specific policies may require the wl_pointer.leave
+ * and wl_pointer.enter event being split across multiple
+ * wl_pointer.frame groups.
+ * @since 5
+ */
+ void (*frame)(void *data,
+ struct wl_pointer *wl_pointer);
+ /**
+ * axis source event
+ *
+ * Source information for scroll and other axes.
+ *
+ * This event does not occur on its own. It is sent before a
+ * wl_pointer.frame event and carries the source information for
+ * all events within that frame.
+ *
+ * The source specifies how this event was generated. If the source
+ * is wl_pointer.axis_source.finger, a wl_pointer.axis_stop event
+ * will be sent when the user lifts the finger off the device.
+ *
+ * If the source is wl_pointer.axis_source.wheel,
+ * wl_pointer.axis_source.wheel_tilt or
+ * wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event
+ * may or may not be sent. Whether a compositor sends an axis_stop
+ * event for these sources is hardware-specific and
+ * implementation-dependent; clients must not rely on receiving an
+ * axis_stop event for these scroll sources and should treat scroll
+ * sequences from these scroll sources as unterminated by default.
+ *
+ * This event is optional. If the source is unknown for a
+ * particular axis event sequence, no event is sent. Only one
+ * wl_pointer.axis_source event is permitted per frame.
+ *
+ * The order of wl_pointer.axis_discrete and wl_pointer.axis_source
+ * is not guaranteed.
+ * @param axis_source source of the axis event
+ * @since 5
+ */
+ void (*axis_source)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t axis_source);
+ /**
+ * axis stop event
+ *
+ * Stop notification for scroll and other axes.
+ *
+ * For some wl_pointer.axis_source types, a wl_pointer.axis_stop
+ * event is sent to notify a client that the axis sequence has
+ * terminated. This enables the client to implement kinetic
+ * scrolling. See the wl_pointer.axis_source documentation for
+ * information on when this event may be generated.
+ *
+ * Any wl_pointer.axis events with the same axis_source after this
+ * event should be considered as the start of a new axis motion.
+ *
+ * The timestamp is to be interpreted identical to the timestamp in
+ * the wl_pointer.axis event. The timestamp value may be the same
+ * as a preceding wl_pointer.axis event.
+ * @param time timestamp with millisecond granularity
+ * @param axis the axis stopped with this event
+ * @since 5
+ */
+ void (*axis_stop)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t time,
+ uint32_t axis);
+ /**
+ * axis click event
+ *
+ * Discrete step information for scroll and other axes.
+ *
+ * This event carries the axis value of the wl_pointer.axis event
+ * in discrete steps (e.g. mouse wheel clicks).
+ *
+ * This event is deprecated with wl_pointer version 8 - this event
+ * is not sent to clients supporting version 8 or later.
+ *
+ * This event does not occur on its own, it is coupled with a
+ * wl_pointer.axis event that represents this axis value on a
+ * continuous scale. The protocol guarantees that each
+ * axis_discrete event is always followed by exactly one axis event
+ * with the same axis number within the same wl_pointer.frame. Note
+ * that the protocol allows for other events to occur between the
+ * axis_discrete and its coupled axis event, including other
+ * axis_discrete or axis events. A wl_pointer.frame must not
+ * contain more than one axis_discrete event per axis type.
+ *
+ * This event is optional; continuous scrolling devices like
+ * two-finger scrolling on touchpads do not have discrete steps and
+ * do not generate this event.
+ *
+ * The discrete value carries the directional information. e.g. a
+ * value of -2 is two steps towards the negative direction of this
+ * axis.
+ *
+ * The axis number is identical to the axis number in the
+ * associated axis event.
+ *
+ * The order of wl_pointer.axis_discrete and wl_pointer.axis_source
+ * is not guaranteed.
+ * @param axis axis type
+ * @param discrete number of steps
+ * @since 5
+ */
+ void (*axis_discrete)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t axis,
+ int32_t discrete);
+ /**
+ * axis high-resolution scroll event
+ *
+ * Discrete high-resolution scroll information.
+ *
+ * This event carries high-resolution wheel scroll information,
+ * with each multiple of 120 representing one logical scroll step
+ * (a wheel detent). For example, an axis_value120 of 30 is one
+ * quarter of a logical scroll step in the positive direction, a
+ * value120 of -240 are two logical scroll steps in the negative
+ * direction within the same hardware event. Clients that rely on
+ * discrete scrolling should accumulate the value120 to multiples
+ * of 120 before processing the event.
+ *
+ * The value120 must not be zero.
+ *
+ * This event replaces the wl_pointer.axis_discrete event in
+ * clients supporting wl_pointer version 8 or later.
+ *
+ * Where a wl_pointer.axis_source event occurs in the same
+ * wl_pointer.frame, the axis source applies to this event.
+ *
+ * The order of wl_pointer.axis_value120 and wl_pointer.axis_source
+ * is not guaranteed.
+ * @param axis axis type
+ * @param value120 scroll distance as fraction of 120
+ * @since 8
+ */
+ void (*axis_value120)(void *data,
+ struct wl_pointer *wl_pointer,
+ uint32_t axis,
+ int32_t value120);
+};
+
+/**
+ * @ingroup iface_wl_pointer
+ */
+static inline int
+wl_pointer_add_listener(struct wl_pointer *wl_pointer,
+ const struct wl_pointer_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_pointer,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_POINTER_SET_CURSOR 0
+#define WL_POINTER_RELEASE 1
+
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_ENTER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_LEAVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_MOTION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_BUTTON_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_FRAME_SINCE_VERSION 5
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_SOURCE_SINCE_VERSION 5
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_STOP_SINCE_VERSION 5
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_DISCRETE_SINCE_VERSION 5
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_AXIS_VALUE120_SINCE_VERSION 8
+
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_SET_CURSOR_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_pointer
+ */
+#define WL_POINTER_RELEASE_SINCE_VERSION 3
+
+/** @ingroup iface_wl_pointer */
+static inline void
+wl_pointer_set_user_data(struct wl_pointer *wl_pointer, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_pointer, user_data);
+}
+
+/** @ingroup iface_wl_pointer */
+static inline void *
+wl_pointer_get_user_data(struct wl_pointer *wl_pointer)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_pointer);
+}
+
+static inline uint32_t
+wl_pointer_get_version(struct wl_pointer *wl_pointer)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_pointer);
+}
+
+/** @ingroup iface_wl_pointer */
+static inline void
+wl_pointer_destroy(struct wl_pointer *wl_pointer)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_pointer);
+}
+
+/**
+ * @ingroup iface_wl_pointer
+ *
+ * Set the pointer surface, i.e., the surface that contains the
+ * pointer image (cursor). This request gives the surface the role
+ * of a cursor. If the surface already has another role, it raises
+ * a protocol error.
+ *
+ * The cursor actually changes only if the pointer
+ * focus for this device is one of the requesting client's surfaces
+ * or the surface parameter is the current pointer surface. If
+ * there was a previous surface set with this request it is
+ * replaced. If surface is NULL, the pointer image is hidden.
+ *
+ * The parameters hotspot_x and hotspot_y define the position of
+ * the pointer surface relative to the pointer location. Its
+ * top-left corner is always at (x, y) - (hotspot_x, hotspot_y),
+ * where (x, y) are the coordinates of the pointer location, in
+ * surface-local coordinates.
+ *
+ * On surface.attach requests to the pointer surface, hotspot_x
+ * and hotspot_y are decremented by the x and y parameters
+ * passed to the request. Attach must be confirmed by
+ * wl_surface.commit as usual.
+ *
+ * The hotspot can also be updated by passing the currently set
+ * pointer surface to this request with new values for hotspot_x
+ * and hotspot_y.
+ *
+ * The current and pending input regions of the wl_surface are
+ * cleared, and wl_surface.set_input_region is ignored until the
+ * wl_surface is no longer used as the cursor. When the use as a
+ * cursor ends, the current and pending input regions become
+ * undefined, and the wl_surface is unmapped.
+ *
+ * The serial parameter must match the latest wl_pointer.enter
+ * serial number sent to the client. Otherwise the request will be
+ * ignored.
+ */
+static inline void
+wl_pointer_set_cursor(struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, int32_t hotspot_x, int32_t hotspot_y)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_pointer,
+ WL_POINTER_SET_CURSOR, NULL, wl_proxy_get_version((struct wl_proxy *) wl_pointer), 0, serial, surface, hotspot_x, hotspot_y);
+}
+
+/**
+ * @ingroup iface_wl_pointer
+ *
+ * Using this request a client can tell the server that it is not going to
+ * use the pointer object anymore.
+ *
+ * This request destroys the pointer proxy object, so clients must not call
+ * wl_pointer_destroy() after using this request.
+ */
+static inline void
+wl_pointer_release(struct wl_pointer *wl_pointer)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_pointer,
+ WL_POINTER_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_pointer), WL_MARSHAL_FLAG_DESTROY);
+}
+
+#ifndef WL_KEYBOARD_KEYMAP_FORMAT_ENUM
+#define WL_KEYBOARD_KEYMAP_FORMAT_ENUM
+/**
+ * @ingroup iface_wl_keyboard
+ * keyboard mapping format
+ *
+ * This specifies the format of the keymap provided to the
+ * client with the wl_keyboard.keymap event.
+ */
+enum wl_keyboard_keymap_format {
+ /**
+ * no keymap; client must understand how to interpret the raw keycode
+ */
+ WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP = 0,
+ /**
+ * libxkbcommon compatible, null-terminated string; to determine the xkb keycode, clients must add 8 to the key event keycode
+ */
+ WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 = 1,
+};
+#endif /* WL_KEYBOARD_KEYMAP_FORMAT_ENUM */
+
+#ifndef WL_KEYBOARD_KEY_STATE_ENUM
+#define WL_KEYBOARD_KEY_STATE_ENUM
+/**
+ * @ingroup iface_wl_keyboard
+ * physical key state
+ *
+ * Describes the physical state of a key that produced the key event.
+ */
+enum wl_keyboard_key_state {
+ /**
+ * key is not pressed
+ */
+ WL_KEYBOARD_KEY_STATE_RELEASED = 0,
+ /**
+ * key is pressed
+ */
+ WL_KEYBOARD_KEY_STATE_PRESSED = 1,
+};
+#endif /* WL_KEYBOARD_KEY_STATE_ENUM */
+
+/**
+ * @ingroup iface_wl_keyboard
+ * @struct wl_keyboard_listener
+ */
+struct wl_keyboard_listener {
+ /**
+ * keyboard mapping
+ *
+ * This event provides a file descriptor to the client which can
+ * be memory-mapped in read-only mode to provide a keyboard mapping
+ * description.
+ *
+ * From version 7 onwards, the fd must be mapped with MAP_PRIVATE
+ * by the recipient, as MAP_SHARED may fail.
+ * @param format keymap format
+ * @param fd keymap file descriptor
+ * @param size keymap size, in bytes
+ */
+ void (*keymap)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ uint32_t format,
+ int32_t fd,
+ uint32_t size);
+ /**
+ * enter event
+ *
+ * Notification that this seat's keyboard focus is on a certain
+ * surface.
+ *
+ * The compositor must send the wl_keyboard.modifiers event after
+ * this event.
+ * @param serial serial number of the enter event
+ * @param surface surface gaining keyboard focus
+ * @param keys the currently pressed keys
+ */
+ void (*enter)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ uint32_t serial,
+ struct wl_surface *surface,
+ struct wl_array *keys);
+ /**
+ * leave event
+ *
+ * Notification that this seat's keyboard focus is no longer on a
+ * certain surface.
+ *
+ * The leave notification is sent before the enter notification for
+ * the new focus.
+ *
+ * After this event client must assume that all keys, including
+ * modifiers, are lifted and also it must stop key repeating if
+ * there's some going on.
+ * @param serial serial number of the leave event
+ * @param surface surface that lost keyboard focus
+ */
+ void (*leave)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ uint32_t serial,
+ struct wl_surface *surface);
+ /**
+ * key event
+ *
+ * A key was pressed or released. The time argument is a
+ * timestamp with millisecond granularity, with an undefined base.
+ *
+ * The key is a platform-specific key code that can be interpreted
+ * by feeding it to the keyboard mapping (see the keymap event).
+ *
+ * If this event produces a change in modifiers, then the resulting
+ * wl_keyboard.modifiers event must be sent after this event.
+ * @param serial serial number of the key event
+ * @param time timestamp with millisecond granularity
+ * @param key key that produced the event
+ * @param state physical state of the key
+ */
+ void (*key)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t key,
+ uint32_t state);
+ /**
+ * modifier and group state
+ *
+ * Notifies clients that the modifier and/or group state has
+ * changed, and it should update its local state.
+ * @param serial serial number of the modifiers event
+ * @param mods_depressed depressed modifiers
+ * @param mods_latched latched modifiers
+ * @param mods_locked locked modifiers
+ * @param group keyboard layout
+ */
+ void (*modifiers)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ uint32_t serial,
+ uint32_t mods_depressed,
+ uint32_t mods_latched,
+ uint32_t mods_locked,
+ uint32_t group);
+ /**
+ * repeat rate and delay
+ *
+ * Informs the client about the keyboard's repeat rate and delay.
+ *
+ * This event is sent as soon as the wl_keyboard object has been
+ * created, and is guaranteed to be received by the client before
+ * any key press event.
+ *
+ * Negative values for either rate or delay are illegal. A rate of
+ * zero will disable any repeating (regardless of the value of
+ * delay).
+ *
+ * This event can be sent later on as well with a new value if
+ * necessary, so clients should continue listening for the event
+ * past the creation of wl_keyboard.
+ * @param rate the rate of repeating keys in characters per second
+ * @param delay delay in milliseconds since key down until repeating starts
+ * @since 4
+ */
+ void (*repeat_info)(void *data,
+ struct wl_keyboard *wl_keyboard,
+ int32_t rate,
+ int32_t delay);
+};
+
+/**
+ * @ingroup iface_wl_keyboard
+ */
+static inline int
+wl_keyboard_add_listener(struct wl_keyboard *wl_keyboard,
+ const struct wl_keyboard_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_keyboard,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_KEYBOARD_RELEASE 0
+
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_KEYMAP_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_ENTER_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_LEAVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_KEY_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_MODIFIERS_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION 4
+
+/**
+ * @ingroup iface_wl_keyboard
+ */
+#define WL_KEYBOARD_RELEASE_SINCE_VERSION 3
+
+/** @ingroup iface_wl_keyboard */
+static inline void
+wl_keyboard_set_user_data(struct wl_keyboard *wl_keyboard, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_keyboard, user_data);
+}
+
+/** @ingroup iface_wl_keyboard */
+static inline void *
+wl_keyboard_get_user_data(struct wl_keyboard *wl_keyboard)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_keyboard);
+}
+
+static inline uint32_t
+wl_keyboard_get_version(struct wl_keyboard *wl_keyboard)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_keyboard);
+}
+
+/** @ingroup iface_wl_keyboard */
+static inline void
+wl_keyboard_destroy(struct wl_keyboard *wl_keyboard)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_keyboard);
+}
+
+/**
+ * @ingroup iface_wl_keyboard
+ */
+static inline void
+wl_keyboard_release(struct wl_keyboard *wl_keyboard)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_keyboard,
+ WL_KEYBOARD_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_keyboard), WL_MARSHAL_FLAG_DESTROY);
+}
+
+/**
+ * @ingroup iface_wl_touch
+ * @struct wl_touch_listener
+ */
+struct wl_touch_listener {
+ /**
+ * touch down event and beginning of a touch sequence
+ *
+ * A new touch point has appeared on the surface. This touch
+ * point is assigned a unique ID. Future events from this touch
+ * point reference this ID. The ID ceases to be valid after a touch
+ * up event and may be reused in the future.
+ * @param serial serial number of the touch down event
+ * @param time timestamp with millisecond granularity
+ * @param surface surface touched
+ * @param id the unique ID of this touch point
+ * @param x surface-local x coordinate
+ * @param y surface-local y coordinate
+ */
+ void (*down)(void *data,
+ struct wl_touch *wl_touch,
+ uint32_t serial,
+ uint32_t time,
+ struct wl_surface *surface,
+ int32_t id,
+ wl_fixed_t x,
+ wl_fixed_t y);
+ /**
+ * end of a touch event sequence
+ *
+ * The touch point has disappeared. No further events will be
+ * sent for this touch point and the touch point's ID is released
+ * and may be reused in a future touch down event.
+ * @param serial serial number of the touch up event
+ * @param time timestamp with millisecond granularity
+ * @param id the unique ID of this touch point
+ */
+ void (*up)(void *data,
+ struct wl_touch *wl_touch,
+ uint32_t serial,
+ uint32_t time,
+ int32_t id);
+ /**
+ * update of touch point coordinates
+ *
+ * A touch point has changed coordinates.
+ * @param time timestamp with millisecond granularity
+ * @param id the unique ID of this touch point
+ * @param x surface-local x coordinate
+ * @param y surface-local y coordinate
+ */
+ void (*motion)(void *data,
+ struct wl_touch *wl_touch,
+ uint32_t time,
+ int32_t id,
+ wl_fixed_t x,
+ wl_fixed_t y);
+ /**
+ * end of touch frame event
+ *
+ * Indicates the end of a set of events that logically belong
+ * together. A client is expected to accumulate the data in all
+ * events within the frame before proceeding.
+ *
+ * A wl_touch.frame terminates at least one event but otherwise no
+ * guarantee is provided about the set of events within a frame. A
+ * client must assume that any state not updated in a frame is
+ * unchanged from the previously known state.
+ */
+ void (*frame)(void *data,
+ struct wl_touch *wl_touch);
+ /**
+ * touch session cancelled
+ *
+ * Sent if the compositor decides the touch stream is a global
+ * gesture. No further events are sent to the clients from that
+ * particular gesture. Touch cancellation applies to all touch
+ * points currently active on this client's surface. The client is
+ * responsible for finalizing the touch points, future touch points
+ * on this surface may reuse the touch point ID.
+ */
+ void (*cancel)(void *data,
+ struct wl_touch *wl_touch);
+ /**
+ * update shape of touch point
+ *
+ * Sent when a touchpoint has changed its shape.
+ *
+ * This event does not occur on its own. It is sent before a
+ * wl_touch.frame event and carries the new shape information for
+ * any previously reported, or new touch points of that frame.
+ *
+ * Other events describing the touch point such as wl_touch.down,
+ * wl_touch.motion or wl_touch.orientation may be sent within the
+ * same wl_touch.frame. A client should treat these events as a
+ * single logical touch point update. The order of wl_touch.shape,
+ * wl_touch.orientation and wl_touch.motion is not guaranteed. A
+ * wl_touch.down event is guaranteed to occur before the first
+ * wl_touch.shape event for this touch ID but both events may occur
+ * within the same wl_touch.frame.
+ *
+ * A touchpoint shape is approximated by an ellipse through the
+ * major and minor axis length. The major axis length describes the
+ * longer diameter of the ellipse, while the minor axis length
+ * describes the shorter diameter. Major and minor are orthogonal
+ * and both are specified in surface-local coordinates. The center
+ * of the ellipse is always at the touchpoint location as reported
+ * by wl_touch.down or wl_touch.move.
+ *
+ * This event is only sent by the compositor if the touch device
+ * supports shape reports. The client has to make reasonable
+ * assumptions about the shape if it did not receive this event.
+ * @param id the unique ID of this touch point
+ * @param major length of the major axis in surface-local coordinates
+ * @param minor length of the minor axis in surface-local coordinates
+ * @since 6
+ */
+ void (*shape)(void *data,
+ struct wl_touch *wl_touch,
+ int32_t id,
+ wl_fixed_t major,
+ wl_fixed_t minor);
+ /**
+ * update orientation of touch point
+ *
+ * Sent when a touchpoint has changed its orientation.
+ *
+ * This event does not occur on its own. It is sent before a
+ * wl_touch.frame event and carries the new shape information for
+ * any previously reported, or new touch points of that frame.
+ *
+ * Other events describing the touch point such as wl_touch.down,
+ * wl_touch.motion or wl_touch.shape may be sent within the same
+ * wl_touch.frame. A client should treat these events as a single
+ * logical touch point update. The order of wl_touch.shape,
+ * wl_touch.orientation and wl_touch.motion is not guaranteed. A
+ * wl_touch.down event is guaranteed to occur before the first
+ * wl_touch.orientation event for this touch ID but both events may
+ * occur within the same wl_touch.frame.
+ *
+ * The orientation describes the clockwise angle of a touchpoint's
+ * major axis to the positive surface y-axis and is normalized to
+ * the -180 to +180 degree range. The granularity of orientation
+ * depends on the touch device, some devices only support binary
+ * rotation values between 0 and 90 degrees.
+ *
+ * This event is only sent by the compositor if the touch device
+ * supports orientation reports.
+ * @param id the unique ID of this touch point
+ * @param orientation angle between major axis and positive surface y-axis in degrees
+ * @since 6
+ */
+ void (*orientation)(void *data,
+ struct wl_touch *wl_touch,
+ int32_t id,
+ wl_fixed_t orientation);
+};
+
+/**
+ * @ingroup iface_wl_touch
+ */
+static inline int
+wl_touch_add_listener(struct wl_touch *wl_touch,
+ const struct wl_touch_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_touch,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_TOUCH_RELEASE 0
+
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_DOWN_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_UP_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_MOTION_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_FRAME_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_CANCEL_SINCE_VERSION 1
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_SHAPE_SINCE_VERSION 6
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_ORIENTATION_SINCE_VERSION 6
+
+/**
+ * @ingroup iface_wl_touch
+ */
+#define WL_TOUCH_RELEASE_SINCE_VERSION 3
+
+/** @ingroup iface_wl_touch */
+static inline void
+wl_touch_set_user_data(struct wl_touch *wl_touch, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_touch, user_data);
+}
+
+/** @ingroup iface_wl_touch */
+static inline void *
+wl_touch_get_user_data(struct wl_touch *wl_touch)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_touch);
+}
+
+static inline uint32_t
+wl_touch_get_version(struct wl_touch *wl_touch)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_touch);
+}
+
+/** @ingroup iface_wl_touch */
+static inline void
+wl_touch_destroy(struct wl_touch *wl_touch)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_touch);
+}
+
+/**
+ * @ingroup iface_wl_touch
+ */
+static inline void
+wl_touch_release(struct wl_touch *wl_touch)
+{
+ wl_proxy_marshal_flags((struct wl_proxy *) wl_touch,
+ WL_TOUCH_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) wl_touch), WL_MARSHAL_FLAG_DESTROY);
+}
+
+#ifndef WL_OUTPUT_SUBPIXEL_ENUM
+#define WL_OUTPUT_SUBPIXEL_ENUM
+/**
+ * @ingroup iface_wl_output
+ * subpixel geometry information
+ *
+ * This enumeration describes how the physical
+ * pixels on an output are laid out.
+ */
+enum wl_output_subpixel {
+ /**
+ * unknown geometry
+ */
+ WL_OUTPUT_SUBPIXEL_UNKNOWN = 0,
+ /**
+ * no geometry
+ */
+ WL_OUTPUT_SUBPIXEL_NONE = 1,
+ /**
+ * horizontal RGB
+ */
+ WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB = 2,
+ /**
+ * horizontal BGR
+ */
+ WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR = 3,
+ /**
+ * vertical RGB
+ */
+ WL_OUTPUT_SUBPIXEL_VERTICAL_RGB = 4,
+ /**
+ * vertical BGR
+ */
+ WL_OUTPUT_SUBPIXEL_VERTICAL_BGR = 5,
+};
+#endif /* WL_OUTPUT_SUBPIXEL_ENUM */
+
+#ifndef WL_OUTPUT_TRANSFORM_ENUM
+#define WL_OUTPUT_TRANSFORM_ENUM
+/**
+ * @ingroup iface_wl_output
+ * transform from framebuffer to output
+ *
+ * This describes the transform that a compositor will apply to a
+ * surface to compensate for the rotation or mirroring of an
+ * output device.
+ *
+ * The flipped values correspond to an initial flip around a
+ * vertical axis followed by rotation.
+ *
+ * The purpose is mainly to allow clients to render accordingly and
+ * tell the compositor, so that for fullscreen surfaces, the
+ * compositor will still be able to scan out directly from client
+ * surfaces.
+ */
+enum wl_output_transform {
+ /**
+ * no transform
+ */
+ WL_OUTPUT_TRANSFORM_NORMAL = 0,
+ /**
+ * 90 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_90 = 1,
+ /**
+ * 180 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_180 = 2,
+ /**
+ * 270 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_270 = 3,
+ /**
+ * 180 degree flip around a vertical axis
+ */
+ WL_OUTPUT_TRANSFORM_FLIPPED = 4,
+ /**
+ * flip and rotate 90 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_FLIPPED_90 = 5,
+ /**
+ * flip and rotate 180 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_FLIPPED_180 = 6,
+ /**
+ * flip and rotate 270 degrees counter-clockwise
+ */
+ WL_OUTPUT_TRANSFORM_FLIPPED_270 = 7,
+};
+#endif /* WL_OUTPUT_TRANSFORM_ENUM */
+
+#ifndef WL_OUTPUT_MODE_ENUM
+#define WL_OUTPUT_MODE_ENUM
+/**
+ * @ingroup iface_wl_output
+ * mode information
+ *
+ * These flags describe properties of an output mode.
+ * They are used in the flags bitfield of the mode event.
+ */
+enum wl_output_mode {
+ /**
+ * indicates this is the current mode
+ */
+ WL_OUTPUT_MODE_CURRENT = 0x1,
+ /**
+ * indicates this is the preferred mode
+ */
+ WL_OUTPUT_MODE_PREFERRED = 0x2,
+};
+#endif /* WL_OUTPUT_MODE_ENUM */
+
+/**
+ * @ingroup iface_wl_output
+ * @struct wl_output_listener
+ */
+struct wl_output_listener {
+ /**
+ * properties of the output
+ *
+ * The geometry event describes geometric properties of the
+ * output. The event is sent when binding to the output object and
+ * whenever any of the properties change.
+ *
+ * The physical size can be set to zero if it doesn't make sense
+ * for this output (e.g. for projectors or virtual outputs).
+ *
+ * The geometry event will be followed by a done event (starting
+ * from version 2).
+ *
+ * Note: wl_output only advertises partial information about the
+ * output position and identification. Some compositors, for
+ * instance those not implementing a desktop-style output layout or
+ * those exposing virtual outputs, might fake this information.
+ * Instead of using x and y, clients should use
+ * xdg_output.logical_position. Instead of using make and model,
+ * clients should use name and description.
+ * @param x x position within the global compositor space
+ * @param y y position within the global compositor space
+ * @param physical_width width in millimeters of the output
+ * @param physical_height height in millimeters of the output
+ * @param subpixel subpixel orientation of the output
+ * @param make textual description of the manufacturer
+ * @param model textual description of the model
+ * @param transform transform that maps framebuffer to output
+ */
+ void (*geometry)(void *data,
+ struct wl_output *wl_output,
+ int32_t x,
+ int32_t y,
+ int32_t physical_width,
+ int32_t physical_height,
+ int32_t subpixel,
+ const char *make,
+ const char *model,
+ int32_t transform);
+ /**
+ * advertise available modes for the output
+ *
+ * The mode event describes an available mode for the output.
+ *
+ * The event is sent when binding to the output o