HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
samplerObjectRegistry.h
Go to the documentation of this file.
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_HD_ST_SAMPLER_OBJECT_REGISTRY_H
8 #define PXR_IMAGING_HD_ST_SAMPLER_OBJECT_REGISTRY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
13 #include <memory>
14 #include <vector>
15 
17 
20  std::shared_ptr<class HdStTextureObject>;
22  std::shared_ptr<class HdStSamplerObject>;
24 
25 /// \class HdSt_SamplerObjectRegistry
26 ///
27 /// A simple registry for GPU samplers.
28 ///
29 /// The registry makes no attempt at de-duplication. But construction
30 /// is dispatched by texture type returing a matching sampler (e.g.,
31 /// HdStFieldSamplerObject for a HdStFieldTextureObject or
32 /// HdStPtexSamplerObject for the (not yet existing)
33 /// HdStPtexTextureObject). Also, it keeps a shared pointer to a sampler
34 /// around until garbage collection so that clients can safely drop their
35 /// shared pointers from different threads.
36 ///
38 {
39 public:
40  HDST_API
42 
43  HDST_API
45 
46  /// Create new sampler object matching the given texture object.
47  ///
48  /// The associated GPU resource is created immediately and
49  /// the call is not thread-safe.
50  HDST_API
53  HdSamplerParameters const &samplerParameters);
54 
55  /// Delete samplers no longer used by a client.
56  HDST_API
57  void GarbageCollect();
58 
59  HDST_API
61 
62  /// Get resource registry
63  ///
64  HDST_API
66 
67 private:
68  std::vector<HdStSamplerObjectSharedPtr> _samplerObjects;
69 
70  bool _garbageCollectionNeeded;
71  HdStResourceRegistry *_resourceRegistry;
72 };
73 
75 
76 #endif
HDST_API HdStResourceRegistry * GetResourceRegistry() const
HDST_API ~HdSt_SamplerObjectRegistry()
HDST_API HdStSamplerObjectSharedPtr AllocateSampler(HdStTextureObjectSharedPtr const &texture, HdSamplerParameters const &samplerParameters)
std::shared_ptr< class HdStTextureObject > HdStTextureObjectSharedPtr
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
HDST_API void MarkGarbageCollectionNeeded()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDST_API void GarbageCollect()
Delete samplers no longer used by a client.
std::shared_ptr< class HdStSamplerObject > HdStSamplerObjectSharedPtr
Definition: samplerObject.h:30
GLuint texture
Definition: glcorearb.h:415
HDST_API HdSt_SamplerObjectRegistry(HdStResourceRegistry *registry)