Files
Patrik Lermon 0ffb2b1b9d Bokeh Blur: gather through a kernel of whole-pixel weights, 5x faster on the GPU (#3768)
* render, gpu: Bokeh Blur gathers through a kernel of whole-pixel weights, 5x faster on the GPU

Each bilinear tap's four weights fall on the same offsets around every pixel (a pixel's centre is
a whole number and a half), so vfx::bokeh_kernel sums them per offset once per frame: about 330
reads at amount 10 instead of 1764. The CPU gathers through it, and the GPU reads it from a small
texture in the gather pass's aux slot, in the same order. 1080x1920, M4 Max: amount 10 hexagon
15 -> 3.2 ms on the GPU, 781 -> 114 ms on the CPU; amount 12 disc 58 -> 6.7 ms on the GPU.
New test bokeh_kernel_matches_the_bilinear_taps keeps the old gather as the reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* render: Bokeh kernel offsets stay within 2^20 pixels; the CPU gather adds them saturating

A huge amount on an image too small to halve kept its whole radius, so an offset could reach
i32::MAX and wrap when added to a pixel position (on the GPU, and on 32-bit CPU targets). An
offset past any image's width reads the edge pixel either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:15:29 -05:00
..