renderPass.h
1 //
2 // Copyright 2016 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 PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_PASS_H
25 #define PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_PASS_H
26 
27 #include "pxr/pxr.h"
28 
29 #include "pxr/imaging/hd/aov.h"
30 #include "pxr/imaging/hd/renderPass.h"
31 #include "pxr/imaging/hd/renderThread.h"
32 #include "pxr/imaging/plugin/hdEmbree/renderer.h"
33 #include "pxr/imaging/plugin/hdEmbree/renderBuffer.h"
34 
35 #include "pxr/base/gf/matrix4d.h"
36 #include "pxr/base/gf/rect2i.h"
37 
38 #include <atomic>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
50 class HdEmbreeRenderPass final : public HdRenderPass
51 {
52 public:
59  HdRprimCollection const &collection,
60  HdRenderThread *renderThread,
61  HdEmbreeRenderer *renderer,
62  std::atomic<int> *sceneVersion);
63 
65  ~HdEmbreeRenderPass() override;
66 
67  // -----------------------------------------------------------------------
68  // HdRenderPass API
69 
72  bool IsConverged() const override;
73 
74 protected:
75 
76  // -----------------------------------------------------------------------
77  // HdRenderPass API
78 
83  void _Execute(HdRenderPassStateSharedPtr const& renderPassState,
84  TfTokenVector const &renderTags) override;
85 
87  void _MarkCollectionDirty() override {}
88 
89 private:
90  // A handle to the render thread.
91  HdRenderThread *_renderThread;
92 
93  // A handle to the global renderer.
94  HdEmbreeRenderer *_renderer;
95 
96  // A reference to the global scene version.
97  std::atomic<int> *_sceneVersion;
98 
99  // The last scene version we rendered with.
100  int _lastSceneVersion;
101 
102  // The last settings version we rendered with.
103  int _lastSettingsVersion;
104 
105  // The pixels written to. Like viewport in OpenGL,
106  // but coordinates are y-Down.
107  GfRect2i _dataWindow;
108 
109  // The view matrix: world space to camera space
110  GfMatrix4d _viewMatrix;
111  // The projection matrix: camera space to NDC space (with
112  // respect to the data window).
113  GfMatrix4d _projMatrix;
114 
115  // The list of aov buffers this renderpass should write to.
116  HdRenderPassAovBindingVector _aovBindings;
117 
118  // If no attachments are provided, provide an anonymous renderbuffer for
119  // color and depth output.
120  HdEmbreeRenderBuffer _colorBuffer;
121  HdEmbreeRenderBuffer _depthBuffer;
122 
123  // Were the color/depth buffer converged the last time we blitted them?
124  bool _converged;
125 };
126 
127 PXR_NAMESPACE_CLOSE_SCOPE
128 
129 #endif // PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_PASS_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:120
HdEmbreeRenderPass(HdRenderIndex *index, HdRprimCollection const &collection, HdRenderThread *renderThread, HdEmbreeRenderer *renderer, std::atomic< int > *sceneVersion)
Renderpass constructor.
void _MarkCollectionDirty() override
Update internal tracking to reflect a dirty collection.
Definition: renderPass.h:87
A 2D rectangle with integer coordinates.
Definition: rect2i.h:61
void _Execute(HdRenderPassStateSharedPtr const &renderPassState, TfTokenVector const &renderTags) override
Draw the scene with the bound renderpass state.
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection),...
Definition: renderPass.h:69
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
HdRenderPass represents a single render iteration, rendering a view of the scene (the HdRprimCollecti...
Definition: renderPass.h:50
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A named, semantic collection of objects.
bool IsConverged() const override
Determine whether the sample buffer has enough samples.
HdEmbreeRenderer implements a renderer on top of Embree's raycasting abilities.
Definition: renderer.h:54
~HdEmbreeRenderPass() override
Renderpass destructor.
HdRenderThread is a utility that specific render delegates can choose to use depending on their needs...
Definition: renderThread.h:146