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();
130 void SetMemoryRequestForTextureType(HdStTextureType textureType,
size_t memoryRequest);
133 size_t GetNumberOfTextureHandles()
const;
136 void _ComputeMemoryRequest(HdStTextureObjectSharedPtr
const &);
137 void _ComputeMemoryRequests(
const std::set<HdStTextureObjectSharedPtr> &);
138 void _ComputeAllMemoryRequests();
140 bool _GarbageCollectHandlesAndComputeTargetMemory();
141 void _GarbageCollectAndComputeTargetMemory();
142 std::set<HdStShaderCodeSharedPtr> _Commit();
144 class _TextureToHandlesMap;
150 std::map<HdStTextureType, size_t> _textureTypeToMemoryRequest;
152 bool _textureTypeToMemoryRequestChanged;
157 tbb::concurrent_vector<HdStTextureHandlePtr> _dirtyHandles;
161 tbb::concurrent_vector<HdStTextureObjectPtr> _dirtyTextures;
166 tbb::concurrent_vector<HdStShaderCodePtr> _dirtyShaders;
168 std::unique_ptr<class HdSt_SamplerObjectRegistry> _samplerObjectRegistry;
169 std::unique_ptr<class HdSt_TextureObjectRegistry> _textureObjectRegistry;
170 std::unique_ptr<_TextureToHandlesMap> _textureToHandlesMap;
174PXR_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).