Loading...
Searching...
No Matches
renderBuffer.h
1//
2// Copyright 2019 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_RENDER_BUFFER_H
8#define PXR_IMAGING_HD_ST_RENDER_BUFFER_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/gf/vec3i.h"
12#include "pxr/imaging/hdSt/api.h"
13#include "pxr/imaging/hdSt/textureUtils.h"
14#include "pxr/imaging/hd/renderBuffer.h"
15#include "pxr/imaging/hgi/hgi.h"
16#include "pxr/imaging/hgi/enums.h"
17#include "pxr/imaging/hgi/texture.h"
18
19PXR_NAMESPACE_OPEN_SCOPE
20
23using HdStDynamicUvTextureObjectSharedPtr =
24 std::shared_ptr<class HdStDynamicUvTextureObject>;
25
26class HdStRenderBuffer : public HdRenderBuffer
27{
28public:
29 HDST_API
30 HdStRenderBuffer(HdStResourceRegistry *resourceRegistry, SdfPath const& id);
31
32 HDST_API
33 ~HdStRenderBuffer() override;
34
35 HDST_API
36 void Sync(HdSceneDelegate *sceneDelegate,
37 HdRenderParam *renderParam,
38 HdDirtyBits *dirtyBits) override;
39
40 HDST_API
41 bool Allocate(GfVec3i const& dimensions,
42 HdFormat format,
43 bool multiSampled) override;
44
45 HDST_API
46 unsigned int GetWidth() const override;
47
48 HDST_API
49 unsigned int GetHeight() const override;
50
51 HDST_API
52 unsigned int GetDepth() const override;
53
54 HDST_API
55 HdFormat GetFormat() const override {return _format;}
56
57 HDST_API
58 bool IsMultiSampled() const override;
59
60 HDST_API
61 uint32_t GetMSAASampleCount() const;
62
67 HDST_API
68 void* Map() override;
69
71 HDST_API
72 void Unmap() override;
73
76 HDST_API
77 bool IsMapped() const override {
78 return _mappers.load() != 0;
79 }
80
84 HDST_API
85 bool IsConverged() const override {
86 return true;
87 }
88
90 HDST_API
91 void Resolve() override;
92
94 HDST_API
95 VtValue GetResource(bool multiSampled) const override;
96
100 HDST_API
101 HdStTextureIdentifier GetTextureIdentifier(
102 bool multiSampled);
103
104protected:
105 void _Deallocate() override;
106
107private:
108 // HdRenderBuffer::Allocate should take a scene delegate or
109 // resource registry so that we do not need to save it here.
110 HdStResourceRegistry * _resourceRegistry;
111
112 // Format saved here (somewhat redundantely) since the
113 // Hgi texture descriptor holds an HgiFormat instead of HdFormat.
114 HdFormat _format;
115
116 uint32_t _msaaSampleCount;
117
118 // The GPU texture resource
119 HdStDynamicUvTextureObjectSharedPtr _textureObject;
120
121 // The GPU multi-sample texture resource (optional)
122 HdStDynamicUvTextureObjectSharedPtr _textureMSAAObject;
123
124 // The number of callers mapping this buffer.
125 std::atomic<int> _mappers;
126 // Texels are temp captured into this buffer between map and unmap.
127 HdStTextureUtils::AlignedBuffer<uint8_t> _mappedBuffer;
128};
129
130PXR_NAMESPACE_CLOSE_SCOPE
131
132#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
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:33
virtual void Resolve()=0
Resolve the buffer so that reads reflect the latest writes.
virtual unsigned int GetWidth() const =0
Get the buffer's width.
virtual void * Map()=0
Map the buffer for reading.
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Get allocation information from the scene delegate.
virtual unsigned int GetHeight() const =0
Get the buffer's height.
virtual bool IsMapped() const =0
Return whether the buffer is currently mapped by anybody.
virtual void _Deallocate()=0
Deallocate the buffer, freeing any owned resources.
virtual void Unmap()=0
Unmap the buffer. It is no longer safe to read from the buffer.
virtual unsigned int GetDepth() const =0
Get the buffer's depth.
virtual bool IsConverged() const =0
Return whether the buffer is converged (whether the renderer is still adding samples or not).
virtual HdFormat GetFormat() const =0
Get the buffer's per-pixel format.
virtual bool IsMultiSampled() const =0
Get whether the buffer is multisampled.
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 Allocate(GfVec3i const &dimensions, HdFormat format, bool multiSampled)=0
Allocate a buffer.
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
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).
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90