forked from blender/blender
Rename some functions #25
@ -26,7 +26,7 @@ class FinalEngine : public Engine {
|
|||||||
int height);
|
int height);
|
||||||
void notify_status(float progress, const std::string &title, const std::string &info);
|
void notify_status(float progress, const std::string &title, const std::string &info);
|
||||||
|
|
||||||
pxr::HdRenderSettingsMap render_settings;
|
pxr::HdRenderSettingsMap render_settings_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FinalEngineGL : public FinalEngine {
|
class FinalEngineGL : public FinalEngine {
|
||||||
|
@ -13,19 +13,6 @@ const double LIFETIME = 180.0;
|
|||||||
|
|
||||||
std::unique_ptr<PreviewEngine> PreviewEngine::instance_;
|
std::unique_ptr<PreviewEngine> PreviewEngine::instance_;
|
||||||
|
|
||||||
void PreviewEngine::schedule_free()
|
|
||||||
{
|
|
||||||
instance_->render_delegate_->Stop();
|
|
||||||
|
|
||||||
/* Register timer for schedule free PreviewEngine instance */
|
|
||||||
BLI_timer_register((uintptr_t)instance_.get(),
|
|
||||||
free_instance,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
LIFETIME,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewEngine *PreviewEngine::get_instance(RenderEngine *bl_engine, const std::string &render_delegate_id)
|
PreviewEngine *PreviewEngine::get_instance(RenderEngine *bl_engine, const std::string &render_delegate_id)
|
||||||
{
|
{
|
||||||
if (!instance_) {
|
if (!instance_) {
|
||||||
@ -40,16 +27,12 @@ PreviewEngine *PreviewEngine::get_instance(RenderEngine *bl_engine, const std::s
|
|||||||
return instance_.get();
|
return instance_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
|
void PreviewEngine::schedule_free()
|
||||||
{
|
{
|
||||||
if (!instance_->render_task_delegate_->is_converged()) {
|
instance_->render_delegate_->Stop();
|
||||||
/* Restart timer if render isn't completed */
|
|
||||||
return LIFETIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLOG_INFO(LOG_EN, 2, "");
|
/* Register timer for schedule free PreviewEngine instance */
|
||||||
instance_ = nullptr;
|
BLI_timer_register((uintptr_t)instance_.get(), free_instance, nullptr, nullptr, LIFETIME, true);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewEngine::sync(Depsgraph *depsgraph,
|
void PreviewEngine::sync(Depsgraph *depsgraph,
|
||||||
@ -117,6 +100,19 @@ void PreviewEngine::render(Depsgraph *depsgraph)
|
|||||||
update_render_result(layer_name, res[0], res[1], pixels);
|
update_render_result(layer_name, res[0], res[1], pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
|
||||||
|
{
|
||||||
|
if (!instance_->render_task_delegate_->is_converged()) {
|
||||||
|
/* Restart timer if render isn't completed */
|
||||||
|
return LIFETIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_EN, 2, "");
|
||||||
|
instance_ = nullptr;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_delegate_id)
|
void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_delegate_id)
|
||||||
{
|
{
|
||||||
this->bl_engine_ = bl_engine;
|
this->bl_engine_ = bl_engine;
|
||||||
|
@ -236,8 +236,8 @@ static PyMethodDef methods[] = {
|
|||||||
|
|
||||||
{"engine_create", engine_create_func, METH_VARARGS, ""},
|
{"engine_create", engine_create_func, METH_VARARGS, ""},
|
||||||
{"engine_free", engine_free_func, METH_VARARGS, ""},
|
{"engine_free", engine_free_func, METH_VARARGS, ""},
|
||||||
{"engine_render", engine_render_func, METH_VARARGS, ""},
|
|
||||||
{"engine_sync", engine_sync_func, METH_VARARGS, ""},
|
{"engine_sync", engine_sync_func, METH_VARARGS, ""},
|
||||||
|
{"engine_render", engine_render_func, METH_VARARGS, ""},
|
||||||
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
||||||
|
|
||||||
{NULL, NULL, 0, NULL},
|
{NULL, NULL, 0, NULL},
|
||||||
|
@ -36,32 +36,6 @@ pxr::SdfPath RenderTaskDelegate::get_aov_id(pxr::TfToken const &aov) const
|
|||||||
return GetDelegateID().AppendElementString("aov_" + aov.GetString());
|
return GetDelegateID().AppendElementString("aov_" + aov.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
|
||||||
{
|
|
||||||
if (key == pxr::HdTokens->params) {
|
|
||||||
return pxr::VtValue(task_params_);
|
|
||||||
}
|
|
||||||
if (key == pxr::HdTokens->collection) {
|
|
||||||
pxr::HdRprimCollection rprim_collection(pxr::HdTokens->geometry,
|
|
||||||
pxr::HdReprSelector(pxr::HdReprTokens->smoothHull),
|
|
||||||
false,
|
|
||||||
pxr::TfToken());
|
|
||||||
rprim_collection.SetRootPath(pxr::SdfPath::AbsoluteRootPath());
|
|
||||||
return pxr::VtValue(rprim_collection);
|
|
||||||
}
|
|
||||||
return pxr::VtValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr::SdfPath const &id)
|
|
||||||
{
|
|
||||||
return buffer_descriptors_[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const &task_id)
|
|
||||||
{
|
|
||||||
return {pxr::HdRenderTagTokens->geometry};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderTaskDelegate::is_converged()
|
bool RenderTaskDelegate::is_converged()
|
||||||
{
|
{
|
||||||
pxr::HdTaskSharedPtr renderTask = GetRenderIndex().GetTask(get_task_id());
|
pxr::HdTaskSharedPtr renderTask = GetRenderIndex().GetTask(get_task_id());
|
||||||
@ -132,4 +106,30 @@ void RenderTaskDelegate::set_camera_and_viewport(pxr::SdfPath const &camera_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
||||||
|
{
|
||||||
|
if (key == pxr::HdTokens->params) {
|
||||||
|
return pxr::VtValue(task_params_);
|
||||||
|
}
|
||||||
|
if (key == pxr::HdTokens->collection) {
|
||||||
|
pxr::HdRprimCollection rprim_collection(pxr::HdTokens->geometry,
|
||||||
|
pxr::HdReprSelector(pxr::HdReprTokens->smoothHull),
|
||||||
|
false,
|
||||||
|
pxr::TfToken());
|
||||||
|
rprim_collection.SetRootPath(pxr::SdfPath::AbsoluteRootPath());
|
||||||
|
return pxr::VtValue(rprim_collection);
|
||||||
|
}
|
||||||
|
return pxr::VtValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr::SdfPath const &id)
|
||||||
|
{
|
||||||
|
return buffer_descriptors_[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const &task_id)
|
||||||
|
{
|
||||||
|
return {pxr::HdRenderTagTokens->geometry};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -173,6 +173,20 @@ void DrawTexture::set_buffer(pxr::HdRenderBuffer *buffer)
|
|||||||
buffer->Unmap();
|
buffer->Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawTexture::draw(GPUShader *shader, float x, float y)
|
||||||
|
{
|
||||||
|
int slot = GPU_shader_get_sampler_binding(shader, "image");
|
||||||
|
GPU_texture_bind(texture_, slot);
|
||||||
|
GPU_shader_uniform_1i(shader, "image", slot);
|
||||||
|
|
||||||
|
GPU_matrix_push();
|
||||||
|
GPU_matrix_translate_2f(x, y);
|
||||||
|
GPU_matrix_scale_2f(width_, height_);
|
||||||
|
GPU_batch_set_shader(batch_, shader);
|
||||||
|
GPU_batch_draw(batch_);
|
||||||
|
GPU_matrix_pop();
|
||||||
|
}
|
||||||
|
|
||||||
void DrawTexture::create(pxr::HdRenderBuffer *buffer)
|
void DrawTexture::create(pxr::HdRenderBuffer *buffer)
|
||||||
{
|
{
|
||||||
width_ = buffer->GetWidth();
|
width_ = buffer->GetWidth();
|
||||||
@ -199,20 +213,6 @@ void DrawTexture::free()
|
|||||||
texture_ = nullptr;
|
texture_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTexture::draw(GPUShader *shader, float x, float y)
|
|
||||||
{
|
|
||||||
int slot = GPU_shader_get_sampler_binding(shader, "image");
|
|
||||||
GPU_texture_bind(texture_, slot);
|
|
||||||
GPU_shader_uniform_1i(shader, "image", slot);
|
|
||||||
|
|
||||||
GPU_matrix_push();
|
|
||||||
GPU_matrix_translate_2f(x, y);
|
|
||||||
GPU_matrix_scale_2f(width_, height_);
|
|
||||||
GPU_batch_set_shader(batch_, shader);
|
|
||||||
GPU_batch_draw(batch_);
|
|
||||||
GPU_matrix_pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewportEngine::sync(Depsgraph *depsgraph,
|
void ViewportEngine::sync(Depsgraph *depsgraph,
|
||||||
bContext *context,
|
bContext *context,
|
||||||
pxr::HdRenderSettingsMap &render_settings)
|
pxr::HdRenderSettingsMap &render_settings)
|
||||||
@ -230,6 +230,11 @@ void ViewportEngine::sync(Depsgraph *depsgraph,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewportEngine::render(Depsgraph *depsgraph)
|
||||||
|
{
|
||||||
|
/* Empty function */
|
||||||
|
}
|
||||||
|
|
||||||
void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||||
{
|
{
|
||||||
ViewSettings view_settings(context);
|
ViewSettings view_settings(context);
|
||||||
@ -296,11 +301,6 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewportEngine::render(Depsgraph *depsgraph)
|
|
||||||
{
|
|
||||||
/* Empty function */
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewportEngine::notify_status(const std::string &info, const std::string &status)
|
void ViewportEngine::notify_status(const std::string &info, const std::string &status)
|
||||||
{
|
{
|
||||||
RE_engine_update_stats(bl_engine_, status.c_str(), info.c_str());
|
RE_engine_update_stats(bl_engine_, status.c_str(), info.c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user