ReShade FX bitwise operations

  • Posts: 3665
4 years 5 months ago - 4 years 5 months ago #1 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)))
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.

  • Posts: 501
4 years 5 months ago #2 by Wicked Sick
You got me at "optimizations" ^^

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