Skip to content

Commit b4c9b9f

Browse files
committed
renderStandaloneView() needs a driver and engine flush
1 parent e59972b commit b4c9b9f

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

filament/src/details/Renderer.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,20 @@ void FRenderer::renderStandaloneView(FView const* view) {
574574
1'000'000'000.0 / mDisplayInfo.refreshRate),
575575
mFrameId);
576576

577-
renderInternal(view);
577+
// because we don't have a "present" call, we use flush so the driver can submit
578+
// the command buffer; we do this before driver.endFrame() to mimic what would
579+
// happen with Renderer::beginFrame/endFrame.
580+
renderInternal(view, true);
578581

579582
driver.endFrame(mFrameId);
580583

581-
// This is a workaround for internal bug b/361822355.
582-
// TODO: properly address the bug and remove this workaround.
584+
// engine.flush() has already been called by renderInternal(), but we need an extra one
585+
// for endFrame() above. This operation in actually not too heavy, it just kicks the
586+
// driver thread, which is mostlikely already running.
587+
engine.flush();
588+
589+
// FIXME: This is a workaround for internal bug b/361822355.
590+
// properly address the bug and remove this workaround.
583591
if (engine.getBackend() == Backend::VULKAN) {
584592
engine.flushAndWait();
585593
}
@@ -600,11 +608,11 @@ void FRenderer::render(FView const* view) {
600608
assert_invariant(mSwapChain);
601609

602610
if (UTILS_LIKELY(view && view->getScene() && view->hasCamera())) {
603-
renderInternal(view);
611+
renderInternal(view, false);
604612
}
605613
}
606614

607-
void FRenderer::renderInternal(FView const* view) {
615+
void FRenderer::renderInternal(FView const* view, bool flush) {
608616
FEngine& engine = mEngine;
609617

610618
FILAMENT_CHECK_PRECONDITION(!view->hasPostProcessPass() ||
@@ -621,6 +629,10 @@ void FRenderer::renderInternal(FView const* view) {
621629
// execute the render pass
622630
renderJob(rootArenaScope, const_cast<FView&>(*view));
623631

632+
if (flush) {
633+
engine.getDriverApi().flush();
634+
}
635+
624636
// make sure to flush the command buffer
625637
engine.flush();
626638

filament/src/details/Renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class FRenderer : public Renderer {
189189
return mCommandsHighWatermark;
190190
}
191191

192-
void renderInternal(FView const* view);
192+
void renderInternal(FView const* view, bool flush);
193193
void renderJob(RootArenaScope& rootArenaScope, FView& view);
194194

195195
static std::pair<float, math::float2> prepareUpscaler(math::float2 scale,

0 commit comments

Comments
 (0)