Reducer
wgslsmith is able to integrate with a number of off-the-shelf program reduction tools to reduce WGSL programs that exhibit compilation crashes or have mismatching output buffers during differential testing. Currently, the following tools are supported:
Perses tends to work the best thanks to its syntax-aware approach, though C-Reduce also works very well. If you want to use Perses, you must use this fork which includes the WGSL grammar, and add the following to your wgslsmith config file (open it in your editor by running wgslsmith config
):
[reducer.perses]
jar = "/path/to/perses_deploy.jar"
The other tools can be installed by following their respective documentation.
To reduce WGSL programs use the reduce
command:
$ wgslsmith reduce --help
The reducer can only be run on Linux at the moment (although it can still reduce shaders for all supported platforms). Windows support is tracked in #22. To reduce shaders for another platform, use the harness in server mode or the validation tools described below.
For reducing mismatches, there are no extra required arguments other than the path to the shader and input data. For crashes, wgslsmith supports two approaches described below. In both cases you must provide the --regex <REGEX>
option to specify a regex to match against the crash output (e.g. an error code that you're interested in).
Using the harness
The obvious way is to use the harness to attempt to execute the shader and check if it crashes. In this case, you will need to provide the --config <CONFIG>
option with a config string that produces the crash (see here).
Using standalone validation tools
Executing the shaders can be relatively slow and requires access to the platform that has the bug. Instead, there are existing tools that can be used to validate HLSL, MSL and SPIR-V shaders generated by WGSL compilers. To use this, you will need to set up the validation server as described here. Then pass the --compiler <COMPILER>
and --backend <BACKEND>
options to the reduce command.
SPIR-V is not yet supported with the validation tools. This is tracked in #23.