10 Commits

Author SHA1 Message Date
b95bc3101f add logical device creation
Some checks failed
Build and Test verification / build (push) Failing after 27s
Build and Test verification / test (push) Has been skipped
2026-05-22 21:16:40 -05:00
a94f2da6b2 improve device selection logic
Some checks failed
Build and Test verification / build (push) Failing after 10m25s
Build and Test verification / test (push) Has been skipped
2026-05-19 20:52:05 -05:00
9bcb8385fe add device clas which enumerates availble gpu devices 2026-05-16 13:37:44 -07:00
a0b3325e1d change default remote to github 2026-05-16 09:57:53 -07:00
e3c4267fc2 add validation layers + debug callback
Some checks failed
Build and Test verification / build (push) Failing after 26s
Build and Test verification / test (push) Has been skipped
2026-05-14 21:10:36 -05:00
cedb80cb03 fix that buffoonery
Some checks failed
Build and Test verification / build (push) Failing after 28m1s
Build and Test verification / test (push) Has been skipped
2026-05-13 19:24:55 -05:00
6835359510 add validation layer checking (c++20 black magic)
Some checks failed
Build and Test verification / build (push) Failing after 38m46s
Build and Test verification / test (push) Has been skipped
2026-05-12 23:19:21 -05:00
e6b98362b6 fixed formatting because nano trolled me 2026-05-12 23:00:43 -05:00
0194699815 add required extensions to vulkan instance (+ use the c++ library over c library)
Some checks failed
Build and Test verification / build (push) Failing after 29s
Build and Test verification / test (push) Has been skipped
2026-05-11 23:32:28 -05:00
302b680a48 update contributing with goals 2026-05-11 22:26:59 -05:00
10 changed files with 12 additions and 118 deletions

View File

@@ -34,8 +34,6 @@ add_library(maiden_core STATIC
src/Window.cpp
src/Engine.cpp
src/Device.cpp
src/Pipeline.cpp
src/Swapchain.cpp
# include extra source files here
)

View File

@@ -3,10 +3,7 @@
#include <iostream>
Device::Device(vk::raii::Instance* instance, Window* window): instance_(instance), window_(window) {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Device constructor" << std::endl;
createSurface();
Device::Device(vk::raii::Instance* instance): instance_(instance) {
}
@@ -58,7 +55,7 @@ uint32_t Device::evaluatePhysicalDevice(vk::raii::PhysicalDevice& device) {
if(deviceProperties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
score += 2;
} else {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Warning: physical device " << deviceProperties.deviceName << " is not a discrete device!" << std::endl;
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Warning: physical device " << deviceProperties.deviceName << " is not a discrete device!" << std::endl;
}
// prefer devices that support vulkan 1.3
@@ -110,11 +107,6 @@ uint32_t Device::evaluatePhysicalDevice(vk::raii::PhysicalDevice& device) {
bool Device::createLogicalDevice() {
if(surface_ == nullptr) {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: cannot create logical device without a valid presentation surface." << std::endl;
return false;
}
if(physicalDevice_ == nullptr) {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: cannot create logical device without a valid physical device." << std::endl;
return false;
@@ -122,20 +114,11 @@ bool Device::createLogicalDevice() {
// specify queue family requirements
std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice_.getQueueFamilyProperties();
int32_t queueIndex = -1;
for(uint32_t qfpIndex = 0; qfpIndex < queueFamilyProperties.size(); qfpIndex++) {
if((queueFamilyProperties[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice_.getSurfaceSupportKHR(qfpIndex, *surface_)) {
queueIndex = static_cast<int32_t>(qfpIndex);
break;
}
}
if(queueIndex == -1) {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: could not locate valid graphics queues." << std::endl;
}
float queuePriority = 0.5f;
auto graphicsQueueFamilyProperty = std::ranges::find_if(queueFamilyProperties, [](auto const &qfp) { return (qfp.queueFlags & vk::QueueFlagBits::eGraphics) != static_cast<vk::QueueFlags>(0); });
auto graphicsIndex = static_cast<uint32_t>(std::distance(queueFamilyProperties.begin(), graphicsQueueFamilyProperty));
float queuePriority = 1.0f;
vk::DeviceQueueCreateInfo deviceQueueCreateInfo {
.queueFamilyIndex = queueIndex,
.queueFamilyIndex = graphicsIndex,
.queueCount = 1,
.pQueuePriorities = &queuePriority
};
@@ -160,7 +143,7 @@ bool Device::createLogicalDevice() {
logicalDevice_ = vk::raii::Device(physicalDevice_, deviceCreateInfo);
// initialize the graphics queue
graphicsQueue_ = vk::raii::Queue(logicalDevice_, queueIndex, 0);
graphicsQueue_ = vk::raii::Queue(logicalDevice_, graphicsIndex, 0);
if(logicalDevice_ != nullptr) {
return true;
@@ -170,9 +153,3 @@ bool Device::createLogicalDevice() {
}
}
void Device::createSurface() {
(void)window_->createSurface(&surface_);
}

View File

@@ -3,13 +3,11 @@
#include <vulkan/vulkan_raii.hpp>
#include "Window.hpp"
class Device {
class Device {
public:
Device(vk::raii::Instance* instance, Window* window);
Device(vk::raii::Instance* instance);
~Device();
// assigns a capable gpu vkdevice to physicalDevice
@@ -23,18 +21,10 @@ class Device {
// gives a device a score to attempt to select the most capable device
uint32_t evaluatePhysicalDevice(vk::raii::PhysicalDevice& device);
// internal create surface
void createSurface();
// vulkan objects
vk::raii::Instance* instance_ = nullptr;
vk::raii::PhysicalDevice physicalDevice_ = nullptr;
vk::raii::Device logicalDevice_ = nullptr;
vk::raii::Queue graphicsQueue_ = nullptr;
vk::raii::SurfaceKHR surface_ = nullptr;
// ptrs to other engine objects
Window* window_ = nullptr;
// required extensions for the physical device
std::vector<const char*> requiredDeviceExtensions_ = { vk::KHRSwapchainExtensionName };

View File

@@ -22,7 +22,7 @@ void Engine::init() {
}
// device selection and setup
Device device(&instance_, window_);
Device device(&instance_);
(void)device.selectPhysicalDevice();
(void)device.createLogicalDevice();

View File

@@ -1,6 +0,0 @@
#include "Pipeline.hpp"
Pipeline::Pipeline(Device* device) : device_(device) {
}

View File

@@ -1,19 +0,0 @@
#pragma once
#include "Device.hpp"
// the Pipeline lays out the rendering steps for the vulkan engine to follow
class Pipeline {
public:
Pipeline(Device* device);
~Pipeline() = default;
private:
Device* device_ = nullptr;
// will include shaders eventually
};

View File

@@ -1,6 +0,0 @@
#include "Swapchain.hpp"
Swapchain::Swapchain() {
}

View File

@@ -1,14 +0,0 @@
#pragma once
// the swapchain functions as the layout for framebuffers that get written to by the gpu and read from to present to the screen
class Swapchain {
public:
Swapchain();
~Swapchain() = default;
private:
};

View File

@@ -2,7 +2,6 @@
#include "Window.hpp"
#include <SDL3/SDL_events.h>
#include <iostream>
Window::Window() {
@@ -44,26 +43,3 @@ void Window::handleEvent(SDL_Event& event) {
rendering_ = true;
}
}
bool Window::createSurface(vk::raii::SurfaceKHR* surface) {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] createSurface()" << std::endl;
#ifdef __WIN32
vk::Win32SurfaceCreateInfoKHR createInfo {
.hinstance = GetModuleHandle(nullptr),
.hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(sdlWindow_), "SDL.window.win32.hwnd", nullptr);
}
surface = &instance_.createWin32SurfaceKHR(createInfo);
#else // __WIN32
#endif // __WIN32
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] attempted to createSurface" << std::endl;
if(surface != nullptr) {
return true;
} else {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: unable to create window surface." << std::endl;
return false;
}
}

View File

@@ -1,9 +1,8 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3/SDL_vulkan.h>
#include <vulkan/vulkan_raii.hpp>
#include "SDL3/SDL.h"
#include "SDL3/SDL_vulkan.h"
// reference: https://wiki.libsdl.org/SDL3/SDL_CreateWindow
class Window {
@@ -18,7 +17,6 @@ public:
bool rendering() { return rendering_; }
bool open() { return open_; }
bool createSurface(vk::raii::SurfaceKHR* surface);
private: