summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErico Nunes <nunes.erico@gmail.com>2021-11-16 16:44:39 +0100
committerFlorian Müllner <fmuellner@gnome.org>2023-03-19 21:45:14 +0000
commit70a1ab6af5b2d94d54ec3299288d07a9a6d53561 (patch)
tree336f93ef5d9f69ea5a6df759c13aeae460d566bf
parent860353fb4ed559209871953fe91088fc133f5ad1 (diff)
downloadmutter-70a1ab6af5b2d94d54ec3299288d07a9a6d53561.tar.gz
cogl/onscreen: Discard depth/stencil before swapping buffers
Marking the the depth/stencil as discarded before swapping buffers for the screen signals the GPU that we don't need to keep them around for the future. This helps performance by reducing memory bandwidth usage in some GPUs which may optimize to not write those buffers back to memory at all after rendering, when they would just be cleared right after that anyway. It is not necessary to mark buffers as discarded after swapping buffers. This should have no effect according to the spec (since that is going to be followed by new rendering commands which make the buffer valid again) and removing that has shown no impact in performance tests. Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2091> (cherry picked from commit 523b27e2672efa1a2a1901fb6352e6c50f57f039)
-rw-r--r--cogl/cogl/cogl-onscreen.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c
index ff9e1749a..842ececf7 100644
--- a/cogl/cogl/cogl-onscreen.c
+++ b/cogl/cogl/cogl-onscreen.c
@@ -334,17 +334,16 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SYNC_FRAME)))
cogl_framebuffer_finish (framebuffer);
+ cogl_framebuffer_discard_buffers (framebuffer,
+ COGL_BUFFER_BIT_DEPTH |
+ COGL_BUFFER_BIT_STENCIL);
+
klass->swap_buffers_with_damage (onscreen,
rectangles,
n_rectangles,
info,
user_data);
- cogl_framebuffer_discard_buffers (framebuffer,
- COGL_BUFFER_BIT_COLOR |
- COGL_BUFFER_BIT_DEPTH |
- COGL_BUFFER_BIT_STENCIL);
-
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
CoglFrameInfo *info;
@@ -395,17 +394,16 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
COGL_WINSYS_FEATURE_SWAP_REGION */
g_return_if_fail (klass->swap_region);
+ cogl_framebuffer_discard_buffers (framebuffer,
+ COGL_BUFFER_BIT_DEPTH |
+ COGL_BUFFER_BIT_STENCIL);
+
klass->swap_region (onscreen,
rectangles,
n_rectangles,
info,
user_data);
- cogl_framebuffer_discard_buffers (framebuffer,
- COGL_BUFFER_BIT_COLOR |
- COGL_BUFFER_BIT_DEPTH |
- COGL_BUFFER_BIT_STENCIL);
-
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
CoglFrameInfo *info;