Commit Graph

8 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
49653b0b0a clutter/blur: Select a better n_steps
The n_steps variable corresponds to the number of *pairs* of
texture lookups that the blur shader does. For example, when
n_steps = 1, the for-loop reads 1 pixel before and 1 pixel
after the current one.

Our blur shader is heavily inspired in WebRender's blur shader,
the biggest difference being that we calculate the gaussian
samples in the fragment shader itself, and not in the vertex
shader. (This could be an improvement in performance for the
future though!)

WebRender's blur shader calculates n_steps differently than what
we currently do, though. It calculates n_step in such a way that
at least 2 steps are performed for evey non-zero sigma value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
5fca8f231a clutter/blur: Fix shader loop
We must iterate at least once, and i starts at 1, so use
less-or-equal in the for-loop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
0b4b341e6c clutter/blur: Make sigma a float
The shader already operates on floating point sigma, and
there's just no reason for us to force it to be an unsigned
integer. It's still important that sigma must be positive
though.

Make sigma a float, and make sure it's a positive number.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
925809ea75 clutter/blur: Pass direction as vec2
Yet another way to reduce the instruction count of the fragment
shader. Passing a pair of floats once is virtually free, compared
to computing horizontal and vertical on each fragment run.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
8588352d1d clutter/blur: Remove uniform locations from BlurPass
They're not used anywhere except when setting up the pipeline, so
make them local variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
2020-12-17 13:21:50 +00:00
Georges Basile Stavracas Neto
d717cc9231 clutter/blur: Shortcircuit when sigma is 0
When there's no blur to be performed, don't do any; instead,
return the original texture, and don't run the vertical and
horizontal blur pipelines.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
2020-12-17 03:04:03 +00:00
Georges Basile Stavracas Neto
53f7b6c149 clutter: Simplify framebuffer setup using ortho projection
Setting an ortho projection gives us pretty much the same result as
manually calculating the projection matrix. The ortho projection is
actually more "complete" than the custom projection we've been using,
as it also considers z-near and z-far, but in practice the generated
pixels are exactly equal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1642>
2020-12-16 11:46:26 -03:00
Georges Basile Stavracas Neto
3440fbd358 clutter: Add private ClutterBlur
ClutterBlur is a small helper structure that implements
blurring a texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
2020-12-14 09:43:08 -03:00