Loading...
Searching...
No Matches
renderDelegate.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 EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
8#define EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/renderDelegate.h"
12#include "pxr/imaging/hd/version.h"
13#include "hdPrman/api.h"
14
15PXR_NAMESPACE_OPEN_SCOPE
16
17#define HDPRMAN_RENDER_SETTINGS_TOKENS \
18 ((rileyVariant, "ri:variant")) \
19 ((xpuDevices, "ri:xpudevices")) \
20 ((integrator, "integrator")) \
21 ((integratorName, "ri:integrator:name")) \
22 ((interactiveIntegrator, "interactiveIntegrator")) \
23 ((interactiveIntegratorTimeout, "interactiveIntegratorTimeout")) \
24 ((dataWindowNDC, "dataWindowNDC")) \
25 ((aspectRatioConformPolicy, "aspectRatioConformPolicy")) \
26 ((pixelAspectRatio, "pixelAspectRatio")) \
27 ((resolution, "resolution")) \
28 \
29 /* \deprecated Use disableMotionBlur instead */ \
30 ((instantaneousShutter, "instantaneousShutter")) \
31 ((disableMotionBlur, "disableMotionBlur")) \
32 ((disableDepthOfField, "disableDepthOfField")) \
33 ((shutterOpen, "shutter:open")) \
34 ((shutterClose, "shutter:close")) \
35 ((experimentalRenderSpec, "experimental:renderSpec")) \
36 ((renderVariant, "renderVariant")) \
37 ((xpuCpuConfig, "xpuCpuConfig")) \
38 ((xpuGpuConfig, "xpuGpuConfig")) \
39 ((delegateRenderProducts, "delegateRenderProducts")) \
40 ((projection, "projection")) \
41 ((projectionName, "ri:projection:name")) \
42 ((enableInteractive, "enableInteractive")) \
43 ((batchCommandLine, "batchCommandLine")) \
44 ((houdiniFrame, "houdini:frame")) \
45 ((checkpointInterval, "ri:checkpoint:interval")) \
46 ((pixelFilter, "ri:Ri:PixelFilterName")) \
47 ((pixelFilterWidth, "ri:Ri:PixelFilterWidth"))
48
49TF_DECLARE_PUBLIC_TOKENS(HdPrmanRenderSettingsTokens, HDPRMAN_API,
50 HDPRMAN_RENDER_SETTINGS_TOKENS);
51
52#define HDPRMAN_EXPERIMENTAL_RENDER_SPEC_TOKENS \
53 (renderProducts) \
54 (renderVars) \
55 (renderVarIndices) \
56 (name) \
57 (sourceName) \
58 (sourceType) \
59 (type) \
60 (params) \
61 (camera)
62
63TF_DECLARE_PUBLIC_TOKENS(HdPrmanExperimentalRenderSpecTokens, HDPRMAN_API,
64 HDPRMAN_EXPERIMENTAL_RENDER_SPEC_TOKENS);
65
66#define HDPRMAN_INTEGRATOR_TOKENS \
67 (PxrPathTracer) \
68 (PbsPathTracer) \
69 (PxrDirectLighting) \
70 (PxrUnified)
71
72#define HDPRMAN_PROJECTION_TOKENS \
73 (PxrPerspective) \
74 (PxrOrthographic)
75
76TF_DECLARE_PUBLIC_TOKENS(HdPrmanIntegratorTokens, HDPRMAN_API,
77 HDPRMAN_INTEGRATOR_TOKENS);
78
79#define HDPRMAN_RENDER_PRODUCT_TOKENS \
80 (productName) \
81 (productType) \
82 (orderedVars) \
83 (sourcePrim)
84
86 HdPrmanRenderProductTokens, HDPRMAN_API,
87 HDPRMAN_RENDER_PRODUCT_TOKENS);
88
89TF_DECLARE_PUBLIC_TOKENS(HdPrmanProjectionTokens, HDPRMAN_API,
90 HDPRMAN_PROJECTION_TOKENS);
91
92#define HDPRMAN_AOV_SETTINGS_TOKENS \
93 ((dataType, "dataType")) \
94 ((sourceName, "sourceName")) \
95 ((sourceType, "sourceType")) \
96 ((format, "aovDescriptor.format")) \
97 ((multiSampled, "aovDescriptor.multiSampled")) \
98 ((aovSettings, "aovDescriptor.aovSettings")) \
99 ((clearValue, "aovDescriptor.clearValue"))
100
102 HdPrmanAovSettingsTokens, HDPRMAN_API,
103 HDPRMAN_AOV_SETTINGS_TOKENS);
104
105#if PXR_VERSION <= 2308
106/* Aspect Ratio Conform Policy Tokens used on render settings prims
107 * Note that these mirror the conform policy tokens in UsdRenderTokens */
108#define HD_ASPECT_RATIO_CONFORM_POLICY \
109 (adjustApertureWidth) \
110 (adjustApertureHeight) \
111 (expandAperture) \
112 (cropAperture) \
113 (adjustPixelAspectRatio) \
114
115TF_DECLARE_PUBLIC_TOKENS(HdAspectRatioConformPolicyTokens,
116 HD_ASPECT_RATIO_CONFORM_POLICY);
117#endif
118
119class HdPrmanRenderDelegate : public HdRenderDelegate
120{
121public:
122 HDPRMAN_API
123 HdPrmanRenderDelegate(HdRenderSettingsMap const& settingsMap);
124 HDPRMAN_API
125 ~HdPrmanRenderDelegate() override;
126
127 // ------------------------------------------------------------------------
128 // Satisfying HdRenderDelegate
129 // ------------------------------------------------------------------------
130 HDPRMAN_API
131 HdRenderParam *GetRenderParam() const override;
132 HDPRMAN_API
133 const TfTokenVector & GetSupportedRprimTypes() const override;
134 HDPRMAN_API
135 const TfTokenVector & GetSupportedSprimTypes() const override;
136 HDPRMAN_API
137 const TfTokenVector & GetSupportedBprimTypes() const override;
138 HDPRMAN_API
139 HdResourceRegistrySharedPtr GetResourceRegistry() const override;
140
142 HDPRMAN_API
143 HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override;
144
145 HDPRMAN_API
146 VtDictionary GetRenderStats() const override;
147
148 HDPRMAN_API
149 HdRenderPassSharedPtr CreateRenderPass(
150 HdRenderIndex *index,
151 HdRprimCollection const& collection) override;
152 HDPRMAN_API
153 HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
154 SdfPath const& id) override;
155 HDPRMAN_API
156 void DestroyInstancer(HdInstancer *instancer) override;
157 HDPRMAN_API
158 HdRprim *CreateRprim(TfToken const& typeId,
159 SdfPath const& rprimId) override;
160 HDPRMAN_API
161 void DestroyRprim(HdRprim *rPrim) override;
162 HDPRMAN_API
163 HdSprim *CreateSprim(TfToken const& typeId,
164 SdfPath const& sprimId) override;
165 HDPRMAN_API
166 HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
167 HDPRMAN_API
168 void DestroySprim(HdSprim *sPrim) override;
169 HDPRMAN_API
170 HdBprim *CreateBprim(TfToken const& typeId,
171 SdfPath const& bprimId) override;
172 HDPRMAN_API
173 HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
174 HDPRMAN_API
175 void DestroyBprim(HdBprim *bPrim) override;
176
177 HDPRMAN_API
178 HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const override;
179
180 HDPRMAN_API
181 void CommitResources(HdChangeTracker *tracker) override;
182 HDPRMAN_API
183 TfToken GetMaterialBindingPurpose() const override;
184 HDPRMAN_API
185 TfTokenVector GetMaterialRenderContexts() const override;
186 HDPRMAN_API
187 TfTokenVector GetShaderSourceTypes() const override;
188
189#if HD_API_VERSION > 46
190 HDPRMAN_API
191 TfTokenVector GetRenderSettingsNamespaces() const override;
192#endif
193
194#if HD_API_VERSION >= 60
195 HDPRMAN_API
196 HdContainerDataSourceHandle GetCapabilities() const override;
197#endif
198
199 HDPRMAN_API
200 void SetRenderSetting(TfToken const &key, VtValue const &value) override;
201
202 HDPRMAN_API
203 bool IsPauseSupported() const override { return true; }
204 bool Pause() override;
205 bool Resume() override;
206
208 HDPRMAN_API
209 bool IsStopSupported() const override;
210
212 HDPRMAN_API
213 bool IsStopped() const override;
214
216 HDPRMAN_API
217 bool Stop(bool blocking) override;
218
220 HDPRMAN_API
221 bool Restart() override;
222
223#if HD_API_VERSION >= 55
224
230
231 HDPRMAN_API
232 void SetTerminalSceneIndex(
233 const HdSceneIndexBaseRefPtr &inputSceneIndex) override;
234
235 HDPRMAN_API
236 void Update() override;
237
238#if HD_API_VERSION >= 71
239 HDPRMAN_API
240 bool IsParallelSyncEnabled(const TfToken &primType) const override;
241#endif
242
243#endif
244
245 // ------------------------------------------------------------------------
246 // Public (non-virtual) API
247 // ------------------------------------------------------------------------
248
249 HDPRMAN_API
250 HdRenderSettingsMap GetRenderSettingsMap() const;
251
252 HDPRMAN_API
253 bool IsInteractive() const;
254
255 HDPRMAN_API
256 HdRenderIndex* GetRenderIndex() const;
257
258private:
259 // This class does not support copying.
260 HdPrmanRenderDelegate(const HdPrmanRenderDelegate &) = delete;
261 HdPrmanRenderDelegate &operator =(const HdPrmanRenderDelegate &) = delete;
262
263 void _Initialize();
264
265 std::string _GetRenderVariant(const HdRenderSettingsMap &settingsMap);
266
267 static
268 int _GetCpuConfig(const HdRenderSettingsMap &settingsMap);
269
270 static
271 std::vector<int> _GetGpuConfig(const HdRenderSettingsMap &settingsMap);
272
273protected:
274 static const TfTokenVector SUPPORTED_RPRIM_TYPES;
275 static const TfTokenVector SUPPORTED_SPRIM_TYPES;
276 static const TfTokenVector SUPPORTED_BPRIM_TYPES;
277
278 std::shared_ptr<class HdPrman_RenderParam> _renderParam;
279
280 // _rileySceneIndices holds on to _renderParam, so it needs to
281 // be after _renderParam so that we destroy it before _renderParam.
282 struct _RileySceneIndices;
283 std::unique_ptr<_RileySceneIndices> _rileySceneIndices;
284
285 HdResourceRegistrySharedPtr _resourceRegistry;
286 HdRenderPassSharedPtr _renderPass;
287 HdRenderSettingDescriptorList _settingDescriptors;
288};
289
290PXR_NAMESPACE_CLOSE_SCOPE
291
292#endif // EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:40
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
Definition: changeTracker.h:35
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:108
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
A named, semantic collection of objects.
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:38
Adapter class providing data exchange with the client scene graph.
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:35
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81
A bundle of state describing an AOV ("Arbitrary Output Variable") display channel.
Definition: aov.h:30
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440