Skip to content

Commit ac6a906

Browse files
Merge pull request vsg-dev#1580 from blobfish/devicePreference
app: WindowTraits: Support command line arguments to alter first devi…
2 parents dcb800b + 5b2aefa commit ac6a906

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/vsg/app/WindowTraits.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ WindowTraits::WindowTraits(CommandLine& arguments)
5454
arguments.read("--screen", screenNum);
5555
arguments.read("--display", display);
5656
arguments.read("--samples", samples);
57+
58+
auto setDevicePref = [&](const VkPhysicalDeviceType typeIn)
59+
{
60+
auto it = std::find(deviceTypePreferences.begin(), deviceTypePreferences.end(), typeIn);
61+
if (it != deviceTypePreferences.end()) deviceTypePreferences.erase(it);
62+
deviceTypePreferences.insert(deviceTypePreferences.begin(), typeIn);
63+
};
64+
if (arguments.read("--prefer-integrated")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);
65+
if (arguments.read("--prefer-discrete")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);
66+
if (arguments.read("--prefer-virtual")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);
67+
if (arguments.read("--prefer-cpu")) setDevicePref(VK_PHYSICAL_DEVICE_TYPE_CPU);
5768
}
5869

5970
WindowTraits::WindowTraits(const WindowTraits& traits, const CopyOp& copyop) :

0 commit comments

Comments
 (0)