vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
render_backend.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <utility>
6#include <vector>
7
8#include "resource/resource_handle.h"
9
10namespace Vkm::Engine {
11
12struct RenderView;
13struct TextureAsset;
14class ResourceManager;
15class WindowManager;
17
24 std::string api;
25 std::string device;
26};
27
30inline constexpr uint32_t BACKEND_MIN_TEXTURE_EDGE = 16384;
31
39class RenderBackend {
40 public:
41 RenderBackend() = default;
42 virtual ~RenderBackend() = default;
43
44 RenderBackend(const RenderBackend& other) = delete;
45 RenderBackend& operator=(const RenderBackend& other) = delete;
46
47 RenderBackend(RenderBackend && other) = delete;
48 RenderBackend& operator=(RenderBackend && other) = delete;
49
50 public:
60 virtual bool init(WindowManager& window) = 0;
61
71 virtual void render(const RenderView& view, const ResourceManager& resources) = 0;
72
84 virtual bool readFrame(const RenderView& view, std::vector<uint8_t>& pixels) = 0;
85
94 virtual uint32_t reloadChangedShaders() = 0;
95
103 virtual uint32_t maxAnisotropy() const = 0;
104
114 virtual bool holdsPixels(const Handle<TextureAsset>& texture, uint64_t version) const = 0;
115
122
123 public:
124 BackendInfo info() const { return m_info; }
125
126 protected:
128 void setInfo(BackendInfo info) { m_info = std::move(info); }
129
130 private:
131 BackendInfo m_info;
132};
133
134} // namespace Vkm::Engine
What a backend may offer an authoring tool beyond drawing the frame.
Definition editor_render_hooks.h:64
virtual uint32_t reloadChangedShaders()=0
Recompile shaders whose source changed on disk - a dev hook.
virtual void render(const RenderView &view, const ResourceManager &resources)=0
Draw one frame into the window's back buffer, for the engine loop to present.
virtual uint32_t maxAnisotropy() const =0
The highest anisotropic-filtering degree this backend can honour.
void setInfo(BackendInfo info)
What info() reports, once init() knows the API and the device.
Definition render_backend.h:128
virtual bool readFrame(const RenderView &view, std::vector< uint8_t > &pixels)=0
Read back the frame render() last drew, as the window shows it.
virtual bool init(WindowManager &window)=0
Bring the backend up against the window.
virtual bool holdsPixels(const Handle< TextureAsset > &texture, uint64_t version) const =0
Whether the backend holds its own copy of a texture's pixels.
virtual EditorRenderHooks * editorHooks()=0
The backend's authoring-only hooks, or null when it offers none.
Type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
Owns the application's window, its WindowSurface, input, and frame limiting.
Definition window_manager.h:69
Human-readable backend identity, for a status display.
Definition render_backend.h:23
std::string api
The graphics API and its version.
Definition render_backend.h:24
std::string device
The GPU, as its driver names it.
Definition render_backend.h:25
Opaque, type-safe handle for resources, distinguished by ResourceType.
Definition resource_handle.h:16
The backend-agnostic view of the frame handed to RenderBackend::render.
Definition render_view.h:41
Texture asset combining Resource tracking with engine-level texture parameters.
Definition texture_asset.h:15