History

hwcontext_vulkan: do not chain structs of unsupported extensions in vkCreateDevice

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.

Lynne committed 2 years ago

Commit ef11a641 parent 12080ff2 files · +30 −11Browse files

Unified · Split

2 files
  1. libavutil/hwcontext_vulkan.c +21 −11
  2. libavutil/vulkan.h +9 −0
libavutil/hwcontext_vulkan.c+21−11
@@ -1369,17 +1369,27 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 1368 unmodified lines
1369 p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;1369 p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
1370 p->device_features_1_2.pNext = &p->device_features_1_3;1370 p->device_features_1_2.pNext = &p->device_features_1_3;
1371 p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;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;1372 p->device_features_1_3.pNext = NULL;
1373 p->desc_buf_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT;1373
1374 p->desc_buf_features.pNext = &p->atomic_float_features;1374#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \
1375 p->atomic_float_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT;1375 do { \
1376 p->atomic_float_features.pNext = &p->coop_matrix_features;1376 if (p->vkctx.extensions & EXT_FLAG) { \
1377 p->coop_matrix_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;1377 (STRUCT_P)->sType = TYPE; \
1378 p->coop_matrix_features.pNext = &p->optical_flow_features;1378 ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \
1379 p->optical_flow_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV;1379 } \
1380 p->optical_flow_features.pNext = &p->shader_object_features;1380 } while (0)
1381 p->shader_object_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT;1381
1382 p->shader_object_features.pNext = NULL;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 ctx->free = vulkan_device_free;1394 ctx->free = vulkan_device_free;
1385 1395
libavutil/vulkan.h+9−0
@@ -291,6 +291,15 @@ static inline const void *ff_vk_find_struct(const void *chain, VkStructureType s · 290 unmodified lines
291 return NULL;291 return NULL;
292}292}
293 293
294static 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/* Identity mapping - r = r, b = b, g = g, a = a */303/* Identity mapping - r = r, b = b, g = g, a = a */
295extern const VkComponentMapping ff_comp_identity_map;304extern const VkComponentMapping ff_comp_identity_map;
296 305

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t