microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.88k stars 2k forks source link

Fixed race condition in blur shader with WARP #871

Closed stanard closed 1 month ago

stanard commented 1 month ago

For wave sizes smaller than 8, the blur compute shader had a race condition in the horizontal blur because it reads several pixels from group shared memory and then overwrites them with the blurred value. When running at SIMD widths of 8 or larger, the reads and writes were naturally synchronized. However, WARP has a pseudo-SIMD width of 4, and artifacts were detected. The solution is to add a GroupMemoryBarrierWithGroupSync() after loading the pixels and before storing the convolved result.