ReShade FX bitwise operations

  • crosire
  • Topic Author
More
9 years 11 months ago - 9 years 11 months 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: 9 years 11 months 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.

  • Wicked Sick
More
9 years 11 months 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.