5#include "flutter/testing/testing.h"
6#include "gtest/gtest.h"
10#include "vulkan/vulkan_enums.hpp"
15TEST(RenderPassBuilder, CreatesRenderPassWithNoDepthStencil) {
24 auto render_pass =
builder.Build(context->GetDevice());
27 EXPECT_FALSE(
builder.GetDepthStencil().has_value());
30TEST(RenderPassBuilder, CreatesRenderPassWithCombinedDepthStencil) {
42 auto render_pass =
builder.Build(context->GetDevice());
46 auto maybe_color =
builder.GetColorAttachments().find(0u);
47 ASSERT_NE(maybe_color,
builder.GetColorAttachments().end());
48 auto color = maybe_color->second;
50 EXPECT_EQ(
color.initialLayout, vk::ImageLayout::eGeneral);
51 EXPECT_EQ(
color.finalLayout, vk::ImageLayout::eGeneral);
52 EXPECT_EQ(
color.loadOp, vk::AttachmentLoadOp::eClear);
53 EXPECT_EQ(
color.storeOp, vk::AttachmentStoreOp::eStore);
55 auto maybe_depth_stencil =
builder.GetDepthStencil();
56 ASSERT_TRUE(maybe_depth_stencil.has_value());
57 if (!maybe_depth_stencil.has_value()) {
60 auto depth_stencil = maybe_depth_stencil.value();
62 EXPECT_EQ(depth_stencil.initialLayout, vk::ImageLayout::eUndefined);
63 EXPECT_EQ(depth_stencil.finalLayout,
64 vk::ImageLayout::eDepthStencilAttachmentOptimal);
65 EXPECT_EQ(depth_stencil.loadOp, vk::AttachmentLoadOp::eDontCare);
66 EXPECT_EQ(depth_stencil.storeOp, vk::AttachmentStoreOp::eDontCare);
67 EXPECT_EQ(depth_stencil.stencilLoadOp, vk::AttachmentLoadOp::eDontCare);
68 EXPECT_EQ(depth_stencil.stencilStoreOp, vk::AttachmentStoreOp::eDontCare);
71TEST(RenderPassBuilder, CreatesRenderPassWithOnlyStencil) {
82 auto render_pass =
builder.Build(context->GetDevice());
86 auto maybe_depth_stencil =
builder.GetDepthStencil();
87 ASSERT_TRUE(maybe_depth_stencil.has_value());
88 if (!maybe_depth_stencil.has_value()) {
91 auto depth_stencil = maybe_depth_stencil.value();
93 EXPECT_EQ(depth_stencil.initialLayout, vk::ImageLayout::eUndefined);
94 EXPECT_EQ(depth_stencil.finalLayout,
95 vk::ImageLayout::eDepthStencilAttachmentOptimal);
96 EXPECT_EQ(depth_stencil.loadOp, vk::AttachmentLoadOp::eDontCare);
97 EXPECT_EQ(depth_stencil.storeOp, vk::AttachmentStoreOp::eDontCare);
98 EXPECT_EQ(depth_stencil.stencilLoadOp, vk::AttachmentLoadOp::eDontCare);
99 EXPECT_EQ(depth_stencil.stencilStoreOp, vk::AttachmentStoreOp::eDontCare);
102TEST(RenderPassBuilder, CreatesMSAAResolveWithCorrectStore) {
111 auto render_pass =
builder.Build(context->GetDevice());
115 auto maybe_color =
builder.GetColorAttachments().find(0u);
116 ASSERT_NE(maybe_color,
builder.GetColorAttachments().end());
117 auto color = maybe_color->second;
120 EXPECT_EQ(
color.initialLayout, vk::ImageLayout::eGeneral);
121 EXPECT_EQ(
color.finalLayout, vk::ImageLayout::eGeneral);
122 EXPECT_EQ(
color.loadOp, vk::AttachmentLoadOp::eClear);
123 EXPECT_EQ(
color.storeOp, vk::AttachmentStoreOp::eDontCare);
125 auto maybe_resolve =
builder.GetResolves().find(0u);
126 ASSERT_NE(maybe_resolve,
builder.GetResolves().end());
127 auto resolve = maybe_resolve->second;
130 EXPECT_EQ(resolve.initialLayout, vk::ImageLayout::eGeneral);
131 EXPECT_EQ(resolve.finalLayout, vk::ImageLayout::eGeneral);
132 EXPECT_EQ(resolve.loadOp, vk::AttachmentLoadOp::eClear);
133 EXPECT_EQ(resolve.storeOp, vk::AttachmentStoreOp::eStore);
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
TEST(AiksCanvasTest, EmptyCullRect)
#define EXPECT_TRUE(handle)