From de7ebead23ef6c385cb820d71c29e3a665a57a7b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 21 Feb 2019 22:30:41 -0500 Subject: [PATCH] Ensures the line_allocation_has_failed_ condition can be exited. --- Outputs/OpenGL/ScanTarget.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Outputs/OpenGL/ScanTarget.cpp b/Outputs/OpenGL/ScanTarget.cpp index 753acbd5c..1a3933480 100644 --- a/Outputs/OpenGL/ScanTarget.cpp +++ b/Outputs/OpenGL/ScanTarget.cpp @@ -253,6 +253,8 @@ void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display:: if(output_is_visible_ == is_visible) return; if(is_visible) { + const auto read_pointers = read_pointers_.load(); + // Commit the most recent line only if any scans fell on it. // Otherwise there's no point outputting it, it'll contribute nothing. if(provided_scans_) { @@ -263,8 +265,6 @@ void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display:: is_first_in_frame_ = false; } - const auto read_pointers = read_pointers_.load(); - // Attempt to allocate a new line; note allocation failure if necessary. const auto next_line = uint16_t((write_pointers_.line + 1) % LineBufferHeight); if(next_line == read_pointers.line) { @@ -276,6 +276,16 @@ void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display:: active_line_ = &line_buffer_[size_t(write_pointers_.line)]; } provided_scans_ = 0; + } else { + // Just check whether a new line is available now, if waiting. + if(line_allocation_has_failed_) { + const auto next_line = uint16_t((write_pointers_.line + 1) % LineBufferHeight); + if(next_line != read_pointers.line) { + line_allocation_has_failed_ = false; + write_pointers_.line = next_line; + active_line_ = &line_buffer_[size_t(write_pointers_.line)]; + } + } } if(active_line_) { @@ -551,7 +561,7 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) { // If this is start-of-frame, clear any untouched pixels and flush the stencil buffer if(line_metadata_buffer_[start_line].is_first_in_frame) { if(stencil_is_valid_ && line_metadata_buffer_[start_line].previous_frame_was_complete) { - full_display_rectangle_.draw(0.0f, 0.0f, 0.0f); + full_display_rectangle_.draw(1.0f, 0.0f, 0.0f); } stencil_is_valid_ = true; test_gl(glClear, GL_STENCIL_BUFFER_BIT);