start refactoring, doesnt compile

This commit is contained in:
tylermurphy534 2022-09-19 07:08:42 -04:00
parent 27bc8c9c9b
commit 8754e31367
5 changed files with 62 additions and 13 deletions

17
engine/xe_engine.cpp Normal file
View file

@ -0,0 +1,17 @@
#include "xe_engine.hpp"
#include "xe_descriptors.hpp"
namespace xe {
XeEngine::XeEngine(int width, int height, std::string name)
: xeWindow{width, height, name}, xeDevice{xeWindow}, xeRenderer{xeWindow, xeDevice} {};
void XeEngine::loadDescriptorPool() {
xeDescriptorPool = XeDescriptorPool::Builder(xeDevice)
.setMaxSets(XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.build();
}
}

40
engine/xe_engine.hpp Normal file
View file

@ -0,0 +1,40 @@
#pragma once
#include "xe_window.hpp"
#include "xe_device.hpp"
#include "xe_renderer.hpp"
namespace xe {
class XeEngine {
public:
XeEngine(int width, int height, std::string name);
~XeEngine() {};
XeEngine(const XeEngine&) = delete;
XeEngine operator=(const XeEngine&) = delete;
const XeWindow& getWindow() const {
return xeWindow;
};
const XeRenderer& getRenderer() const {
return xeRenderer;
};
private:
void loadDescriptorPool();
XeWindow xeWindow;
XeDevice xeDevice;
XeRenderer xeRenderer;
std::unique_ptr<XeDescriptorPool> xeDescriptorPool{};
std::unique_ptr<xe::XeDescriptorSetLayout> xeDescriptorSetLayout;
};
}

View file

@ -3,6 +3,7 @@
#include "xe_device.hpp" #include "xe_device.hpp"
#include "xe_game_object.hpp" #include "xe_game_object.hpp"
#include "xe_swap_chain.hpp" #include "xe_swap_chain.hpp"
#include "xe_descriptors.hpp"
#include "xe_window.hpp" #include "xe_window.hpp"
#include <memory> #include <memory>
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
@ -16,6 +17,7 @@ namespace xe {
XeRenderer::XeRenderer(XeWindow& window, XeDevice& device) : xeWindow{window}, xeDevice{device} { XeRenderer::XeRenderer(XeWindow& window, XeDevice& device) : xeWindow{window}, xeDevice{device} {
recreateSwapChain(); recreateSwapChain();
createCommandBuffers(); createCommandBuffers();
loadDescriptorPool();
} }
XeRenderer::~XeRenderer() { freeCommandBuffers(); } XeRenderer::~XeRenderer() { freeCommandBuffers(); }

View file

@ -24,12 +24,7 @@ struct GlobalUbo {
glm::vec3 lightDirection = glm::normalize(glm::vec3{-1.f, 3.f, 1.f}); glm::vec3 lightDirection = glm::normalize(glm::vec3{-1.f, 3.f, 1.f});
}; };
FirstApp::FirstApp() { FirstApp::FirstApp() : xeEngine{WIDTH, HEIGHT, "Hello, Vulkan!"} {
globalPool = XeDescriptorPool::Builder(xeDevice)
.setMaxSets(XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
.build();
loadGameObjects(); loadGameObjects();
} }

View file

@ -1,8 +1,6 @@
#pragma once #pragma once
#include "xe_renderer.hpp" #include "xe_engine.hpp"
#include "xe_window.hpp"
#include "xe_device.hpp"
#include "xe_game_object.hpp" #include "xe_game_object.hpp"
#include "xe_descriptors.hpp" #include "xe_descriptors.hpp"
@ -26,11 +24,8 @@ class FirstApp {
private: private:
void loadGameObjects(); void loadGameObjects();
XeWindow xeWindow{WIDTH, HEIGHT, "Hello Vulkan!"}; XeEngine xeEngine;
XeDevice xeDevice{xeWindow};
XeRenderer xeRenderer{xeWindow, xeDevice};
std::unique_ptr<XeDescriptorPool> globalPool{};
std::vector<XeGameObject> gameObjects; std::vector<XeGameObject> gameObjects;
}; };
} }