6#include "flutter/testing/testing.h"
8#include "gtest/gtest.h"
18TEST(GPUTracerVK, CanBeDisabled) {
20 MockVulkanContextBuilder()
21 .SetSettingsCallback([](ContextVK::Settings&
settings) {
25 auto tracer = context->GetGPUTracer();
27 ASSERT_FALSE(tracer->IsEnabled());
30TEST(GPUTracerVK, DisabledFrameCycle) {
32 MockVulkanContextBuilder()
33 .SetSettingsCallback([](ContextVK::Settings&
settings) {
37 auto tracer = context->GetGPUTracer();
40 for (
int i = 0;
i < 2;
i++) {
41 tracer->MarkFrameStart();
42 tracer->MarkFrameEnd();
46TEST(GPUTracerVK, CanTraceCmdBuffer) {
48 MockVulkanContextBuilder()
49 .SetSettingsCallback([](ContextVK::Settings&
settings) {
53 auto tracer = context->GetGPUTracer();
55 ASSERT_TRUE(tracer->IsEnabled());
56 tracer->MarkFrameStart();
58 auto cmd_buffer = context->CreateCommandBuffer();
59 auto blit_pass = cmd_buffer->CreateBlitPass();
60 blit_pass->EncodeCommands(context->GetResourceAllocator());
62 auto latch = std::make_shared<fml::CountDownLatch>(1u);
64 if (!context->GetCommandQueue()
69 GTEST_FAIL() <<
"Failed to submit cmd buffer";
72 tracer->MarkFrameEnd();
76 ASSERT_NE(called,
nullptr);
77 ASSERT_TRUE(
std::find(called->begin(), called->end(),
"vkCreateQueryPool") !=
79 ASSERT_TRUE(
std::find(called->begin(), called->end(),
80 "vkGetQueryPoolResults") != called->end());
83TEST(GPUTracerVK, DoesNotTraceOutsideOfFrameWorkload) {
85 MockVulkanContextBuilder()
86 .SetSettingsCallback([](ContextVK::Settings&
settings) {
90 auto tracer = context->GetGPUTracer();
92 ASSERT_TRUE(tracer->IsEnabled());
94 auto cmd_buffer = context->CreateCommandBuffer();
95 auto blit_pass = cmd_buffer->CreateBlitPass();
96 blit_pass->EncodeCommands(context->GetResourceAllocator());
98 auto latch = std::make_shared<fml::CountDownLatch>(1u);
99 if (!context->GetCommandQueue()
104 GTEST_FAIL() <<
"Failed to submit cmd buffer";
111 ASSERT_NE(called,
nullptr);
112 ASSERT_TRUE(
std::find(called->begin(), called->end(),
113 "vkGetQueryPoolResults") == called->end());
118TEST(GPUTracerVK, TracesWithPartialFrameOverlap) {
120 MockVulkanContextBuilder()
121 .SetSettingsCallback([](ContextVK::Settings&
settings) {
125 auto tracer = context->GetGPUTracer();
127 ASSERT_TRUE(tracer->IsEnabled());
128 tracer->MarkFrameStart();
130 auto cmd_buffer = context->CreateCommandBuffer();
131 auto blit_pass = cmd_buffer->CreateBlitPass();
132 blit_pass->EncodeCommands(context->GetResourceAllocator());
134 auto latch = std::make_shared<fml::CountDownLatch>(1u);
135 if (!context->GetCommandQueue()
140 GTEST_FAIL() <<
"Failed to submit cmd buffer";
142 tracer->MarkFrameEnd();
147 ASSERT_NE(called,
nullptr);
148 ASSERT_TRUE(
std::find(called->begin(), called->end(),
"vkCreateQueryPool") !=
150 ASSERT_TRUE(
std::find(called->begin(), called->end(),
151 "vkGetQueryPoolResults") != called->end());
int find(T *array, int N, T item)
def Build(configs, env, options)
std::shared_ptr< std::vector< std::string > > GetMockVulkanFunctions(VkDevice device)
TEST(AiksCanvasTest, EmptyCullRect)