aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/vkrenderer.hpp
blob: ea85115cbb3a3bb4516b798a4a3cdd6610e50901 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include "vke.hpp"

#define DRAW_FENCE_TIMEOUT 99900000

namespace vke {

    class vkRenderer
    {
    protected:

        bool prepared = false;

        vke::device_t*          device;
        vke::render_target_t*          renderTarget;
        vke::engine_t::UniformBuffers sharedUBOs;

        vke::ShadingContext*        shadingCtx;

        VkCommandPool               commandPool = VK_NULL_HANDLE;
        std::vector<VkCommandBuffer>cmdBuffers;

        VkDescriptorSet         descriptorSet   = VK_NULL_HANDLE;

        std::vector<VkFence>    fences;
        VkSubmitInfo            submitInfo;

        VkPipeline              pipeline        = VK_NULL_HANDLE;
        VkPipelineLayout        pipelineLayout  = VK_NULL_HANDLE;

        std::vector<float>	vertices;
        vke::buffer_t*		vertexBuff;
        uint32_t			vBufferSize = 10000 * sizeof(float) * 6;

        virtual void prepare();
        virtual void prepareRendering();
        virtual void configurePipelineLayout();
        virtual void loadRessources();
        virtual void freeRessources();
        virtual void prepareDescriptors();
        virtual void preparePipeline();

    public:
        VkSemaphore         drawComplete    = VK_NULL_HANDLE;
        uint32_t			vertexCount = 0;
        uint32_t			sdffVertexCount = 0;

        vkRenderer ();
        virtual ~vkRenderer();

        virtual void create (device_t *_device, vke::render_target_t* _renderTarget,
                                               engine_t::UniformBuffers& _sharedUbos);
        virtual void destroy();

        virtual void buildCommandBuffer ();
        virtual void rebuildCommandBuffer ();
        virtual void draw(VkCommandBuffer cmdBuff);

        void submit (VkQueue queue, VkSemaphore *waitSemaphore, uint32_t waitSemaphoreCount);

        void drawLine(const glm::vec3& from,const glm::vec3& to,const glm::vec3& fromColor, const glm::vec3& toColor);
        void drawLine(const glm::vec3& from,const glm::vec3& to,const glm::vec3& color);

        virtual void flush();
        virtual void clear();
    };
}