ReShade FX bitwise operations

More
5 years 1 week ago - 5 years 1 week ago #1 by crosire
ReShade FX bitwise operations was created by crosire
Be aware, this post is intended for shader developers using the ReShade FX shader programming language.

It is probably relativly unknown, but ReShade FX supports bitwise integer operations even on targets which don't have native support for them (like shader model 3). They are emulated there. As this was requested, here is a list of high level code transformations (in pseudocode) ReShade applies for that emulation. It's no rocket science, but still useful to know and could provide as base for optimizations.
!a         =>     (4294967295 - a)

a & b      =>     if (is_pow2(b))          =>     (((a / b) % 2) * b)
                  else if (is_pow2(b + 1)) =>     ((b + 1) * frac(a / (b + 1)))
                  else                     =>     error

a | b      =>     error

a ^ b      =>     error

a << b     =>     (a * exp2(b))

a >> b     =>     (floor(a / exp2(b)))
Last edit: 5 years 1 week ago by crosire.
The following user(s) said Thank You: Wicked Sick, Marty McFly, GroinShooter, Quentin-Tarantino

Please Log in or Create an account to join the conversation.

More
5 years 6 days ago #2 by Wicked Sick
Replied by Wicked Sick on topic ReShade FX bitwise operations
You got me at "optimizations" ^^

Please Log in or Create an account to join the conversation.