History

hwcontext_vulkan: setup extensions before features

The issue is that enabling features requires that the device extension is supported. The extensions bitfield was set later, so it was always 0, leading to no features being added.

Lynne committed 2 years ago

Commit 97e947a1 parent c3cbaf31 file · +38 −35Browse files

Unified · Split

libavutil/hwcontext_vulkan.c+38−35
@@ -1442,35 +1442,6 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 1441 unmodified lines
14421442 .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
14431443 };
14441444
1445− hwctx->device_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
1446− hwctx->device_features.pNext = &p->device_features_1_1;
1447− p->device_features_1_1.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
1448− p->device_features_1_1.pNext = &p->device_features_1_2;
1449− p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
1450− p->device_features_1_2.pNext = &p->device_features_1_3;
1451− p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
1452− p->device_features_1_3.pNext = NULL;
1453−
1454−#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \
1455− do { \
1456− if (p->vkctx.extensions & EXT_FLAG) { \
1457− (STRUCT_P)->sType = TYPE; \
1458− ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \
1459− } \
1460− } while (0)
1461−
1462− OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features,
1463− VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT);
1464− OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features,
1465− VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT);
1466− OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features,
1467− VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR);
1468− OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features,
1469− VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT);
1470− OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features,
1471− VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV);
1472−#undef OPT_CHAIN
1473−
14741445 ctx->free = vulkan_device_free;
14751446
14761447 /* Create an instance if not given one */
@@ -1539,12 +1510,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 62 unmodified lines
15391510
15401511 p->shader_object_features.shaderObject = shader_object_features.shaderObject;
15411512
1542− dev_info.pNext = &hwctx->device_features;
1543−
1544− /* Setup queue family */
1545− if ((err = setup_queue_families(ctx, &dev_info)))
1546− goto end;
1547−
1513+ /* Find and enable extensions */
15481514 if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames,
15491515 &dev_info.enabledExtensionCount, 0))) {
15501516 for (int i = 0; i < dev_info.queueCreateInfoCount; i++)
@@ -1553,6 +1519,43 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 2 unmodified lines
15531519 goto end;
15541520 }
15551521
1522+ /* Setup enabled device features */
1523+ hwctx->device_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
1524+ hwctx->device_features.pNext = &p->device_features_1_1;
1525+ p->device_features_1_1.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
1526+ p->device_features_1_1.pNext = &p->device_features_1_2;
1527+ p->device_features_1_2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
1528+ p->device_features_1_2.pNext = &p->device_features_1_3;
1529+ p->device_features_1_3.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
1530+ p->device_features_1_3.pNext = NULL;
1531+
1532+#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE) \
1533+ do { \
1534+ if (p->vkctx.extensions & EXT_FLAG) { \
1535+ (STRUCT_P)->sType = TYPE; \
1536+ ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \
1537+ } \
1538+ } while (0)
1539+
1540+ OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features,
1541+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT);
1542+ OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features,
1543+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT);
1544+ OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features,
1545+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR);
1546+ OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features,
1547+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT);
1548+ OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features,
1549+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV);
1550+#undef OPT_CHAIN
1551+
1552+ /* Add the enabled features into the pnext chain of device creation */
1553+ dev_info.pNext = &hwctx->device_features;
1554+
1555+ /* Setup enabled queue families */
1556+ if ((err = setup_queue_families(ctx, &dev_info)))
1557+ goto end;
1558+
15561559 ret = vk->CreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc,
15571560 &hwctx->act_dev);
15581561

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