3 ms·
What's the reason for generating 2 versions of each fragment shader (SIMD8 and SIMD16)?
by Narishma 11y ago
What's the reason for generating 2 versions of each fragment shader (SIMD8 and SIMD16)?
- mattst88 11y agoThat's a good question. SIMD8/SIMD16 refers to the number of fragments processed per thread invocation. There is some overhead to spawning a thread, and so processing 16 fragments at a time is typically faster even though the shader itself is doing more work. The driver provides both versions because it's the GPU that decides which version is use and where, even using both versions to shade the same primitive. For instance, on a triangle boundary maybe only 4 or 8 fragments are "lit", so the hardware spawns a SIMD8 thread and saves itself a little work. SIMD16 shaders typically use twice the number of registers as SIMD8, and if they require registers to be spilled to memory it's likely the SIMD8 shader is faster even with the additional thread-spawning overhead. Lots of compiler optimization revolves around trying to squeak in under the register limit to get the program compiled as SIMD16 without spilling. :)