Loading...
Searching...
No Matches
garbageCollector.h
1//
2// Copyright 2020 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HGI_GL_GARBAGE_COLLECTOR_H
8#define PXR_IMAGING_HGI_GL_GARBAGE_COLLECTOR_H
9
10#include "pxr/pxr.h"
12
13#include "pxr/imaging/hgi/hgi.h"
14#include "pxr/imaging/hgiGL/api.h"
15
16#include <mutex>
17#include <vector>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class HgiGL;
22
29{
30public:
31 HGIGL_API
33
34 HGIGL_API
36
41 HGIGL_API
43
47 HgiBufferHandleVector* GetBufferList();
48 HgiTextureHandleVector* GetTextureList();
49 HgiSamplerHandleVector* GetSamplerList();
50 HgiShaderFunctionHandleVector* GetShaderFunctionList();
51 HgiShaderProgramHandleVector* GetShaderProgramList();
52 HgiResourceBindingsHandleVector* GetResourceBindingsList();
53 HgiGraphicsPipelineHandleVector* GetGraphicsPipelineList();
54 HgiComputePipelineHandleVector* GetComputePipelineList();
55
56private:
57 HgiGLGarbageCollector & operator =
58 (const HgiGLGarbageCollector&) = delete;
60
64 template<class T>
65 T* _GetThreadLocalStorageList(std::vector<T*>* collector);
66
67 // List of all the per-thread-vectors of objects that need to be destroyed.
68 // The vectors are static (shared across HGIs), because we use thread_local
69 // in _GetThreadLocalStorageList which makes us share the garbage collector
70 // vectors across Hgi instances.
71 static std::vector<HgiBufferHandleVector*> _bufferList;
72 static std::vector<HgiTextureHandleVector*> _textureList;
73 static std::vector<HgiSamplerHandleVector*> _samplerList;
74 static std::vector<HgiShaderFunctionHandleVector*> _shaderFunctionList;
75 static std::vector<HgiShaderProgramHandleVector*> _shaderProgramList;
76 static std::vector<HgiResourceBindingsHandleVector*> _resourceBindingsList;
77 static std::vector<HgiGraphicsPipelineHandleVector*> _graphicsPipelineList;
78 static std::vector<HgiComputePipelineHandleVector*> _computePipelineList;
79
80 bool _isDestroying;
81};
82
83
84PXR_NAMESPACE_CLOSE_SCOPE
85
86#endif
Low-level utilities for informing users of various internal and external diagnostic conditions.
Handles garbage collection of opengl objects by delaying their destruction until those objects are no...
HGIGL_API void PerformGarbageCollection()
Destroys the objects inside the garbage collector.
HgiBufferHandleVector * GetBufferList()
Returns a garbage collection vector for a type of handle.
OpenGL implementation of the Hydra Graphics Interface.
Definition: hgi.h:55