5 #include "gtest/gtest.h"
8 #include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
13 using impeller::testing::GetMockVulkanFunctions;
14 using impeller::testing::MockVulkanContextBuilder;
18 "VK_ANDROID_external_memory_android_hardware_buffer",
19 "VK_KHR_sampler_ycbcr_conversion",
20 "VK_KHR_external_memory",
21 "VK_EXT_queue_family_foreign",
22 "VK_KHR_dedicated_allocation",
27 bool IsValid()
const override {
return true; }
29 ASurfaceControl*
GetHandle()
const override {
return nullptr; }
34 TEST(AndroidAHBSwapchainTest,
35 AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure) {
36 bool wait_for_fences_called =
false;
38 MockVulkanContextBuilder()
40 .SetAcquireNextImageCallback(
41 [](VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence,
42 uint32_t*) -> VkResult {
return VK_ERROR_SURFACE_LOST_KHR; })
43 .SetWaitForFencesCallback([&](VkDevice, uint32_t,
const VkFence*,
44 VkBool32, uint64_t) -> VkResult {
45 wait_for_fences_called =
true;
50 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(
new AHBSwapchainVK(
51 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100},
false));
53 auto image = ahb_swapchain->AcquireNextDrawable();
56 ahb_swapchain->AcquireNextDrawable();
57 EXPECT_FALSE(wait_for_fences_called);
60 TEST(AndroidAHBSwapchainTest, AHBSwapchainDtorCallsWaitIdle) {
61 const auto context = MockVulkanContextBuilder()
65 auto ahb_swapchain = std::shared_ptr<AHBSwapchainVK>(
new AHBSwapchainVK(
66 context, std::make_shared<FakeSurfaceControl>(), {}, {100, 100},
false));
68 ahb_swapchain.reset();
70 auto called_functions = GetMockVulkanFunctions(
context->GetDevice());
71 EXPECT_NE(std::find(called_functions->begin(), called_functions->end(),
73 called_functions->end());
The implementation of a swapchain that uses hardware buffers presented to a given surface control on ...
A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asur...
ASurfaceControl * GetHandle() const override
bool IsValid() const override
bool RemoveFromParent() const override
Remove the surface control from the hierarchy of nodes presented by the system compositor.
TEST(AndroidAHBSwapchainTest, AHBSwapchainNoFenceWaitAfterAcquireNextImageFailure)
const std::vector< std::string > kAndroidDeviceExtensions
std::shared_ptr< ContextGLES > context