docs/dup/test_ci_renderdiff.html
This tool (/test/renderdiff) is a collections of scripts to run gltf_viewer and produce headless renderings.
This is mainly useful for continuous integration where GPUs are generally not available on cloud machines. To perform software rasterization, these scripts are centered around Mesa's software rasterizers, but nothing bars us from using another rasterizer like SwiftShader. Additionally, we should be able to use GPUs where available (though this is more of a future work).
The script render.py contains the core logic for taking input parameters (such as the test description file) and then running gltf_viewer to produce the renderings.
In the test directory is a list of test descriptions that are specified in json. Please see sample.json to glean the structure.
The renderdiff project uses python extensively. To install the dependencies for producing renderings, do the following step
python3 -m venv venv
. ./venv/bin/activate
pip install -r test/renderdiff/src/rendering_requirements.txt
pip install -r test/renderdiff/src/viewer_requirements.txt
deactivate
test-renderdiff, you can dobash test/renderdiff/local_test.sh
bash test/renderdiff/generate.sh
You can control the behavior of the test scripts with the following flags passed to local_test.sh:
--test_filter=<filter>: Run a subset of tests. The filter supports wildcards (*) to match test names.--no_rebuild: Skip rebuilding the gltf_viewer executable.--num_threads=<number>: Set the number of threads for rendering. If not set, the system's default is used.For example, to run all MSAA tests without rebuilding and using 8 threads:
bash test/renderdiff/local_test.sh --test_filter='MSAA.*.*' --no_rebuild --num_threads=8
The golden images are stored in a github repository: https://github.com/google/filament-assets. Filament team members should have access to write to the repository. A typical flow for updating the goldens is to upload your changed images into branch of filament-assets. This branch is paired with a PR or commit on the filament repo.
As an example, imagine I am working on a PR, and I've uploaded my change, which is in a branch called my-pr-branch, to filament. This PR requires updating the golden. We would do it in the following fashion on a macOS machine:
update_golden.py script.python3 test/renderdiff/src/update_golden.py
filament-assets.git clone [email protected]:google/filament-assets.git
cd filament-assets
git switch -c my-pr-branch-golden
filament-assetsfilament-assets working branch to remotegit push origin my-pr-branch-golden
filament, add the following lineRDIFF_BRANCH=my-pr-branch-golden
Doing the above has multiple effects:
test-renderdiff will test against the provided branch of the golden repo (i.e. my-pr-branch-golden).my-pr-branch-golden to the main branch of the golden repo.Alternatively, if you are confident in your changes and want the CI to handle the update for you, you can use the following tag in your commit message:
filament, add the following line:RDIFF_ACCEPT_NEW_GOLDENS
This has the following effects:
test-renderdiff will be bypassed (it will not perform rendering or comparison).filament-assets.main.We provide a viewer for looking at the result of a test run. The viewer is a webapp that can be used by pointing your browser to a localhost port. If you input the viewer with a PR or a directory, it will parse the test result and show the results and the rendered and/or golden images.
To run the viewer of a test output directory that has been generated locally, you would run the following
python3 test/renderdiff/src/viewer.py --diff=[test output]
where [test output] is a directory containing the compare_results.json of the test run. For example, it could be out/renderdiff/diffs/presubmit for the standard path to the presubmit test output.
To see the results of a Pull Request initiated test run, you would do the following
python3 test/renderdiff/src/viewer.py --pr_number=[PR #] --github_token=[github token]
where [PR #] is the numeric ID of your pull request, and the [github token] is an acess token that you (as a github user) needs to generate (reference).
To see the results of a specific run, you would do the following
python3 test/renderdiff/src/viewer.py --run_number=[RUN #] --github_token=[github token]
where [RUN #] is the numeric ID of the run. You can find the run number in the URL of the GitHub Actions page. For example, in the URL https://github.com/google/filament/actions/runs/18023632663/job/51286323708?pr=9264, the run number is 18023632663.