7#ifndef PXR_IMAGING_HD_ST_TEXTURE_HANDLE_REGISTRY_H
8#define PXR_IMAGING_HD_ST_TEXTURE_HANDLE_REGISTRY_H
11#include "pxr/imaging/hdSt/api.h"
13#include "pxr/imaging/hdSt/textureObject.h"
15#include "pxr/imaging/hd/enums.h"
17#include <tbb/concurrent_vector.h>
22PXR_NAMESPACE_OPEN_SCOPE
27class HdSt_SamplerObjectRegistry;
29using HdStTextureHandlePtr =
30 std::weak_ptr<class HdStTextureHandle>;
31using HdStTextureHandleSharedPtr =
32 std::shared_ptr<class HdStTextureHandle>;
33using HdStTextureObjectPtr =
34 std::weak_ptr<class HdStTextureObject>;
35using HdStTextureObjectSharedPtr =
36 std::shared_ptr<class HdStTextureObject>;
37using HdStSamplerObjectSharedPtr =
38 std::shared_ptr<class HdStSamplerObject>;
39using HdStShaderCodePtr =
40 std::weak_ptr<class HdStShaderCode>;
41using HdStShaderCodeSharedPtr =
42 std::shared_ptr<class HdStShaderCode>;
55class HdSt_TextureHandleRegistry final
62 ~HdSt_TextureHandleRegistry();
69 HdStTextureHandleSharedPtr AllocateTextureHandle(
71 HdStTextureType textureType,
75 HdStShaderCodePtr
const &shaderCode);
85 void MarkDirty(HdStTextureObjectPtr
const &texture);
93 void MarkDirty(HdStShaderCodePtr
const &shader);
99 void MarkSamplerGarbageCollectionNeeded();
103 HdSt_TextureObjectRegistry * GetTextureObjectRegistry()
const {
104 return _textureObjectRegistry.get();
109 HdSt_SamplerObjectRegistry * GetSamplerObjectRegistry()
const {
110 return _samplerObjectRegistry.get();
120 std::set<HdStShaderCodeSharedPtr> Commit();
122 void GarbageCollect();
132 void SetMemoryRequestForTextureType(HdStTextureType textureType,
size_t memoryRequest);
135 size_t GetNumberOfTextureHandles()
const;
138 void _ComputeMemoryRequest(HdStTextureObjectSharedPtr
const &);
139 void _ComputeMemoryRequests(
const std::set<HdStTextureObjectSharedPtr> &);
140 void _ComputeAllMemoryRequests();
142 bool _GarbageCollectHandlesAndComputeTargetMemory();
143 std::set<HdStShaderCodeSharedPtr> _Commit();
145 class _TextureToHandlesMap;
151 std::map<HdStTextureType, size_t> _textureTypeToMemoryRequest;
153 bool _textureTypeToMemoryRequestChanged;
158 tbb::concurrent_vector<HdStTextureHandlePtr> _dirtyHandles;
162 tbb::concurrent_vector<HdStTextureObjectPtr> _dirtyTextures;
167 tbb::concurrent_vector<HdStShaderCodePtr> _dirtyShaders;
169 std::unique_ptr<class HdSt_SamplerObjectRegistry> _samplerObjectRegistry;
170 std::unique_ptr<class HdSt_TextureObjectRegistry> _textureObjectRegistry;
171 std::unique_ptr<_TextureToHandlesMap> _textureToHandlesMap;
175PXR_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).