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

Function vulkan_device_init

libavutil/hwcontext_vulkan.c:1907–2148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1905}
1906
1907static int vulkan_device_init(AVHWDeviceContext *ctx)
1908{
1909 int err = 0;
1910 uint32_t qf_num;
1911 VulkanDevicePriv *p = ctx->hwctx;
1912 AVVulkanDeviceContext *hwctx = &p->p;
1913 FFVulkanFunctions *vk = &p->vkctx.vkfn;
1914 VkQueueFamilyProperties2 *qf;
1915 VkQueueFamilyVideoPropertiesKHR *qf_vid;
1916 VkPhysicalDeviceExternalSemaphoreInfo ext_sem_props_info;
1917 int graph_index, comp_index, tx_index, enc_index, dec_index;
1918
1919 /* Set device extension flags */
1920 for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++) {
1921 for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) {
1922 if (!strcmp(hwctx->enabled_dev_extensions[i],
1923 optional_device_exts[j].name)) {
1924 p->vkctx.extensions |= optional_device_exts[j].flag;
1925 break;
1926 }
1927 }
1928 }
1929
1930 err = ff_vk_load_functions(ctx, vk, p->vkctx.extensions, 1, 1);
1931 if (err < 0) {
1932 av_log(ctx, AV_LOG_ERROR, "Unable to load functions!\n");
1933 return err;
1934 }
1935
1936 p->props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
1937 p->props.pNext = &p->hprops;
1938 p->hprops.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT;
1939 p->hprops.pNext = &p->dprops;
1940 p->dprops.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
1941
1942 vk->GetPhysicalDeviceProperties2(hwctx->phys_dev, &p->props);
1943 av_log(ctx, AV_LOG_VERBOSE, "Using device: %s\n",
1944 p->props.properties.deviceName);
1945 av_log(ctx, AV_LOG_VERBOSE, "Alignments:\n");
1946 av_log(ctx, AV_LOG_VERBOSE, " optimalBufferCopyRowPitchAlignment: %"PRIu64"\n",
1947 p->props.properties.limits.optimalBufferCopyRowPitchAlignment);
1948 av_log(ctx, AV_LOG_VERBOSE, " minMemoryMapAlignment: %zu\n",
1949 p->props.properties.limits.minMemoryMapAlignment);
1950 av_log(ctx, AV_LOG_VERBOSE, " nonCoherentAtomSize: %"PRIu64"\n",
1951 p->props.properties.limits.nonCoherentAtomSize);
1952 if (p->vkctx.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
1953 av_log(ctx, AV_LOG_VERBOSE, " minImportedHostPointerAlignment: %"PRIu64"\n",
1954 p->hprops.minImportedHostPointerAlignment);
1955
1956 vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, NULL);
1957 if (!qf_num) {
1958 av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n");
1959 return AVERROR_EXTERNAL;
1960 }
1961
1962 ext_sem_props_info = (VkPhysicalDeviceExternalSemaphoreInfo) {
1963 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
1964 };

Callers

nothing calls this directly

Calls 8

ff_vk_load_functionsFunction · 0.85
av_logFunction · 0.85
av_malloc_arrayFunction · 0.85
av_callocFunction · 0.85
ff_vk_load_propsFunction · 0.85
ff_vk_qf_findFunction · 0.85
av_freeFunction · 0.70
pthread_mutex_initFunction · 0.50

Tested by

no test coverage detected