MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vulkan_device_create_internal

Function vulkan_device_create_internal

libavutil/hwcontext_vulkan.c:1788–1893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1786}
1787
1788static 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,

Callers 2

vulkan_device_createFunction · 0.85
vulkan_device_deriveFunction · 0.85

Calls 10

create_instanceFunction · 0.85
find_deviceFunction · 0.85
check_extensionsFunction · 0.85
device_features_initFunction · 0.85
av_dict_getFunction · 0.85
setup_queue_familiesFunction · 0.85
av_logFunction · 0.85
ff_vk_ret2strFunction · 0.85
av_freeFunction · 0.70

Tested by

no test coverage detected