Blender  V3.3
hydra/output_driver.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2022 NVIDIA Corporation
3  * Copyright 2022 Blender Foundation */
4 
5 #include "hydra/output_driver.h"
6 #include "hydra/render_buffer.h"
7 #include "hydra/session.h"
8 
10 
12  : _renderParam(renderParam)
13 {
14 }
15 
16 void HdCyclesOutputDriver::write_render_tile(const Tile &tile)
17 {
18  update_render_tile(tile);
19 
20  // Update convergence state of all render buffers
21  for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
22  if (const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(aovBinding.renderBuffer)) {
23  renderBuffer->SetConverged(true);
24  }
25  }
26 }
27 
28 bool HdCyclesOutputDriver::update_render_tile(const Tile &tile)
29 {
30  std::vector<float> pixels;
31 
32  for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
33  if (const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(aovBinding.renderBuffer)) {
34  if (aovBinding == _renderParam->GetDisplayAovBinding() && renderBuffer->IsResourceUsed()) {
35  continue; // Display AOV binding is already updated by Cycles display driver
36  }
37 
38  const HdFormat format = renderBuffer->GetFormat();
39  if (format == HdFormatInvalid) {
40  continue; // Skip invalid AOV bindings
41  }
42 
43  const size_t channels = HdGetComponentCount(format);
44  // Avoid extra copy by mapping render buffer directly when dimensions/format match the tile
45  if (tile.offset.x == 0 && tile.offset.y == 0 && tile.size.x == renderBuffer->GetWidth() &&
46  tile.size.y == renderBuffer->GetHeight() &&
47  (format >= HdFormatFloat32 && format <= HdFormatFloat32Vec4)) {
48  float *const data = static_cast<float *>(renderBuffer->Map());
49  TF_VERIFY(tile.get_pass_pixels(aovBinding.aovName.GetString(), channels, data));
50  renderBuffer->Unmap();
51  }
52  else {
53  pixels.resize(channels * tile.size.x * tile.size.y);
54  if (tile.get_pass_pixels(aovBinding.aovName.GetString(), channels, pixels.data())) {
55  const bool isId = aovBinding.aovName == HdAovTokens->primId ||
56  aovBinding.aovName == HdAovTokens->elementId ||
57  aovBinding.aovName == HdAovTokens->instanceId;
58 
59  renderBuffer->WritePixels(pixels.data(),
60  GfVec2i(tile.offset.x, tile.offset.y),
61  GfVec2i(tile.size.x, tile.size.y),
62  channels,
63  isId);
64  }
65  else {
66  // Do not warn on missing elementId, which is a standard AOV but is not implememted
67  if (aovBinding.aovName != HdAovTokens->elementId) {
68  TF_RUNTIME_ERROR("Could not find pass for AOV '%s'", aovBinding.aovName.GetText());
69  }
70  }
71  }
72  }
73  }
74 
75  return true;
76 }
77 
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
HdCyclesOutputDriver(HdCyclesSession *renderParam)
PXR_NS::HdRenderPassAovBinding GetDisplayAovBinding() const
Definition: hydra/session.h:42
const PXR_NS::HdRenderPassAovBindingVector & GetAovBindings() const
Definition: hydra/session.h:52
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE
Definition: hydra/config.h:17
ccl_global const KernelWorkTile * tile
format
Definition: logImageCore.h:38