renderBuffer.h
1 //
2 // Copyright 2018 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_RENDER_BUFFER_H
8 #define PXR_IMAGING_HD_RENDER_BUFFER_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/bprim.h"
13 
14 #include "pxr/base/gf/vec2i.h"
15 
16 PXR_NAMESPACE_OPEN_SCOPE
17 
18 
19 
20 
32 class HdRenderBuffer : public HdBprim
33 {
34 public:
35  // change tracking for HdRenderBuffer
36  enum DirtyBits : HdDirtyBits {
37  Clean = 0,
38  DirtyDescription = 1 << 0,
39  AllDirty = (DirtyDescription)
40  };
41 
42  HD_API
43  HdRenderBuffer(SdfPath const& id);
44  HD_API
45  ~HdRenderBuffer() override;
46 
47  // ---------------------------------------------------------------------- //
49  // ---------------------------------------------------------------------- //
50 
52  HD_API
53  HdDirtyBits GetInitialDirtyBitsMask() const override;
54 
56  HD_API
57  void Sync(HdSceneDelegate *sceneDelegate,
58  HdRenderParam *renderParam,
59  HdDirtyBits *dirtyBits) override;
60 
62  HD_API
63  void Finalize(HdRenderParam *renderParam) override;
64 
65  // ---------------------------------------------------------------------- //
67  // ---------------------------------------------------------------------- //
68 
76  virtual bool Allocate(GfVec3i const& dimensions,
77  HdFormat format,
78  bool multiSampled) = 0;
79 
81  virtual unsigned int GetWidth() const = 0;
83  virtual unsigned int GetHeight() const = 0;
85  virtual unsigned int GetDepth() const = 0;
87  virtual HdFormat GetFormat() const = 0;
89  virtual bool IsMultiSampled() const = 0;
90 
92  virtual void* Map() = 0;
94  virtual void Unmap() = 0;
96  virtual bool IsMapped() const = 0;
97 
103  virtual void Resolve() = 0;
104 
107  virtual bool IsConverged() const = 0;
108 
113  virtual VtValue GetResource(bool multiSampled) const {return VtValue();}
114 
115 protected:
117  virtual void _Deallocate() = 0;
118 };
119 
120 PXR_NAMESPACE_CLOSE_SCOPE
121 
122 #endif // PXR_IMAGING_HD_RENDER_BUFFER_H
virtual void Unmap()=0
Unmap the buffer. It is no longer safe to read from the buffer.
virtual VtValue GetResource(bool multiSampled) const
This optional API returns a (type-erased) resource that backs this render buffer.
Definition: renderBuffer.h:113
virtual bool IsMapped() const =0
Return whether the buffer is currently mapped by anybody.
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
virtual unsigned int GetWidth() const =0
Get the buffer's width.
HD_API void Finalize(HdRenderParam *renderParam) override
Deallocate before deletion.
virtual void _Deallocate()=0
Deallocate the buffer, freeing any owned resources.
Adapter class providing data exchange with the client scene graph.
virtual HdFormat GetFormat() const =0
Get the buffer's per-pixel format.
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Get allocation information from the scene delegate.
virtual bool IsConverged() const =0
Return whether the buffer is converged (whether the renderer is still adding samples or not).
virtual unsigned int GetHeight() const =0
Get the buffer's height.
virtual unsigned int GetDepth() const =0
Get the buffer's depth.
HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
Get initial invalidation state.
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:39
A render buffer is a handle to a data resource that can be rendered into, such as a 2d image for a dr...
Definition: renderBuffer.h:32
virtual void * Map()=0
Map the buffer for reading.
virtual bool Allocate(GfVec3i const &dimensions, HdFormat format, bool multiSampled)=0
Allocate a buffer.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:89
virtual bool IsMultiSampled() const =0
Get whether the buffer is multisampled.
virtual void Resolve()=0
Resolve the buffer so that reads reflect the latest writes.