project-aster/aster_core/aster.cpp

39 lines
1.3 KiB
C++

#include "constants.h"
#include "glfw_context.h"
#include "physical_device.h"
#include "window.h"
bool suitable_device(const PhysicalDevice *physical_device) {
constexpr auto required_support = QueueSupportFlags{} | QueueSupportFlagBits::eGraphics | QueueSupportFlagBits::ePresent | QueueSupportFlagBits::eTransfer;
return physical_device->properties.deviceType != vk::PhysicalDeviceType::eCpu &&
!physical_device->surface_formats.empty() &&
!physical_device->present_modes.empty() &&
cast<bool>(physical_device->queue_support & required_support);
}
PhysicalDevice find_suitable_device(PhysicalDevices &&_physical_devices) {
for (auto physdev : _physical_devices) {
VERBOSE(fmt::format("Checking device: {}", physdev.properties.deviceName.data()));
if (suitable_device(&physdev)) {
VERBOSE(fmt::format("Found suitable device {}.", physdev.properties.deviceName.data()));
return physdev;
}
}
throw std::runtime_error("No suitable physical device found.");
}
int main(int, char **) {
GlfwContext glfw = {};
Context context = { "Aster", VERSION };
Window window = { "Aster1", &context, { 640, 480 } };
PhysicalDevice physical_device = find_suitable_device({ &window, &context });
INFO(fmt::format("Using Device {}", physical_device.properties.deviceName.data()));
while (window.poll()) {
}
return 0;
}