| 1 |
/* |
| 2 |
* Copyright © 2022 Imagination Technologies Ltd. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "pvr_descriptor_set.h" |
| 8 |
|
| 9 |
#include "vk_descriptor_update_template.h" |
| 10 |
#include "vk_log.h" |
| 11 |
#include "vk_util.h" |
| 12 |
|
| 13 |
#include "pvr_buffer.h" |
| 14 |
#include "pvr_csb.h" |
| 15 |
#include "pvr_device.h" |
| 16 |
#include "pvr_entrypoints.h" |
| 17 |
#include "pvr_image.h" |
| 18 |
#include "pvr_physical_device.h" |
| 19 |
#include "pvr_sampler.h" |
| 20 |
|
| 21 |
static void |
| 22 |
write_buffer(const struct pvr_descriptor_set *set, |
| 23 |
const VkDescriptorBufferInfo *buffer_info, |
| 24 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 25 |
uint32_t elem) |
| 26 |
{ |
| 27 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 28 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 29 |
|
| 30 |
if (buffer_info->buffer == VK_NULL_HANDLE) { |
| 31 |
memset(desc_mapping, 0, sizeof(struct pvr_buffer_descriptor)); |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
VK_FROM_HANDLE(pvr_buffer, buffer, buffer_info->buffer); |
| 36 |
|
| 37 |
const pvr_dev_addr_t buffer_addr = |
| 38 |
PVR_DEV_ADDR_OFFSET(buffer->dev_addr, buffer_info->offset); |
| 39 |
|
| 40 |
UNUSED uint32_t range = |
| 41 |
vk_buffer_range(&buffer->vk, buffer_info->offset, buffer_info->range); |
| 42 |
|
| 43 |
const struct pvr_buffer_descriptor buffer_desc = { |
| 44 |
.addr = buffer_addr.addr, |
| 45 |
.size = range, |
| 46 |
}; |
| 47 |
|
| 48 |
memcpy(desc_mapping, &buffer_desc, sizeof(buffer_desc)); |
| 49 |
} |
| 50 |
|
| 51 |
static void |
| 52 |
write_dynamic_buffer(struct pvr_descriptor_set *set, |
| 53 |
const VkDescriptorBufferInfo *buffer_info, |
| 54 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 55 |
uint32_t elem) |
| 56 |
{ |
| 57 |
assert(binding->dynamic_buffer_idx != ~0); |
| 58 |
const unsigned desc_offset = binding->dynamic_buffer_idx + elem; |
| 59 |
struct pvr_buffer_descriptor *desc_mapping = |
| 60 |
&set->dynamic_buffers[desc_offset]; |
| 61 |
|
| 62 |
if (buffer_info->buffer == VK_NULL_HANDLE) { |
| 63 |
memset(desc_mapping, 0, sizeof(*desc_mapping)); |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
VK_FROM_HANDLE(pvr_buffer, buffer, buffer_info->buffer); |
| 68 |
|
| 69 |
const pvr_dev_addr_t buffer_addr = |
| 70 |
PVR_DEV_ADDR_OFFSET(buffer->dev_addr, buffer_info->offset); |
| 71 |
|
| 72 |
UNUSED uint32_t range = |
| 73 |
vk_buffer_range(&buffer->vk, buffer_info->offset, buffer_info->range); |
| 74 |
|
| 75 |
desc_mapping->addr = buffer_addr.addr; |
| 76 |
desc_mapping->size = range; |
| 77 |
} |
| 78 |
|
| 79 |
static void |
| 80 |
write_sampler(const struct pvr_descriptor_set *set, |
| 81 |
const VkDescriptorImageInfo *image_info, |
| 82 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 83 |
uint32_t elem) |
| 84 |
{ |
| 85 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 86 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 87 |
struct pvr_sampler *sampler; |
| 88 |
|
| 89 |
if (binding->immutable_sampler_count) { |
| 90 |
sampler = binding->immutable_samplers[elem]; |
| 91 |
} else { |
| 92 |
assert(image_info); |
| 93 |
VK_FROM_HANDLE(pvr_sampler, info_sampler, image_info->sampler); |
| 94 |
sampler = info_sampler; |
| 95 |
} |
| 96 |
|
| 97 |
struct pvr_sampler_descriptor sampler_desc = sampler->descriptor; |
| 98 |
memcpy(desc_mapping, &sampler_desc, sizeof(sampler_desc)); |
| 99 |
} |
| 100 |
|
| 101 |
static void |
| 102 |
write_image_sampler(const struct pvr_descriptor_set *set, |
| 103 |
const VkDescriptorImageInfo *image_info, |
| 104 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 105 |
uint32_t elem) |
| 106 |
{ |
| 107 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 108 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 109 |
|
| 110 |
struct pvr_combined_image_sampler_descriptor image_sampler_desc = { 0 }; |
| 111 |
|
| 112 |
VK_FROM_HANDLE(pvr_sampler, info_sampler, image_info->sampler); |
| 113 |
struct pvr_sampler *sampler = binding->immutable_sampler_count |
| 114 |
? binding->immutable_samplers[elem] |
| 115 |
: info_sampler; |
| 116 |
|
| 117 |
image_sampler_desc.sampler = sampler->descriptor; |
| 118 |
|
| 119 |
if (image_info->imageView != VK_NULL_HANDLE) { |
| 120 |
VK_FROM_HANDLE(pvr_image_view, image_view, image_info->imageView); |
| 121 |
image_sampler_desc.image = |
| 122 |
image_view->image_state[PVR_TEXTURE_STATE_SAMPLE]; |
| 123 |
if (image_view->sampler_words[0]) { |
| 124 |
for (unsigned i = 0; i < ROGUE_NUM_TEXSTATE_SAMPLER_WORDS; i++) { |
| 125 |
image_sampler_desc.sampler.words[i] |= image_view->sampler_words[i]; |
| 126 |
image_sampler_desc.sampler.gather_words[i] |= |
| 127 |
image_view->sampler_words[i]; |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
memcpy(desc_mapping, &image_sampler_desc, sizeof(image_sampler_desc)); |
| 133 |
} |
| 134 |
|
| 135 |
static void |
| 136 |
write_input_attachment(const struct pvr_descriptor_set *set, |
| 137 |
const VkDescriptorImageInfo *image_info, |
| 138 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 139 |
uint32_t elem) |
| 140 |
{ |
| 141 |
VK_FROM_HANDLE(pvr_image_view, image_view, image_info->imageView); |
| 142 |
|
| 143 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 144 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 145 |
|
| 146 |
struct pvr_image_descriptor image_desc = |
| 147 |
image_view->image_state[PVR_TEXTURE_STATE_ATTACHMENT]; |
| 148 |
|
| 149 |
memcpy(desc_mapping, &image_desc, sizeof(image_desc)); |
| 150 |
} |
| 151 |
|
| 152 |
static void |
| 153 |
write_sampled_image(const struct pvr_descriptor_set *set, |
| 154 |
const VkDescriptorImageInfo *image_info, |
| 155 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 156 |
uint32_t elem, |
| 157 |
const struct pvr_device_info *dev_info) |
| 158 |
{ |
| 159 |
VK_FROM_HANDLE(pvr_image_view, image_view, image_info->imageView); |
| 160 |
|
| 161 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 162 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 163 |
|
| 164 |
struct pvr_image_descriptor sampled_image_desc = |
| 165 |
image_view->image_state[PVR_TEXTURE_STATE_SAMPLE]; |
| 166 |
|
| 167 |
/* YCbCr must use combined image smapler */ |
| 168 |
assert(!image_view->sampler_words[0] && !image_view->sampler_words[1]); |
| 169 |
|
| 170 |
memcpy(desc_mapping, &sampled_image_desc, sizeof(sampled_image_desc)); |
| 171 |
} |
| 172 |
|
| 173 |
static void |
| 174 |
write_storage_image(const struct pvr_descriptor_set *set, |
| 175 |
const VkDescriptorImageInfo *image_info, |
| 176 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 177 |
uint32_t elem, |
| 178 |
const struct pvr_device_info *dev_info) |
| 179 |
{ |
| 180 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 181 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 182 |
|
| 183 |
if (image_info->imageView == VK_NULL_HANDLE) { |
| 184 |
memset(desc_mapping, 0, sizeof(struct pvr_image_descriptor)); |
| 185 |
return; |
| 186 |
} |
| 187 |
|
| 188 |
VK_FROM_HANDLE(pvr_image_view, image_view, image_info->imageView); |
| 189 |
|
| 190 |
bool is_cube = image_view->vk.view_type == VK_IMAGE_VIEW_TYPE_CUBE || |
| 191 |
image_view->vk.view_type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; |
| 192 |
|
| 193 |
struct pvr_image_descriptor storage_image_desc = |
| 194 |
image_view->image_state[is_cube ? PVR_TEXTURE_STATE_STORAGE |
| 195 |
: PVR_TEXTURE_STATE_SAMPLE]; |
| 196 |
|
| 197 |
if (!PVR_HAS_FEATURE(dev_info, tpu_extended_integer_lookup)) { |
| 198 |
struct ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1 word1; |
| 199 |
ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1_unpack(&storage_image_desc.words[1], |
| 200 |
&word1); |
| 201 |
|
| 202 |
word1.index_lookup = true; |
| 203 |
ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1_pack(&storage_image_desc.words[1], |
| 204 |
&word1); |
| 205 |
} |
| 206 |
|
| 207 |
memcpy(desc_mapping, &storage_image_desc, sizeof(storage_image_desc)); |
| 208 |
} |
| 209 |
|
| 210 |
static void |
| 211 |
write_buffer_view(const struct pvr_descriptor_set *set, |
| 212 |
const VkBufferView _buffer_view, |
| 213 |
const struct pvr_descriptor_set_layout_binding *binding, |
| 214 |
uint32_t elem, |
| 215 |
bool is_texel_buffer, |
| 216 |
const struct pvr_device_info *dev_info) |
| 217 |
{ |
| 218 |
const unsigned desc_offset = binding->offset + (elem * binding->stride); |
| 219 |
void *desc_mapping = (uint8_t *)set->mapping + desc_offset; |
| 220 |
|
| 221 |
if (_buffer_view == VK_NULL_HANDLE) { |
| 222 |
memset(desc_mapping, 0, sizeof(struct pvr_image_descriptor)); |
| 223 |
return; |
| 224 |
} |
| 225 |
|
| 226 |
VK_FROM_HANDLE(pvr_buffer_view, buffer_view, _buffer_view); |
| 227 |
struct pvr_image_descriptor buffer_view_state = buffer_view->image_state; |
| 228 |
|
| 229 |
if (is_texel_buffer && |
| 230 |
!PVR_HAS_FEATURE(dev_info, tpu_extended_integer_lookup)) { |
| 231 |
struct ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1 word1; |
| 232 |
ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1_unpack(&buffer_view_state.words[1], |
| 233 |
&word1); |
| 234 |
|
| 235 |
word1.index_lookup = true; |
| 236 |
ROGUE_TEXSTATE_STRIDE_IMAGE_WORD1_pack(&buffer_view_state.words[1], |
| 237 |
&word1); |
| 238 |
} |
| 239 |
|
| 240 |
memcpy(desc_mapping, &buffer_view_state, sizeof(buffer_view_state)); |
| 241 |
} |
| 242 |
|
| 243 |
void PVR_PER_ARCH(descriptor_set_write_immutable_samplers)( |
| 244 |
struct pvr_descriptor_set_layout *layout, |
| 245 |
struct pvr_descriptor_set *set) |
| 246 |
{ |
| 247 |
for (unsigned u = 0; u < layout->binding_count; ++u) { |
| 248 |
const struct pvr_descriptor_set_layout_binding *binding = |
| 249 |
&layout->bindings[u]; |
| 250 |
|
| 251 |
if (binding->type == VK_DESCRIPTOR_TYPE_SAMPLER && |
| 252 |
binding->immutable_samplers) { |
| 253 |
for (uint32_t j = 0; j < binding->descriptor_count; j++) { |
| 254 |
write_sampler(set, NULL, binding, j); |
| 255 |
} |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
|
| 260 |
void PVR_PER_ARCH(UpdateDescriptorSets)( |
| 261 |
VkDevice _device, |
| 262 |
uint32_t descriptorWriteCount, |
| 263 |
const VkWriteDescriptorSet *pDescriptorWrites, |
| 264 |
uint32_t descriptorCopyCount, |
| 265 |
const VkCopyDescriptorSet *pDescriptorCopies) |
| 266 |
{ |
| 267 |
VK_FROM_HANDLE(pvr_device, device, _device); |
| 268 |
const struct pvr_device_info *dev_info = &device->pdevice->dev_info; |
| 269 |
|
| 270 |
for (uint32_t i = 0; i < descriptorWriteCount; i++) { |
| 271 |
const VkWriteDescriptorSet *write = &pDescriptorWrites[i]; |
| 272 |
VK_FROM_HANDLE(pvr_descriptor_set, set, write->dstSet); |
| 273 |
const struct pvr_descriptor_set_layout *layout = set->layout; |
| 274 |
const struct pvr_descriptor_set_layout_binding *binding; |
| 275 |
|
| 276 |
assert(write->dstBinding < layout->binding_count); |
| 277 |
binding = &layout->bindings[write->dstBinding]; |
| 278 |
|
| 279 |
vk_foreach_struct_const (ext, write->pNext) { |
| 280 |
vk_debug_ignored_stype(ext->sType); |
| 281 |
} |
| 282 |
|
| 283 |
if (!binding->stage_flags) |
| 284 |
continue; |
| 285 |
|
| 286 |
switch (write->descriptorType) { |
| 287 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 288 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 289 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 290 |
write_buffer(set, |
| 291 |
&write->pBufferInfo[j], |
| 292 |
binding, |
| 293 |
write->dstArrayElement + j); |
| 294 |
} |
| 295 |
break; |
| 296 |
|
| 297 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 298 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 299 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 300 |
write_dynamic_buffer(set, |
| 301 |
&write->pBufferInfo[j], |
| 302 |
binding, |
| 303 |
write->dstArrayElement + j); |
| 304 |
} |
| 305 |
break; |
| 306 |
|
| 307 |
case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 308 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 309 |
write_sampler(set, |
| 310 |
&write->pImageInfo[j], |
| 311 |
binding, |
| 312 |
write->dstArrayElement + j); |
| 313 |
} |
| 314 |
break; |
| 315 |
|
| 316 |
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 317 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 318 |
write_image_sampler(set, |
| 319 |
&write->pImageInfo[j], |
| 320 |
binding, |
| 321 |
write->dstArrayElement + j); |
| 322 |
} |
| 323 |
break; |
| 324 |
|
| 325 |
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 326 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 327 |
write_sampled_image(set, |
| 328 |
&write->pImageInfo[j], |
| 329 |
binding, |
| 330 |
write->dstArrayElement + j, |
| 331 |
dev_info); |
| 332 |
} |
| 333 |
break; |
| 334 |
|
| 335 |
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 336 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 337 |
write_storage_image(set, |
| 338 |
&write->pImageInfo[j], |
| 339 |
binding, |
| 340 |
write->dstArrayElement + j, |
| 341 |
dev_info); |
| 342 |
} |
| 343 |
break; |
| 344 |
|
| 345 |
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 346 |
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
| 347 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 348 |
write_buffer_view(set, |
| 349 |
write->pTexelBufferView[j], |
| 350 |
binding, |
| 351 |
write->dstArrayElement + j, |
| 352 |
write->descriptorType == |
| 353 |
VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 354 |
dev_info); |
| 355 |
} |
| 356 |
break; |
| 357 |
|
| 358 |
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: |
| 359 |
for (uint32_t j = 0; j < write->descriptorCount; j++) { |
| 360 |
write_input_attachment(set, |
| 361 |
&write->pImageInfo[j], |
| 362 |
binding, |
| 363 |
write->dstArrayElement + j); |
| 364 |
} |
| 365 |
break; |
| 366 |
|
| 367 |
default: |
| 368 |
UNREACHABLE(""); |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
for (uint32_t i = 0; i < descriptorCopyCount; i++) { |
| 373 |
const VkCopyDescriptorSet *copy = &pDescriptorCopies[i]; |
| 374 |
VK_FROM_HANDLE(pvr_descriptor_set, src_set, copy->srcSet); |
| 375 |
VK_FROM_HANDLE(pvr_descriptor_set, dst_set, copy->dstSet); |
| 376 |
|
| 377 |
const struct pvr_descriptor_set_layout *src_layout = src_set->layout; |
| 378 |
const struct pvr_descriptor_set_layout *dst_layout = dst_set->layout; |
| 379 |
const struct pvr_descriptor_set_layout_binding *src_binding; |
| 380 |
const struct pvr_descriptor_set_layout_binding *dst_binding; |
| 381 |
|
| 382 |
assert(copy->srcBinding < src_layout->binding_count); |
| 383 |
assert(copy->dstBinding < dst_layout->binding_count); |
| 384 |
src_binding = &src_layout->bindings[copy->srcBinding]; |
| 385 |
dst_binding = &dst_layout->bindings[copy->dstBinding]; |
| 386 |
|
| 387 |
vk_foreach_struct_const (ext, copy->pNext) { |
| 388 |
vk_debug_ignored_stype(ext->sType); |
| 389 |
} |
| 390 |
|
| 391 |
assert(src_binding->stage_flags == dst_binding->stage_flags); |
| 392 |
if (!src_binding->stage_flags) |
| 393 |
continue; |
| 394 |
|
| 395 |
assert(src_binding->stride == dst_binding->stride); |
| 396 |
|
| 397 |
if (vk_descriptor_type_is_dynamic(src_binding->type)) { |
| 398 |
const unsigned src_desc_offset = |
| 399 |
src_binding->dynamic_buffer_idx + copy->srcArrayElement; |
| 400 |
const unsigned dst_desc_offset = |
| 401 |
dst_binding->dynamic_buffer_idx + copy->dstArrayElement; |
| 402 |
|
| 403 |
memcpy(&dst_set->dynamic_buffers[dst_desc_offset], |
| 404 |
&src_set->dynamic_buffers[src_desc_offset], |
| 405 |
sizeof(*src_set->dynamic_buffers) * copy->descriptorCount); |
| 406 |
|
| 407 |
continue; |
| 408 |
} |
| 409 |
|
| 410 |
if (src_binding->stride > 0) { |
| 411 |
for (uint32_t j = 0; j < copy->descriptorCount; j++) { |
| 412 |
const unsigned src_desc_offset = |
| 413 |
src_binding->offset + |
| 414 |
((copy->srcArrayElement + j) * src_binding->stride); |
| 415 |
const void *src_desc_mapping = |
| 416 |
(uint8_t *)src_set->mapping + src_desc_offset; |
| 417 |
|
| 418 |
const unsigned dst_desc_offset = |
| 419 |
dst_binding->offset + |
| 420 |
((copy->dstArrayElement + j) * dst_binding->stride); |
| 421 |
void *dst_desc_mapping = |
| 422 |
(uint8_t *)dst_set->mapping + dst_desc_offset; |
| 423 |
|
| 424 |
memcpy(dst_desc_mapping, src_desc_mapping, src_binding->stride); |
| 425 |
} |
| 426 |
} |
| 427 |
} |
| 428 |
} |
| 429 |
|
| 430 |
void PVR_PER_ARCH(UpdateDescriptorSetWithTemplate)( |
| 431 |
VkDevice _device, |
| 432 |
VkDescriptorSet descriptorSet, |
| 433 |
VkDescriptorUpdateTemplate descriptorUpdateTemplate, |
| 434 |
const void *pData) |
| 435 |
{ |
| 436 |
VK_FROM_HANDLE(pvr_device, device, _device); |
| 437 |
VK_FROM_HANDLE(vk_descriptor_update_template, |
| 438 |
template, |
| 439 |
descriptorUpdateTemplate); |
| 440 |
VK_FROM_HANDLE(pvr_descriptor_set, set, descriptorSet); |
| 441 |
|
| 442 |
const struct pvr_device_info *dev_info = &device->pdevice->dev_info; |
| 443 |
|
| 444 |
assert(template->type != |
| 445 |
VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS); |
| 446 |
|
| 447 |
for (uint32_t i = 0; i < template->entry_count; i++) { |
| 448 |
const struct vk_descriptor_template_entry *entry = &template->entries[i]; |
| 449 |
const struct pvr_descriptor_set_layout_binding *layout_binding = |
| 450 |
&set->layout->bindings[entry->binding]; |
| 451 |
uint8_t *data = (uint8_t *)pData + entry->offset; |
| 452 |
|
| 453 |
switch (entry->type) { |
| 454 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 455 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 456 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 457 |
const VkDescriptorBufferInfo *info = |
| 458 |
(const VkDescriptorBufferInfo *)(data + j * entry->stride); |
| 459 |
|
| 460 |
write_buffer(set, info, layout_binding, entry->array_element + j); |
| 461 |
} |
| 462 |
break; |
| 463 |
|
| 464 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 465 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 466 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 467 |
const VkDescriptorBufferInfo *info = |
| 468 |
(const VkDescriptorBufferInfo *)(data + j * entry->stride); |
| 469 |
|
| 470 |
write_dynamic_buffer(set, |
| 471 |
info, |
| 472 |
layout_binding, |
| 473 |
entry->array_element + j); |
| 474 |
} |
| 475 |
break; |
| 476 |
|
| 477 |
case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 478 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 479 |
const VkDescriptorImageInfo *info = |
| 480 |
(const VkDescriptorImageInfo *)(data + j * entry->stride); |
| 481 |
|
| 482 |
write_sampler(set, info, layout_binding, entry->array_element + j); |
| 483 |
} |
| 484 |
break; |
| 485 |
|
| 486 |
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 487 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 488 |
const VkDescriptorImageInfo *info = |
| 489 |
(const VkDescriptorImageInfo *)(data + j * entry->stride); |
| 490 |
|
| 491 |
write_image_sampler(set, |
| 492 |
info, |
| 493 |
layout_binding, |
| 494 |
entry->array_element + j); |
| 495 |
} |
| 496 |
break; |
| 497 |
|
| 498 |
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 499 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 500 |
const VkDescriptorImageInfo *info = |
| 501 |
(const VkDescriptorImageInfo *)(data + j * entry->stride); |
| 502 |
|
| 503 |
write_sampled_image(set, |
| 504 |
info, |
| 505 |
layout_binding, |
| 506 |
entry->array_element + j, |
| 507 |
dev_info); |
| 508 |
} |
| 509 |
break; |
| 510 |
|
| 511 |
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 512 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 513 |
const VkDescriptorImageInfo *info = |
| 514 |
(const VkDescriptorImageInfo *)(data + j * entry->stride); |
| 515 |
|
| 516 |
write_storage_image(set, |
| 517 |
info, |
| 518 |
layout_binding, |
| 519 |
entry->array_element + j, |
| 520 |
dev_info); |
| 521 |
} |
| 522 |
break; |
| 523 |
|
| 524 |
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 525 |
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
| 526 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 527 |
const VkBufferView *bview = |
| 528 |
(const VkBufferView *)(data + j * entry->stride); |
| 529 |
|
| 530 |
write_buffer_view(set, |
| 531 |
*bview, |
| 532 |
layout_binding, |
| 533 |
entry->array_element + j, |
| 534 |
entry->type == |
| 535 |
VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, |
| 536 |
dev_info); |
| 537 |
} |
| 538 |
break; |
| 539 |
|
| 540 |
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: |
| 541 |
for (uint32_t j = 0; j < entry->array_count; j++) { |
| 542 |
const VkDescriptorImageInfo *info = |
| 543 |
(const VkDescriptorImageInfo *)(data + j * entry->stride); |
| 544 |
|
| 545 |
write_input_attachment(set, |
| 546 |
info, |
| 547 |
layout_binding, |
| 548 |
entry->array_element + j); |
| 549 |
} |
| 550 |
break; |
| 551 |
|
| 552 |
default: |
| 553 |
UNREACHABLE("Unknown descriptor type"); |
| 554 |
} |
| 555 |
} |
| 556 |
} |