From 05d7e0651d2c4c3b90459b4474f2c6ba851ace88 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 25 Jul 2023 14:24:00 +0300 Subject: [PATCH 1/9] Initial --- source/blender/render/hydra/final_engine.cc | 36 +++++--- source/blender/render/hydra/final_engine.h | 3 + .../render/hydra/render_task_delegate.cc | 84 +++++++++++++------ .../render/hydra/render_task_delegate.h | 18 ++-- .../blender/render/hydra/viewport_engine.cc | 4 +- 5 files changed, 102 insertions(+), 43 deletions(-) diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 68e763736afc..258336d6e7b8 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -14,6 +14,10 @@ #include "camera.h" #include "final_engine.h" +PXR_NAMESPACE_OPEN_SCOPE +TF_DEFINE_PRIVATE_TOKENS(tokens_, (worldCoordinate)); +PXR_NAMESPACE_CLOSE_SCOPE + namespace blender::render::hydra { /* FinalEngine implementation */ @@ -47,8 +51,19 @@ void FinalEngine::render(Depsgraph *depsgraph) light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1])); } - render_task_delegate_->add_aov(pxr::HdAovTokens->color); - render_task_delegate_->add_aov(pxr::HdAovTokens->depth); + aovs_map_.add_new("Combined", pxr::HdAovTokens->color); + aovs_map_.add_new("Depth", pxr::HdAovTokens->depth); + aovs_map_.add_new("Normal", pxr::HdAovTokens->normal); + aovs_map_.add_new("Position", pxr::tokens_->worldCoordinate); + + RenderResult *result = RE_engine_get_result(bl_engine_); + RenderLayer *layer = (RenderLayer *)result->layers.first; + for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) { + pxr::TfToken *aov_token = aovs_map_.lookup_ptr(pass->name); + if (aov_token) { + render_task_delegate_->add_aov(*aov_token); + } + } render_task_delegate_->bind(); @@ -59,7 +74,10 @@ void FinalEngine::render(Depsgraph *depsgraph) } tasks.push_back(light_tasks_delegate_->simple_task()); } - tasks.push_back(render_task_delegate_->task()); + if (bl_engine_->type->flag & RE_USE_GPU_CONTEXT) { + tasks.push_back(static_cast(render_task_delegate_.get())->aov_task()); + } + tasks.push_back(render_task_delegate_->render_task()); engine_->Execute(render_index_.get(), &tasks); char elapsed_time[32]; @@ -79,7 +97,7 @@ void FinalEngine::render(Depsgraph *depsgraph) std::string("Render Time: ") + elapsed_time + " | Done: " + std::to_string(int(percent_done)) + "%"); - if (render_task_delegate_->is_converged()) { + if (render_task_delegate_->is_converged(render_task_delegate_->render_task())) { break; } @@ -104,14 +122,10 @@ void FinalEngine::update_render_result() /* TODO: only for the first render layer */ RenderLayer *layer = (RenderLayer *)result->layers.first; for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) { - pxr::TfToken aov_key; - if (STREQ(pass->name, "Combined")) { - aov_key = pxr::HdAovTokens->color; + pxr::TfToken *aov_token = aovs_map_.lookup_ptr(pass->name); + if (aov_token) { + render_task_delegate_->read_aov(*aov_token, pass->ibuf->float_buffer.data); } - else if (STREQ(pass->name, "Depth")) { - aov_key = pxr::HdAovTokens->depth; - } - render_task_delegate_->read_aov(aov_key, pass->ibuf->float_buffer.data); } RE_engine_end_result(bl_engine_, result, false, false, false); diff --git a/source/blender/render/hydra/final_engine.h b/source/blender/render/hydra/final_engine.h index 81155629a010..52ff479e4b36 100644 --- a/source/blender/render/hydra/final_engine.h +++ b/source/blender/render/hydra/final_engine.h @@ -20,6 +20,9 @@ class FinalEngine : public Engine { std::string scene_name_; std::string layer_name_; pxr::GfVec2i resolution_; + + /* Map supported Blender AOV to corresponded Hydra AOV token */ + Map aovs_map_; }; } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index 278f6e99a203..133458423996 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -17,17 +17,17 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id) : pxr::HdSceneDelegate(parent_index, delegate_id) { - task_id_ = GetDelegateID().AppendElementString("task"); - GetRenderIndex().InsertTask(this, task_id_); + render_task_id_ = GetDelegateID().AppendElementString("renderTask"); + GetRenderIndex().InsertTask(this, render_task_id_); - task_params_.enableLighting = true; - task_params_.alphaThreshold = 0.1f; + render_task_params_.enableLighting = true; + render_task_params_.alphaThreshold = 0.1f; } pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken const &key) { if (key == pxr::HdTokens->params) { - return pxr::VtValue(task_params_); + return pxr::VtValue(render_task_params_); } if (key == pxr::HdTokens->collection) { return pxr::VtValue(pxr::HdRprimCollection( @@ -46,33 +46,33 @@ pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr: return buffer_descriptors_[id]; } -pxr::HdTaskSharedPtr RenderTaskDelegate::task() +pxr::HdTaskSharedPtr RenderTaskDelegate::render_task() { - return GetRenderIndex().GetTask(task_id_); + return GetRenderIndex().GetTask(render_task_id_); } void RenderTaskDelegate::set_camera(pxr::SdfPath const &camera_id) { - if (task_params_.camera == camera_id) { + if (render_task_params_.camera == camera_id) { return; } - task_params_.camera = camera_id; - GetRenderIndex().GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); + render_task_params_.camera = camera_id; + GetRenderIndex().GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); } -bool RenderTaskDelegate::is_converged() +bool RenderTaskDelegate::is_converged(pxr::HdTaskSharedPtr task) { - return ((pxr::HdxRenderTask *)task().get())->IsConverged(); + return ((pxr::HdxRenderTask *)task.get())->IsConverged(); } void RenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) { - if (task_params_.viewport == viewport) { + if (render_task_params_.viewport == viewport) { return; } auto &render_index = GetRenderIndex(); - task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); + render_task_params_.viewport = viewport; + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); int w = viewport[2] - viewport[0]; int h = viewport[3] - viewport[1]; @@ -93,8 +93,12 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) pxr::HdAovDescriptor aov_desc = render_index.GetRenderDelegate()->GetDefaultAovDescriptor( aov_key); - int w = task_params_.viewport[2] - task_params_.viewport[0]; - int h = task_params_.viewport[3] - task_params_.viewport[1]; + if (aov_desc.format == pxr::HdFormatInvalid) { + return; + } + + int w = render_task_params_.viewport[2] - render_task_params_.viewport[0]; + int h = render_task_params_.viewport[3] - render_task_params_.viewport[1]; render_index.InsertBprim(pxr::HdPrimTypeTokens->renderBuffer, this, buf_id); buffer_descriptors_[buf_id] = pxr::HdRenderBufferDescriptor( pxr::GfVec3i(w, h, 1), aov_desc.format, aov_desc.multiSampled); @@ -103,8 +107,8 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) binding.aovName = aov_key; binding.renderBufferId = buf_id; binding.aovSettings = aov_desc.aovSettings; - task_params_.aovBindings.push_back(binding); - render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); + render_task_params_.aovBindings.push_back(binding); + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); } void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) @@ -142,14 +146,44 @@ pxr::SdfPath RenderTaskDelegate::buffer_id(pxr::TfToken const &aov_key) const return GetDelegateID().AppendElementString("aov_" + aov_key.GetString()); } +GPURenderTaskDelegate::GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, + pxr::SdfPath const &delegate_id) + : RenderTaskDelegate(parent_index, delegate_id) +{ + aov_task_id_ = GetDelegateID().AppendElementString("aovTask"); + GetRenderIndex().InsertTask(this, aov_task_id_); + GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_, + pxr::HdChangeTracker::DirtyCollection); + GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_, + pxr::HdChangeTracker::DirtyRenderTags); +} + +pxr::VtValue GPURenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) +{ + if (id == render_task_id_) { + return RenderTaskDelegate::Get(id, key); + } + + if (key == pxr::HdTokens->params) { + return pxr::VtValue(aov_task_params_); + } + + return pxr::VtValue(); +} + +pxr::HdTaskSharedPtr GPURenderTaskDelegate::aov_task() +{ + return GetRenderIndex().GetTask(aov_task_id_); +} + void GPURenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) { - if (task_params_.viewport == viewport) { + if (render_task_params_.viewport == viewport) { return; } auto &render_index = GetRenderIndex(); - task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); + render_task_params_.viewport = viewport; + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); if (tex_color_) { GPU_texture_free(tex_color_); @@ -172,7 +206,7 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) tex = &tex_color_; } else if (aov_key == pxr::HdAovTokens->depth) { - format = GPU_DEPTH32F_STENCIL8; + format = GPU_DEPTH_COMPONENT32F; tex = &tex_depth_; } else { @@ -184,8 +218,8 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) } *tex = GPU_texture_create_2d(("tex_render_hydra_" + aov_key.GetString()).c_str(), - task_params_.viewport[2] - task_params_.viewport[0], - task_params_.viewport[3] - task_params_.viewport[1], + render_task_params_.viewport[2] - render_task_params_.viewport[0], + render_task_params_.viewport[3] - render_task_params_.viewport[1], 1, format, GPU_TEXTURE_USAGE_GENERAL, diff --git a/source/blender/render/hydra/render_task_delegate.h b/source/blender/render/hydra/render_task_delegate.h index 548fec3a02c5..14fd79df4f2c 100644 --- a/source/blender/render/hydra/render_task_delegate.h +++ b/source/blender/render/hydra/render_task_delegate.h @@ -5,6 +5,7 @@ #include #include +#include #include "GPU_framebuffer.h" #include "GPU_texture.h" @@ -21,8 +22,8 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { pxr::TfTokenVector GetTaskRenderTags(pxr::SdfPath const &id) override; pxr::HdRenderBufferDescriptor GetRenderBufferDescriptor(pxr::SdfPath const &id) override; - pxr::HdTaskSharedPtr task(); - bool is_converged(); + pxr::HdTaskSharedPtr render_task(); + bool is_converged(pxr::HdTaskSharedPtr task); void set_camera(pxr::SdfPath const &camera_id); virtual void set_viewport(pxr::GfVec4d const &viewport); virtual void add_aov(pxr::TfToken const &aov_key); @@ -34,16 +35,21 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { protected: pxr::SdfPath buffer_id(pxr::TfToken const &aov_key) const; - pxr::SdfPath task_id_; - pxr::HdxRenderTaskParams task_params_; + pxr::SdfPath render_task_id_; + pxr::HdxRenderTaskParams render_task_params_; pxr::TfHashMap buffer_descriptors_; }; class GPURenderTaskDelegate : public RenderTaskDelegate { public: - using RenderTaskDelegate::RenderTaskDelegate; + GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id); + ~GPURenderTaskDelegate() override = default; + /* Delegate methods */ + pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override; + + pxr::HdTaskSharedPtr aov_task(); void set_viewport(pxr::GfVec4d const &viewport) override; void add_aov(pxr::TfToken const &aov_key) override; void read_aov(pxr::TfToken const &aov_key, void *data) override; @@ -52,6 +58,8 @@ class GPURenderTaskDelegate : public RenderTaskDelegate { void unbind() override; private: + pxr::SdfPath aov_task_id_; + pxr::HdxVisualizeAovTaskParams aov_task_params_; GPUFrameBuffer *framebuffer_ = nullptr; GPUTexture *tex_color_ = nullptr; GPUTexture *tex_depth_ = nullptr; diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 229ec9fff309..f23728fa2644 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -242,7 +242,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) } tasks.push_back(light_tasks_delegate_->simple_task()); } - tasks.push_back(render_task_delegate_->task()); + tasks.push_back(render_task_delegate_->render_task()); engine_->Execute(render_index_.get(), &tasks); if ((bl_engine_->type->flag & RE_USE_GPU_CONTEXT) == 0) { @@ -262,7 +262,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) BLI_timecode_string_from_time_simple( elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); - if (!render_task_delegate_->is_converged()) { + if (!render_task_delegate_->is_converged(render_task_delegate_->render_task())) { notify_status(std::string("Time: ") + elapsed_time + " | Done: " + std::to_string(int(renderer_percent_done())) + "%", "Render"); -- 2.30.2 From 790e6a289e7b8ba652dc3e64b6dda09478150f1e Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 25 Jul 2023 16:26:28 +0300 Subject: [PATCH 2/9] Added logging --- .../render/hydra/light_tasks_delegate.cc | 6 +++++ .../render/hydra/render_task_delegate.cc | 27 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/source/blender/render/hydra/light_tasks_delegate.cc b/source/blender/render/hydra/light_tasks_delegate.cc index 82730c042da5..ffd84f3b7a68 100644 --- a/source/blender/render/hydra/light_tasks_delegate.cc +++ b/source/blender/render/hydra/light_tasks_delegate.cc @@ -2,6 +2,7 @@ * Copyright 2011-2022 Blender Foundation */ #include "light_tasks_delegate.h" +#include "engine.h" namespace blender::render::hydra { @@ -13,10 +14,15 @@ LightTasksDelegate::LightTasksDelegate(pxr::HdRenderIndex *parent_index, GetRenderIndex().InsertTask(this, simple_task_id_); skydome_task_id_ = GetDelegateID().AppendElementString("skydomeTask"); GetRenderIndex().InsertTask(this, skydome_task_id_); + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", simple_task_id_.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", skydome_task_id_.GetText()); } pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { + CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); + if (key == pxr::HdTokens->params) { if (id == simple_task_id_) { return pxr::VtValue(simple_task_params_); diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index 133458423996..a07337067b3d 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" #include "render_task_delegate.h" +#include "engine.h" namespace blender::render::hydra { @@ -22,10 +23,14 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index, render_task_params_.enableLighting = true; render_task_params_.alphaThreshold = 0.1f; + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", render_task_id_.GetText()); } -pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken const &key) +pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & id, pxr::TfToken const &key) { + CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); + if (key == pxr::HdTokens->params) { return pxr::VtValue(render_task_params_); } @@ -36,13 +41,17 @@ pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken c return pxr::VtValue(); } -pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & /*id*/) +pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & id) { + CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText()); + return {pxr::HdRenderTagTokens->geometry}; } pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr::SdfPath const &id) { + CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText()); + return buffer_descriptors_[id]; } @@ -109,6 +118,8 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) binding.aovSettings = aov_desc.aovSettings; render_task_params_.aovBindings.push_back(binding); render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); } void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) @@ -152,14 +163,14 @@ GPURenderTaskDelegate::GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, { aov_task_id_ = GetDelegateID().AppendElementString("aovTask"); GetRenderIndex().InsertTask(this, aov_task_id_); - GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_, - pxr::HdChangeTracker::DirtyCollection); - GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_, - pxr::HdChangeTracker::DirtyRenderTags); + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_task_id_.GetText()); } pxr::VtValue GPURenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { + CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); + if (id == render_task_id_) { return RenderTaskDelegate::Get(id, key); } @@ -224,6 +235,8 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) format, GPU_TEXTURE_USAGE_GENERAL, nullptr); + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); } void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) @@ -282,7 +295,7 @@ void GPURenderTaskDelegate::bind() GPU_framebuffer_clear_color_depth(framebuffer_, clear_color, 1.0f); /* Important: we have to create and bind at least one Vertex Array Object (VAO) before render - execution: More info at https://open.gl/drawing */ + * execution: More info at https://open.gl/drawing */ if (VAO_ == 0) { glGenVertexArrays(1, &VAO_); } -- 2.30.2 From 7e247033e3b2a4379fda625981164ca79719477f Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 25 Jul 2023 16:31:35 +0300 Subject: [PATCH 3/9] Fix comments --- source/blender/render/hydra/camera.cc | 2 +- source/blender/render/hydra/engine.cc | 2 -- source/blender/render/hydra/final_engine.cc | 2 -- source/blender/render/hydra/light_tasks_delegate.cc | 4 ++-- source/blender/render/hydra/scene_delegate/instancer.h | 10 +++++----- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/blender/render/hydra/camera.cc b/source/blender/render/hydra/camera.cc index 09a7b923b4fc..384e1a1d4be3 100644 --- a/source/blender/render/hydra/camera.cc +++ b/source/blender/render/hydra/camera.cc @@ -240,7 +240,7 @@ pxr::GfCamera CameraData::gf_camera(pxr::GfVec4f tile) switch (mode_) { case CAM_PERSP: case CAM_PANO: { - /* TODO: store panoramic camera settings */ + /* TODO: store panoramic camera settings */ gf_camera.SetProjection(pxr::GfCamera::Projection::Perspective); gf_camera.SetFocalLength(focal_length_); diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index dfe39edee02c..b729649a3dc1 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -27,8 +27,6 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name) pxr::TF_PY_ALLOW_THREADS_IN_SCOPE(); - /* USD has limited support for Vulkan. To make it works USD should be built - * with PXR_ENABLE_VULKAN_SUPPORT=TRUE which is not possible now */ if (GPU_backend_get_type() == GPU_BACKEND_VULKAN) { BLI_setenv("HGI_ENABLE_VULKAN", "1"); } diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 258336d6e7b8..6d52e66446ba 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -20,8 +20,6 @@ PXR_NAMESPACE_CLOSE_SCOPE namespace blender::render::hydra { -/* FinalEngine implementation */ - void FinalEngine::render(Depsgraph *depsgraph) { const Scene *scene = DEG_get_evaluated_scene(depsgraph); diff --git a/source/blender/render/hydra/light_tasks_delegate.cc b/source/blender/render/hydra/light_tasks_delegate.cc index ffd84f3b7a68..9e4815e124a6 100644 --- a/source/blender/render/hydra/light_tasks_delegate.cc +++ b/source/blender/render/hydra/light_tasks_delegate.cc @@ -42,8 +42,8 @@ pxr::HdTaskSharedPtr LightTasksDelegate::simple_task() pxr::HdTaskSharedPtr LightTasksDelegate::skydome_task() { /* Note that this task is intended to be the first "Render Task", - so that the AOV's are properly cleared, however it - does not spawn a HdRenderPass. */ + * so that the AOV's are properly cleared, however it + * does not spawn a HdRenderPass. */ return GetRenderIndex().GetTask(skydome_task_id_); } diff --git a/source/blender/render/hydra/scene_delegate/instancer.h b/source/blender/render/hydra/scene_delegate/instancer.h index 75c42efb2109..441408e6ca4f 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.h +++ b/source/blender/render/hydra/scene_delegate/instancer.h @@ -43,11 +43,11 @@ class InstancerData : public IdData { void update_double_sided(MaterialData *mat_data); /* Following update functions are working together: - pre_update() - update_instance() - update_instance() - ... - post_update() */ + * pre_update() + * update_instance() + * update_instance() + * ... + * post_update() */ void pre_update(); void update_instance(Object *parent_ob, DupliObject *dupli); void post_update(); -- 2.30.2 From 7c524a074be58c9b51f1c9d70881664913f93631 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 25 Jul 2023 16:32:36 +0300 Subject: [PATCH 4/9] make format --- .../render/hydra/render_task_delegate.cc | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index a07337067b3d..219c494686e2 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -9,8 +9,8 @@ #include "MEM_guardedalloc.h" -#include "render_task_delegate.h" #include "engine.h" +#include "render_task_delegate.h" namespace blender::render::hydra { @@ -27,7 +27,7 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index, CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", render_task_id_.GetText()); } -pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & id, pxr::TfToken const &key) +pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); @@ -41,7 +41,7 @@ pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & id, pxr::TfToken const return pxr::VtValue(); } -pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & id) +pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const &id) { CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText()); @@ -66,7 +66,8 @@ void RenderTaskDelegate::set_camera(pxr::SdfPath const &camera_id) return; } render_task_params_.camera = camera_id; - GetRenderIndex().GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); + GetRenderIndex().GetChangeTracker().MarkTaskDirty(render_task_id_, + pxr::HdChangeTracker::DirtyParams); } bool RenderTaskDelegate::is_converged(pxr::HdTaskSharedPtr task) @@ -81,7 +82,8 @@ void RenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) } auto &render_index = GetRenderIndex(); render_task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, + pxr::HdChangeTracker::DirtyParams); int w = viewport[2] - viewport[0]; int h = viewport[3] - viewport[1]; @@ -117,7 +119,8 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) binding.renderBufferId = buf_id; binding.aovSettings = aov_desc.aovSettings; render_task_params_.aovBindings.push_back(binding); - render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, + pxr::HdChangeTracker::DirtyParams); CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); } @@ -158,7 +161,7 @@ pxr::SdfPath RenderTaskDelegate::buffer_id(pxr::TfToken const &aov_key) const } GPURenderTaskDelegate::GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, - pxr::SdfPath const &delegate_id) + pxr::SdfPath const &delegate_id) : RenderTaskDelegate(parent_index, delegate_id) { aov_task_id_ = GetDelegateID().AppendElementString("aovTask"); @@ -194,7 +197,8 @@ void GPURenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) } auto &render_index = GetRenderIndex(); render_task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, + pxr::HdChangeTracker::DirtyParams); if (tex_color_) { GPU_texture_free(tex_color_); -- 2.30.2 From 7d1f4838e02bdd2f61d4ca8153470baaa39a69bd Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 26 Jul 2023 20:46:30 +0300 Subject: [PATCH 5/9] Fix review comments. Added empty def update_render_passes for base class --- scripts/modules/bpy_hydra.py | 8 +++++ source/blender/render/hydra/CMakeLists.txt | 3 +- source/blender/render/hydra/engine.cc | 7 +++- source/blender/render/hydra/engine.h | 1 + source/blender/render/hydra/final_engine.cc | 23 +++++------- source/blender/render/hydra/final_engine.h | 3 -- .../render/hydra/render_task_delegate.cc | 36 ++----------------- .../render/hydra/render_task_delegate.h | 13 ++----- .../hydra/{scene_delegate => }/settings.h | 0 .../blender/render/hydra/viewport_engine.cc | 4 +-- 10 files changed, 33 insertions(+), 65 deletions(-) rename source/blender/render/hydra/{scene_delegate => }/settings.h (100%) diff --git a/scripts/modules/bpy_hydra.py b/scripts/modules/bpy_hydra.py index 649351288d58..950e99a9955c 100644 --- a/scripts/modules/bpy_hydra.py +++ b/scripts/modules/bpy_hydra.py @@ -30,7 +30,12 @@ class CustomHydraRenderEngine(HydraRenderEngine): return { 'enableTinyPrimCulling': True, 'maxLights': 8, + 'aov:Depth': "depth", } + + def update_render_passes(self, scene, render_layer): + if render_layer.use_pass_z: + self.register_pass(scene, render_layer, 'Depth', 1, 'Z', 'VALUE') ``` """ @@ -141,6 +146,9 @@ class HydraRenderEngine(bpy.types.RenderEngine): _bpy_hydra.engine_view_draw(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer()) + def update_render_passes(self, scene, render_layer): + """ Register supported AOVs for render. Must be overridden in child classes. """ + pass def export_mtlx(material): """ Exports material to .mtlx file. It is called from Blender source code. """ diff --git a/source/blender/render/hydra/CMakeLists.txt b/source/blender/render/hydra/CMakeLists.txt index d5301388f81e..e181164d614d 100644 --- a/source/blender/render/hydra/CMakeLists.txt +++ b/source/blender/render/hydra/CMakeLists.txt @@ -91,6 +91,8 @@ set(SRC light_tasks_delegate.cc light_tasks_delegate.h + settings.h + scene_delegate/blender_scene_delegate.cc scene_delegate/blender_scene_delegate.h scene_delegate/curves.cc @@ -111,7 +113,6 @@ set(SRC scene_delegate/mtlx_hydra_adapter.h scene_delegate/object.cc scene_delegate/object.h - scene_delegate/settings.h scene_delegate/usd_scene_delegate.cc scene_delegate/usd_scene_delegate.hh scene_delegate/volume.cc diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index b729649a3dc1..718a208c588c 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -112,7 +112,12 @@ void Engine::set_sync_setting(const std::string &key, const pxr::VtValue &val) void Engine::set_render_setting(const std::string &key, const pxr::VtValue &val) { - render_delegate_->SetRenderSetting(pxr::TfToken(key), val); + if (key._Starts_with("aov:")) { + render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1), pxr::TfToken(val.UncheckedGet())); + } + else { + render_delegate_->SetRenderSetting(pxr::TfToken(key), val); + } } float Engine::renderer_percent_done() diff --git a/source/blender/render/hydra/engine.h b/source/blender/render/hydra/engine.h index ebfb32a4a7a1..55cf56eea635 100644 --- a/source/blender/render/hydra/engine.h +++ b/source/blender/render/hydra/engine.h @@ -55,6 +55,7 @@ class Engine { std::unique_ptr hydra_scene_delegate_; std::unique_ptr usd_scene_delegate_; + RenderDelegateSettings render_delegate_settings_; std::unique_ptr render_task_delegate_; std::unique_ptr free_camera_delegate_; std::unique_ptr light_tasks_delegate_; diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 6d52e66446ba..e940c0e32fad 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -14,10 +14,6 @@ #include "camera.h" #include "final_engine.h" -PXR_NAMESPACE_OPEN_SCOPE -TF_DEFINE_PRIVATE_TOKENS(tokens_, (worldCoordinate)); -PXR_NAMESPACE_CLOSE_SCOPE - namespace blender::render::hydra { void FinalEngine::render(Depsgraph *depsgraph) @@ -49,15 +45,15 @@ void FinalEngine::render(Depsgraph *depsgraph) light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1])); } - aovs_map_.add_new("Combined", pxr::HdAovTokens->color); - aovs_map_.add_new("Depth", pxr::HdAovTokens->depth); - aovs_map_.add_new("Normal", pxr::HdAovTokens->normal); - aovs_map_.add_new("Position", pxr::tokens_->worldCoordinate); + render_task_delegate_->add_aov(pxr::HdAovTokens->color); + if (bl_engine_->type->flag & RE_USE_GPU_CONTEXT) { + render_task_delegate_->add_aov(pxr::HdAovTokens->depth); + } RenderResult *result = RE_engine_get_result(bl_engine_); RenderLayer *layer = (RenderLayer *)result->layers.first; for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) { - pxr::TfToken *aov_token = aovs_map_.lookup_ptr(pass->name); + pxr::TfToken *aov_token = render_delegate_settings_.aovs.lookup_ptr(pass->name); if (aov_token) { render_task_delegate_->add_aov(*aov_token); } @@ -72,10 +68,7 @@ void FinalEngine::render(Depsgraph *depsgraph) } tasks.push_back(light_tasks_delegate_->simple_task()); } - if (bl_engine_->type->flag & RE_USE_GPU_CONTEXT) { - tasks.push_back(static_cast(render_task_delegate_.get())->aov_task()); - } - tasks.push_back(render_task_delegate_->render_task()); + tasks.push_back(render_task_delegate_->task()); engine_->Execute(render_index_.get(), &tasks); char elapsed_time[32]; @@ -95,7 +88,7 @@ void FinalEngine::render(Depsgraph *depsgraph) std::string("Render Time: ") + elapsed_time + " | Done: " + std::to_string(int(percent_done)) + "%"); - if (render_task_delegate_->is_converged(render_task_delegate_->render_task())) { + if (render_task_delegate_->is_converged()) { break; } @@ -120,7 +113,7 @@ void FinalEngine::update_render_result() /* TODO: only for the first render layer */ RenderLayer *layer = (RenderLayer *)result->layers.first; for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) { - pxr::TfToken *aov_token = aovs_map_.lookup_ptr(pass->name); + pxr::TfToken *aov_token = render_delegate_settings_.aovs.lookup_ptr(pass->name); if (aov_token) { render_task_delegate_->read_aov(*aov_token, pass->ibuf->float_buffer.data); } diff --git a/source/blender/render/hydra/final_engine.h b/source/blender/render/hydra/final_engine.h index 52ff479e4b36..81155629a010 100644 --- a/source/blender/render/hydra/final_engine.h +++ b/source/blender/render/hydra/final_engine.h @@ -20,9 +20,6 @@ class FinalEngine : public Engine { std::string scene_name_; std::string layer_name_; pxr::GfVec2i resolution_; - - /* Map supported Blender AOV to corresponded Hydra AOV token */ - Map aovs_map_; }; } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index 219c494686e2..4794d3f1eaf3 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -55,7 +55,7 @@ pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr: return buffer_descriptors_[id]; } -pxr::HdTaskSharedPtr RenderTaskDelegate::render_task() +pxr::HdTaskSharedPtr RenderTaskDelegate::task() { return GetRenderIndex().GetTask(render_task_id_); } @@ -70,9 +70,9 @@ void RenderTaskDelegate::set_camera(pxr::SdfPath const &camera_id) pxr::HdChangeTracker::DirtyParams); } -bool RenderTaskDelegate::is_converged(pxr::HdTaskSharedPtr task) +bool RenderTaskDelegate::is_converged() { - return ((pxr::HdxRenderTask *)task.get())->IsConverged(); + return ((pxr::HdxRenderTask *)task().get())->IsConverged(); } void RenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) @@ -160,36 +160,6 @@ pxr::SdfPath RenderTaskDelegate::buffer_id(pxr::TfToken const &aov_key) const return GetDelegateID().AppendElementString("aov_" + aov_key.GetString()); } -GPURenderTaskDelegate::GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, - pxr::SdfPath const &delegate_id) - : RenderTaskDelegate(parent_index, delegate_id) -{ - aov_task_id_ = GetDelegateID().AppendElementString("aovTask"); - GetRenderIndex().InsertTask(this, aov_task_id_); - - CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_task_id_.GetText()); -} - -pxr::VtValue GPURenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) -{ - CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); - - if (id == render_task_id_) { - return RenderTaskDelegate::Get(id, key); - } - - if (key == pxr::HdTokens->params) { - return pxr::VtValue(aov_task_params_); - } - - return pxr::VtValue(); -} - -pxr::HdTaskSharedPtr GPURenderTaskDelegate::aov_task() -{ - return GetRenderIndex().GetTask(aov_task_id_); -} - void GPURenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) { if (render_task_params_.viewport == viewport) { diff --git a/source/blender/render/hydra/render_task_delegate.h b/source/blender/render/hydra/render_task_delegate.h index 14fd79df4f2c..e9b181ad1a99 100644 --- a/source/blender/render/hydra/render_task_delegate.h +++ b/source/blender/render/hydra/render_task_delegate.h @@ -22,9 +22,9 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { pxr::TfTokenVector GetTaskRenderTags(pxr::SdfPath const &id) override; pxr::HdRenderBufferDescriptor GetRenderBufferDescriptor(pxr::SdfPath const &id) override; - pxr::HdTaskSharedPtr render_task(); - bool is_converged(pxr::HdTaskSharedPtr task); + pxr::HdTaskSharedPtr task(); void set_camera(pxr::SdfPath const &camera_id); + virtual bool is_converged(); virtual void set_viewport(pxr::GfVec4d const &viewport); virtual void add_aov(pxr::TfToken const &aov_key); virtual void read_aov(pxr::TfToken const &aov_key, void *data); @@ -43,13 +43,8 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { class GPURenderTaskDelegate : public RenderTaskDelegate { public: - GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id); - ~GPURenderTaskDelegate() override = default; + using RenderTaskDelegate::RenderTaskDelegate; - /* Delegate methods */ - pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override; - - pxr::HdTaskSharedPtr aov_task(); void set_viewport(pxr::GfVec4d const &viewport) override; void add_aov(pxr::TfToken const &aov_key) override; void read_aov(pxr::TfToken const &aov_key, void *data) override; @@ -58,8 +53,6 @@ class GPURenderTaskDelegate : public RenderTaskDelegate { void unbind() override; private: - pxr::SdfPath aov_task_id_; - pxr::HdxVisualizeAovTaskParams aov_task_params_; GPUFrameBuffer *framebuffer_ = nullptr; GPUTexture *tex_color_ = nullptr; GPUTexture *tex_depth_ = nullptr; diff --git a/source/blender/render/hydra/scene_delegate/settings.h b/source/blender/render/hydra/settings.h similarity index 100% rename from source/blender/render/hydra/scene_delegate/settings.h rename to source/blender/render/hydra/settings.h diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index f23728fa2644..229ec9fff309 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -242,7 +242,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) } tasks.push_back(light_tasks_delegate_->simple_task()); } - tasks.push_back(render_task_delegate_->render_task()); + tasks.push_back(render_task_delegate_->task()); engine_->Execute(render_index_.get(), &tasks); if ((bl_engine_->type->flag & RE_USE_GPU_CONTEXT) == 0) { @@ -262,7 +262,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) BLI_timecode_string_from_time_simple( elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); - if (!render_task_delegate_->is_converged(render_task_delegate_->render_task())) { + if (!render_task_delegate_->is_converged()) { notify_status(std::string("Time: ") + elapsed_time + " | Done: " + std::to_string(int(renderer_percent_done())) + "%", "Render"); -- 2.30.2 From 2e3f81e2c636eeb1b70e76350bd7073d1ea2650a Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Jul 2023 15:41:47 +0300 Subject: [PATCH 6/9] fix after merge --- source/blender/render/hydra/render_task_delegate.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index e0e4a5de50e4..194cf4df458d 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -22,7 +22,7 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id) : pxr::HdSceneDelegate(parent_index, delegate_id) { - task_id_ = GetDelegateID().AppendElementString("renderTask"); + task_id_ = GetDelegateID().AppendElementString("task"); GetRenderIndex().InsertTask(this, task_id_); task_params_.enableLighting = true; -- 2.30.2 From c23cf4d89206722ad70d7ff9b14fbd52213c4e00 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Jul 2023 15:56:27 +0300 Subject: [PATCH 7/9] change _Starts_with with STRPREFIX --- source/blender/render/hydra/engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index e45b2361ad21..e98601cccbed 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -118,7 +118,7 @@ void Engine::set_sync_setting(const std::string &key, const pxr::VtValue &val) void Engine::set_render_setting(const std::string &key, const pxr::VtValue &val) { - if (key._Starts_with("aov:")) { + if (STRPREFIX(key.c_str(), "aovToken:")) { render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1), pxr::TfToken(val.UncheckedGet())); } else { -- 2.30.2 From 06aec6a82666af150df788426403d986d07787e2 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Jul 2023 15:57:15 +0300 Subject: [PATCH 8/9] make format --- source/blender/render/hydra/engine.cc | 3 ++- source/blender/render/hydra/render_task_delegate.cc | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index e98601cccbed..15e24c1a7588 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -119,7 +119,8 @@ void Engine::set_sync_setting(const std::string &key, const pxr::VtValue &val) void Engine::set_render_setting(const std::string &key, const pxr::VtValue &val) { if (STRPREFIX(key.c_str(), "aovToken:")) { - render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1), pxr::TfToken(val.UncheckedGet())); + render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1), + pxr::TfToken(val.UncheckedGet())); } else { render_delegate_->SetRenderSetting(pxr::TfToken(key), val); diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index 194cf4df458d..15d03273a158 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -70,8 +70,7 @@ void RenderTaskDelegate::set_camera(pxr::SdfPath const &camera_id) return; } task_params_.camera = camera_id; - GetRenderIndex().GetChangeTracker().MarkTaskDirty(task_id_, - pxr::HdChangeTracker::DirtyParams); + GetRenderIndex().GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); } bool RenderTaskDelegate::is_converged() @@ -86,8 +85,7 @@ void RenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) } auto &render_index = GetRenderIndex(); task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(task_id_, - pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); int w = viewport[2] - viewport[0]; int h = viewport[3] - viewport[1]; @@ -123,8 +121,7 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) binding.renderBufferId = buf_id; binding.aovSettings = aov_desc.aovSettings; task_params_.aovBindings.push_back(binding); - render_index.GetChangeTracker().MarkTaskDirty(task_id_, - pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); } @@ -171,8 +168,7 @@ void GPURenderTaskDelegate::set_viewport(pxr::GfVec4d const &viewport) } auto &render_index = GetRenderIndex(); task_params_.viewport = viewport; - render_index.GetChangeTracker().MarkTaskDirty(task_id_, - pxr::HdChangeTracker::DirtyParams); + render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); if (tex_color_) { GPU_texture_free(tex_color_); -- 2.30.2 From 54ad8af5ac90b7ac6cd787e6321d9aa5f32fbd4d Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Jul 2023 16:06:16 +0300 Subject: [PATCH 9/9] added code to examples --- doc/python_api/examples/bpy.types.HydraRenderEngine.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/python_api/examples/bpy.types.HydraRenderEngine.py b/doc/python_api/examples/bpy.types.HydraRenderEngine.py index 2285fedc1299..4f3a051220f6 100644 --- a/doc/python_api/examples/bpy.types.HydraRenderEngine.py +++ b/doc/python_api/examples/bpy.types.HydraRenderEngine.py @@ -28,6 +28,7 @@ class CustomHydraRenderEngine(bpy.types.HydraRenderEngine): return { 'myBoolean': True, 'myValue': 8, + 'aovToken:Depth': "depth", } # Settings used by the synchronization process. @@ -43,6 +44,11 @@ class CustomHydraRenderEngine(bpy.types.HydraRenderEngine): super().update(data, depsgraph) # Do extra work here + def update_render_passes(self, scene, render_layer): + if render_layer.use_pass_z: + self.register_pass(scene, render_layer, 'Depth', 1, 'Z', 'VALUE') + + # Registration def register(): bpy.utils.register_class(CustomHydraRenderEngine) -- 2.30.2