Blender V5.0
vk_descriptor_set_layouts.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
17
18#pragma once
19
20#include "BLI_map.hh"
21#include "BLI_mutex.hh"
22#include "BLI_utility_mixins.hh"
23#include "BLI_vector.hh"
24
25#include "vk_common.hh"
26
27namespace blender::gpu {
28
29class VKDevice;
30
47
48}; // namespace blender::gpu
49
50namespace blender {
56template<> struct DefaultHash<gpu::VKDescriptorSetLayoutInfo> {
58 {
60 for (VkDescriptorType vk_descriptor_type : key.bindings) {
61 hash = hash * 33 ^ uint64_t(vk_descriptor_type);
62 }
63 return hash;
64 }
65};
66} // namespace blender
67
68namespace blender::gpu {
69
87
92 friend class VKDevice;
93
94 private:
100
104 VkDescriptorSetLayoutCreateInfo vk_descriptor_set_layout_create_info_;
105 Vector<VkDescriptorSetLayoutBinding> vk_descriptor_set_layout_bindings_;
106 Mutex mutex_;
107
108 public:
110 virtual ~VKDescriptorSetLayouts();
111
118 VkDescriptorSetLayout get_or_create(const VKDescriptorSetLayoutInfo &info,
119 bool &r_created,
120 bool &r_needed);
121
133 VkDescriptorSetLayout vk_descriptor_set_layout)
134 {
135 std::scoped_lock lock(mutex_);
136 return descriptor_buffer_layouts_.lookup(vk_descriptor_set_layout);
137 }
138
144 void deinit();
145
149 int64_t size() const
150 {
151 return vk_descriptor_set_layouts_.size();
152 }
153
154 private:
155 void update_layout_bindings(const VKDescriptorSetLayoutInfo &info);
156 VKDescriptorBufferLayout create_descriptor_buffer_layout(
157 const VKDevice &device,
158 const VKDescriptorSetLayoutInfo &info,
159 VkDescriptorSetLayout vk_descriptor_set_layout) const;
160};
161
162} // namespace blender::gpu
volatile int lock
long long int int64_t
unsigned long long int uint64_t
NonCopyable(const NonCopyable &other)=delete
VKDescriptorBufferLayout descriptor_buffer_layout_get(VkDescriptorSetLayout vk_descriptor_set_layout)
VkDescriptorSetLayout get_or_create(const VKDescriptorSetLayoutInfo &info, bool &r_created, bool &r_needed)
std::mutex Mutex
Definition BLI_mutex.hh:47
#define hash
Definition noise_c.cc:154
uint64_t operator()(const gpu::VKDescriptorSetLayoutInfo &key) const
bool operator==(const VKDescriptorSetLayoutInfo &other) const