forked from blender/blender
Fix review comments #27
@ -5,10 +5,11 @@
|
|||||||
#include "DEG_depsgraph_query.h"
|
#include "DEG_depsgraph_query.h"
|
||||||
#include "GPU_framebuffer.h"
|
#include "GPU_framebuffer.h"
|
||||||
#include "GPU_texture.h"
|
#include "GPU_texture.h"
|
||||||
|
#include "PIL_time.h"
|
||||||
|
#include "BLI_timecode.h"
|
||||||
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "final_engine.h"
|
#include "final_engine.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
@ -63,12 +64,6 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
|||||||
}
|
}
|
||||||
tasks.push_back(render_task_delegate_->get_task());
|
tasks.push_back(render_task_delegate_->get_task());
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::steady_clock> time_begin = std::chrono::steady_clock::now(),
|
|
||||||
time_current;
|
|
||||||
std::chrono::milliseconds elapsed_time;
|
|
||||||
|
|
||||||
float percent_done = 0.0;
|
|
||||||
|
|
||||||
std::map<std::string, std::vector<float>> render_images{
|
std::map<std::string, std::vector<float>> render_images{
|
||||||
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
||||||
std::vector<float> &pixels = render_images["Combined"];
|
std::vector<float> &pixels = render_images["Combined"];
|
||||||
@ -79,19 +74,23 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
|||||||
engine_->Execute(render_index_.get(), &tasks);
|
engine_->Execute(render_index_.get(), &tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char elapsed_time[32];
|
||||||
|
double time_begin = PIL_check_seconds_timer();
|
||||||
|
float percent_done = 0.0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (RE_engine_test_break(bl_engine_)) {
|
if (RE_engine_test_break(bl_engine_)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
percent_done = renderer_percent_done();
|
percent_done = renderer_percent_done();
|
||||||
time_current = std::chrono::steady_clock::now();
|
|
||||||
elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(time_current -
|
BLI_timecode_string_from_time_simple(
|
||||||
time_begin);
|
elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin);
|
||||||
|
|
||||||
notify_status(percent_done / 100.0,
|
notify_status(percent_done / 100.0,
|
||||||
scene_name + ": " + layer_name,
|
scene_name + ": " + layer_name,
|
||||||
"Render Time: " + format_duration(elapsed_time) +
|
std::string("Render Time: ") + elapsed_time +
|
||||||
" | Done: " + std::to_string(int(percent_done)) + "%");
|
" | Done: " + std::to_string(int(percent_done)) + "%");
|
||||||
|
|
||||||
if (render_task_delegate_->is_converged()) {
|
if (render_task_delegate_->is_converged()) {
|
||||||
@ -185,12 +184,6 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
}
|
}
|
||||||
tasks.push_back(render_task_delegate_->get_task());
|
tasks.push_back(render_task_delegate_->get_task());
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::steady_clock> time_begin = std::chrono::steady_clock::now(),
|
|
||||||
time_current;
|
|
||||||
std::chrono::milliseconds elapsed_time;
|
|
||||||
|
|
||||||
float percent_done = 0.0;
|
|
||||||
|
|
||||||
std::map<std::string, std::vector<float>> render_images{
|
std::map<std::string, std::vector<float>> render_images{
|
||||||
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
||||||
std::vector<float> &pixels = render_images["Combined"];
|
std::vector<float> &pixels = render_images["Combined"];
|
||||||
@ -217,19 +210,23 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
engine_->Execute(render_index_.get(), &tasks);
|
engine_->Execute(render_index_.get(), &tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char elapsed_time[32];
|
||||||
|
double time_begin = PIL_check_seconds_timer();
|
||||||
|
float percent_done = 0.0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (RE_engine_test_break(bl_engine_)) {
|
if (RE_engine_test_break(bl_engine_)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
percent_done = renderer_percent_done();
|
percent_done = renderer_percent_done();
|
||||||
time_current = std::chrono::steady_clock::now();
|
|
||||||
elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(time_current -
|
BLI_timecode_string_from_time_simple(
|
||||||
time_begin);
|
elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin);
|
||||||
|
|
||||||
notify_status(percent_done / 100.0,
|
notify_status(percent_done / 100.0,
|
||||||
scene_name + ": " + layer_name,
|
scene_name + ": " + layer_name,
|
||||||
"Render Time: " + format_duration(elapsed_time) +
|
std::string("Render Time: ") + elapsed_time +
|
||||||
" | Done: " + std::to_string(int(percent_done)) + "%");
|
" | Done: " + std::to_string(int(percent_done)) + "%");
|
||||||
|
|
||||||
if (render_task_delegate_->is_converged()) {
|
if (render_task_delegate_->is_converged()) {
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: Apache-2.0
|
/* SPDX-License-Identifier: Apache-2.0
|
||||||
* Copyright 2011-2022 Blender Foundation */
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <pxr/base/tf/stringUtils.h>
|
#include <pxr/base/tf/stringUtils.h>
|
||||||
|
|
||||||
@ -29,35 +27,6 @@ pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4])
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string format_duration(std::chrono::milliseconds millisecs)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
bool neg = millisecs < std::chrono::milliseconds(0);
|
|
||||||
if (neg) {
|
|
||||||
millisecs = -millisecs;
|
|
||||||
}
|
|
||||||
auto m = std::chrono::duration_cast<std::chrono::minutes>(millisecs);
|
|
||||||
millisecs -= m;
|
|
||||||
auto s = std::chrono::duration_cast<std::chrono::seconds>(millisecs);
|
|
||||||
millisecs -= s;
|
|
||||||
if (neg) {
|
|
||||||
ss << "-";
|
|
||||||
}
|
|
||||||
if (m < std::chrono::minutes(10)) {
|
|
||||||
ss << "0";
|
|
||||||
}
|
|
||||||
ss << std::to_string(m / std::chrono::minutes(1)) << ":";
|
|
||||||
if (s < std::chrono::seconds(10)) {
|
|
||||||
ss << "0";
|
|
||||||
}
|
|
||||||
ss << std::to_string(s / std::chrono::seconds(1)) << ":";
|
|
||||||
if (millisecs < std::chrono::milliseconds(10)) {
|
|
||||||
ss << "0";
|
|
||||||
}
|
|
||||||
ss << std::to_string(millisecs / std::chrono::milliseconds(1) / 10);
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string cache_image(Main *bmain,
|
std::string cache_image(Main *bmain,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
Image *image,
|
Image *image,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <pxr/base/gf/matrix4d.h>
|
#include <pxr/base/gf/matrix4d.h>
|
||||||
@ -14,7 +13,6 @@
|
|||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
||||||
std::string format_duration(std::chrono::milliseconds secs);
|
|
||||||
std::string cache_image(Main *bmain,
|
std::string cache_image(Main *bmain,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
Image *image,
|
Image *image,
|
||||||
|
@ -11,14 +11,16 @@
|
|||||||
|
|
||||||
#include "BKE_camera.h"
|
#include "BKE_camera.h"
|
||||||
|
|
||||||
|
#include "BLI_timecode.h"
|
||||||
#include "BLI_math_matrix.h"
|
#include "BLI_math_matrix.h"
|
||||||
|
|
||||||
#include "DEG_depsgraph_query.h"
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "GPU_matrix.h"
|
#include "GPU_matrix.h"
|
||||||
|
|
||||||
|
#include "PIL_time.h"
|
||||||
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "viewport_engine.h"
|
#include "viewport_engine.h"
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
@ -259,10 +261,6 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
|||||||
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color);
|
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderer_percent_done() == 0.0f) {
|
|
||||||
time_begin_ = std::chrono::steady_clock::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
|
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
|
||||||
GPU_shader_bind(shader);
|
GPU_shader_bind(shader);
|
||||||
|
|
||||||
@ -285,21 +283,23 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
|||||||
|
|
||||||
GPU_shader_unbind();
|
GPU_shader_unbind();
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::steady_clock> time_current =
|
if (renderer_percent_done() == 0.0f) {
|
||||||
std::chrono::steady_clock::now();
|
time_begin_ = PIL_check_seconds_timer();
|
||||||
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
}
|
||||||
time_current - time_begin_);
|
|
||||||
|
|
||||||
std::string formatted_time = format_duration(elapsed_time);
|
char elapsed_time[32];
|
||||||
|
|
||||||
|
BLI_timecode_string_from_time_simple(
|
||||||
|
elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_);
|
||||||
|
|
||||||
if (!render_task_delegate_->is_converged()) {
|
if (!render_task_delegate_->is_converged()) {
|
||||||
notify_status("Time: " + formatted_time +
|
notify_status(std::string("Time: ") + elapsed_time +
|
||||||
" | Done: " + std::to_string(int(renderer_percent_done())) + "%",
|
" | Done: " + std::to_string(int(renderer_percent_done())) + "%",
|
||||||
"Render");
|
"Render");
|
||||||
bl_engine_->flag |= RE_ENGINE_DO_DRAW;
|
bl_engine_->flag |= RE_ENGINE_DO_DRAW;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
notify_status(("Time: " + formatted_time).c_str(), "Rendering Done");
|
notify_status((std::string("Time: ") + elapsed_time).c_str(), "Rendering Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include <pxr/imaging/hd/renderBuffer.h>
|
#include <pxr/imaging/hd/renderBuffer.h>
|
||||||
|
|
||||||
#include "GPU_batch.h"
|
#include "GPU_batch.h"
|
||||||
@ -46,7 +44,7 @@ class ViewportEngine : public Engine {
|
|||||||
void notify_status(const std::string &title, const std::string &info);
|
void notify_status(const std::string &title, const std::string &info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::time_point<std::chrono::steady_clock> time_begin_;
|
double time_begin_;
|
||||||
|
|
||||||
DrawTexture draw_texture_;
|
DrawTexture draw_texture_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user