Creates a VkInstance */
| 1163 | |
| 1164 | /* Creates a VkInstance */ |
| 1165 | static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts, |
| 1166 | enum FFVulkanDebugMode *debug_mode) |
| 1167 | { |
| 1168 | int err = 0; |
| 1169 | VkResult ret; |
| 1170 | VulkanDevicePriv *p = ctx->hwctx; |
| 1171 | AVVulkanDeviceContext *hwctx = &p->p; |
| 1172 | FFVulkanFunctions *vk = &p->vkctx.vkfn; |
| 1173 | VkApplicationInfo application_info = { |
| 1174 | .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, |
| 1175 | .pApplicationName = "ffmpeg", |
| 1176 | .applicationVersion = VK_MAKE_VERSION(LIBAVUTIL_VERSION_MAJOR, |
| 1177 | LIBAVUTIL_VERSION_MINOR, |
| 1178 | LIBAVUTIL_VERSION_MICRO), |
| 1179 | .pEngineName = "libavutil", |
| 1180 | .apiVersion = VK_API_VERSION_1_3, |
| 1181 | .engineVersion = VK_MAKE_VERSION(LIBAVUTIL_VERSION_MAJOR, |
| 1182 | LIBAVUTIL_VERSION_MINOR, |
| 1183 | LIBAVUTIL_VERSION_MICRO), |
| 1184 | }; |
| 1185 | VkValidationFeaturesEXT validation_features = { |
| 1186 | .sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, |
| 1187 | }; |
| 1188 | VkInstanceCreateInfo inst_props = { |
| 1189 | .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
| 1190 | .pApplicationInfo = &application_info, |
| 1191 | }; |
| 1192 | |
| 1193 | if (!hwctx->get_proc_addr) { |
| 1194 | err = load_libvulkan(ctx); |
| 1195 | if (err < 0) |
| 1196 | return err; |
| 1197 | } |
| 1198 | |
| 1199 | err = ff_vk_load_functions(ctx, vk, p->vkctx.extensions, 0, 0); |
| 1200 | if (err < 0) { |
| 1201 | av_log(ctx, AV_LOG_ERROR, "Unable to load instance enumeration functions!\n"); |
| 1202 | return err; |
| 1203 | } |
| 1204 | |
| 1205 | err = check_layers(ctx, opts, &inst_props.ppEnabledLayerNames, |
| 1206 | &inst_props.enabledLayerCount, debug_mode); |
| 1207 | if (err) |
| 1208 | goto fail; |
| 1209 | |
| 1210 | /* Check for present/missing extensions */ |
| 1211 | err = check_extensions(ctx, 0, opts, &inst_props.ppEnabledExtensionNames, |
| 1212 | &inst_props.enabledExtensionCount, *debug_mode); |
| 1213 | hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; |
| 1214 | hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount; |
| 1215 | if (err < 0) |
| 1216 | goto fail; |
| 1217 | |
| 1218 | /* Enable debug features if needed */ |
| 1219 | if (*debug_mode == FF_VULKAN_DEBUG_VALIDATE) { |
| 1220 | static const VkValidationFeatureEnableEXT feat_list_validate[] = { |
| 1221 | VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT, |
| 1222 | VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT, |
no test coverage detected