Why doesn't the name say ANYTHING about code being attached?
Please let @alfred-valve choose what to do with the pull request.
The name doesn’t need to, when the bug is read it’ll be considered, alfred doesn’t work on big picture. I’ve asked you to read our conduct policy, please do so.
I added one more commit to the pull request referenced in this issue.
Mostly micro-optimizations (such as 1-argument vector constructors), but I also merged my YUV code with fancyquaduber.frag.
Steam Community Discussions topic: http://steamcommunity.com/app/221410/discussions/0/864969953688896715/
You can test the shaders by overriding them while Steam is running in desktop mode.
Restarting Steam brings back the old shaders.
chattr +i doesn't work, it only makes Steam update infinitely.
Hi SiPlus,
Thanks a lot for your interest. Do you have any data showing real performance gains from these changes? As far as the particle shader goes, these aren't "real" branches and the compiler should fold them into a construct similar to your re-factored version. It's just a lot more legible to have the shaders laid out that way, I'm afraid merging this would only make the code harder to grok. Thanks for taking the time to look into it, however.
Never rely on the compiler on OpenGL, because every driver has its own compiler. It's not Direct3D's single FXC.
Nothing extracted yet.
Reported by @SiPlus in a pull request #2569 …
YUV shader
In the YUV shader used by Big Picture on Linux (and, I think, Mac), I replaced scalar operations with vector ones, because vector operations are mostly single instructions and are faster than their unrolled scalar equivalents.
Here is the original code (uniforms, varyings and compiler directives are omitted):
And here is the vectorized code:
As you see, I removed multiple passes for
y,uandv.dotalso usually takes one instruction (and one cycle), so it is used instead of manual multiply-accumulate.The number
0.42723is0.5 - 1.1643 * 0.0625, precalculated so- 0.5can be used on the entire vector.The same unoptimized code (with some very little differences in texture lookups) is also used in
fancyquaduber.fragat#elif defined(TEXTURETYPE_YUV), so the same optimization can apply there. Maybe I'll optimize the shader later too, but it's really huge.Particle shader
The particle shader in the pull request is optimized much higher than the YUV shader.
13 statement lines with branching were replaced with 4 lines without branching.
The original code:
The optimized code:
Branching is a very heavy performance dropper, because pixels are processed in batches in parallel. It's much heavier than redundant arithmetic and clamping.
If there's no branching, the GPU can decode and use one instruction for multiple pixels.
If there is branching, the GPU will need to execute different instructions for different pixels.