5#include "flutter/testing/testing.h"
6#include "gtest/gtest.h"
11#include "vulkan/vulkan_enums.hpp"
12#include "vulkan/vulkan_handles.hpp"
19 impeller::vk::MetalSurfaceCreateInfoEXT createInfo = {};
21 context.
GetInstance().createMetalSurfaceEXTUnique(createInfo);
29TEST(SwapchainTest, CanCreateSwapchain) {
39TEST(SwapchainTest, RecreateSwapchainWhenSizeChanges) {
48 auto expected_size =
ISize{1, 1};
49 EXPECT_EQ(
image->GetSize(), expected_size);
54 auto image_b =
swapchain->AcquireNextDrawable();
55 expected_size =
ISize{100, 100};
56 EXPECT_EQ(image_b->GetSize(), expected_size);
59TEST(SwapchainTest, CachesRenderPassOnSwapchainImage) {
71 std::vector<std::shared_ptr<Texture>> msaa_textures;
72 std::vector<std::shared_ptr<Texture>> depth_stencil_textures;
73 for (
auto i = 0u;
i < 3u;
i++) {
74 auto drawable =
swapchain->AcquireNextDrawable();
75 RenderTarget render_target = drawable->GetTargetRenderPassDescriptor();
79 EXPECT_EQ(texture_vk.GetCachedFramebuffer(),
nullptr);
80 EXPECT_EQ(texture_vk.GetCachedRenderPass(),
nullptr);
82 auto command_buffer = context->CreateCommandBuffer();
83 auto render_pass = command_buffer->CreateRenderPass(render_target);
84 render_pass->EncodeCommands();
87 depth_stencil_textures.push_back(depth.has_value() ? depth->texture
89 msaa_textures.push_back(
93 for (
auto i = 1;
i < 3;
i++) {
94 EXPECT_EQ(msaa_textures[
i - 1], msaa_textures[
i]);
95 EXPECT_EQ(depth_stencil_textures[
i - 1], depth_stencil_textures[
i]);
101 std::vector<SharedHandleVK<vk::Framebuffer>> framebuffers;
102 std::vector<SharedHandleVK<vk::RenderPass>> render_passes;
103 for (
auto i = 0u;
i < 3u;
i++) {
104 auto drawable =
swapchain->AcquireNextDrawable();
105 RenderTarget render_target = drawable->GetTargetRenderPassDescriptor();
110 EXPECT_NE(texture_vk.GetCachedFramebuffer(),
nullptr);
111 EXPECT_NE(texture_vk.GetCachedRenderPass(),
nullptr);
112 framebuffers.push_back(texture_vk.GetCachedFramebuffer());
113 render_passes.push_back(texture_vk.GetCachedRenderPass());
118 for (
auto i = 0u;
i < 3u;
i++) {
119 auto drawable =
swapchain->AcquireNextDrawable();
120 RenderTarget render_target = drawable->GetTargetRenderPassDescriptor();
125 EXPECT_EQ(texture_vk.GetCachedFramebuffer(), framebuffers[
i]);
126 EXPECT_EQ(texture_vk.GetCachedRenderPass(), render_passes[
i]);
static TextureVK & Cast(Texture &base)
vk::Instance GetInstance() const
std::shared_ptr< Texture > GetRenderTargetTexture() const
const std::map< size_t, ColorAttachment > & GetColorAttachments() const
const std::optional< DepthAttachment > & GetDepthAttachment() const
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
#define FML_DCHECK(condition)
sk_sp< const SkImage > image
TEST(AiksCanvasTest, EmptyCullRect)
vk::UniqueSurfaceKHR CreateSurface(const ContextVK &context)
void SetSwapchainImageSize(ISize size)
Override the image size returned by all swapchain images.
#define EXPECT_TRUE(handle)