Faster shader math, checked before you see it.
SweetOpt reads ReShade FX and HLSL shaders, finds cheaper ways to write their arithmetic, verifies every one, and writes them next to the originals behind preprocessor switches, so you compare them in ReShade and choose.
A taste: a faster sign()
HLSL's sign(x) compiles to two compares, an integer subtract and an integer-to-float conversion, and that conversion is slow on many GPUs. SweetOpt found a form with no conversion at all: one multiply-add with saturate, and one more multiply-add. It gives exactly the same result as sign(x) (checked on every float between ±4,194,304, with the GPUs' flushing of tiny values).
mad(saturate(mad(x, 1e38, 0.5)), 2.0, -1.0)
Cost in fma units per architecture: grey = sign(x), colour = the new form. On Turing sign is already cheap, so there SweetOpt keeps the original; its variant files can pick the fastest form per GPU vendor (SOPT_AUTO).
How it works
1. Find
Every arithmetic statement in the shader becomes a small expression with the value ranges of its inputs (from ui_min / ui_max, texture formats, texture coordinates, and ranges you add).
2. Search
A superoptimizer tries every cheaper program, smallest first, plus a library of known rewrites, and ranks them with cost models measured on real GPUs.
3. Verify
Each candidate is checked against the original on millions of points, under the GPUs' approximate math, and often proven with interval arithmetic. Only what the output cannot tell apart (or what is closer to exact math) survives.
4. Choose
Variants are written next to the original behind switches like SOPT_ALL, with a report of each one's speed and accuracy. You test them in ReShade and keep what you like.
Explore
Rewrite library
Every verified rewrite SweetOpt knows, with what it saves on each GPU architecture.
open →GPU Blueprint
The cost models: what each operation costs on every DirectX 11 GPU architecture, measured on real cards.
open →TexBench findings
Texture formats, filters, caches, writes and blending, and how each GPU orders its pixels.
open →Download
SweetOpt for Windows and Linux (double-click SweetOpt.bat), and GPU Blueprint to measure your own card.