Skip to content

About

Direct3D 12 test bench: can a GPU with 32-lane waves behave like one with 64? Waves, memory, textures and image conformance, checked bit by bit against the CPU.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

44 Commits

Folders and files

Repository files navigation

wave64-prefix-test

Can a GPU with 32-lane waves behave like one with 64?
Correctness and cost tests in Direct3D 12, checked value by value against the CPU.

Direct3D: 12 HLSL: SM 6.0 C++: 17 Windows: 10 | 11 tests: 32/32 PASS status: in progress WARP: automatic tests license: MIT

Prefix sum of 64 ones: the emulated path climbs from 0 to 63 like the CPU; the physical one restarts at index 32

English · Español

Progress · What is left · How it works · Getting started · Cost
H2 · H3 · All three · Image · What a PASS proves · Details

Note

There is also a Spanish version. Code comments and program output are in Spanish; quoted names such as OMITIDA (skipped) or MAL (bad) appear that way on screen.

Progress

32 of 32 wave tests are PASS 594 of 594 deliberate errors caught 1,048,576 values per test 0 debug layer warnings

H1, waves and synchronization: emulating wave64 costs from 1.2 to 8.7 times H2, memory and streaming: 48 MB per frame arrive from an NVMe drive at 60 fps H3, texture fidelity: BC6H and BC7 are exact

Conclusions so far

  • With integers, the emulation is bit-for-bit identical in everything tested.
  • With float sums it is deterministic and accurate, but it cannot be guaranteed to give the same bits as the original hardware.
  • Divergence is what is expensive, especially nested loops in groups of 256. Without divergence, emulating sum, minimum and maximum of floats costs only ×1.2–×1.3.
  • With NaN, infinities and denormals, the translation reproduces fixed semantics, but HLSL leaves several cases open and adapters differ (see "What a PASS proves").
  • These are synthetic programs: they support the idea that the hard part is wave operations and synchronization, but they do not prove it.
The three hypotheses, in words
Hypothesis Status What is known
H1. The hard part is wave operations and synchronization 🟡 In progress Emulation is correct with integers; cost grows with divergence
H2. Memory and streaming over PCIe weigh the most 🟡 In progress Reading new data over PCIe costs ×19.6–19.7; on the copy queue, uploading textures the shader reads adds at most 0.03 ms to the GPU; from an NVMe drive at 60 fps, 48 MB per frame arrive on time and 64 MB do not
H3. The problem is resource fidelity (textures, DCC, BCPack) 🟡 In progress BC6H and BC7 decode exactly; BC1–BC5 are up to 7 steps of 255 from the ideal on the RTX and 1.65 on WARP; filtering, less than 3/256 on both, but the RTX LOD is up to 0.74 levels away; imitating BC1 and the filter in the shader costs up to x6.5, and turning it into BC7 almost nothing, with 1 step of error in 4-color blocks
All the wave tests, one by one 32 of 32 tests run are PASS and the GPU detects 594 of 594 errors. The check against real 64-lane waves is missing
Test Groups RTX 4070 SUPER WARP Cost vs. physical
Exclusive sum, integers 64 / 256 ✅ 100/100 ✅ 3/3 barriers, ×1.5 / ×1.8
Divergence (if/else and loop) 64 / 256 ✅ 100/100 ✅ 3/3 ×3.6 / ×4.7
Nested loops 64 / 256 ✅ 100/100 ✅ 3/3 ×3.8 / ×6.4
Three loop levels with return 64 / 256 ✅ 100/100 ✅ 3/3 ×4.6 / ×8.7
Floats: sum, minimum, maximum, fixed point 64 / 256 ✅ 100/100 ✅ 3/3 no comparable baseline
Floats with divergence 64 / 256 ✅ 100/100 ✅ 3/3 ×3.2 / ×3.4
Floats in nested loops 64 / 256 ✅ 100/100 ✅ 3/3 ×2.8 / ×3.9
NaN, infinities and ±0, denormals preserved 64 / 256 ✅ 100/100 ✅ 3/3 ×1.3 / ×1.2
The same, denormals flushed to zero 64 / 256 ✅ 100/100 ✅ 3/3 ×1.3 / ×1.2
The same, in float16_t 64 / 256 ✅ 100/100 ✅ 3/3 ×1.2 / ×1.2
Those cases with divergence, denormals preserved 64 / 256 ✅ 100/100 ✅ 3/3 ×1.7 / ×1.6
Those cases with divergence, denormals flushed 64 / 256 ✅ 100/100 ✅ 3/3 ×1.7 / ×1.7
Those cases with divergence, in float16_t 64 / 256 ✅ 100/100 ✅ 3/3 ×1.5 / ×1.4
Those cases in nested loops, denormals preserved 64 / 256 ✅ 100/100 ✅ 3/3 ×1.7 / ×1.7
Those cases in nested loops, denormals flushed 64 / 256 ✅ 100/100 ✅ 3/3 ×1.7 / ×1.7
Those cases in nested loops, in float16_t 64 / 256 ✅ 100/100 ✅ 3/3 ×1.4 / ×1.5

✅ counts runs with PASS, on driver 32.0.16.2124. The D3D12 debug layer reports no errors or warnings on the GPU or on WARP. WARP is Microsoft's software adapter. Under "Errors detected" and "Cost", the first figure is for groups of 64 and the second for groups of 256. Four of the 594 errors are only detected sometimes (see "Sensitivity"). Leaving the loop per individual wave is not counted: it has not been run on the GPU.

What is left

What could be done on this PC alone is finished. The rest needs hardware, a download or starting something big:

🟡 Needs something else ⚪ Not started
  • Check the reference
    another GPU, with 64-lane waves: can you help?
  • Detect leaving the loop per wave
    may hang the GPU
  • H2 with VRAM written by the CPU
    enable Resizable BAR in the BIOS
  • H2 with DirectStorage
    download its SDK
  • Repeat the frame timings
    with the graphics card free
  • Translate from RDNA 2 binaries
  • H3: DCC and BCPack

How it works

flowchart LR
    I["Synthetic data<br>fixed seed"] --> CPU["CPU reference<br>64-lane wave"]
    I --> L["Emulated path<br>groupshared + barriers"]
    I --> F["Physical path<br>wave intrinsics"]
    CPU --> C{"Equal,<br>value by value?"}
    L --> C
    C -- yes --> P["PASS · code 0"]
    C -- no --> X["FAIL · code 1"]
    F -. "diagnostic only" .-> R["Validates the CPU model<br>against real waves"]
Loading
  • Branches: they become predicates, so that every thread reaches every barrier.
  • Loops: they end by a vote of the whole group, not of each wave.
  • Wave operations: they are rebuilt with groupshared, atomics and barriers, without depending on the width or the order of the physical lanes.

Getting started

You need Windows 10 or 11 and Visual Studio 2022 Build Tools with Desktop development with C++. build.bat finds the tools through vswhere:

.\build.bat
.\build\bin\wave64_prefix_test.exe

On every change, GitHub Actions builds it and runs the 32 tests and --bc, --filter, --emulate, --lod, --raster, --output and --cache on WARP. There is no GPU there: no RTX results, no timings and no debug layer.

Run it on your card: share the results. The form has the commands and where to download it already built, without Visual Studio. AMD cards with 64-lane waves help the most.

Options and exit codes
wave64_prefix_test.exe [--adapter N] [--shaders DIR] [--debug] [--bench] [--stream] [--disk DIR] [--bc] [--filter] [--emulate]
                       [--frame] [--lod] [--raster]
                       [--output] [--cache DIR]
  --adapter N   index of the adapter in the printed list (default: the first hardware one)
  --shaders DIR folder with the .cso files (default: bin\shaders next to the .exe)
  --debug       enables the D3D12 debug layer and shows its messages (needs Windows "Graphics Tools")
  --bench       measures GPU times after the test; does not change the exit code
  --stream      instead of the tests, measures memory and streaming (H2); about 40 s
  --disk DIR    instead of the tests, measures streaming from disk (H2) with a 2 GB
                temporary file in DIR; under 2 minutes on an NVMe drive
  --bc          instead of the tests, compares BC textures with the CPU (H3)
  --filter      instead of the tests, compares filtering with the CPU (H3)
  --emulate     instead of the tests, measures the cost of imitating another GPU (H3)
  --frame       instead of the tests, measures H1, H2 and H3 in one frame; about 2 minutes
  --lod         instead of the tests, compares LOD and anisotropy with the CPU (H3)
  --raster      instead of the tests, compares rasterization with the CPU
  --output      instead of the tests, compares output formats, blending, compositing and depth
  --cache DIR   instead of the tests, loads pipelines that another process saved in DIR; 3 to 5 minutes
Code Meaning
0 The logical paths (sum, divergence, nested loops, three levels with return, floats, floats with divergence, floats in nested loops and special cases, in groups of 64 and 256) match the CPU in all 1,048,576 values of each one (PASS)
1 Some logical path differs from the CPU (FAIL)
2 Setup error (no device, no SM 6.0, shader not found, etc.) or, with --debug, any error from the debug layer
Full requirements
  • Windows 10 (1803 or later) or Windows 11, with a GPU and driver that support D3D12 and Shader Model 6.0.
  • Visual Studio 2022 Build Tools with the Desktop development with C++ workload. It includes MSVC, the Windows SDK (which brings dxc.exe and dxil.dll) and "C++ CMake tools for Windows".
  • The native path also needs the D3D12 runtime and the driver to support SM 6.6. Otherwise it is reported as OMITIDA (skipped) and the main test runs anyway.
  • The special cases need SM 6.2 and, for float16_t, an adapter that supports it. Otherwise they are reported as OMITIDOS (skipped).
Building with CMake

Tested with CMake 4.4.4 and Visual Studio 2022 Build Tools. The 75 shaders come out byte for byte identical to those of build.bat, and the program ends up in the same folder:

cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release
.\build\bin\wave64_prefix_test.exe

If it does not find dxc.exe, or you want another version, add -DDXC_EXECUTABLE="C:\path\dxc.exe" to the first command. Avoid folders under AppData: MSBuild does not track dependencies there and rebuilds every shader each time.

Cost

Cost vs. the physical path. Divergence: 3.6 with groups of 64 and 4.7 with 256. Nested loops: 3.8 and 6.4. Three levels with return: 4.6 and 8.7. Floats with divergence: 3.2 and 3.4. Floats in nested loops: 2.8 and 3.9. Special cases: 1.3 and 1.2. Specials with divergence: 1.7 and 1.6. Nested specials: 1.7 and 1.7

Note

The comparison is indicative: the physical path computes a different result and its loops may run a different number of iterations.

Timing tables and measurement method

GPU timestamps around 16 dispatches per interval, 50 warm-up repetitions and 100 measurements, with the order of the paths rotating and one command list per repetition. On NVIDIA, timestamps advance in steps of ~1 us even though the reported frequency is higher; that is why a single dispatch is not measured.

Measured on an RTX 4070 SUPER (driver 32.0.16.2124), 16,384 groups, median per dispatch over 5 runs:

Path us per dispatch
Logical 64 with barriers 17.0–19.7
Logical 64 without barriers (wrong result) 11.4–12.8
Physical (WavePrefixSum) 25.8–28.9
Logical 64 in groups of 256, with barriers 21.5–21.6
Logical 64 in groups of 256, without barriers (wrong result) 12.2

With barriers, the dispatch takes about 1.5 times as long as without them (x1.49–x1.54, between +5.6 and +6.9 us). In groups of 256 the ratio rises to x1.77 (+9.3 us).

  • The baseline is the same path without barriers, not the physical one: WavePrefixSum is slower than the logical path on this GPU, and subtracting it would give a negative cost.
  • The figure also includes whatever the driver can optimize when there are no barriers. It is an approximation, not the isolated cost of the instruction.
  • Absolute time varies by ~15% with the GPU clock; the ratio is more stable. ID3D12Device::SetStablePowerState(TRUE) would reduce it, but it requires Windows developer mode.

Divergence

Median per dispatch of 1,048,576 threads, over 5 runs:

Path us per dispatch vs. physical
64 logical threads, groups of 64 57.3–57.4 x3.6
64 logical threads, groups of 256 74.7–74.8 x4.7
Physical (32-lane waves) 15.9 x1
  • Going from 64 to 256 costs x1.30, but it is not all due to the wider barriers. The 64 version with unsimplified indices (gi / 64, gi % 64) takes 70.3–70.6 us, so about 13 us come from there and only about 4–5 us from the rest.
  • The comparison with the physical path is indicative: it gives a different result and its loop may run a different number of iterations.

Nested loops

Path us per dispatch vs. physical
64 logical threads, groups of 64 142.9–143.4 x3.8
64 logical threads, groups of 256 228.4–242.6 x6.1–x6.5
Physical (32-lane waves) 37.4–37.5 x1
  • Going from 64 to 256 costs between x1.60 and x1.69, more than without nesting (x1.30). With unsimplified indices the 64 version takes 168–180 us, so here most of the difference does not come from the indices. How much is due to the wider barriers and how much to waiting in each loop for the slowest of the four waves has not been separated.

Three levels with return

Path us per dispatch vs. physical
64 logical threads, groups of 64 217.6–230.7 x4.6
64 logical threads, groups of 256 405.6–420.3 x8.5–x8.8
Physical (32-lane waves) 47.7–47.9 x1

Floats

Path us per dispatch vs. physical
Floats, groups of 64 26.8–26.9 not comparable
Floats, groups of 256 26.1 not comparable
Floats with divergence, groups of 64 107.4–107.7 x3.2
Floats with divergence, groups of 256 116.3–116.6 x3.4
Floats with divergence, physical (32-lane waves) 33.8–33.9 x1
Floats in nested loops, groups of 64 203.0–203.4 x2.8
Floats in nested loops, groups of 256 283.3–283.9 x3.9
Floats in nested loops, physical (32-lane waves) 73.0–73.2 x1
  • float_wave.cso only computes the sum, so it is no baseline for floats.hlsl. The comparable baseline is the one for the special cases, where the physical path does the same work:
Path us per dispatch vs. physical
Special cases, groups of 64 19.4–19.5 x1.27
Special cases, groups of 256 18.8–18.9 x1.23
Special cases, physical (32-lane waves) 15.2–15.4 x1
Denormals flushed, 64 / 256 / physical 19.4 / 18.8 / 15.4 x1.26 / x1.23
float16_t, 64 / 256 / physical 19.3 / 18.6 / 15.8 x1.22 / x1.18
With divergence, denormals preserved, 64 / 256 / physical 109.7 / 108.3 / 65.8 x1.67 / x1.65
With divergence, denormals flushed, 64 / 256 / physical 115.9 / 114.7 / 68.7 x1.69 / x1.67
With divergence, float16_t, 64 / 256 / physical 111.4 / 109.1 / 76.1 x1.46 / x1.43
In nested loops, denormals preserved, 64 / 256 / physical 249.8 / 261.1 / 149.9 x1.67 / x1.74
In nested loops, denormals flushed, 64 / 256 / physical 271.6 / 277.4 / 160.8 x1.69 / x1.72
In nested loops, float16_t, 64 / 256 / physical 255.6 / 263.4 / 180.9 x1.41 / x1.46
  • The physical divergence path computes a different result and does not write the minimum: the comparison is indicative.

H2: memory and streaming

--stream measures what changes when going from a console's unified memory to VRAM behind PCIe. The figures come from the RTX 4070 SUPER (PCIe 4.0 x16), without the debug layer: six runs for dynamic data and three for textures.

Dynamic data

The same shader reads 4 MB of new data in each dispatch:

Reading 4 MB of new data: 16.4 us from VRAM, 189.4–190.5 copying it first and 321.5–322.6 straight over PCIe
Table with all the figures
Where it reads from us per dispatch (p50) p99 vs. VRAM
VRAM, already resident 16.4 17.4 x1
CPU memory, over PCIe 321.5–322.6 338.9–384.0 x19.6–19.7
CPU memory, copied to VRAM first 189.4–190.5 191.5–201.7 x11.6
VRAM written by the CPU (GPU_UPLOAD) not measured — Resizable BAR is disabled

Textures

Each frame uploads 64 KB tiles to a texture with 64 slices of 4 MB, a shader reads 16 slices (64 MB) and the GPU runs 70 divergence dispatches. It reads what was just uploaded, with three policies:

  • Direct: the copy goes in the same queue as the read, right before it.
  • Copy, same frame: the copy goes in a separate queue and the main one waits for it to finish.
  • Copy, next frame: the same, but it reads what the previous frame uploaded.

Times in milliseconds. GPU time does not include the wait for the copy queue; frame time does:

Table with all the figures
MB per frame Policy GPU p50, physical load GPU p50, emulated load Frame p50 / p99, physical Frame p50 / p99, emulated
0 — 1.36–1.37 4.29 1.4 / 1.5–1.6 4.3 / 4.5–4.6
4 direct 1.56–1.57 4.49 1.6 / 1.8 4.5 / 4.7–4.8
16 direct 2.09–2.13 5.02 2.1 / 2.4–3.3 5.0 / 5.2–5.3
64 direct 4.19–4.20 7.16–7.18 5.4–5.5 / 7.1–7.8 7.2 / 7.7–9.2
4 copy, same frame 1.37 4.29 1.4 / 1.5–1.6 4.3 / 4.5–4.6
16 copy, same frame 1.38 4.29 1.4 / 1.8–2.0 4.3 / 4.5–4.7
64 copy, same frame 1.36 4.29 5.4–5.5 / 7.1–7.2 5.4 / 7.1–7.6
4 copy, next frame 1.37 4.29–4.30 1.4 / 1.5–1.6 4.3 / 4.5–4.6
16 copy, next frame 1.38 4.29–4.30 1.4–1.5 / 1.8–2.6 4.3 / 4.4–4.5
64 copy, next frame 1.38–1.39 4.30–4.31 5.4–5.5 / 6.9–8.1 5.4 / 7.2–8.0
  • The GPU: on the direct queue each MB costs about 0.04 ms (23 GB/s). On the copy queue, GPU time goes up by at most 0.03 ms, even though the shader reads what was just uploaded.
  • Waiting one more frame makes no difference: with three frames in flight, reading in the same frame or in the next gives the same times at these sizes.
  • The frame: with 64 MB the CPU is the limit, taking about 5.4 ms to write the data. That is where spikes appear: the p99 reaches 1.1–1.5 times the p50 (up to 1.7 with 16 MB and the physical load).
  • Compared with H1: emulating divergence adds 2.9 ms to this frame; uploading 64 MB on the direct queue, 2.8–2.9 ms; on the copy queue, almost nothing on the GPU.
  • Conclusion so far: with a copy queue, streaming does not dominate. What would is a literal translation of "the CPU writes and the GPU reads", normal with unified memory.
How it is checked

The shader sums each tile it reads and the CPU compares, frame by frame, with what it should see: 8,417,280 tiles per run and 0 wrong in all four, one of them with the debug layer (0 errors and 0 warnings). Out of nine deliberate errors:

  • Five in the data (tiles transposed, not copied, holding old data, or a shifted range or source) fail in all 18 combinations that upload data.
  • Reading before the copy finishes, by removing the wait or by reading one frame earlier, fails with 16 and 64 MB; with 4 MB the copy finishes before the read.
  • Sharing the upload buffer across frames always fails on the direct queue. On the copy queue it is not always visible: the copy finishes before the CPU overwrites it.
  • Removing the wait in "next frame" is not visible at this speed. Repeating each copy six times so that it outlasts the frame, it is; and so is the shared buffer, in all combinations.

Note

It is synthetic: the shader reads with Load, without filtering, mips or compressed textures; there is no decompression, and the frame is short. It was not run on WARP, where measuring PCIe would make no sense.

Disk

--disk DIR creates a 2 GB file in that folder with 32,768 different tiles, reads it without the Windows cache and without intermediate copies, from the SSD to the upload buffer, and Windows deletes it on close. Three runs on a PCIe 3.0 NVMe drive (Crucial P3) with 1% free. Random reads:

Batch ms, p50 / p99 CPU ms to request it, p50 GB/s
1 read of 64 KB 0.15–0.35 / 0.29–2.60 0.01–0.02 0.1–0.4
64 of 64 KB (4 MB) 1.38–1.41 / 1.79–1.92 0.42–0.48 2.9
1024 of 64 KB (64 MB) 19.79–20.12 / 20.76–22.80 8.31–8.59 2.8–3.4
16 of 4 MB (64 MB) 19.56–19.58 / 20.17–20.98 2.99–3.14 3.4

The same frame as before, at 60 fps (16.67 ms), with random tiles, the emulated load and the copy queue. "Late" counts frames more than 5% over, out of 399:

Late frames out of 399: almost none up to 48 MB; with 64 MB, 399 when reading in the same frame and 116–133 with 2 frames of advance
Table with all the figures
MB per frame Source CPU ms to request ms waiting for the disk, p50 / p99 ms per frame, p50 / p99 Late
4 memory — — 16.7 / 16.7 0–1
4 disk, same frame 0.5–0.6 0.9 / 1.2–1.3 16.7 / 16.7 0–1
4 disk, 2 frames earlier 0.5 0.0 / 0.1 16.7 / 16.7 0
16 memory — — 16.7 / 16.7 0
16 disk, same frame 2.1–2.3 2.8–2.9 / 3.5–3.6 16.7 / 16.7 0
16 disk, 2 frames earlier 2.1 0.1–0.2 / 0.3 16.7 / 16.7 0
48 memory — — 16.7 / 16.7 0
48 disk, same frame 6.5–6.6 8.3–8.5 / 9.8–10.0 16.7 / 16.7–18.1 2–6
48 disk, 2 frames earlier 6.4–6.8 0.6 / 1.0–1.5 16.7 / 16.7 0–1
64 memory — — 16.7 / 16.7 0
64 disk, same frame 8.9–9.0 10.9–11.0 / 12.3–13.0 20.6–20.7 / 22.4–22.9 399
64 disk, 2 frames earlier 8.8–9.1 1.1–2.3 / 25.6–27.8 16.7 / 34.7–38.4 116–133
  • The disk is the bottleneck, not PCIe: it gives 3.4 GB/s and PCIe, 23 GB/s.
  • The limit: at 60 fps about 54 MB fit in a frame. With 48 almost everything arrives on time; with 64, every frame is late when reading in the same one. Sony advertises 5.5 GB/s for the PS5.
  • Requesting ahead: doing it 2 frames earlier removes almost all the waiting up to 48 MB, at the cost of guessing 33 ms in advance. With 64 MB fewer are late, but with bigger hitches: p99 of 34.7–38.4 ms versus 22.4–22.9. The disk probably does not serve the requests in order.
  • The CPU counts too: requesting 1024 reads costs 8.3–8.6 ms, about 8 us each; with 4 MB reads, 3.0–3.1 ms. Here the frame thread pays for it.
  • Compared with H1: emulating divergence adds 2.9 ms; reading 16 MB in the same frame, about 5 ms between requesting and waiting. From disk, streaming does weigh more.
How it is checked

Each run checks 5,624,064 tiles, 0 wrong in all four (one with the debug layer, 0 errors and 0 warnings). Out of six deliberate errors:

  • Four in the data (neighboring tile, swapped destination, one altered byte or skipped reads) fail in all 8 combinations with disk.
  • Waiting for the disk after submitting the copy always fails when reading in the same frame; with 2 ahead, only with 48 and 64 MB, because with less the data had already arrived.
  • Leaving no room in the ring for reads made ahead is not visible at 60 fps, because the previous copy has already finished. Unpaced and repeating each copy six times, it fails at any size.

Removing the flag that bypasses the Windows cache raises 4 MB reads to 6.0 GB/s: the figures above come from the SSD and not from memory.

Note

The file was just written, and on a QLC SSD older data may read more slowly. There is no DirectStorage or GPU decompression, and the second run measured slower single reads, probably because of other activity. On an external USB SSD, reading at 41 MB/s, it was stopped after 10 minutes without finishing. Unexplained: in a test without the 60 fps pace, the physical load with 64 MB from disk went from 1.35 to 2.3–2.5 ms of GPU, and the emulated one barely changed.

H3: textures

BC formats

--bc uploads block-compressed textures, reads them unfiltered in a shader and compares the bits with a CPU reference: 262,144 blocks per format (4,194,304 texels). BC4 and BC5 cover every pair of endpoints with every index; BC6H and BC7, every mode, including the reserved ones. It takes about 3 seconds. The error is in 1/255 (1/127 when signed) against ideal interpolation:

Maximum error decoding BC: up to 7.09 steps on the RTX and 1.65 on WARP; 0 in BC6H and BC7
Table with all the figures
Format RTX: max error RTX: over 1 The RTX is identical to WARP: max error WARP: over 1
BC1 5.40 16.0% NVIDIA formula from rgbcx 1.65 8.0%
BC2 5.40 32.6% NVIDIA formula from rgbcx 1.65 15.7%
BC3 6.60 43.5% the same, with the alpha fitted here 1.65 15.8%
BC4 UNORM 6.75 21.7% model fitted here 0.003 0%
BC4 SNORM 7.09 24.1% model fitted here 0.004 0%
BC5 UNORM 6.75 38.6% model fitted here 0.003 0%
BC5 SNORM 7.09 42.3% model fitted here 0.004 0%
BC6H UF16 and SF16 0 0% exact reference 0 0%
BC7 0 0% exact reference 0 0%

"Identical" means 100% of the texels, bit by bit, with all four channels. The NVIDIA and AMD formulas are the ones published in rgbcx.

  • BC6H and BC7 are not a problem: the specification demands exactness and both adapters meet it, with a reference written separately.
  • BC1 to BC5 do depend on the vendor: on random blocks, the RTX is up to 7 steps away from the ideal, because it interpolates with approximate weights. For b, BC4 and BC5 use 36, 72, 112, 144, 184 and 220 of 256 (the ideal is 36.6, 73.1, 109.7, 146.3, 182.9 and 219.4), or 48, 96, 160 and 208 with six values (51.2, 102.4, 153.6 and 204.8). WARP truncates the ideal to 16 bits in BC4 UNORM.
  • Compared with AMD: with its formula from rgbcx, the RTX gives another value in 30.6% of BC1 texels and 46.2% of BC2 ones, by up to 4 steps, and differs by more than one in 10.0% and 20.3%.
  • With similar endpoints it is barely noticeable: the difference from AMD stays within 1 step if they are at most 22 of 31 apart in red and blue, or 18 of 63 in green.
  • One ambiguous case: with signed endpoints -127 and -128, index 7 is 1 on the RTX and -1 on WARP, depending on whether they are clamped before or after comparing. That pair is left out of the verdict.
What gives PASS and how it is checked

What gives PASS: BC6H and BC7 identical to the reference, and BC1 to BC5 within 8 steps of the ideal, a margin of our own that only rules out gross errors. All ten formats pass on the RTX and on WARP: 100 identical runs on the GPU and 3 on WARP, with 0 debug layer errors and 0 warnings.

Out of 6323 errors inserted one by one in the tables (partitions, anchors, weights, modes, BC6H bit order and NVIDIA model), 6264 are detected. The remaining 59 change no value: 51 anchors that ask for a bit outside the block, which is zero here, and 8 BC3 alpha weights absorbed by rounding. Eight more errors (seven in the program and one in the shader) give FAIL on both adapters.

Note

The blocks are random, not images: they exaggerate the distance between endpoints. AMD's formula was not checked on an AMD GPU, and how the console interpolates BC3, BC4 and BC5 is unknown. sRGB and filtered BC textures were not looked at, and the NVIDIA model was only fitted on this RTX.

Filtering

--filter filters a 64 x 64 texture with 7 levels at random coordinates and LODs, with all five addressing modes, and compares with the CPU: 262,144 samples per combination of format, filter and mode, about 3 seconds. The error, maximum / mean, is in 1/256 of the largest texel involved, against ideal filtering:

Format RTX, point RTX, bilinear RTX, trilinear Identical to the RTX model WARP, bilinear WARP, trilinear
R8 UNORM 0 1.38 / 0.10 1.84 / 0.22 100% 1.65 / 0.15 1.53 / 0.15
R16 UNORM 0 1.41 / 0.10 1.89 / 0.20 100% 1.62 / 0.15 1.62 / 0.14
R16 FLOAT 0 1.54 / 0.16 2.24 / 0.28 100% 1.89 / 0.23 2.00 / 0.19
R32 FLOAT 0 1.56 / 0.17 2.38 / 0.28 100% 1.89 / 0.24 2.01 / 0.19
RGBA8 SRGB 1.39 2.79 / 0.33 2.89 / 0.34 100% 1.81 / 0.19 1.72 / 0.18
  • The difference is small but not zero: with 8 bits for the weights, only 41% of the RTX's bilinear results and 22% of its trilinear ones equal the ideal (even fewer in sRGB).
  • Each adapter rounds differently: the RTX rounds coordinates to 8 bits and WARP truncates them. 59% of the R8 bilinear results and 78% of the trilinear ones change from one to the other.
  • The RTX, modeled bit by bit: weights are integers that always add up to 256, split first between levels, then between columns and finally between rows. UNORM values are summed with 16 bits; floats, aligned to the largest exponent of each level with 4 extra bits, and ties go up.
  • sRGB: the RTX uses a table with 8 mantissa bits that is up to 0.43 codes away from the formula; WARP, 0.000. If any texel of 0.125 or more takes part, the sum keeps nothing below 2^-18. This was checked separately with another 12 textures, most of them dark: 15.7 million samples, all identical.
What gives PASS and how it is checked

What gives PASS: staying within 4/256 in every combination, a margin of our own. All 15 combinations of format and filter pass on the RTX and on WARP: 100 identical runs on the GPU and 3 on WARP, with 0 debug layer errors and 0 warnings. When choosing a single level, samples closer than 1/256 to the tie do not count, since WARP and the RTX take different levels there.

Out of 17 deliberate errors (14 in the reference and 3 in the shader), all 17 give FAIL on both adapters. Another 25 in the RTX model, such as changing a rounding or a bit, all drop below 100%.

Note

Only square power-of-two textures, positive values, one channel and explicit LOD. BC textures with levels and how AMD filters were not looked at. The model is empirical, from this RTX.

LOD and anisotropy

--lod uses a texture where each level holds its own number, so what it returns is the chosen LOD. With 262,144 random derivatives per row it compares it with the D3D11 specification, which allows approximations. Error in levels:

Maximum anisotropy RTX: max / mean RTX against its model: max RTX: within 4/256 of the model WARP: max / mean
1 (trilinear) 0.534 / 0.055 0.008 100% 0.003 / 0.001
2 0.659 / 0.100 0.068 99.99% 0.003 / 0.001
4 0.710 / 0.117 0.079 99.61% 0.003 / 0.001
8 0.738 / 0.125 0.094 99.98% 0.003 / 0.001
16 0.744 / 0.120 0.094 99.97% 0.003 / 0.001
  • The RTX is up to 0.74 levels away; WARP, nothing noticeable. The RTX estimates length as the longer side plus 11/32 of the shorter one, and also looks at the diagonals (times 11/16).
  • With anisotropy it also narrows the blend between levels: the slope is 1.5 with anisotropy 2, 1.75 with 4 and 2 with 8 or 16. With 8 or 16, half of the LODs use a single level. This is the behavior of the NVIDIA driver's "trilinear optimization", which can probably be turned off in its panel.
  • Automatic derivatives: Sample in compute gives exactly the same as SampleGrad on both.
  • The RTX footprint is a box: samples one texel apart, as many as the width rounded to even, and the two at the ends with the weight that is missing (error of 0.002 at most). WARP always takes the maximum number of samples in a slightly narrower footprint, and differs from the box by up to 0.056.
What gives PASS and how it is checked

What gives PASS: staying within 1 level of the specification, equal automatic derivatives and weights that add up to 1 inside the footprint; the margins are our own. Both pass: 100 identical runs on the GPU and 3 on WARP, with 0 debug layer errors and 0 warnings. All 14 deliberate errors (10 in the reference and 4 in the shader) give FAIL on both, and another 9 in the RTX model make the match worse.

Note

The model is empirical, from this RTX with the current settings of its driver. The footprint was only looked at horizontally and on level 0, and automatic derivatives, in compute and not in pixels. What AMD does is unknown.

Cost of imitating another GPU

If AMD's BC1 is needed bit by bit, the RTX hardware is no use. --emulate measures the ways out: decoding and filtering in the shader, decoding to RGBA8 on load, which takes 8 times the memory, or turning it into BC7, which takes twice. It runs 1024 x 1024 threads with 16 bilinear samples each, from a BC1 texture, with consecutive or random coordinates. Milliseconds, p50 of three runs on the RTX:

Cost of imitating BC1 from another GPU: in the shader it goes from 0.044–0.049 to 0.286–0.287 ms with consecutive coordinates; decoding to RGBA8 reaches 4.71–4.93 ms with random ones
Table with all the figures
Variant Equal to the CPU, RTX Equal to the CPU, WARP 2048², consecutive 2048², random 8192², consecutive 8192², random
Coordinates only — — 0.015–0.018 0.036–0.041 0.016 0.036
Hardware, BC1 100% 21–26% 0.044–0.049 0.444–0.481 0.044–0.045 0.462
Hardware, RGBA8 with AMD's BC1 100% 22–27% 0.046 0.587–0.589 0.046 4.71–4.93
Hardware, BC1 turned into BC7 (approximate) 100% 26–34% 0.045 0.494–0.498 0.045 1.96–2.12
Filter in the shader 100% 67% 0.121–0.122 0.457–0.530 0.120–0.121 0.468–0.556
BC1 and filter in the shader, NVIDIA (not optimized) 100% 100% 0.376–0.378 0.453–0.543 0.374–0.377 0.469–0.565
BC1 and filter in the shader, AMD 100% 100% 0.286–0.287 0.549–0.552 0.284–0.286 0.566–0.571
Same, with prepared blocks (twice the memory) 100% 100% 0.204 0.600–0.607 0.203–0.206 2.05–2.13
  • It can be imitated exactly: the shader gives the same as the CPU on both adapters and, with the NVIDIA formula, the same as the RTX hardware. On WARP the hardware does not, because it filters differently.
  • With consecutive coordinates it costs x5.8–6.5: 1000 million samples go from 2.6–2.9 ms to 17 ms. Filtering in the shader without decoding, x2.5–2.8.
  • How it was optimized: the first version took 0.387 ms (x7.9–8.8). Packing channels in pairs and looking the weights up in a table cuts it by 26%. Gather does not help, nor do branches for when all four texels fall in one block. Keeping the endpoints already in 8 bits leaves it at x4.1–4.7, with twice the memory.
  • With random ones, memory rules: imitating it costs x1.3 at most. Decoding to RGBA8 is free if the texture fits in the GPU cache; if it does not (8192², 256 MB), x10–11. The prepared blocks of that texture (64 MB) do not fit either, and cost x4.4–4.6.
  • Turning BC1 into BC7 on load: with 2-bit indices, BC7 uses the same weights as AMD's formula and the hardware decodes it exactly. It costs the same as plain BC1 with consecutive coordinates and takes twice the memory; random in 8192², which is then 64 MB, x4.3–4.7. It is not exact, but it comes very close in 4-color blocks:
Blocks (random) How many BC1 in hardware: texels different from AMD > 1 step max BC7: different > 1 step max Exact blocks
4 colors 128,813 46.2% 20.3% 4 36.1% 0% 1 20.6%
3 colors 1348 21.0% 0% 1 56.3% 2.1% 8 3.4%
3 colors and transparency 131,983 15.4% 0% 1 93.2% 50.2% 255 0%
  • When it is useful: for opaque textures whose blocks all have 4 colors. The 3-color ones already come out within 1 step on the RTX, and they get worse in BC7: there is no 1/2 weight nor a separate transparent black.
  • A detail of the filter: in textures larger than 4096, the RTX truncates the coordinate to 1/256 of a texel instead of rounding it (checked by hand up to 16384).
How it is checked

Out of 25 deliberate errors in the shader, all 25 give FAIL on both adapters. Ten runs on the GPU and three on WARP give the same results, with 0 debug layer errors and 0 warnings. The step to BC7 gives PASS if 4-color blocks stay within 1 step and at least one in five comes out exact. Out of 17 deliberate errors in it, 15 are detected; the other two change nothing in those blocks.

Note

There is only bilinear BC1, with the RTX filter, because AMD's is not public. Random measurements vary between runs, and the step of decoding, preparing or turning into BC7 on load is not measured. Other applications were using the graphics card while measuring.

All three together

--frame puts waves with divergence (150 dispatches), bilinear BC1 sampling (55, with consecutive coordinates) and 48 MB of new textures read by another shader into the same frame. Without imitating anything, waves and sampling take about the same, some 2.5 ms. GPU milliseconds on the RTX, six runs of 400 frames with other applications using the card; "sum" is the frame without imitation plus what each part adds on its own:

GPU milliseconds in one frame: 5.29–5.52 with nothing imitated, 11.46–12.30 with emulated waves, 19.10–20.01 with textures in the shader and 25.44–26.34 with both
Table with all the figures
Waves (H1) Sampling (H3) Streaming (H2) p50 p99 Sum
physical hardware nothing 5.21–5.52 5.9–6.9 —
emulated hardware nothing 11.39–12.10 12.3–13.4 —
physical in the shader nothing 18.87–19.87 20.4–21.4 —
emulated in the shader nothing 25.16–26.53 26.8–29.4 24.9–26.5
physical hardware direct queue 7.26–7.97 8.2–9.4 —
emulated hardware direct queue 13.62–14.69 14.8–15.9 13.5–14.7
physical in the shader direct queue 21.19–21.88 23.0–24.1 21.2–22.2
emulated in the shader direct queue 27.25–28.63 28.4–30.4 27.4–29.0
physical hardware copy queue 5.29–5.52 6.3–7.4 —
emulated hardware copy queue 11.46–12.30 12.6–14.7 11.3–12.3
physical in the shader copy queue 19.10–20.01 20.6–21.9 18.8–19.9
emulated in the shader copy queue 25.44–26.34 26.6–28.2 24.8–26.7
  • The costs add up: with the card free and the shader not optimized, the total stayed within 1.2% of the sum of the parts. In these six, with noise, up to 8.3%, with no clear trend.
  • For the same starting work, imitated textures weigh the most: they add 13.5–14.6 ms (19.6 not optimized), waves 6.0–6.8 and uploading 48 MB, 1.9–2.7 on the direct queue and almost nothing on the copy queue.
  • But they are not always needed: emulated waves are necessary for the result to be correct. Imitating textures is only so to match BC1 to BC5 bit by bit; BC6H and BC7 already come out exact.
  • For each millisecond affected: the waves in this test become 3.6 ms (from 1.2 to 8.8 in other variants) and imitated sampling about 6, although with random coordinates it barely changes. Streaming depends on the MB, not on the frame.
  • Conclusion so far: with streaming on the copy queue and hardware textures, H1 weighs the most. From disk, H2 rules beyond 48 MB per frame, and if BC1 to BC5 must match bit by bit, H3 rules.
How it is checked

Each combination checks all three results: the tiles the shader saw, what the waves wrote and what came out of the sampling. All 12 pass in the six runs and in another with the debug layer (0 errors and 0 warnings). Out of seven deliberate errors, all seven give FAIL.

Note

How much of each there is in a real frame is unknown: this is synthetic and compute only. The waves are a middle case (divergence in groups of 64) and streaming comes from memory, not from disk. It was not run on WARP.

Image conformance

Rasterization

--raster draws triangles without a render target: the pixel shader writes into a buffer which triangle it got, its covered samples, the interpolated values and the derivatives. The CPU repeats the math with integers. It is 8 images of 1024 x 1024 per row (2 for clipping), about 10 seconds:

Case Pixels drawn Wrong, RTX Wrong, WARP Max interpolation error, RTX WARP
Random triangles 645,335 0 0 2.1e-5 2.0e-3
Mesh of 8192 triangles 8,388,608 0 0 1.9e-6 9.7e-5
Vertices at 1/1024 of a pixel 645,361 0 0 1.3e-5 1.6e-3
Huge triangles, from -4096 to 4096 pixels 8,388,608 0 135, all next to an edge — —
Clipping by z and behind the camera 2,097,152 56, all next to an edge 70, all next to an edge — —
Lines, without the ends 97,506 columns 0 0 — —
4 samples per pixel 782,929 0 0 — —
8 samples per pixel 823,285 0 0 — —
  • Which pixels are drawn is exact: top-left rule, vertices at 1/256 of a pixel and standard sample positions. There is nothing to imitate here, as long as the other GPU follows the same rules.
  • Clipping moves the edges a little: surely because cutting a triangle creates new vertices that are rounded again. All the different pixels are within 1/32 of a pixel of an edge. With huge triangles, the RTX comes out exact, as if it did not clip, and WARP does not.
  • The mesh has no gaps or overlaps: each pixel is drawn exactly once.
  • Vertices are rounded to even on ties on both adapters, like the reference in the specification: 0 wrong pixels, versus 178 rounding up and 496 truncating.
  • Interpolation is neither exact nor equal: the values are approximate. The RTX stays at 2e-5 and WARP at 2e-3, both in random triangles, which include some very thin ones.
What gives PASS and how it is checked

What gives PASS: not a single wrong pixel (in the huge ones and clipping, none more than 1/32 from an edge) and interpolation (with and without perspective, z, w and derivatives) within 1/256, margins of our own. Both pass: 20 identical runs on the GPU and 2 on WARP, with 0 debug layer errors and 0 warnings. Out of 35 deliberate errors (26 in the reference or the program and 9 in the shaders), all 35 give FAIL on both.

Note

No conservative rasterization, the 16 samples, the ends of the lines or custom clip planes. What AMD does when interpolating, or whether it rounds vertices the same way, is unknown.

Output

--output writes known colors and depths and compares what ends up stored, blending and the depth test, with 262,144 pixels per row. The D3D11 specification allows 0.6 steps when converting to integers (0.5 is ideal rounding) and asks for truncation when losing precision in floats. Maximum steps from the ideal:

Maximum error when storing: the RTX stays within the limit of 0.6 in all formats; WARP exceeds it in RGBA8 SRGB (0.843) and D24 (0.750)
Table with all the figures
Format RTX WARP
RGBA8 UNORM 0.562 0.500
RGBA8 SRGB 0.600 0.843
RGB10A2 UNORM 0.562 0.500
R16 UNORM 0.562 0.502
R8 SNORM 0.562 0.500
RGBA16 FLOAT and R11G11B10 FLOAT truncate, 100% truncate, 100%
R32 FLOAT and D32 FLOAT exact exact
D16 UNORM 0.561 0.502
D24 UNORM 0.563 0.750
Blending: maximum steps RTX: add, subtract and min RTX: alpha RTX: premultiplied alpha RTX: multiply WARP, all
RGBA8 UNORM 0.56 1.34 1.44 1.05 0.50
RGB10A2 UNORM 0.55 1.35 1.47 1.04 0.50
RGBA8 SRGB, in linear 1/255 1.29–3.15 3.15 3.36 3.48 1.13–1.15
RGBA16 FLOAT, of the largest operand 0.97–1.47 2.25 1.73 1.45 0.97–1.00
MSAA resolve: maximum steps RTX, 4 samples RTX, 8 samples WARP, 4 WARP, 8
RGBA8 UNORM 0.50 0.50 0.50 0.50
RGBA8 SRGB 1.77 1.40 0.76 0.58
RGBA16 FLOAT, of 1/1024 0.25 0.25 0.25 0.38
A black layer over a 188, both RGBA8 SRGB The 188 as read, RTX WARP Alpha 0 Alpha 128 Alpha 255
Read UNORM, store UNORM 0.737 0.737 188 94 0
Read sRGB, store UNORM 0.504 0.503 128 64 0
Read sRGB, store sRGB 0.504 0.503 188 137 0
Read sRGB, encode in the shader, store UNORM 0.504 0.503 188 94 0
  • MSAA resolve is the rounded mean: in RGBA8, exact except for which way ties go. In sRGB both average in linear space, and the RTX is up to 1.77 steps away.
  • The RTX meets the specification everywhere, using up the margin: it rounds 1/16 of a step before or after the ideal. So 2.8% of the values of an RGBA8 ramp do not come out the same as on WARP.
  • Blending shows more: with alpha in RGBA8, 84.1% of the RTX results are the ideal ones, and in sRGB 80.9%. The specification only asks to compute with the precision of the format or more.
  • Where you blend matters more than how it rounds: these four ways of compositing two planes leave 64, 94 or 137, the same on both. The first and the last one end up equal: only what is read tells them apart. Neither says which one another system uses.
  • Reading an sRGB texture as UNORM is valid here: both adapters support CastingFullyTypedFormatSupported and the debug layer does not complain. It does with a view from another family, such as R32 FLOAT.
  • WARP does not comply in four rows: the two sRGB ones, D24 and NaN in SNORM, which do not become 0.
  • The depth test is exact on both with the values already converted: 0 wrong pixels with <, <=, = and >, even though the second pass is extremely close to the first.
How the RTX does it, bit by bit

The program compares each result with a model fitted to what it returns. It matches in 100% of the pixels in the 16 format rows, the 24 blending ones, the 4 compositing ones and the 3 depth ones:

  • To integers: it truncates the value to 4 bits more than the format and from there goes to the nearest one, with ties going down. The 2-bit alpha comes from the 10-bit code, and in sRGB it uses a table of 255 thresholds.
  • D24: the exact value would be z·2^24 - z, rounded. Up to 0.5, the subtracted z is truncated to 4 bits.
  • Integer blending: it first converts color and alpha to the format, and then blends with integers, rounding. That is why it is up to 1.35 steps away with alpha.
  • sRGB blending: it encodes the color to 8 bits, reads it back with its table, blends with 16-bit floats and encodes the result.
  • RGBA16 FLOAT blending: it truncates color and alpha to 16 bits, and rounds 1 - alpha to the nearest one. Each product is truncated to 2 bits more than the largest, with a mark if it lost anything, and the sum goes to even.

Both sRGB tables are measured on the adapter itself at the start. WARP is not like this model: for example, with alpha in RGBA8 it matches in 84%.

What gives PASS and how it is checked

What gives PASS: 0.6 steps in integer formats, truncation in floats, NaN where it belongs, exact depth, blending within 4 steps and MSAA resolve within 2, the last two being margins of our own. In compositing, reading within 1 code and the three known pixels within 1. The RTX passes all 53 rows and WARP, 49. It is 50 identical runs on the GPU and 2 on WARP, with 0 debug layer errors and 0 warnings. Out of 50 deliberate errors 49 are detected; the other one only changes an informative column. Out of another 38 in the RTX model, 37 drop below 100% in some row; the other one always gives the same.

Note

Stencil, dithering, and blending with several outputs or logic are not looked at. How AMD rounds is unknown. The model is empirical, from this RTX, and only with the six blends in the table.

Pipeline cache

--cache DIR saves a pipeline in one process and loads it in another one, which creates other static samplers first. The texture tells apart the three samplers of its root signature: point must give 0, linear 0.25 and trilinear 1.1875. Each read is a process of its own, with a pipeline the driver has never seen: graphics, compute, mesh and, with a 78 KB shader, graphics and compute again. It takes a bit over three minutes, with small temporary files in DIR. On the RTX, with driver 32.0.16.2124, when nothing was created before saving:

The process that loads creates Graphics Compute, on load Compute, 1 s later
nothing else right right right
10 other samplers, before 3.0625 4 4 3.0625 4 4 right
its own three reversed, before 1.1875 0.25 0 1.1875 0.25 0 right
10 other samplers, after its own right right right
10 other samplers, released before its own right right right
  • The driver accepts the pipeline and reads with other samplers, without any error, from CachedPSO and from ID3D12PipelineLibrary. Compiled cold it is always right. Others found it in XCL. Mesh and the large shaders give the same in the rows tested with them.
  • The 119 wrong reads out of 336 are all the ones their model predicts: the cache keeps the place of each sampler in a table of the process, by order of creation. A released place keeps what it had: it goes to the same sampler if it comes back and, if not, to the first one that arrives. That last part was not in the model, which failed on a new row.
  • In compute it fixes itself, with the same pipeline, and in graphics and mesh it does not: they are still wrong after 20 s. The driver surely uses what was saved while it prepares the good one. How long it takes depends on the size: the large shader, which takes 0.3 s to compile cold, was still wrong 0.2 s after loading it and right after 3 s.
  • A test may miss it: if it reads as soon as it loads, a second process is right with a shader of 5 KB or less and wrong with one of 40 KB or more, also after compiling it cold. In between it comes out one way or the other.
  • WARP is right in all 336.

A prelude fixes it, in compute and right on load too: a root signature with the program's samplers and others, which every process creates before anything else, in the same order. That is an idea from others as well. If the process that saves created it:

The process that loads creates On load
the same prelude right
the same prelude and, after it, 10 other samplers right
a new sampler and, after it, the prelude 4 0 0.25
the samplers of the prelude in another order 4 4 4
nothing 0 0 0

In mesh, besides, the description must carry the topology (PRIMITIVE_TOPOLOGY). Without it the runtime does not accept what was saved, on WARP either: it gives E_INVALIDARG.

What gives PASS and how it is checked

What gives PASS: every read with its own samplers, or that the driver rejects what was saved. WARP passes and the RTX does not: 31 of 56 rows FAIL. The RTX gives the same, cell by cell, in 5 runs, and WARP in 2. With another copy of the program at the same time a few compute reads change. There are 0 debug layer errors and 0 warnings. All 31 deliberate errors in the program, the model and the shaders are detected. Below each table, the program prints the median of what it takes to create or load the pipeline: in compute, 18 to 24 ms cold, 1.3 to 1.7 on the first load and 0.5 on the second; with the large shader, about 300, 21 to 23 and 1.

Note

One card and one driver: whether it happens on others is only known from what others report. The waiting times and the sizes come from a separate measurement, with 1 to 5 repeats. That the driver prepares the good one behind is deduced from them.

What a PASS proves

That, on that adapter and with that driver, D3D12 reproduces bit for bit the semantics of an exclusive prefix sum of 64 logical threads with integers. It does so only with SV_GroupIndex, groupshared and group barriers, without depending on the width or the order of the physical lanes.

The divergence test adds that WavePrefixSum, WavePrefixCountBits and WaveActiveCountBits are reproduced bit for bit inside an if/else and a loop with an early exit, also with another divergent loop nested inside, for 8 patterns of active lanes and groups of 64 and 256 threads.

The three-level test adds a return in the innermost loop. After it, the physical wave is not defined the same way everywhere: the RTX 4070 SUPER brings the lanes back together after the if/else, and the reference matches it (0 mismatches); WARP does not, and differs in 376,085 values, all of them in the final count. The translation passes on both because it assumes they come back together; what the original hardware does is not known.

The float test proves that the translation is deterministic: it always sums in the same tree, which the CPU reproduces bit for bit, and the minimum, the maximum and the fixed point are exact. It does not prove that it matches a console's float sum bit for bit: HLSL does not fix the order of WavePrefixSum, and AMD's is not public.

Measured with rounding (odd groups) RTX 4070 SUPER WARP
Emulated sum equal to the sequential one 174,591 of 524,288 (33%) same
Physical WavePrefixSum equal to the sequential one 235,886 of 524,288 (45%) 524,288 (100%)
Worst error of the emulated sum / theoretical bound 0.49 0.49

With data whose partial sums are exact (even groups), everything matches bit for bit.

With divergence, the summation order also changes the control flow: 35,084 of 524,288 lanes with rounding run a different number of iterations when summing in a tree instead of in sequence. The emulated sum equals the sequential one in 195,985 (37%), and the physical one of the RTX 4070 SUPER equals its own sequential reference in 249,371 (48%; WARP, 100%). With nested loops the figures are 36,889 lanes, 167,689 (32%) and 218,309 (42%; WARP, 100%).

The special-case test covers NaN, infinities, signed zeros and denormals, also in float16_t. HLSL leaves several points open, so what the physical wave does was measured:

Case RTX 4070 SUPER WARP The translation
NaN in WaveActiveMin/Max, float ignores them (100%) ignores them (100%) ignores them
NaN in WaveActiveMin/Max, float16_t no: 96–97%, and different in each lane ignores them (100%) ignores them
Denormals flushed: also in minimum and maximum? yes (100%) yes yes
Sign of the minimum of +0 and −0, float −0 (100%) depends on order (56%) −0
Every active lane is NaN and the wave is incomplete ±FLT_MAX ±infinity NaN
Actual precision of min16float 16 bits (365,804 of 365,804) 16 bits (same) not applicable

A first version did not flush denormals in the minimum and gave PASS, because the reference had the same mistake; the comparison with the physical wave revealed it.

Why float16_t fails on the RTX 4070 SUPER. It behaves like a butterfly reduction: each lane combines with its partner at distance 16, 8, 4, 2 and 1, keeping a < b ? a : b. With a NaN that comparison is false, so the NaN jumps to the partner at every step, ends up in the mirror lane (31 − n) and erases partial minimums along the way. That is why WaveActiveMin gives different results in lanes of the same wave. This model reproduces the 1,048,576 values of the minimum and those of the maximum, including the sign of zeros. It is an inference from the results: the driver's code is not public. It does not happen with float.

With divergence, it adds that the NaN and infinities of inactive lanes do not leak in, and that a comparison with NaN does not take the lane out of the loop. The ±FLT_MAX and infinity row was measured there: with a full wave both give NaN, but if any lane is missing the internal identity value surfaces, and it differs between adapters. There is no common semantics to imitate.

Nested loops repeat the same with two levels. The first version gave PASS but did not detect a lane with NaN leaving the inner loop early: if its acc is NaN, so is that of every later lane, and it does not show. It was strengthened so that the inner loop uses WaveActiveMin of the lanes still inside, and now it is detected.

Warning

What it does not cover. It does not cover more than three loop levels or equivalence with a real console. It assumes the logical wave is SV_GroupIndex / 64 and the lane SV_GroupIndex % 64; HLSL does not guarantee that the original hardware distributes threads that way.

Details

Tests and shaders
Path Shader What it is for Does it decide the result?
1. Physical prefix_wave_default.cso (cs_6_0) WavePrefixSum with whatever wave the driver picks. Records WaveGetLaneCount, WaveGetLaneIndex and a wave id to see where the sum restarts. No (diagnostic)
2. Logical 64 prefix_logical64.cso (cs_6_0) Scan over SV_GroupIndex with groupshared and barriers in uniform flow. Uses no wave intrinsics. Yes: PASS/FAIL and exit code
2b. Logical 64, groups of 256 prefix_logical256.cso (cs_6_0, -D GROUP_SIZE=256) The same sum with 4 logical waves per group. Yes
3. Native prefix_wave_native64.cso (cs_6_6) [WaveSize(64)], only if the adapter declares 64 within [WaveLaneCountMin, WaveLaneCountMax] and SM 6.6. No (reported separately)
Divergence divergence_logical64.cso (cs_6_0) 64-lane sum and ballot inside a divergent if/else and loop, translated with predicates. Yes
Divergence 256 divergence_logical256.cso (cs_6_0, -D GROUP_SIZE=256) The same with 4 logical waves per group, each with a different lane pattern and iteration count. Yes
Nested loops nested_logical64.cso and nested_logical256.cso (-D NESTED=1) One divergent loop inside another, each with its own vote and early exit. nested_wave.cso is its physical version. Yes
Three levels with return deep_logical64.cso and deep_logical256.cso (-D DEEP=1) Three divergent loops; the innermost one does return and the lane stops counting in everything after it. deep_wave.cso is the physical version. Yes
Physical divergence divergence_wave.cso (cs_6_0, -D PHYSICAL=1) The original program with the driver's wave. Validates the CPU reference against hardware. No (diagnostic)
Floats float_logical64.cso and float_logical256.cso (cs_6_0) Exclusive sum, minimum and maximum of floats, and the sum in fixed point. float_wave.cso is the physical WavePrefixSum. Yes
Floats with divergence float_divergence_logical64.cso and float_divergence_logical256.cso Float sums and minimums inside branches and a loop whose exit depends on the last bits. float_divergence_wave.cso is the physical version. Yes
Special cases special_preserve_*, special_ftz_* and half_* (cs_6_2); with divergence, *_div_* (-D DIVERGENT=1); in nested loops, *_nested_* (also -D NESTED=1) NaN, infinities, ±0 and denormals, with -denorm preserve, -denorm ftz and float16_t. The _wave versions are the physical ones; min16_logical64.cso measures the precision of min16float. Yes
Floats in nested loops float_nested_logical64.cso and float_nested_logical256.cso (-D NESTED=1) A float loop inside another; the iterations and exit of the inner one depend on the bits of the result. float_nested_wave.cso is the physical version. Yes

Input data (16,384 groups of 64; the output table shows the first two):

  • Case 0: 64 values equal to 1. The CPU must give e[31]=31, e[32]=32, e[63]=63; the program checks it before using the GPU.
  • Case 1 and remaining groups: integers 0..15 generated with an LCG of fixed seed 0x5EED1234. It is an explicit LCG, not std::uniform_int_distribution, so that the sequence is the same with any compiler.

The physical path is validated without assuming any lane order. The CPU groups the threads by (group, WaveReadLaneFirst(SV_GroupIndex)), sorts them by physical lane and recomputes the sum in that order.

Sensitivity: does it detect missing barriers?

tests/controls.py breaks the shaders in 594 ways and checks that the test gives FAIL. It takes about 25 minutes with 10 runs per control, and needs Python and build.bat:

python tests/controls.py                                 # all of them
python tests/controls.py --reps 1                        # quick, a couple of minutes
python tests/controls.py --only "float_" --adapter 1     # a subset, on WARP

It returns 0 if no control goes undetected, 1 if one does or an original shader fails, and 2 if something cannot run. On WARP it returns 1: it misses 140 of the 594.

Result on the RTX 4070 SUPER: all 594 are detected. 590 failed in every run. The other four are the same race, removing "any: tras limpiar" (after clearing) in floats with groups of 256, and show up sometimes: 90 out of 100 in float_divergence_logical256, 72 out of 100 in half_div_logical256, and 8 and 5 out of 10 in special_preserve_div_logical256 and special_ftz_div_logical256. With --reps 1 they may show as MAL (bad).

The rest of the section summarizes the measurements made by hand before automating them.

Measured on an RTX 4070 SUPER and on WARP (--adapter 1) by removing barriers from prefix_logical64.hlsl. With only 2 groups and the input in the UPLOAD heap, the GPU passed 93 out of 100 times without any barrier.

Shader GPU: FAIL WARP: FAIL
Original (13 barriers) 0/100 0/5
No barriers at all 100/100 5/5
Without the initial barrier 100/100 0/5
Without the barrier after reading 100/100 5/5
Without the barrier after writing 100/100 0/5
Without the last step (offset 32) 100/100 5/5

WARP does not detect every case, so its PASS alone is not enough.

In divergence.hlsl the GPU gives FAIL 20/20 (and 0/100 unmodified) with each of these changes: removing any of the 6 barriers in the code, not predicating the sums of the branch, counting inactive lanes in the vote, not adding the low half of the ballot and skipping the early exit. WARP only detects 6 of the 10.

With groups of 256 the same ten are detected plus three more: mixing waves in the ballot, mixing them in the sum and voting only with the first wave (WARP: 9 of 13). Leaving the loop per individual wave, which is undefined behavior because it leaves threads that never reach the barriers, was only tried on WARP and it passes there: the test does not detect it. It was not run on the GPU because it could hang.

Nested loops add four changes: the inner loop ignoring the mask of the outer one, counting inactive lanes in its vote, skipping its early exit and skipping the count that follows. The GPU gives FAIL 20/20 in the 14 for groups of 64 and in the 17 for groups of 256. WARP detects 10 of 14 and 13 of 17.

In floats.hlsl the GPU gives FAIL 20/20 with eight changes: removing any of the 4 barriers in the code, computing the exclusive sum as inclusive minus own value, skipping the last step, comparing floats as integers without fixing the sign and truncating the fixed point. Groups of 256 add three (mixing waves in the sum, mixing them in the minimum and letting the exclusive sum cross waves). After making the group size a parameter they were repeated 10 times: FAIL 10/10 in the 8 and in the 11. WARP: 5/8 and 8/11. Removing precise does not change the result with this version of DXC and of the driver.

In float_divergence.hlsl the GPU gives FAIL 10/10 in 17 changes with groups of 64 and in 21 with groups of 256, one of them intermittent (WARP: 12/17 and 16/21). Removing the barrier "any: tras leer" (after reading) does not give FAIL because it is redundant: between that read and the next clearing of gsAny there are always other barriers. Leaving the loop per individual wave was not tried here either.

Reference values

Computed on the CPU. The "physical" columns are what a 32-lane wave predicts, not a measurement.

gi case 0: input case 0: CPU case 0: physical 32 case 1: input case 1: CPU case 1: physical 32
0 1 0 0 13 0 0
30 1 30 30 15 243 243
31 1 31 31 14 258 258
32 1 32 0 7 272 0
33 1 33 1 14 279 7
62 1 62 30 7 422 150
63 1 63 31 10 429 157

On a GPU with 32-lane waves, the expected outcome is: physical path consistent with its waves but different from the logical sum (it restarts at gi = 32), logical path PASS and native comparison OMITIDA (skipped) if the wave range is [32, 32].

Project layout
wave64-prefix-test/
├── .github/ISSUE_TEMPLATE        form to share results
├── .github/workflows/warp.yml    automatic tests on WARP
├── LICENSE                       MIT
├── CMakeLists.txt
├── build.bat                     builds without CMake
├── assets/                       charts for the READMEs (charts.py generates them)
├── src/main.cpp                  D3D12 host in C++17
├── src/streaming.h               H2 experiments (--stream, --disk)
├── src/disk.h                    temporary file read without the Windows cache
├── src/bc.h                      BC textures against the CPU (--bc)
├── src/filter.h                  filtering against the CPU (--filter)
├── src/emulate.h                 cost of imitating another GPU (--emulate)
├── src/transcode.h               from BC1 to BC7 with AMD's weights
├── src/frame.h                   all three hypotheses together (--frame)
├── src/lod.h                     LOD and anisotropy against the CPU (--lod)
├── src/raster.h                  rasterization against the CPU (--raster)
├── src/output.h                  output against the CPU (--output)
├── src/cache.h                   pipelines saved by another process (--cache)
├── tests/controls.py             sensitivity controls
└── shaders/
    ├── prefix_logical64.hlsl     path 2 (main): groupshared + barriers
    ├── divergence.hlsl           wave operations inside branches and loops
    ├── common.hlsli              shared data, masks and group size
    ├── floats.hlsl               sum, minimum and maximum of floats
    ├── float_divergence.hlsl     the same inside branches and loops
    ├── specials.hlsl             NaN, infinities, denormals and 16 bits
    ├── stream_read.hlsl          H2 texture reads
    ├── bc_read.hlsl              H3 BC texture reads
    ├── filter.hlsl               H3 texture filtering
    ├── lod.hlsl                  H3 LOD and anisotropy
    ├── raster.hlsl               vertex and pixel shader for --raster
    ├── output.hlsl               vertex and pixel shader for --output
    ├── cache.hlsl                pixel, compute and mesh shader for --cache
    ├── emulate.hlsl              BC1 and filter in the shader, H3
    └── prefix_wave.hlsl          path 1 (physical WavePrefixSum) and
                                  path 3 ([WaveSize(64)] with -D NATIVE_WAVE64=1)

About

Direct3D 12 test bench: can a GPU with 32-lane waves behave like one with 64? Waves, memory, textures and image conformance, checked bit by bit against the CPU.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages