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
8 changed files with 23 additions and 11 deletions
Showing only changes of commit 2e97a39e96 - Show all commits

View File

@ -17,12 +17,13 @@ namespace blender::render::hydra {
CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA, "render.hydra");
Engine::Engine(RenderEngine *bl_engine, const std::string &delegate_id) : bl_engine_(bl_engine)
Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
: bl_engine_(bl_engine), render_delegate_name(render_delegate_name)
{
pxr::HdRendererPluginRegistry &registry = pxr::HdRendererPluginRegistry::GetInstance();
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(delegate_id));
render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(render_delegate_name));
/* 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 */
@ -44,7 +45,7 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &delegate_id) : bl_eng
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("freeCamera"));
render_task_delegate_ = std::make_unique<RenderTaskDelegate>(
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
if (render_delegate_->GetRendererDisplayName() == "GL") {
if (render_delegate_name == "HdStormRendererPlugin") {
simple_light_task_delegate_ = std::make_unique<SimpleLightTaskDelegate>(
render_index_.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("simpleLightTask"));

View File

@ -25,7 +25,7 @@ extern struct CLG_LogRef *LOG_RENDER_HYDRA; /* EN - Engine */
class Engine {
public:
Engine(RenderEngine *bl_engine, const std::string &render_delegate_id);
Engine(RenderEngine *bl_engine, const std::string &render_delegate_name);
virtual ~Engine() = default;
virtual void sync(Depsgraph *depsgraph,
@ -33,6 +33,8 @@ class Engine {
pxr::HdRenderSettingsMap &render_settings) = 0;
virtual void render(Depsgraph *depsgraph) = 0;
std::string render_delegate_name;
protected:
float renderer_percent_done();

View File

@ -20,7 +20,8 @@ void FinalEngine::sync(Depsgraph *depsgraph,
scene_delegate_ = std::make_unique<BlenderSceneDelegate>(
render_index_.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("scene"),
BlenderSceneDelegate::EngineType::FINAL);
BlenderSceneDelegate::EngineType::FINAL,
render_delegate_name);
scene_delegate_->populate(depsgraph, context);
for (auto const &setting : render_settings) {

View File

@ -44,7 +44,8 @@ void PreviewEngine::sync(Depsgraph *depsgraph,
scene_delegate_ = std::make_unique<BlenderSceneDelegate>(
render_index_.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("scene"),
BlenderSceneDelegate::EngineType::PREVIEW);
BlenderSceneDelegate::EngineType::PREVIEW,
render_delegate_name);
}
scene_delegate_->clear();
scene_delegate_->populate(depsgraph, context);

View File

@ -15,8 +15,11 @@ CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA_SCENE, "render.hydra.scene");
BlenderSceneDelegate::BlenderSceneDelegate(pxr::HdRenderIndex *parent_index,
pxr::SdfPath const &delegate_id,
BlenderSceneDelegate::EngineType engine_type)
: HdSceneDelegate(parent_index, delegate_id), engine_type(engine_type)
BlenderSceneDelegate::EngineType engine_type,
std::string render_delegate_name)
: HdSceneDelegate(parent_index, delegate_id),
engine_type(engine_type),
render_delegate_name(render_delegate_name)
{
}

View File

@ -28,7 +28,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
BlenderSceneDelegate(pxr::HdRenderIndex *parent_index,
pxr::SdfPath const &delegate_id,
BlenderSceneDelegate::EngineType engine_type);
BlenderSceneDelegate::EngineType engine_type,
std::string render_delegate_name);
~BlenderSceneDelegate() override = default;
/* Delegate methods */
@ -56,6 +57,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
View3D *view3d = nullptr;
Scene *scene = nullptr;
std::string render_delegate_name;
private:
pxr::SdfPath prim_id(ID *id, const char *prefix) const;
pxr::SdfPath object_prim_id(Object *object) const;

View File

@ -162,7 +162,7 @@ void WorldData::write_transform()
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
/* TODO : do this check via RenderSettings*/
if (scene_delegate_->GetRenderIndex().GetRenderDelegate()->GetRendererDisplayName() == "RPR") {
if (scene_delegate_->render_delegate_name == "HdRprPlugin") {
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),

View File

@ -225,7 +225,8 @@ void ViewportEngine::sync(Depsgraph *depsgraph,
scene_delegate_ = std::make_unique<BlenderSceneDelegate>(
render_index_.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("scene"),
BlenderSceneDelegate::EngineType::VIEWPORT);
BlenderSceneDelegate::EngineType::VIEWPORT,
render_delegate_name);
}
scene_delegate_->populate(depsgraph, context);