Finality Engine
Loading...
Searching...
No Matches
RenderDevice.h
Go to the documentation of this file.
1
11#pragma once
12#include <functional>
13#include "Core.h"
14#include "Window.h"
15#include <vector>
16#include <memory>
17#include <glm/glm.hpp>
18
19#include "Texture.h"
20#include "RenderTypes.h"
21#include "RenderTarget.h"
22#include "RenderView.h"
24
25namespace FINALITY
26{
27 class Mesh;
28 class Pipeline;
29 class Shader;
30 class Material;
31 struct PipelineConfig;
32 struct Vertex;
33
36 {
37 std::shared_ptr<Mesh> MeshData;
38 std::shared_ptr<Pipeline> PipelineInstance;
39 glm::mat4 Transform{ 1.0f };
40
41 std::vector<uint8_t> CustomPushData;
42 std::unordered_map<std::string, std::shared_ptr<Texture>> Textures;
43 std::shared_ptr<const Material> MaterialInstance;
44 bool EditorOverlay = false;
45 bool Occluder = false;
46 uint64_t EntityID = 0;
47 std::shared_ptr<const RenderLODGroup> LODGroup;
48 int LODLevel = 0;
49 };
50
53 glm::mat4 Transform;
54 uint8_t CustomData[64];
55 };
56
57
68 {
69 public:
70 virtual ~RenderDevice() = default;
71
72 virtual void Initialize(const NativeWindowHandle& handle) = 0;
73 virtual void Shutdown() = 0;
74
75 virtual void BeginFrame() = 0;
76 virtual void EndFrame() = 0;
77 virtual void PresentFrame() = 0;
78
84 virtual void WaitIdle() = 0;
91 virtual void RetireResource(std::function<void()> release) = 0;
92 virtual void FlushRetiredResources() = 0;
93 virtual void Clear(float r, float g, float b, float a) = 0;
94
95 virtual void SetWindowSpec(const WindowSpec& spec) = 0;
97
98 virtual void DrawQueue(const std::vector<RenderPacket>& queue) = 0;
99 virtual RendererAPI GetActiveApi() const = 0;
100
101 virtual std::shared_ptr<Mesh> CreateMesh(const std::vector<Vertex>& vertices) = 0;
102 virtual std::shared_ptr<Mesh> CreateMesh(const std::vector<Vertex>& vertices, const std::vector<uint32_t>& indices) = 0;
103 virtual std::shared_ptr<Mesh> CreateMesh(const std::string& meshPath) = 0;
104 virtual std::shared_ptr<Pipeline> CreatePipeline(const PipelineConfig& config) = 0;
105 virtual std::unique_ptr<Shader> CreateShader(const std::string& path) = 0;
106 virtual std::shared_ptr<Pipeline> CreatePostProcessPipeline(const PipelineConfig& config) = 0;
107 virtual void SetPostProcessPipeline(std::shared_ptr<Pipeline> pipeline) = 0;
108 virtual void SetFrameView(const RenderView& view) = 0;
109
110 virtual std::shared_ptr<RenderTarget> CreateRenderTarget(uint32_t width, uint32_t height) = 0;
111 virtual void ResizeRenderTarget(const std::shared_ptr<RenderTarget>& target, uint32_t width, uint32_t height) = 0;
112 void UpdateRenderTargetCamera(const std::shared_ptr<RenderTarget>& target, Camera* camera)
113 { if (target && camera) SetRenderTargetView(target, {camera->GetViewMatrix(), camera->GetProjection()}); }
114 virtual void SetRenderTargetView(const std::shared_ptr<RenderTarget>& target, const RenderView& view) = 0;
116 virtual void RenderSceneToTarget(const std::shared_ptr<RenderTarget>& target, const std::vector<RenderPacket>& queue) = 0;
117 virtual void* GetRenderTargetTextureHandle(const std::shared_ptr<RenderTarget>& target) = 0;
118 virtual void SetRenderTargetClearColor(const std::shared_ptr<RenderTarget>& target, float r, float g, float b, float a) = 0;
119 virtual void SetGameRenderTarget(const std::shared_ptr<RenderTarget>& target) = 0;
120 virtual void SetSwapchainClearColor(float r, float g, float b, float a) = 0;
121
122 virtual void BeginTextureBatch() = 0;
123 virtual void EndAndSubmitTextureBatch() = 0;
124 virtual bool IsUploadBatchActive() const = 0;
125
126 virtual const double GetGPUTimeMS() const = 0;
127
128 private:
129 virtual double GetGPUTime() = 0;
130 };
131}
#define FAPI
Definition Core.h:22
Describes the camera matrices and occlusion policy for one render view.
Stores camera projection and view configuration.
Definition Camera.h:28
const glm::mat4 & GetProjection() const
Definition Camera.h:39
glm::mat4 GetViewMatrix() const
Definition Camera.h:41
Defines the graphics backend boundary and render submission contract.
virtual void * GetRenderTargetTextureHandle(const std::shared_ptr< RenderTarget > &target)=0
virtual void SetGameRenderTarget(const std::shared_ptr< RenderTarget > &target)=0
void UpdateRenderTargetCamera(const std::shared_ptr< RenderTarget > &target, Camera *camera)
virtual void FlushRetiredResources()=0
virtual void SetRenderTargetView(const std::shared_ptr< RenderTarget > &target, const RenderView &view)=0
virtual void Initialize(const NativeWindowHandle &handle)=0
virtual void DrawQueue(const std::vector< RenderPacket > &queue)=0
virtual std::shared_ptr< RenderTarget > CreateRenderTarget(uint32_t width, uint32_t height)=0
virtual void SetRenderTargetClearColor(const std::shared_ptr< RenderTarget > &target, float r, float g, float b, float a)=0
virtual void EndAndSubmitTextureBatch()=0
virtual void ResizeRenderTarget(const std::shared_ptr< RenderTarget > &target, uint32_t width, uint32_t height)=0
virtual void RetireResource(std::function< void()> release)=0
Defers resource cleanup until backend frame work permits its release.
virtual const double GetGPUTimeMS() const =0
virtual void SetPostProcessPipeline(std::shared_ptr< Pipeline > pipeline)=0
virtual void Clear(float r, float g, float b, float a)=0
virtual RendererAPI GetActiveApi() const =0
virtual void SetSwapchainClearColor(float r, float g, float b, float a)=0
virtual void BeginFrame()=0
virtual std::shared_ptr< Mesh > CreateMesh(const std::vector< Vertex > &vertices)=0
virtual bool IsUploadBatchActive() const =0
virtual std::shared_ptr< Mesh > CreateMesh(const std::string &meshPath)=0
virtual void Shutdown()=0
virtual void DestroyRenderTargetGpuResources(RenderTarget &target)=0
virtual WindowSpec GetWindowSpec()=0
virtual void BeginTextureBatch()=0
virtual std::shared_ptr< Mesh > CreateMesh(const std::vector< Vertex > &vertices, const std::vector< uint32_t > &indices)=0
virtual std::unique_ptr< Shader > CreateShader(const std::string &path)=0
virtual void WaitIdle()=0
Waits for outstanding device work to finish.
virtual void PresentFrame()=0
virtual void EndFrame()=0
virtual std::shared_ptr< Pipeline > CreatePipeline(const PipelineConfig &config)=0
virtual std::shared_ptr< Pipeline > CreatePostProcessPipeline(const PipelineConfig &config)=0
virtual ~RenderDevice()=default
virtual void RenderSceneToTarget(const std::shared_ptr< RenderTarget > &target, const std::vector< RenderPacket > &queue)=0
virtual void SetFrameView(const RenderView &view)=0
virtual void SetWindowSpec(const WindowSpec &spec)=0
Per-instance transform and fixed-size custom data uploaded to the graphics backend.
Scene draw submission retaining geometry, material and visibility inputs until backend recording.
std::unordered_map< std::string, std::shared_ptr< Texture > > Textures
std::shared_ptr< const RenderLODGroup > LODGroup
std::shared_ptr< Mesh > MeshData
std::shared_ptr< Pipeline > PipelineInstance
std::shared_ptr< const Material > MaterialInstance
std::vector< uint8_t > CustomPushData
Describes the camera matrices and occlusion policy for one render view.
Definition RenderView.h:26