forked from wetadigital/USDPluginExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderBuffer.h
81 lines (59 loc) · 2.15 KB
/
renderBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Copyright © 2023 Weta Digital Limited
//
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <pxr/imaging/hd/renderBuffer.h>
#include <pxr/base/gf/vec3i.h>
PXR_NAMESPACE_OPEN_SCOPE
/// \class HdTriRenderBuffer
///
/// A block of memory which we are rendering into.
class HdTriRenderBuffer : public HdRenderBuffer
{
public:
HdTriRenderBuffer(const SdfPath& bprimId);
/// Allocate a new buffer with the given dimensions and format.
virtual bool Allocate(const GfVec3i& dimensions,
HdFormat format,
bool multiSampled) override;
/// Accessor for buffer width.
virtual unsigned int GetWidth() const override;
/// Accessor for buffer height.
virtual unsigned int GetHeight() const override;
/// Accessor for buffer depth.
virtual unsigned int GetDepth() const override;
/// Accessor for buffer format.
virtual HdFormat GetFormat() const override;
/// Accessor for the buffer multisample state.
virtual bool IsMultiSampled() const override;
/// Map the buffer for reading/writing. The control flow should be Map(),
/// before any I/O, followed by memory access, followed by Unmap() when
/// done.
virtual void* Map() override;
/// Unmap the buffer.
virtual void Unmap() override;
/// Return whether any clients have this buffer mapped currently.
virtual bool IsMapped() const override;
/// Is the buffer converged?
virtual bool IsConverged() const override;
/// Set the convergence.
void SetConverged(bool converged);
/// Resolve the sample buffer into final values.
virtual void Resolve() override;
private:
// Release any allocated resources.
virtual void _Deallocate() override;
// Buffer dimensions.
GfVec3i _dimensions = GfVec3i(0, 0, 0);
// Buffer format.
HdFormat _format = HdFormatInvalid;
// The actual buffer of bytes.
std::vector<uint8_t> _buffer;
// The number of callers mapping this buffer.
std::atomic<int> _mappers{ 0 };
// Whether the buffer has been marked as converged.
std::atomic<bool> _converged{ false };
};
PXR_NAMESPACE_CLOSE_SCOPE