[Fix] (trace-replay): use SSIM for golden validation

This commit is contained in:
2026-06-23 21:26:55 +08:00
parent f0f6d1e5fa
commit 2f52264f01
14 changed files with 159 additions and 266 deletions
@@ -40,8 +40,9 @@ The golden and target environments must use the same trace, surface size, target
call numbers, and comparison crop. They do not need to report the same GL vendor,
renderer, version, or extension set. The only requirement for the golden
environment is that it can replay the case and pass the fixture's golden image
test. Disable overlays and avoid tolerance/fuzz while localizing the first
divergent call unless the known golden already has small nondeterministic noise.
test. Disable overlays and use a strict SSIM threshold while localizing the
first divergent call unless the known golden already has small nondeterministic
noise.
## Prepare two replay environments
@@ -80,8 +81,7 @@ mkdir -p "$WORK/$CASE"
--target-call "$TARGET_CALL" \
--width "$WIDTH" \
--height "$HEIGHT" \
--tolerance 0 \
--fuzz-percent 0 > "$WORK/$CASE/target-retrace.log" 2>&1 || true
--ssim-threshold 1.0 > "$WORK/$CASE/target-retrace.log" 2>&1 || true
```
Keep target GL identity lines such as `MOBILEGL_TRACE_GL_VENDOR`,
@@ -90,7 +90,7 @@ Keep target GL identity lines such as `MOBILEGL_TRACE_GL_VENDOR`,
reject a golden environment because its GL strings differ from the target.
For Android, use `android-plugin/trace-replay-ci.sh` with the same trace,
golden, target call, width, height, crop, tolerance, and fuzz values. Pull
golden, target call, width, height, crop, and SSIM threshold values. Pull
`result.json`, `actual.png`, `diff.png`, `retrace.log`, and `logcat.txt` before
continuing.
@@ -151,8 +151,7 @@ for call in 1000 1250 1430 1700; do
--target-call "$call" \
--width "$WIDTH" \
--height "$HEIGHT" \
--tolerance 0 \
--fuzz-percent 0 || true
--ssim-threshold 1.0 || true
done
```
@@ -173,8 +173,7 @@ add_trace_replay_test_for_backends(case-name
TARGET_CALL 0
WIDTH 854
HEIGHT 480
TOLERANCE 20
FUZZ_PERCENT 20)
SSIM_THRESHOLD 0.99)
```
Optional crop:
@@ -191,13 +190,13 @@ Optional crop:
Edit `.github/workflows/apk.yml` `TRACE_REPLAY_CASES`:
```text
case-name|tools/trace_replay/fixtures/case-name.tgz|trace.trace|tools/trace_replay/fixtures/case-name.0000000000.png|0|854|480|20|0|0|0|0|20|900
case-name|tools/trace_replay/fixtures/case-name.tgz|trace.trace|tools/trace_replay/fixtures/case-name.0000000000.png|0|854|480|0.99|0|0|0|0|900
```
Field order:
```text
case|trace archive|trace file|golden|target call|width|height|tolerance|crop x|crop y|crop width|crop height|fuzz percent|timeout seconds
case|trace archive|trace file|golden|target call|width|height|ssim threshold|crop x|crop y|crop width|crop height|timeout seconds
```
Update `tools/trace_replay/README.md` with one fixture sentence and one golden
@@ -236,12 +235,11 @@ cmake \
-DTRACE_TARGET_CALL="$TARGET_CALL" \
-DTRACE_WIDTH="$WIDTH" \
-DTRACE_HEIGHT="$HEIGHT" \
-DTRACE_TOLERANCE=20 \
-DTRACE_SSIM_THRESHOLD=0.99 \
-DTRACE_CROP_X=0 \
-DTRACE_CROP_Y=0 \
-DTRACE_CROP_WIDTH=0 \
-DTRACE_CROP_HEIGHT=0 \
-DTRACE_FUZZ_PERCENT=20 \
-DTRACE_OUTPUT_DIR="$WORK/$CASE/linux-DirectGLES" \
-DTRACE_ARTIFACT_DIR="$WORK/$CASE/linux-artifacts" \
-P "$REPO/tools/trace_replay/run_trace_case.cmake"
@@ -292,12 +290,11 @@ sh "$REPO/android-plugin/trace-replay-ci.sh" \
--target-call "$TARGET_CALL" \
--width "$WIDTH" \
--height "$HEIGHT" \
--tolerance 20 \
--ssim-threshold 0.99 \
--crop-x 0 \
--crop-y 0 \
--crop-width 0 \
--crop-height 0 \
--fuzz-percent 20 \
--timeout-seconds 900
```