Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 629f5c2

Browse files
[Impeller] Increase host buffer arena count to 4. (#54808)
It seems like on some ANdroid devices we can actually get 4 pending frames even with the 3 frame wait. I thought about this a lot but too hard. Lets bump it up one. Also minor comment fixes in ahb swapchain.
1 parent cfc5c1b commit 629f5c2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

impeller/core/host_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace impeller {
2020

2121
/// Approximately the same size as the max frames in flight.
22-
static const constexpr size_t kHostBufferArenaSize = 3u;
22+
static const constexpr size_t kHostBufferArenaSize = 4u;
2323

2424
/// The host buffer class manages one more 1024 Kb blocks of device buffer
2525
/// allocations.

impeller/entity/contents/host_buffer_unittests.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ TEST_P(HostBufferTest, ResetIncrementsFrameCounter) {
9090
buffer->Reset();
9191
EXPECT_EQ(buffer->GetStateForTest().current_frame, 2u);
9292

93+
buffer->Reset();
94+
EXPECT_EQ(buffer->GetStateForTest().current_frame, 3u);
95+
9396
buffer->Reset();
9497
EXPECT_EQ(buffer->GetStateForTest().current_frame, 0u);
9598
}
@@ -131,7 +134,7 @@ TEST_P(HostBufferTest, UnusedBuffersAreDiscardedWhenResetting) {
131134
EXPECT_EQ(buffer->GetStateForTest().current_frame, 0u);
132135

133136
// Reset until we get back to this frame.
134-
for (auto i = 0; i < 3; i++) {
137+
for (auto i = 0; i < 4; i++) {
135138
buffer->Reset();
136139
}
137140

@@ -141,7 +144,7 @@ TEST_P(HostBufferTest, UnusedBuffersAreDiscardedWhenResetting) {
141144

142145
// Now when we reset, the buffer should get dropped.
143146
// Reset until we get back to this frame.
144-
for (auto i = 0; i < 3; i++) {
147+
for (auto i = 0; i < 4; i++) {
145148
buffer->Reset();
146149
}
147150

impeller/renderer/backend/vulkan/swapchain/ahb/ahb_swapchain_impl_vk.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "impeller/renderer/backend/vulkan/swapchain/surface_vk.h"
1616
#include "impeller/toolkit/android/surface_transaction.h"
1717
#include "impeller/toolkit/android/surface_transaction_stats.h"
18+
#include "vulkan/vulkan_to_string.hpp"
1819

1920
namespace impeller {
2021

@@ -111,20 +112,21 @@ std::unique_ptr<Surface> AHBSwapchainImplVK::AcquireNextDrawable() {
111112
return nullptr;
112113
}
113114

114-
auto context = transients_->GetContext().lock();
115-
if (context) {
116-
ContextVK::Cast(*context).GetGPUTracer()->MarkFrameStart();
117-
}
118-
119115
// Ask the GPU to wait for the render ready semaphore to be signaled before
120116
// performing rendering operations.
121117
if (!SubmitWaitForRenderReady(pool_entry.render_ready_fence,
122118
pool_entry.texture)) {
123-
VALIDATION_LOG << "Could not submit a command to the GPU to wait on render "
124-
"readiness.";
119+
VALIDATION_LOG << "Could wait on render ready fence.";
125120
return nullptr;
126121
}
127122

123+
#if IMPELLER_DEBUG
124+
auto context = transients_->GetContext().lock();
125+
if (context) {
126+
ContextVK::Cast(*context).GetGPUTracer()->MarkFrameStart();
127+
}
128+
#endif // IMPELLER_DEBUG
129+
128130
auto surface = SurfaceVK::WrapSwapchainImage(
129131
transients_, pool_entry.texture,
130132
[signaler = auto_sema_signaler, weak = weak_from_this(),
@@ -154,10 +156,12 @@ bool AHBSwapchainImplVK::Present(
154156
return false;
155157
}
156158

159+
#if IMPELLER_DEBUG
157160
auto context = transients_->GetContext().lock();
158161
if (context) {
159162
ContextVK::Cast(*context).GetGPUTracer()->MarkFrameEnd();
160163
}
164+
#endif // IMPELLER_DEBUG
161165

162166
if (!texture) {
163167
return false;
@@ -308,8 +312,8 @@ bool AHBSwapchainImplVK::SubmitWaitForRenderReady(
308312
);
309313

310314
if (!(result == vk::Result::eSuccess || result == vk::Result::eTimeout)) {
311-
VALIDATION_LOG << "Fence waiter encountered an unexpected error. Tearing "
312-
"down the waiter thread.";
315+
VALIDATION_LOG << "Encountered error while waiting on swapchain image: "
316+
<< vk::to_string(result);
313317
return false;
314318
}
315319

0 commit comments

Comments
 (0)