chunky to planar
category: code [glöplog]
Quote:
@krabob: IIRC it's hidden somewhere here:
http://graphics.stanford.edu/~seander/bithacks.html
Nice page, but it doesn't seem to contain anything about clamping or saturating addition, or even computations on individual bytes in parallel, apart from detecting a specific byte value.
Quote:
Compute the minimum (min) or maximum (max) of two integers without branching
Isn't that clamping ?
It is, though the first version
Clamping to a power of two minus one is not mentioned as a special case, though. There are special tricks for that (as discussed in the ADA thread).
Quote:
isn't really without branching, as the comparison will usually be compiled into a branch.r = y ^ ((x ^ y) & -(x < y)); // min(x, y)
Clamping to a power of two minus one is not mentioned as a special case, though. There are special tricks for that (as discussed in the ADA thread).
yeah thanks, that's the thread I was searching for ! I dunno why I thought windden posted on it.
When akawalampadu was out, I understood you did it after that thread, perfect job as always !!
And fucking good double trick !
When akawalampadu was out, I understood you did it after that thread, perfect job as always !!
And fucking good double trick !
Yeah I know I'm late, but...
Well that depends on your platform, e.g. MIPS has "slt", and x86 has set* and cmov.
Quote:
Code:r = y ^ ((x ^ y) & -(x < y)); // min(x, y)
isn't really without branching, as the comparison will usually be compiled into a branch.
Well that depends on your platform, e.g. MIPS has "slt", and x86 has set* and cmov.
68k CPUs also have Scc opcodes.