Blender V4.3
vk_descriptor_set.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_utility_mixins.hh"
12#include "BLI_vector.hh"
13
14#include "gpu_shader_private.hh"
15
17#include "vk_buffer.hh"
18#include "vk_common.hh"
20#include "vk_uniform_buffer.hh"
21
22namespace blender::gpu {
23struct VKResourceBinding;
24class VKStateManager;
25class VKDevice;
26class VKPushConstants;
27class VKShader;
28
38
39 public:
51 struct Location {
53 friend class VKShaderInterface;
54 friend struct VKResourceBinding;
55
56 private:
60 uint32_t binding;
61
62 Location(uint32_t binding) : binding(binding) {}
63
64 public:
65 Location() = default;
66
67 bool operator==(const Location &other) const
68 {
69 return binding == other.binding;
70 }
71
72 operator uint32_t() const
73 {
74 return binding;
75 }
76 };
77};
78
80 friend class VKDescriptorSet;
81
82 Vector<VkBufferView> vk_buffer_views_;
83 Vector<VkDescriptorBufferInfo> vk_descriptor_buffer_infos_;
84 Vector<VkDescriptorImageInfo> vk_descriptor_image_infos_;
85 Vector<VkWriteDescriptorSet> vk_write_descriptor_sets_;
86
87 /* Last used layout to identify changes. */
88 VkDescriptorSetLayout vk_descriptor_set_layout_ = VK_NULL_HANDLE;
89
90 public:
91 VkDescriptorSet vk_descriptor_set = VK_NULL_HANDLE;
92
94
99 void update_descriptor_set(VKContext &context,
100 render_graph::VKResourceAccessInfo &resource_access_info);
102
103 private:
104 void bind_shader_resources(const VKDevice &device,
105 const VKStateManager &state_manager,
106 VKShader &shader,
108
109 void bind_image_resource(const VKStateManager &state_manager,
110 const VKResourceBinding &resource_binding,
112 void bind_texture_resource(const VKDevice &device,
113 const VKStateManager &state_manager,
114 const VKResourceBinding &resource_binding,
116 void bind_storage_buffer_resource(const VKStateManager &state_manager,
117 const VKResourceBinding &resource_binding,
119 void bind_uniform_buffer_resource(const VKStateManager &state_manager,
120 const VKResourceBinding &resource_binding,
122 void bind_push_constants(VKPushConstants &push_constants,
123
125
126 void bind_texel_buffer(VkBufferView vk_buffer_view, VKDescriptorSet::Location location);
127 void bind_buffer(VkDescriptorType vk_descriptor_type,
128 VkBuffer vk_buffer,
129 VkDeviceSize size_in_bytes,
131 void bind_image(VkDescriptorType vk_descriptor_type,
132 VkSampler vk_sampler,
133 VkImageView vk_image_view,
134 VkImageLayout vk_image_layout,
136};
137
138} // namespace blender::gpu
void update_descriptor_set(VKContext &context, render_graph::VKResourceAccessInfo &resource_access_info)
unsigned int uint32_t
Definition stdint.h:80
bool operator==(const Location &other) const