Add a single-pass-fragment-shader path #8
+320
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to make it possible to optimize most of the effects which can be rendered with a single fragment shader pass. The old pipeline uses 3 passes:
The new render code combines all three together in a single fragment shader pass, allowing us to also make efficient use of GL scissor. By reducing the passes, we also reduce the CPU usage.
The idea of how the shaders work:
vec4 effect_color(vec2 pos)
which gives the color from the effect.vec4 overlay_effect(vec2 pos)
. It may call effect_color() to get the color of the effect, or set a color on its own. For example thenone
overlay effect simply returnseffect_color(pos)
.overlay_effect(pos)
.The headers, effect, overlay and main function code are simply concatenated together to form a single shader which is then executed.