Blender V4.3
render_buffer.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 NVIDIA Corporation
2 * SPDX-FileCopyrightText: 2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: Apache-2.0 */
5
6#pragma once
7
8#include "hydra/config.h"
9
10#include <pxr/imaging/hd/renderBuffer.h>
11
13
14class HdCyclesRenderBuffer final : public PXR_NS::HdRenderBuffer {
15 public:
16 HdCyclesRenderBuffer(const PXR_NS::SdfPath &bprimId);
17 ~HdCyclesRenderBuffer() override;
18
19 void Finalize(PXR_NS::HdRenderParam *renderParam) override;
20
21 bool Allocate(const PXR_NS::GfVec3i &dimensions,
22 PXR_NS::HdFormat format,
23 bool multiSampled) override;
24
25 unsigned int GetWidth() const override
26 {
27 return _width;
28 }
29
30 unsigned int GetHeight() const override
31 {
32 return _height;
33 }
34
35 unsigned int GetDepth() const override
36 {
37 return 1u;
38 }
39
40 PXR_NS::HdFormat GetFormat() const override
41 {
42 return _format;
43 }
44
45 bool IsMultiSampled() const override
46 {
47 return false;
48 }
49
50 void *Map() override;
51
52 void Unmap() override;
53
54 bool IsMapped() const override;
55
56 void Resolve() override;
57
58 bool IsConverged() const override;
59
60 void SetConverged(bool converged);
61
62 bool IsResourceUsed() const;
63
64 PXR_NS::VtValue GetResource(bool multiSampled = false) const override;
65
66 void SetResource(const PXR_NS::VtValue &resource);
67
68 void WritePixels(const float *pixels,
69 const PXR_NS::GfVec2i &offset,
70 const PXR_NS::GfVec2i &dims,
71 int channels,
72 bool isId = false);
73
74 private:
75 void _Deallocate() override;
76
77 unsigned int _width = 0u;
78 unsigned int _height = 0u;
79 PXR_NS::HdFormat _format = PXR_NS::HdFormatInvalid;
80 size_t _dataSize = 0;
81
82 std::vector<uint8_t> _data;
83 PXR_NS::VtValue _resource;
84 mutable std::atomic_bool _resourceUsed = false;
85
86 std::atomic_int _mapped = 0;
87 std::atomic_bool _converged = false;
88};
89
bool IsConverged() const override
void Resolve() override
void SetConverged(bool converged)
HdCyclesRenderBuffer(const PXR_NS::SdfPath &bprimId)
bool IsResourceUsed() const
unsigned int GetWidth() const override
bool IsMultiSampled() const override
bool Allocate(const PXR_NS::GfVec3i &dimensions, PXR_NS::HdFormat format, bool multiSampled) override
unsigned int GetHeight() const override
~HdCyclesRenderBuffer() override
bool IsMapped() const override
void SetResource(const PXR_NS::VtValue &resource)
void Unmap() override
PXR_NS::HdFormat GetFormat() const override
void * Map() override
void Finalize(PXR_NS::HdRenderParam *renderParam) override
unsigned int GetDepth() const override
void WritePixels(const float *pixels, const PXR_NS::GfVec2i &offset, const PXR_NS::GfVec2i &dims, int channels, bool isId=false)
PXR_NS::VtValue GetResource(bool multiSampled=false) const override
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE
format