HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resourceRegistry.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_RESOURCE_REGISTRY_H
8 #define PXR_IMAGING_HD_RESOURCE_REGISTRY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
13 
14 #include "pxr/imaging/hd/perfLog.h"
15 
16 #include "pxr/imaging/hf/perfLog.h"
17 
18 #include "pxr/base/tf/singleton.h"
19 #include "pxr/base/tf/token.h"
20 #include "pxr/base/vt/dictionary.h"
21 
22 #include <memory>
23 
25 
26 
27 using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
28 
29 /// \class HdResourceRegistry
30 ///
31 /// A central registry for resources.
32 ///
34 public:
35  HF_MALLOC_TAG_NEW("new HdResourceRegistry");
36 
37  HD_API
39 
40  HD_API
41  virtual ~HdResourceRegistry();
42 
43  /// Commits all in-flight source data.
44  HD_API
45  void Commit();
46 
47  /// cleanup all buffers and remove if empty
48  HD_API
49  void GarbageCollect();
50 
51  /// Globally unique id for texture, see HdRenderIndex::GetTextureKey() for
52  /// details.
53  typedef size_t TextureKey;
54 
55  /// Invalidate any shaders registered with this registry.
56  HD_API
57  virtual void InvalidateShaderRegistry();
58 
59  /// Generic method to inform RenderDelegate a resource needs to be reloaded.
60  /// This method can be used by the application to inform the renderDelegate
61  /// that a resource, which may not have any prim representation in Hydra,
62  /// needs to be reloaded. For example a texture found in a material network.
63  /// The `path` can be absolute or relative. It should usually match the
64  /// path found for textures during HdMaterial::Sync.
65  HD_API
66  virtual void ReloadResource(
67  TfToken const& resourceType,
68  std::string const& path);
69 
70  /// Returns a report of resource allocation by role in bytes and
71  /// a summary total allocation of GPU memory in bytes for this registry.
72  HD_API
73  virtual VtDictionary GetResourceAllocation() const;
74 
75 protected:
76  /// A hook for derived registries to perform additional resource commits.
77  HD_API
78  virtual void _Commit();
79 
80  /// Hooks for derived registries to perform additional GC when
81  /// GarbageCollect() is invoked.
82  HD_API
83  virtual void _GarbageCollect();
84 
85 private:
86  // Not copyable
87  HdResourceRegistry(const HdResourceRegistry&) = delete;
88  HdResourceRegistry& operator=(const HdResourceRegistry&) = delete;
89 };
90 
92 
93 #endif //PXR_IMAGING_HD_RESOURCE_REGISTRY_H
virtual HD_API void InvalidateShaderRegistry()
Invalidate any shaders registered with this registry.
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
HD_API void Commit()
Commits all in-flight source data.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define HD_API
Definition: api.h:23
virtual HD_API void _Commit()
A hook for derived registries to perform additional resource commits.
virtual HD_API VtDictionary GetResourceAllocation() const
Definition: token.h:70
virtual HD_API void _GarbageCollect()
virtual HD_API void ReloadResource(TfToken const &resourceType, std::string const &path)
HD_API void GarbageCollect()
cleanup all buffers and remove if empty
virtual HD_API ~HdResourceRegistry()
HF_MALLOC_TAG_NEW("new HdResourceRegistry")
HD_API HdResourceRegistry()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74