diff options
| author | TreXito <81475944+TreXito@users.noreply.github.com> | 2026-11-23 21:45:01 +0000 |
|---|---|---|
| committer | TreXito <81475944+TreXito@users.noreply.github.com> | 2026-11-23 21:45:01 +0000 |
| commit | 8d46480ae2e9cdec79214e9d322cc1508c350efc (patch) | |
| tree | 3addef6d62a3b67ae149771000665c423e8efeb1 /docs | |
| parent | f1d006bdbda200bb599d7652d828bb03fbf54d5a (diff) | |
| parent | 8b02c9ed0dd383e605d57985b76be9095affb2dd (diff) | |
Merge #4717 (fuzz/dot-diff)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/shader_validation.md | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/docs/shader_validation.md b/docs/shader_validation.md index fe9b6b4d7..ac603c902 100644 --- a/docs/shader_validation.md +++ b/docs/shader_validation.md | |||
| @@ -701,6 +701,78 @@ pair replaced by a wrapped subtraction, and the `v_sad_hi_u8` shift dropped — | |||
| 701 | programs fail (`--programs 60 --seed 2 --max-ops 5 --no-sweep`), so the runner does catch arithmetic | 701 | programs fail (`--programs 60 --seed 2 --max-ops 5 --no-sweep`), so the runner does catch arithmetic |
| 702 | errors. | 702 | errors. |
| 703 | 703 | ||
| 704 | ### Packed integer dot products (`tools/dot_diff.py`) | ||
| 705 | |||
| 706 | No other runner generates a dot product: none of the `--list-ops` lists of `vint_diff`, `pk16_diff`, | ||
| 707 | `fmisc_diff` or `f32_fuzz` has one. Yet the FidelityFX programs use `v_dot4c_i32_i8` 25,813 times and | ||
| 708 | `v_dot4_i32_i8` 1,458 times ([fspx.md](fspx.md)). `tools/dot_diff.py` covers twelve opcodes: | ||
| 709 | |||
| 710 | - the VOP3P `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_i32_i8`, `v_dot4_u32_u8`, `v_dot8_i32_i4` | ||
| 711 | and `v_dot8_u32_u4` (accumulator `S2`); | ||
| 712 | - the VOP2 `v_dot4c_i32_i8` (accumulator: the old destination); | ||
| 713 | - the five gfx908-syntax accumulating forms the translator also accepts: `v_dot2c_i32_i16`, | ||
| 714 | `v_dot2c_u32_u16`, `v_dot4c_u32_u8`, `v_dot8c_i32_i4` and `v_dot8c_u32_u4`. | ||
| 715 | |||
| 716 | The first seven are the gfx103x encodings; `--ops gfx103x` keeps only those. | ||
| 717 | |||
| 718 | The reference uses Python integers and shares no code with the translator. It takes the exact sum | ||
| 719 | `sum(S0.elem[k] * S1.elem[k]) + acc` modulo 2^32, or under `clamp` saturates it to | ||
| 720 | `[-2^31, 2^31-1]` (signed) or `[0, 2^32-1]` (unsigned). `tests/test_dot_diff.py` checks it against | ||
| 721 | the rows measured on gfx1036 in `tests/semantic/test_alu_dot4_i8.py`: 10 operand sets (`MEASURED`), | ||
| 722 | each of which gave one word as `v_dot4_i32_i8`, as `v_dot4c_i32_i8` and with the two sources swapped, | ||
| 723 | and 5 more under `op_sel` 2 / `op_sel_hi` 5 (`MEASURED_OP_SEL`). Saturation under `clamp` is measured on | ||
| 724 | hardware only for `v_dot4_i32_i8` (its two overflowing cases give 0x7fffffff and 0x80000000); for the other ops | ||
| 725 | the reference takes it from the ISA documentation, so a misreading the translator shares would not show | ||
| 726 | here. It is compared with the translation run in `spirv_mini_interp`, on the four exported mrt0 words, | ||
| 727 | bit for bit. | ||
| 728 | |||
| 729 | **Programs and sources.** | ||
| 730 | - Programs follow the `sad_diff.py` shape: seeds in v8..v15 and s4..s7, then family ops writing | ||
| 731 | v8..v11, so accumulating forms chain on earlier results. | ||
| 732 | - Sources are VGPR, SGPR, a hex literal and an integer inline constant. Constants read as 32-bit | ||
| 733 | dwords (positive zero-extends, negative sign-extends), the rule measured for VOP3P integer | ||
| 734 | constants in [design.md](design.md). | ||
| 735 | - Every VOP3P program is encodable on GFX10: at most one literal and two constant-bus reads. | ||
| 736 | `S1` of the accumulating forms is a VGPR. | ||
| 737 | - Modifiers: `clamp` wherever the translator takes it, all 16 `op_sel`/`op_sel_hi` settings of | ||
| 738 | `S0`/`S1` on `v_dot4_i32_i8`, and the explicit default `op_sel:[0,0,0] op_sel_hi:[1,1,1]` on the | ||
| 739 | other VOP3P ops. | ||
| 740 | - `--self-test` pins the refused forms as expected rejections: `neg_lo`/`neg_hi`, source | ||
| 741 | `neg`/`abs`, other `op_sel` settings, and `clamp` on `v_dot4c_i32_i8`. | ||
| 742 | |||
| 743 | **Three stages.** | ||
| 744 | 1. A sweep of every encodable source-kind combination with and without `clamp` (671 programs). | ||
| 745 | 2. An edge grid (2,944 cases, four per program). `S0`/`S1` come from words built of one lane width's | ||
| 746 | extremes; the accumulators sit on and next to the saturation bounds. | ||
| 747 | 3. Random seeded programs. | ||
| 748 | |||
| 749 | The grid is the only stage that reliably reaches the single point where `v_dot2_i32_i16`'s two | ||
| 750 | products alone overflow: `(-32768)^2 + (-32768)^2 = 2^31`. The report counts, per op, the results | ||
| 751 | that saturated under `clamp` and the ones that wrapped without it. | ||
| 752 | |||
| 753 | ```powershell | ||
| 754 | python -I tools/dot_diff.py --programs 2000 --seed 7 | ||
| 755 | python -I tools/dot_diff.py --self-test | ||
| 756 | python -I tests/test_dot_diff.py | ||
| 757 | ``` | ||
| 758 | |||
| 759 | **Results.** Seeds 776511 to 776514 (`--programs 25000 --max-ops 8`) match bit for bit, zero | ||
| 760 | mismatches and zero skips: 4 x 26,407 programs. | ||
| 761 | |||
| 762 | Four mutations of the translator's dot lowering are all caught by a default run | ||
| 763 | (`--programs 0 --seed 2`, sweep and grid): | ||
| 764 | |||
| 765 | | Mutation | Failing programs | | ||
| 766 | |---|---| | ||
| 767 | | unsigned `clamp` that never saturates | 32 + 192 | | ||
| 768 | | `u4` lanes sign-extended | 91 + 116 | | ||
| 769 | | `op_sel_hi[0]` ignored on `v_dot4_i32_i8` (S0's byte pairs 2..3 always from the high half) | 8 sweep | | ||
| 770 | | `v_dot2_i32_i16` product carry dropped | 4 grid, missed by the sweep and by 200 random programs | | ||
| 771 | |||
| 772 | The counts belong to these exact one-line changes and move with the mutation. On the same run, ignoring | ||
| 773 | `op_sel_hi[1]` instead fails 10 sweep programs, ignoring both 13, and reading S1's byte pairs 2..3 from the | ||
| 774 | low half (an `op_sel_hi[1]` taken as 0) fails 64. | ||
| 775 | |||
| 704 | ### Images on the GPU (`tools/image_fuzz.py`) | 776 | ### Images on the GPU (`tools/image_fuzz.py`) |
| 705 | 777 | ||
| 706 | `tools/image_fuzz.py` starts on the image path, where the T# format, the view type and the binding layout | 778 | `tools/image_fuzz.py` starts on the image path, where the T# format, the view type and the binding layout |