-
Notifications
You must be signed in to change notification settings - Fork 17
/
renderDelegate.cpp
217 lines (187 loc) · 5.13 KB
/
renderDelegate.cpp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//
// Copyright © 2024 Weta Digital Limited
//
// SPDX-License-Identifier: Apache-2.0
//
#include "debugCodes.h"
#include "renderBuffer.h"
#include "renderDelegate.h"
#include "renderParam.h"
#include "renderPass.h"
#include <pxr/imaging/hd/bprim.h>
#include <pxr/imaging/hd/camera.h>
#include <pxr/imaging/hd/rprim.h>
#include <pxr/imaging/hd/sprim.h>
PXR_NAMESPACE_OPEN_SCOPE
/// Supported Hydra prim types.
const TfTokenVector HdTriRenderDelegate::SUPPORTED_RPRIM_TYPES = {};
const TfTokenVector HdTriRenderDelegate::SUPPORTED_SPRIM_TYPES = {
HdPrimTypeTokens->camera
};
const TfTokenVector HdTriRenderDelegate::SUPPORTED_BPRIM_TYPES = {
HdPrimTypeTokens->renderBuffer
};
HdTriRenderDelegate::HdTriRenderDelegate()
: HdRenderDelegate()
{
_Setup();
}
HdTriRenderDelegate::HdTriRenderDelegate(const HdRenderSettingsMap& settingsMap)
: HdRenderDelegate(settingsMap)
{
_Setup();
}
HdTriRenderDelegate::~HdTriRenderDelegate()
{
// Clean resources.
_renderParam.reset();
}
TfTokenVector const&
HdTriRenderDelegate::GetSupportedRprimTypes() const
{
return SUPPORTED_RPRIM_TYPES;
}
TfTokenVector const&
HdTriRenderDelegate::GetSupportedSprimTypes() const
{
return SUPPORTED_SPRIM_TYPES;
}
TfTokenVector const&
HdTriRenderDelegate::GetSupportedBprimTypes() const
{
return SUPPORTED_BPRIM_TYPES;
}
HdRenderParam*
HdTriRenderDelegate::GetRenderParam() const
{
return _renderParam.get();
}
HdRenderSettingDescriptorList
HdTriRenderDelegate::GetRenderSettingDescriptors() const
{
return _settingDescriptors;
}
HdResourceRegistrySharedPtr
HdTriRenderDelegate::GetResourceRegistry() const
{
return _resourceRegistry;
}
HdRenderPassSharedPtr
HdTriRenderDelegate::CreateRenderPass(HdRenderIndex* index,
const HdRprimCollection& collection)
{
return HdRenderPassSharedPtr(new HdTriRenderPass(index, collection));
}
void
HdTriRenderDelegate::CommitResources(HdChangeTracker* tracker)
{
}
HdRprim*
HdTriRenderDelegate::CreateRprim(const TfToken& typeId, const SdfPath& rprimId)
{
TF_DEBUG(HDTRI_GENERAL)
.Msg("[%s] Create HdTri Rprim type %s id %s\n",
TF_FUNC_NAME().c_str(),
typeId.GetText(),
rprimId.GetText());
TF_CODING_ERROR(
"Unknown Rprim type=%s id=%s", typeId.GetText(), rprimId.GetText());
return nullptr;
}
void
HdTriRenderDelegate::DestroyRprim(HdRprim* rprim)
{
TF_DEBUG(HDTRI_GENERAL)
.Msg("[%s] Destroy Rprim id %s\n",
TF_FUNC_NAME().c_str(),
rprim->GetId().GetText());
delete rprim;
}
HdSprim*
HdTriRenderDelegate::CreateSprim(const TfToken& typeId, const SdfPath& sprimId)
{
if (typeId == HdPrimTypeTokens->camera) {
return new HdCamera(sprimId);
} else {
TF_CODING_ERROR(
"Unknown Sprim type=%s id=%s", typeId.GetText(), sprimId.GetText());
}
return nullptr;
}
HdSprim*
HdTriRenderDelegate::CreateFallbackSprim(const TfToken& typeId)
{
if (typeId == HdPrimTypeTokens->camera) {
return new HdCamera(SdfPath::EmptyPath());
} else {
TF_CODING_ERROR("Unknown Fallback Sprim type=%s id=%s",
typeId.GetText(),
typeId.GetText());
}
return nullptr;
}
void
HdTriRenderDelegate::DestroySprim(HdSprim* sprim)
{
delete sprim;
}
HdBprim*
HdTriRenderDelegate::CreateBprim(const TfToken& typeId, const SdfPath& bprimId)
{
if (typeId == HdPrimTypeTokens->renderBuffer) {
return new HdTriRenderBuffer(bprimId);
} else {
TF_CODING_ERROR("Unknown Bprim Type %s", typeId.GetText());
}
return nullptr;
}
HdBprim*
HdTriRenderDelegate::CreateFallbackBprim(const TfToken& typeId)
{
if (typeId == HdPrimTypeTokens->renderBuffer) {
return new HdTriRenderBuffer(SdfPath::EmptyPath());
} else {
TF_CODING_ERROR("Unknown Bprim Type %s", typeId.GetText());
}
return nullptr;
}
void
HdTriRenderDelegate::DestroyBprim(HdBprim* bprim)
{
delete bprim;
}
HdInstancer*
HdTriRenderDelegate::CreateInstancer(HdSceneDelegate* delegate,
const SdfPath& id)
{
TF_CODING_ERROR("Creating Instancer not supported id=%s", id.GetText());
return nullptr;
}
void
HdTriRenderDelegate::DestroyInstancer(HdInstancer* instancer)
{
TF_CODING_ERROR("Destroy instancer not supported");
}
HdAovDescriptor
HdTriRenderDelegate::GetDefaultAovDescriptor(const TfToken& aovName) const
{
if (aovName == HdAovTokens->color) {
return HdAovDescriptor(
HdFormatUNorm8Vec4, true, VtValue(GfVec4f(0.0f)));
} else if (aovName == HdAovTokens->depth) {
return HdAovDescriptor(HdFormatFloat32, false, VtValue(1.0f));
} else if (aovName == HdAovTokens->primId ||
aovName == HdAovTokens->instanceId ||
aovName == HdAovTokens->elementId) {
return HdAovDescriptor(HdFormatInt32, false, VtValue(-1));
}
return HdAovDescriptor();
}
void
HdTriRenderDelegate::_Setup()
{
_renderParam = std::unique_ptr<HdTriRenderParam>(new HdTriRenderParam());
_resourceRegistry =
std::shared_ptr<HdResourceRegistry>(new HdResourceRegistry());
}
PXR_NAMESPACE_CLOSE_SCOPE