forked from blender/blender
Fixed rendering for MacOS #82
@ -133,4 +133,22 @@ float Engine::renderer_percent_done()
|
||||
return (float)it->second.UncheckedGet<double>();
|
||||
}
|
||||
|
||||
pxr::HdTaskSharedPtrVector Engine::tasks()
|
||||
{
|
||||
pxr::HdTaskSharedPtrVector res;
|
||||
if (light_tasks_delegate_) {
|
||||
if (scene_->r.alphamode != R_ALPHAPREMUL) {
|
||||
#ifndef __APPLE__
|
||||
/* TODO: Temporary disable skydome task for MacOS due to crash with error:
|
||||
Failed to created pipeline state, error depthAttachmentPixelFormat is not valid
|
||||
and shader writes to depth */
|
||||
res.push_back(light_tasks_delegate_->skydome_task());
|
||||
#endif
|
||||
}
|
||||
res.push_back(light_tasks_delegate_->simple_task());
|
||||
}
|
||||
res.push_back(render_task_delegate_->task());
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -64,7 +64,10 @@ class Engine {
|
||||
|
||||
protected:
|
||||
float renderer_percent_done();
|
||||
virtual void notify_status(float progress, const std::string &title, const std::string &info) = 0;
|
||||
pxr::HdTaskSharedPtrVector tasks();
|
||||
virtual void notify_status(float progress,
|
||||
const std::string &title,
|
||||
const std::string &info) = 0;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -66,20 +66,10 @@ void FinalEngine::render()
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->depth);
|
||||
}
|
||||
|
||||
pxr::HdTaskSharedPtrVector tasks;
|
||||
if (light_tasks_delegate_) {
|
||||
if (scene_->r.alphamode != R_ALPHAPREMUL) {
|
||||
#ifndef __APPLE__
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
#endif
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
}
|
||||
tasks.push_back(render_task_delegate_->task());
|
||||
|
||||
render_task_delegate_->bind();
|
||||
|
||||
engine_->Execute(render_index_.get(), &tasks);
|
||||
auto t = tasks();
|
||||
engine_->Execute(render_index_.get(), &t);
|
||||
|
||||
char elapsed_time[32];
|
||||
double time_begin = PIL_check_seconds_timer();
|
||||
|
@ -37,7 +37,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
||||
|
||||
RenderEngine *bl_engine = pyrna_to_pointer<RenderEngine>(pyengine, &RNA_RenderEngine);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %s", engine_type);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 1, "Engine %s", engine_type);
|
||||
Engine *engine = nullptr;
|
||||
try {
|
||||
if (STREQ(engine_type, "VIEWPORT")) {
|
||||
|
@ -108,6 +108,16 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
|
||||
aov_key);
|
||||
|
||||
if (aov_desc.format == pxr::HdFormatInvalid) {
|
||||
CLOG_ERROR(LOG_HYDRA_RENDER, "Invalid AOV: %s", aov_key.GetText());
|
||||
return;
|
||||
}
|
||||
if (!ELEM(
|
||||
pxr::HdGetComponentFormat(aov_desc.format), pxr::HdFormatFloat32, pxr::HdFormatFloat16))
|
||||
{
|
||||
CLOG_WARN(LOG_HYDRA_RENDER,
|
||||
"Unsupported data format %s for AOV %s",
|
||||
pxr::TfEnum::GetName(aov_desc.format).c_str(),
|
||||
aov_key.GetText());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,7 +138,7 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", aov_key.GetText());
|
||||
}
|
||||
|
||||
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
|
||||
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
|
||||
{
|
||||
pxr::HdRenderBuffer *buffer = static_cast<pxr::HdRenderBuffer *>(
|
||||
GetRenderIndex().GetBprim(pxr::HdPrimTypeTokens->renderBuffer, buffer_id(aov_key)));
|
||||
@ -139,17 +149,21 @@ void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
|
||||
pxr::HdFormat format = buffer->GetFormat();
|
||||
size_t len = buffer->GetWidth() * buffer->GetHeight() * pxr::HdGetComponentCount(format);
|
||||
if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat32) {
|
||||
float *buf_data = (float *)buffer->Map();
|
||||
void *buf_data = buffer->Map();
|
||||
memcpy(data, buf_data, len * sizeof(float));
|
||||
buffer->Unmap();
|
||||
}
|
||||
else if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat16) {
|
||||
Eigen::half *buf_data = (Eigen::half *)buffer->Map();
|
||||
float *fdata = (float *)data;
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
data[i] = buf_data[i];
|
||||
fdata[i] = buf_data[i];
|
||||
}
|
||||
buffer->Unmap();
|
||||
}
|
||||
else {
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, GPUTexture *texture)
|
||||
@ -221,6 +235,7 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
|
||||
tex = &tex_depth_;
|
||||
}
|
||||
else {
|
||||
CLOG_ERROR(LOG_HYDRA_RENDER, "Invalid AOV: %s", aov_key.GetText());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -239,7 +254,7 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 1, "%s", aov_key.GetText());
|
||||
}
|
||||
|
||||
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
|
||||
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
|
||||
{
|
||||
GPUTexture *tex = nullptr;
|
||||
int c;
|
||||
|
@ -34,7 +34,7 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate {
|
||||
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, float *data);
|
||||
virtual void read_aov(pxr::TfToken const &aov_key, void *data);
|
||||
virtual void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture);
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
@ -56,7 +56,7 @@ class GPURenderTaskDelegate : public RenderTaskDelegate {
|
||||
|
||||
void set_viewport(pxr::GfVec4d const &viewport) override;
|
||||
void add_aov(pxr::TfToken const &aov_key) override;
|
||||
void read_aov(pxr::TfToken const &aov_key, float *data) override;
|
||||
void read_aov(pxr::TfToken const &aov_key, void *data) override;
|
||||
void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture) override;
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
|
@ -232,21 +232,11 @@ void ViewportEngine::render()
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->color);
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->depth);
|
||||
|
||||
pxr::HdTaskSharedPtrVector tasks;
|
||||
if (light_tasks_delegate_) {
|
||||
if (scene_->r.alphamode != R_ALPHAPREMUL) {
|
||||
#ifndef __APPLE__
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
#endif
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
}
|
||||
tasks.push_back(render_task_delegate_->task());
|
||||
|
||||
GPUFrameBuffer *view_framebuffer = GPU_framebuffer_active_get();
|
||||
render_task_delegate_->bind();
|
||||
|
||||
engine_->Execute(render_index_.get(), &tasks);
|
||||
auto t = tasks();
|
||||
engine_->Execute(render_index_.get(), &t);
|
||||
|
||||
render_task_delegate_->unbind();
|
||||
|
||||
@ -295,7 +285,8 @@ void ViewportEngine::render(bContext *context)
|
||||
render();
|
||||
}
|
||||
|
||||
void ViewportEngine::notify_status(float /*progress*/, const std::string &info,
|
||||
void ViewportEngine::notify_status(float /*progress*/,
|
||||
const std::string &info,
|
||||
const std::string &status)
|
||||
{
|
||||
RE_engine_update_stats(bl_engine_, status.c_str(), info.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user