• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ANGLE Development
2
3ANGLE provides OpenGL ES 2.0 and EGL 1.4 libraries and dlls.  You can use these to build and run OpenGL ES 2.0 applications on Windows, Linux, Mac and Android.
4
5## Development setup
6
7### Version Control
8ANGLE uses git for version control. If you are not familiar with git, helpful documentation can be found at [http://git-scm.com/documentation](http://git-scm.com/documentation).
9
10### Required Tools
11On all platforms:
12
13 * GN is the build system.  GYP support has been removed.
14 * Clang will be set up by the build system and used by default.  See below for platform-specific compiler choices.
15 * [depot_tools](http://dev.chromium.org/developers/how-tos/install-depot-tools)
16   * Required to generate projects and build files, contribute patches, run the unit tests or build the shader compiler on non-Windows systems.
17
18On Windows:
19
20 * [Visual Studio Community 2017 Update 3.2](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes)
21   * Put `is_clang = false` in your gn args to compile with the Microsoft Visual C++ compiler instead of clang.
22   * See the [Chromium Windows build instructions](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md) for more info.
23   * Required for the packaged Windows 10 SDK.
24 * [Windows 10 Standalone SDK version 10.0.17134 exactly](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk).
25   * Comes with additional features that aid development, such as the Debug runtime for D3D11. Required for the D3D Compiler DLL.
26 * [Cygwin's Bison, flex, and patch](https://cygwin.com/setup-x86_64.exe) (optional)
27   * This is only required if you need to modify GLSL ES grammar files (`glslang.l` and `glslang.y` under `src/compiler/translator`, or `ExpressionParser.y` and `Tokenizer.l` in `src/compiler/preprocessor`).
28     Use the latest versions of bison, flex and patch from the 64-bit cygwin distribution.
29 * **IMPORTANT**: Non-googlers need to set `DEPOT_TOOLS_WIN_TOOLCHAIN` environment variable to 0.
30
31On Linux:
32
33 * Development packages for OpenGL, X11 and libpci (all of these dependencies should be installed automatically when running `install-build-deps.sh` later on).
34 * Bison and flex are not needed as we only support generating the translator grammar on Windows.
35
36On MacOS:
37
38 * [XCode](https://developer.apple.com/xcode/) for Clang and development files.
39 * Bison and flex are not needed as we only support generating the translator grammar on Windows.
40
41### Getting the source
42
43```
44git clone https://chromium.googlesource.com/angle/angle
45cd angle
46python scripts/bootstrap.py
47gclient sync
48git checkout master
49```
50
51On Linux only, you need to install all the necessary dependencies before going further by running this command:
52```
53./build/install-build-deps.sh
54```
55
56After this completes successfully, you are ready to generate the ninja files:
57```
58gn gen out/Debug
59```
60
61GN will generate ninja files by default.  To change the default build options run `gn args out/Debug`.  Some commonly used options are:
62```
63target_cpu = "x64"  (or "x86")
64is_clang = false    (to use system default compiler instead of clang)
65is_debug = true     (enable debugging, true is the default)
66```
67For a release build run `gn args out/Release` and set `is_debug = false`.
68
69For more information on GN run `gn help`.
70
71Ninja can be used to compile on all platforms with one of the following commands:
72```
73ninja -C out/Debug
74ninja -C out/Release
75```
76Ninja automatically calls GN to regenerate the build files on any configuration change.
77Ensure `depot_tools` is in your path as it provides ninja.
78
79### Building with Visual Studio
80
81To generate the Visual Studio solution in `out/Debug/angle-debug.sln`:
82```
83gn gen out/Debug --sln=angle-debug --ide=vs<2017/2019>
84```
85
86In Visual Studio:
87 1. Open the ANGLE solution file `out/Debug/angle-debug.sln`.
88 2. Right click the "all" solution and select build.  "Build Solution" is not functional with GN; instead build one target at a time."
89
90Once the build completes all ANGLE libraries, tests, and samples will be located in out/Debug.
91
92### Building ANGLE for Android
93Building ANGLE for Android is heavily dependent on the Chromium toolchain. It is not currently possible to build ANGLE for Android without a Chromium checkout. See http://anglebug.com/2344 for more details on why.
94Please follow the steps in
95[Checking out and building Chromium for Android](https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md).
96This must be done on Linux, the only platform that Chromium for Android supports.
97Name your output directories `out/Debug` and `out/Release`, because Chromium GPU tests look for browser binaries in these folders. Replacing `out` with other names seems to be OK when working with multiple build configurations.
98It's best to use a build configuration of some Android bot on [GPU.FYI waterfall](https://ci.chromium.org/p/chromium/g/chromium.gpu.fyi/console). Look for `generate_build_files` step output of that bot. Remove `goma_dir` flag.
99For example, these are the build flags from Nexus 5X bot:
100```
101build_angle_deqp_tests = true
102dcheck_always_on = true
103ffmpeg_branding = "Chrome"
104is_component_build = false
105is_debug = false
106proprietary_codecs = true
107symbol_level = 1
108target_cpu = "arm64"          # Nexus 5X is 64 bit, remove this on 32 bit devices
109target_os = "android"
110use_goma = true               # Remove this if you don't have goma
111```
112Additional flags to build the Vulkan backend, enable only if running on Android O or higher:
113```
114android32_ndk_api_level = 26
115android64_ndk_api_level = 26
116```
117
118These ANGLE targets are supported:
119`ninja -C out/Release translator libEGL libGLESv2 angle_unittests angle_end2end_tests angle_white_box_tests angle_deqp_gles2_tests angle_deqp_gles3_tests angle_deqp_egl_tests angle_perftests angle_white_box_perftests`
120
121In order to run ANGLE tests, prepend `bin/run_` to the test name, for example: `./out/Release/bin/run_angle_unittests`.
122Additional details are in [Android Test Instructions](https://chromium.googlesource.com/chromium/src/+/master/docs/testing/android_test_instructions.md).
123
124**dEQP Note**: Running the tests not using the test runner is tricky, but is necessary in order to get a complete TestResults.qpa from the dEQP tests (since the runner shards the tests, only the results of the last shard will be available when using the test runner). First, use the runner to install the APK, test data and test expectations on the device. After the tests start running, the test runner can be stopped with Ctrl+C. Then, run
125```
126adb shell am start -a android.intent.action.MAIN -n org.chromium.native_test/.NativeUnitTestNativeActivity -e org.chromium.native_test.NativeTest.StdoutFile /sdcard/chromium_tests_root/out.txt
127```
128After the tests finish, get the results with
129```
130adb pull /sdcard/chromium_tests_root/third_party/angle/third_party/deqp/src/data/TestResults.qpa .
131```
132Note: this location might change, one can double-check with `adb logcat -d | grep qpa`.
133
134In order to run GPU telemetry tests, build `chrome_public_apk` target. Then follow [GPU Testing](http://www.chromium.org/developers/testing/gpu-testing#TOC-Running-the-GPU-Tests-Locally) doc, using `--browser=android-chromium` argument. Make sure to set your `CHROMIUM_OUT_DIR` environment variable, so that your browser is found, otherwise the stock one will run.
135
136Also, follow [How to build ANGLE in Chromium for dev](BuildingAngleForChromiumDevelopment.md) to work with Top of Tree ANGLE in Chromium.
137
138## Application Development with ANGLE
139This sections describes how to use ANGLE to build an OpenGL ES application.
140
141### Choosing a Backend
142ANGLE can use a variety of backing renderers based on platform.  On Windows, it defaults to D3D11 where it's available,
143or D3D9 otherwise.  On other desktop platforms, it defaults to GL.  On mobile, it defaults to GLES.
144
145ANGLE provides an EGL extension called `EGL_ANGLE_platform_angle` which allows uers to select which renderer to use at EGL initialization time by calling eglGetPlatformDisplayEXT with special enums. Details of the extension can be found in it's specification in `extensions/ANGLE_platform_angle.txt` and `extensions/ANGLE_platform_angle_*.txt` and examples of it's use can be seen in the ANGLE samples and tests, particularly `util/EGLWindow.cpp`.
146
147To change the default D3D backend:
148
149 1. Open `src/libANGLE/renderer/d3d/DisplayD3D.cpp`
150 2. Locate the definition of `ANGLE_DEFAULT_D3D11` near the head of the file, and set it to your preference.
151
152### To Use ANGLE in Your Application
153On Windows:
154
155 1. Configure your build environment to have access to the `include` folder to provide access to the standard Khronos EGL and GLES2 header files.
156  * For Visual C++
157     * Right-click your project in the _Solution Explorer_, and select _Properties_.
158     * Under the _Configuration Properties_ branch, click _C/C++_.
159     * Add the relative path to the Khronos EGL and GLES2 header files to _Additional Include Directories_.
160 2. Configure your build environment to have access to `libEGL.lib` and `libGLESv2.lib` found in the build output directory (see [Building ANGLE](#building-with-visual-studio)).
161   * For Visual C++
162     * Right-click your project in the _Solution Explorer_, and select _Properties_.
163     * Under the _Configuration Properties_ branch, open the _Linker_ branch and click _Input_.
164     * Add the relative paths to both the `libEGL.lib` file and `libGLESv2.lib` file to _Additional Dependencies_, separated by a semicolon.
165 3. Copy `libEGL.dll` and `libGLESv2.dll` from the build output directory (see [Building ANGLE](#building-with-visual-studio)) into your application folder.
166 4. Code your application to the Khronos [OpenGL ES 2.0](http://www.khronos.org/registry/gles/) and [EGL 1.4](http://www.khronos.org/registry/egl/) APIs.
167
168On Linux and MacOS, either:
169
170 - Link you application against `libGLESv2` and `libEGL`
171 - Use `dlopen` to load the OpenGL ES and EGL entry points at runtime.
172
173## GLSL ES to GLSL Translator
174In addition to OpenGL ES 2.0 and EGL 1.4 libraries, ANGLE also provides a GLSL ES to GLSL translator. This is useful for implementing OpenGL ES emulators on top of desktop OpenGL.
175
176### Source and Building
177The translator code is included with ANGLE but fully independent; it resides in `src/compiler`.
178Follow the steps above for [getting and building ANGLE](#getting-the-source) to build the translator on the platform of your choice.
179
180### Usage
181The basic usage is shown in `essl_to_glsl` sample under `samples/translator`. To translate a GLSL ES shader, following functions need to be called in the same order:
182
183 * `ShInitialize()` initializes the translator library and must be called only once from each process using the translator.
184 * `ShContructCompiler()` creates a translator object for vertex or fragment shader.
185 * `ShCompile()` translates the given shader.
186 * `ShDestruct()` destroys the given translator.
187 * `ShFinalize()` shuts down the translator library and must be called only once from each process using the translator.
188