Fixes: vkCreateDevice(): pCreateInfo->pNext<VkPhysicalDeviceOpticalFlowFeaturesNV> includes a pointer to a VkPhysicalDeviceOpticalFlowFeaturesNV, but when creating VkDevice, the parent extension (VK_NV_optical_flow) was not included in ppEnabledExtensionNames. The Vulkan spec states: Each pNext member of any structure (including this one) in the pNext chain must be either NULL or a pointer to a valid struct for extending VkDeviceCreateInfo.
Unified · Split
| @@ -1369,17 +1369,27 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 1368 unmodified lines | ||
| 1369 | 1369 | p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; |
| 1370 | 1370 | p->device_features_1_2.pNext = &p->device_features_1_3; |
| 1371 | 1371 | p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; |
| 1372 | − p->device_features_1_3.pNext = &p->desc_buf_features; | |
| 1373 | − p->desc_buf_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT; | |
| 1374 | − p->desc_buf_features.pNext = &p->atomic_float_features; | |
| 1375 | − p->atomic_float_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT; | |
| 1376 | − p->atomic_float_features.pNext = &p->coop_matrix_features; | |
| 1377 | − p->coop_matrix_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR; | |
| 1378 | − p->coop_matrix_features.pNext = &p->optical_flow_features; | |
| 1379 | − p->optical_flow_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV; | |
| 1380 | − p->optical_flow_features.pNext = &p->shader_object_features; | |
| 1381 | − p->shader_object_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT; | |
| 1382 | − p->shader_object_features.pNext = NULL; | |
| 1372 | + p->device_features_1_3.pNext = NULL; | |
| 1373 | + | |
| 1374 | +#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \ | |
| 1375 | + do { \ | |
| 1376 | + if (p->vkctx.extensions & EXT_FLAG) { \ | |
| 1377 | + (STRUCT_P)->sType = TYPE; \ | |
| 1378 | + ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \ | |
| 1379 | + } \ | |
| 1380 | + } while (0) | |
| 1381 | + | |
| 1382 | + OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features, | |
| 1383 | + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT); | |
| 1384 | + OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features, | |
| 1385 | + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT); | |
| 1386 | + OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features, | |
| 1387 | + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR); | |
| 1388 | + OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features, | |
| 1389 | + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT); | |
| 1390 | + OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features, | |
| 1391 | + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV); | |
| 1392 | +#undef OPT_CHAIN | |
| 1383 | 1393 | |
| 1384 | 1394 | ctx->free = vulkan_device_free; |
| 1385 | 1395 | |
| @@ -291,6 +291,15 @@ static inline const void *ff_vk_find_struct(const void *chain, VkStructureType s · 290 unmodified lines | ||
| 291 | 291 | return NULL; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | +static inline void ff_vk_link_struct(void *chain, const void *in) | |
| 295 | +{ | |
| 296 | + VkBaseOutStructure *out = chain; | |
| 297 | + while (out->pNext) | |
| 298 | + out = out->pNext; | |
| 299 | + | |
| 300 | + out->pNext = (void *)in; | |
| 301 | +} | |
| 302 | + | |
| 294 | 303 | /* Identity mapping - r = r, b = b, g = g, a = a */ |
| 295 | 304 | extern const VkComponentMapping ff_comp_identity_map; |
| 296 | 305 | |