diff --git a/src/lve_device.cpp b/src/lve_device.cpp index 601e6f0..31ad6fd 100644 --- a/src/lve_device.cpp +++ b/src/lve_device.cpp @@ -119,7 +119,14 @@ void LveDevice::pickPhysicalDevice() { vkEnumeratePhysicalDevices(instance, &deviceCount, devices.data()); for (const auto &device : devices) { - if (isDeviceSuitable(device)) { + if (isPreferredDevice(device)) { + physicalDevice = device; + return; + } + } + + for (const auto &device : devices) { + if (isSuitableDevice(device)) { physicalDevice = device; break; } @@ -195,7 +202,19 @@ void LveDevice::createCommandPool() { void LveDevice::createSurface() { window.createWindowSurface(instance, &surface_); } -bool LveDevice::isDeviceSuitable(VkPhysicalDevice device) { +bool LveDevice::isPreferredDevice(VkPhysicalDevice device) { + if (!isSuitableDevice(device)) + { + return false; + } + + auto props = VkPhysicalDeviceProperties{}; + vkGetPhysicalDeviceProperties(device, &props); + + return props.deviceType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU; +} + +bool LveDevice::isSuitableDevice(VkPhysicalDevice device) { QueueFamilyIndices indices = findQueueFamilies(device); bool extensionsSupported = checkDeviceExtensionSupport(device); @@ -530,4 +549,4 @@ void LveDevice::createImageWithInfo( } } -} // namespace lve \ No newline at end of file +} // namespace lve diff --git a/src/lve_device.hpp b/src/lve_device.hpp index fd664b0..a7f4244 100644 --- a/src/lve_device.hpp +++ b/src/lve_device.hpp @@ -81,7 +81,8 @@ class LveDevice { void createCommandPool(); // helper functions - bool isDeviceSuitable(VkPhysicalDevice device); + bool isSuitableDevice(VkPhysicalDevice device); + bool isPreferredDevice(VkPhysicalDevice device); std::vector getRequiredExtensions(); bool checkValidationLayerSupport(); QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device); diff --git a/unixBuild.sh b/unixBuild.sh index 5fc6e80..5280075 100755 --- a/unixBuild.sh +++ b/unixBuild.sh @@ -2,5 +2,10 @@ mkdir -p build cd build cmake -S ../ -B . +if [ -z "$MAKEFLAGS" ] +then + export MAKEFLAGS=-j$(nproc) +fi + make && make Shaders && ./LveEngine -cd .. \ No newline at end of file +cd ..