summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_descriptor_pool.h
blob: a441dbc0f1e8f4a2c41e1f000e4bba4f9ad3aadc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <memory>
#include <vector>

#include "common/common_types.h"
#include "video_core/renderer_vulkan/declarations.h"
#include "video_core/renderer_vulkan/vk_resource_manager.h"

namespace Vulkan {

class VKDescriptorPool;

class DescriptorAllocator final : public VKFencedPool {
public:
    explicit DescriptorAllocator(VKDescriptorPool& descriptor_pool, vk::DescriptorSetLayout layout);
    ~DescriptorAllocator() override;

    DescriptorAllocator(const DescriptorAllocator&) = delete;

    vk::DescriptorSet Commit(VKFence& fence);

protected:
    void Allocate(std::size_t begin, std::size_t end) override;

private:
    VKDescriptorPool& descriptor_pool;
    const vk::DescriptorSetLayout layout;

    std::vector<UniqueDescriptorSet> descriptors;
};

class VKDescriptorPool final {
    friend DescriptorAllocator;

public:
    explicit VKDescriptorPool(const VKDevice& device);
    ~VKDescriptorPool();

private:
    vk::DescriptorPool AllocateNewPool();

    std::vector<UniqueDescriptorSet> AllocateDescriptors(vk::DescriptorSetLayout layout,
                                                         std::size_t count);

    const VKDevice& device;

    std::vector<UniqueDescriptorPool> pools;
    vk::DescriptorPool active_pool;
};

} // namespace Vulkan