Blender V5.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/dataSource.h>
8#include <pxr/imaging/hd/renderIndex.h>
9#include <pxr/imaging/hd/retainedSceneIndex.h>
10#include <pxr/imaging/hd/task.h>
11#include <pxr/imaging/hdx/renderSetupTask.h>
12
13#include "GPU_framebuffer.hh"
14#include "GPU_texture.hh"
15
16namespace blender::render::hydra {
17
18/* Registers a HdxRenderTask with the render index as a task prim. */
19
21 : public pxr::HdTypedSampledDataSource<pxr::HdxRenderTaskParams> {
22 public:
24
25 pxr::HdxRenderTaskParams params;
26
27 pxr::VtValue GetValue(Time /*shutterOffset*/) override
28 {
29 return pxr::VtValue(params);
30 }
31 pxr::HdxRenderTaskParams GetTypedValue(Time /*shutterOffset*/) override
32 {
33 return params;
34 }
36 Time /*end*/,
37 std::vector<Time> * /*sampleTimes*/) override
38 {
39 return false;
40 }
41};
42
44 protected:
45 pxr::HdRenderIndex *render_index_ = nullptr;
46 pxr::HdRetainedSceneIndexRefPtr task_scene_index_;
47 pxr::SdfPath base_id_;
48 pxr::SdfPath task_id_;
49 RenderTaskParamsDataSource::Handle task_params_ds_ = RenderTaskParamsDataSource::New();
50 pxr::HdxRenderTaskParams &task_params_ = task_params_ds_->params;
51 pxr::TfHashMap<pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash>
53
54 public:
55 RenderTaskDelegate(pxr::HdRenderIndex *render_index,
56 pxr::HdRetainedSceneIndexRefPtr task_scene_index,
57 pxr::SdfPath const &base_id);
58 virtual ~RenderTaskDelegate() = default;
59
60 pxr::HdTaskSharedPtr task();
61 void set_camera(pxr::SdfPath const &camera_id);
62 bool is_converged();
63 virtual void set_viewport(pxr::GfVec4d const &viewport);
64 virtual void add_aov(pxr::TfToken const &aov_key);
65 virtual void read_aov(pxr::TfToken const &aov_key, void *data);
66 pxr::HdRenderBuffer *get_aov_buffer(pxr::TfToken const &aov_key);
67 virtual void bind();
68 virtual void unbind();
69
70 protected:
71 pxr::SdfPath buffer_id(pxr::TfToken const &aov_key) const;
72
73 void publish_task();
74 void dirty_task_params();
75 void publish_buffer(pxr::SdfPath const &buf_id, pxr::HdRenderBufferDescriptor const &desc);
76};
77
79 private:
80 gpu::FrameBuffer *framebuffer_ = nullptr;
81 gpu::Texture *tex_color_ = nullptr;
82 gpu::Texture *tex_depth_ = nullptr;
83 unsigned int VAO_ = 0;
84
85 public:
87 ~GPURenderTaskDelegate() override;
88
89 void set_viewport(pxr::GfVec4d const &viewport) override;
90 void add_aov(pxr::TfToken const &aov_key) override;
91 void read_aov(pxr::TfToken const &aov_key, void *data) override;
92 void bind() override;
93 void unbind() override;
94 gpu::Texture *get_aov_texture(pxr::TfToken const &aov_key);
95};
96
97} // namespace blender::render::hydra
#define final(a, b, c)
Definition BLI_hash_c.hh:21
void add_aov(pxr::TfToken const &aov_key) override
void set_viewport(pxr::GfVec4d const &viewport) override
gpu::Texture * get_aov_texture(pxr::TfToken const &aov_key)
RenderTaskDelegate(pxr::HdRenderIndex *render_index, pxr::HdRetainedSceneIndexRefPtr task_scene_index, pxr::SdfPath const &base_id)
void read_aov(pxr::TfToken const &aov_key, void *data) override
pxr::HdRenderBuffer * get_aov_buffer(pxr::TfToken const &aov_key)
virtual void set_viewport(pxr::GfVec4d const &viewport)
RenderTaskDelegate(pxr::HdRenderIndex *render_index, pxr::HdRetainedSceneIndexRefPtr task_scene_index, pxr::SdfPath const &base_id)
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)
void publish_buffer(pxr::SdfPath const &buf_id, pxr::HdRenderBufferDescriptor const &desc)
virtual void read_aov(pxr::TfToken const &aov_key, void *data)
pxr::HdRetainedSceneIndexRefPtr task_scene_index_
RenderTaskParamsDataSource::Handle task_params_ds_
pxr::TfHashMap< pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash > buffer_descriptors_
bool GetContributingSampleTimesForInterval(Time, Time, std::vector< Time > *) override
HD_DECLARE_DATASOURCE(RenderTaskParamsDataSource)
pxr::HdxRenderTaskParams GetTypedValue(Time) override
BMesh const char void * data