1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Corrects access to data_type_size, adds sanity check on output area return.

This commit is contained in:
Thomas Harte 2020-09-13 18:59:27 -04:00
parent e113780fd1
commit 7dd4c67304
2 changed files with 19 additions and 1 deletions

View File

@ -319,6 +319,11 @@ BufferingScanTarget::OutputArea BufferingScanTarget::get_output_area() {
// Update the read-ahead pointers. // Update the read-ahead pointers.
read_ahead_pointers_.store(submit_pointers, std::memory_order::memory_order_relaxed); read_ahead_pointers_.store(submit_pointers, std::memory_order::memory_order_relaxed);
#ifndef NDEBUG
area.counter = output_area_counter_;
++output_area_counter_;
#endif
return area; return area;
} }
@ -330,6 +335,12 @@ void BufferingScanTarget::complete_output_area(const OutputArea &area) {
new_read_pointers.scan = uint16_t(area.end.scan); new_read_pointers.scan = uint16_t(area.end.scan);
new_read_pointers.write_area = TextureAddress(area.end.write_area_x, area.end.write_area_y); new_read_pointers.write_area = TextureAddress(area.end.write_area_x, area.end.write_area_y);
read_pointers_.store(new_read_pointers, std::memory_order::memory_order_relaxed); read_pointers_.store(new_read_pointers, std::memory_order::memory_order_relaxed);
#ifndef NDEBUG
// This will fire if the caller is announcing completed output areas out of order.
assert(area.counter == output_area_next_returned_);
++output_area_next_returned_;
#endif
} }
void BufferingScanTarget::perform(const std::function<void(void)> &function) { void BufferingScanTarget::perform(const std::function<void(void)> &function) {
@ -358,6 +369,7 @@ const Outputs::Display::ScanTarget::Modals *BufferingScanTarget::new_modals() {
// MAJOR SHARP EDGE HERE: assume that because the new_modals have been fetched then the caller will // MAJOR SHARP EDGE HERE: assume that because the new_modals have been fetched then the caller will
// now ensure their texture buffer is appropriate. They might provide a new pointer and might now. // now ensure their texture buffer is appropriate. They might provide a new pointer and might now.
// But either way it's now appropriate to start treating the data size as implied by the data type. // But either way it's now appropriate to start treating the data size as implied by the data type.
std::lock_guard lock_guard(producer_mutex_);
data_type_size_ = Outputs::Display::size_for_data_type(modals_.input_data_type); data_type_size_ = Outputs::Display::size_for_data_type(modals_.input_data_type);
return &modals_; return &modals_;

View File

@ -128,6 +128,10 @@ class BufferingScanTarget: public Outputs::Display::ScanTarget {
}; };
Endpoint start, end; Endpoint start, end;
#ifndef NDEBUG
size_t counter;
#endif
}; };
/// Gets the current range of content that has been posted but not yet returned by /// Gets the current range of content that has been posted but not yet returned by
@ -252,8 +256,10 @@ class BufferingScanTarget: public Outputs::Display::ScanTarget {
bool modals_are_dirty_ = false; bool modals_are_dirty_ = false;
#ifndef NDEBUG #ifndef NDEBUG
// Debug features; these amount to API validate. // Debug features; these amount to API validation.
bool scan_is_ongoing_ = false; bool scan_is_ongoing_ = false;
size_t output_area_counter_ = 0;
size_t output_area_next_returned_ = 0;
#endif #endif
}; };