diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2020-09-18 09:13:54 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2020-09-18 14:33:39 +0200 |
commit | 76a13b7cf7bdea2344b65f775226a22a17fa78c6 (patch) | |
tree | 3c6cc9d8a6094637d8a4e20e3921c223f46f44d7 | |
parent | 0731f8b336a6792e344dfefad8b7e9c79afac2d2 (diff) |
RHI renderer: begin frame and submit even if we have no commands
We still need to upload textures/buffers which might be needed later on
even if we have no draw calles to perform.
This fixes the following case:
Frame 1: A buffer is created, no command generated -> buffer
data transfer not performed but still recorded in the RHI command buffer
Frame 2: buffer is reallocated (we orphan, destroy the old rhi buffer and
create a new one with the new size as we cannot resize rhi buffers). This
time, we have commands, so we perform data transfer but in this case, we may
crash as we have since destroyed the RHI buffer from Frame 1, yet we still
have in the command buffer the data transfer command for the old rhi buffer
(we have no way of removing commands once they have been inserted in the
command buffer).
With this patch, the data transfer command would get performed at Frame 1
even if we have nothing to draw, ensuring we have no left over transfer
commands when reaching Frame 2.
Change-Id: I48357633f6c2ee727fb74b4fd81af86e5bad68a6
Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r-- | src/plugins/renderers/rhi/renderer/renderer.cpp | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp index 81d1194f3..aa18f093e 100644 --- a/src/plugins/renderers/rhi/renderer/renderer.cpp +++ b/src/plugins/renderers/rhi/renderer/renderer.cpp @@ -680,17 +680,7 @@ void Renderer::render(bool swapBuffers) rhiPassesInfo = prepareCommandsSubmission(renderViews); // 2) Update Pipelines and copy data into commands to allow concurrent submission - bool hasCommands = false; - for (const RenderView *rv : renderViews) { - // TODO find a way to break earlier with this pattern. - rv->forEachCommand([&] (const RenderCommand &cmd) { - hasCommands |= cmd.isValid(); - }); - if (hasCommands) - break; - } - - if (hasCommands) { + { // Scoped to destroy surfaceLock SurfaceLocker surfaceLock(surface); const bool surfaceIsValid = (surface && surfaceLock.isSurfaceValid()); |