Hymn to Beauty
C++ 3D Engine
WebGPURenderTargetAllocator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/RenderTargetAllocator.hpp"
4
5#include "WebGPU.hpp"
6#include <map>
7#include <deque>
8
9namespace Video {
10
11class WebGPURenderer;
12class WebGPUTexture;
13
16 public:
18
22
25
26 void BeginFrame() final;
27
29
33 WebGPUTexture* CreateAttachmentlessRenderTarget(const glm::uvec2& size, uint32_t sampleCount = 1);
34
36
40
41 private:
42 struct AttachmentlessRenderTargetInfo {
43 glm::uvec2 size;
44 uint32_t sampleCount;
45 };
46
47 struct AttachmentlessRenderTargetInfoCompare {
48 bool operator()(const AttachmentlessRenderTargetInfo& a, const AttachmentlessRenderTargetInfo& b) const {
49 if (a.size.x != b.size.x) {
50 return a.size.x < b.size.x;
51 }
52
53 if (a.size.y != b.size.y) {
54 return a.size.y < b.size.y;
55 }
56
57 return a.sampleCount < b.sampleCount;
58 }
59 };
60
61 struct AttachmentlessRenderTarget {
62 WebGPUTexture* texture;
63 uint8_t age;
64 };
65
66 Texture* AllocateRenderTarget(const glm::uvec2& size, Texture::Format format) final;
67
68 // Since we don't have a render pass allocator, we need to override this method.
69 void FreeRenderPasses(Texture* renderTarget) final;
70
71 WebGPURenderer& renderer;
72
73 std::map<AttachmentlessRenderTargetInfo, std::deque<AttachmentlessRenderTarget>, AttachmentlessRenderTargetInfoCompare> freeAttachmentlessRenderTargets;
74};
75
76}
Responsible for allocating render targets.
Definition: RenderTargetAllocator.hpp:13
A texture.
Definition: Texture.hpp:8
Format
The format of the texture.
Definition: Texture.hpp:18
WebGPU implementation of RenderTargetAllocator.
Definition: WebGPURenderTargetAllocator.hpp:15
WebGPUTexture * CreateAttachmentlessRenderTarget(const glm::uvec2 &size, uint32_t sampleCount=1)
Create an attachmentless render target.
Definition: WebGPURenderTargetAllocator.cpp:34
WebGPURenderTargetAllocator(WebGPURenderer &renderer)
Create a new render target allocator.
Definition: WebGPURenderTargetAllocator.cpp:9
~WebGPURenderTargetAllocator() final
Destructor.
Definition: WebGPURenderTargetAllocator.cpp:13
void BeginFrame() final
Call at the beginning of each frame.
Definition: WebGPURenderTargetAllocator.cpp:17
void FreeAttachmentlessRenderTarget(WebGPUTexture *renderTarget)
Free an attachmentless render target.
Definition: WebGPURenderTargetAllocator.cpp:54
Low-level renderer implementing WebGPU.
Definition: WebGPURenderer.hpp:22
WebGPU implementation of Texture.
Definition: WebGPUTexture.hpp:13
Definition: Editor.hpp:18