| Flutter Impeller |

render_pass_vk_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/testing/testing.h" // IWYU pragma: keep
6 #include "gtest/gtest.h"
7 #include "impeller/core/formats.h"
8 #include "impeller/renderer/backend/vulkan/render_pass_builder_vk.h"
9 #include "impeller/renderer/backend/vulkan/render_pass_vk.h"
10 #include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
11 #include "impeller/renderer/render_target.h"
12 #include "vulkan/vulkan_enums.hpp"
13
14 namespace impeller {
15 namespace testing {
16
17 TEST(RenderPassVK, DoesNotRedundantlySetStencil) {
18 std::shared_ptr<ContextVK> context = MockVulkanContextBuilder().Build();
19 std::shared_ptr<Context> copy = context;
20 auto cmd_buffer = context->CreateCommandBuffer();
21
22 RenderTargetAllocator allocator(context->GetResourceAllocator());
23 RenderTarget target = allocator.CreateOffscreenMSAA(*copy.get(), {1, 1}, 1);
24
25 std::shared_ptr<RenderPass> render_pass =
26 cmd_buffer->CreateRenderPass(target);
27
28 // Stencil reference set once at buffer start.
29 auto called_functions = GetMockVulkanFunctions(context->GetDevice());
30 EXPECT_EQ(std::count(called_functions->begin(), called_functions->end(),
31 "vkCmdSetStencilReference"),
32 1);
33
34 // Duplicate stencil ref is not replaced.
35 render_pass->SetStencilReference(0);
36 render_pass->SetStencilReference(0);
37 render_pass->SetStencilReference(0);
38
39 called_functions = GetMockVulkanFunctions(context->GetDevice());
40 EXPECT_EQ(std::count(called_functions->begin(), called_functions->end(),
41 "vkCmdSetStencilReference"),
42 1);
43
44 // Different stencil value is updated.
45 render_pass->SetStencilReference(1);
46 called_functions = GetMockVulkanFunctions(context->GetDevice());
47 EXPECT_EQ(std::count(called_functions->begin(), called_functions->end(),
48 "vkCmdSetStencilReference"),
49 2);
50 }
51
52 } // namespace testing
53 } // namespace impeller
impeller::RenderPassVK
Definition: render_pass_vk.h:21
impeller::RenderTargetAllocator
a wrapper around the impeller [Allocator] instance that can be used to provide caching of allocated r...
Definition: render_target.h:149
impeller::RenderTargetAllocator::CreateOffscreenMSAA
virtual RenderTarget CreateOffscreenMSAA(const Context &context, ISize size, int mip_count, std::string_view label="Offscreen MSAA", RenderTarget::AttachmentConfigMSAA color_attachment_config=RenderTarget::kDefaultColorAttachmentConfigMSAA, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_msaa_texture=nullptr, const std::shared_ptr< Texture > &existing_color_resolve_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr)
Definition: render_target.cc:376
impeller::RenderTarget
Definition: render_target.h:38
formats.h
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller
Definition: allocation.cc:12
render_pass_builder_vk.h
render_pass_vk.h
render_target.h