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>
This commit is contained in:
parent
5fedd065c9
commit
523b27e267
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user