Skip to content

Instantly share code, notes, and snippets.

@JayFoxRox
Last active September 26, 2015 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayFoxRox/d98fcc8312d33e69b1df to your computer and use it in GitHub Desktop.
Save JayFoxRox/d98fcc8312d33e69b1df to your computer and use it in GitHub Desktop.
select min and max value
uint x;
uint y;
if (false) { // 46 cycles, 9 instrs.
x = min(ia,ib);
y = max(ia,ib);
}
if (false) { // 30 cycles, 15 instrs.
if (ia <= ib) {
x = ia;
y = ib;
} else {
x = ib;
y = ia;
}
}
if (true) { // 30 cycles, 14 instrs.
x = ib;
y = ia;
if (ia <= ib) {
x = ia;
y = ib;
}
}
if (true) { // 30 cycles, 15 instrs.
uvec2 iab = uvec2(ia,ib);
uvec2 tmp = (iab.x <= iab.y) ? iab.xy : iab.yx;
x = tmp.x;
y = tmp.y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment