Proposal: Generalize dot to support genIType/genUType

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) {

[INDENT]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;
}

[/INDENT]

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.