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 ((integrator, "integrator")) \
19 ((integratorName, "ri:integrator:name")) \
20 ((interactiveIntegrator, "interactiveIntegrator")) \
21 ((interactiveIntegratorTimeout, "interactiveIntegratorTimeout")) \
22 ((dataWindowNDC, "dataWindowNDC")) \
23 ((aspectRatioConformPolicy, "aspectRatioConformPolicy")) \
24 ((pixelAspectRatio, "pixelAspectRatio")) \
25 ((resolution, "resolution")) \
26 \
27 /* \deprecated Use disableMotionBlur instead */ \
28 ((instantaneousShutter, "instantaneousShutter")) \
29 ((disableMotionBlur, "disableMotionBlur")) \
30 ((disableDepthOfField, "disableDepthOfField")) \
31 ((shutterOpen, "shutter:open")) \
32 ((shutterClose, "shutter:close")) \
33 ((experimentalRenderSpec, "experimental:renderSpec")) \
34 ((delegateRenderProducts, "delegateRenderProducts")) \
35 ((projection, "projection")) \
36 ((projectionName, "ri:projection:name")) \
37 ((enableInteractive, "enableInteractive")) \
38 ((batchCommandLine, "batchCommandLine")) \
39 ((houdiniFrame, "houdini:frame")) \
40 ((checkpointInterval, "ri:checkpoint:interval")) \
41 ((pixelFilter, "ri:Ri:PixelFilterName")) \
42 ((pixelFilterWidth, "ri:Ri:PixelFilterWidth")) \
43 ((worldOrigin, "ri:trace:worldorigin")) \
44 ((worldOffset, "ri:trace:worldoffset"))
45
46TF_DECLARE_PUBLIC_TOKENS(HdPrmanRenderSettingsTokens, HDPRMAN_API,
47 HDPRMAN_RENDER_SETTINGS_TOKENS);
48
49#define HDPRMAN_EXPERIMENTAL_RENDER_SPEC_TOKENS \
50 (renderProducts) \
51 (renderVars) \
52 (renderVarIndices) \
53 (name) \
54 (sourceName) \
55 (sourceType) \
56 (type) \
57 (params) \
58 (camera)
59
60TF_DECLARE_PUBLIC_TOKENS(HdPrmanExperimentalRenderSpecTokens, HDPRMAN_API,
61 HDPRMAN_EXPERIMENTAL_RENDER_SPEC_TOKENS);
62
63#define HDPRMAN_INTEGRATOR_TOKENS \
64 (PxrPathTracer) \
65 (PbsPathTracer) \
66 (PxrDirectLighting) \
67 (PxrUnified)
68
69#define HDPRMAN_PROJECTION_TOKENS \
70 (PxrPerspective) \
71 (PxrOrthographic)
72
73TF_DECLARE_PUBLIC_TOKENS(HdPrmanIntegratorTokens, HDPRMAN_API,
74 HDPRMAN_INTEGRATOR_TOKENS);
75
76#define HDPRMAN_RENDER_PRODUCT_TOKENS \
77 (productName) \
78 (productType) \
79 (orderedVars) \
80 (sourcePrim) \
81 (idMap)
82
84 HdPrmanRenderProductTokens, HDPRMAN_API,
85 HDPRMAN_RENDER_PRODUCT_TOKENS);
86
87TF_DECLARE_PUBLIC_TOKENS(HdPrmanProjectionTokens, HDPRMAN_API,
88 HDPRMAN_PROJECTION_TOKENS);
89
90#define HDPRMAN_AOV_SETTINGS_TOKENS \
91 ((dataType, "dataType")) \
92 ((sourceName, "sourceName")) \
93 ((sourceType, "sourceType")) \
94 ((format, "aovDescriptor.format")) \
95 ((multiSampled, "aovDescriptor.multiSampled")) \
96 ((aovSettings, "aovDescriptor.aovSettings")) \
97 ((clearValue, "aovDescriptor.clearValue"))
98
100 HdPrmanAovSettingsTokens, HDPRMAN_API,
101 HDPRMAN_AOV_SETTINGS_TOKENS);
102
103#if PXR_VERSION <= 2308
104/* Aspect Ratio Conform Policy Tokens used on render settings prims
105 * Note that these mirror the conform policy tokens in UsdRenderTokens */
106#define HD_ASPECT_RATIO_CONFORM_POLICY \
107 (adjustApertureWidth) \
108 (adjustApertureHeight) \
109 (expandAperture) \
110 (cropAperture) \
111 (adjustPixelAspectRatio) \
112
113TF_DECLARE_PUBLIC_TOKENS(HdAspectRatioConformPolicyTokens,
114 HD_ASPECT_RATIO_CONFORM_POLICY);
115#endif
116
117class HdPrmanRenderDelegate : public HdRenderDelegate
118{
119public:
120 HDPRMAN_API
121 HdPrmanRenderDelegate(HdRenderSettingsMap const& settingsMap,
122 TfToken const& rileyVariant,
123 int xpuCpuConfig,
124 std::vector<int> xpuGpuConfig);
125 HDPRMAN_API
126 ~HdPrmanRenderDelegate() override;
127
128 // ------------------------------------------------------------------------
129 // Satisfying HdRenderDelegate
130 // ------------------------------------------------------------------------
131 HDPRMAN_API
132 HdRenderParam *GetRenderParam() const override;
133 HDPRMAN_API
134 const TfTokenVector & GetSupportedRprimTypes() const override;
135 HDPRMAN_API
136 const TfTokenVector & GetSupportedSprimTypes() const override;
137 HDPRMAN_API
138 const TfTokenVector & GetSupportedBprimTypes() const override;
139 HDPRMAN_API
140 HdResourceRegistrySharedPtr GetResourceRegistry() const override;
141
143 HDPRMAN_API
144 HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override;
145
146 HDPRMAN_API
147 VtDictionary GetRenderStats() const override;
148
149 HDPRMAN_API
150 HdRenderPassSharedPtr CreateRenderPass(
151 HdRenderIndex *index,
152 HdRprimCollection const& collection) override;
153 HDPRMAN_API
154 HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
155 SdfPath const& id) override;
156 HDPRMAN_API
157 void DestroyInstancer(HdInstancer *instancer) override;
158 HDPRMAN_API
159 HdRprim *CreateRprim(TfToken const& typeId,
160 SdfPath const& rprimId) override;
161 HDPRMAN_API
162 void DestroyRprim(HdRprim *rPrim) override;
163 HDPRMAN_API
164 HdSprim *CreateSprim(TfToken const& typeId,
165 SdfPath const& sprimId) override;
166 HDPRMAN_API
167 HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
168 HDPRMAN_API
169 void DestroySprim(HdSprim *sPrim) override;
170 HDPRMAN_API
171 HdBprim *CreateBprim(TfToken const& typeId,
172 SdfPath const& bprimId) override;
173 HDPRMAN_API
174 HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
175 HDPRMAN_API
176 void DestroyBprim(HdBprim *bPrim) override;
177
178 HDPRMAN_API
179 HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const override;
180
181 HDPRMAN_API
182 void CommitResources(HdChangeTracker *tracker) override;
183 HDPRMAN_API
184 TfToken GetMaterialBindingPurpose() const override;
185 HDPRMAN_API
186 TfTokenVector GetMaterialRenderContexts() const override;
187 HDPRMAN_API
188 TfTokenVector GetShaderSourceTypes() const override;
189
190#if HD_API_VERSION > 46
191 HDPRMAN_API
192 TfTokenVector GetRenderSettingsNamespaces() const override;
193#endif
194
195#if HD_API_VERSION >= 60
196 HDPRMAN_API
197 HdContainerDataSourceHandle GetCapabilities() const override;
198#endif
199
200 HDPRMAN_API
201 void SetRenderSetting(TfToken const &key, VtValue const &value) override;
202
203 HDPRMAN_API
204 bool IsPauseSupported() const override { return true; }
205 bool Pause() override;
206 bool Resume() override;
207
209 HDPRMAN_API
210 bool IsStopSupported() const override;
211
213 HDPRMAN_API
214 bool IsStopped() const override;
215
217 HDPRMAN_API
218 bool Stop(bool blocking) override;
219
221 HDPRMAN_API
222 bool Restart() override;
223
224#if HD_API_VERSION >= 55
225
231
232 HDPRMAN_API
233 void SetTerminalSceneIndex(
234 const HdSceneIndexBaseRefPtr &inputSceneIndex) override;
235
236 HDPRMAN_API
237 void Update() override;
238
239#if HD_API_VERSION >= 71
240 HDPRMAN_API
241 bool IsParallelSyncEnabled(const TfToken &primType) const override;
242#endif
243
244#endif
245
246 // ------------------------------------------------------------------------
247 // Public (non-virtual) API
248 // ------------------------------------------------------------------------
249
250 HDPRMAN_API
251 HdRenderSettingsMap GetRenderSettingsMap() const;
252
253 HDPRMAN_API
254 bool IsInteractive() const;
255
256 HDPRMAN_API
257 HdRenderIndex* GetRenderIndex() const;
258
259private:
260 // This class does not support copying.
261 HdPrmanRenderDelegate(const HdPrmanRenderDelegate &) = delete;
262 HdPrmanRenderDelegate &operator =(const HdPrmanRenderDelegate &) = delete;
263
264 void _Initialize();
265
266 std::string _GetRenderVariant(const HdRenderSettingsMap &settingsMap);
267
268 static
269 int _GetCpuConfig(const HdRenderSettingsMap &settingsMap);
270
271 static
272 std::vector<int> _GetGpuConfig(const HdRenderSettingsMap &settingsMap);
273
274protected:
275 static const TfTokenVector SUPPORTED_RPRIM_TYPES;
276 static const TfTokenVector SUPPORTED_SPRIM_TYPES;
277 static const TfTokenVector SUPPORTED_BPRIM_TYPES;
278
279 std::shared_ptr<class HdPrman_RenderParam> _renderParam;
280
281 // _rileySceneIndices holds on to _renderParam, so it needs to
282 // be after _renderParam so that we destroy it before _renderParam.
283 struct _RileySceneIndices;
284 std::unique_ptr<_RileySceneIndices> _rileySceneIndices;
285
286 HdResourceRegistrySharedPtr _resourceRegistry;
287 HdRenderPassSharedPtr _renderPass;
288 HdRenderSettingDescriptorList _settingDescriptors;
289};
290
291PXR_NAMESPACE_CLOSE_SCOPE
292
293#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:52
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92
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