CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/Vulkan/VulkanDescSet.h
Views: 1401
1
#pragma once
2
3
#include "Common/Data/Collections/FastVec.h"
4
#include "Common/GPU/Vulkan/VulkanContext.h"
5
6
#include <vector>
7
8
enum class BindingType {
9
COMBINED_IMAGE_SAMPLER,
10
UNIFORM_BUFFER_DYNAMIC_VERTEX,
11
UNIFORM_BUFFER_DYNAMIC_ALL,
12
STORAGE_BUFFER_VERTEX,
13
STORAGE_BUFFER_COMPUTE,
14
STORAGE_IMAGE_COMPUTE,
15
};
16
17
// Only appropriate for use in a per-frame pool.
18
class VulkanDescSetPool {
19
public:
20
VulkanDescSetPool(const char *tag, bool grow = true) : tag_(tag), grow_(grow) {}
21
~VulkanDescSetPool();
22
23
void Create(VulkanContext *vulkan, const BindingType *bindingTypes, uint32_t bindingTypesCount, uint32_t descriptorCount);
24
// Allocate a new set, which may resize and empty the current sets.
25
// Use only for the current frame.
26
bool Allocate(VkDescriptorSet *descriptorSets, int count, const VkDescriptorSetLayout *layouts);
27
void Reset();
28
29
// This queues up destruction.
30
void Destroy();
31
// This actually destroys immediately.
32
void DestroyImmediately();
33
34
bool IsDestroyed() const {
35
return !descPool_;
36
}
37
38
void SetTag(const char *tag) {
39
tag_ = tag;
40
}
41
42
private:
43
VkResult Recreate(bool grow);
44
45
const char *tag_;
46
VulkanContext *vulkan_ = nullptr;
47
VkDescriptorPool descPool_ = VK_NULL_HANDLE;
48
VkDescriptorPoolCreateInfo info_{};
49
std::vector<VkDescriptorPoolSize> sizes_;
50
uint32_t usage_ = 0;
51
bool grow_;
52
};
53
54