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 /* By defining the descriptors to be zero now, we can later verify that
413 * a descriptor has not been populated with user data.
415 memset(set
->descriptors
, 0, sizeof(struct anv_descriptor
) * layout
->size
);
417 /* Go through and fill out immutable samplers if we have any */
418 struct anv_descriptor
*desc
= set
->descriptors
;
419 for (uint32_t b
= 0; b
< layout
->binding_count
; b
++) {
420 if (layout
->binding
[b
].immutable_samplers
) {
421 for (uint32_t i
= 0; i
< layout
->binding
[b
].array_size
; i
++) {
422 /* The type will get changed to COMBINED_IMAGE_SAMPLER in
423 * UpdateDescriptorSets if needed. However, if the descriptor
424 * set has an immutable sampler, UpdateDescriptorSets may never
425 * touch it, so we need to make sure it's 100% valid now.
427 desc
[i
] = (struct anv_descriptor
) {
428 .type
= VK_DESCRIPTOR_TYPE_SAMPLER
,
429 .sampler
= layout
->binding
[b
].immutable_samplers
[i
],
433 desc
+= layout
->binding
[b
].array_size
;
436 /* Allocate surface state for the buffer views. */
437 for (uint32_t b
= 0; b
< layout
->buffer_count
; b
++) {
438 struct surface_state_free_list_entry
*entry
=
439 pool
->surface_state_free_list
;
440 struct anv_state state
;
444 state
.offset
= entry
->offset
;
445 state
.alloc_size
= 64;
446 pool
->surface_state_free_list
= entry
->next
;
448 state
= anv_state_stream_alloc(&pool
->surface_state_stream
, 64, 64);
451 set
->buffer_views
[b
].surface_state
= state
;
460 anv_descriptor_set_destroy(struct anv_device
*device
,
461 struct anv_descriptor_pool
*pool
,
462 struct anv_descriptor_set
*set
)
464 /* Put the buffer view surface state back on the free list. */
465 for (uint32_t b
= 0; b
< set
->buffer_count
; b
++) {
466 struct surface_state_free_list_entry
*entry
=
467 set
->buffer_views
[b
].surface_state
.map
;
468 entry
->next
= pool
->surface_state_free_list
;
469 pool
->surface_state_free_list
= entry
;
472 /* Put the descriptor set allocation back on the free list. */
473 const uint32_t index
= (char *) set
- pool
->data
;
474 if (index
+ set
->size
== pool
->next
) {
477 struct pool_free_list_entry
*entry
= (struct pool_free_list_entry
*) set
;
478 entry
->next
= pool
->free_list
;
479 entry
->size
= set
->size
;
480 pool
->free_list
= (char *) entry
- pool
->data
;
484 VkResult
anv_AllocateDescriptorSets(
486 const VkDescriptorSetAllocateInfo
* pAllocateInfo
,
487 VkDescriptorSet
* pDescriptorSets
)
489 ANV_FROM_HANDLE(anv_device
, device
, _device
);
490 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, pAllocateInfo
->descriptorPool
);
492 VkResult result
= VK_SUCCESS
;
493 struct anv_descriptor_set
*set
;
496 for (i
= 0; i
< pAllocateInfo
->descriptorSetCount
; i
++) {
497 ANV_FROM_HANDLE(anv_descriptor_set_layout
, layout
,
498 pAllocateInfo
->pSetLayouts
[i
]);
500 result
= anv_descriptor_set_create(device
, pool
, layout
, &set
);
501 if (result
!= VK_SUCCESS
)
504 pDescriptorSets
[i
] = anv_descriptor_set_to_handle(set
);
507 if (result
!= VK_SUCCESS
)
508 anv_FreeDescriptorSets(_device
, pAllocateInfo
->descriptorPool
,
514 VkResult
anv_FreeDescriptorSets(
516 VkDescriptorPool descriptorPool
,
518 const VkDescriptorSet
* pDescriptorSets
)
520 ANV_FROM_HANDLE(anv_device
, device
, _device
);
521 ANV_FROM_HANDLE(anv_descriptor_pool
, pool
, descriptorPool
);
523 for (uint32_t i
= 0; i
< count
; i
++) {
524 ANV_FROM_HANDLE(anv_descriptor_set
, set
, pDescriptorSets
[i
]);
526 anv_descriptor_set_destroy(device
, pool
, set
);
532 void anv_UpdateDescriptorSets(
534 uint32_t descriptorWriteCount
,
535 const VkWriteDescriptorSet
* pDescriptorWrites
,
536 uint32_t descriptorCopyCount
,
537 const VkCopyDescriptorSet
* pDescriptorCopies
)
539 ANV_FROM_HANDLE(anv_device
, device
, _device
);
541 for (uint32_t i
= 0; i
< descriptorWriteCount
; i
++) {
542 const VkWriteDescriptorSet
*write
= &pDescriptorWrites
[i
];
543 ANV_FROM_HANDLE(anv_descriptor_set
, set
, write
->dstSet
);
544 const struct anv_descriptor_set_binding_layout
*bind_layout
=
545 &set
->layout
->binding
[write
->dstBinding
];
546 struct anv_descriptor
*desc
=
547 &set
->descriptors
[bind_layout
->descriptor_index
];
548 desc
+= write
->dstArrayElement
;
550 assert(write
->descriptorType
== bind_layout
->type
);
552 switch (write
->descriptorType
) {
553 case VK_DESCRIPTOR_TYPE_SAMPLER
:
554 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
555 ANV_FROM_HANDLE(anv_sampler
, sampler
,
556 write
->pImageInfo
[j
].sampler
);
558 desc
[j
] = (struct anv_descriptor
) {
559 .type
= VK_DESCRIPTOR_TYPE_SAMPLER
,
565 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
:
566 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
567 ANV_FROM_HANDLE(anv_image_view
, iview
,
568 write
->pImageInfo
[j
].imageView
);
569 ANV_FROM_HANDLE(anv_sampler
, sampler
,
570 write
->pImageInfo
[j
].sampler
);
572 desc
[j
].type
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
;
573 desc
[j
].image_view
= iview
;
575 /* If this descriptor has an immutable sampler, we don't want
579 desc
[j
].sampler
= sampler
;
583 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
:
584 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
:
585 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
586 ANV_FROM_HANDLE(anv_image_view
, iview
,
587 write
->pImageInfo
[j
].imageView
);
589 desc
[j
] = (struct anv_descriptor
) {
590 .type
= write
->descriptorType
,
596 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
:
597 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
:
598 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
599 ANV_FROM_HANDLE(anv_buffer_view
, bview
,
600 write
->pTexelBufferView
[j
]);
602 desc
[j
] = (struct anv_descriptor
) {
603 .type
= write
->descriptorType
,
604 .buffer_view
= bview
,
609 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
:
610 anv_finishme("input attachments not implemented");
613 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
:
614 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
:
615 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
:
616 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
:
617 for (uint32_t j
= 0; j
< write
->descriptorCount
; j
++) {
618 assert(write
->pBufferInfo
[j
].buffer
);
619 ANV_FROM_HANDLE(anv_buffer
, buffer
, write
->pBufferInfo
[j
].buffer
);
622 struct anv_buffer_view
*view
=
623 &set
->buffer_views
[bind_layout
->buffer_index
];
624 view
+= write
->dstArrayElement
+ j
;
627 anv_isl_format_for_descriptor_type(write
->descriptorType
);
628 view
->bo
= buffer
->bo
;
629 view
->offset
= buffer
->offset
+ write
->pBufferInfo
[j
].offset
;
631 /* For buffers with dynamic offsets, we use the full possible
632 * range in the surface state and do the actual range-checking
635 if (bind_layout
->dynamic_offset_index
>= 0 ||
636 write
->pBufferInfo
[j
].range
== VK_WHOLE_SIZE
)
637 view
->range
= buffer
->size
- write
->pBufferInfo
[j
].offset
;
639 view
->range
= write
->pBufferInfo
[j
].range
;
641 anv_fill_buffer_surface_state(device
, view
->surface_state
,
643 view
->offset
, view
->range
, 1);
645 desc
[j
] = (struct anv_descriptor
) {
646 .type
= write
->descriptorType
,
657 for (uint32_t i
= 0; i
< descriptorCopyCount
; i
++) {
658 const VkCopyDescriptorSet
*copy
= &pDescriptorCopies
[i
];
659 ANV_FROM_HANDLE(anv_descriptor_set
, src
, copy
->dstSet
);
660 ANV_FROM_HANDLE(anv_descriptor_set
, dst
, copy
->dstSet
);
662 const struct anv_descriptor_set_binding_layout
*src_layout
=
663 &src
->layout
->binding
[copy
->srcBinding
];
664 struct anv_descriptor
*src_desc
=
665 &src
->descriptors
[src_layout
->descriptor_index
];
666 src_desc
+= copy
->srcArrayElement
;
668 const struct anv_descriptor_set_binding_layout
*dst_layout
=
669 &dst
->layout
->binding
[copy
->dstBinding
];
670 struct anv_descriptor
*dst_desc
=
671 &dst
->descriptors
[dst_layout
->descriptor_index
];
672 dst_desc
+= copy
->dstArrayElement
;
674 for (uint32_t j
= 0; j
< copy
->descriptorCount
; j
++)
675 dst_desc
[j
] = src_desc
[j
];