4 ms·
> AVX style vectors IMHO should have been used for all those vec3 and vec4 operations that are used in graphics applications. That is the naive application of
by incrudible 6y ago
> AVX style vectors IMHO should have been used for all those vec3 and vec4 operations that are used in graphics applications.
That is the naive application of SIMD, which many have attempted. It does not lead to a meaningful speedup.
To get a good speedup from SIMD, you need SOA or AOSOA layout. Ergonomically this is already similar to vector instructions.
- phkahler 6y ago>> That is the naive application of SIMD, which many have attempted. It does not lead to a meaningful speedup. How can it not provide a meaningful speedup? If I have 3- or 4-element vectors a,b, and c, with scalars u,v. I want to compute: a = ub + vc; These should be first class data types, passed by value, and that line of code should take 2 SIMD instructions at most. That should also not require a fancy vectorizing compiler to do the analysis to find the parallelism because the data types map directly to the ISA vector registers. GPUs have this, the benefit should be very real.
- atq2119 6y agoBy and large, GPUs don't have this anymore, actually (they used to, but this changed many years ago). On modern GPUs your example is "scalarized" and results in separate instructions for each vector component. Of course execution is still "vectorized", but only in the sense of operating on the data for 16/32/64 threads at once. The reason for this design is that while vec3 and vec4 are common, they are by no means universal in modern shader code. A micro-architecture built on vec3 or vec4 would be under-utilized in the large amounts of shader code that are scalar in the source language. There are some exceptions, e.g. native support for 16-bit vec2 comes naturally on architectures with 32-bit registers. But those are exceptions.