blob: 1afe3fb590d8d15c8e970ea3470ec874b7e2f91a [file] [log] [blame] [view]
Nicolas Capensa5eaa8d2017-07-26 13:55:52 -04001# SwiftShader
Nicolas Capensc9d61ae2017-06-28 00:58:48 -04002
Nicolas Capens4c50ae92020-07-16 23:23:15 -04003[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Nicolas Capens1703e0f2016-05-12 17:27:05 -04004
Nicolas Capensfe5861b2018-08-03 16:01:48 -04005Introduction
6------------
7
Nicolas Capensf8b99b52020-12-14 01:46:52 -05008SwiftShader is a high-performance CPU-based implementation of the Vulkan graphics API<sup>1</sup><sup>2</sup>. Its goal is to provide hardware independence for advanced 3D graphics.
Antonio Maiorano6f744152020-08-17 11:15:16 -04009
Nicolas Capensc0a055b2022-04-15 01:42:53 -040010> NOTE: The [ANGLE](http://angleproject.org/) project can be used to achieve a layered implementation of OpenGL ES (aka. "SwANGLE").
Nicolas Capens1703e0f2016-05-12 17:27:05 -040011
Nicolas Capensfe5861b2018-08-03 16:01:48 -040012Building
13--------
14
Nicolas Capensf8b99b52020-12-14 01:46:52 -050015SwiftShader libraries can be built for Windows, Linux, and macOS.\
Nicolas Capensfe5861b2018-08-03 16:01:48 -040016Android and Chrome (OS) build environments are also supported.
17
Antonio Maiorano6f744152020-08-17 11:15:16 -040018* **CMake**
19\
Nicolas Capensf8b99b52020-12-14 01:46:52 -050020 [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:
Antonio Maiorano6f744152020-08-17 11:15:16 -040021 ```
22 cd build
23 cmake ..
24 cmake --build . --parallel
25
26 ./vk-unittests
27 ```
Nicolas Capens7776bf02022-10-04 00:30:30 -040028 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.
Nicolas Capensf8b99b52020-12-14 01:46:52 -050029
Antonio Maiorano6f744152020-08-17 11:15:16 -040030
Nicolas Capensfe5861b2018-08-03 16:01:48 -040031* **Visual Studio**
Ben Claytone2d8b122019-02-07 18:13:16 +000032\
Antonio Maiorano6f744152020-08-17 11:15:16 -040033 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.
Nicolas Capensa580e2d2019-10-03 22:40:25 -040034
Nicolas Capens64d537a2018-10-02 12:40:12 -040035
Nicolas Capens1703e0f2016-05-12 17:27:05 -040036Usage
Nicolas Capens9eaa19c2017-06-28 11:13:55 -040037-----
Nicolas Capens1703e0f2016-05-12 17:27:05 -040038
39The SwiftShader libraries act as drop-in replacements for graphics drivers.
40
Antonio Maiorano6f744152020-08-17 11:15:16 -040041On 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.
42
Nicolas Capens4bd7fd22020-11-03 19:46:29 +000043In 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).
Nicolas Capens1703e0f2016-05-12 17:27:05 -040044
45Contributing
Nicolas Capens9eaa19c2017-06-28 11:13:55 -040046------------
Nicolas Capens1703e0f2016-05-12 17:27:05 -040047
Nicolas Capenscf83d162016-07-02 23:41:30 -040048See [CONTRIBUTING.txt](CONTRIBUTING.txt) for important contributing requirements.
Nicolas Capens1703e0f2016-05-12 17:27:05 -040049
Nicolas Capenscf83d162016-07-02 23:41:30 -040050The canonical repository for SwiftShader is hosted at:
Nicolas Capens4ca96302021-07-03 01:25:58 -040051https://swiftshader.googlesource.com/SwiftShader.
Nicolas Capens1703e0f2016-05-12 17:27:05 -040052
Nicolas Capenscf83d162016-07-02 23:41:30 -040053All changes must be reviewed and approved in the [Gerrit](https://www.gerritcodereview.com/) review tool at:
Nicolas Capens51f20362022-01-25 15:56:03 -050054https://swiftshader-review.googlesource.com. You must sign in to this site with a Google Account before changes can be uploaded.
Nicolas Capens1703e0f2016-05-12 17:27:05 -040055
Nicolas Capens51f20362022-01-25 15:56:03 -050056Next, authenticate your account here:
Nicolas Capens4ca96302021-07-03 01:25:58 -040057https://swiftshader-review.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)).
Nicolas Capenscf83d162016-07-02 23:41:30 -040058
Nicolas Capens4ca96302021-07-03 01:25:58 -040059All 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:
60https://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:
Nicolas Capens1703e0f2016-05-12 17:27:05 -040061
Sean Risser3c89f072021-05-27 16:56:09 -040062 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)
Nicolas Capens1703e0f2016-05-12 17:27:05 -040063
Nicolas Capens4ca96302021-07-03 01:25:58 -040064On Windows, this command line requires using the [Git Bash Shell](https://www.atlassian.com/git/tutorials/git-bash).
65
Nicolas Capensfe5861b2018-08-03 16:01:48 -040066Changes are uploaded to Gerrit by executing:
Nicolas Capens1703e0f2016-05-12 17:27:05 -040067
68 git push origin HEAD:refs/for/master
69
Nicolas Capensdb747762020-03-31 12:00:46 -040070When ready, [add](https://gerrit-review.googlesource.com/Documentation/intro-user.html#adding-reviewers) a project [owner](OWNERS) as a reviewer on your change.
71
Nicolas Capensdac99e82020-11-19 04:18:58 +000072Some 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).
Nicolas Capensdb747762020-03-31 12:00:46 -040073
Nicolas Capensfe5861b2018-08-03 16:01:48 -040074Testing
75-------
76
Nicolas Capens02a91c92021-08-20 03:49:24 -040077SwiftShader's Vulkan implementation can be tested using the [dEQP](https://github.com/KhronosGroup/VK-GL-CTS) test suite.
Nicolas Capensfe5861b2018-08-03 16:01:48 -040078
79See [docs/dEQP.md](docs/dEQP.md) for details.
80
Nicolas Capens3532c692017-05-18 11:22:26 -040081Third-Party Dependencies
82------------------------
83
84The [third_party](third_party/) directory contains projects which originated outside of SwiftShader:
85
Nicolas Capensf8b99b52020-12-14 01:46:52 -050086[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.
Nicolas Capens3532c692017-05-18 11:22:26 -040087
88[llvm-subzero](third_party/llvm-subzero/) contains a minimized set of LLVM dependencies of the Subzero project.
89
90[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.
91
92[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.
93
Nicolas Capens63883022016-05-30 11:03:26 -040094Documentation
95-------------
96
Nicolas Capens1bc61382016-05-30 15:29:09 -040097See [docs/Index.md](docs/Index.md).
Nicolas Capens63883022016-05-30 11:03:26 -040098
Nicolas Capens1703e0f2016-05-12 17:27:05 -040099Contact
Nicolas Capens9eaa19c2017-06-28 11:13:55 -0400100-------
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400101
Nicolas Capensd851f232016-08-01 15:36:23 -0400102Public mailing list: [swiftshader@googlegroups.com](https://groups.google.com/forum/#!forum/swiftshader)
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400103
Nicolas Capensb638dfe2020-08-25 13:24:54 +0000104General bug tracker: https://g.co/swiftshaderbugs \
Nicolas Capensdb309b62018-05-22 14:49:35 -0400105Chrome specific bugs: https://bugs.chromium.org/p/swiftshader
Nicolas Capens22b17b02016-06-17 13:39:18 -0400106
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400107License
Nicolas Capens9eaa19c2017-06-28 11:13:55 -0400108-------
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400109
Nicolas Capenscf83d162016-07-02 23:41:30 -0400110The SwiftShader project is licensed under the Apache License Version 2.0. You can find a copy of it in [LICENSE.txt](LICENSE.txt).
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400111
112Files in the third_party folder are subject to their respective license.
113
114Authors and Contributors
Nicolas Capens9eaa19c2017-06-28 11:13:55 -0400115------------------------
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400116
Nicolas Capenscf83d162016-07-02 23:41:30 -0400117The legal authors for copyright purposes are listed in [AUTHORS.txt](AUTHORS.txt).
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400118
Nicolas Capenscf83d162016-07-02 23:41:30 -0400119[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.
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400120
121Disclaimer
Nicolas Capens9eaa19c2017-06-28 11:13:55 -0400122----------
Nicolas Capens1703e0f2016-05-12 17:27:05 -0400123
1241. Trademarks are the property of their respective owners.
Antonio Maiorano6f744152020-08-17 11:15:16 -04001252. This is not an official Google product.