File include/jen/compute.h changed (mode: 100644) (index 09081dc..14199e1) |
... |
... |
namespace jen::compute { |
48 |
48 |
using BindingUseMask = uint32_t; |
using BindingUseMask = uint32_t; |
49 |
49 |
/// @brief User-provided information about binding |
/// @brief User-provided information about binding |
50 |
50 |
struct BindingCreateInfo { |
struct BindingCreateInfo { |
51 |
|
vkw::DeviceSize size; ///< Size in bytes for buffer allocation |
|
52 |
|
BindingUseMask use; ///< Usage of binding buffer |
|
53 |
|
vkw::BindNo bindingNo; ///< Number of binding to use in shader |
|
|
51 |
|
vkw::DeviceSize size; ///< Size in bytes for buffer allocation |
|
52 |
|
BindingUseMask use; ///< Usage of binding buffer |
|
53 |
|
vkw::Binding binding; ///< Number of binding to use in shader |
54 |
54 |
}; |
}; |
55 |
55 |
/// @brief Constant jl::rarray, array of BindingCreateInfo data types. |
/// @brief Constant jl::rarray, array of BindingCreateInfo data types. |
56 |
56 |
using BindingCreateInfos = jl::rarray<const BindingCreateInfo>; |
using BindingCreateInfos = jl::rarray<const BindingCreateInfo>; |
|
... |
... |
namespace jen::compute { |
66 |
66 |
/// Buffer part allocation |
/// Buffer part allocation |
67 |
67 |
DeviceBufferPart part; |
DeviceBufferPart part; |
68 |
68 |
/// Binding number for shader |
/// Binding number for shader |
69 |
|
vkw::BindNo binding; |
|
|
69 |
|
vkw::Binding binding; |
70 |
70 |
/// Is staging required for transferring data |
/// Is staging required for transferring data |
71 |
71 |
bool use_staging; |
bool use_staging; |
72 |
72 |
/// Staging buffer part allocation, if staging is required |
/// Staging buffer part allocation, if staging is required |
|
... |
... |
namespace jen::compute { |
139 |
139 |
/// @brief User-provided information about image binding |
/// @brief User-provided information about image binding |
140 |
140 |
struct BindingImage { |
struct BindingImage { |
141 |
141 |
/// Image to use in binding |
/// Image to use in binding |
142 |
|
Image *p_image; |
|
|
142 |
|
Image *p_image; |
143 |
143 |
/// Binding number |
/// Binding number |
144 |
|
vkw::BindNo binding; |
|
|
144 |
|
vkw::Binding binding; |
145 |
145 |
}; |
}; |
146 |
146 |
/// @brief Bindings list for a single binding set. |
/// @brief Bindings list for a single binding set. |
147 |
147 |
/// Every binding in this list must have unique binding number. |
/// Every binding in this list must have unique binding number. |
|
... |
... |
namespace jen::compute { |
165 |
165 |
/// Data are valid only after filling with |
/// Data are valid only after filling with |
166 |
166 |
/// ModuleCompute::create_bindingSet and becomes invalid after |
/// ModuleCompute::create_bindingSet and becomes invalid after |
167 |
167 |
/// ModuleCompute::destroy_bindingSet. |
/// ModuleCompute::destroy_bindingSet. |
168 |
|
struct BindingsSet { |
|
|
168 |
|
struct BindingSet { |
169 |
169 |
/// Vulkan descriptor set handle. @see VkDescriptorSet |
/// Vulkan descriptor set handle. @see VkDescriptorSet |
170 |
170 |
vkw::DescrSet set; |
vkw::DescrSet set; |
171 |
171 |
/// Vulkan descriptor pool handle. @see VkDescriptorPool |
/// Vulkan descriptor pool handle. @see VkDescriptorPool |
|
... |
... |
namespace jen |
315 |
315 |
/// @return If not VK_SUCCESS then function has no effect |
/// @return If not VK_SUCCESS then function has no effect |
316 |
316 |
/// and binding set is not created |
/// and binding set is not created |
317 |
317 |
[[nodiscard]] Result |
[[nodiscard]] Result |
318 |
|
create_bindingSet(const compute::Pipeline &pipeline, |
|
319 |
|
const compute::Bindings &bindings, |
|
320 |
|
compute::BindingsSet *p_dst); |
|
|
318 |
|
create_bindingSet(const compute::Pipeline &pipeline, |
|
319 |
|
const compute::Bindings &bindings, |
|
320 |
|
compute::BindingSet *p_dst); |
321 |
321 |
/// @brief Destroy binding set. |
/// @brief Destroy binding set. |
322 |
322 |
/// Must be called only once for a created set. |
/// Must be called only once for a created set. |
323 |
323 |
/// Set cannot be used after destroying. |
/// Set cannot be used after destroying. |
324 |
324 |
/// @param p_set pointer to created by create_bindingSet set |
/// @param p_set pointer to created by create_bindingSet set |
325 |
|
void destroy_bindingSet(compute::BindingsSet *p_set); |
|
|
325 |
|
void destroy_binding_set(compute::BindingSet *p_set); |
326 |
326 |
/// @brief Destroy buffer bindings. |
/// @brief Destroy buffer bindings. |
327 |
327 |
/// Must be called only once for every created binding. |
/// Must be called only once for every created binding. |
328 |
328 |
/// Binding cannot be used after destroying. |
/// Binding cannot be used after destroying. |
|
... |
... |
namespace jen |
358 |
358 |
compute::Pipeline *p_pipeline; |
compute::Pipeline *p_pipeline; |
359 |
359 |
/// Pointer to set to use in computation. |
/// Pointer to set to use in computation. |
360 |
360 |
/// Must be created with pipeline from *p_pipeline |
/// Must be created with pipeline from *p_pipeline |
361 |
|
compute::BindingsSet *p_bindingsSet; |
|
|
361 |
|
compute::BindingSet *p_binding_set; |
362 |
362 |
/// Pointer to bindings lists. |
/// Pointer to bindings lists. |
363 |
363 |
/// Must be еру same as the one passed to this pipeline and this binding set |
/// Must be еру same as the one passed to this pipeline and this binding set |
364 |
364 |
compute::Bindings *p_bindings; |
compute::Bindings *p_bindings; |
File libs/vkw/include/vkw/descriptor_set.h changed (mode: 100644) (index b0c4b09..808d059) |
... |
... |
namespace vkw |
45 |
45 |
struct DescrSet : HandleWrapper<VkDescriptorSet> |
struct DescrSet : HandleWrapper<VkDescriptorSet> |
46 |
46 |
{ |
{ |
47 |
47 |
void |
void |
48 |
|
set(Device d, BindNo bn, DescrType t, |
|
|
48 |
|
set(Device d, Binding bn, DescrType t, |
49 |
49 |
const DescrBuffer *p_b, const DescrImage *p_i, const BufferView *p_bv) { |
const DescrBuffer *p_b, const DescrImage *p_i, const BufferView *p_bv) { |
50 |
50 |
VkWriteDescriptorSet info; { |
VkWriteDescriptorSet info; { |
51 |
51 |
info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
|
... |
... |
namespace vkw |
61 |
61 |
} |
} |
62 |
62 |
vkUpdateDescriptorSets(d, 1, &info, 0, nullptr); |
vkUpdateDescriptorSets(d, 1, &info, 0, nullptr); |
63 |
63 |
} |
} |
64 |
|
void set(Device d, BindNo bn, DescrType t, const DescrBuffer &b) { |
|
|
64 |
|
void set(Device d, Binding bn, DescrType t, const DescrBuffer &b) { |
65 |
65 |
set(d, bn, t, &b, {}, {}); |
set(d, bn, t, &b, {}, {}); |
66 |
66 |
} |
} |
67 |
|
void set(Device d, BindNo bn, DescrType t, const DescrImage &i) { |
|
|
67 |
|
void set(Device d, Binding bn, DescrType t, const DescrImage &i) { |
68 |
68 |
set(d, bn, t, {}, &i, {}); |
set(d, bn, t, {}, &i, {}); |
69 |
69 |
} |
} |
70 |
|
void set(Device d, BindNo bn, DescrType t, const BufferView &bv) { |
|
|
70 |
|
void set(Device d, Binding bn, DescrType t, const BufferView &bv) { |
71 |
71 |
set(d, bn, t, {}, {}, &bv); |
set(d, bn, t, {}, {}, &bv); |
72 |
72 |
} |
} |
73 |
73 |
}; |
}; |
File src/compute/compute.cpp changed (mode: 100644) (index 5aef7c4..d04b330) |
... |
... |
create_pipeline(const Bindings &bi, const char *p_shader_file_path, |
42 |
42 |
auto put_part = [&numBinds, &dbinds] (vkw::DescrType dt, auto part) { |
auto put_part = [&numBinds, &dbinds] (vkw::DescrType dt, auto part) { |
43 |
43 |
for (auto &b : part) |
for (auto &b : part) |
44 |
44 |
dbinds[numBinds++] = { |
dbinds[numBinds++] = { |
45 |
|
.bind_no = b.binding, |
|
|
45 |
|
.binding = b.binding, |
46 |
46 |
.type = dt, |
.type = dt, |
47 |
47 |
.count = 1, |
.count = 1, |
48 |
48 |
.stages = vkw::ShaderStage::COMPUTE, |
.stages = vkw::ShaderStage::COMPUTE, |
|
... |
... |
init(Device *p_d, BindingBuffer *p, const BindingCreateInfo &info) { |
102 |
102 |
else |
else |
103 |
103 |
mem_use = DevMemUsage::STATIC; |
mem_use = DevMemUsage::STATIC; |
104 |
104 |
|
|
105 |
|
p->binding = info.bindingNo; |
|
|
105 |
|
p->binding = info.binding; |
106 |
106 |
|
|
107 |
107 |
Result res; |
Result res; |
108 |
108 |
res = p_d->buffer_allocator |
res = p_d->buffer_allocator |
|
... |
... |
create_images(ImageCreateInfos infos, Image *p_dst) { |
235 |
235 |
} |
} |
236 |
236 |
|
|
237 |
237 |
[[nodiscard]] Result |
[[nodiscard]] Result |
238 |
|
init(Device *p_dev, BindingsSet *p, vkw::DescrLayout setLayout, |
|
|
238 |
|
init(Device *p_dev, BindingSet *p, vkw::DescrLayout setLayout, |
239 |
239 |
const Bindings &bi) |
const Bindings &bi) |
240 |
240 |
{ |
{ |
241 |
241 |
uint32_t numPoolPart = 0; |
uint32_t numPoolPart = 0; |
|
... |
... |
init(Device *p_dev, BindingsSet *p, vkw::DescrLayout setLayout, |
291 |
291 |
|
|
292 |
292 |
return res; |
return res; |
293 |
293 |
} |
} |
294 |
|
void destroy(Device *p_dev, BindingsSet *p) { |
|
|
294 |
|
void destroy(Device *p_dev, BindingSet *p) { |
295 |
295 |
p->pool.destroy(*p_dev); |
p->pool.destroy(*p_dev); |
296 |
296 |
} |
} |
297 |
297 |
|
|
298 |
298 |
[[nodiscard]] Result ModuleCompute:: |
[[nodiscard]] Result ModuleCompute:: |
299 |
299 |
create_bindingSet(const Pipeline &pipeline, const Bindings &bindings, |
create_bindingSet(const Pipeline &pipeline, const Bindings &bindings, |
300 |
|
BindingsSet *p_dst) { |
|
|
300 |
|
BindingSet *p_dst) { |
301 |
301 |
return init(&p->device, p_dst, pipeline.setLayout, bindings); |
return init(&p->device, p_dst, pipeline.setLayout, bindings); |
302 |
302 |
} |
} |
303 |
303 |
|
|
304 |
304 |
|
|
305 |
305 |
void ModuleCompute:: |
void ModuleCompute:: |
306 |
|
destroy_bindingSet(BindingsSet *p_set) { |
|
|
306 |
|
destroy_binding_set(BindingSet *p_set) { |
307 |
307 |
destroy(&p->device, p_set); |
destroy(&p->device, p_set); |
308 |
308 |
} |
} |
309 |
309 |
void ModuleCompute:: |
void ModuleCompute:: |
File src/graphics/draw_stages/clusters.cpp changed (mode: 100644) (index 9207756..16874b0) |
... |
... |
init(jen::Device *p_dev, vkw::DescrPool pool) |
92 |
92 |
|
|
93 |
93 |
jl::array<vkw::DescrBind, BINDING_COUNT> bindings; |
jl::array<vkw::DescrBind, BINDING_COUNT> bindings; |
94 |
94 |
bindings[BINDING_OFFSETS] = { |
bindings[BINDING_OFFSETS] = { |
95 |
|
.bind_no = BINDING_OFFSETS, |
|
|
95 |
|
.binding = BINDING_OFFSETS, |
96 |
96 |
.type = OFFSET_DESCR, |
.type = OFFSET_DESCR, |
97 |
97 |
.count = 1, |
.count = 1, |
98 |
98 |
.stages = vkw::ShaderStage::FRAGMENT, |
.stages = vkw::ShaderStage::FRAGMENT, |
99 |
99 |
}; |
}; |
100 |
100 |
bindings[BINDING_LIGHTS] = { |
bindings[BINDING_LIGHTS] = { |
101 |
|
.bind_no = BINDING_LIGHTS, |
|
|
101 |
|
.binding = BINDING_LIGHTS, |
102 |
102 |
.type = LIGHTS_DESCR, |
.type = LIGHTS_DESCR, |
103 |
103 |
.count = 1, |
.count = 1, |
104 |
104 |
.stages = vkw::ShaderStage::FRAGMENT, |
.stages = vkw::ShaderStage::FRAGMENT, |
105 |
105 |
}; |
}; |
106 |
106 |
bindings[BINDING_INDICES] = { |
bindings[BINDING_INDICES] = { |
107 |
|
.bind_no = BINDING_INDICES, |
|
|
107 |
|
.binding = BINDING_INDICES, |
108 |
108 |
.type = INDICES_DESCR, |
.type = INDICES_DESCR, |
109 |
109 |
.count = 1, |
.count = 1, |
110 |
110 |
.stages = vkw::ShaderStage::FRAGMENT, |
.stages = vkw::ShaderStage::FRAGMENT, |
File src/misc/descriptors.cpp changed (mode: 100644) (index f8ab527..e58878c) |
... |
... |
init(Device *p_dev, vkw::DeviceSize size, |
86 |
86 |
res = create_buffer(p_dev, this, size, count); |
res = create_buffer(p_dev, this, size, count); |
87 |
87 |
if (res != VK_SUCCESS) |
if (res != VK_SUCCESS) |
88 |
88 |
goto C_LAYOUT; |
goto C_LAYOUT; |
89 |
|
res = create_set(p_dev->device, this, binding.bind_no, pool); |
|
|
89 |
|
res = create_set(p_dev->device, this, binding.binding, pool); |
90 |
90 |
if (res != VK_SUCCESS) |
if (res != VK_SUCCESS) |
91 |
91 |
goto C_BUFFER; |
goto C_BUFFER; |
92 |
92 |
return res; |
return res; |
|
... |
... |
init(vkw::Device device) { |
128 |
128 |
init(vkw::Device device) { |
init(vkw::Device device) { |
129 |
129 |
Result res; |
Result res; |
130 |
130 |
vkw::DescrBind binding = { |
vkw::DescrBind binding = { |
131 |
|
.bind_no = 0, |
|
|
131 |
|
.binding = 0, |
132 |
132 |
.type = vkw::DescrType::COMBINED_IMAGE_SAMPLER, |
.type = vkw::DescrType::COMBINED_IMAGE_SAMPLER, |
133 |
133 |
.count = 1, |
.count = 1, |
134 |
134 |
.stages = vkw::ShaderStage::FRAGMENT, |
.stages = vkw::ShaderStage::FRAGMENT, |
|
... |
... |
void jen::DescriptorTextureAllocator::destroy(vkw::Device device, Set set) { |
208 |
208 |
init(vkw::Device dev, vkw::DescrPool p, vkw::ImView v, vkw::Sampler s) { |
init(vkw::Device dev, vkw::DescrPool p, vkw::ImView v, vkw::Sampler s) { |
209 |
209 |
Result res; |
Result res; |
210 |
210 |
vkw::DescrBind binding = { |
vkw::DescrBind binding = { |
211 |
|
.bind_no = 0, |
|
|
211 |
|
.binding = 0, |
212 |
212 |
.type = s.is_null() ? DESCR_TYPE : DESCR_TYPE_SAMPLER, |
.type = s.is_null() ? DESCR_TYPE : DESCR_TYPE_SAMPLER, |
213 |
213 |
.count = 1, |
.count = 1, |
214 |
214 |
.stages = vkw::ShaderStage::FRAGMENT, |
.stages = vkw::ShaderStage::FRAGMENT, |