HatchitGraphics
ht_renderer.h
1 
30 #pragma once
31 
32 #include <ht_platform.h>
33 #include <Hatchit/HatchitGraphics/include/ht_color.h>
34 #include <ht_types.h>
35 #include <ht_string.h>
36 #include <ht_renderpass.h>
37 #include <ht_camera.h>
38 #include <Hatchit/HatchitGraphics/include/ht_device.h>
39 #include <ht_gpuqueue.h>
40 #include <ht_threadqueue.h>
41 #include <ht_shadervariable.h>
42 #include <ht_renderthread.h>
43 
44 namespace Hatchit {
45 
46  namespace Graphics {
47 
48  class SwapChain;
49 
50  enum class ClearArgs
51  {
52  Color,
53  Depth,
54  Stencil,
55  ColorDepth,
56  ColorStencil,
57  ColorDepthStencil
58  };
59 
60  enum RendererType
61  {
62  UNKNOWN,
63  OPENGL,
64  DIRECTX11,
65  DIRECTX12,
66  VULKAN
67  };
68 
70  {
71  RendererType renderer;
72  bool validate;
73  void* window;
74  uint32_t viewportWidth;
75  uint32_t viewportHeight;
76  void* display;
77  Color clearColor;
78  std::string applicationName;
79  };
80 
81  class HT_API Renderer
82  {
83  public:
84  Renderer();
85 
86  ~Renderer();
87 
91  bool Initialize(const RendererParams& params);
92 
97  void ResizeBuffers(uint32_t width, uint32_t height);
98 
100  void Render();
101 
103  void Present();
104 
105  void RegisterRenderRequest(RenderPassHandle pass, MaterialHandle material, MeshHandle mesh, ShaderVariableChunk* instanceVariables);
106 
107  void RegisterCamera(Camera camera);
108 
109  static IDevice* const GetDevice();
110 
111  static SwapChain* const GetSwapChain();
112 
113  static RendererType GetType();
114 
115  protected:
116  static IDevice* _Device;
117  static GPUQueue* _Queue;
118  static RendererType _Type;
119  static SwapChain* _SwapChain;
120 
121  //A collection of renderpass layers. Each layer may contain multiple render passes.
122  std::vector<std::vector<RenderPassHandle>> m_renderPassLayers = std::vector<std::vector<RenderPassHandle>>(64);
123  //A collection of cameras sorted by renderpass layer. Repopulated each frame.
124  std::vector<std::vector<Graphics::Camera>> m_renderPassCameras = std::vector<std::vector<Graphics::Camera>>(64);
125 
126  std::vector<RenderThread*> m_threads;
127  std::mutex m_mutex;
128  std::unique_lock<std::mutex> m_lock;
129  std::condition_variable m_cv;
130  bool m_locked;
131  bool m_processed;
132 
133  Core::ThreadsafeQueue<RenderPassHandle> m_threadQueue;
134 
135  RendererParams m_params;
136 
137  TextureHandle test;
138 
139  void initThreads();
140  };
141 
142  }
143 }
Definition: ht_d3d12material.h:27
Definition: ht_renderer.h:81
Definition: ht_renderer.h:69
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_color.h:19
Definition: ht_camera.h:37
Definition: ht_swapchain.h:38
Color class defining a 4-component color value.
Definition: ht_color.h:26
Interface outlining implementation for GPU Device.
Definition: ht_device.h:27
Singelton class that manages loading of GPU resource objects.
Definition: ht_gpuqueue.h:41
Definition: ht_shadervariablechunk.h:38