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
1442 .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,1442 .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
1443 };1443 };
1444 1444
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
1474 ctx->free = vulkan_device_free;1445 ctx->free = vulkan_device_free;
1475 1446
1476 /* Create an instance if not given one */1447 /* Create an instance if not given one */
@@ -1539,12 +1510,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 62 unmodified lines
1539 1510
1540 p->shader_object_features.shaderObject = shader_object_features.shaderObject;1511 p->shader_object_features.shaderObject = shader_object_features.shaderObject;
1541 1512
1542 dev_info.pNext = &hwctx->device_features;1513 /* Find and enable extensions */
1543
1544 /* Setup queue family */
1545 if ((err = setup_queue_families(ctx, &dev_info)))
1546 goto end;
1547
1548 if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames,1514 if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames,
1549 &dev_info.enabledExtensionCount, 0))) {1515 &dev_info.enabledExtensionCount, 0))) {
1550 for (int i = 0; i < dev_info.queueCreateInfoCount; i++)1516 for (int i = 0; i < dev_info.queueCreateInfoCount; i++)
@@ -1553,6 +1519,43 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, · 2 unmodified lines
1553 goto end;1519 goto end;
1554 }1520 }
1555 1521
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
1556 ret = vk->CreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc,1559 ret = vk->CreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc,
1557 &hwctx->act_dev);1560 &hwctx->act_dev);
1558 1561

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