@@ -144,9 +144,15 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char
144144 return true;
145145 }
146146
147- if (ffStrEqualsIgnCase (subKey , "force-vulkan " ))
147+ if (ffStrEqualsIgnCase (subKey , "detection-method " ))
148148 {
149- options -> forceVulkan = ffOptionParseBoolean (value );
149+ options -> detectionMethod = ffOptionParseEnum (key , value , (FFKeyValuePair []) {
150+ { "auto" , FF_GPU_DETECTION_METHOD_AUTO },
151+ { "pci" , FF_GPU_DETECTION_METHOD_PCI },
152+ { "vulkan" , FF_GPU_DETECTION_METHOD_VULKAN },
153+ { "opengl" , FF_GPU_DETECTION_METHOD_OPENGL },
154+ {},
155+ });
150156 return true;
151157 }
152158
@@ -191,9 +197,20 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
191197 continue ;
192198 }
193199
194- if (ffStrEqualsIgnCase (key , "forceVulkan " ))
200+ if (ffStrEqualsIgnCase (key , "detectionMethod " ))
195201 {
196- options -> forceVulkan = yyjson_get_bool (val );
202+ int value ;
203+ const char * error = ffJsonConfigParseEnum (val , & value , (FFKeyValuePair []) {
204+ { "auto" , FF_GPU_DETECTION_METHOD_AUTO },
205+ { "pci" , FF_GPU_DETECTION_METHOD_PCI },
206+ { "vulkan" , FF_GPU_DETECTION_METHOD_VULKAN },
207+ { "opengl" , FF_GPU_DETECTION_METHOD_OPENGL },
208+ {},
209+ });
210+ if (error )
211+ ffPrintError (FF_GPU_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "Invalid %s value: %s" , key , error );
212+ else
213+ options -> detectionMethod = (FFGPUDetectionMethod ) value ;
197214 continue ;
198215 }
199216
@@ -230,8 +247,24 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
230247 if (options -> driverSpecific != defaultOptions .driverSpecific )
231248 yyjson_mut_obj_add_bool (doc , module , "driverSpecific" , options -> driverSpecific );
232249
233- if (options -> forceVulkan != defaultOptions .forceVulkan )
234- yyjson_mut_obj_add_bool (doc , module , "forceVulkan" , options -> forceVulkan );
250+ if (options -> detectionMethod != defaultOptions .detectionMethod )
251+ {
252+ switch (options -> detectionMethod )
253+ {
254+ case FF_GPU_DETECTION_METHOD_AUTO :
255+ yyjson_mut_obj_add_str (doc , module , "detectionMethod" , "auto" );
256+ break ;
257+ case FF_GPU_DETECTION_METHOD_PCI :
258+ yyjson_mut_obj_add_str (doc , module , "detectionMethod" , "pci" );
259+ break ;
260+ case FF_GPU_DETECTION_METHOD_VULKAN :
261+ yyjson_mut_obj_add_str (doc , module , "detectionMethod" , "vulkan" );
262+ break ;
263+ case FF_GPU_DETECTION_METHOD_OPENGL :
264+ yyjson_mut_obj_add_str (doc , module , "detectionMethod" , "opengl" );
265+ break ;
266+ }
267+ }
235268
236269 ffTempsGenerateJsonConfig (doc , module , defaultOptions .temp , defaultOptions .tempConfig , options -> temp , options -> tempConfig );
237270
@@ -366,7 +399,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
366399 ffOptionInitModuleArg (& options -> moduleArgs );
367400
368401 options -> driverSpecific = false;
369- options -> forceVulkan = false ;
402+ options -> detectionMethod = FF_GPU_DETECTION_METHOD_AUTO ;
370403 options -> temp = false;
371404 options -> hideType = FF_GPU_TYPE_UNKNOWN ;
372405 options -> tempConfig = (FFColorRangeConfig ) { 60 , 80 };
0 commit comments