diff options
-rw-r--r-- | intern/cycles/blender/blender_display_driver.cpp | 35 | ||||
-rw-r--r-- | intern/cycles/blender/blender_display_driver.h | 3 | ||||
-rw-r--r-- | intern/cycles/integrator/path_trace_display.cpp | 19 | ||||
-rw-r--r-- | intern/cycles/integrator/path_trace_display.h | 9 |
4 files changed, 30 insertions, 36 deletions
diff --git a/intern/cycles/blender/blender_display_driver.cpp b/intern/cycles/blender/blender_display_driver.cpp index f55a8ce8c4e..3870f4956f2 100644 --- a/intern/cycles/blender/blender_display_driver.cpp +++ b/intern/cycles/blender/blender_display_driver.cpp @@ -357,6 +357,8 @@ bool BlenderDisplayDriver::update_begin(const Params ¶ms, * centralized place. */ texture_.need_update = true; + texture_.params = params; + return true; } @@ -717,8 +719,23 @@ void BlenderDisplayDriver::texture_update_if_needed() texture_.need_update = false; } -void BlenderDisplayDriver::vertex_buffer_update(const Params ¶ms) +void BlenderDisplayDriver::vertex_buffer_update(const Params & /*params*/) { + /* Draw at the parameters for which the texture has been updated for. This allows to always draw + * texture during bordered-rendered camera view without flickering. The validness of the display + * parameters for a texture is guaranteed by the initial "clear" state which makes drawing to + * have an early output. + * + * Such approach can cause some extra "jelly" effect during panning, but it is not more jelly + * than overlay of selected objects. Also, it's possible to redraw texture at an intersection of + * the texture draw parameters and the latest updated draw paaremters (altohoyugh, complexity of + * doing it might not worth it. */ + const int x = texture_.params.full_offset.x; + const int y = texture_.params.full_offset.y; + + const int width = texture_.params.size.x; + const int height = texture_.params.size.y; + /* Invalidate old contents - avoids stalling if the buffer is still waiting in queue to be * rendered. */ glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW); @@ -730,23 +747,23 @@ void BlenderDisplayDriver::vertex_buffer_update(const Params ¶ms) vpointer[0] = 0.0f; vpointer[1] = 0.0f; - vpointer[2] = params.full_offset.x; - vpointer[3] = params.full_offset.y; + vpointer[2] = x; + vpointer[3] = y; vpointer[4] = 1.0f; vpointer[5] = 0.0f; - vpointer[6] = (float)params.size.x + params.full_offset.x; - vpointer[7] = params.full_offset.y; + vpointer[6] = x + width; + vpointer[7] = y; vpointer[8] = 1.0f; vpointer[9] = 1.0f; - vpointer[10] = (float)params.size.x + params.full_offset.x; - vpointer[11] = (float)params.size.y + params.full_offset.y; + vpointer[10] = x + width; + vpointer[11] = y + height; vpointer[12] = 0.0f; vpointer[13] = 1.0f; - vpointer[14] = params.full_offset.x; - vpointer[15] = (float)params.size.y + params.full_offset.y; + vpointer[14] = x; + vpointer[15] = y + height; glUnmapBuffer(GL_ARRAY_BUFFER); } diff --git a/intern/cycles/blender/blender_display_driver.h b/intern/cycles/blender/blender_display_driver.h index 558997c6b4f..5e7e9b01065 100644 --- a/intern/cycles/blender/blender_display_driver.h +++ b/intern/cycles/blender/blender_display_driver.h @@ -188,6 +188,9 @@ class BlenderDisplayDriver : public DisplayDriver { /* Dimensions of the underlying PBO. */ int buffer_width = 0; int buffer_height = 0; + + /* Display parameters the texture has been updated for. */ + Params params; } texture_; unique_ptr<BlenderDisplayShader> display_shader_; diff --git a/intern/cycles/integrator/path_trace_display.cpp b/intern/cycles/integrator/path_trace_display.cpp index 28f0a7f7745..e22989bb301 100644 --- a/intern/cycles/integrator/path_trace_display.cpp +++ b/intern/cycles/integrator/path_trace_display.cpp @@ -30,29 +30,16 @@ void PathTraceDisplay::reset(const BufferParams &buffer_params) { thread_scoped_lock lock(mutex_); - const DisplayDriver::Params old_params = params_; - params_.full_offset = make_int2(buffer_params.full_x, buffer_params.full_y); params_.full_size = make_int2(buffer_params.full_width, buffer_params.full_height); params_.size = make_int2(buffer_params.width, buffer_params.height); - /* If the parameters did change tag texture as unusable. This avoids drawing old texture content - * in an updated configuration of the viewport. For example, avoids drawing old frame when render - * border did change. - * If the parameters did not change, allow drawing the current state of the texture, which will - * not count as an up-to-date redraw. This will avoid flickering when doping camera navigation by - * showing a previously rendered frame for until the new one is ready. */ - if (old_params.modified(params_)) { - texture_state_.is_usable = false; - } - texture_state_.is_outdated = true; } void PathTraceDisplay::mark_texture_updated() { texture_state_.is_outdated = false; - texture_state_.is_usable = true; } /* -------------------------------------------------------------------- @@ -248,19 +235,15 @@ bool PathTraceDisplay::draw() * The drawing itself is non-blocking however, for better performance and to avoid * potential deadlocks due to locks held by the subclass. */ DisplayDriver::Params params; - bool is_usable; bool is_outdated; { thread_scoped_lock lock(mutex_); params = params_; - is_usable = texture_state_.is_usable; is_outdated = texture_state_.is_outdated; } - if (is_usable) { - driver_->draw(params); - } + driver_->draw(params); return !is_outdated; } diff --git a/intern/cycles/integrator/path_trace_display.h b/intern/cycles/integrator/path_trace_display.h index 24aaa0df6b1..99d2e0e1203 100644 --- a/intern/cycles/integrator/path_trace_display.h +++ b/intern/cycles/integrator/path_trace_display.h @@ -174,15 +174,6 @@ class PathTraceDisplay { /* State of the texture, which is needed for an integration with render session and interactive * updates and navigation. */ struct { - /* Denotes whether possibly existing state of GPU side texture is still usable. - * It will not be usable in cases like render border did change (in this case we don't want - * previous texture to be rendered at all). - * - * However, if only navigation or object in scene did change, then the outdated state of the - * texture is still usable for draw, preventing display viewport flickering on navigation and - * object modifications. */ - bool is_usable = false; - /* Texture is considered outdated after `reset()` until the next call of * `copy_pixels_to_texture()`. */ bool is_outdated = true; |