Blender V4.3
render_task_delegate.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <pxr/imaging/hd/sceneDelegate.h>
8#include <pxr/imaging/hdx/renderSetupTask.h>
9
10#include "GPU_framebuffer.hh"
11#include "GPU_texture.hh"
12
13namespace blender::render::hydra {
14
15/* Delegate to create a render task with given camera, viewport and AOVs. */
16
17class RenderTaskDelegate : public pxr::HdSceneDelegate {
18 protected:
19 pxr::SdfPath task_id_;
20 pxr::HdxRenderTaskParams task_params_;
21 pxr::TfHashMap<pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash>
23
24 public:
25 RenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id);
26 ~RenderTaskDelegate() override = default;
27
28 /* Delegate methods */
29 pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override;
30 pxr::TfTokenVector GetTaskRenderTags(pxr::SdfPath const &id) override;
31 pxr::HdRenderBufferDescriptor GetRenderBufferDescriptor(pxr::SdfPath const &id) override;
32
33 pxr::HdTaskSharedPtr task();
34 void set_camera(pxr::SdfPath const &camera_id);
35 bool is_converged();
36 virtual void set_viewport(pxr::GfVec4d const &viewport);
37 virtual void add_aov(pxr::TfToken const &aov_key);
38 virtual void read_aov(pxr::TfToken const &aov_key, void *data);
39 virtual void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture);
40 virtual void bind();
41 virtual void unbind();
42
43 protected:
44 pxr::SdfPath buffer_id(pxr::TfToken const &aov_key) const;
45};
46
48 private:
49 GPUFrameBuffer *framebuffer_ = nullptr;
50 GPUTexture *tex_color_ = nullptr;
51 GPUTexture *tex_depth_ = nullptr;
52 unsigned int VAO_ = 0;
53
54 public:
56 ~GPURenderTaskDelegate() override;
57
58 void set_viewport(pxr::GfVec4d const &viewport) override;
59 void add_aov(pxr::TfToken const &aov_key) override;
60 void read_aov(pxr::TfToken const &aov_key, void *data) override;
61 void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture) override;
62 void bind() override;
63 void unbind() override;
64 GPUTexture *aov_texture(pxr::TfToken const &aov_key);
65};
66
67} // namespace blender::render::hydra
void add_aov(pxr::TfToken const &aov_key) override
void set_viewport(pxr::GfVec4d const &viewport) override
GPUTexture * aov_texture(pxr::TfToken const &aov_key)
void read_aov(pxr::TfToken const &aov_key, void *data) override
pxr::TfTokenVector GetTaskRenderTags(pxr::SdfPath const &id) override
RenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id)
virtual void set_viewport(pxr::GfVec4d const &viewport)
pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override
virtual void add_aov(pxr::TfToken const &aov_key)
pxr::SdfPath buffer_id(pxr::TfToken const &aov_key) const
void set_camera(pxr::SdfPath const &camera_id)
virtual void read_aov(pxr::TfToken const &aov_key, void *data)
pxr::HdRenderBufferDescriptor GetRenderBufferDescriptor(pxr::SdfPath const &id) override
pxr::TfHashMap< pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash > buffer_descriptors_