• Home
Name Date Size #Lines LOC

..--

android_gradle/04-Jul-2025-305207

android_sample/04-Jul-2025-521328

android_test/04-Jul-2025-419

docs/04-Jul-2025-2,8702,382

include/amber/04-Jul-2025-634279

kokoro/04-Jul-2025-1,297785

samples/04-Jul-2025-3,5982,771

src/04-Jul-2025-62,72348,922

tests/04-Jul-2025-15,08210,655

third_party/04-Jul-2025-191160

tools/04-Jul-2025-1,5641,034

.clang-formatD04-Jul-202581 32

.gitignoreD04-Jul-2025670 3832

AUTHORSD04-Jul-2025323 97

Android.bpD04-Jul-20253.1 KiB104100

CMakeLists.txtD04-Jul-20258.3 KiB276238

CODE_OF_CONDUCT.mdD04-Jul-20254.4 KiB9473

CONTRIBUTING.mdD04-Jul-20251.1 KiB2920

CPPLINT.cfgD04-Jul-202527 32

DEPSD04-Jul-20253.5 KiB8565

DoxyfileD04-Jul-2025105.8 KiB2,4841,931

LICENSED04-Jul-202511.1 KiB203169

METADATAD04-Jul-202539 43

README.mdD04-Jul-202512.3 KiB396302

framebuffer.pngD04-Jul-20253.8 KiB

license-checker.cfgD04-Jul-20251.3 KiB4541

setup_debug_local.envD04-Jul-2025724 1815

README.md

1# Amber
2
3Amber is a multi-API shader test framework.
4
5Amber lets you capture and communicate shader bugs with the fluidity and ease of
6a scripting flow:
7
8* No graphics API programming is required.
9  * Supports Vulkan graphics API
10  * WIP: Supports [Dawn][Dawn] graphics API
11* A single text string (or file) maps to a single graphics API pipeline test
12  case. The text includes:
13  * Input data, including buffers and images.
14  * Shaders.
15  * Expectations for the result of running the pipeline.
16* Shaders can be expressed in binary form (as hex), in SPIR-V assembly, or in a
17  higher level shader language.
18* After executing the pipeline, result buffers and images can be saved to output
19  files.
20
21Amber is influenced by [Talvos][Talvos] and [VkRunner][VkRunner].
22The [VkScript](docs/vk_script.md) syntax matches the format used by VkRunner.
23
24This is not an officially supported Google product.
25
26## Writing Amber Tests
27Working with Amber involves writing input test files. Some example files can be
28see in the [tests/cases](tests/cases) folder.
29
30The main input format is [Amberscript](docs/amber_script.md). New features are
31added to AmberScript as Amber is enhanced. This is the preferred format in which
32new script files are written.
33
34### Clear test as AmberScript
35
36```groovy
37SHADER vertex vtex_shader PASSTHROUGH
38SHADER fragment frag_shader GLSL
39#version 430
40
41layout(location = 0) in vec4 color_in;
42layout(location = 0) out vec4 color_out;
43
44void main() {
45  color_out = color_in;
46}
47END
48
49BUFFER img_buf FORMAT B8G8R8A8_UNORM
50
51PIPELINE graphics my_pipeline
52  ATTACH vtex_shader
53  ATTACH frag_shader
54
55  FRAMEBUFFER_SIZE 256 256
56  BIND BUFFER img_buf AS color LOCATION 0
57END
58
59CLEAR my_pipeline
60EXPECT img_buf IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 0
61```
62
63The [VkScript](docs/vk_script.md) format is supported for historic reasons. It
64is based off, and very closely matches, the format accepted by VkRunner. There
65are no new features being added to VkScript, it is for historical use.
66
67### Clear test as VkScript
68
69```
70[require]
71VK_KHR_get_physical_device_properties2
72
73[vertex shader passthrough]
74
75[fragment shader]
76#version 430
77
78layout(location = 0) in vec4 color_in;
79layout(location = 0) out vec4 color_out;
80
81void main() {
82  color_out = color_in;
83}
84
85[test]
86clear
87relative probe rect rgba (0.0, 0.0, 1.0, 1.0) (0, 0, 0, 0)
88```
89
90## Requirements
91
92 * Recommended: Configure at least one backend. See [Backends](#backends) below.
93 * Git
94 * CMake (version 3.7+ enables automatic discovery of an installed Vulkan SDK)
95 * Ninja (or other build tool)
96 * Python3, for fetching dependencies and building Vulkan wrappers
97
98
99## Building
100```
101git clone https://github.com/google/amber.git
102cd amber
103./tools/git-sync-deps
104mkdir -p out/Debug
105cd out/Debug
106cmake -GNinja ../..
107ninja
108```
109
110Alternatives:
111
112* On Windows, Amber normally statically links against the C runtime library.
113  To override this and link against a shared C runtime, CMake option
114  `-DAMBER_ENABLE_SHARED_CRT`.
115  This will cause Amber to be built with `/MD` for release builds or `/MDd` for
116  debug builds.
117
118### Android
119
120* Android build needs Android SDK 28, Android NDK r25b, Java 8. If you prefer
121  other versions of Android SDK, Android NDK, Java, then you can change
122  `ANDROID_PLATFORM` and `ANDROID_BUILD_TOOL_VERSION` in
123  `tools/build-amber-sample.sh`.
124* Set up Android SDK path by running
125  `export ANDROID_SDK_HOME=path/to/Android/SDK` in your shell.
126* Set up Android NDK path by running
127  `export ANDROID_NDK_HOME=path/to/Android/NDK` in your shell.
128* Generate a KeyStore using `keytool` command and set up `KEY_STORE_PATH`
129  env variable for the KeyStore file path.
130* Run `./tools/build-amber-sample.sh [build output directory path]`.
131
132#### Android plain executable
133
134It is possible to obtain a plain executable for Android, as opposed to an APK,
135with the following:
136
137```
138git clone https://github.com/google/amber.git
139cd amber
140./tools/git-sync-deps
141
142./tools/update_build_version.py . samples/ third_party/
143./tools/update_vk_wrappers.py . .
144
145mkdir build
146cd build
147mkdir app
148mkdir libs
149${ANDROID_NDK_HOME}/ndk-build -C ../samples NDK_PROJECT_PATH=. NDK_LIBS_OUT=`pwd`/libs NDK_APP_OUT=`pwd`/app
150```
151
152The list of target ABIs can be configured in `samples/jni/Application.mk` by
153editing the APP_ABI entry:
154
155```
156APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
157```
158
159The resulting executable will be produced as
160`build/app/local/<abi>/amber_ndk`. This executable can be run via the adb shell
161on your device, e.g. under `/data/local/tmp` (`/sdcard` is generally not
162suitable because it is mounted with a non-executable flag). Also, vulkan layers
163may not be available to this executable as it is not an app, so make sure to use
164the `-d` flag to disable Vulkan layers:
165
166```
167adb push build/app/local/<abi>/amber_ndk /data/local/tmp
168adb shell
169# Now on device shell
170cd /data/local/tmp
171./amber_ndk -d <shader-test-files>
172```
173
174### ChromeOS plain executable (not officially supported)
175
176It is possible to obtain produce a cross compiled amber binary for ChromeOS.
177Start with the standard amber checkout
178```
179git clone https://github.com/google/amber.git
180cd amber
181./tools/git-sync-deps
182./tools/update_build_version.py . samples/ third_party/
183./tools/update_vk_wrappers.py . .
184```
185
186Then add the cmake cross compiling variable to the root amber /CMakeLists.txt
187
188The example ChromeOS platform used here is trogdor.
189
190```
191# Top of CMakeLists.txt file
192cmake_minimum_required(VERSION 3.13)
193
194set(CMAKE_SYSTEM_NAME Linux)
195# The example processor here is 64 bit arm
196set(CMAKE_SYSTEM_PROCESSOR aarch64)
197
198set(CMAKE_SYSROOT "$ENV{HOME}/chromium/src/build/cros_cache/chrome-sdk/symlinks/trogdor+16074.0.0-1064250+sysroot_chromeos-base_chromeos-chrome.tar.xz/")
199
200set(tools "$ENV{HOME}/chromium/src/build/cros_cache/chrome-sdk/symlinks/trogdor+16074.0.0-1064250+target_toolchain")
201set(CMAKE_C_COMPILER ${tools}/bin/aarch64-cros-linux-gnu-gcc)
202set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-cros-linux-gnu-g++)
203
204set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
205set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
206set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
207set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
208# To avoid having the host try to execute a cross compiled binary 'asm_offset'
209set(USE_GAS OFF)
210
211```
212We statically link c++ to avoid missing libstdc++.so.X
213
214Replace these lines
215```
216  if (NOT ${AMBER_ENABLE_SHARED_CRT})
217    # For MinGW cross compile, statically link to the C++ runtime.
218    # But it still depends on MSVCRT.dll.
219    if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
220      if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
221	set_target_properties(${TARGET} PROPERTIES LINK_FLAGS
222	  -static
223	  -static-libgcc
224	  -static-libstdc++)
225      endif()
226    endif()
227  endif()
228
229```
230With this line.
231```
232	set_target_properties(${TARGET} PROPERTIES LINK_FLAGS -static-libstdc++)
233```
234
235Finally we can build and deploy the amber binary.
236
237```
238mkdir -p out/Debug
239cd out/Debug
240cmake -GNinja ../..  -DAMBER_USE_LOCAL_VULKAN=1
241ninja amber
242# Copy over the amber binary to the DUT (note the root disk partion has limited space)
243scp amber device:/root/amber
244# An example of how to copy over some amber scripts
245scp ../../tests/cases/* device:/root/
246
247```
248Now by ssh-ing into the DUT you can locally run any amber script. Also, vulkan layers
249may not be available to this executable, so make sure to use the `-d` flag to disable
250Vulkan layers.
251
252### Optional components
253
254The components which build up Amber can be enabled or disabled as needed. Any
255option with `_SKIP_` in the name is on by default, any with `_USE_` is off by
256default.
257
258The available flags which can be defined are:
259 * AMBER_SKIP_TESTS -- Skip building Amber unit tests
260 * AMBER_SKIP_SAMPLES -- Skip building the Amber sample applications
261 * AMBER_SKIP_SPIRV_TOOLS -- Disable the SPIRV-Tools integration
262 * AMBER_SKIP_SHADERC -- Disable the ShaderC integration
263 * AMBER_SKIP_LODEPNG -- Disable the LodePNG integration
264 * AMBER_USE_DXC -- Enables DXC as a shader compiler
265 * AMBER_USE_LOCAL_VULKAN -- Does not try to find the Vulkan SDK, builds needed
266                             components locally
267 * AMBER_USE_CLSPV -- Enables CLSPV as a shader compiler
268 * AMBER_USE_SWIFTSHADER -- Builds Swiftshader so it can be used as a Vulkan ICD
269
270```
271cmake -DAMBER_SKIP_TESTS=True -DAMBER_SKIP_SPIRV_TOOLS=True -GNinja ../..
272```
273
274#### DXC
275
276DXC can be enabled in Amber by adding the `-DAMBER_USE_DXC=true` flag when
277running cmake.
278
279## Build Bots
280
281There are a number of build bots to verify Amber continues to compile and run
282on the various targets. Due to bot limitations, the integration tests are not
283being run on the bots, just the unit tests.
284
285## Backends
286
287Amber is designed to run against different graphics APIs.
288Amber will build if no graphics API is found, but will only allow verifying the
289syntax of the amber script files.
290
291Currently the Vulkan and Dawn graphics APIs are supported.
292
293### Using Vulkan as a backend
294
295A Vulkan implementation is found by CMake in the following priority order:
296
297 * If `AMBER_USE_LOCAL_VULKAN` is enable the headers, loader and layers will be
298   built locally and not found on the system.
299 * If an enclosing CMake project includes the
300   [Vulkan-Headers][Vulkan-Headers]
301   CMake project, then headers will be picked up from there.
302
303   In this case the CMake variable `Vulkan_LIBRARIES` can name the
304   Vulkan library, or a default of `vulkan` will be used.
305
306 * If you have CMake 3.7 or later, then the Vulkan implementation will
307   be found from a Vulkan SDK as published by LunarG.
308
309   Environment variables:
310   * `VULKAN_SDK` should point to the platform-specific SDK directory
311     that contains the `include` and `lib` directories.
312   * `VK_ICD_FILENAMES` should point to the ICD JSON file.
313   * `VK_LAYER_PATH` should point to the explicit\_layer.d folder.
314   * `LD_LIBRARY_PATH` must contain the $VULKAN_SDK/lib/ folder for the
315     validation libraries.
316
317   ```
318   export VULKAN_SDK=$HOME/vulkan-macos-1.1.85.0/macOS
319   export VK_ICD_FILENAMES=$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json
320   export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d
321   export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH
322   ```
323
324### Using Dawn as a backend
325
326We assume you have built [Dawn][Dawn] from source, and have access to both the
327source and build trees. To build a Dawn backend for Amber, set the following
328CMake variables when configuring Amber:
329
330  * `Dawn_INCLUDE_DIR`: The directory containing `dawn/dawn_export.h`
331    (in the source tree).
332  * `Dawn_GEN_INCLUDE_DIR`: The directory containing generated header
333    `dawn/dawncpp.h` (in the build output tree).
334  * `Dawn_LIBRARY_DIR`: The directory containing the `dawn_native` library (in
335    the build output tree).
336
337### Using SwiftShader as a backend
338
339SwiftShader, if available, can be used by by exporting the `VK_ICD_FILENAMES`
340environment variable and using it directly. If SwiftShader is not installed it
341can be built with Amber by setting `AMBER_ENABLE_SWIFTSHADER` during the
342configure step of CMake.
343
344
345```
346mkdir out/sw
347cd out/sw
348cmake -GNinja -DAMBER_ENABLE_SWIFTSHADER=TRUE ../..
349ninja
350export VK_ICD_FILENAMES=$PWD/Linux/vk_swiftshader_icd.json
351./amber -d -V    # Should see SwiftShader listed as device
352./amber -d ../../tests/cases/clear.amber
353```
354
355## Amber Samples
356
357The build will generate an `out/Debug/amber` executable which can be used to
358run amber scripts. The script can be used as
359`out/Debug/amber <path to amber file>`.
360
361```
362out/Debug/amber tests/cases/clear.amber
363```
364
365The sample app returns a value of 0 on success or non-zero on error. Any issues
366encountered should be displayed on the console.
367
368Run `out/Debug/amber -h` to see a description of the program's command line options.
369
370Example AmberScript files can be found in the [tests/cases](tests/cases)
371directory in this repository.
372Also the [Vulkan Conformance Test
373Suite](https://github.com/KhronosGroup/VK-GL-CTS) contains many real-world
374examples in its
375[external/vulkancts/data/vulkan/amber](https://github.com/KhronosGroup/VK-GL-CTS/tree/master/external/vulkancts/data/vulkan/amber)
376subdirectory.
377
378By default, `out/Debug/amber` supports saving the output image into '.png'
379file. You can disable this by passing `-DAMBER_SKIP_LODEPNG=true` to cmake.
380
381The `image_diff` program will also be created. This allows comparing two images
382using the Amber buffer comparison methods.
383
384## Contributing
385
386Please see the [CONTRIBUTING](CONTRIBUTING.md) and
387[CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) files on how to contribute to Amber.
388
389
390## References
391[Dawn]: https://dawn.googlesource.com/dawn/
392[Talvos]: https://talvos.github.io/
393[Vulkan-Headers]: https://github.com/KhronosGroup/Vulkan-Headers
394[VkRunner]: https://github.com/igalia/vkrunner
395
396