diff options
| author | 2020-12-30 02:06:22 -0300 | |
|---|---|---|
| committer | 2020-12-30 02:10:19 -0300 | |
| commit | 9106ac1e6b912d7098845c346e5465b780bd70dd (patch) | |
| tree | 464269b4d06dd6263f7bd9a37ab9f3bc6ad6489d /src | |
| parent | host_shaders: Add Vulkan assembler compute shaders (diff) | |
| download | yuzu-9106ac1e6b912d7098845c346e5465b780bd70dd.tar.gz yuzu-9106ac1e6b912d7098845c346e5465b780bd70dd.tar.xz yuzu-9106ac1e6b912d7098845c346e5465b780bd70dd.zip | |
video_core: Add a delayed destruction ring abstraction
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/delayed_destruction_ring.h | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 5b73724ce..acf96f789 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -25,6 +25,7 @@ add_library(video_core STATIC | |||
| 25 | command_classes/vic.h | 25 | command_classes/vic.h |
| 26 | compatible_formats.cpp | 26 | compatible_formats.cpp |
| 27 | compatible_formats.h | 27 | compatible_formats.h |
| 28 | delayed_destruction_ring.h | ||
| 28 | dirty_flags.cpp | 29 | dirty_flags.cpp |
| 29 | dirty_flags.h | 30 | dirty_flags.h |
| 30 | dma_pusher.cpp | 31 | dma_pusher.cpp |
diff --git a/src/video_core/delayed_destruction_ring.h b/src/video_core/delayed_destruction_ring.h new file mode 100644 index 000000000..4f1d29c04 --- /dev/null +++ b/src/video_core/delayed_destruction_ring.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <cstddef> | ||
| 9 | #include <utility> | ||
| 10 | #include <vector> | ||
| 11 | |||
| 12 | namespace VideoCommon { | ||
| 13 | |||
| 14 | /// Container to push objects to be destroyed a few ticks in the future | ||
| 15 | template <typename T, size_t TICKS_TO_DESTROY> | ||
| 16 | class DelayedDestructionRing { | ||
| 17 | public: | ||
| 18 | void Tick() { | ||
| 19 | index = (index + 1) % TICKS_TO_DESTROY; | ||
| 20 | elements[index].clear(); | ||
| 21 | } | ||
| 22 | |||
| 23 | void Push(T&& object) { | ||
| 24 | elements[index].push_back(std::move(object)); | ||
| 25 | } | ||
| 26 | |||
| 27 | private: | ||
| 28 | size_t index = 0; | ||
| 29 | std::array<std::vector<T>, TICKS_TO_DESTROY> elements; | ||
| 30 | }; | ||
| 31 | |||
| 32 | } // namespace VideoCommon | ||