View Full Version : Proposal: Generalize dot to support genIType/genUType

Edward Kmett
11-21-2014, 09:27 AM
This really belongs as a post in "Suggestions for the next release of OpenGL" but it won't let me post there as I don't regularly lurk in these parts.

dot doesn't need anything peculiar to floats, and nothing in the mathematical definition of a dot product prevents them from being used over domains such as Gaussian integers, e.g. ivec2

There is no reason it shouldn't be able to be extended to genIType/genUType other than heretofore it hasn't been a priority.

These can be emulated currently by the user by "polyfilling" the functionality with something like:

int dot(ivec4 a, ivec4 b) {

ivec4 c = a * b;
ivec2 b = a.xy + a.zw;
return b.x + b.y;

int dot(ivec3 a, ivec3 b) {

ivec3 c = a * b;
return c.x + c.y + c.z;

int dot(ivec2 a, ivec2 b) {

ivec2 c = a * b;
return c.x + c.y;

and similarly of course for genUType, so there is no issue with introducing this from a vendor portability standpoint, but it'd be nice to make it possible for vendors to let us use more optimized operations in the hardware where available.