2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include "anv_private.h"
33 * Descriptor set layouts.
36 VkResult
anv_CreateDescriptorSetLayout(
38 const VkDescriptorSetLayoutCreateInfo
* pCreateInfo
,
39 const VkAllocationCallbacks
* pAllocator
,
40 VkDescriptorSetLayout
* pSetLayout
)
42 ANV_FROM_HANDLE(anv_device
, device
, _device
);
43 struct anv_descriptor_set_layout
*set_layout
;
45 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
);
47 uint32_t max_binding
= 0;
48 uint32_t immutable_sampler_count
= 0;
49 for (uint32_t j
= 0; j
< pCreateInfo
->bindingCount
; j
++) {
50 max_binding
= MAX2(max_binding
, pCreateInfo
->pBindings
[j
].binding
);
51 if (pCreateInfo
->pBindings
[j
].pImmutableSamplers
)
52 immutable_sampler_count
+= pCreateInfo
->pBindings
[j
].descriptorCount
;
55 size_t size
= sizeof(struct anv_descriptor_set_layout
) +
56 (max_binding
+ 1) * sizeof(set_layout
->binding
[0]) +
57 immutable_sampler_count
* sizeof(struct anv_sampler
*);
59 set_layout
= anv_alloc2(&device
->alloc
, pAllocator
, size
, 8,
60 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
62 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
64 /* We just allocate all the samplers at the end of the struct */
65 struct anv_sampler
**samplers
=
66 (struct anv_sampler
**)&set_layout
->binding
[max_binding
+ 1];
68 set_layout
->binding_count
= max_binding
+ 1;
69 set_layout
->shader_stages
= 0;
72 for (uint32_t b
= 0; b
<= max_binding
; b
++) {
73 /* Initialize all binding_layout entries to -1 */
74 memset(&set_layout
->binding
[b
], -1, sizeof(set_layout
->binding
[b
]));
76 set_layout
->binding
[b
].array_size
= 0;
77 set_layout
->binding
[b
].immutable_samplers
= NULL
;
80 /* Initialize all samplers to 0 */
81 memset(samplers
, 0, immutable_sampler_count
* sizeof(*samplers
));
83 uint32_t sampler_count
[MESA_SHADER_STAGES
] = { 0, };
84 uint32_t surface_count
[MESA_SHADER_STAGES
] = { 0, };
85 uint32_t image_count
[MESA_SHADER_STAGES
] = { 0, };
86 uint32_t buffer_count
= 0;
87 uint32_t dynamic_offset_count
= 0;
89 for (uint32_t j
= 0; j
< pCreateInfo
->bindingCount
; j
++) {
90 const VkDescriptorSetLayoutBinding
*binding
= &pCreateInfo
->pBindings
[j
];
91 uint32_t b
= binding
->binding
;
92 /* We temporarily store the pointer to the binding in the
93 * immutable_samplers pointer. This provides us with a quick-and-dirty
94 * way to sort the bindings by binding number.
96 set_layout
->binding
[b
].immutable_samplers
= (void *)binding
;
99 for (uint32_t b
= 0; b
<= max_binding
; b
++) {
100 const VkDescriptorSetLayoutBinding
*binding
=
101 (void *)set_layout
->binding
[b
].immutable_samplers
;
106 assert(binding
->descriptorCount
> 0);
108 set_layout
->binding
[b
].type
= binding
->descriptorType
;
110 set_layout
->binding
[b
].array_size
= binding
->descriptorCount
;
111 set_layout
->binding
[b
].descriptor_index
= set_layout
->size
;
112 set_layout
->size
+= binding
->descriptorCount
;
114 switch (binding
->descriptorType
) {
115 case VK_DESCRIPTOR_TYPE_SAMPLER
:
116 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
:
117 anv_foreach_stage(s
, binding
->stageFlags
) {
118 set_layout
->binding
[b
].stage
[s
].sampler_index
= sampler_count
[s
];
119 sampler_count
[s
] += binding
->descriptorCount
;
126 switch (binding
->descriptorType
) {
127 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
:
128 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
:
129 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
:
130 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
:
131 set_layout
->binding
[b
].buffer_index
= buffer_count
;
132 buffer_count
+= binding
->descriptorCount
;
135 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
:
136 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
:
137 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
:
138 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
:
139 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
:
140 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
:
141 anv_foreach_stage(s
, binding
->stageFlags
) {
142 set_layout
->binding
[b
].stage
[s
].surface_index
= surface_count
[s
];
143 surface_count
[s
] += binding
->descriptorCount
;
150 switch (binding
->descriptorType
) {
151 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
:
152 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
:
153 set_layout
->binding
[b
].dynamic_offset_index
= dynamic_offset_count
;
154 dynamic_offset_count
+= binding
->descriptorCount
;
160 switch (binding
->descriptorType
) {
161 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
:
162 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
:
163 anv_foreach_stage(s
, binding
->stageFlags
) {
164 set_layout
->binding
[b
].stage
[s
].image_index
= image_count
[s
];
165 image_count
[s
] += binding
->descriptorCount
;
172 if (binding
->pImmutableSamplers
) {
173 set_layout
->binding
[b
].immutable_samplers
= samplers
;
174 samplers
+= binding
->descriptorCount
;
176 for (uint32_t i
= 0; i
< binding
->descriptorCount
; i
++)
177 set_layout
->binding
[b
].immutable_samplers
[i
] =
178 anv_sampler_from_handle(binding
->pImmutableSamplers
[i
]);
180 set_layout
->binding
[b
].immutable_samplers
= NULL
;
183 set_layout
->shader_stages
|= binding
->stageFlags
;
186 set_layout
->buffer_count
= buffer_count
;
187 set_layout
->dynamic_offset_count
= dynamic_offset_count
;
189 *pSetLayout
= anv_descriptor_set_layout_to_handle(set_layout
);
194 void anv_DestroyDescriptorSetLayout(
196 VkDescriptorSetLayout _set_layout
,
197 const VkAllocationCallbacks
* pAllocator
)
199 ANV_FROM_HANDLE(anv_device
, device
, _device
);
200 ANV_FROM_HANDLE(anv_descriptor_set_layout
, set_layout
, _set_layout
);
202 anv_free2(&device
->alloc
, pAllocator
, set_layout
);
206 * Pipeline layouts. These have nothing to do with the pipeline. They are
207 * just muttiple descriptor set layouts pasted together
210 VkResult
anv_CreatePipelineLayout(
212 const VkPipelineLayoutCreateInfo
* pCreateInfo
,
213 const VkAllocationCallbacks
* pAllocator
,
214 VkPipelineLayout
* pPipelineLayout
)
216 ANV_FROM_HANDLE(anv_device
, device
, _device
);
217 struct anv_pipeline_layout
*layout
;
219 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
);
221 layout
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*layout
), 8,
222 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
224 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
226 layout
->num_sets
= pCreateInfo
->setLayoutCount
;
228 unsigned dynamic_offset_count
= 0;
230 memset(layout
->stage
, 0, sizeof(layout
->stage
));
231 for (uint32_t set
= 0; set
< pCreateInfo
->setLayoutCount
; set
++) {
232 ANV_FROM_HANDLE(anv_descriptor_set_layout
, set_layout
,
233 pCreateInfo
->pSetLayouts
[set
]);
234 layout
->set
[set
].layout
= set_layout
;
236 layout
->set
[set
].dynamic_offset_start
= dynamic_offset_count
;
237 for (uint32_t b
= 0; b
< set_layout
->binding_count
; b
++) {
238 if (set_layout
->binding
[b
].dynamic_offset_index
< 0)
241 dynamic_offset_count
+= set_layout
->binding
[b
].array_size
;
242 for (gl_shader_stage s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
243 if (set_layout
->binding
[b
].stage
[s
].surface_index
>= 0)
244 layout
->stage
[s
].has_dynamic_offsets
= true;
249 *pPipelineLayout
= anv_pipeline_layout_to_handle(layout
);
254 void anv_DestroyPipelineLayout(
256 VkPipelineLayout _pipelineLayout
,
257 const VkAllocationCallbacks
* pAllocator
)
259 ANV_FROM_HANDLE(anv_device
, device
, _device
);
260 ANV_FROM_HANDLE(anv_pipeline_layout
, pipeline_layout
, _pipelineLayout
);
262 anv_free2(&device
->alloc
, pAllocator
, pipeline_layout
);
268 * These are implemented using a big pool of memory and a free-list for the
269 * host memory allocations and a state_stream and a free list for the buffer
270 * view surface state. The spec allows us to fail to allocate due to
271 * fragmentation in all cases but two: 1) after pool reset, allocating up
272 * until the pool size with no freeing must succeed and 2) allocating and
273 * freeing only descriptor sets with the same layout. Case 1) is easy enogh,
274 * and the free lists lets us recycle blocks for case 2).
279 VkResult
anv_CreateDescriptorPool(
281 const VkDescriptorPoolCreateInfo
* pCreateInfo
,
282 const VkAllocationCallbacks
* pAllocator
,
283 VkDescriptorPool
* pDescriptorPool
)
285 ANV_FROM_HANDLE(anv_device
, device
, _device
);
286 struct anv_descriptor_pool
*pool
;
288 uint32_t descriptor_count
= 0;
289 uint32_t buffer_count
= 0;
290 for (uint32_t i
= 0; i
< pCreateInfo
->poolSizeCount
; i
++) {
291 switch (pCreateInfo
->pPoolSizes
[i
].type
) {
292 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
:
293 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
:
294 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
:
295 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
:
296 buffer_count
+= pCreateInfo
->pPoolSizes
[i
].descriptorCount
;
298 descriptor_count
+= pCreateInfo
->pPoolSizes
[i
].descriptorCount
;
305 pCreateInfo
->maxSets
* sizeof(struct anv_descriptor_set
) +
306 descriptor_count
* sizeof(struct anv_descriptor
) +
307 buffer_count
* sizeof(struct anv_buffer_view
);
309 pool
= anv_alloc2(&device
->alloc
, pAllocator
, size
, 8,
310 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
312 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
316 pool
->free_list
= EMPTY
;
318 anv_state_stream_init(&pool
->surface_state_stream
,
319 &device
->surface_state_block_pool
);
320 pool
->surface_state_free_list
= NULL
;
322 *pDescriptorPool
= anv_descriptor_pool_to_handle(pool
);
327 void anv_DestroyDescriptorPool(
329 VkDescriptorPool _pool
,
330 const VkAllocationCallbacks
* pAllocator
)
332 ANV_FROM_HANDLE(anv_device
, device
, _device
);
333 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, _pool
);
335 anv_state_stream_finish(&pool
->surface_state_stream
);
336 anv_free2(&device
->alloc
, pAllocator
, pool
);
339 VkResult
anv_ResetDescriptorPool(
341 VkDescriptorPool descriptorPool
,
342 VkDescriptorPoolResetFlags flags
)
344 ANV_FROM_HANDLE(anv_device
, device
, _device
);
345 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, descriptorPool
);
348 pool
->free_list
= EMPTY
;
349 anv_state_stream_finish(&pool
->surface_state_stream
);
350 anv_state_stream_init(&pool
->surface_state_stream
,
351 &device
->surface_state_block_pool
);
352 pool
->surface_state_free_list
= NULL
;
357 struct pool_free_list_entry
{
363 layout_size(const struct anv_descriptor_set_layout
*layout
)
366 sizeof(struct anv_descriptor_set
) +
367 layout
->size
* sizeof(struct anv_descriptor
) +
368 layout
->buffer_count
* sizeof(struct anv_buffer_view
);
371 struct surface_state_free_list_entry
{
377 anv_descriptor_set_create(struct anv_device
*device
,
378 struct anv_descriptor_pool
*pool
,
379 const struct anv_descriptor_set_layout
*layout
,
380 struct anv_descriptor_set
**out_set
)
382 struct anv_descriptor_set
*set
;
383 const size_t size
= layout_size(layout
);
386 if (size
<= pool
->size
- pool
->next
) {
387 set
= (struct anv_descriptor_set
*) (pool
->data
+ pool
->next
);
390 struct pool_free_list_entry
*entry
;
391 uint32_t *link
= &pool
->free_list
;
392 for (uint32_t f
= pool
->free_list
; f
!= EMPTY
; f
= entry
->next
) {
393 entry
= (struct pool_free_list_entry
*) (pool
->data
+ f
);
394 if (size
<= entry
->size
) {
396 set
= (struct anv_descriptor_set
*) entry
;
404 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
407 set
->layout
= layout
;
409 (struct anv_buffer_view
*) &set
->descriptors
[layout
->size
];
410 set
->buffer_count
= layout
->buffer_count
;
412 /* Go through and fill out immutable samplers if we have any */
413 struct anv_descriptor
*desc
= set
->descriptors
;
414 for (uint32_t b
= 0; b
< layout
->binding_count
; b
++) {
415 if (layout
->binding
[b
].immutable_samplers
) {
416 for (uint32_t i
= 0; i
< layout
->binding
[b
].array_size
; i
++) {
417 /* The type will get changed to COMBINED_IMAGE_SAMPLER in
418 * UpdateDescriptorSets if needed. However, if the descriptor
419 * set has an immutable sampler, UpdateDescriptorSets may never
420 * touch it, so we need to make sure it's 100% valid now.
422 desc
[i
] = (struct anv_descriptor
) {
423 .type
= VK_DESCRIPTOR_TYPE_SAMPLER
,
424 .sampler
= layout
->binding
[b
].immutable_samplers
[i
],
428 desc
+= layout
->binding
[b
].array_size
;
431 /* Allocate surface state for the buffer views. */
432 for (uint32_t b
= 0; b
< layout
->buffer_count
; b
++) {
433 struct surface_state_free_list_entry
*entry
=
434 pool
->surface_state_free_list
;
435 struct anv_state state
;
439 state
.offset
= entry
->offset
;
440 state
.alloc_size
= 64;
441 pool
->surface_state_free_list
= entry
->next
;
443 state
= anv_state_stream_alloc(&pool
->surface_state_stream
, 64, 64);
446 set
->buffer_views
[b
].surface_state
= state
;
455 anv_descriptor_set_destroy(struct anv_device
*device
,
456 struct anv_descriptor_pool
*pool
,
457 struct anv_descriptor_set
*set
)
459 /* Put the buffer view surface state back on the free list. */
460 for (uint32_t b
= 0; b
< set
->buffer_count
; b
++) {
461 struct surface_state_free_list_entry
*entry
=
462 set
->buffer_views
[b
].surface_state
.map
;
463 entry
->next
= pool
->surface_state_free_list
;
464 pool
->surface_state_free_list
= entry
;
467 /* Put the descriptor set allocation back on the free list. */
468 const uint32_t index
= (char *) set
- pool
->data
;
469 if (index
+ set
->size
== pool
->next
) {
472 struct pool_free_list_entry
*entry
= (struct pool_free_list_entry
*) set
;
473 entry
->next
= pool
->free_list
;
474 entry
->size
= set
->size
;
475 pool
->free_list
= (char *) entry
- pool
->data
;
479 VkResult
anv_AllocateDescriptorSets(
481 const VkDescriptorSetAllocateInfo
* pAllocateInfo
,
482 VkDescriptorSet
* pDescriptorSets
)
484 ANV_FROM_HANDLE(anv_device
, device
, _device
);
485 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, pAllocateInfo
->descriptorPool
);
487 VkResult result
= VK_SUCCESS
;
488 struct anv_descriptor_set
*set
;
491 for (i
= 0; i
< pAllocateInfo
->descriptorSetCount
; i
++) {
492 ANV_FROM_HANDLE(anv_descriptor_set_layout
, layout
,
493 pAllocateInfo
->pSetLayouts
[i
]);
495 result
= anv_descriptor_set_create(device
, pool
, layout
, &set
);
496 if (result
!= VK_SUCCESS
)
499 pDescriptorSets
[i
] = anv_descriptor_set_to_handle(set
);
502 if (result
!= VK_SUCCESS
)
503 anv_FreeDescriptorSets(_device
, pAllocateInfo
->descriptorPool
,
509 VkResult
anv_FreeDescriptorSets(
511 VkDescriptorPool descriptorPool
,
513 const VkDescriptorSet
* pDescriptorSets
)
515 ANV_FROM_HANDLE(anv_device
, device
, _device
);
516 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, descriptorPool
);
518 for (uint32_t i
= 0; i
< count
; i
++) {
519 ANV_FROM_HANDLE(anv_descriptor_set
, set
, pDescriptorSets
[i
]);
521 anv_descriptor_set_destroy(device
, pool
, set
);
527 void anv_UpdateDescriptorSets(
529 uint32_t descriptorWriteCount
,
530 const VkWriteDescriptorSet
* pDescriptorWrites
,
531 uint32_t descriptorCopyCount
,
532 const VkCopyDescriptorSet
* pDescriptorCopies
)
534 ANV_FROM_HANDLE(anv_device
, device
, _device
);
536 for (uint32_t i
= 0; i
< descriptorWriteCount
; i
++) {
537 const VkWriteDescriptorSet
*write
= &pDescriptorWrites
[i
];
538 ANV_FROM_HANDLE(anv_descriptor_set
, set
, write
->dstSet
);
539 const struct anv_descriptor_set_binding_layout
*bind_layout
=
540 &set
->layout
->binding
[write
->dstBinding
];
541 struct anv_descriptor
*desc
=
542 &set
->descriptors
[bind_layout
->descriptor_index
];
543 desc
+= write
->dstArrayElement
;
545 assert(write
->descriptorType
== bind_layout
->type
);
547 switch (write
->descriptorType
) {
548 case VK_DESCRIPTOR_TYPE_SAMPLER
:
549 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
550 ANV_FROM_HANDLE(anv_sampler
, sampler
,
551 write
->pImageInfo
[j
].sampler
);
553 desc
[j
] = (struct anv_descriptor
) {
554 .type
= VK_DESCRIPTOR_TYPE_SAMPLER
,
560 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
:
561 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
562 ANV_FROM_HANDLE(anv_image_view
, iview
,
563 write
->pImageInfo
[j
].imageView
);
564 ANV_FROM_HANDLE(anv_sampler
, sampler
,
565 write
->pImageInfo
[j
].sampler
);
567 desc
[j
].type
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
;
568 desc
[j
].image_view
= iview
;
570 /* If this descriptor has an immutable sampler, we don't want
574 desc
[j
].sampler
= sampler
;
578 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
:
579 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
:
580 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
581 ANV_FROM_HANDLE(anv_image_view
, iview
,
582 write
->pImageInfo
[j
].imageView
);
584 desc
[j
] = (struct anv_descriptor
) {
585 .type
= write
->descriptorType
,
591 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
:
592 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
:
593 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
594 ANV_FROM_HANDLE(anv_buffer_view
, bview
,
595 write
->pTexelBufferView
[j
]);
597 desc
[j
] = (struct anv_descriptor
) {
598 .type
= write
->descriptorType
,
599 .buffer_view
= bview
,
604 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
:
605 anv_finishme("input attachments not implemented");
608 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
:
609 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
:
610 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
:
611 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
:
612 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
613 assert(write
->pBufferInfo
[j
].buffer
);
614 ANV_FROM_HANDLE(anv_buffer
, buffer
, write
->pBufferInfo
[j
].buffer
);
617 struct anv_buffer_view
*view
=
618 &set
->buffer_views
[bind_layout
->buffer_index
];
619 view
+= write
->dstArrayElement
+ j
;
622 anv_isl_format_for_descriptor_type(write
->descriptorType
);
623 view
->bo
= buffer
->bo
;
624 view
->offset
= buffer
->offset
+ write
->pBufferInfo
[j
].offset
;
626 /* For buffers with dynamic offsets, we use the full possible
627 * range in the surface state and do the actual range-checking
630 if (bind_layout
->dynamic_offset_index
>= 0 ||
631 write
->pBufferInfo
[j
].range
== VK_WHOLE_SIZE
)
632 view
->range
= buffer
->size
- write
->pBufferInfo
[j
].offset
;
634 view
->range
= write
->pBufferInfo
[j
].range
;
636 anv_fill_buffer_surface_state(device
, view
->surface_state
,
638 view
->offset
, view
->range
, 1);
640 desc
[j
] = (struct anv_descriptor
) {
641 .type
= write
->descriptorType
,
652 for (uint32_t i
= 0; i
< descriptorCopyCount
; i
++) {
653 const VkCopyDescriptorSet
*copy
= &pDescriptorCopies
[i
];
654 ANV_FROM_HANDLE(anv_descriptor_set
, src
, copy
->dstSet
);
655 ANV_FROM_HANDLE(anv_descriptor_set
, dst
, copy
->dstSet
);
657 const struct anv_descriptor_set_binding_layout
*src_layout
=
658 &src
->layout
->binding
[copy
->srcBinding
];
659 struct anv_descriptor
*src_desc
=
660 &src
->descriptors
[src_layout
->descriptor_index
];
661 src_desc
+= copy
->srcArrayElement
;
663 const struct anv_descriptor_set_binding_layout
*dst_layout
=
664 &dst
->layout
->binding
[copy
->dstBinding
];
665 struct anv_descriptor
*dst_desc
=
666 &dst
->descriptors
[dst_layout
->descriptor_index
];
667 dst_desc
+= copy
->dstArrayElement
;
669 for (uint32_t j
= 0; j
< copy
->descriptorCount
; j
++)
670 dst_desc
[j
] = src_desc
[j
];