Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/path_trace_display.cpp
| Show All 10 Lines | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "integrator/path_trace_display.h" | #include "integrator/path_trace_display.h" | ||||
| #include "render/buffers.h" | #include "session/buffers.h" | ||||
| #include "util/util_logging.h" | #include "util/log.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| PathTraceDisplay::PathTraceDisplay(unique_ptr<DisplayDriver> driver) : driver_(move(driver)) | PathTraceDisplay::PathTraceDisplay(unique_ptr<DisplayDriver> driver) : driver_(move(driver)) | ||||
| { | { | ||||
| } | } | ||||
| void PathTraceDisplay::reset(const BufferParams &buffer_params) | void PathTraceDisplay::reset(const BufferParams &buffer_params) | ||||
| { | { | ||||
| thread_scoped_lock lock(mutex_); | 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_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_.full_size = make_int2(buffer_params.full_width, buffer_params.full_height); | ||||
| params_.size = make_int2(buffer_params.width, buffer_params.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; | texture_state_.is_outdated = true; | ||||
| } | } | ||||
| void PathTraceDisplay::mark_texture_updated() | void PathTraceDisplay::mark_texture_updated() | ||||
| { | { | ||||
| texture_state_.is_outdated = false; | texture_state_.is_outdated = false; | ||||
| texture_state_.is_usable = true; | |||||
| } | } | ||||
| /* -------------------------------------------------------------------- | /* -------------------------------------------------------------------- | ||||
| * Update procedure. | * Update procedure. | ||||
| */ | */ | ||||
| bool PathTraceDisplay::update_begin(int texture_width, int texture_height) | bool PathTraceDisplay::update_begin(int texture_width, int texture_height) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| bool PathTraceDisplay::draw() | bool PathTraceDisplay::draw() | ||||
| { | { | ||||
| /* Get parameters within a mutex lock, to avoid reset() modifying them at the same time. | /* Get parameters within a mutex lock, to avoid reset() modifying them at the same time. | ||||
| * The drawing itself is non-blocking however, for better performance and to avoid | * The drawing itself is non-blocking however, for better performance and to avoid | ||||
| * potential deadlocks due to locks held by the subclass. */ | * potential deadlocks due to locks held by the subclass. */ | ||||
| DisplayDriver::Params params; | DisplayDriver::Params params; | ||||
| bool is_usable; | |||||
| bool is_outdated; | bool is_outdated; | ||||
| { | { | ||||
| thread_scoped_lock lock(mutex_); | thread_scoped_lock lock(mutex_); | ||||
| params = params_; | params = params_; | ||||
| is_usable = texture_state_.is_usable; | |||||
| is_outdated = texture_state_.is_outdated; | is_outdated = texture_state_.is_outdated; | ||||
| } | } | ||||
| if (is_usable) { | |||||
| driver_->draw(params); | driver_->draw(params); | ||||
| } | |||||
| return !is_outdated; | return !is_outdated; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||