From c367279df3e4ab3e2fe91a79b8415a6067a22771 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 18 Apr 2023 15:23:06 +0300 Subject: [PATCH 01/12] added setting HGI_ENABLE_VULKAN env var for hgi renamed logging --- source/blender/render/hydra/engine.cc | 9 ++++++- source/blender/render/hydra/engine.h | 2 +- source/blender/render/hydra/preview_engine.cc | 2 +- source/blender/render/hydra/python.cc | 14 +++++------ .../scene_delegate/blender_scene_delegate.cc | 24 +++++++++---------- .../scene_delegate/blender_scene_delegate.h | 2 +- .../render/hydra/scene_delegate/instancer.cc | 14 +++++------ .../render/hydra/scene_delegate/light.cc | 10 ++++---- .../render/hydra/scene_delegate/material.cc | 16 ++++++------- .../render/hydra/scene_delegate/mesh.cc | 10 ++++---- .../render/hydra/scene_delegate/world.cc | 10 ++++---- 11 files changed, 60 insertions(+), 53 deletions(-) diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index 26026dad49ea..1aa1bedecfd5 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -8,11 +8,14 @@ #include #include +#include "BLI_path_util.h" +#include "GPU_context.h" + #include "engine.h" namespace blender::render::hydra { -CLG_LOGREF_DECLARE_GLOBAL(LOG_EN, "rhd.en"); +CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA, "render.hydra"); Engine::Engine(RenderEngine *bl_engine, const std::string &delegate_id) : bl_engine_(bl_engine) { @@ -21,6 +24,10 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &delegate_id) : bl_eng pxr::TF_PY_ALLOW_THREADS_IN_SCOPE(); render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(delegate_id)); + if (GPU_backend_get_type() == GPU_BACKEND_VULKAN) { + BLI_setenv("HGI_ENABLE_VULKAN", "1"); + } + pxr::HdDriverVector hd_drivers; if (bl_engine->type->flag & RE_USE_GPU_CONTEXT) { hgi_ = pxr::Hgi::CreatePlatformDefaultHgi(); diff --git a/source/blender/render/hydra/engine.h b/source/blender/render/hydra/engine.h index 4de015e51ee1..6fb1ea14b139 100644 --- a/source/blender/render/hydra/engine.h +++ b/source/blender/render/hydra/engine.h @@ -21,7 +21,7 @@ namespace blender::render::hydra { -extern struct CLG_LogRef *LOG_EN; /* EN - Engine */ +extern struct CLG_LogRef *LOG_RENDER_HYDRA; /* EN - Engine */ class Engine { public: diff --git a/source/blender/render/hydra/preview_engine.cc b/source/blender/render/hydra/preview_engine.cc index 08b1f5b90c7d..4992c67f9636 100644 --- a/source/blender/render/hydra/preview_engine.cc +++ b/source/blender/render/hydra/preview_engine.cc @@ -109,7 +109,7 @@ double PreviewEngine::free_instance(uintptr_t uuid, void *user_data) return LIFETIME; } - CLOG_INFO(LOG_EN, 2, ""); + CLOG_INFO(LOG_RENDER_HYDRA, 2, ""); instance_ = nullptr; return -1; } diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index e445ead763a2..c4d10e8b24c3 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -22,7 +22,7 @@ namespace blender::render::hydra { static PyObject *init_func(PyObject * /*self*/, PyObject *args) { - CLOG_INFO(LOG_EN, 1, "Init"); + CLOG_INFO(LOG_RENDER_HYDRA, 1, "Init"); pxr::PlugRegistry::GetInstance().RegisterPlugins(std::string(BKE_appdir_program_dir()) + "/blender.shared/usd"); @@ -59,7 +59,7 @@ static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args) ss << s << ", "; } ss << "]"; - CLOG_INFO(LOG_EN, 1, "Register %s", ss.str().c_str()); + CLOG_INFO(LOG_RENDER_HYDRA, 1, "Register %s", ss.str().c_str()); Py_RETURN_NONE; } @@ -125,7 +125,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args) } } - CLOG_INFO(LOG_EN, 2, "Engine %016llx %s", engine, engine_type); + CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx %s", engine, engine_type); return PyLong_FromVoidPtr(engine); } @@ -146,7 +146,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args) delete engine; } - CLOG_INFO(LOG_EN, 2, "Engine %016llx", engine); + CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine); Py_RETURN_NONE; } @@ -185,7 +185,7 @@ static PyObject *engine_sync_func(PyObject * /*self*/, PyObject *args) engine->sync(depsgraph, context, settings); - CLOG_INFO(LOG_EN, 2, "Engine %016llx", engine); + CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine); Py_RETURN_NONE; } @@ -205,7 +205,7 @@ static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args) engine->render(depsgraph); Py_END_ALLOW_THREADS; - CLOG_INFO(LOG_EN, 2, "Engine %016llx", engine); + CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine); Py_RETURN_NONE; } @@ -225,7 +225,7 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args) engine->render(depsgraph, context); Py_END_ALLOW_THREADS; - CLOG_INFO(LOG_EN, 3, "Engine %016llx", engine); + CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx", engine); Py_RETURN_NONE; } diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index b86bf0ab200b..5253f32842e9 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -11,7 +11,7 @@ namespace blender::render::hydra { -CLG_LOGREF_DECLARE_GLOBAL(LOG_BSD, "rhd.bsd"); +CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA_SCENE, "render.hydra.scene"); BlenderSceneDelegate::BlenderSceneDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id, @@ -44,7 +44,7 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont) unsigned int scene_recalc = ((ID *)scene_)->recalc; if (scene_recalc) { /* Checking scene updates */ - CLOG_INFO(LOG_BSD, + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "Update: %s [%s]", ((ID *)scene_)->name, @@ -74,7 +74,7 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont) DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) { CLOG_INFO( - LOG_BSD, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str()); + LOG_RENDER_HYDRA_SCENE, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str()); switch (GS(id->name)) { case ID_OB: { @@ -125,14 +125,14 @@ void BlenderSceneDelegate::clear() pxr::HdMeshTopology BlenderSceneDelegate::GetMeshTopology(pxr::SdfPath const &id) { - CLOG_INFO(LOG_BSD, 3, "%s", id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); MeshData *m_data = mesh_data(id); return m_data->mesh_topology(); } pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id) { - CLOG_INFO(LOG_BSD, 3, "%s", id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText()); ObjectData *obj_data = object_data(id); if (obj_data) { return obj_data->transform(); @@ -152,7 +152,7 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id) pxr::VtValue BlenderSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) { - CLOG_INFO(LOG_BSD, 3, "%s, %s", id.GetText(), key.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText()); ObjectData *obj_data = object_data(id); if (obj_data) { @@ -188,7 +188,7 @@ pxr::VtValue BlenderSceneDelegate::GetLightParamValue(pxr::SdfPath const &id, pxr::HdPrimvarDescriptorVector BlenderSceneDelegate::GetPrimvarDescriptors( pxr::SdfPath const &id, pxr::HdInterpolation interpolation) { - CLOG_INFO(LOG_BSD, 3, "%s, %d", id.GetText(), interpolation); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %d", id.GetText(), interpolation); MeshData *m_data = mesh_data(id); if (m_data) { @@ -228,7 +228,7 @@ bool BlenderSceneDelegate::GetVisible(pxr::SdfPath const &id) pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id) { - CLOG_INFO(LOG_BSD, 3, "%s", prim_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", prim_id.GetText()); InstancerData *i_data = instancer_data(prim_id, true); if (i_data) { return i_data->instancer_id; @@ -238,7 +238,7 @@ pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id) pxr::SdfPathVector BlenderSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const &instancer_id) { - CLOG_INFO(LOG_BSD, 3, "%s", instancer_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); pxr::SdfPathVector paths; paths.push_back(instancer_id.GetParentPath()); return paths; @@ -247,14 +247,14 @@ pxr::SdfPathVector BlenderSceneDelegate::GetInstancerPrototypes(pxr::SdfPath con pxr::VtIntArray BlenderSceneDelegate::GetInstanceIndices(pxr::SdfPath const &instancer_id, pxr::SdfPath const &prototype_id) { - CLOG_INFO(LOG_BSD, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText()); InstancerData *i_data = instancer_data(instancer_id); return i_data->instance_indices(); } pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const &instancer_id) { - CLOG_INFO(LOG_BSD, 3, "%s", instancer_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText()); InstancerData *i_data = instancer_data(instancer_id); return i_data->transform(); } @@ -391,7 +391,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility) Object *, object) { - CLOG_INFO(LOG_BSD, 2, "Add %s", ((ID *)object)->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "Add %s", ((ID *)object)->name); if (!ObjectData::is_supported(object)) { continue; } diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h index 48c84e987e14..847246dec3a6 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h @@ -18,7 +18,7 @@ namespace blender::render::hydra { -extern struct CLG_LogRef *LOG_BSD; /* BSD - Blender Scene Delegate */ +extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE; /* BSD - Blender Scene Delegate */ class BlenderSceneDelegate : public pxr::HdSceneDelegate { friend MeshData; diff --git a/source/blender/render/hydra/scene_delegate/instancer.cc b/source/blender/render/hydra/scene_delegate/instancer.cc index 8e85c641841f..40486362f63e 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.cc +++ b/source/blender/render/hydra/scene_delegate/instancer.cc @@ -15,7 +15,7 @@ InstancerData::InstancerData(BlenderSceneDelegate *scene_delegate, Object *objec id_ = nullptr; p_id_ = prim_id(scene_delegate, object); instancer_id = p_id_.AppendElementString("Instancer"); - CLOG_INFO(LOG_BSD, 2, "%s, instancer_id=%s", ((ID *)parent_obj_)->name, instancer_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s, instancer_id=%s", ((ID *)parent_obj_)->name, instancer_id.GetText()); } bool InstancerData::is_supported(Object *object) @@ -54,7 +54,7 @@ pxr::SdfPath InstancerData::prim_id(BlenderSceneDelegate *scene_delegate, Object void InstancerData::init() { - CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj_)->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", ((ID *)parent_obj_)->name); set_instances(); MeshData::init(); @@ -62,7 +62,7 @@ void InstancerData::init() void InstancerData::insert() { - CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj_)->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", ((ID *)parent_obj_)->name); MeshData::insert(); if (face_vertex_counts_.empty()) { @@ -73,7 +73,7 @@ void InstancerData::insert() void InstancerData::remove() { - CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj_)->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", ((ID *)parent_obj_)->name); if (!scene_delegate_->GetRenderIndex().HasInstancer(instancer_id)) { return; @@ -85,7 +85,7 @@ void InstancerData::remove() void InstancerData::update() { - CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj_)->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", ((ID *)parent_obj_)->name); pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean; unsigned int recalc = ((ID *)parent_obj_)->recalc; @@ -113,7 +113,7 @@ void InstancerData::update() pxr::VtValue InstancerData::get_data(pxr::TfToken const &key) const { - CLOG_INFO(LOG_BSD, 3, "%s [%s]", id_->name, key.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s [%s]", id_->name, key.GetText()); if (key == pxr::HdInstancerTokens->instanceTransform) { return pxr::VtValue(transforms_); @@ -185,7 +185,7 @@ bool InstancerData::set_instances() } transforms_.push_back(gf_matrix_from_transform(dupli->mat)); CLOG_INFO( - LOG_BSD, 2, "Instance %s (%s) %d", id_->name, ((ID *)dupli->ob)->name, dupli->random_id); + LOG_RENDER_HYDRA_SCENE, 2, "Instance %s (%s) %d", id_->name, ((ID *)dupli->ob)->name, dupli->random_id); } free_object_duplilist(lb); diff --git a/source/blender/render/hydra/scene_delegate/light.cc b/source/blender/render/hydra/scene_delegate/light.cc index ca99694a57de..de3afa738451 100644 --- a/source/blender/render/hydra/scene_delegate/light.cc +++ b/source/blender/render/hydra/scene_delegate/light.cc @@ -17,12 +17,12 @@ namespace blender::render::hydra { LightData::LightData(BlenderSceneDelegate *scene_delegate, Object *object) : ObjectData(scene_delegate, object) { - CLOG_INFO(LOG_BSD, 2, "%s id=%s", id_->name, p_id_.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s id=%s", id_->name, p_id_.GetText()); } void LightData::init() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); Light *light = (Light *)((Object *)id_)->data; data_.clear(); @@ -87,19 +87,19 @@ void LightData::init() void LightData::insert() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().InsertSprim(p_type_, scene_delegate_, p_id_); } void LightData::remove() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().RemoveSprim(p_type_, p_id_); } void LightData::update() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); Light *light = (Light *)((Object *)id_)->data; if (prim_type(light) != p_type_) { diff --git a/source/blender/render/hydra/scene_delegate/material.cc b/source/blender/render/hydra/scene_delegate/material.cc index d13b011e89b3..88a179b39817 100644 --- a/source/blender/render/hydra/scene_delegate/material.cc +++ b/source/blender/render/hydra/scene_delegate/material.cc @@ -24,7 +24,7 @@ MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate, Material *mater : IdData(scene_delegate, (ID *)material) { p_id_ = prim_id(scene_delegate, material); - CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id_->name, p_id_.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s, id=%s", id_->name, p_id_.GetText()); } std::unique_ptr MaterialData::create(BlenderSceneDelegate *scene_delegate, @@ -47,7 +47,7 @@ pxr::SdfPath MaterialData::prim_id(BlenderSceneDelegate *scene_delegate, Materia void MaterialData::init() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); material_network_map_ = pxr::VtValue(); @@ -76,7 +76,7 @@ void MaterialData::init() Py_DECREF(result); } else { - CLOG_ERROR(LOG_BSD, "Export error for %s", id_->name); + CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Export error for %s", id_->name); PyErr_Print(); } Py_DECREF(module); @@ -84,25 +84,25 @@ void MaterialData::init() PyGILState_Release(gstate); mtlx_path_ = pxr::SdfAssetPath(path, path); - CLOG_INFO(LOG_BSD, 2, "Export: %s, mtlx=%s", id_->name, mtlx_path_.GetResolvedPath().c_str()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "Export: %s, mtlx=%s", id_->name, mtlx_path_.GetResolvedPath().c_str()); } void MaterialData::insert() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().InsertSprim( pxr::HdPrimTypeTokens->material, scene_delegate_, p_id_); } void MaterialData::remove() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->material, p_id_); } void MaterialData::update() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); init(); scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id_, pxr::HdMaterial::AllDirty); @@ -115,7 +115,7 @@ pxr::VtValue MaterialData::get_data(pxr::TfToken const &key) const if (!mtlx_path_.GetResolvedPath().empty()) { ret = mtlx_path_; } - CLOG_INFO(LOG_BSD, 3, "%s", key.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", key.GetText()); } return ret; } diff --git a/source/blender/render/hydra/scene_delegate/mesh.cc b/source/blender/render/hydra/scene_delegate/mesh.cc index 5c3340962277..959f072e86fb 100644 --- a/source/blender/render/hydra/scene_delegate/mesh.cc +++ b/source/blender/render/hydra/scene_delegate/mesh.cc @@ -18,12 +18,12 @@ namespace blender::render::hydra { MeshData::MeshData(BlenderSceneDelegate *scene_delegate, Object *object) : ObjectData(scene_delegate, object), mat_data_(nullptr) { - CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id_->name, p_id_.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s, id=%s", id_->name, p_id_.GetText()); } void MeshData::init() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); Object *object = (Object *)id_; if (object->type == OB_MESH && object->mode == OB_MODE_OBJECT && @@ -47,7 +47,7 @@ void MeshData::insert() return; } - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().InsertRprim( pxr::HdPrimTypeTokens->mesh, scene_delegate_, p_id_); } @@ -58,7 +58,7 @@ void MeshData::remove() return; } - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().RemoveRprim(p_id_); } @@ -94,7 +94,7 @@ void MeshData::update() remove(); return; } - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(p_id_, bits); } diff --git a/source/blender/render/hydra/scene_delegate/world.cc b/source/blender/render/hydra/scene_delegate/world.cc index e712d076c336..72a58c1ba8f8 100644 --- a/source/blender/render/hydra/scene_delegate/world.cc +++ b/source/blender/render/hydra/scene_delegate/world.cc @@ -32,7 +32,7 @@ WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContex : IdData(scene_delegate, (ID *)world), context_(context) { p_id_ = prim_id(scene_delegate); - CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id_->name, p_id_.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s, id=%s", id_->name, p_id_.GetText()); } std::unique_ptr WorldData::create(BlenderSceneDelegate *scene_delegate, @@ -52,7 +52,7 @@ pxr::SdfPath WorldData::prim_id(BlenderSceneDelegate *scene_delegate) void WorldData::init() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); World *world = (World *)id_; data_.clear(); @@ -125,20 +125,20 @@ void WorldData::init() void WorldData::insert() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().InsertSprim( pxr::HdPrimTypeTokens->domeLight, scene_delegate_, p_id_); } void WorldData::remove() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); scene_delegate_->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->domeLight, p_id_); } void WorldData::update() { - CLOG_INFO(LOG_BSD, 2, "%s", id_->name); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", id_->name); init(); scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id_, pxr::HdLight::AllDirty); -- 2.30.2 From 176406f4947a2040b424186213c4b0500a6e1a31 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 14:30:46 +0300 Subject: [PATCH 02/12] replaced utils.h/format_duration with BLI_timecode_string_from_time_simple --- source/blender/render/hydra/final_engine.cc | 41 +++++++++---------- source/blender/render/hydra/final_engine.h | 2 - source/blender/render/hydra/utils.cc | 31 -------------- source/blender/render/hydra/utils.h | 2 - .../blender/render/hydra/viewport_engine.cc | 26 ++++++------ source/blender/render/hydra/viewport_engine.h | 4 +- 6 files changed, 33 insertions(+), 73 deletions(-) diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index f2b8286fc04c..e37e75a3adb6 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -5,10 +5,11 @@ #include "DEG_depsgraph_query.h" #include "GPU_framebuffer.h" #include "GPU_texture.h" +#include "PIL_time.h" +#include "BLI_timecode.h" #include "camera.h" #include "final_engine.h" -#include "utils.h" namespace blender::render::hydra { @@ -63,12 +64,6 @@ void FinalEngine::render(Depsgraph *depsgraph) } tasks.push_back(render_task_delegate_->get_task()); - std::chrono::time_point time_begin = std::chrono::steady_clock::now(), - time_current; - std::chrono::milliseconds elapsed_time; - - float percent_done = 0.0; - std::map> render_images{ {"Combined", std::vector(res[0] * res[1] * 4)}}; /* 4 - number of channels. */ std::vector &pixels = render_images["Combined"]; @@ -79,19 +74,23 @@ void FinalEngine::render(Depsgraph *depsgraph) engine_->Execute(render_index_.get(), &tasks); } + char elapsed_time[32]; + double time_begin = PIL_check_seconds_timer(); + float percent_done = 0.0; + while (true) { if (RE_engine_test_break(bl_engine_)) { break; } - percent_done = renderer_percent_done(); - time_current = std::chrono::steady_clock::now(); - elapsed_time = std::chrono::duration_cast(time_current - - time_begin); + percent_done = renderer_percent_done(); + + 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, - "Render Time: " + format_duration(elapsed_time) + + std::string("Render Time: ") + elapsed_time + " | Done: " + std::to_string(int(percent_done)) + "%"); if (render_task_delegate_->is_converged()) { @@ -185,12 +184,6 @@ void FinalEngineGL::render(Depsgraph *depsgraph) } tasks.push_back(render_task_delegate_->get_task()); - std::chrono::time_point time_begin = std::chrono::steady_clock::now(), - time_current; - std::chrono::milliseconds elapsed_time; - - float percent_done = 0.0; - std::map> render_images{ {"Combined", std::vector(res[0] * res[1] * 4)}}; /* 4 - number of channels. */ std::vector &pixels = render_images["Combined"]; @@ -217,19 +210,23 @@ void FinalEngineGL::render(Depsgraph *depsgraph) engine_->Execute(render_index_.get(), &tasks); } + char elapsed_time[32]; + double time_begin = PIL_check_seconds_timer(); + float percent_done = 0.0; + while (true) { if (RE_engine_test_break(bl_engine_)) { break; } percent_done = renderer_percent_done(); - time_current = std::chrono::steady_clock::now(); - elapsed_time = std::chrono::duration_cast(time_current - - time_begin); + + 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, - "Render Time: " + format_duration(elapsed_time) + + std::string("Render Time: ") + elapsed_time + " | Done: " + std::to_string(int(percent_done)) + "%"); if (render_task_delegate_->is_converged()) { diff --git a/source/blender/render/hydra/final_engine.h b/source/blender/render/hydra/final_engine.h index 17473ad5ec74..388500a38710 100644 --- a/source/blender/render/hydra/final_engine.h +++ b/source/blender/render/hydra/final_engine.h @@ -3,8 +3,6 @@ #pragma once -#include - #include "engine.h" namespace blender::render::hydra { diff --git a/source/blender/render/hydra/utils.cc b/source/blender/render/hydra/utils.cc index 8d37a14ef7ac..97541c338e0e 100644 --- a/source/blender/render/hydra/utils.cc +++ b/source/blender/render/hydra/utils.cc @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: Apache-2.0 * Copyright 2011-2022 Blender Foundation */ -#include #include -#include #include @@ -29,35 +27,6 @@ pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]) return ret; } -std::string format_duration(std::chrono::milliseconds millisecs) -{ - std::stringstream ss; - bool neg = millisecs < std::chrono::milliseconds(0); - if (neg) { - millisecs = -millisecs; - } - auto m = std::chrono::duration_cast(millisecs); - millisecs -= m; - auto s = std::chrono::duration_cast(millisecs); - millisecs -= s; - if (neg) { - ss << "-"; - } - if (m < std::chrono::minutes(10)) { - ss << "0"; - } - ss << std::to_string(m / std::chrono::minutes(1)) << ":"; - if (s < std::chrono::seconds(10)) { - ss << "0"; - } - ss << std::to_string(s / std::chrono::seconds(1)) << ":"; - if (millisecs < std::chrono::milliseconds(10)) { - ss << "0"; - } - ss << std::to_string(millisecs / std::chrono::milliseconds(1) / 10); - return ss.str(); -} - std::string cache_image(Main *bmain, Scene *scene, Image *image, diff --git a/source/blender/render/hydra/utils.h b/source/blender/render/hydra/utils.h index 05d7c85fc610..e71c64e9b5d8 100644 --- a/source/blender/render/hydra/utils.h +++ b/source/blender/render/hydra/utils.h @@ -3,7 +3,6 @@ #pragma once -#include #include #include @@ -14,7 +13,6 @@ namespace blender::render::hydra { pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]); -std::string format_duration(std::chrono::milliseconds secs); std::string cache_image(Main *bmain, Scene *scene, Image *image, diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index f3db317a9a8b..6fa3c782ec32 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -11,14 +11,16 @@ #include "BKE_camera.h" +#include "BLI_timecode.h" #include "BLI_math_matrix.h" #include "DEG_depsgraph_query.h" #include "GPU_matrix.h" +#include "PIL_time.h" + #include "camera.h" -#include "utils.h" #include "viewport_engine.h" namespace blender::render::hydra { @@ -259,10 +261,6 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color); } - if (renderer_percent_done() == 0.0f) { - time_begin_ = std::chrono::steady_clock::now(); - } - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE); GPU_shader_bind(shader); @@ -285,21 +283,23 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) GPU_shader_unbind(); - std::chrono::time_point time_current = - std::chrono::steady_clock::now(); - std::chrono::milliseconds elapsed_time = std::chrono::duration_cast( - time_current - time_begin_); + if (renderer_percent_done() == 0.0f) { + time_begin_ = PIL_check_seconds_timer(); + } - std::string formatted_time = format_duration(elapsed_time); + char elapsed_time[32]; + + BLI_timecode_string_from_time_simple( + elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); if (!render_task_delegate_->is_converged()) { - notify_status("Time: " + formatted_time + - " | Done: " + std::to_string(int(renderer_percent_done())) + "%", + notify_status(std::string("Time: ") + elapsed_time + + " | Done: " + std::to_string(int(renderer_percent_done())) + "%", "Render"); bl_engine_->flag |= RE_ENGINE_DO_DRAW; } else { - notify_status(("Time: " + formatted_time).c_str(), "Rendering Done"); + notify_status((std::string("Time: ") + elapsed_time).c_str(), "Rendering Done"); } } diff --git a/source/blender/render/hydra/viewport_engine.h b/source/blender/render/hydra/viewport_engine.h index a362cf21bfba..2f893d71a9d1 100644 --- a/source/blender/render/hydra/viewport_engine.h +++ b/source/blender/render/hydra/viewport_engine.h @@ -3,8 +3,6 @@ #pragma once -#include - #include #include "GPU_batch.h" @@ -46,7 +44,7 @@ class ViewportEngine : public Engine { void notify_status(const std::string &title, const std::string &info); private: - std::chrono::time_point time_begin_; + double time_begin_; DrawTexture draw_texture_; }; -- 2.30.2 From 0a3ed69a0fb3199d04140d7873bcf2d01385aa47 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 14:57:31 +0300 Subject: [PATCH 03/12] made name for MatX file unique --- scripts/modules/bpy_hydra.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/modules/bpy_hydra.py b/scripts/modules/bpy_hydra.py index 07eaa455912e..ccb5e8c5aeaf 100644 --- a/scripts/modules/bpy_hydra.py +++ b/scripts/modules/bpy_hydra.py @@ -109,7 +109,7 @@ def export_mtlx(material): if not doc: return "" - mtlx_file = mx_utils.get_temp_file(".mtlx", material.name) + mtlx_file = mx_utils.get_temp_file(".mtlx", str(material.as_pointer())) mx_utils.export_to_file(doc, mtlx_file, export_deps=True, copy_deps=False) return str(mtlx_file) -- 2.30.2 From 9168971d62dc7168c9c42a47dabe914af3b0921d Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 15:43:35 +0300 Subject: [PATCH 04/12] changed cached image name and folder for it --- source/blender/render/hydra/utils.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/source/blender/render/hydra/utils.cc b/source/blender/render/hydra/utils.cc index 97541c338e0e..51133d1bb629 100644 --- a/source/blender/render/hydra/utils.cc +++ b/source/blender/render/hydra/utils.cc @@ -43,20 +43,11 @@ std::string cache_image(Main *bmain, return ""; } - std::string image_name; - - if (image->source == IMA_SRC_GENERATED) { - image_name = pxr::TfMakeValidIdentifier(image_name.append(image->id.name + 2)); - } - else { - image_name = image->filepath == NULL ? image->filepath : image->id.name + 2; - image_name = std::filesystem::path(image_name).filename().replace_extension().string(); - image_name = pxr::TfMakeValidIdentifier(image_name); - } + std::string image_name(std::to_string((uintptr_t)image)); image_name.append(default_format); - BLI_path_join(tempfile, sizeof(tempfile), BKE_tempdir_session(), image_name.c_str()); + BLI_path_join(tempfile, sizeof(tempfile), BKE_tempdir_session(), "hydra_image_cache", image_name.c_str()); STRNCPY(opts->filepath, tempfile); if (!BKE_image_save(reports, bmain, image, iuser, opts)) { -- 2.30.2 From 28f01bd7f75215e33079a6b78573987691efa807 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 15:47:05 +0300 Subject: [PATCH 05/12] added comment for Vulkan --- source/blender/render/hydra/engine.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/render/hydra/engine.cc b/source/blender/render/hydra/engine.cc index 1aa1bedecfd5..fdcbf0903785 100644 --- a/source/blender/render/hydra/engine.cc +++ b/source/blender/render/hydra/engine.cc @@ -24,6 +24,8 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &delegate_id) : bl_eng pxr::TF_PY_ALLOW_THREADS_IN_SCOPE(); render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(delegate_id)); + /* Current USD (23.02) 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"); } -- 2.30.2 From 1ae87e00615d46ca1636aaac7a76f03bbb0a4cba Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 15:49:06 +0300 Subject: [PATCH 06/12] make format --- source/blender/render/hydra/final_engine.cc | 6 +++--- .../hydra/scene_delegate/blender_scene_delegate.cc | 7 +++++-- .../render/hydra/scene_delegate/instancer.cc | 14 +++++++++++--- .../render/hydra/scene_delegate/material.cc | 6 +++++- source/blender/render/hydra/utils.cc | 3 ++- source/blender/render/hydra/viewport_engine.cc | 6 +++--- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index e37e75a3adb6..768934b9ffca 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -2,11 +2,11 @@ * Copyright 2011-2022 Blender Foundation */ #include "BKE_lib_id.h" +#include "BLI_timecode.h" #include "DEG_depsgraph_query.h" #include "GPU_framebuffer.h" #include "GPU_texture.h" #include "PIL_time.h" -#include "BLI_timecode.h" #include "camera.h" #include "final_engine.h" @@ -83,8 +83,8 @@ void FinalEngine::render(Depsgraph *depsgraph) break; } - percent_done = renderer_percent_done(); - + percent_done = renderer_percent_done(); + BLI_timecode_string_from_time_simple( elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin); diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 5253f32842e9..c3c41d19ec91 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -73,8 +73,11 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont) ITER_BEGIN ( DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) { - CLOG_INFO( - LOG_RENDER_HYDRA_SCENE, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + 2, + "Update: %s [%s]", + id->name, + std::bitset<32>(id->recalc).to_string().c_str()); switch (GS(id->name)) { case ID_OB: { diff --git a/source/blender/render/hydra/scene_delegate/instancer.cc b/source/blender/render/hydra/scene_delegate/instancer.cc index 40486362f63e..80b4cb6698a1 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.cc +++ b/source/blender/render/hydra/scene_delegate/instancer.cc @@ -15,7 +15,11 @@ InstancerData::InstancerData(BlenderSceneDelegate *scene_delegate, Object *objec id_ = nullptr; p_id_ = prim_id(scene_delegate, object); instancer_id = p_id_.AppendElementString("Instancer"); - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s, instancer_id=%s", ((ID *)parent_obj_)->name, instancer_id.GetText()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + 2, + "%s, instancer_id=%s", + ((ID *)parent_obj_)->name, + instancer_id.GetText()); } bool InstancerData::is_supported(Object *object) @@ -184,8 +188,12 @@ bool InstancerData::set_instances() continue; } transforms_.push_back(gf_matrix_from_transform(dupli->mat)); - CLOG_INFO( - LOG_RENDER_HYDRA_SCENE, 2, "Instance %s (%s) %d", id_->name, ((ID *)dupli->ob)->name, dupli->random_id); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + 2, + "Instance %s (%s) %d", + id_->name, + ((ID *)dupli->ob)->name, + dupli->random_id); } free_object_duplilist(lb); diff --git a/source/blender/render/hydra/scene_delegate/material.cc b/source/blender/render/hydra/scene_delegate/material.cc index 88a179b39817..4455ee445ec0 100644 --- a/source/blender/render/hydra/scene_delegate/material.cc +++ b/source/blender/render/hydra/scene_delegate/material.cc @@ -84,7 +84,11 @@ void MaterialData::init() PyGILState_Release(gstate); mtlx_path_ = pxr::SdfAssetPath(path, path); - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "Export: %s, mtlx=%s", id_->name, mtlx_path_.GetResolvedPath().c_str()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + 2, + "Export: %s, mtlx=%s", + id_->name, + mtlx_path_.GetResolvedPath().c_str()); } void MaterialData::insert() diff --git a/source/blender/render/hydra/utils.cc b/source/blender/render/hydra/utils.cc index 51133d1bb629..744e32b1aaa0 100644 --- a/source/blender/render/hydra/utils.cc +++ b/source/blender/render/hydra/utils.cc @@ -47,7 +47,8 @@ std::string cache_image(Main *bmain, image_name.append(default_format); - BLI_path_join(tempfile, sizeof(tempfile), BKE_tempdir_session(), "hydra_image_cache", image_name.c_str()); + BLI_path_join( + tempfile, sizeof(tempfile), BKE_tempdir_session(), "hydra_image_cache", image_name.c_str()); STRNCPY(opts->filepath, tempfile); if (!BKE_image_save(reports, bmain, image, iuser, opts)) { diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 6fa3c782ec32..802f2d9f3c1a 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -11,8 +11,8 @@ #include "BKE_camera.h" -#include "BLI_timecode.h" #include "BLI_math_matrix.h" +#include "BLI_timecode.h" #include "DEG_depsgraph_query.h" @@ -290,11 +290,11 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context) char elapsed_time[32]; BLI_timecode_string_from_time_simple( - elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); + elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_); if (!render_task_delegate_->is_converged()) { notify_status(std::string("Time: ") + elapsed_time + - " | Done: " + std::to_string(int(renderer_percent_done())) + "%", + " | Done: " + std::to_string(int(renderer_percent_done())) + "%", "Render"); bl_engine_->flag |= RE_ENGINE_DO_DRAW; } -- 2.30.2 From 15efdf229c2822e973215dbaa93c3c4193a0c8bc Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 19 Apr 2023 16:17:15 +0300 Subject: [PATCH 07/12] make format --- .../hydra/scene_delegate/blender_scene_delegate.cc | 2 +- source/blender/render/hydra/scene_delegate/id.h | 3 ++- .../blender/render/hydra/scene_delegate/instancer.cc | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 867693d74ed2..618a79f546f9 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -150,7 +150,7 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const & return i_data->transform(); } -void BlenderSceneDelegate::populate(Depsgraph * deps, bContext * cont) +void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont) { bool is_populated = depsgraph_ != nullptr; diff --git a/source/blender/render/hydra/scene_delegate/id.h b/source/blender/render/hydra/scene_delegate/id.h index b29efbd606bd..db5a599aeda0 100644 --- a/source/blender/render/hydra/scene_delegate/id.h +++ b/source/blender/render/hydra/scene_delegate/id.h @@ -41,6 +41,7 @@ template const T IdData::get_data(pxr::TfToken const &key) const } #define ID_LOG(level, msg, ...) \ - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, level, "%s (%s): " msg, p_id_.GetText(), id_->name, __VA_ARGS__); + CLOG_INFO( \ + LOG_RENDER_HYDRA_SCENE, level, "%s (%s): " msg, p_id_.GetText(), id_->name, __VA_ARGS__); } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/scene_delegate/instancer.cc b/source/blender/render/hydra/scene_delegate/instancer.cc index 9e25b044d276..011261b6d37a 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.cc +++ b/source/blender/render/hydra/scene_delegate/instancer.cc @@ -128,7 +128,8 @@ bool InstancerData::update_visibility(View3D *view3d) return ret; } -pxr::HdPrimvarDescriptorVector InstancerData::primvar_descriptors(pxr::HdInterpolation interpolation) +pxr::HdPrimvarDescriptorVector InstancerData::primvar_descriptors( + pxr::HdInterpolation interpolation) { pxr::HdPrimvarDescriptorVector primvars; if (interpolation == pxr::HdInterpolationInstance) { @@ -192,8 +193,8 @@ void InstancerData::check_remove(std::set &available_objects) } if (ret) { set_instances(); - scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(p_id_, - pxr::HdChangeTracker::AllDirty); + scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty( + p_id_, pxr::HdChangeTracker::AllDirty); } } @@ -217,7 +218,8 @@ void InstancerData::set_instances() Instance *inst; pxr::SdfPath path; - ListBase *lb = object_duplilist(scene_delegate_->depsgraph_, scene_delegate_->scene_, (Object *)id_); + ListBase *lb = object_duplilist( + scene_delegate_->depsgraph_, scene_delegate_->scene_, (Object *)id_); LISTBASE_FOREACH (DupliObject *, dupli, lb) { path = ObjectData::prim_id(scene_delegate_, dupli->ob); path = p_id_.AppendElementString(path.GetName()); -- 2.30.2 From 51473dd21b1a0788f820c70c38cc13d71362f434 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Thu, 20 Apr 2023 13:37:56 +0300 Subject: [PATCH 08/12] fix review comments --- scripts/modules/bpy_hydra.py | 2 +- source/blender/render/hydra/utils.cc | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/modules/bpy_hydra.py b/scripts/modules/bpy_hydra.py index ccb5e8c5aeaf..3923a78d6bcc 100644 --- a/scripts/modules/bpy_hydra.py +++ b/scripts/modules/bpy_hydra.py @@ -109,7 +109,7 @@ def export_mtlx(material): if not doc: return "" - mtlx_file = mx_utils.get_temp_file(".mtlx", str(material.as_pointer())) + mtlx_file = mx_utils.get_temp_file(".mtlx", f"mat_{material.as_pointer():016x}") mx_utils.export_to_file(doc, mtlx_file, export_deps=True, copy_deps=False) return str(mtlx_file) diff --git a/source/blender/render/hydra/utils.cc b/source/blender/render/hydra/utils.cc index 744e32b1aaa0..9a0462fc4ae3 100644 --- a/source/blender/render/hydra/utils.cc +++ b/source/blender/render/hydra/utils.cc @@ -34,8 +34,7 @@ std::string cache_image(Main *bmain, ImageSaveOptions *opts, ReportList *reports) { - const std::string default_format = ".png"; - + const char *default_format = ".png"; char tempfile[FILE_MAX]; if (!BKE_image_save_options_init(opts, bmain, scene, image, iuser, true, false)) { @@ -43,12 +42,13 @@ std::string cache_image(Main *bmain, return ""; } - std::string image_name(std::to_string((uintptr_t)image)); + char image_name[32]; + snprintf(image_name, 32, "img_%016llx", (uint64_t)image); - image_name.append(default_format); + strcat(image_name, default_format); BLI_path_join( - tempfile, sizeof(tempfile), BKE_tempdir_session(), "hydra_image_cache", image_name.c_str()); + tempfile, sizeof(tempfile), BKE_tempdir_session(), "hydra_image_cache", image_name); STRNCPY(opts->filepath, tempfile); if (!BKE_image_save(reports, bmain, image, iuser, opts)) { -- 2.30.2 From 49916ba396074c3b9711cb3dbe31666a3339258f Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 21 Apr 2023 11:43:21 +0300 Subject: [PATCH 09/12] set_transform_to_object -> write_transform set_transform -> write_transform --- source/blender/render/hydra/scene_delegate/light.cc | 4 ++-- source/blender/render/hydra/scene_delegate/mesh.cc | 4 ++-- source/blender/render/hydra/scene_delegate/object.cc | 2 +- source/blender/render/hydra/scene_delegate/object.h | 2 +- source/blender/render/hydra/scene_delegate/world.cc | 4 ++-- source/blender/render/hydra/scene_delegate/world.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/light.cc b/source/blender/render/hydra/scene_delegate/light.cc index 6b2e5bf0a14b..ab4642f86389 100644 --- a/source/blender/render/hydra/scene_delegate/light.cc +++ b/source/blender/render/hydra/scene_delegate/light.cc @@ -85,7 +85,7 @@ void LightData::init() /* TODO: temporary value, it should be delivered through Python UI */ data_[pxr::HdLightTokens->exposure] = 1.0f; - set_transform_to_object(); + write_transform(); } void LightData::insert() @@ -118,7 +118,7 @@ void LightData::update() bits = pxr::HdLight::AllDirty; } else if (id->recalc & ID_RECALC_TRANSFORM) { - set_transform_to_object(); + write_transform(); bits = pxr::HdLight::DirtyTransform; } scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(prim_id, bits); diff --git a/source/blender/render/hydra/scene_delegate/mesh.cc b/source/blender/render/hydra/scene_delegate/mesh.cc index 35107bc90910..50f65f26a269 100644 --- a/source/blender/render/hydra/scene_delegate/mesh.cc +++ b/source/blender/render/hydra/scene_delegate/mesh.cc @@ -40,7 +40,7 @@ void MeshData::init() } write_material(); - set_transform_to_object(); + write_transform(); } void MeshData::insert() @@ -78,7 +78,7 @@ void MeshData::update() bits |= pxr::HdChangeTracker::DirtyMaterialId; } if (id->recalc & ID_RECALC_TRANSFORM) { - set_transform_to_object(); + write_transform(); bits |= pxr::HdChangeTracker::DirtyTransform; } } diff --git a/source/blender/render/hydra/scene_delegate/object.cc b/source/blender/render/hydra/scene_delegate/object.cc index 7e5396cf8d8c..ea7de70e4b91 100644 --- a/source/blender/render/hydra/scene_delegate/object.cc +++ b/source/blender/render/hydra/scene_delegate/object.cc @@ -79,7 +79,7 @@ bool ObjectData::update_visibility() return ret; } -void ObjectData::set_transform_to_object() +void ObjectData::write_transform() { transform = gf_matrix_from_transform(((Object *)id)->object_to_world); } diff --git a/source/blender/render/hydra/scene_delegate/object.h b/source/blender/render/hydra/scene_delegate/object.h index 5297c576e28b..f7fd44c76168 100644 --- a/source/blender/render/hydra/scene_delegate/object.h +++ b/source/blender/render/hydra/scene_delegate/object.h @@ -29,7 +29,7 @@ class ObjectData : public IdData { bool visible; protected: - void set_transform_to_object(); + void write_transform(); }; using ObjectDataMap = diff --git a/source/blender/render/hydra/scene_delegate/world.cc b/source/blender/render/hydra/scene_delegate/world.cc index e586df5a4e9b..08f7a326db10 100644 --- a/source/blender/render/hydra/scene_delegate/world.cc +++ b/source/blender/render/hydra/scene_delegate/world.cc @@ -49,7 +49,7 @@ void WorldData::init() { ID_LOG(2, ""); - set_transform(); + write_transform(); World *world = (World *)id; data_.clear(); @@ -157,7 +157,7 @@ pxr::VtValue WorldData::get_data(pxr::TfToken const &key) const return ret; } -void WorldData::set_transform() +void WorldData::write_transform() { transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d()); diff --git a/source/blender/render/hydra/scene_delegate/world.h b/source/blender/render/hydra/scene_delegate/world.h index d29806ec1298..083e0daff78a 100644 --- a/source/blender/render/hydra/scene_delegate/world.h +++ b/source/blender/render/hydra/scene_delegate/world.h @@ -37,7 +37,7 @@ class WorldData : public IdData { pxr::GfMatrix4d transform; private: - void set_transform(); + void write_transform(); std::map data_; }; -- 2.30.2 From 9bb7062c4dc4c81fab738722c3fa1f0887f3c42f Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 21 Apr 2023 13:51:53 +0300 Subject: [PATCH 10/12] fix after merge --- .../scene_delegate/blender_scene_delegate.cc | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index f65a37082620..90f0091ee558 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -330,28 +330,6 @@ void BlenderSceneDelegate::check_updates() bool do_update_visibility = false; bool do_update_world = false; - unsigned int scene_recalc = scene->id.recalc; - if (scene_recalc) { - /* Checking scene updates */ - CLOG_INFO(LOG_RENDER_HYDRA_SCENE, - 2, - "Update: %s [%s]", - ((ID *)scene)->name, - std::bitset<32>(scene_recalc).to_string().c_str()); - - if (scene_recalc & ID_RECALC_BASE_FLAGS) { - do_update_visibility = true; - } - if (scene_recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) { - do_update_collection = true; - } - if (scene_recalc & ID_RECALC_AUDIO_VOLUME) { - if ((scene->world && !world_data_) || (!scene->world && world_data_)) { - do_update_world = true; - } - } - } - /* Checking other objects updates */ DEGIDIterData data = {0}; data.graph = depsgraph; -- 2.30.2 From b8876bebe73832263aa81e02bdfad677089388ab Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 21 Apr 2023 13:53:05 +0300 Subject: [PATCH 11/12] make format --- .../render/hydra/scene_delegate/blender_scene_delegate.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 90f0091ee558..3fe36674b574 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -337,8 +337,11 @@ void BlenderSceneDelegate::check_updates() ITER_BEGIN ( DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) { - CLOG_INFO( - LOG_RENDER_HYDRA_SCENE, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str()); + CLOG_INFO(LOG_RENDER_HYDRA_SCENE, + 2, + "Update: %s [%s]", + id->name, + std::bitset<32>(id->recalc).to_string().c_str()); switch (GS(id->name)) { case ID_OB: { -- 2.30.2 From 0de9823f1677579b2cc2c230df22635dda9ac0c3 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Fri, 21 Apr 2023 14:36:45 +0300 Subject: [PATCH 12/12] Removed comment --- .../render/hydra/scene_delegate/blender_scene_delegate.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 3fe36674b574..bb6614f2be8a 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -330,7 +330,6 @@ void BlenderSceneDelegate::check_updates() bool do_update_visibility = false; bool do_update_world = false; - /* Checking other objects updates */ DEGIDIterData data = {0}; data.graph = depsgraph; data.only_updated = true; -- 2.30.2