Fix review comments 2 #31

Merged
Bogdan Nagirniak merged 8 commits from BLEN-397 into hydra-render 2023-04-27 09:05:38 +02:00
2 changed files with 10 additions and 31 deletions
Showing only changes of commit 6b25f1ea48 - Show all commits

View File

@ -57,33 +57,12 @@ void PreviewEngine::sync(Depsgraph *depsgraph,
void PreviewEngine::render(Depsgraph *depsgraph)
{
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
std::string layer_name = view_layer->name;
pxr::GfVec2i res(scene->r.xsch, scene->r.ysch);
pxr::GfCamera camera =
CameraData(scene->camera, res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(pxr::GfVec4f(0, 0, 1, 1));
free_camera_delegate_->SetCamera(camera);
render_task_delegate_->set_camera_and_viewport(free_camera_delegate_->GetCameraId(),
pxr::GfVec4d(0, 0, res[0], res[1]));
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color);
pxr::HdTaskSharedPtrVector tasks;
if (simple_light_task_delegate_) {
tasks.push_back(simple_light_task_delegate_->get_task());
}
tasks.push_back(render_task_delegate_->get_task());
std::vector<float> pixels = std::vector<float>(res[0] * res[1] *
4); /* 4 - number of channels. */
prepare_for_render(depsgraph);
{
/* Release the GIL before calling into hydra, in case any hydra plugins call into python. */
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
engine_->Execute(render_index_.get(), &tasks);
engine_->Execute(render_index_.get(), &tasks_);
}
while (true) {
@ -94,13 +73,13 @@ void PreviewEngine::render(Depsgraph *depsgraph)
if (render_task_delegate_->is_converged()) {
break;
}
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels.data());
update_render_result(layer_name, res[0], res[1], pixels);
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_->data());
update_render_result(layer_name_, resolution_[0], resolution_[1], pixels_);
}
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels.data());
update_render_result(layer_name, res[0], res[1], pixels);
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_->data());
update_render_result(layer_name_, resolution_[0], resolution_[1], pixels_);
}
double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
@ -124,14 +103,14 @@ void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_de
void PreviewEngine::update_render_result(const std::string &layer_name,
int width,
int height,
std::vector<float> &pixels)
std::vector<float> *pixels)
{
RenderResult *result = RE_engine_begin_result(
bl_engine_, 0, 0, width, height, layer_name.c_str(), nullptr);
RenderLayer *layer = (RenderLayer *)result->layers.first;
RenderPass *pass = (RenderPass *)layer->passes.first;
memcpy(pass->rect, pixels.data(), sizeof(float) * pass->rectx * pass->recty * pass->channels);
memcpy(pass->rect, pixels->data(), sizeof(float) * pass->rectx * pass->recty * pass->channels);
RE_engine_end_result(bl_engine_, result, false, false, false);
}

View File

@ -29,7 +29,7 @@ class PreviewEngine : public FinalEngine {
void update_render_result(const std::string &layer_name,
int width,
int height,
std::vector<float> &pixels);
std::vector<float> *pixels);
};
} // namespace blender::render::hydra