Appendix C: Feature Gates
Various feature gate exist in Amethyst, with different purposes. In this chapter, we will go through each of the feature gate types.
Crate Enabling Feature Gates
To reduce compilation times, you can disable features that are not needed for your project.
When compiling, you can use the following Cargo parameters:
cargo (build/test/run) --no-default-features --features feature1,feature2,feature3
At the time of writing, the list of features of this type is the following:
The full list of available features is available in the Cargo.toml file. The available features might change from time to time.
Whenever you run your game, you'll need to enable one graphics backend. The following features are available for the backend:
Rendy has multiple safety checks built-in to detect bugs in the data it gets submitted. However,
those checks can become too costly for a smooth experience with larger games; you can disable
them using the
Additionally, there's a
shader-compiler feature which allows compiling GLSL / HLSL to SPIR-V
shaders. This is only needed if you're planning to compile shaders at runtime. Amethyst's
built-in shaders come pre-compiled, and you can also precompile your own using
by shaderc). Please note, that on Windows this feature requires Ninja to be installed.
We're using the
Float type in Amethyst to hide the precision of the floating-point numbers.
This allows switching to 64-bit precision without breaking code. To do that, you can simply enable
Using Amethyst testing utility
As described in the Testing chapter, Amethyst has several utilities to help you
test an application written using Amethyst. For some cases (especially when rendering components
are involved in the test), you need to enable the
To enable the profiler, you can use the following feature:
cargo (build/test/run) --features profiler
The next time you will run a project, upon closing it, a file will be created at the root of the project called
You can open this file using the chromium browser (or google chrome) and navigating to chrome://tracing
nightly feature adds a bit of debug information when running into runtime issues. To
use it, you need to use the nightly rust compiler toolchain.
Here is how to enable it:
cargo (build/test/run) --features nightly
The most common use of this feature is to find out the type name of the resource that is missing, such as when a
World::read_resource() invocation fails.
Amethyst as a dependency
When using Amethyst as a dependency of your project, you can use the following to disable default features and enable other ones.
[dependencies.amethyst] version = "*" default-features = false features = ["audio", "animation"] # you can add more or replace those