9#include "gmock/gmock.h"
28 auto mock_idle_waiter = std::make_shared<MockIdleWaiter>();
31 mock_idle_waiter, 256);
32 EXPECT_CALL(*mock_idle_waiter, WaitIdle());
40 static_assert(
sizeof(Length2) == 2u);
43 GetContext()->GetIdleWaiter(), 256);
45 for (
size_t i = 0;
i < 12500;
i++) {
48 ASSERT_EQ(
view.GetRange(),
Range(
i *
sizeof(Length2), 2u));
56 static_assert(
sizeof(Length2) == 2);
57 struct alignas(16) Align16 {
60 static_assert(
alignof(Align16) == 16);
61 static_assert(
sizeof(Align16) == 16);
64 GetContext()->GetIdleWaiter(), 256);
70 ASSERT_EQ(
view.GetRange(),
Range(0u, 2u));
76 ASSERT_EQ(
view.GetRange().offset, 16u);
77 ASSERT_EQ(
view.GetRange().length, 16u);
82 ASSERT_EQ(
view.GetRange(),
Range(32u, 2u));
88 ASSERT_EQ(
view.GetRange().offset, 48u);
89 ASSERT_EQ(
view.GetRange().length, 16u);
95 GetContext()->GetIdleWaiter(), 256);
97 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 0u);
98 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
99 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 1u);
104 GetContext()->GetIdleWaiter(), 256);
106 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
109 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 1u);
112 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 2u);
115 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 3u);
118 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
122 EmplacingLargerThanBlockSizeCreatesOneOffBufferCallback) {
124 GetContext()->GetIdleWaiter(), 256);
128 auto buffer_view =
buffer->Emplace(1024000 + 10, 0, [](uint8_t*
data) {});
130 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 0u);
131 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
132 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 1u);
137 GetContext()->GetIdleWaiter(), 256);
141 auto buffer_view =
buffer->Emplace(
nullptr, 1024000 + 10, 0);
143 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 0u);
144 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
145 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 1u);
150 GetContext()->GetIdleWaiter(), 256);
153 auto buffer_view_a =
buffer->Emplace(1020000, 0, [](uint8_t*
data) {});
154 auto buffer_view_b =
buffer->Emplace(1020000, 0, [](uint8_t*
data) {});
156 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 1u);
157 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 2u);
158 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
161 for (
auto i = 0;
i < 4;
i++) {
165 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 0u);
166 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 2u);
167 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
171 for (
auto i = 0;
i < 4;
i++) {
175 EXPECT_EQ(
buffer->GetStateForTest().current_buffer, 0u);
176 EXPECT_EQ(
buffer->GetStateForTest().total_buffer_count, 1u);
177 EXPECT_EQ(
buffer->GetStateForTest().current_frame, 0u);
182 GetContext()->GetIdleWaiter(), 256);
185 EXPECT_EQ(
view.GetRange(),
Range(0, 21));
187 view =
buffer->Emplace(64, 16, [](uint8_t*) {});
188 EXPECT_EQ(
view.GetRange(),
Range(32, 64));
206 return delegate_->CreateBuffer(desc);
211 return delegate_->CreateTexture(desc);
215 return delegate_->GetMaxTextureSizeSupported();
219 std::shared_ptr<Allocator> delegate_;
222TEST(GpuSubmissionTrackerTest, WatermarkHandlesOutOfOrderCompletion) {
239 auto tracker = std::make_shared<GpuSubmissionTracker>();
241 GetContext()->GetIdleWaiter(), 256, tracker);
245 uint64_t pending = tracker->RecordSubmission();
251 EXPECT_NE(
buffer->EmplaceUniform(0.0f).GetBuffer(), first_entry);
254 tracker->RecordCompletion(pending);
259 EXPECT_EQ(
buffer->EmplaceUniform(0.0f).GetBuffer(), second_entry);
263 auto tracker = std::make_shared<GpuSubmissionTracker>();
265 GetContext()->GetIdleWaiter(), 256, tracker);
271 tracker->RecordCompletion(tracker->RecordSubmission());
274 EXPECT_EQ(
buffer->EmplaceUniform(0.0f).GetBuffer(), entry);
279 std::shared_ptr<FailingAllocator>
allocator =
280 std::make_shared<FailingAllocator>(GetContext()->GetResourceAllocator());
286 EXPECT_EQ(
view.GetBuffer(),
nullptr);
287 EXPECT_EQ(
view.GetRange().offset, 0u);
288 EXPECT_EQ(
view.GetRange().length, 0u);
An object that allocates device memory.
Tracks GPU completion of submitted command buffers as a monotonic watermark.
uint64_t LatestSubmission() const
Returns the id of the most recent submission.
uint64_t CompletedThrough() const
void RecordCompletion(uint64_t id)
Marks a previously recorded submission as completed by the GPU.
uint64_t RecordSubmission()
Records a command buffer submission and returns its id.
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment, std::shared_ptr< const GpuSubmissionTracker > submission_tracker=nullptr)
virtual void WaitIdle() const =0
std::shared_ptr< Texture > OnCreateTexture(const TextureDescriptor &desc, bool threadsafe)
~FailingAllocator()=default
ISize GetMaxTextureSizeSupported() const override
FailingAllocator(std::shared_ptr< Allocator > delegate)
std::shared_ptr< DeviceBuffer > OnCreateBuffer(const DeviceBufferDescriptor &desc)
MOCK_METHOD(void, WaitIdle,(),(const, override))
std::shared_ptr< ImpellerAllocator > allocator
TEST(FrameTimingsRecorderTest, RecordVsync)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
static constexpr const size_t kMagicFailingAllocation
TEST_P(AiksTest, DrawAtlasNoColor)
static const constexpr size_t kHostBufferArenaSize
Approximately the same size as the max frames in flight.
#define INSTANTIATE_PLAYGROUND_SUITE(playground)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...