Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/lve_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -530,4 +549,4 @@ void LveDevice::createImageWithInfo(
}
}

} // namespace lve
} // namespace lve
3 changes: 2 additions & 1 deletion src/lve_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class LveDevice {
void createCommandPool();

// helper functions
bool isDeviceSuitable(VkPhysicalDevice device);
bool isSuitableDevice(VkPhysicalDevice device);
bool isPreferredDevice(VkPhysicalDevice device);
std::vector<const char *> getRequiredExtensions();
bool checkValidationLayerSupport();
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device);
Expand Down
7 changes: 6 additions & 1 deletion unixBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
cd ..