diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-09-30 01:11:10 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-10-12 13:33:19 +0200 |
commit | 95fd21a26a2b6316aa5b178d5a1fce24feba13a6 (patch) | |
tree | f66358c21e7577052c3df75d0f20df7412e87131 /src/gui/rhi | |
parent | 5ed0974ef483a36ff0aee6ddc90c777c4a854a1a (diff) |
RHI: introduce a way to disable framebuffer clears on GL
On low-end hardware without fast framebuffer clears one can
significantly reduce the fill rate by disabling framebuffer clears
(provided, as it's usually the case, that the application has content
filling the entire framebuffer).
Add a couple of environment variables to do so, one to disable all
clears and one to disable only color clears (in case the surface is
requested without a depth buffer). Note that disabling all clears
on a surface *with* a depth buffer still requires
QSG_NO_DEPTH_BUFFER to be set, otherwise QtQuick is going to assume
that there is a clean usable depth buffer.
Change-Id: I96ad0a3d28dd0ab65cc960fb7cb2e0a8b6f35628
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 7d7e8a9226..908cdbb547 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3621,13 +3621,16 @@ QGles2RenderTargetData *QRhiGles2::enqueueBindFramebuffer(QRhiRenderTarget *rt, QGles2CommandBuffer::Command &fbCmd(cbD->commands.get()); fbCmd.cmd = QGles2CommandBuffer::Command::BindFramebuffer; + static const bool doClearBuffers = qEnvironmentVariableIntValue("QT_GL_NO_CLEAR_BUFFERS") == 0; + static const bool doClearColorBuffer = qEnvironmentVariableIntValue("QT_GL_NO_CLEAR_COLOR_BUFFER") == 0; + switch (rt->resourceType()) { case QRhiResource::RenderTarget: rtD = &QRHI_RES(QGles2ReferenceRenderTarget, rt)->d; if (wantsColorClear) - *wantsColorClear = true; + *wantsColorClear = doClearBuffers && doClearColorBuffer; if (wantsDsClear) - *wantsDsClear = true; + *wantsDsClear = doClearBuffers; fbCmd.args.bindFramebuffer.fbo = 0; fbCmd.args.bindFramebuffer.colorAttCount = 1; break; |