~sircmpwn/xrgears

ref: 4d2c57c7eae28e5eab820a11a3ca1ea08fa40441 xrgears/vkc/vkcRenderer.hpp -rw-r--r-- 1.2 KiB
4d2c57c7 — Lubosz Sarnecki rename functions 4 years ago
                                                                                
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
#pragma once

#define VK_PROTOTYPES
#include <vulkan/vulkan.h>

#include "vkcSwapChainVK.hpp"
#include "vkcSwapChainDRM.hpp"
#include "vikRenderer.hpp"

namespace vkc {

class Renderer : public vik::Renderer {
public:
  vik::SwapChain *swap_chain;

  VkInstance instance;
  VkPhysicalDevice physical_device;
  VkDevice device;
  VkRenderPass render_pass;
  VkQueue queue;
  VkPipelineLayout pipeline_layout;
  VkPipeline pipeline;
  VkDeviceMemory mem;
  VkBuffer buffer;
  VkDescriptorSet descriptor_set;
  VkSemaphore semaphore;
  VkFence fence;
  VkCommandPool cmd_pool;

  uint32_t width, height;

  timeval start_tv;
  VkSurfaceKHR surface;
  VkFormat image_format;

  VkCommandBuffer cmd_buffer;

  uint32_t vertex_offset, colors_offset, normals_offset;

  Renderer(uint32_t w, uint32_t h) ;
  ~Renderer() ;

  void init_vk(const char *extension);
  VkFormat choose_surface_format();
  void init_render_pass();
  void init_vk_objects();
  void submit_queue();

  void create_vulkan_swapchain();

  void wait_and_reset_fences();

  uint64_t get_animation_time();

  void build_command_buffer(VkFramebuffer frame_buffer);

  void render(uint32_t index);

  void render_swapchain_vk();
};
}