| 1 |
|
| 2 |
. |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "kk_descriptor_set_layout.h" |
| 9 |
|
| 10 |
#include "kk_descriptor_types.h" |
| 11 |
#include "kk_device.h" |
| 12 |
#include "kk_entrypoints.h" |
| 13 |
#include "kk_physical_device.h" |
| 14 |
#include "kk_sampler.h" |
| 15 |
|
| 16 |
#include "vk_pipeline_layout.h" |
| 17 |
|
| 18 |
static bool |
| 19 |
binding_has_immutable_samplers(const VkDescriptorSetLayoutBinding *binding) |
| 20 |
{ |
| 21 |
switch (binding->descriptorType) { |
| 22 |
case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 23 |
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 24 |
return binding->pImmutableSamplers != NULL; |
| 25 |
|
| 26 |
default: |
| 27 |
return false; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void |
| 32 |
kk_descriptor_stride_align_for_type( |
| 33 |
VkDescriptorType type, const VkMutableDescriptorTypeListEXT *type_list, |
| 34 |
uint32_t *stride, uint32_t *alignment) |
| 35 |
{ |
| 36 |
switch (type) { |
| 37 |
case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 38 |
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 39 |
|
| 40 |
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 41 |
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: |
| 42 |
*stride = *alignment = sizeof(struct kk_sampled_image_descriptor); |
| 43 |
break; |
| 44 |
|
| 45 |
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 46 |
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
| 47 |
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 48 |
*stride = *alignment = sizeof(struct kk_storage_image_descriptor); |
| 49 |
break; |
| 50 |
|
| 51 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 52 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 53 |
*stride = *alignment = sizeof(struct kk_buffer_address); |
| 54 |
break; |
| 55 |
|
| 56 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 57 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 58 |
*stride = *alignment = 0; |
| 59 |
break; |
| 60 |
|
| 61 |
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK: |
| 62 |
*stride = 1; |
| 63 |
*alignment = kk_min_cbuf_alignment(); |
| 64 |
break; |
| 65 |
|
| 66 |
case VK_DESCRIPTOR_TYPE_MUTABLE_EXT: |
| 67 |
*stride = *alignment = 0; |
| 68 |
if (type_list == NULL || type_list->descriptorTypeCount == 0u) |
| 69 |
*stride = *alignment = KK_MAX_DESCRIPTOR_SIZE; |
| 70 |
for (unsigned i = 0; type_list && i < type_list->descriptorTypeCount; |
| 71 |
i++) { |
| 72 |
|
| 73 |
assert(type_list->pDescriptorTypes[i] != |
| 74 |
VK_DESCRIPTOR_TYPE_MUTABLE_EXT); |
| 75 |
uint32_t desc_stride, desc_align; |
| 76 |
kk_descriptor_stride_align_for_type(type_list->pDescriptorTypes[i], |
| 77 |
NULL, &desc_stride, &desc_align); |
| 78 |
*stride = MAX2(*stride, desc_stride); |
| 79 |
*alignment = MAX2(*alignment, desc_align); |
| 80 |
} |
| 81 |
*stride = align(*stride, *alignment); |
| 82 |
break; |
| 83 |
|
| 84 |
default: |
| 85 |
UNREACHABLE("Invalid descriptor type"); |
| 86 |
} |
| 87 |
|
| 88 |
assert(*stride <= KK_MAX_DESCRIPTOR_SIZE); |
| 89 |
} |
| 90 |
|
| 91 |
static const VkMutableDescriptorTypeListEXT * |
| 92 |
kk_descriptor_get_type_list(VkDescriptorType type, |
| 93 |
const VkMutableDescriptorTypeCreateInfoEXT *info, |
| 94 |
const uint32_t info_idx) |
| 95 |
{ |
| 96 |
const VkMutableDescriptorTypeListEXT *type_list = NULL; |
| 97 |
if (type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) { |
| 98 |
assert(info != NULL); |
| 99 |
assert(info_idx < info->mutableDescriptorTypeListCount); |
| 100 |
type_list = &info->pMutableDescriptorTypeLists[info_idx]; |
| 101 |
} |
| 102 |
return type_list; |
| 103 |
} |
| 104 |
|
| 105 |
static void |
| 106 |
kk_descriptor_set_layout_destroy(struct vk_device *vk_dev, |
| 107 |
struct vk_descriptor_set_layout *vk_layout) |
| 108 |
{ |
| 109 |
struct kk_device *dev = container_of(vk_dev, struct kk_device, vk); |
| 110 |
struct kk_descriptor_set_layout *layout = |
| 111 |
vk_to_kk_descriptor_set_layout(vk_layout); |
| 112 |
|
| 113 |
vk_object_free(&dev->vk, NULL, layout); |
| 114 |
} |
| 115 |
|
| 116 |
VKAPI_ATTR VkResult VKAPI_CALL |
| 117 |
kk_CreateDescriptorSetLayout(VkDevice device, |
| 118 |
const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 119 |
const VkAllocationCallbacks *pAllocator, |
| 120 |
VkDescriptorSetLayout *pSetLayout) |
| 121 |
{ |
| 122 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 123 |
|
| 124 |
uint32_t num_bindings = 0; |
| 125 |
uint32_t immutable_sampler_count = 0; |
| 126 |
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) { |
| 127 |
const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[j]; |
| 128 |
num_bindings = MAX2(num_bindings, binding->binding + 1); |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
if (binding_has_immutable_samplers(binding)) |
| 142 |
immutable_sampler_count += binding->descriptorCount; |
| 143 |
} |
| 144 |
|
| 145 |
VK_MULTIALLOC(ma); |
| 146 |
VK_MULTIALLOC_DECL(&ma, struct kk_descriptor_set_layout, layout, 1); |
| 147 |
VK_MULTIALLOC_DECL(&ma, struct kk_descriptor_set_binding_layout, bindings, |
| 148 |
num_bindings); |
| 149 |
VK_MULTIALLOC_DECL(&ma, struct kk_sampler *, samplers, |
| 150 |
immutable_sampler_count); |
| 151 |
|
| 152 |
if (!vk_descriptor_set_layout_multizalloc(&dev->vk, &ma, pCreateInfo)) |
| 153 |
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); |
| 154 |
|
| 155 |
layout->vk.destroy = kk_descriptor_set_layout_destroy; |
| 156 |
layout->flags = pCreateInfo->flags; |
| 157 |
layout->binding_count = num_bindings; |
| 158 |
|
| 159 |
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) { |
| 160 |
const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[j]; |
| 161 |
uint32_t b = binding->binding; |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
layout->binding[b].immutable_samplers = (void *)(uintptr_t)(j + 1); |
| 167 |
} |
| 168 |
|
| 169 |
const VkDescriptorSetLayoutBindingFlagsCreateInfo *binding_flags_info = |
| 170 |
vk_find_struct_const(pCreateInfo->pNext, |
| 171 |
DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO); |
| 172 |
const VkMutableDescriptorTypeCreateInfoEXT *mutable_info = |
| 173 |
vk_find_struct_const(pCreateInfo->pNext, |
| 174 |
MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT); |
| 175 |
|
| 176 |
uint32_t buffer_size = 0; |
| 177 |
uint32_t max_variable_descriptor_size = 0; |
| 178 |
uint8_t dynamic_buffer_count = 0; |
| 179 |
for (uint32_t b = 0; b < num_bindings; b++) { |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
if (layout->binding[b].immutable_samplers == NULL) |
| 185 |
continue; |
| 186 |
const uint32_t info_idx = |
| 187 |
(uintptr_t)(void *)layout->binding[b].immutable_samplers - 1; |
| 188 |
layout->binding[b].immutable_samplers = NULL; |
| 189 |
|
| 190 |
const VkDescriptorSetLayoutBinding *binding = |
| 191 |
&pCreateInfo->pBindings[info_idx]; |
| 192 |
|
| 193 |
if (binding->descriptorCount == 0) |
| 194 |
continue; |
| 195 |
|
| 196 |
layout->binding[b].type = binding->descriptorType; |
| 197 |
layout->descriptor_count += binding->descriptorCount; |
| 198 |
|
| 199 |
if (binding_flags_info && binding_flags_info->bindingCount > 0) { |
| 200 |
assert(binding_flags_info->bindingCount == pCreateInfo->bindingCount); |
| 201 |
layout->binding[b].flags = binding_flags_info->pBindingFlags[info_idx]; |
| 202 |
} |
| 203 |
|
| 204 |
layout->binding[b].array_size = binding->descriptorCount; |
| 205 |
|
| 206 |
switch (binding->descriptorType) { |
| 207 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 208 |
layout->binding[b].dynamic_buffer_index = dynamic_buffer_count; |
| 209 |
BITSET_SET_COUNT(layout->dynamic_ubos, dynamic_buffer_count, |
| 210 |
binding->descriptorCount); |
| 211 |
dynamic_buffer_count += binding->descriptorCount; |
| 212 |
break; |
| 213 |
|
| 214 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 215 |
layout->binding[b].dynamic_buffer_index = dynamic_buffer_count; |
| 216 |
dynamic_buffer_count += binding->descriptorCount; |
| 217 |
break; |
| 218 |
|
| 219 |
default: |
| 220 |
break; |
| 221 |
} |
| 222 |
|
| 223 |
const VkMutableDescriptorTypeListEXT *type_list = |
| 224 |
kk_descriptor_get_type_list(binding->descriptorType, mutable_info, |
| 225 |
info_idx); |
| 226 |
|
| 227 |
uint32_t stride, alignment; |
| 228 |
kk_descriptor_stride_align_for_type(binding->descriptorType, type_list, |
| 229 |
&stride, &alignment); |
| 230 |
|
| 231 |
uint8_t max_plane_count = 1; |
| 232 |
|
| 233 |
if (binding_has_immutable_samplers(binding)) { |
| 234 |
layout->binding[b].immutable_samplers = samplers; |
| 235 |
samplers += binding->descriptorCount; |
| 236 |
for (uint32_t i = 0; i < binding->descriptorCount; i++) { |
| 237 |
VK_FROM_HANDLE(kk_sampler, sampler, binding->pImmutableSamplers[i]); |
| 238 |
layout->binding[b].immutable_samplers[i] = sampler; |
| 239 |
const uint8_t sampler_plane_count = |
| 240 |
sampler->vk.ycbcr_conversion |
| 241 |
? vk_format_get_plane_count( |
| 242 |
sampler->vk.ycbcr_conversion->state.format) |
| 243 |
: 1; |
| 244 |
if (max_plane_count < sampler_plane_count) |
| 245 |
max_plane_count = sampler_plane_count; |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
stride *= max_plane_count; |
| 250 |
|
| 251 |
if (stride > 0) { |
| 252 |
assert(stride <= UINT8_MAX); |
| 253 |
assert(util_is_power_of_two_nonzero(alignment)); |
| 254 |
|
| 255 |
buffer_size = align64(buffer_size, alignment); |
| 256 |
layout->binding[b].offset = buffer_size; |
| 257 |
layout->binding[b].stride = stride; |
| 258 |
|
| 259 |
if (layout->binding[b].flags & |
| 260 |
VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT) { |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
assert(b == num_bindings - 1); |
| 273 |
assert(max_variable_descriptor_size == 0); |
| 274 |
max_variable_descriptor_size = stride * binding->descriptorCount; |
| 275 |
} else { |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
buffer_size += stride * binding->descriptorCount; |
| 281 |
} |
| 282 |
} |
| 283 |
} |
| 284 |
|
| 285 |
layout->non_variable_descriptor_buffer_size = buffer_size; |
| 286 |
layout->max_buffer_size = buffer_size + max_variable_descriptor_size; |
| 287 |
layout->vk.dynamic_descriptor_count = dynamic_buffer_count; |
| 288 |
|
| 289 |
struct mesa_blake3 blake3_ctx; |
| 290 |
_mesa_blake3_init(&blake3_ctx); |
| 291 |
|
| 292 |
#define BLAKE3_UPDATE_VALUE(x) \ |
| 293 |
_mesa_blake3_update(&blake3_ctx, &(x), sizeof(x)); |
| 294 |
BLAKE3_UPDATE_VALUE(layout->non_variable_descriptor_buffer_size); |
| 295 |
BLAKE3_UPDATE_VALUE(layout->vk.dynamic_descriptor_count); |
| 296 |
BLAKE3_UPDATE_VALUE(layout->binding_count); |
| 297 |
|
| 298 |
for (uint32_t b = 0; b < num_bindings; b++) { |
| 299 |
BLAKE3_UPDATE_VALUE(layout->binding[b].type); |
| 300 |
BLAKE3_UPDATE_VALUE(layout->binding[b].flags); |
| 301 |
BLAKE3_UPDATE_VALUE(layout->binding[b].array_size); |
| 302 |
BLAKE3_UPDATE_VALUE(layout->binding[b].offset); |
| 303 |
BLAKE3_UPDATE_VALUE(layout->binding[b].stride); |
| 304 |
BLAKE3_UPDATE_VALUE(layout->binding[b].dynamic_buffer_index); |
| 305 |
|
| 306 |
if (layout->binding[b].immutable_samplers != NULL) { |
| 307 |
for (uint32_t i = 0; i < layout->binding[b].array_size; i++) { |
| 308 |
const struct kk_sampler *sampler = |
| 309 |
layout->binding[b].immutable_samplers[i]; |
| 310 |
|
| 311 |
|
| 312 |
if (sampler != NULL && sampler->vk.ycbcr_conversion != NULL) |
| 313 |
BLAKE3_UPDATE_VALUE(sampler->vk.ycbcr_conversion->state); |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
#undef BLAKE3_UPDATE_VALUE |
| 318 |
|
| 319 |
_mesa_blake3_final(&blake3_ctx, layout->vk.blake3); |
| 320 |
|
| 321 |
if (pCreateInfo->flags & |
| 322 |
VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT) { |
| 323 |
void *sampler_desc_data = |
| 324 |
vk_alloc2(&dev->vk.alloc, pAllocator, buffer_size, 4, |
| 325 |
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); |
| 326 |
if (sampler_desc_data == NULL) { |
| 327 |
kk_descriptor_set_layout_destroy(&dev->vk, &layout->vk); |
| 328 |
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); |
| 329 |
} |
| 330 |
|
| 331 |
for (uint32_t b = 0; b < num_bindings; b++) { |
| 332 |
assert(layout->binding[b].type == VK_DESCRIPTOR_TYPE_SAMPLER); |
| 333 |
assert(layout->binding[b].array_size == 1); |
| 334 |
assert(layout->binding[b].immutable_samplers != NULL); |
| 335 |
assert(!(layout->binding[b].flags & |
| 336 |
VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT)); |
| 337 |
|
| 338 |
|
| 339 |
if (layout->binding[b].immutable_samplers == NULL) |
| 340 |
continue; |
| 341 |
|
| 342 |
struct kk_sampler *sampler = layout->binding[b].immutable_samplers[0]; |
| 343 |
|
| 344 |
|
| 345 |
assert(sampler->plane_count == 1); |
| 346 |
|
| 347 |
assert(sampler->planes[0].hw->handle); |
| 348 |
} |
| 349 |
|
| 350 |
vk_free2(&dev->vk.alloc, pAllocator, sampler_desc_data); |
| 351 |
} |
| 352 |
|
| 353 |
*pSetLayout = kk_descriptor_set_layout_to_handle(layout); |
| 354 |
|
| 355 |
return VK_SUCCESS; |
| 356 |
} |
| 357 |
|
| 358 |
VKAPI_ATTR void VKAPI_CALL |
| 359 |
kk_GetDescriptorSetLayoutSupport( |
| 360 |
VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 361 |
VkDescriptorSetLayoutSupport *pSupport) |
| 362 |
{ |
| 363 |
const VkMutableDescriptorTypeCreateInfoEXT *mutable_info = |
| 364 |
vk_find_struct_const(pCreateInfo->pNext, |
| 365 |
MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT); |
| 366 |
const VkDescriptorSetLayoutBindingFlagsCreateInfo *binding_flags = |
| 367 |
vk_find_struct_const(pCreateInfo->pNext, |
| 368 |
DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO); |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
uint32_t max_align = 0; |
| 375 |
for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) { |
| 376 |
const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[i]; |
| 377 |
const VkMutableDescriptorTypeListEXT *type_list = |
| 378 |
kk_descriptor_get_type_list(binding->descriptorType, mutable_info, i); |
| 379 |
|
| 380 |
uint32_t stride, alignment; |
| 381 |
kk_descriptor_stride_align_for_type(binding->descriptorType, type_list, |
| 382 |
&stride, &alignment); |
| 383 |
max_align = MAX2(max_align, alignment); |
| 384 |
} |
| 385 |
|
| 386 |
uint64_t non_variable_size = 0; |
| 387 |
uint32_t variable_stride = 0; |
| 388 |
uint32_t variable_count = 0; |
| 389 |
uint8_t dynamic_buffer_count = 0; |
| 390 |
bool variable_is_inline_uniform_block = false; |
| 391 |
|
| 392 |
for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) { |
| 393 |
const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[i]; |
| 394 |
|
| 395 |
VkDescriptorBindingFlags flags = 0; |
| 396 |
if (binding_flags != NULL && binding_flags->bindingCount > 0) |
| 397 |
flags = binding_flags->pBindingFlags[i]; |
| 398 |
|
| 399 |
switch (binding->descriptorType) { |
| 400 |
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 401 |
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 402 |
dynamic_buffer_count += binding->descriptorCount; |
| 403 |
break; |
| 404 |
default: |
| 405 |
break; |
| 406 |
} |
| 407 |
|
| 408 |
const VkMutableDescriptorTypeListEXT *type_list = |
| 409 |
kk_descriptor_get_type_list(binding->descriptorType, mutable_info, i); |
| 410 |
|
| 411 |
uint32_t stride, alignment; |
| 412 |
kk_descriptor_stride_align_for_type(binding->descriptorType, type_list, |
| 413 |
&stride, &alignment); |
| 414 |
|
| 415 |
if (stride > 0) { |
| 416 |
assert(stride <= UINT8_MAX); |
| 417 |
assert(util_is_power_of_two_nonzero(alignment)); |
| 418 |
|
| 419 |
if (flags & VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT) { |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
variable_count = MAX2(1, binding->descriptorCount); |
| 427 |
variable_stride = stride; |
| 428 |
|
| 429 |
variable_is_inline_uniform_block = |
| 430 |
binding->descriptorType == |
| 431 |
VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK; |
| 432 |
|
| 433 |
} else { |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
non_variable_size += stride * binding->descriptorCount; |
| 439 |
non_variable_size = align64(non_variable_size, max_align); |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
uint64_t buffer_size = non_variable_size; |
| 445 |
if (variable_stride > 0) { |
| 446 |
buffer_size += variable_stride * variable_count; |
| 447 |
buffer_size = align64(buffer_size, max_align); |
| 448 |
} |
| 449 |
|
| 450 |
uint32_t max_buffer_size; |
| 451 |
if (pCreateInfo->flags & |
| 452 |
VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) |
| 453 |
max_buffer_size = KK_PUSH_DESCRIPTOR_SET_SIZE; |
| 454 |
else |
| 455 |
max_buffer_size = KK_MAX_DESCRIPTOR_SET_SIZE; |
| 456 |
|
| 457 |
pSupport->supported = dynamic_buffer_count <= KK_MAX_DYNAMIC_BUFFERS && |
| 458 |
buffer_size <= max_buffer_size; |
| 459 |
|
| 460 |
vk_foreach_struct(ext, pSupport->pNext) { |
| 461 |
switch (ext->sType) { |
| 462 |
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT: { |
| 463 |
VkDescriptorSetVariableDescriptorCountLayoutSupport *vs = (void *)ext; |
| 464 |
uint32_t max_var_count; |
| 465 |
|
| 466 |
if (variable_stride > 0) { |
| 467 |
max_var_count = |
| 468 |
(max_buffer_size - non_variable_size) / variable_stride; |
| 469 |
} else { |
| 470 |
max_var_count = 0; |
| 471 |
} |
| 472 |
|
| 473 |
if (variable_is_inline_uniform_block) { |
| 474 |
max_var_count = |
| 475 |
MIN2(max_var_count, KK_MAX_INLINE_UNIFORM_BLOCK_SIZE); |
| 476 |
} |
| 477 |
|
| 478 |
vs->maxVariableDescriptorCount = max_var_count; |
| 479 |
break; |
| 480 |
} |
| 481 |
|
| 482 |
default: |
| 483 |
vk_debug_ignored_stype(ext->sType); |
| 484 |
break; |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
|
| 489 |
VKAPI_ATTR void VKAPI_CALL |
| 490 |
kk_GetDescriptorSetLayoutSizeEXT(VkDevice device, VkDescriptorSetLayout _layout, |
| 491 |
VkDeviceSize *pLayoutSizeInBytes) |
| 492 |
{ |
| 493 |
VK_FROM_HANDLE(kk_descriptor_set_layout, layout, _layout); |
| 494 |
|
| 495 |
*pLayoutSizeInBytes = layout->max_buffer_size; |
| 496 |
} |
| 497 |
|
| 498 |
VKAPI_ATTR void VKAPI_CALL |
| 499 |
kk_GetDescriptorSetLayoutBindingOffsetEXT(VkDevice device, |
| 500 |
VkDescriptorSetLayout _layout, |
| 501 |
uint32_t binding, |
| 502 |
VkDeviceSize *pOffset) |
| 503 |
{ |
| 504 |
VK_FROM_HANDLE(kk_descriptor_set_layout, layout, _layout); |
| 505 |
|
| 506 |
*pOffset = layout->binding[binding].offset; |
| 507 |
} |