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,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) 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); render_delegate_->SetRenderSetting(pxr::TfToken(key), val);
}
} }
float Engine::renderer_percent_done() float Engine::renderer_percent_done()

View File

@ -29,10 +29,6 @@ namespace blender::render::hydra {
extern struct CLG_LogRef *LOG_HYDRA_RENDER; extern struct CLG_LogRef *LOG_HYDRA_RENDER;
struct RenderDelegateSettings {
Map<std::string, pxr::TfToken> aovs;
};
class Engine { class Engine {
protected: protected:
std::string render_delegate_name_; 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::HydraSceneDelegate> hydra_scene_delegate_;
std::unique_ptr<io::hydra::USDSceneDelegate> usd_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<RenderTaskDelegate> render_task_delegate_;
std::unique_ptr<pxr::HdxFreeCameraSceneDelegate> free_camera_delegate_; std::unique_ptr<pxr::HdxFreeCameraSceneDelegate> free_camera_delegate_;
std::unique_ptr<LightTasksDelegate> light_tasks_delegate_; std::unique_ptr<LightTasksDelegate> light_tasks_delegate_;
@ -65,7 +60,7 @@ class Engine {
virtual void render() = 0; virtual void render() = 0;
void set_sync_setting(const std::string &key, const pxr::VtValue &val); 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: protected:
float renderer_percent_done(); float renderer_percent_done();

View File

@ -55,13 +55,15 @@ void FinalEngine::render()
render_task_delegate_->add_aov(pxr::HdAovTokens->depth); render_task_delegate_->add_aov(pxr::HdAovTokens->depth);
} }
RenderResult *result = RE_engine_get_result(bl_engine_); RenderResult *rr = RE_engine_get_result(bl_engine_);
RenderLayer *layer = (RenderLayer *)result->layers.first; RenderLayer *rlayer = (RenderLayer *)rr->layers.first;
for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) { LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) {
pxr::TfToken *aov_token = render_delegate_settings_.aovs.lookup_ptr(pass->name); pxr::TfToken *aov_token = aov_tokens_.lookup_ptr(rpass->name);
if (aov_token) { if (!aov_token) {
render_task_delegate_->add_aov(*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; pxr::HdTaskSharedPtrVector tasks;
@ -105,6 +107,16 @@ void FinalEngine::render()
render_task_delegate_->unbind(); 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) void FinalEngine::notify_status(float progress, const std::string &title, const std::string &info)
{ {
RE_engine_update_progress(bl_engine_, progress); 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) { if (rlayer) {
LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) { 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) { if (aov_token) {
render_task_delegate_->read_aov(*aov_token, rpass->ibuf->float_buffer.data); render_task_delegate_->read_aov(*aov_token, rpass->ibuf->float_buffer.data);
} }

View File

@ -8,10 +8,14 @@
namespace blender::render::hydra { namespace blender::render::hydra {
class FinalEngine : public Engine { class FinalEngine : public Engine {
private:
Map<std::string, pxr::TfToken> aov_tokens_;
public: public:
using Engine::Engine; using Engine::Engine;
void render() override; void render() override;
void set_render_setting(const std::string &key, const pxr::VtValue &val) override;
protected: protected:
void notify_status(float progress, const std::string &title, const std::string &info) override; 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(); pxr::HdTaskSharedPtr task();
void set_camera(pxr::SdfPath const &camera_id); 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 set_viewport(pxr::GfVec4d const &viewport);
virtual void add_aov(pxr::TfToken const &aov_key); virtual void add_aov(pxr::TfToken const &aov_key);
virtual void read_aov(pxr::TfToken const &aov_key, void *data); virtual void read_aov(pxr::TfToken const &aov_key, void *data);