All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderDelegate.h
1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef EXT_RMANPKG_24_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
25 #define EXT_RMANPKG_24_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/renderDelegate.h"
29 #include "hdPrman/api.h"
30 
31 #include <mutex>
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 class HdPrman_RenderParam;
36 class HdPrman_RenderPass;
37 struct HdPrman_Context;
38 struct HdPrman_InteractiveContext;
39 class RixParamList;
40 
42  HdPrmanRenderSettingsTokens,
43  ((integrator, "integrator"))
44  ((integratorName, "ri:integrator:name"))
45  ((interactiveIntegrator, "interactiveIntegrator"))
46  ((interactiveIntegratorTimeout, "interactiveIntegratorTimeout"))
47  ((dataWindowNDC, "dataWindowNDC"))
48  ((pixelAspectRatio, "pixelAspectRatio"))
49  ((resolution, "resolution"))
50  ((instantaneousShutter, "instantaneousShutter"))
51  ((shutterOpen, "shutter:open"))
52  ((shutterClose, "shutter:close"))
53 );
54 
55 #define HDPRMAN_INTEGRATOR_TOKENS \
56  (PxrPathTracer) \
57  (PbsPathTracer) \
58  (PxrDirectLighting)
59 
60 TF_DECLARE_PUBLIC_TOKENS(HdPrmanIntegratorTokens, HDPRMAN_API,
61  HDPRMAN_INTEGRATOR_TOKENS);
62 
63 class HdPrmanRenderDelegate : public HdRenderDelegate
64 {
65 public:
66  HDPRMAN_API
67  HdPrmanRenderDelegate(std::shared_ptr<HdPrman_Context> context);
68  HDPRMAN_API
69  HdPrmanRenderDelegate(std::shared_ptr<HdPrman_Context> context,
70  HdRenderSettingsMap const& settingsMap);
71  HDPRMAN_API
72  virtual ~HdPrmanRenderDelegate();
73 
74  // HdRenderDelegate API implementation.
75  HDPRMAN_API
76  HdRenderParam *GetRenderParam() const override;
77  HDPRMAN_API
78  const TfTokenVector & GetSupportedRprimTypes() const override;
79  HDPRMAN_API
80  const TfTokenVector & GetSupportedSprimTypes() const override;
81  HDPRMAN_API
82  const TfTokenVector & GetSupportedBprimTypes() const override;
83  HDPRMAN_API
84  HdResourceRegistrySharedPtr GetResourceRegistry() const override;
85 
87  HDPRMAN_API
88  HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override;
89 
90  HDPRMAN_API
91  HdRenderSettingsMap GetRenderSettingsMap() const;
92 
93  HDPRMAN_API
94  HdRenderPassSharedPtr CreateRenderPass(
95  HdRenderIndex *index,
96  HdRprimCollection const& collection) override;
97  HDPRMAN_API
98  HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
99  SdfPath const& id) override;
100  HDPRMAN_API
101  void DestroyInstancer(HdInstancer *instancer) override;
102  HDPRMAN_API
103  HdRprim *CreateRprim(TfToken const& typeId,
104  SdfPath const& rprimId) override;
105  HDPRMAN_API
106  void DestroyRprim(HdRprim *rPrim) override;
107  HDPRMAN_API
108  HdSprim *CreateSprim(TfToken const& typeId,
109  SdfPath const& sprimId) override;
110  HDPRMAN_API
111  HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
112  HDPRMAN_API
113  void DestroySprim(HdSprim *sPrim) override;
114  HDPRMAN_API
115  HdBprim *CreateBprim(TfToken const& typeId,
116  SdfPath const& bprimId) override;
117  HDPRMAN_API
118  HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
119  HDPRMAN_API
120  void DestroyBprim(HdBprim *bPrim) override;
121 
122  HDPRMAN_API
123  HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const override;
124 
125  HDPRMAN_API
126  void CommitResources(HdChangeTracker *tracker) override;
127  HDPRMAN_API
128  TfToken GetMaterialBindingPurpose() const override;
129 #if HD_API_VERSION < 41
130  HDPRMAN_API
131  TfToken GetMaterialNetworkSelector() const override;
132 #else
133  HDPRMAN_API
134  TfTokenVector GetMaterialRenderContexts() const override;
135 #endif
136  HDPRMAN_API
137  TfTokenVector GetShaderSourceTypes() const override;
138 
139  HDPRMAN_API
140  void SetRenderSetting(TfToken const &key, VtValue const &value) override;
141 
146  HDPRMAN_API
147  bool IsPauseSupported() const override { return false; }
148 
150  HDPRMAN_API
151  bool IsStopSupported() const override;
152 
154  HDPRMAN_API
155  bool Stop() override;
156 
158  HDPRMAN_API
159  bool Restart() override;
160 
161 private:
162  // This class does not support copying.
163  HdPrmanRenderDelegate(const HdPrmanRenderDelegate &) = delete;
164  HdPrmanRenderDelegate &operator =(const HdPrmanRenderDelegate &) = delete;
165 
166  void _Initialize();
167 
168  enum RenderMode
169  {
170  Interactive = 0,
171  Offline
172  };
173  RenderMode _renderMode;
174 
175  bool _IsInteractive() const {
176  return (_renderMode == RenderMode::Interactive);
177  }
178 
179 protected:
180  static const TfTokenVector SUPPORTED_RPRIM_TYPES;
181  static const TfTokenVector SUPPORTED_SPRIM_TYPES;
182  static const TfTokenVector SUPPORTED_BPRIM_TYPES;
183 
184  std::shared_ptr<HdPrman_Context> _context;
185  std::shared_ptr<HdPrman_RenderParam> _renderParam;
186  HdResourceRegistrySharedPtr _resourceRegistry;
187  HdRenderPassSharedPtr _renderPass;
188  HdRenderSettingDescriptorList _settingDescriptors;
189 };
190 
191 PXR_NAMESPACE_CLOSE_SCOPE
192 
193 #endif // EXT_RMANPKG_24_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_DELEGATE_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:116
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine...
Definition: changeTracker.h:50
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:124
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
#define TF_DEFINE_PRIVATE_TOKENS(key, seq)
Macro to define private tokens.
Definition: staticTokens.h:129
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:68
Adapter class providing data exchange with the client scene graph.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:52
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:56
A bundle of state describing an AOV (&quot;Arbitrary Output Variable&quot;) display channel.
Definition: aov.h:46
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168