• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Shader Variations
2
3To build multiple variations of a shader, add a file named X.json corresponding to shader file X.  A
4variation is generated by building the shader with different definitions (a la glslang_validator's
5-DName=1).  These definitions come from flags and enumerations defined in the json file.  Without a
6.json file, the shader is generated as is (1 variation).
7
8There are multiple possible fields in the json file:
9
10- "Description": This contains the license and other comments, which will be ignored.
11- "Flags": this is a list of flags.  Each flag FLAG defines a shader variation with or without the
12  define FLAG=1.
13- other: any other field is a similar list to flags, except that each entry in this enumeration is a
14  variation.  Similar to "flags", every entry ENTRY results in an ENTRY=1 define.
15
16Flags are shorthand for 2-entry enumerations.  Given n flags, there are 2^n variations where every
17flag is either present or not.  For enumerations, only one entry is active in any variation.  Thus,
18an enumeration with n entries generates n variations.
19
20## Example
21
22Here is an example json file:
23
24{
25    "Description": [
26        "Copyright 2018 The ANGLE Project Authors. All rights reserved.",
27        "Use of this source code is governed by a BSD-style license that can be",
28        "found in the LICENSE file.",
29        "",
30        "RayTrace.comp.json: Build parameters for RayTrace.comp."
31    ],
32    "Flags": [
33        "NanFilter",
34        "WorkaroundIntelBug"
35    ],
36    "RayTraceQuality": [
37        "IsRTLowRes",
38        "IsRTHighRes",
39        "IsRTAwesome"
40    ],
41    "ImageType": [
42        "IsR",
43        "IsRG",
44        "IsRGB",
45        "IsRGBA"
46    ]
47}
48
49This will generate 2^2 * 3 * 4 shaders.
50