| 1786 | } |
| 1787 | |
| 1788 | static int vulkan_device_create_internal(AVHWDeviceContext *ctx, |
| 1789 | VulkanDeviceSelection *dev_select, |
| 1790 | int disable_multiplane, |
| 1791 | AVDictionary *opts, int flags) |
| 1792 | { |
| 1793 | int err = 0; |
| 1794 | VkResult ret; |
| 1795 | AVDictionaryEntry *opt_d; |
| 1796 | VulkanDevicePriv *p = ctx->hwctx; |
| 1797 | AVVulkanDeviceContext *hwctx = &p->p; |
| 1798 | FFVulkanFunctions *vk = &p->vkctx.vkfn; |
| 1799 | enum FFVulkanDebugMode debug_mode = FF_VULKAN_DEBUG_NONE; |
| 1800 | VulkanDeviceFeatures supported_feats = { 0 }; |
| 1801 | VkDeviceCreateInfo dev_info = { |
| 1802 | .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, |
| 1803 | }; |
| 1804 | |
| 1805 | /* Create an instance if not given one */ |
| 1806 | if ((err = create_instance(ctx, opts, &debug_mode))) |
| 1807 | goto end; |
| 1808 | |
| 1809 | /* Find a physical device (if not given one) */ |
| 1810 | if ((err = find_device(ctx, dev_select))) |
| 1811 | goto end; |
| 1812 | |
| 1813 | /* Get supported memory types */ |
| 1814 | vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &p->mprops); |
| 1815 | |
| 1816 | /* Find and enable extensions for the physical device */ |
| 1817 | if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames, |
| 1818 | &dev_info.enabledExtensionCount, debug_mode))) { |
| 1819 | for (int i = 0; i < dev_info.queueCreateInfoCount; i++) |
| 1820 | av_free((void *)dev_info.pQueueCreateInfos[i].pQueuePriorities); |
| 1821 | av_free((void *)dev_info.pQueueCreateInfos); |
| 1822 | goto end; |
| 1823 | } |
| 1824 | |
| 1825 | /* Get all supported features for the physical device */ |
| 1826 | device_features_init(ctx, &supported_feats); |
| 1827 | vk->GetPhysicalDeviceFeatures2(hwctx->phys_dev, &supported_feats.device); |
| 1828 | |
| 1829 | /* Copy all needed features from those supported and activate them */ |
| 1830 | device_features_init(ctx, &p->feats); |
| 1831 | device_features_copy_needed(&p->feats, &supported_feats); |
| 1832 | dev_info.pNext = p->feats.device.pNext; |
| 1833 | dev_info.pEnabledFeatures = &p->feats.device.features; |
| 1834 | |
| 1835 | /* Limit queues to a given number if needed */ |
| 1836 | opt_d = av_dict_get(opts, "limit_queues", NULL, 0); |
| 1837 | if (opt_d) |
| 1838 | p->limit_queues = strtol(opt_d->value, NULL, 10); |
| 1839 | |
| 1840 | /* Setup enabled queue families */ |
| 1841 | if ((err = setup_queue_families(ctx, &dev_info))) |
| 1842 | goto end; |
| 1843 | |
| 1844 | /* Finally create the device */ |
| 1845 | ret = vk->CreateDevice(hwctx->phys_dev, &dev_info, hwctx->alloc, |
no test coverage detected