Hydra code cleanup #81

Merged
Bogdan Nagirniak merged 7 commits from hydra-code-cleanup into hydra-render 2023-08-01 21:35:28 +02:00
5 changed files with 26 additions and 21 deletions
Showing only changes of commit 4f0a20760d - Show all commits

View File

@ -120,14 +120,8 @@ void Engine::set_sync_setting(const std::string &key, const pxr::VtValue &val)
void Engine::set_render_setting(const std::string &key, const pxr::VtValue &val)
{
if (STRPREFIX(key.c_str(), "aovToken:")) {
render_delegate_settings_.aovs.add_new(key.substr(key.find(":") + 1),
pxr::TfToken(val.UncheckedGet<std::string>()));
}
else {
render_delegate_->SetRenderSetting(pxr::TfToken(key), val);
}
}
float Engine::renderer_percent_done()
{

View File

@ -29,10 +29,6 @@ namespace blender::render::hydra {
extern struct CLG_LogRef *LOG_HYDRA_RENDER;
struct RenderDelegateSettings {
Map<std::string, pxr::TfToken> aovs;
};
class Engine {
protected:
std::string render_delegate_name_;
@ -51,7 +47,6 @@ class Engine {
std::unique_ptr<io::hydra::HydraSceneDelegate> hydra_scene_delegate_;
std::unique_ptr<io::hydra::USDSceneDelegate> usd_scene_delegate_;
RenderDelegateSettings render_delegate_settings_;
std::unique_ptr<RenderTaskDelegate> render_task_delegate_;
std::unique_ptr<pxr::HdxFreeCameraSceneDelegate> free_camera_delegate_;
std::unique_ptr<LightTasksDelegate> 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();

View File

@ -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<std::string>()));
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);
}

View File

@ -8,10 +8,14 @@
namespace blender::render::hydra {
class FinalEngine : public Engine {
private:
Map<std::string, pxr::TfToken> 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;

View File

@ -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);