minecraftvulkan/engine/xe_render_system.hpp

71 lines
1.7 KiB
C++
Raw Normal View History

2022-09-19 16:54:23 +00:00
#pragma once
#include <vulkan/vulkan.h>
#include "xe_device.hpp"
#include "xe_pipeline.hpp"
#include "xe_game_object.hpp"
2022-09-19 20:35:45 +00:00
#include "xe_descriptors.hpp"
#include "xe_renderer.hpp"
2022-09-20 01:28:41 +00:00
#include "xe_engine.hpp"
2022-09-21 02:02:58 +00:00
#include "xe_image.hpp"
2022-09-19 16:54:23 +00:00
#include <memory>
namespace xe {
class XeRenderSystem {
public:
2022-09-20 01:28:41 +00:00
2022-09-19 16:54:23 +00:00
XeRenderSystem(
2022-09-20 01:28:41 +00:00
XeEngine &xeEngine,
2022-09-19 16:54:23 +00:00
std::string vert,
std::string frag,
2022-09-19 20:35:45 +00:00
uint32_t pushCunstantDataSize,
2022-09-21 02:02:58 +00:00
uint32_t uniformBufferDataSize,
XeImage *image
2022-09-20 01:28:41 +00:00
);
2022-09-19 16:54:23 +00:00
~XeRenderSystem();
XeRenderSystem(const XeRenderSystem &) = delete;
XeRenderSystem operator=(const XeRenderSystem &) = delete;
2022-09-21 02:02:58 +00:00
void start();
void loadPushConstant(void *pushConstantData);
void loadUniformObject(void *uniformBufferData);
void loadTexture(XeImage *image);
2022-09-20 01:28:41 +00:00
void render(XeGameObject &gameObject);
void stop();
2022-09-19 16:54:23 +00:00
private:
2022-09-20 01:28:41 +00:00
2022-09-21 02:02:58 +00:00
void createDescriptorSetLayout();
void createUniformBuffers();
2022-09-21 03:04:33 +00:00
void createDescriptorSets(XeImage *image);
void updateDescriptorSet(XeImage *image, int frameIndex, bool allocate);
2022-09-21 02:02:58 +00:00
void createPipelineLayout();
2022-09-19 16:54:23 +00:00
void createPipeline(VkRenderPass renderPass, std::string vert, std::string frag);
2022-09-20 01:28:41 +00:00
bool boundPipeline{false};
bool boundDescriptor{false};
2022-09-21 02:02:58 +00:00
uint32_t uniformBufferDataSize;
uint32_t pushCunstantDataSize;
bool textureSamplerBinding;
2022-09-19 16:54:23 +00:00
XeDevice& xeDevice;
2022-09-20 01:28:41 +00:00
XeRenderer& xeRenderer;
2022-09-19 16:54:23 +00:00
std::unique_ptr<XePipeline> xePipeline;
std::vector<std::unique_ptr<XeBuffer>> uboBuffers;
std::vector<VkDescriptorSet> descriptorSets;
2022-09-21 02:02:58 +00:00
VkSampler textureSampler;
2022-09-19 16:54:23 +00:00
VkPipelineLayout pipelineLayout;
2022-09-21 03:04:33 +00:00
std::unique_ptr<XeDescriptorPool> &xeDescriptorPool;
2022-09-21 02:02:58 +00:00
std::unique_ptr<XeDescriptorSetLayout> xeDescriptorSetLayout;
2022-09-19 16:54:23 +00:00
};
}