Comment by mfost
5 years ago
This doesn't work for alpha blending since even if you output the color in the right space, the GPU might do blending in sRGB space and mess things up.
Best is to properly declare the target framebuffer as sRGB (if it is) and output linear colors while letting the GPU deal with it.
There be dragons. First, you're assuming the target display device is sRGB! There's a decent chance it isn't these days.
Second, this will prevent HDR.
Most games render to a linear HDR target surface with a very wide dynamic range, and then will tonemap it to the display gamut as the final step. This was common as far back as Valve's Half Life game. I think even the first one did something along these lines!
This is especially important for modern engines that are used by AAA games. E.g. Unreal engine and all similar engines are commonly used for XBox and Playstation games where the output display is a wide-gamut HDR television, not an SDR sRGB computer monitor.