From bf9221581b0ba4fa3ecd5a2bfb1bd5a40fa5df9c Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Fri, 28 Jul 2023 18:55:25 +0300 Subject: [PATCH 1/6] Renamed loggers. Unified some functions in Engines classes --- .../io/usd/hydra/hydra_scene_delegate.cc | 42 +++++++++---------- .../io/usd/hydra/hydra_scene_delegate.h | 2 +- source/blender/io/usd/hydra/id.h | 4 +- source/blender/io/usd/hydra/image.cc | 10 ++--- source/blender/io/usd/hydra/instancer.cc | 4 +- source/blender/io/usd/hydra/instancer.h | 2 +- source/blender/io/usd/hydra/light.cc | 12 +++--- source/blender/io/usd/hydra/material.cc | 2 +- .../blender/io/usd/hydra/volume_modifier.cc | 2 +- source/blender/render/hydra/engine.cc | 10 +++-- source/blender/render/hydra/engine.h | 8 +++- source/blender/render/hydra/final_engine.cc | 37 +++++++--------- source/blender/render/hydra/final_engine.h | 13 +++--- source/blender/render/hydra/python.cc | 24 +++++------ .../blender/render/hydra/viewport_engine.cc | 23 +++++----- source/blender/render/hydra/viewport_engine.h | 7 ++-- 16 files changed, 96 insertions(+), 106 deletions(-) diff --git a/source/blender/io/usd/hydra/hydra_scene_delegate.cc b/source/blender/io/usd/hydra/hydra_scene_delegate.cc index 7dc15ccf700f..aa42a694ea5b 100644 --- a/source/blender/io/usd/hydra/hydra_scene_delegate.cc +++ b/source/blender/io/usd/hydra/hydra_scene_delegate.cc @@ -13,7 +13,7 @@ namespace blender::io::hydra { -CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA_SCENE, "render.hydra.scene"); +CLG_LOGREF_DECLARE_GLOBAL(LOG_HYDRA_SCENE, "hydra.scene"); bool HydraSceneDelegate::ShadingSettings::operator==(const ShadingSettings &other) { @@ -38,21 +38,21 @@ HydraSceneDelegate::HydraSceneDelegate(pxr::HdRenderIndex *parent_index, pxr::HdMeshTopology HydraSceneDelegate::GetMeshTopology(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); MeshData *m_data = mesh_data(id); return m_data->topology(id); } pxr::HdBasisCurvesTopology HydraSceneDelegate::GetBasisCurvesTopology(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); CurvesData *c_data = curves_data(id); return c_data->topology(); }; pxr::GfMatrix4d HydraSceneDelegate::GetTransform(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); InstancerData *i_data = instancer_data(id, true); if (i_data) { return i_data->transform(id); @@ -69,7 +69,7 @@ pxr::GfMatrix4d HydraSceneDelegate::GetTransform(pxr::SdfPath const &id) pxr::VtValue HydraSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText()); ObjectData *obj_data = object_data(id); if (obj_data) { return obj_data->get_data(id, key); @@ -88,7 +88,7 @@ pxr::VtValue HydraSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const pxr::VtValue HydraSceneDelegate::GetLightParamValue(pxr::SdfPath const &id, pxr::TfToken const &key) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText()); LightData *l_data = light_data(id); if (l_data) { return l_data->get_data(key); @@ -99,7 +99,7 @@ pxr::VtValue HydraSceneDelegate::GetLightParamValue(pxr::SdfPath const &id, pxr::HdPrimvarDescriptorVector HydraSceneDelegate::GetPrimvarDescriptors( pxr::SdfPath const &id, pxr::HdInterpolation interpolation) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %d", id.GetText(), interpolation); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %d", id.GetText(), interpolation); MeshData *m_data = mesh_data(id); if (m_data) { return m_data->primvar_descriptors(interpolation); @@ -117,7 +117,7 @@ pxr::HdPrimvarDescriptorVector HydraSceneDelegate::GetPrimvarDescriptors( pxr::SdfPath HydraSceneDelegate::GetMaterialId(pxr::SdfPath const &rprim_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", rprim_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", rprim_id.GetText()); ObjectData *obj_data = object_data(rprim_id); if (obj_data) { return obj_data->material_id(rprim_id); @@ -127,7 +127,7 @@ pxr::SdfPath HydraSceneDelegate::GetMaterialId(pxr::SdfPath const &rprim_id) pxr::VtValue HydraSceneDelegate::GetMaterialResource(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); MaterialData *mat_data = material_data(id); if (mat_data) { return mat_data->get_material_resource(); @@ -137,7 +137,7 @@ pxr::VtValue HydraSceneDelegate::GetMaterialResource(pxr::SdfPath const &id) bool HydraSceneDelegate::GetVisible(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); if (id == world_prim_id()) { return true; } @@ -150,19 +150,19 @@ bool HydraSceneDelegate::GetVisible(pxr::SdfPath const &id) bool HydraSceneDelegate::GetDoubleSided(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); return mesh_data(id)->double_sided(id); } pxr::HdCullStyle HydraSceneDelegate::GetCullStyle(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText()); return mesh_data(id)->cull_style(id); } pxr::SdfPath HydraSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", prim_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", prim_id.GetText()); InstancerData *i_data = instancer_data(prim_id, true); if (i_data && mesh_data(prim_id)) { return i_data->prim_id; @@ -172,7 +172,7 @@ pxr::SdfPath HydraSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id) pxr::SdfPathVector HydraSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const &instancer_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); InstancerData *i_data = instancer_data(instancer_id); return i_data->prototypes(); } @@ -180,14 +180,14 @@ pxr::SdfPathVector HydraSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const pxr::VtIntArray HydraSceneDelegate::GetInstanceIndices(pxr::SdfPath const &instancer_id, pxr::SdfPath const &prototype_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText()); InstancerData *i_data = instancer_data(instancer_id); return i_data->indices(prototype_id); } pxr::GfMatrix4d HydraSceneDelegate::GetInstancerTransform(pxr::SdfPath const &instancer_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); InstancerData *i_data = instancer_data(instancer_id); return i_data->transform(instancer_id); } @@ -195,7 +195,7 @@ pxr::GfMatrix4d HydraSceneDelegate::GetInstancerTransform(pxr::SdfPath const &in pxr::HdVolumeFieldDescriptorVector HydraSceneDelegate::GetVolumeFieldDescriptors( pxr::SdfPath const &volume_id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", volume_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", volume_id.GetText()); VolumeData *v_data = volume_data(volume_id); return v_data->field_descriptors(); } @@ -271,8 +271,8 @@ ObjectData *HydraSceneDelegate::object_data(pxr::SdfPath const &id) const if (id == world_prim_id()) { return world_data_.get(); } - - pxr::SdfPath p_id = (id.GetName().find("SM_") == 0 || id.GetName().find("VF_") == 0) ? + auto name = id.GetName(); + pxr::SdfPath p_id = (STRPREFIX(name.c_str(), "SM_") || STRPREFIX(name.c_str(), "VF_")) ? id.GetParentPath() : id; auto obj_data = objects_.lookup_ptr(p_id); @@ -378,7 +378,7 @@ void HydraSceneDelegate::check_updates() data.only_updated = true; ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + CLOG_INFO(LOG_HYDRA_SCENE, 0, "Update: %s [%s]", id->name, @@ -459,7 +459,7 @@ void HydraSceneDelegate::update_collection() continue; } - instancer_data_->update_instance(data.dupli_parent, dupli); + instancer_data_->update_instance(dupli); continue; } diff --git a/source/blender/io/usd/hydra/hydra_scene_delegate.h b/source/blender/io/usd/hydra/hydra_scene_delegate.h index ac7988445134..dc8a3ea704f2 100644 --- a/source/blender/io/usd/hydra/hydra_scene_delegate.h +++ b/source/blender/io/usd/hydra/hydra_scene_delegate.h @@ -29,7 +29,7 @@ struct View3D; namespace blender::io::hydra { -extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE; +extern struct CLG_LogRef *LOG_HYDRA_SCENE; class Engine; diff --git a/source/blender/io/usd/hydra/id.h b/source/blender/io/usd/hydra/id.h index f4469965cf3e..74a334d24ec3 100644 --- a/source/blender/io/usd/hydra/id.h +++ b/source/blender/io/usd/hydra/id.h @@ -50,10 +50,10 @@ class IdData { }; #define ID_LOG(level, msg, ...) \ - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, level, "%s: " msg, prim_id.GetText(), ##__VA_ARGS__); + CLOG_INFO(LOG_HYDRA_SCENE, level, "%s: " msg, prim_id.GetText(), ##__VA_ARGS__); #define ID_LOGN(level, msg, ...) \ - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, \ + CLOG_INFO(LOG_HYDRA_SCENE, \ level, \ "%s (%s): " msg, \ prim_id.GetText(), \ diff --git a/source/blender/io/usd/hydra/image.cc b/source/blender/io/usd/hydra/image.cc index 6d376955a0d9..a56a2b144121 100644 --- a/source/blender/io/usd/hydra/image.cc +++ b/source/blender/io/usd/hydra/image.cc @@ -56,10 +56,10 @@ static std::string cache_image_file( opts.save_copy = true; STRNCPY(opts.filepath, file_path.c_str()); if (BKE_image_save(nullptr, bmain, image, iuser, &opts)) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str()); + CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str()); } else { - CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Can't save %s", file_path.c_str()); + CLOG_ERROR(LOG_HYDRA_SCENE, "Can't save %s", file_path.c_str()); file_path = ""; } } @@ -86,7 +86,7 @@ std::string cache_or_get_image_file(Main *bmain, Scene *scene, Image *image, Ima } } - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str()); + CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str()); return file_path; } @@ -109,10 +109,10 @@ std::string cache_image_color(float color[4]) ibuf->ftype = IMB_FTYPE_RADHDR; if (IMB_saveiff(ibuf, file_path.c_str(), IB_rectfloat)) { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", file_path.c_str()); + CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s", file_path.c_str()); } else { - CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Can't save %s", file_path.c_str()); + CLOG_ERROR(LOG_HYDRA_SCENE, "Can't save %s", file_path.c_str()); file_path = ""; } IMB_freeImBuf(ibuf); diff --git a/source/blender/io/usd/hydra/instancer.cc b/source/blender/io/usd/hydra/instancer.cc index 34a04b7b3c85..eb84564326f9 100644 --- a/source/blender/io/usd/hydra/instancer.cc +++ b/source/blender/io/usd/hydra/instancer.cc @@ -23,7 +23,7 @@ void InstancerData::insert() {} void InstancerData::remove() { - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", prim_id.GetText()); + CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s", prim_id.GetText()); for (auto &m_inst : mesh_instances_.values()) { m_inst.data->remove(); } @@ -129,7 +129,7 @@ void InstancerData::pre_update() } } -void InstancerData::update_instance(Object * /* parent_ob */, DupliObject *dupli) +void InstancerData::update_instance(DupliObject *dupli) { Object *object = dupli->ob; pxr::SdfPath p_id = object_prim_id(object); diff --git a/source/blender/io/usd/hydra/instancer.h b/source/blender/io/usd/hydra/instancer.h index 68ffbc4562a0..84897daed0a7 100644 --- a/source/blender/io/usd/hydra/instancer.h +++ b/source/blender/io/usd/hydra/instancer.h @@ -51,7 +51,7 @@ class InstancerData : public IdData { ... post_update() */ void pre_update(); - void update_instance(Object *parent_ob, DupliObject *dupli); + void update_instance(DupliObject *dupli); void post_update(); private: diff --git a/source/blender/io/usd/hydra/light.cc b/source/blender/io/usd/hydra/light.cc index 6b1e228181a4..1380125dcce2 100644 --- a/source/blender/io/usd/hydra/light.cc +++ b/source/blender/io/usd/hydra/light.cc @@ -155,28 +155,28 @@ pxr::TfToken LightData::prim_type(Light *light) switch (light->area_shape) { case LA_AREA_SQUARE: case LA_AREA_RECT: - return pxr::TfToken(pxr::HdPrimTypeTokens->rectLight); + return pxr::HdPrimTypeTokens->rectLight; case LA_AREA_DISK: case LA_AREA_ELLIPSE: - return pxr::TfToken(pxr::HdPrimTypeTokens->diskLight); + return pxr::HdPrimTypeTokens->diskLight; default: - return pxr::TfToken(pxr::HdPrimTypeTokens->rectLight); + return pxr::HdPrimTypeTokens->rectLight; } break; case LA_LOCAL: case LA_SPOT: - return pxr::TfToken(pxr::HdPrimTypeTokens->sphereLight); + return pxr::HdPrimTypeTokens->sphereLight; case LA_SUN: - return pxr::TfToken(pxr::HdPrimTypeTokens->distantLight); + return pxr::HdPrimTypeTokens->distantLight; default: BLI_assert_unreachable(); - return pxr::TfToken(pxr::HdPrimTypeTokens->sphereLight); } + return pxr::TfToken(); } } // namespace blender::io::hydra diff --git a/source/blender/io/usd/hydra/material.cc b/source/blender/io/usd/hydra/material.cc index 232b0373fab5..e041ce6c9f88 100644 --- a/source/blender/io/usd/hydra/material.cc +++ b/source/blender/io/usd/hydra/material.cc @@ -151,7 +151,7 @@ void MaterialData::export_mtlx() err_str += PyUnicode_AsUTF8(pstr); Py_DECREF(pstr); } - CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, + CLOG_ERROR(LOG_HYDRA_SCENE, "Export error for %s (%s): %s", prim_id.GetText(), id->name, diff --git a/source/blender/io/usd/hydra/volume_modifier.cc b/source/blender/io/usd/hydra/volume_modifier.cc index 5b52771585e4..81612e6fd8c7 100644 --- a/source/blender/io/usd/hydra/volume_modifier.cc +++ b/source/blender/io/usd/hydra/volume_modifier.cc @@ -50,7 +50,7 @@ void VolumeModifierData::init() scene_delegate_->depsgraph, object, md); if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) { - CLOG_WARN(LOG_RENDER_HYDRA_SCENE, + CLOG_WARN(LOG_HYDRA_SCENE, "Volume %s is't exported: only OpenVDB file format supported", prim_id.GetText()); return; diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index 14fe1949b748..dc8cae9bdb17 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -24,7 +24,7 @@ namespace blender::render::hydra { -CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA, "render.hydra"); +CLG_LOGREF_DECLARE_GLOBAL(LOG_HYDRA_RENDER, "hydra.render"); Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name) : render_delegate_name_(render_delegate_name), bl_engine_(bl_engine) @@ -78,9 +78,11 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name) void Engine::sync(Depsgraph *depsgraph, bContext *context) { - const Scene *scene = DEG_get_evaluated_scene(depsgraph); + depsgraph_ = depsgraph; + context_ = context; + scene_ = DEG_get_evaluated_scene(depsgraph); - if (scene->hydra.export_method == SCE_HYDRA_EXPORT_HYDRA) { + if (scene_->hydra.export_method == SCE_HYDRA_EXPORT_HYDRA) { /* Fast path. */ usd_scene_delegate_.reset(); @@ -128,7 +130,7 @@ float Engine::renderer_percent_done() pxr::VtDictionary render_stats = render_delegate_->GetRenderStats(); auto it = render_stats.find("percentDone"); if (it == render_stats.end()) { - return 0.0; + return 0.0f; } return (float)it->second.UncheckedGet(); } diff --git a/source/blender/render/hydra/engine.h b/source/blender/render/hydra/engine.h index 30a62e7d27f5..709fb4dad369 100644 --- a/source/blender/render/hydra/engine.h +++ b/source/blender/render/hydra/engine.h @@ -27,12 +27,15 @@ struct CLG_LogRef; namespace blender::render::hydra { -extern struct CLG_LogRef *LOG_RENDER_HYDRA; +extern struct CLG_LogRef *LOG_HYDRA_RENDER; class Engine { protected: std::string render_delegate_name_; RenderEngine *bl_engine_ = nullptr; + Depsgraph *depsgraph_ = nullptr; + bContext *context_ = nullptr; + Scene *scene_ = nullptr; /* The order is important due to deletion order */ pxr::HgiUniquePtr hgi_; @@ -54,13 +57,14 @@ class Engine { virtual ~Engine() = default; void sync(Depsgraph *depsgraph, bContext *context); - virtual void render(Depsgraph *depsgraph) = 0; + virtual void render() = 0; void set_sync_setting(const std::string &key, const pxr::VtValue &val); void set_render_setting(const std::string &key, const pxr::VtValue &val); protected: float renderer_percent_done(); + virtual void notify_status(float progress, const std::string &title, const std::string &info) = 0; }; } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 12fe44325d62..35fa92cfa30f 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -23,19 +23,14 @@ namespace blender::render::hydra { -/* FinalEngine implementation */ - -void FinalEngine::render(Depsgraph *depsgraph) +void FinalEngine::render() { - const Scene *scene = DEG_get_evaluated_scene(depsgraph); - const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); + const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph_); char scene_name[MAX_ID_FULL_NAME]; - BKE_id_full_name_get(scene_name, &scene->id, 0); - scene_name_ = scene_name; - layer_name_ = view_layer->name; + BKE_id_full_name_get(scene_name, &scene_->id, 0); - const RenderData &r = scene->r; + const RenderData &r = scene_->r; pxr::GfVec4f border(0, 0, 1, 1); if (r.mode & R_BORDER) { border.Set(r.border.xmin, @@ -44,14 +39,15 @@ void FinalEngine::render(Depsgraph *depsgraph) r.border.ymax - r.border.ymin); } pxr::GfVec2i image_res(r.xsch * r.size / 100, r.ysch * r.size / 100); - resolution_ = pxr::GfVec2i(int(image_res[0] * border[2]), int(image_res[1] * border[3])); + int width = image_res[0] * border[2]; + int height = image_res[1] * border[3]; pxr::GfCamera camera = - io::hydra::CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border); + io::hydra::CameraData(scene_->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border); free_camera_delegate_->SetCamera(camera); - render_task_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1])); + render_task_delegate_->set_viewport(pxr::GfVec4d(0, 0, width, height)); if (light_tasks_delegate_) { - light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1])); + light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, width, height)); } render_task_delegate_->add_aov(pxr::HdAovTokens->color); @@ -61,7 +57,7 @@ void FinalEngine::render(Depsgraph *depsgraph) pxr::HdTaskSharedPtrVector tasks; if (light_tasks_delegate_) { - if (scene->r.alphamode != R_ALPHAPREMUL) { + if (scene_->r.alphamode != R_ALPHAPREMUL) { tasks.push_back(light_tasks_delegate_->skydome_task()); } tasks.push_back(light_tasks_delegate_->simple_task()); @@ -82,7 +78,7 @@ void FinalEngine::render(Depsgraph *depsgraph) BLI_timecode_string_from_time_simple( elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin); notify_status(percent_done / 100.0, - scene_name_ + ": " + layer_name_, + std::string(scene_name) + ": " + view_layer->name, std::string("Render Time: ") + elapsed_time + " | Done: " + std::to_string(int(percent_done)) + "%"); @@ -90,10 +86,10 @@ void FinalEngine::render(Depsgraph *depsgraph) break; } - update_render_result(); + update_render_result(width, height, view_layer->name); } - update_render_result(); + update_render_result(width, height, view_layer->name); render_task_delegate_->unbind(); } @@ -103,13 +99,12 @@ void FinalEngine::notify_status(float progress, const std::string &title, const RE_engine_update_stats(bl_engine_, title.c_str(), info.c_str()); } -void FinalEngine::update_render_result() +void FinalEngine::update_render_result(int width, int height, const char *layer_name) { - RenderResult *rr = RE_engine_begin_result( - bl_engine_, 0, 0, resolution_[0], resolution_[1], layer_name_.c_str(), nullptr); + RenderResult *rr = RE_engine_begin_result(bl_engine_, 0, 0, width, height, layer_name, nullptr); RenderLayer *rlayer = static_cast( - BLI_findstring(&rr->layers, layer_name_.c_str(), offsetof(RenderLayer, name))); + BLI_findstring(&rr->layers, layer_name, offsetof(RenderLayer, name))); if (rlayer) { LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) { diff --git a/source/blender/render/hydra/final_engine.h b/source/blender/render/hydra/final_engine.h index 0802d8b9f19c..51c7bd23e655 100644 --- a/source/blender/render/hydra/final_engine.h +++ b/source/blender/render/hydra/final_engine.h @@ -8,19 +8,16 @@ namespace blender::render::hydra { class FinalEngine : public Engine { - protected: - std::string scene_name_; - std::string layer_name_; - pxr::GfVec2i resolution_; - public: using Engine::Engine; - void render(Depsgraph *depsgraph) override; + void render() override; protected: - virtual void notify_status(float progress, const std::string &title, const std::string &info); - void update_render_result(); + void notify_status(float progress, const std::string &title, const std::string &info) override; + + private: + void update_render_result(int width, int height, const char *layer_name); }; } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index fe2a9295452c..a03da640a5a7 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -50,11 +50,11 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args) } } catch (std::runtime_error &e) { - CLOG_ERROR(LOG_RENDER_HYDRA, "%s", e.what()); + CLOG_ERROR(LOG_HYDRA_RENDER, "%s", e.what()); } if (engine) { - CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p %s", engine, engine_type); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "Engine %p %s", engine, engine_type); } return PyLong_FromVoidPtr(engine); } @@ -69,7 +69,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args) Engine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); delete engine; - CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p", engine); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "Engine %p", engine); Py_RETURN_NONE; } @@ -84,7 +84,7 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args) Depsgraph *depsgraph = pyrna_to_pointer(pydepsgraph, &RNA_Depsgraph); bContext *context = pyrna_to_pointer(pycontext, &RNA_Context); - CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine); + CLOG_INFO(LOG_HYDRA_RENDER, 2, "Engine %p", engine); engine->sync(depsgraph, context); Py_RETURN_NONE; @@ -93,19 +93,17 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args) static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args) { PyObject *pyengine, *pydepsgraph; - if (!PyArg_ParseTuple(args, "OO", &pyengine, &pydepsgraph)) { Py_RETURN_NONE; } Engine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); - Depsgraph *depsgraph = pyrna_to_pointer(pydepsgraph, &RNA_Depsgraph); - CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine); + CLOG_INFO(LOG_HYDRA_RENDER, 2, "Engine %p", engine); /* Allow Blender to execute other Python scripts. */ Py_BEGIN_ALLOW_THREADS; - engine->render(depsgraph); + engine->render(); Py_END_ALLOW_THREADS; Py_RETURN_NONE; @@ -119,14 +117,12 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args) } ViewportEngine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); - Depsgraph *depsgraph = pyrna_to_pointer(pydepsgraph, &RNA_Depsgraph); - bContext *context = pyrna_to_pointer(pycontext, &RNA_Context); - CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p", engine); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p", engine); /* Allow Blender to execute other Python scripts. */ Py_BEGIN_ALLOW_THREADS; - engine->render(depsgraph, context); + engine->render(); Py_END_ALLOW_THREADS; Py_RETURN_NONE; @@ -160,7 +156,7 @@ static PyObject *engine_set_sync_setting_func(PyObject * /*self*/, PyObject *arg Engine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); - CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p: %s", engine, key); engine->set_sync_setting(key, get_setting_val(pyval)); Py_RETURN_NONE; @@ -176,7 +172,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a Engine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); - CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p: %s", engine, key); engine->set_render_setting(key, get_setting_val(pyval)); Py_RETURN_NONE; diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 4438e7bce56d..c945e1b68295 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -212,15 +212,9 @@ GPUTexture *DrawTexture::texture() const return texture_; } -void ViewportEngine::render(Depsgraph * /* depsgraph */) +void ViewportEngine::render() { - /* Empty function */ -} - -void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) -{ - ViewSettings view_settings(context); - const Scene *scene = DEG_get_evaluated_scene(depsgraph); + ViewSettings view_settings(context_); if (view_settings.width() * view_settings.height() == 0) { return; }; @@ -254,7 +248,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) pxr::HdTaskSharedPtrVector tasks; if (light_tasks_delegate_) { - if (scene->r.alphamode != R_ALPHAPREMUL) { + if (scene_->r.alphamode != R_ALPHAPREMUL) { tasks.push_back(light_tasks_delegate_->skydome_task()); } tasks.push_back(light_tasks_delegate_->simple_task()); @@ -283,18 +277,21 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) BLI_timecode_string_from_time_simple( elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); + float percent_done = renderer_percent_done(); if (!render_task_delegate_->is_converged()) { - notify_status(std::string("Time: ") + elapsed_time + - " | Done: " + std::to_string(int(renderer_percent_done())) + "%", + notify_status(percent_done / 100.0, + std ::string("Time: ") + elapsed_time + + " | Done: " + std::to_string(int(percent_done)) + "%", "Render"); bl_engine_->flag |= RE_ENGINE_DO_DRAW; } else { - notify_status((std::string("Time: ") + elapsed_time).c_str(), "Rendering Done"); + notify_status(percent_done / 100.0, std::string("Time: ") + elapsed_time, "Rendering Done"); } } -void ViewportEngine::notify_status(const std::string &info, const std::string &status) +void ViewportEngine::notify_status(float /*progress*/, const std::string &info, + const std::string &status) { RE_engine_update_stats(bl_engine_, status.c_str(), info.c_str()); } diff --git a/source/blender/render/hydra/viewport_engine.h b/source/blender/render/hydra/viewport_engine.h index 60b889846284..ab0e970a38fe 100644 --- a/source/blender/render/hydra/viewport_engine.h +++ b/source/blender/render/hydra/viewport_engine.h @@ -38,11 +38,10 @@ class ViewportEngine : public Engine { public: using Engine::Engine; - void render(Depsgraph *depsgraph) override; - void render(Depsgraph *depsgraph, bContext *context); + void render() override; - private: - void notify_status(const std::string &title, const std::string &info); + protected: + void notify_status(float progress, const std::string &title, const std::string &info) override; }; } // namespace blender::render::hydra -- 2.30.2 From 554c7ecab4962de0436ed9e9ccea606349af4a7b Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Sat, 29 Jul 2023 16:14:52 +0300 Subject: [PATCH 2/6] Fixes after merging --- .../blender/render/hydra/light_tasks_delegate.cc | 6 +++--- .../blender/render/hydra/render_task_delegate.cc | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/render/hydra/light_tasks_delegate.cc b/source/blender/render/hydra/light_tasks_delegate.cc index 44b9f4f71448..0f4ef1295724 100644 --- a/source/blender/render/hydra/light_tasks_delegate.cc +++ b/source/blender/render/hydra/light_tasks_delegate.cc @@ -15,13 +15,13 @@ LightTasksDelegate::LightTasksDelegate(pxr::HdRenderIndex *parent_index, 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()); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", simple_task_id_.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 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()); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "%s, %s", id.GetText(), key.GetText()); if (key == pxr::HdTokens->params) { if (id == simple_task_id_) { diff --git a/source/blender/render/hydra/render_task_delegate.cc b/source/blender/render/hydra/render_task_delegate.cc index d0733d450965..6772920e1d3b 100644 --- a/source/blender/render/hydra/render_task_delegate.cc +++ b/source/blender/render/hydra/render_task_delegate.cc @@ -28,12 +28,12 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index, task_params_.enableLighting = true; task_params_.alphaThreshold = 0.1f; - CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", task_id_.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", task_id_.GetText()); } pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { - CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "%s, %s", id.GetText(), key.GetText()); if (key == pxr::HdTokens->params) { return pxr::VtValue(task_params_); @@ -47,14 +47,14 @@ pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const &id) { - CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 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()); + CLOG_INFO(LOG_HYDRA_RENDER, 3, "%s", id.GetText()); return buffer_descriptors_[id]; } @@ -124,7 +124,7 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) task_params_.aovBindings.push_back(binding); render_index.GetChangeTracker().MarkTaskDirty(task_id_, pxr::HdChangeTracker::DirtyParams); - CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", aov_key.GetText()); } void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) @@ -225,7 +225,7 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key) GPU_TEXTURE_USAGE_GENERAL, nullptr); - CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText()); + CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", aov_key.GetText()); } void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) @@ -289,6 +289,7 @@ void GPURenderTaskDelegate::bind() glGenVertexArrays(1, &VAO_); glBindVertexArray(VAO_); } + CLOG_INFO(LOG_HYDRA_RENDER, 3, ""); } void GPURenderTaskDelegate::unbind() @@ -301,6 +302,7 @@ void GPURenderTaskDelegate::unbind() GPU_framebuffer_free(framebuffer_); framebuffer_ = nullptr; } + CLOG_INFO(LOG_HYDRA_RENDER, 3, ""); } GPUTexture *GPURenderTaskDelegate::aov_texture(pxr::TfToken const &aov_key) -- 2.30.2 From e1806a7ea026a0b483d81766e8b8cc7d824d39b4 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Sat, 29 Jul 2023 16:40:32 +0300 Subject: [PATCH 3/6] Fixed viewport updates --- source/blender/render/hydra/python.cc | 3 ++- source/blender/render/hydra/viewport_engine.cc | 6 ++++++ source/blender/render/hydra/viewport_engine.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index a03da640a5a7..0b1589c8397a 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -117,12 +117,13 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args) } ViewportEngine *engine = static_cast(PyLong_AsVoidPtr(pyengine)); + bContext *context = pyrna_to_pointer(pycontext, &RNA_Context); CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p", engine); /* Allow Blender to execute other Python scripts. */ Py_BEGIN_ALLOW_THREADS; - engine->render(); + engine->render(context); Py_END_ALLOW_THREADS; Py_RETURN_NONE; diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index ec1f187bb074..0c19c4b4f620 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -287,6 +287,12 @@ void ViewportEngine::render() } } +void ViewportEngine::render(bContext *context) +{ + context_ = context; + render(); +} + void ViewportEngine::notify_status(float /*progress*/, const std::string &info, const std::string &status) { diff --git a/source/blender/render/hydra/viewport_engine.h b/source/blender/render/hydra/viewport_engine.h index 78080832580d..32d4fa739082 100644 --- a/source/blender/render/hydra/viewport_engine.h +++ b/source/blender/render/hydra/viewport_engine.h @@ -38,6 +38,7 @@ class ViewportEngine : public Engine { using Engine::Engine; void render() override; + void render(bContext *context); protected: void notify_status(float progress, const std::string &title, const std::string &info) override; -- 2.30.2 From 4f0a20760d8a6f99426656445a998ca69f465c95 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Sat, 29 Jul 2023 17:13:47 +0300 Subject: [PATCH 4/6] Moved AOV tokens map to FinalEngine as more related --- source/blender/render/hydra/engine.cc | 8 +----- source/blender/render/hydra/engine.h | 7 +---- source/blender/render/hydra/final_engine.cc | 26 ++++++++++++++----- source/blender/render/hydra/final_engine.h | 4 +++ .../render/hydra/render_task_delegate.h | 2 +- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index 55519b4906c6..3bdd928c501b 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -120,13 +120,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 (STRPREFIX(key.c_str(), "aovToken:")) { - render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1), - pxr::TfToken(val.UncheckedGet())); - } - else { - render_delegate_->SetRenderSetting(pxr::TfToken(key), val); - } + 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 7bd0091bbdf6..7fe68c81d9f7 100644 --- a/source/blender/render/hydra/engine.h +++ b/source/blender/render/hydra/engine.h @@ -29,10 +29,6 @@ namespace blender::render::hydra { extern struct CLG_LogRef *LOG_HYDRA_RENDER; -struct RenderDelegateSettings { - Map aovs; -}; - class Engine { protected: std::string render_delegate_name_; @@ -51,7 +47,6 @@ 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_; @@ -65,7 +60,7 @@ class Engine { virtual void render() = 0; void set_sync_setting(const std::string &key, const pxr::VtValue &val); - void set_render_setting(const std::string &key, const pxr::VtValue &val); + virtual void set_render_setting(const std::string &key, const pxr::VtValue &val); protected: float renderer_percent_done(); diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 3d1cb5086982..72d3554b336d 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -55,13 +55,15 @@ void FinalEngine::render() 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 = render_delegate_settings_.aovs.lookup_ptr(pass->name); - if (aov_token) { - render_task_delegate_->add_aov(*aov_token); + RenderResult *rr = RE_engine_get_result(bl_engine_); + RenderLayer *rlayer = (RenderLayer *)rr->layers.first; + LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) { + pxr::TfToken *aov_token = aov_tokens_.lookup_ptr(rpass->name); + if (!aov_token) { + CLOG_WARN(LOG_HYDRA_RENDER, "Couldn't find AOV token for render pass: %s", rpass->name); + continue; } + render_task_delegate_->add_aov(*aov_token); } pxr::HdTaskSharedPtrVector tasks; @@ -105,6 +107,16 @@ void FinalEngine::render() render_task_delegate_->unbind(); } +void FinalEngine::set_render_setting(const std::string &key, const pxr::VtValue &val) +{ + if (STRPREFIX(key.c_str(), "aovToken:")) { + aov_tokens_.add_overwrite(key.substr(key.find(":") + 1), + pxr::TfToken(val.UncheckedGet())); + return; + } + Engine::set_render_setting(key, val); +} + void FinalEngine::notify_status(float progress, const std::string &title, const std::string &info) { RE_engine_update_progress(bl_engine_, progress); @@ -120,7 +132,7 @@ void FinalEngine::update_render_result(int width, int height, const char *layer_ if (rlayer) { LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) { - pxr::TfToken *aov_token = render_delegate_settings_.aovs.lookup_ptr(rpass->name); + pxr::TfToken *aov_token = aov_tokens_.lookup_ptr(rpass->name); if (aov_token) { render_task_delegate_->read_aov(*aov_token, rpass->ibuf->float_buffer.data); } diff --git a/source/blender/render/hydra/final_engine.h b/source/blender/render/hydra/final_engine.h index 51c7bd23e655..b61044aa4e52 100644 --- a/source/blender/render/hydra/final_engine.h +++ b/source/blender/render/hydra/final_engine.h @@ -8,10 +8,14 @@ namespace blender::render::hydra { class FinalEngine : public Engine { + private: + Map aov_tokens_; + public: using Engine::Engine; void render() override; + void set_render_setting(const std::string &key, const pxr::VtValue &val) override; protected: void notify_status(float progress, const std::string &title, const std::string &info) override; diff --git a/source/blender/render/hydra/render_task_delegate.h b/source/blender/render/hydra/render_task_delegate.h index 0092fc73c40a..36e7b56b0f45 100644 --- a/source/blender/render/hydra/render_task_delegate.h +++ b/source/blender/render/hydra/render_task_delegate.h @@ -31,7 +31,7 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { pxr::HdTaskSharedPtr task(); void set_camera(pxr::SdfPath const &camera_id); - virtual bool is_converged(); + 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); -- 2.30.2 From b617ff78c825c1c36c876db26baa68d5c0dd8f6c Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Sat, 29 Jul 2023 17:24:48 +0300 Subject: [PATCH 5/6] AOVs set improvement --- source/blender/render/hydra/final_engine.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 72d3554b336d..2413f67d1ba6 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -50,11 +50,6 @@ void FinalEngine::render() light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, width, height)); } - 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 *rr = RE_engine_get_result(bl_engine_); RenderLayer *rlayer = (RenderLayer *)rr->layers.first; LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) { @@ -65,6 +60,11 @@ void FinalEngine::render() } render_task_delegate_->add_aov(*aov_token); } + if (bl_engine_->type->flag & RE_USE_GPU_CONTEXT) { + /* For GPU context engine color and depth AOVs has to be added anyway */ + render_task_delegate_->add_aov(pxr::HdAovTokens->color); + render_task_delegate_->add_aov(pxr::HdAovTokens->depth); + } pxr::HdTaskSharedPtrVector tasks; if (light_tasks_delegate_) { -- 2.30.2 From 435f332055afc446142a8301cf4e62748e924e45 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Sat, 29 Jul 2023 17:39:32 +0300 Subject: [PATCH 6/6] Simplification in python.cc and bpy_types.py --- scripts/modules/bpy_types.py | 7 +++---- source/blender/render/hydra/python.cc | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index 8ac414bc2146..bb770aa91b7c 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -1283,7 +1283,6 @@ class HydraRenderEngine(RenderEngine): # Final render. def update(self, data, depsgraph): import _bpy_hydra - import bpy engine_type = 'PREVIEW' if self.is_preview else 'FINAL' if not self.engine_ptr: @@ -1294,7 +1293,7 @@ class HydraRenderEngine(RenderEngine): for key, val in self.get_sync_settings(engine_type).items(): _bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val) - _bpy_hydra.engine_update(self.engine_ptr, depsgraph, bpy.context) + _bpy_hydra.engine_update(self.engine_ptr, depsgraph, None) for key, val in self.get_render_settings('PREVIEW' if self.is_preview else 'FINAL').items(): _bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val) @@ -1304,7 +1303,7 @@ class HydraRenderEngine(RenderEngine): return import _bpy_hydra - _bpy_hydra.engine_render(self.engine_ptr, depsgraph) + _bpy_hydra.engine_render(self.engine_ptr) # Viewport render. def view_update(self, context, depsgraph): @@ -1327,4 +1326,4 @@ class HydraRenderEngine(RenderEngine): return import _bpy_hydra - _bpy_hydra.engine_view_draw(self.engine_ptr, depsgraph, context) + _bpy_hydra.engine_view_draw(self.engine_ptr, context) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index 0b1589c8397a..cec3a0bd377f 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -92,8 +92,8 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args) static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args) { - PyObject *pyengine, *pydepsgraph; - if (!PyArg_ParseTuple(args, "OO", &pyengine, &pydepsgraph)) { + PyObject *pyengine; + if (!PyArg_ParseTuple(args, "O", &pyengine)) { Py_RETURN_NONE; } @@ -111,8 +111,8 @@ static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args) static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args) { - PyObject *pyengine, *pydepsgraph, *pycontext; - if (!PyArg_ParseTuple(args, "OOO", &pyengine, &pydepsgraph, &pycontext)) { + PyObject *pyengine, *pycontext; + if (!PyArg_ParseTuple(args, "OO", &pyengine, &pycontext)) { Py_RETURN_NONE; } -- 2.30.2