Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clarify that ::Create does not enforce 1-per context. Add a test.
  • Loading branch information
matanlurey committed Sep 5, 2023
commit fe13390331fb7e764729c0e0efe2e3ff0cdb6e7d
1 change: 1 addition & 0 deletions impeller/renderer/backend/vulkan/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impeller_component("vulkan_unittests") {
"blit_command_vk_unittests.cc",
"context_vk_unittests.cc",
"pass_bindings_cache_unittests.cc",
"resource_manager_vk_unittests.cc",
"test/mock_vulkan.cc",
"test/mock_vulkan.h",
]
Expand Down
11 changes: 8 additions & 3 deletions impeller/renderer/backend/vulkan/resource_manager_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ class ResourceManagerVK
: public std::enable_shared_from_this<ResourceManagerVK> {
public:
//----------------------------------------------------------------------------
/// @brief Create a shared resource manager. This creates a dedicated
/// thread for resource management. Only one is created per Vulkan
/// context.
/// @brief Creates a shared resource manager (a dedicated thread).
///
/// Upon creation, a thread is spawned which will collect resources as they
/// are reclaimed (passed to `Reclaim`). The thread will exit when the
/// resource manager is destroyed.
///
/// @note Only one |ResourceManagerVK| should be created per Vulkan
/// context, but that contract is not enforced by this method.
///
/// @return A resource manager if one could be created.
///
Expand Down
20 changes: 20 additions & 0 deletions impeller/renderer/backend/vulkan/resource_manager_vk_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <sys/types.h>
#include "flutter/testing/testing.h"
#include "impeller/renderer/backend/vulkan/resource_manager_vk.h"

namespace impeller {
namespace testing {

// While expected to be a singleton per context, the class does not enforce it.
TEST(ResourceManagerVKTest, CreateCreatesANewInstance) {
auto const a = ResourceManagerVK::Create();
auto const b = ResourceManagerVK::Create();
EXPECT_NE(a, b);
}

} // namespace testing
} // namespace impeller