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>
39PXR_NAMESPACE_OPEN_SCOPE
44class HdSt_SamplerObjectRegistry;
46using HdStTextureHandlePtr =
47 std::weak_ptr<class HdStTextureHandle>;
48using HdStTextureHandleSharedPtr =
49 std::shared_ptr<class HdStTextureHandle>;
50using HdStTextureObjectPtr =
51 std::weak_ptr<class HdStTextureObject>;
52using HdStTextureObjectSharedPtr =
53 std::shared_ptr<class HdStTextureObject>;
54using HdStSamplerObjectSharedPtr =
55 std::shared_ptr<class HdStSamplerObject>;
56using HdStShaderCodePtr =
57 std::weak_ptr<class HdStShaderCode>;
58using HdStShaderCodeSharedPtr =
59 std::shared_ptr<class HdStShaderCode>;
72class HdSt_TextureHandleRegistry final
79 ~HdSt_TextureHandleRegistry();
86 HdStTextureHandleSharedPtr AllocateTextureHandle(
88 HdStTextureType textureType,
92 HdStShaderCodePtr
const &shaderCode);
102 void MarkDirty(HdStTextureObjectPtr
const &texture);
110 void MarkDirty(HdStShaderCodePtr
const &shader);
116 void MarkSamplerGarbageCollectionNeeded();
120 HdSt_TextureObjectRegistry * GetTextureObjectRegistry()
const {
121 return _textureObjectRegistry.get();
126 HdSt_SamplerObjectRegistry * GetSamplerObjectRegistry()
const {
127 return _samplerObjectRegistry.get();
137 std::set<HdStShaderCodeSharedPtr> Commit();
147 void SetMemoryRequestForTextureType(HdStTextureType textureType,
size_t memoryRequest);
150 size_t GetNumberOfTextureHandles()
const;
153 void _ComputeMemoryRequest(HdStTextureObjectSharedPtr
const &);
154 void _ComputeMemoryRequests(
const std::set<HdStTextureObjectSharedPtr> &);
155 void _ComputeAllMemoryRequests();
157 bool _GarbageCollectHandlesAndComputeTargetMemory();
158 void _GarbageCollectAndComputeTargetMemory();
159 std::set<HdStShaderCodeSharedPtr> _Commit();
161 class _TextureToHandlesMap;
167 std::map<HdStTextureType, size_t> _textureTypeToMemoryRequest;
169 bool _textureTypeToMemoryRequestChanged;
174 tbb::concurrent_vector<HdStTextureHandlePtr> _dirtyHandles;
178 tbb::concurrent_vector<HdStTextureObjectPtr> _dirtyTextures;
183 tbb::concurrent_vector<HdStShaderCodePtr> _dirtyShaders;
185 std::unique_ptr<class HdSt_SamplerObjectRegistry> _samplerObjectRegistry;
186 std::unique_ptr<class HdSt_TextureObjectRegistry> _textureObjectRegistry;
187 std::unique_ptr<_TextureToHandlesMap> _textureToHandlesMap;
191PXR_NAMESPACE_CLOSE_SCOPE
Collection of standard parameters such as wrap modes to sample a texture.
A central registry of all GPU resources.
Class to identify a texture file or a texture within the texture file (e.g., a frame in a movie).