summaryrefslogtreecommitdiff
path: root/engine/xe_engine.cpp
blob: ff9c95bf60d7acf1df9edd37c669003638f98d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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} {
    loadDescriptors();
  };

XeEngine::~XeEngine() {};

void XeEngine::loadDescriptors() {
  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();

  xeDescriptorSetLayout = XeDescriptorSetLayout::Builder(xeDevice)
    .addBinding(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT)
    .build();
}

std::unique_ptr<XeRenderSystem> XeEngine::createRenderSystem(const std::string &vert, const std::string &frag, typename pushCunstant, typename uniformBuffer) {
  return std::make_unique<XeRenderSystem>(
    xeDevice,
    xeRenderer,
    xeDescriptorPool,
    xeDescriptorSetLayout,
    vert,
    frag,
    pushCunstantDataSize,
    uniformBufferDataSize
  );
}

}