ezEngine  Milestone 7
GPUResourcePool.h
1 #pragma once
2 
3 #include <RendererCore/Basics.h>
4 #include <Foundation/Containers/DynamicArray.h>
5 #include <Foundation/Threading/Mutex.h>
6 
9 class EZ_RENDERERCORE_DLL ezGPUResourcePool
10 {
11 public:
12 
15 
18  ezGALTextureHandle GetRenderTarget(const ezGALTextureCreationDescription& TextureDesc);
19 
21  ezGALTextureHandle GetRenderTarget(ezUInt32 uiWidth, ezUInt32 uiHeight, ezGALResourceFormat::Enum eFormat);
22 
25  void ReturnRenderTarget(ezGALTextureHandle hRenderTarget);
26 
29  void RunGC();
30 
31 
32  static ezGPUResourcePool* GetDefaultInstance();
33  static void SetDefaultInstance(ezGPUResourcePool* pDefaultInstance);
34 
35 protected:
36 
37  void CheckAndPotentiallyRunGC();
38  void UpdateMemoryStats() const;
39 
40  ezUInt64 m_uiMemoryThresholdForGC;
41  ezUInt64 m_uiCurrentlyAllocatedMemory;
42  ezUInt32 m_uiNumAllocationsThresholdForGC;
43  ezUInt32 m_uiNumAllocationsSinceLastGC;
44 
45 
46  ezDynamicArray<ezGALTextureHandle> m_AvailableTextures;
47  ezDynamicArray<ezGALTextureHandle> m_TexturesInUse;
48 
49  ezMutex m_Lock;
50 
51  ezGALDevice* m_pDevice;
52 
53 private:
54 
55  static ezGPUResourcePool* s_pDefaultInstance;
56 
57 };