All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
context.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 HDXPRMAN_CONTEXT_H
25 #define HDXPRMAN_CONTEXT_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/gf/matrix4d.h"
29 #include "pxr/imaging/hd/renderThread.h"
30 #include "hdPrman/context.h"
31 #include "framebuffer.h"
32 
33 #include "Riley.h"
34 
35 #include <condition_variable>
36 #include <mutex>
37 #include <thread>
38 #include <atomic>
39 
40 class RixRiCtl;
41 class RixParamList;
42 
43 PXR_NAMESPACE_OPEN_SCOPE
44 
45 class SdfPath;
46 class HdSceneDelegate;
47 class HdRenderDelegate;
48 
49 // HdxPrman_InteractiveContext supports interactive rendering workflows.
50 // Specifically, this means it provides:
51 //
52 // - a built-in Riley camera used for the RenderPass
53 // - a framebuffer for returning image results
54 // - concurrent, background rendering support.
55 //
56 struct HdxPrman_InteractiveContext : public HdPrman_Context
57 {
58  // A framebuffer to hold PRMan results.
59  // The d_hydra.so renderman display driver handles updates via IPC.
60  HdxPrmanFramebuffer framebuffer;
61 
62  // The viewport camera to use.
63  // Updated from render pass state.
64  riley::CameraId cameraId;
65 
66  // Count of scene lights. Maintained by the delegate.
67  int sceneLightCount;
68 
69  HdxPrman_InteractiveContext();
70  virtual ~HdxPrman_InteractiveContext();
71  // Start connection to Renderman.
72  void Begin(HdRenderDelegate *renderDelegate);
73  // End connection to Renderman, cancelling any ongoing render.
74  void End();
75  // Indicate whether fallback lights should be enabled.
76  void SetFallbackLightsEnabled(bool);
77 
78  // Request Riley (and the HdRenderThread) to stop.
79  void StopRender();
80 
81  // Render thread for background rendering.
82  HdRenderThread renderThread;
83 
84  // Scene version counter.
85  std::atomic<int> sceneVersion;
86 
87 private:
88  // The fallback light. HdxPrman_RenderPass calls
89  // SetFallbackLightsEnabled() to maintain visibility
90  // of the fallback light XOR other lights in the scene.
91  riley::LightInstanceId _fallbackLight;
92  riley::LightShaderId _fallbackLightShader;
93  RixParamList *_fallbackLightAttrs;
94  bool _fallbackLightEnabled;
95 };
96 
97 PXR_NAMESPACE_CLOSE_SCOPE
98 
99 #endif // HDXPRMAN_CONTEXT_H
A simple framebuffer used to receive display-driver output from PRMan.
Definition: framebuffer.h:42
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
HdRenderThread is a utility that specific render delegates can choose to use depending on their needs...
Definition: renderThread.h:146