From 5b2aefaf9e0e6fc0e76b143e3094c5c487ef9c27 Mon Sep 17 00:00:00 2001 From: blobfish Date: Thu, 18 Sep 2025 17:47:23 -0400 Subject: [PATCH] app: WindowTraits: Support command line arguments to alter first device preference --- src/vsg/app/WindowTraits.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vsg/app/WindowTraits.cpp b/src/vsg/app/WindowTraits.cpp index acd59ba94f..1f3c63639a 100644 --- a/src/vsg/app/WindowTraits.cpp +++ b/src/vsg/app/WindowTraits.cpp @@ -54,6 +54,17 @@ WindowTraits::WindowTraits(CommandLine& arguments) arguments.read("--screen", screenNum); arguments.read("--display", display); arguments.read("--samples", samples); + + auto setDevicePref = [&](const VkPhysicalDeviceType typeIn) + { + auto it = std::find(deviceTypePreferences.begin(), deviceTypePreferences.end(), typeIn); + if (it != deviceTypePreferences.end()) deviceTypePreferences.erase(it); + deviceTypePreferences.insert(deviceTypePreferences.begin(), typeIn); + }; + if (arguments.read("--prefer-integrated")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU); + if (arguments.read("--prefer-discrete")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU); + if (arguments.read("--prefer-virtual")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU); + if (arguments.read("--prefer-cpu")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_CPU); } WindowTraits::WindowTraits(const WindowTraits& traits, const CopyOp& copyop) :