forked from blender/blender
BLEN-365: Improve creation algorithm of PreviewEngine #21
No reviewers
Labels
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: BogdanNagirniak/blender#21
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "BLEN-365"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose
PreviewEngine
shouldn’t be recreated every time when material is changed.Technical steps
Python:
def update
C++:
PreviewEngine
(60 sec for now). Timer is refreshed with every change;BlenderSceneDelegate
from everyEngine
's inheritor toEngine::Engine
;PreviewEngine::sync
clearsrender_index
andscene_delegate
's data;@ -45,0 +46,4 @@
scene_delegate = std::make_unique<BlenderSceneDelegate>(
render_index.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("scene"),
BlenderSceneDelegate::EngineType::PREVIEW);
There could be other types of engines
@ -18,1 +15,3 @@
BlenderSceneDelegate::EngineType::PREVIEW);
scene_delegate->clear_data();
for (auto &prim : render_index->GetRprimIds()) {
Move this to clear()
@ -19,2 +21,4 @@
namespace blender::render::hydra {
static double preview_engine_lifetime = 60.0;
static PreviewEngine *preview_engine;
Use unique_ptr
@ -21,0 +26,4 @@
double delete_preview_engine(uintptr_t uuid, void *user_data)
{
if (preview_engine) {
preview_engine->stop_renderer();
add logging
@ -21,0 +33,4 @@
}
return preview_engine_lifetime;
}
Move this function to preview_engein.cc
Probably it can be static function of PreviewEngine class
@ -117,0 +135,4 @@
if (BLI_timer_is_registered(1)) {
BLI_timer_unregister(1);
}
preview_engine->bl_engine = bl_engine;
Add PreviewEngine::update_engine() instead public usage of bl_engine
@ -477,4 +477,10 @@ pxr::VtValue BlenderSceneDelegate::GetLightParamValue(pxr::SdfPath const &id,
return pxr::VtValue();
}
void BlenderSceneDelegate::clear_data()
Rename to just "clear"
@ -21,0 +26,4 @@
double delete_preview_engine(uintptr_t uuid, void *user_data)
{
if (preview_engine) {
preview_engine->stop_renderer();
Do not stop render, check if it is in render process, then return preview_engine_lifetime.
@ -54,6 +54,12 @@ Engine::~Engine()
render_delegate = nullptr;
engine = nullptr;
hgi = nullptr;
bl_engine = nullptr;
no need
@ -57,0 +57,4 @@
bl_engine = nullptr;
}
bool Engine::is_converged()
This function is not needed
@ -19,2 +20,4 @@
namespace blender::render::hydra {
static std::unique_ptr<PreviewEngine> preview_engine;
move to PreviewEngine class as static
@ -116,0 +124,4 @@
}
preview_engine->update_bl_engine(bl_engine);
CLOG_INFO(LOG_EN, 2, "Engine %016llx %s", engine, engine_type);
This block should be like:
engine = PreviewEngine::get(bl_engine, render_delegate_id);
@ -436,1 +436,4 @@
void BlenderSceneDelegate::clear()
{
for (auto it = materials.begin(); it != materials.end(); ++it) {
@ -25,2 +25,4 @@
private:
std::map<pxr::TfToken, pxr::VtValue> data;
short p_type;
short p_shape;
pxr::TfToken p_type;
make prim_type() with
Light *
parameterAdded some code improvements. Tested - works good.