Compare commits
1 commit
52cbf4507b
...
2700929161
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2700929161 |
7 changed files with 5 additions and 82 deletions
|
@ -312,7 +312,7 @@ vk::DescriptorPool CreateWrappedDescriptorPool(const Device& device, size_t max_
|
|||
return device.GetLogical().CreateDescriptorPool(VkDescriptorPoolCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||
.flags = 0,
|
||||
.maxSets = static_cast<u32>(max_sets),
|
||||
.poolSizeCount = static_cast<u32>(pool_sizes.size()),
|
||||
.pPoolSizes = pool_sizes.data(),
|
||||
|
|
|
@ -19,9 +19,7 @@ struct CommandPool::Pool {
|
|||
CommandPool::CommandPool(MasterSemaphore& master_semaphore_, const Device& device_)
|
||||
: ResourcePool(master_semaphore_, COMMAND_BUFFER_POOL_SIZE), device{device_} {}
|
||||
|
||||
CommandPool::~CommandPool() {
|
||||
Drain();
|
||||
}
|
||||
CommandPool::~CommandPool() = default;
|
||||
|
||||
void CommandPool::Allocate(size_t begin, size_t end) {
|
||||
// Command buffers are going to be committed, recorded, executed every single usage cycle.
|
||||
|
|
|
@ -80,7 +80,7 @@ static void AllocatePool(const Device& device, DescriptorBank& bank) {
|
|||
bank.pools.push_back(device.GetLogical().CreateDescriptorPool({
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||
.flags = 0,
|
||||
.maxSets = sets_per_pool,
|
||||
.poolSizeCount = static_cast<u32>(pool_cursor),
|
||||
.pPoolSizes = std::data(pool_sizes),
|
||||
|
@ -92,10 +92,6 @@ DescriptorAllocator::DescriptorAllocator(const Device& device_, MasterSemaphore&
|
|||
: ResourcePool(master_semaphore_, SETS_GROW_RATE), device{&device_}, bank{&bank_},
|
||||
layout{layout_} {}
|
||||
|
||||
DescriptorAllocator::~DescriptorAllocator() {
|
||||
Drain();
|
||||
}
|
||||
|
||||
VkDescriptorSet DescriptorAllocator::Commit() {
|
||||
const size_t index = CommitResource();
|
||||
return sets[index / SETS_GROW_RATE][index % SETS_GROW_RATE];
|
||||
|
|
|
@ -35,7 +35,7 @@ class DescriptorAllocator final : public ResourcePool {
|
|||
|
||||
public:
|
||||
explicit DescriptorAllocator() = default;
|
||||
~DescriptorAllocator() override;
|
||||
~DescriptorAllocator() override = default;
|
||||
|
||||
DescriptorAllocator& operator=(DescriptorAllocator&&) noexcept = default;
|
||||
DescriptorAllocator(DescriptorAllocator&&) noexcept = default;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
|
||||
#include "video_core/renderer_vulkan/vk_master_semaphore.h"
|
||||
|
@ -43,42 +42,6 @@ size_t ResourcePool::CommitResource() {
|
|||
return *found;
|
||||
}
|
||||
|
||||
void ResourcePool::Drain() {
|
||||
if (!master_semaphore || ticks.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
master_semaphore->Refresh();
|
||||
const auto highest_iter = std::max_element(ticks.begin(), ticks.end());
|
||||
if (highest_iter == ticks.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 highest_tick = *highest_iter;
|
||||
if (highest_tick == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 current_tick = master_semaphore->CurrentTick();
|
||||
const u64 last_submitted_tick = current_tick > 0 ? current_tick - 1 : 0;
|
||||
u64 wait_tick = 0;
|
||||
if (last_submitted_tick != 0) {
|
||||
wait_tick = std::min(highest_tick, last_submitted_tick);
|
||||
}
|
||||
|
||||
if (wait_tick != 0 && !master_semaphore->IsFree(wait_tick)) {
|
||||
// Clamp to the last submitted tick so we never wait for a value that was
|
||||
// never enqueued on the GPU timeline (CurrentTick() is always one ahead
|
||||
// of the most recent submission).
|
||||
master_semaphore->Wait(wait_tick);
|
||||
}
|
||||
|
||||
master_semaphore->Refresh();
|
||||
const u64 completed_tick = master_semaphore->KnownGpuTick();
|
||||
std::fill(ticks.begin(), ticks.end(), completed_tick);
|
||||
hint_iterator = 0;
|
||||
}
|
||||
|
||||
size_t ResourcePool::ManageOverflow() {
|
||||
const size_t old_capacity = ticks.size();
|
||||
Grow();
|
||||
|
|
|
@ -30,7 +30,6 @@ public:
|
|||
|
||||
protected:
|
||||
size_t CommitResource();
|
||||
void Drain();
|
||||
|
||||
/// Called when a chunk of resources have to be allocated.
|
||||
virtual void Allocate(size_t begin, size_t end) = 0;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/vulkan_common/vulkan.h"
|
||||
|
||||
|
@ -553,10 +552,6 @@ public:
|
|||
/// Construct an empty allocation.
|
||||
PoolAllocations() = default;
|
||||
|
||||
~PoolAllocations() noexcept {
|
||||
Release();
|
||||
}
|
||||
|
||||
/// Construct an allocation. Errors are reported through IsOutOfPoolMemory().
|
||||
explicit PoolAllocations(std::unique_ptr<AllocationType[]> allocations_, std::size_t num_,
|
||||
VkDevice device_, PoolType pool_, const DeviceDispatch& dld_) noexcept
|
||||
|
@ -570,38 +565,18 @@ public:
|
|||
/// Construct an allocation transferring ownership from another allocation.
|
||||
PoolAllocations(PoolAllocations&& rhs) noexcept
|
||||
: allocations{std::move(rhs.allocations)}, num{rhs.num}, device{rhs.device}, pool{rhs.pool},
|
||||
dld{rhs.dld} {
|
||||
rhs.Reset();
|
||||
}
|
||||
dld{rhs.dld} {}
|
||||
|
||||
/// Assign an allocation transferring ownership from another allocation.
|
||||
PoolAllocations& operator=(PoolAllocations&& rhs) noexcept {
|
||||
if (this == &rhs) [[unlikely]] {
|
||||
return *this;
|
||||
}
|
||||
Release();
|
||||
allocations = std::move(rhs.allocations);
|
||||
num = rhs.num;
|
||||
device = rhs.device;
|
||||
pool = rhs.pool;
|
||||
dld = rhs.dld;
|
||||
rhs.Reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Releases the underlying allocations back to their pool if owned.
|
||||
void Release() noexcept {
|
||||
if (!allocations || num == 0 || !device || !pool || !dld) {
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
const Span<AllocationType> span{allocations.get(), num};
|
||||
[[maybe_unused]] const VkResult result = Free(device, pool, span, *dld);
|
||||
DEBUG_ASSERT(result == VK_SUCCESS);
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// Returns the number of allocations.
|
||||
std::size_t size() const noexcept {
|
||||
return num;
|
||||
|
@ -629,14 +604,6 @@ private:
|
|||
VkDevice device = nullptr;
|
||||
PoolType pool = nullptr;
|
||||
const DeviceDispatch* dld = nullptr;
|
||||
|
||||
void Reset() noexcept {
|
||||
allocations.reset();
|
||||
num = 0;
|
||||
device = nullptr;
|
||||
pool = nullptr;
|
||||
dld = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
using DebugUtilsMessenger = Handle<VkDebugUtilsMessengerEXT, VkInstance, InstanceDispatch>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue