24 #ifndef PXR_IMAGING_HD_ST_TEXTURE_HANDLE_REGISTRY_H
25 #define PXR_IMAGING_HD_ST_TEXTURE_HANDLE_REGISTRY_H
28 #include "pxr/imaging/hdSt/api.h"
30 #include "pxr/imaging/hdSt/textureObject.h"
32 #include "pxr/imaging/hd/enums.h"
34 #include <tbb/concurrent_vector.h>
39 PXR_NAMESPACE_OPEN_SCOPE
44 class HdSt_SamplerObjectRegistry;
46 using HdStTextureHandlePtr =
47 std::weak_ptr<class HdStTextureHandle>;
48 using HdStTextureHandleSharedPtr =
49 std::shared_ptr<class HdStTextureHandle>;
50 using HdStTextureObjectPtr =
51 std::weak_ptr<class HdStTextureObject>;
52 using HdStTextureObjectSharedPtr =
53 std::shared_ptr<class HdStTextureObject>;
54 using HdStSamplerObjectSharedPtr =
55 std::shared_ptr<class HdStSamplerObject>;
56 using HdStShaderCodePtr =
57 std::weak_ptr<class HdStShaderCode>;
58 using HdStShaderCodeSharedPtr =
59 std::shared_ptr<class HdStShaderCode>;
72 class HdSt_TextureHandleRegistry final
79 ~HdSt_TextureHandleRegistry();
86 HdStTextureHandleSharedPtr AllocateTextureHandle(
88 HdTextureType textureType,
92 bool createBindlessHandle,
93 HdStShaderCodePtr
const &shaderCode);
103 void MarkDirty(HdStTextureObjectPtr
const &texture);
111 void MarkDirty(HdStShaderCodePtr
const &shader);
117 void MarkSamplerGarbageCollectionNeeded();
121 HdSt_TextureObjectRegistry * GetTextureObjectRegistry()
const {
122 return _textureObjectRegistry.get();
127 HdSt_SamplerObjectRegistry * GetSamplerObjectRegistry()
const {
128 return _samplerObjectRegistry.get();
138 std::set<HdStShaderCodeSharedPtr> Commit();
148 void SetMemoryRequestForTextureType(HdTextureType textureType,
size_t memoryRequest);
151 size_t GetNumberOfTextureHandles()
const;
154 void _ComputeMemoryRequest(HdStTextureObjectSharedPtr
const &);
155 void _ComputeMemoryRequests(
const std::set<HdStTextureObjectSharedPtr> &);
156 void _ComputeAllMemoryRequests();
158 bool _GarbageCollectHandlesAndComputeTargetMemory();
159 void _GarbageCollectAndComputeTargetMemory();
160 std::set<HdStShaderCodeSharedPtr> _Commit();
162 class _TextureToHandlesMap;
168 std::map<HdTextureType, size_t> _textureTypeToMemoryRequest;
170 bool _textureTypeToMemoryRequestChanged;
175 tbb::concurrent_vector<HdStTextureHandlePtr> _dirtyHandles;
179 tbb::concurrent_vector<HdStTextureObjectPtr> _dirtyTextures;
184 tbb::concurrent_vector<HdStShaderCodePtr> _dirtyShaders;
186 std::unique_ptr<class HdSt_SamplerObjectRegistry> _samplerObjectRegistry;
187 std::unique_ptr<class HdSt_TextureObjectRegistry> _textureObjectRegistry;
188 std::unique_ptr<_TextureToHandlesMap> _textureToHandlesMap;
192 PXR_NAMESPACE_CLOSE_SCOPE
Class to identify a texture file or a texture within the texture file (e.g., a frame in a movie)...
A central registry of all GPU resources.
Collection of standard parameters such as wrap modes to sample a texture.