Plasma Engine  2.0
Loading...
Searching...
No Matches
GPUResourcePool.h
1#pragma once
2
3#include <Foundation/Containers/Map.h>
4#include <Foundation/Containers/Set.h>
5#include <Foundation/Threading/Mutex.h>
6#include <RendererCore/RendererCoreDLL.h>
7#include <RendererFoundation/Resources/ResourceFormats.h>
8
10
13class PL_RENDERERCORE_DLL plGPUResourcePool
14{
15public:
18
21 plGALTextureHandle GetRenderTarget(const plGALTextureCreationDescription& textureDesc);
22
24 plGALTextureHandle GetRenderTarget(plUInt32 uiWidth, plUInt32 uiHeight, plGALResourceFormat::Enum format,
25 plGALMSAASampleCount::Enum sampleCount = plGALMSAASampleCount::None, plUInt32 uiSliceColunt = 1);
26
29 void ReturnRenderTarget(plGALTextureHandle hRenderTarget);
30
31
33 plGALBufferHandle GetBuffer(const plGALBufferCreationDescription& bufferDesc);
34
36 void ReturnBuffer(plGALBufferHandle hBuffer);
37
38
43 void RunGC(plUInt32 uiMinimumAge);
44
45
46 static plGPUResourcePool* GetDefaultInstance();
47 static void SetDefaultInstance(plGPUResourcePool* pDefaultInstance);
48
49protected:
50 void CheckAndPotentiallyRunGC();
51 void UpdateMemoryStats() const;
52 void GALDeviceEventHandler(const plGALDeviceEvent& e);
53
55 {
56 plGALTextureHandle m_hTexture;
57 plUInt64 m_uiLastUsed = 0;
58 };
59
61 {
62 plGALBufferHandle m_hBuffer;
63 plUInt64 m_uiLastUsed = 0;
64 };
65
66 plEventSubscriptionID m_GALDeviceEventSubscriptionID = 0;
67 plUInt64 m_uiMemoryThresholdForGC = 256 * 1024 * 1024;
68 plUInt64 m_uiCurrentlyAllocatedMemory = 0;
69 plUInt16 m_uiNumAllocationsThresholdForGC = 128;
70 plUInt16 m_uiNumAllocationsSinceLastGC = 0;
71 plUInt16 m_uiFramesThresholdSinceLastGC = 60;
72 plUInt16 m_uiFramesSinceLastGC = 0;
73
75 plSet<plGALTextureHandle> m_TexturesInUse;
76
78 plSet<plGALBufferHandle> m_BuffersInUse;
79
80 plMutex m_Lock;
81
82 plGALDevice* m_pDevice;
83
84private:
85 static plGPUResourcePool* s_pDefaultInstance;
86};
Definition RendererFoundationDLL.h:418
The plRenderDevice class is the primary interface for interactions with rendering APIs It contains a ...
Definition Device.h:19
Definition RendererFoundationDLL.h:411
This class serves as a pool for GPU related resources (e.g. buffers and textures required for renderi...
Definition GPUResourcePool.h:14
Definition Map.h:408
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
Definition Set.h:238
Definition Descriptors.h:169
Type for important GAL events.
Definition Descriptors.h:253
Definition Descriptors.h:177
Definition GPUResourcePool.h:61
Definition GPUResourcePool.h:55