radv: Implement VK_KHR_maintenance3.
[mesa.git] / src / amd / vulkan / radv_descriptor_set.c
1 /*
2 * Copyright © 2016 Red Hat.
3 * Copyright © 2016 Bas Nieuwenhuizen
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24 #include <assert.h>
25 #include <stdbool.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29
30 #include "util/mesa-sha1.h"
31 #include "radv_private.h"
32 #include "sid.h"
33
34
35 static bool has_equal_immutable_samplers(const VkSampler *samplers, uint32_t count)
36 {
37 if (!samplers)
38 return false;
39 for(uint32_t i = 1; i < count; ++i) {
40 if (memcmp(radv_sampler_from_handle(samplers[0])->state,
41 radv_sampler_from_handle(samplers[i])->state, 16)) {
42 return false;
43 }
44 }
45 return true;
46 }
47
48 VkResult radv_CreateDescriptorSetLayout(
49 VkDevice _device,
50 const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
51 const VkAllocationCallbacks* pAllocator,
52 VkDescriptorSetLayout* pSetLayout)
53 {
54 RADV_FROM_HANDLE(radv_device, device, _device);
55 struct radv_descriptor_set_layout *set_layout;
56
57 assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
58
59 uint32_t max_binding = 0;
60 uint32_t immutable_sampler_count = 0;
61 for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
62 max_binding = MAX2(max_binding, pCreateInfo->pBindings[j].binding);
63 if (pCreateInfo->pBindings[j].pImmutableSamplers)
64 immutable_sampler_count += pCreateInfo->pBindings[j].descriptorCount;
65 }
66
67 uint32_t samplers_offset = sizeof(struct radv_descriptor_set_layout) +
68 (max_binding + 1) * sizeof(set_layout->binding[0]);
69 size_t size = samplers_offset + immutable_sampler_count * 4 * sizeof(uint32_t);
70
71 set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
72 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
73 if (!set_layout)
74 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
75
76 set_layout->flags = pCreateInfo->flags;
77
78 /* We just allocate all the samplers at the end of the struct */
79 uint32_t *samplers = (uint32_t*)&set_layout->binding[max_binding + 1];
80
81 set_layout->binding_count = max_binding + 1;
82 set_layout->shader_stages = 0;
83 set_layout->dynamic_shader_stages = 0;
84 set_layout->has_immutable_samplers = false;
85 set_layout->size = 0;
86
87 memset(set_layout->binding, 0, size - sizeof(struct radv_descriptor_set_layout));
88
89 uint32_t buffer_count = 0;
90 uint32_t dynamic_offset_count = 0;
91
92 for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
93 const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[j];
94 uint32_t b = binding->binding;
95 uint32_t alignment;
96 unsigned binding_buffer_count = 0;
97
98 switch (binding->descriptorType) {
99 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
100 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
101 assert(!(pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR));
102 set_layout->binding[b].dynamic_offset_count = 1;
103 set_layout->dynamic_shader_stages |= binding->stageFlags;
104 set_layout->binding[b].size = 0;
105 binding_buffer_count = 1;
106 alignment = 1;
107 break;
108 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
109 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
110 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
111 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
112 set_layout->binding[b].size = 16;
113 binding_buffer_count = 1;
114 alignment = 16;
115 break;
116 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
117 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
118 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
119 /* main descriptor + fmask descriptor */
120 set_layout->binding[b].size = 64;
121 binding_buffer_count = 1;
122 alignment = 32;
123 break;
124 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
125 /* main descriptor + fmask descriptor + sampler */
126 set_layout->binding[b].size = 96;
127 binding_buffer_count = 1;
128 alignment = 32;
129 break;
130 case VK_DESCRIPTOR_TYPE_SAMPLER:
131 set_layout->binding[b].size = 16;
132 alignment = 16;
133 break;
134 default:
135 unreachable("unknown descriptor type\n");
136 break;
137 }
138
139 set_layout->size = align(set_layout->size, alignment);
140 assert(binding->descriptorCount > 0);
141 set_layout->binding[b].type = binding->descriptorType;
142 set_layout->binding[b].array_size = binding->descriptorCount;
143 set_layout->binding[b].offset = set_layout->size;
144 set_layout->binding[b].buffer_offset = buffer_count;
145 set_layout->binding[b].dynamic_offset_offset = dynamic_offset_count;
146
147 if (binding->pImmutableSamplers) {
148 set_layout->binding[b].immutable_samplers_offset = samplers_offset;
149 set_layout->binding[b].immutable_samplers_equal =
150 has_equal_immutable_samplers(binding->pImmutableSamplers, binding->descriptorCount);
151 set_layout->has_immutable_samplers = true;
152
153
154 for (uint32_t i = 0; i < binding->descriptorCount; i++)
155 memcpy(samplers + 4 * i, &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
156
157 /* Don't reserve space for the samplers if they're not accessed. */
158 if (set_layout->binding[b].immutable_samplers_equal) {
159 if (binding->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
160 set_layout->binding[b].size -= 32;
161 else if (binding->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER)
162 set_layout->binding[b].size -= 16;
163 }
164 samplers += 4 * binding->descriptorCount;
165 samplers_offset += 4 * sizeof(uint32_t) * binding->descriptorCount;
166 }
167
168 set_layout->size += binding->descriptorCount * set_layout->binding[b].size;
169 buffer_count += binding->descriptorCount * binding_buffer_count;
170 dynamic_offset_count += binding->descriptorCount *
171 set_layout->binding[b].dynamic_offset_count;
172 set_layout->shader_stages |= binding->stageFlags;
173 }
174
175 set_layout->buffer_count = buffer_count;
176 set_layout->dynamic_offset_count = dynamic_offset_count;
177
178 *pSetLayout = radv_descriptor_set_layout_to_handle(set_layout);
179
180 return VK_SUCCESS;
181 }
182
183 void radv_DestroyDescriptorSetLayout(
184 VkDevice _device,
185 VkDescriptorSetLayout _set_layout,
186 const VkAllocationCallbacks* pAllocator)
187 {
188 RADV_FROM_HANDLE(radv_device, device, _device);
189 RADV_FROM_HANDLE(radv_descriptor_set_layout, set_layout, _set_layout);
190
191 if (!set_layout)
192 return;
193
194 vk_free2(&device->alloc, pAllocator, set_layout);
195 }
196
197 void radv_GetDescriptorSetLayoutSupport(VkDevice device,
198 const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
199 VkDescriptorSetLayoutSupport* pSupport)
200 {
201 bool supported = true;
202 uint64_t size = 0;
203 for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
204 const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[i];
205
206 if (binding->descriptorCount == 0)
207 continue;
208
209 uint64_t descriptor_size = 0;
210 uint64_t descriptor_alignment = 1;
211 switch (binding->descriptorType) {
212 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
213 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
214 break;
215 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
216 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
217 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
218 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
219 descriptor_size = 16;
220 descriptor_alignment = 16;
221 break;
222 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
223 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
224 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
225 descriptor_size = 64;
226 descriptor_alignment = 32;
227 break;
228 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
229 if (!has_equal_immutable_samplers(binding->pImmutableSamplers, binding->descriptorCount)) {
230 descriptor_size = 64;
231 } else {
232 descriptor_size = 96;
233 }
234 descriptor_alignment = 32;
235 break;
236 case VK_DESCRIPTOR_TYPE_SAMPLER:
237 if (!has_equal_immutable_samplers(binding->pImmutableSamplers, binding->descriptorCount)) {
238 descriptor_size = 16;
239 descriptor_alignment = 16;
240 }
241 break;
242 default:
243 unreachable("unknown descriptor type\n");
244 break;
245 }
246
247 if (size && !align_u64(size, descriptor_alignment)) {
248 supported = false;
249 }
250 size = align_u64(size, descriptor_alignment);
251 if (descriptor_size && (UINT64_MAX - size) / descriptor_size < binding->descriptorCount) {
252 supported = false;
253 }
254 size += binding->descriptorCount * descriptor_size;
255 }
256
257 pSupport->supported = supported;
258 }
259
260 /*
261 * Pipeline layouts. These have nothing to do with the pipeline. They are
262 * just muttiple descriptor set layouts pasted together
263 */
264
265 VkResult radv_CreatePipelineLayout(
266 VkDevice _device,
267 const VkPipelineLayoutCreateInfo* pCreateInfo,
268 const VkAllocationCallbacks* pAllocator,
269 VkPipelineLayout* pPipelineLayout)
270 {
271 RADV_FROM_HANDLE(radv_device, device, _device);
272 struct radv_pipeline_layout *layout;
273 struct mesa_sha1 ctx;
274
275 assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
276
277 layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
278 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
279 if (layout == NULL)
280 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
281
282 layout->num_sets = pCreateInfo->setLayoutCount;
283
284 unsigned dynamic_offset_count = 0;
285
286
287 _mesa_sha1_init(&ctx);
288 for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) {
289 RADV_FROM_HANDLE(radv_descriptor_set_layout, set_layout,
290 pCreateInfo->pSetLayouts[set]);
291 layout->set[set].layout = set_layout;
292
293 layout->set[set].dynamic_offset_start = dynamic_offset_count;
294 for (uint32_t b = 0; b < set_layout->binding_count; b++) {
295 dynamic_offset_count += set_layout->binding[b].array_size * set_layout->binding[b].dynamic_offset_count;
296 if (set_layout->binding[b].immutable_samplers_offset)
297 _mesa_sha1_update(&ctx, radv_immutable_samplers(set_layout, set_layout->binding + b),
298 set_layout->binding[b].array_size * 4 * sizeof(uint32_t));
299 }
300 _mesa_sha1_update(&ctx, set_layout->binding,
301 sizeof(set_layout->binding[0]) * set_layout->binding_count);
302 }
303
304 layout->dynamic_offset_count = dynamic_offset_count;
305 layout->push_constant_size = 0;
306
307 for (unsigned i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
308 const VkPushConstantRange *range = pCreateInfo->pPushConstantRanges + i;
309 layout->push_constant_size = MAX2(layout->push_constant_size,
310 range->offset + range->size);
311 }
312
313 layout->push_constant_size = align(layout->push_constant_size, 16);
314 _mesa_sha1_update(&ctx, &layout->push_constant_size,
315 sizeof(layout->push_constant_size));
316 _mesa_sha1_final(&ctx, layout->sha1);
317 *pPipelineLayout = radv_pipeline_layout_to_handle(layout);
318
319 return VK_SUCCESS;
320 }
321
322 void radv_DestroyPipelineLayout(
323 VkDevice _device,
324 VkPipelineLayout _pipelineLayout,
325 const VkAllocationCallbacks* pAllocator)
326 {
327 RADV_FROM_HANDLE(radv_device, device, _device);
328 RADV_FROM_HANDLE(radv_pipeline_layout, pipeline_layout, _pipelineLayout);
329
330 if (!pipeline_layout)
331 return;
332 vk_free2(&device->alloc, pAllocator, pipeline_layout);
333 }
334
335 #define EMPTY 1
336
337 static VkResult
338 radv_descriptor_set_create(struct radv_device *device,
339 struct radv_descriptor_pool *pool,
340 const struct radv_descriptor_set_layout *layout,
341 struct radv_descriptor_set **out_set)
342 {
343 struct radv_descriptor_set *set;
344 unsigned range_offset = sizeof(struct radv_descriptor_set) +
345 sizeof(struct radeon_winsys_bo *) * layout->buffer_count;
346 unsigned mem_size = range_offset +
347 sizeof(struct radv_descriptor_range) * layout->dynamic_offset_count;
348
349 if (pool->host_memory_base) {
350 if (pool->host_memory_end - pool->host_memory_ptr < mem_size)
351 return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
352
353 set = (struct radv_descriptor_set*)pool->host_memory_ptr;
354 pool->host_memory_ptr += mem_size;
355 } else {
356 set = vk_alloc2(&device->alloc, NULL, mem_size, 8,
357 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
358
359 if (!set)
360 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
361 }
362
363 memset(set, 0, mem_size);
364
365 if (layout->dynamic_offset_count) {
366 set->dynamic_descriptors = (struct radv_descriptor_range*)((uint8_t*)set + range_offset);
367 }
368
369 set->layout = layout;
370 if (layout->size) {
371 uint32_t layout_size = align_u32(layout->size, 32);
372 set->size = layout->size;
373
374 if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) {
375 vk_free2(&device->alloc, NULL, set);
376 return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
377 }
378
379 /* try to allocate linearly first, so that we don't spend
380 * time looking for gaps if the app only allocates &
381 * resets via the pool. */
382 if (pool->current_offset + layout_size <= pool->size) {
383 set->bo = pool->bo;
384 set->mapped_ptr = (uint32_t*)(pool->mapped_ptr + pool->current_offset);
385 set->va = radv_buffer_get_va(set->bo) + pool->current_offset;
386 if (!pool->host_memory_base) {
387 pool->entries[pool->entry_count].offset = pool->current_offset;
388 pool->entries[pool->entry_count].size = layout_size;
389 pool->entries[pool->entry_count].set = set;
390 pool->entry_count++;
391 }
392 pool->current_offset += layout_size;
393 } else if (!pool->host_memory_base) {
394 uint64_t offset = 0;
395 int index;
396
397 for (index = 0; index < pool->entry_count; ++index) {
398 if (pool->entries[index].offset - offset >= layout_size)
399 break;
400 offset = pool->entries[index].offset + pool->entries[index].size;
401 }
402
403 if (pool->size - offset < layout_size) {
404 vk_free2(&device->alloc, NULL, set);
405 return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
406 }
407 set->bo = pool->bo;
408 set->mapped_ptr = (uint32_t*)(pool->mapped_ptr + offset);
409 set->va = radv_buffer_get_va(set->bo) + offset;
410 memmove(&pool->entries[index + 1], &pool->entries[index],
411 sizeof(pool->entries[0]) * (pool->entry_count - index));
412 pool->entries[index].offset = offset;
413 pool->entries[index].size = layout_size;
414 pool->entries[index].set = set;
415 pool->entry_count++;
416 } else
417 return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
418 }
419
420 if (layout->has_immutable_samplers) {
421 for (unsigned i = 0; i < layout->binding_count; ++i) {
422 if (!layout->binding[i].immutable_samplers_offset ||
423 layout->binding[i].immutable_samplers_equal)
424 continue;
425
426 unsigned offset = layout->binding[i].offset / 4;
427 if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
428 offset += 16;
429
430 const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
431 for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
432 memcpy(set->mapped_ptr + offset, samplers + 4 * j, 16);
433 offset += layout->binding[i].size / 4;
434 }
435
436 }
437 }
438 *out_set = set;
439 return VK_SUCCESS;
440 }
441
442 static void
443 radv_descriptor_set_destroy(struct radv_device *device,
444 struct radv_descriptor_pool *pool,
445 struct radv_descriptor_set *set,
446 bool free_bo)
447 {
448 assert(!pool->host_memory_base);
449
450 if (free_bo && set->size && !pool->host_memory_base) {
451 uint32_t offset = (uint8_t*)set->mapped_ptr - pool->mapped_ptr;
452 for (int i = 0; i < pool->entry_count; ++i) {
453 if (pool->entries[i].offset == offset) {
454 memmove(&pool->entries[i], &pool->entries[i+1],
455 sizeof(pool->entries[i]) * (pool->entry_count - i - 1));
456 --pool->entry_count;
457 break;
458 }
459 }
460 }
461 vk_free2(&device->alloc, NULL, set);
462 }
463
464 VkResult radv_CreateDescriptorPool(
465 VkDevice _device,
466 const VkDescriptorPoolCreateInfo* pCreateInfo,
467 const VkAllocationCallbacks* pAllocator,
468 VkDescriptorPool* pDescriptorPool)
469 {
470 RADV_FROM_HANDLE(radv_device, device, _device);
471 struct radv_descriptor_pool *pool;
472 int size = sizeof(struct radv_descriptor_pool);
473 uint64_t bo_size = 0, bo_count = 0, range_count = 0;
474
475
476 for (unsigned i = 0; i < pCreateInfo->poolSizeCount; ++i) {
477 if (pCreateInfo->pPoolSizes[i].type != VK_DESCRIPTOR_TYPE_SAMPLER)
478 bo_count += pCreateInfo->pPoolSizes[i].descriptorCount;
479
480 switch(pCreateInfo->pPoolSizes[i].type) {
481 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
482 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
483 range_count += pCreateInfo->pPoolSizes[i].descriptorCount;
484 break;
485 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
486 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
487 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
488 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
489 case VK_DESCRIPTOR_TYPE_SAMPLER:
490 /* 32 as we may need to align for images */
491 bo_size += 32 * pCreateInfo->pPoolSizes[i].descriptorCount;
492 break;
493 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
494 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
495 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
496 bo_size += 64 * pCreateInfo->pPoolSizes[i].descriptorCount;
497 break;
498 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
499 bo_size += 96 * pCreateInfo->pPoolSizes[i].descriptorCount;
500 break;
501 default:
502 unreachable("unknown descriptor type\n");
503 break;
504 }
505 }
506
507 if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
508 uint64_t host_size = pCreateInfo->maxSets * sizeof(struct radv_descriptor_set);
509 host_size += sizeof(struct radeon_winsys_bo*) * bo_count;
510 host_size += sizeof(struct radv_descriptor_range) * range_count;
511 size += host_size;
512 } else {
513 size += sizeof(struct radv_descriptor_pool_entry) * pCreateInfo->maxSets;
514 }
515
516 pool = vk_alloc2(&device->alloc, pAllocator, size, 8,
517 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
518 if (!pool)
519 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
520
521 memset(pool, 0, sizeof(*pool));
522
523 if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
524 pool->host_memory_base = (uint8_t*)pool + sizeof(struct radv_descriptor_pool);
525 pool->host_memory_ptr = pool->host_memory_base;
526 pool->host_memory_end = (uint8_t*)pool + size;
527 }
528
529 if (bo_size) {
530 pool->bo = device->ws->buffer_create(device->ws, bo_size, 32,
531 RADEON_DOMAIN_VRAM,
532 RADEON_FLAG_NO_INTERPROCESS_SHARING |
533 RADEON_FLAG_READ_ONLY);
534 pool->mapped_ptr = (uint8_t*)device->ws->buffer_map(pool->bo);
535 }
536 pool->size = bo_size;
537 pool->max_entry_count = pCreateInfo->maxSets;
538
539 *pDescriptorPool = radv_descriptor_pool_to_handle(pool);
540 return VK_SUCCESS;
541 }
542
543 void radv_DestroyDescriptorPool(
544 VkDevice _device,
545 VkDescriptorPool _pool,
546 const VkAllocationCallbacks* pAllocator)
547 {
548 RADV_FROM_HANDLE(radv_device, device, _device);
549 RADV_FROM_HANDLE(radv_descriptor_pool, pool, _pool);
550
551 if (!pool)
552 return;
553
554 if (!pool->host_memory_base) {
555 for(int i = 0; i < pool->entry_count; ++i) {
556 radv_descriptor_set_destroy(device, pool, pool->entries[i].set, false);
557 }
558 }
559
560 if (pool->bo)
561 device->ws->buffer_destroy(pool->bo);
562 vk_free2(&device->alloc, pAllocator, pool);
563 }
564
565 VkResult radv_ResetDescriptorPool(
566 VkDevice _device,
567 VkDescriptorPool descriptorPool,
568 VkDescriptorPoolResetFlags flags)
569 {
570 RADV_FROM_HANDLE(radv_device, device, _device);
571 RADV_FROM_HANDLE(radv_descriptor_pool, pool, descriptorPool);
572
573 if (!pool->host_memory_base) {
574 for(int i = 0; i < pool->entry_count; ++i) {
575 radv_descriptor_set_destroy(device, pool, pool->entries[i].set, false);
576 }
577 pool->entry_count = 0;
578 }
579
580 pool->current_offset = 0;
581 pool->host_memory_ptr = pool->host_memory_base;
582
583 return VK_SUCCESS;
584 }
585
586 VkResult radv_AllocateDescriptorSets(
587 VkDevice _device,
588 const VkDescriptorSetAllocateInfo* pAllocateInfo,
589 VkDescriptorSet* pDescriptorSets)
590 {
591 RADV_FROM_HANDLE(radv_device, device, _device);
592 RADV_FROM_HANDLE(radv_descriptor_pool, pool, pAllocateInfo->descriptorPool);
593
594 VkResult result = VK_SUCCESS;
595 uint32_t i;
596 struct radv_descriptor_set *set = NULL;
597
598 /* allocate a set of buffers for each shader to contain descriptors */
599 for (i = 0; i < pAllocateInfo->descriptorSetCount; i++) {
600 RADV_FROM_HANDLE(radv_descriptor_set_layout, layout,
601 pAllocateInfo->pSetLayouts[i]);
602
603 assert(!(layout->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR));
604
605 result = radv_descriptor_set_create(device, pool, layout, &set);
606 if (result != VK_SUCCESS)
607 break;
608
609 pDescriptorSets[i] = radv_descriptor_set_to_handle(set);
610 }
611
612 if (result != VK_SUCCESS)
613 radv_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool,
614 i, pDescriptorSets);
615 return result;
616 }
617
618 VkResult radv_FreeDescriptorSets(
619 VkDevice _device,
620 VkDescriptorPool descriptorPool,
621 uint32_t count,
622 const VkDescriptorSet* pDescriptorSets)
623 {
624 RADV_FROM_HANDLE(radv_device, device, _device);
625 RADV_FROM_HANDLE(radv_descriptor_pool, pool, descriptorPool);
626
627 for (uint32_t i = 0; i < count; i++) {
628 RADV_FROM_HANDLE(radv_descriptor_set, set, pDescriptorSets[i]);
629
630 if (set && !pool->host_memory_base)
631 radv_descriptor_set_destroy(device, pool, set, true);
632 }
633 return VK_SUCCESS;
634 }
635
636 static void write_texel_buffer_descriptor(struct radv_device *device,
637 struct radv_cmd_buffer *cmd_buffer,
638 unsigned *dst,
639 struct radeon_winsys_bo **buffer_list,
640 const VkBufferView _buffer_view)
641 {
642 RADV_FROM_HANDLE(radv_buffer_view, buffer_view, _buffer_view);
643
644 memcpy(dst, buffer_view->state, 4 * 4);
645
646 if (cmd_buffer)
647 radv_cs_add_buffer(device->ws, cmd_buffer->cs, buffer_view->bo, 7);
648 else
649 *buffer_list = buffer_view->bo;
650 }
651
652 static void write_buffer_descriptor(struct radv_device *device,
653 struct radv_cmd_buffer *cmd_buffer,
654 unsigned *dst,
655 struct radeon_winsys_bo **buffer_list,
656 const VkDescriptorBufferInfo *buffer_info)
657 {
658 RADV_FROM_HANDLE(radv_buffer, buffer, buffer_info->buffer);
659 uint64_t va = radv_buffer_get_va(buffer->bo);
660 uint32_t range = buffer_info->range;
661
662 if (buffer_info->range == VK_WHOLE_SIZE)
663 range = buffer->size - buffer_info->offset;
664
665 va += buffer_info->offset + buffer->offset;
666 dst[0] = va;
667 dst[1] = S_008F04_BASE_ADDRESS_HI(va >> 32);
668 dst[2] = range;
669 dst[3] = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) |
670 S_008F0C_DST_SEL_Y(V_008F0C_SQ_SEL_Y) |
671 S_008F0C_DST_SEL_Z(V_008F0C_SQ_SEL_Z) |
672 S_008F0C_DST_SEL_W(V_008F0C_SQ_SEL_W) |
673 S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
674 S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
675
676 if (cmd_buffer)
677 radv_cs_add_buffer(device->ws, cmd_buffer->cs, buffer->bo, 7);
678 else
679 *buffer_list = buffer->bo;
680 }
681
682 static void write_dynamic_buffer_descriptor(struct radv_device *device,
683 struct radv_descriptor_range *range,
684 struct radeon_winsys_bo **buffer_list,
685 const VkDescriptorBufferInfo *buffer_info)
686 {
687 RADV_FROM_HANDLE(radv_buffer, buffer, buffer_info->buffer);
688 uint64_t va = radv_buffer_get_va(buffer->bo);
689 unsigned size = buffer_info->range;
690
691 if (buffer_info->range == VK_WHOLE_SIZE)
692 size = buffer->size - buffer_info->offset;
693
694 va += buffer_info->offset + buffer->offset;
695 range->va = va;
696 range->size = size;
697
698 *buffer_list = buffer->bo;
699 }
700
701 static void
702 write_image_descriptor(struct radv_device *device,
703 struct radv_cmd_buffer *cmd_buffer,
704 unsigned *dst,
705 struct radeon_winsys_bo **buffer_list,
706 VkDescriptorType descriptor_type,
707 const VkDescriptorImageInfo *image_info)
708 {
709 RADV_FROM_HANDLE(radv_image_view, iview, image_info->imageView);
710 uint32_t *descriptor;
711
712 if (descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
713 descriptor = iview->storage_descriptor;
714 } else {
715 descriptor = iview->descriptor;
716 }
717
718 memcpy(dst, descriptor, 16 * 4);
719
720 if (cmd_buffer)
721 radv_cs_add_buffer(device->ws, cmd_buffer->cs, iview->bo, 7);
722 else
723 *buffer_list = iview->bo;
724 }
725
726 static void
727 write_combined_image_sampler_descriptor(struct radv_device *device,
728 struct radv_cmd_buffer *cmd_buffer,
729 unsigned *dst,
730 struct radeon_winsys_bo **buffer_list,
731 VkDescriptorType descriptor_type,
732 const VkDescriptorImageInfo *image_info,
733 bool has_sampler)
734 {
735 RADV_FROM_HANDLE(radv_sampler, sampler, image_info->sampler);
736
737 write_image_descriptor(device, cmd_buffer, dst, buffer_list, descriptor_type, image_info);
738 /* copy over sampler state */
739 if (has_sampler)
740 memcpy(dst + 16, sampler->state, 16);
741 }
742
743 static void
744 write_sampler_descriptor(struct radv_device *device,
745 unsigned *dst,
746 const VkDescriptorImageInfo *image_info)
747 {
748 RADV_FROM_HANDLE(radv_sampler, sampler, image_info->sampler);
749
750 memcpy(dst, sampler->state, 16);
751 }
752
753 void radv_update_descriptor_sets(
754 struct radv_device* device,
755 struct radv_cmd_buffer* cmd_buffer,
756 VkDescriptorSet dstSetOverride,
757 uint32_t descriptorWriteCount,
758 const VkWriteDescriptorSet* pDescriptorWrites,
759 uint32_t descriptorCopyCount,
760 const VkCopyDescriptorSet* pDescriptorCopies)
761 {
762 uint32_t i, j;
763 for (i = 0; i < descriptorWriteCount; i++) {
764 const VkWriteDescriptorSet *writeset = &pDescriptorWrites[i];
765 RADV_FROM_HANDLE(radv_descriptor_set, set,
766 dstSetOverride ? dstSetOverride : writeset->dstSet);
767 const struct radv_descriptor_set_binding_layout *binding_layout =
768 set->layout->binding + writeset->dstBinding;
769 uint32_t *ptr = set->mapped_ptr;
770 struct radeon_winsys_bo **buffer_list = set->descriptors;
771 /* Immutable samplers are not copied into push descriptors when they are
772 * allocated, so if we are writing push descriptors we have to copy the
773 * immutable samplers into them now.
774 */
775 const bool copy_immutable_samplers = cmd_buffer &&
776 binding_layout->immutable_samplers_offset && !binding_layout->immutable_samplers_equal;
777 const uint32_t *samplers = radv_immutable_samplers(set->layout, binding_layout);
778
779 ptr += binding_layout->offset / 4;
780 ptr += binding_layout->size * writeset->dstArrayElement / 4;
781 buffer_list += binding_layout->buffer_offset;
782 buffer_list += writeset->dstArrayElement;
783 for (j = 0; j < writeset->descriptorCount; ++j) {
784 switch(writeset->descriptorType) {
785 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
786 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
787 unsigned idx = writeset->dstArrayElement + j;
788 idx += binding_layout->dynamic_offset_offset;
789 assert(!(set->layout->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR));
790 write_dynamic_buffer_descriptor(device, set->dynamic_descriptors + idx,
791 buffer_list, writeset->pBufferInfo + j);
792 break;
793 }
794 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
795 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
796 write_buffer_descriptor(device, cmd_buffer, ptr, buffer_list,
797 writeset->pBufferInfo + j);
798 break;
799 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
800 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
801 write_texel_buffer_descriptor(device, cmd_buffer, ptr, buffer_list,
802 writeset->pTexelBufferView[j]);
803 break;
804 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
805 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
806 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
807 write_image_descriptor(device, cmd_buffer, ptr, buffer_list,
808 writeset->descriptorType,
809 writeset->pImageInfo + j);
810 break;
811 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
812 write_combined_image_sampler_descriptor(device, cmd_buffer, ptr, buffer_list,
813 writeset->descriptorType,
814 writeset->pImageInfo + j,
815 !binding_layout->immutable_samplers_offset);
816 if (copy_immutable_samplers) {
817 const unsigned idx = writeset->dstArrayElement + j;
818 memcpy(ptr + 16, samplers + 4 * idx, 16);
819 }
820 break;
821 case VK_DESCRIPTOR_TYPE_SAMPLER:
822 if (!binding_layout->immutable_samplers_offset) {
823 write_sampler_descriptor(device, ptr,
824 writeset->pImageInfo + j);
825 } else if (copy_immutable_samplers) {
826 unsigned idx = writeset->dstArrayElement + j;
827 memcpy(ptr, samplers + 4 * idx, 16);
828 }
829 break;
830 default:
831 unreachable("unimplemented descriptor type");
832 break;
833 }
834 ptr += binding_layout->size / 4;
835 ++buffer_list;
836 }
837
838 }
839
840 for (i = 0; i < descriptorCopyCount; i++) {
841 const VkCopyDescriptorSet *copyset = &pDescriptorCopies[i];
842 RADV_FROM_HANDLE(radv_descriptor_set, src_set,
843 copyset->srcSet);
844 RADV_FROM_HANDLE(radv_descriptor_set, dst_set,
845 copyset->dstSet);
846 const struct radv_descriptor_set_binding_layout *src_binding_layout =
847 src_set->layout->binding + copyset->srcBinding;
848 const struct radv_descriptor_set_binding_layout *dst_binding_layout =
849 dst_set->layout->binding + copyset->dstBinding;
850 uint32_t *src_ptr = src_set->mapped_ptr;
851 uint32_t *dst_ptr = dst_set->mapped_ptr;
852 struct radeon_winsys_bo **src_buffer_list = src_set->descriptors;
853 struct radeon_winsys_bo **dst_buffer_list = dst_set->descriptors;
854
855 src_ptr += src_binding_layout->offset / 4;
856 dst_ptr += dst_binding_layout->offset / 4;
857
858 src_ptr += src_binding_layout->size * copyset->srcArrayElement / 4;
859 dst_ptr += dst_binding_layout->size * copyset->dstArrayElement / 4;
860
861 src_buffer_list += src_binding_layout->buffer_offset;
862 src_buffer_list += copyset->srcArrayElement;
863
864 dst_buffer_list += dst_binding_layout->buffer_offset;
865 dst_buffer_list += copyset->dstArrayElement;
866
867 for (j = 0; j < copyset->descriptorCount; ++j) {
868 switch (src_binding_layout->type) {
869 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
870 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
871 unsigned src_idx = copyset->srcArrayElement + j;
872 unsigned dst_idx = copyset->dstArrayElement + j;
873 struct radv_descriptor_range *src_range, *dst_range;
874 src_idx += src_binding_layout->dynamic_offset_offset;
875 dst_idx += dst_binding_layout->dynamic_offset_offset;
876
877 src_range = src_set->dynamic_descriptors + src_idx;
878 dst_range = dst_set->dynamic_descriptors + dst_idx;
879 *dst_range = *src_range;
880 break;
881 }
882 default:
883 memcpy(dst_ptr, src_ptr, src_binding_layout->size);
884 }
885 src_ptr += src_binding_layout->size / 4;
886 dst_ptr += dst_binding_layout->size / 4;
887 dst_buffer_list[j] = src_buffer_list[j];
888 ++src_buffer_list;
889 ++dst_buffer_list;
890 }
891 }
892 }
893
894 void radv_UpdateDescriptorSets(
895 VkDevice _device,
896 uint32_t descriptorWriteCount,
897 const VkWriteDescriptorSet* pDescriptorWrites,
898 uint32_t descriptorCopyCount,
899 const VkCopyDescriptorSet* pDescriptorCopies)
900 {
901 RADV_FROM_HANDLE(radv_device, device, _device);
902
903 radv_update_descriptor_sets(device, NULL, VK_NULL_HANDLE, descriptorWriteCount, pDescriptorWrites,
904 descriptorCopyCount, pDescriptorCopies);
905 }
906
907 VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
908 const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
909 const VkAllocationCallbacks *pAllocator,
910 VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate)
911 {
912 RADV_FROM_HANDLE(radv_device, device, _device);
913 RADV_FROM_HANDLE(radv_descriptor_set_layout, set_layout, pCreateInfo->descriptorSetLayout);
914 const uint32_t entry_count = pCreateInfo->descriptorUpdateEntryCount;
915 const size_t size = sizeof(struct radv_descriptor_update_template) +
916 sizeof(struct radv_descriptor_update_template_entry) * entry_count;
917 struct radv_descriptor_update_template *templ;
918 uint32_t i;
919
920 templ = vk_alloc2(&device->alloc, pAllocator, size, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
921 if (!templ)
922 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
923
924 templ->entry_count = entry_count;
925 templ->bind_point = pCreateInfo->pipelineBindPoint;
926
927 for (i = 0; i < entry_count; i++) {
928 const VkDescriptorUpdateTemplateEntryKHR *entry = &pCreateInfo->pDescriptorUpdateEntries[i];
929 const struct radv_descriptor_set_binding_layout *binding_layout =
930 set_layout->binding + entry->dstBinding;
931 const uint32_t buffer_offset = binding_layout->buffer_offset + entry->dstArrayElement;
932 const uint32_t *immutable_samplers = NULL;
933 uint32_t dst_offset;
934 uint32_t dst_stride;
935
936 /* dst_offset is an offset into dynamic_descriptors when the descriptor
937 is dynamic, and an offset into mapped_ptr otherwise */
938 switch (entry->descriptorType) {
939 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
940 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
941 assert(pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR);
942 dst_offset = binding_layout->dynamic_offset_offset + entry->dstArrayElement;
943 dst_stride = 0; /* Not used */
944 break;
945 default:
946 switch (entry->descriptorType) {
947 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
948 case VK_DESCRIPTOR_TYPE_SAMPLER:
949 /* Immutable samplers are copied into push descriptors when they are pushed */
950 if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR &&
951 binding_layout->immutable_samplers_offset && !binding_layout->immutable_samplers_equal) {
952 immutable_samplers = radv_immutable_samplers(set_layout, binding_layout) + entry->dstArrayElement * 4;
953 }
954 break;
955 default:
956 break;
957 }
958 dst_offset = binding_layout->offset / 4 + binding_layout->size * entry->dstArrayElement / 4;
959 dst_stride = binding_layout->size / 4;
960 break;
961 }
962
963 templ->entry[i] = (struct radv_descriptor_update_template_entry) {
964 .descriptor_type = entry->descriptorType,
965 .descriptor_count = entry->descriptorCount,
966 .src_offset = entry->offset,
967 .src_stride = entry->stride,
968 .dst_offset = dst_offset,
969 .dst_stride = dst_stride,
970 .buffer_offset = buffer_offset,
971 .has_sampler = !binding_layout->immutable_samplers_offset,
972 .immutable_samplers = immutable_samplers
973 };
974 }
975
976 *pDescriptorUpdateTemplate = radv_descriptor_update_template_to_handle(templ);
977 return VK_SUCCESS;
978 }
979
980 void radv_DestroyDescriptorUpdateTemplate(VkDevice _device,
981 VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
982 const VkAllocationCallbacks *pAllocator)
983 {
984 RADV_FROM_HANDLE(radv_device, device, _device);
985 RADV_FROM_HANDLE(radv_descriptor_update_template, templ, descriptorUpdateTemplate);
986
987 if (!templ)
988 return;
989
990 vk_free2(&device->alloc, pAllocator, templ);
991 }
992
993 void radv_update_descriptor_set_with_template(struct radv_device *device,
994 struct radv_cmd_buffer *cmd_buffer,
995 struct radv_descriptor_set *set,
996 VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
997 const void *pData)
998 {
999 RADV_FROM_HANDLE(radv_descriptor_update_template, templ, descriptorUpdateTemplate);
1000 uint32_t i;
1001
1002 for (i = 0; i < templ->entry_count; ++i) {
1003 struct radeon_winsys_bo **buffer_list = set->descriptors + templ->entry[i].buffer_offset;
1004 uint32_t *pDst = set->mapped_ptr + templ->entry[i].dst_offset;
1005 const uint8_t *pSrc = ((const uint8_t *) pData) + templ->entry[i].src_offset;
1006 uint32_t j;
1007
1008 for (j = 0; j < templ->entry[i].descriptor_count; ++j) {
1009 switch (templ->entry[i].descriptor_type) {
1010 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
1011 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
1012 const unsigned idx = templ->entry[i].dst_offset + j;
1013 assert(!(set->layout->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR));
1014 write_dynamic_buffer_descriptor(device, set->dynamic_descriptors + idx,
1015 buffer_list, (struct VkDescriptorBufferInfo *) pSrc);
1016 break;
1017 }
1018 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
1019 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
1020 write_buffer_descriptor(device, cmd_buffer, pDst, buffer_list,
1021 (struct VkDescriptorBufferInfo *) pSrc);
1022 break;
1023 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
1024 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
1025 write_texel_buffer_descriptor(device, cmd_buffer, pDst, buffer_list,
1026 *(VkBufferView *) pSrc);
1027 break;
1028 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
1029 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
1030 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
1031 write_image_descriptor(device, cmd_buffer, pDst, buffer_list,
1032 templ->entry[i].descriptor_type,
1033 (struct VkDescriptorImageInfo *) pSrc);
1034 break;
1035 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
1036 write_combined_image_sampler_descriptor(device, cmd_buffer, pDst, buffer_list,
1037 templ->entry[i].descriptor_type,
1038 (struct VkDescriptorImageInfo *) pSrc,
1039 templ->entry[i].has_sampler);
1040 if (templ->entry[i].immutable_samplers)
1041 memcpy(pDst + 16, templ->entry[i].immutable_samplers + 4 * j, 16);
1042 break;
1043 case VK_DESCRIPTOR_TYPE_SAMPLER:
1044 if (templ->entry[i].has_sampler)
1045 write_sampler_descriptor(device, pDst,
1046 (struct VkDescriptorImageInfo *) pSrc);
1047 else if (templ->entry[i].immutable_samplers)
1048 memcpy(pDst, templ->entry[i].immutable_samplers + 4 * j, 16);
1049 break;
1050 default:
1051 unreachable("unimplemented descriptor type");
1052 break;
1053 }
1054 pSrc += templ->entry[i].src_stride;
1055 pDst += templ->entry[i].dst_stride;
1056 ++buffer_list;
1057 }
1058 }
1059 }
1060
1061 void radv_UpdateDescriptorSetWithTemplate(VkDevice _device,
1062 VkDescriptorSet descriptorSet,
1063 VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
1064 const void *pData)
1065 {
1066 RADV_FROM_HANDLE(radv_device, device, _device);
1067 RADV_FROM_HANDLE(radv_descriptor_set, set, descriptorSet);
1068
1069 radv_update_descriptor_set_with_template(device, NULL, set, descriptorUpdateTemplate, pData);
1070 }