Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
GraphicsMemoryManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/primitive_type.h>
4
5#include <cstddef>
6#include <limits>
7
8namespace ph::editor { class GHIThreadUpdateContext; }
9
10namespace ph::editor::ghi
11{
12
13class GraphicsMemoryBlock;
14class GraphicsArena;
15
26{
27public:
29
38 virtual GraphicsMemoryBlock* allocHostBlock(uint32 numFramesToLive) = 0;
39
49 uint32 numFramesToLive,
50 std::size_t blockSize,
51 std::size_t blockAlignment) = 0;
52
55 virtual void onGHILoad() = 0;
56
59 virtual void onGHIUnload() = 0;
60
63 virtual void beginFrameUpdate(const GHIThreadUpdateContext& ctx) = 0;
64
67 virtual void endFrameUpdate(const GHIThreadUpdateContext& ctx) = 0;
68
69 // TODO: arena should guarantee always succeed (custom alloc if cannot fit)
72
73public:
74 static uint32 equivalentRenderFrameLifetime(uint32 numRenderFramesToLive)
75 {
76 /* GHI frame may end before render frame ends but can never restart until next render frame
77 begins, so we need to increase the number of frames to live to cover for the case that GHI
78 frame may end earlier than render frame. Adding 1 frame will suffice for this case, as that
79 means the lifetime won't end until next render frame.
80 */
81 return numRenderFramesToLive + 1;
82 }
83};
84
85}// end namespace ph::editor::ghi
Definition GHIThreadUpdateContext.h:11
Graphics memory allocation helper. The arena is allocating lazily, i.e., constructing and copying an ...
Definition GraphicsArena.h:20
Definition GraphicsMemoryBlock.h:13
Manages memory for graphics.
Definition GraphicsMemoryManager.h:26
virtual void beginFrameUpdate(const GHIThreadUpdateContext &ctx)=0
Called by GHI thread when a frame begins.
virtual void onGHILoad()=0
Called by GHI thread after GHI is loaded.
virtual void endFrameUpdate(const GHIThreadUpdateContext &ctx)=0
Called by GHI thread when a frame ends.
virtual GraphicsMemoryBlock * allocHostBlock(uint32 numFramesToLive)=0
static uint32 equivalentRenderFrameLifetime(uint32 numRenderFramesToLive)
Definition GraphicsMemoryManager.h:74
GraphicsArena newRenderProducerHostArena()
Definition GraphicsMemoryManager.cpp:14
GraphicsArena newHostArena()
Definition GraphicsMemoryManager.cpp:9
virtual GraphicsMemoryBlock * allocCustomHostBlock(uint32 numFramesToLive, std::size_t blockSize, std::size_t blockAlignment)=0
virtual void onGHIUnload()=0
Called by GHI thread before GHI is unloaded.
Definition PlatformDisplay.h:13
Definition ph_editor.h:10