summaryrefslogtreecommitdiff
path: root/engine/xe_render_system.hpp
blob: fa56fddc20596856275b37b06eeb7ae6d3f7a32d (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once

#include <vulkan/vulkan.h>
#include "xe_device.hpp"
#include "xe_pipeline.hpp"
#include "xe_game_object.hpp"
#include "xe_descriptors.hpp"
#include "xe_renderer.hpp"
#include "xe_engine.hpp"

#include <memory>

namespace xe {

class XeRenderSystem {
  public:
  
    XeRenderSystem(
      XeEngine &xeEngine,
      std::string vert,
      std::string frag, 
      uint32_t pushCunstantDataSize,
      uint32_t uniformBufferDataSize
    );

    ~XeRenderSystem();

    XeRenderSystem(const XeRenderSystem &) = delete;
    XeRenderSystem operator=(const XeRenderSystem &) = delete;

    void loadPushConstant(void *pushConstantData, uint32_t pushConstantSize);
    void loadUniformObject(void *uniformBufferData, uint32_t uniformBufferSize);
    void render(XeGameObject &gameObject);
    void stop();

  private:
  
    void createUniformBuffers(XeDescriptorPool &xeDescriptorPool, XeDescriptorSetLayout &xeDescriptorSetLayout, uint32_t uniformBufferDataSize);
    void createPipelineLayout(XeDescriptorSetLayout &xeDescriptorSetLayout, uint32_t pushCunstantDataSize, uint32_t uniformBufferDataSize);
    void createPipeline(VkRenderPass renderPass, std::string vert, std::string frag);

    bool boundPipeline{false};
    bool boundDescriptor{false};

    XeDevice& xeDevice;
    XeRenderer& xeRenderer;

    std::unique_ptr<XePipeline> xePipeline;
    std::vector<std::unique_ptr<XeBuffer>> uboBuffers;
    std::vector<VkDescriptorSet> descriptorSets;

    VkPipelineLayout pipelineLayout;

};

}