mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-19 19:16:34 +00:00
Eliminate LineMetadata, redundant memory barriers.
This commit is contained in:
@@ -84,7 +84,7 @@ ScanTarget::ScanTarget(const API api, const GLuint target_framebuffer, const flo
|
||||
dirty_zones_(dirty_zones_buffer_) {
|
||||
|
||||
set_scan_buffer(scan_buffer_.data(), scan_buffer_.size());
|
||||
set_line_buffer(line_buffer_.data(), line_metadata_buffer_.data(), line_buffer_.size());
|
||||
set_line_buffer(line_buffer_.data(), line_buffer_.size());
|
||||
|
||||
// TODO: if this is OpenGL 4.4 or newer, use glBufferStorage rather than glBufferData
|
||||
// and specify GL_MAP_PERSISTENT_BIT. Then map the buffer now, and let the client
|
||||
|
||||
@@ -99,7 +99,6 @@ private:
|
||||
std::vector<uint8_t> write_area_texture_;
|
||||
std::array<Scan, LineBufferHeight*5> scan_buffer_{};
|
||||
std::array<Line, LineBufferHeight> line_buffer_{};
|
||||
std::array<LineMetadata, LineBufferHeight> line_metadata_buffer_{};
|
||||
std::array<DirtyZone, 2> dirty_zones_buffer_{};
|
||||
|
||||
VertexArray scans_;
|
||||
|
||||
@@ -264,19 +264,7 @@ void BufferingScanTarget::announce(
|
||||
} else {
|
||||
// Commit the most recent line only if any scans fell on it and all allocation was successful.
|
||||
if(!allocation_has_failed_ && provided_scans_) {
|
||||
const auto submit_pointers = submit_pointers_.load(std::memory_order_relaxed);
|
||||
|
||||
// Store metadata.
|
||||
LineMetadata &metadata = line_metadata_buffer_[size_t(write_pointers_.line)];
|
||||
metadata.is_first_in_frame = is_first_in_frame_;
|
||||
metadata.previous_frame_was_complete = previous_frame_was_complete_;
|
||||
metadata.first_scan = submit_pointers.scan;
|
||||
is_first_in_frame_ = false;
|
||||
|
||||
// Sanity check.
|
||||
assert(((metadata.first_scan + size_t(provided_scans_)) % scan_buffer_size_) == write_pointers_.scan);
|
||||
|
||||
// Store actual line data.
|
||||
// Store line data.
|
||||
Line &active_line = line_buffer_[size_t(write_pointers_.line)];
|
||||
active_line.end_points[1].x = location.x;
|
||||
active_line.end_points[1].y = location.y;
|
||||
@@ -287,7 +275,6 @@ void BufferingScanTarget::announce(
|
||||
write_pointers_.line = uint16_t((write_pointers_.line + 1) % line_buffer_size_);
|
||||
|
||||
// Update the submit pointers with all lines, scans and data written during this line.
|
||||
std::atomic_thread_fence(std::memory_order_release);
|
||||
submit_pointers_.store(write_pointers_, std::memory_order_release);
|
||||
} else {
|
||||
// Something failed, or there was nothing on the line anyway, so reset all pointers to where they
|
||||
@@ -344,7 +331,6 @@ BufferingScanTarget::OutputArea BufferingScanTarget::get_output_area() {
|
||||
const auto read_ahead_pointers = read_ahead_pointers_.load(std::memory_order_relaxed);
|
||||
const auto frame_read = frame_read_.load(std::memory_order_relaxed);
|
||||
const auto frame_write = frame_write_.load(std::memory_order_relaxed);
|
||||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
|
||||
OutputArea area;
|
||||
|
||||
@@ -397,11 +383,9 @@ void BufferingScanTarget::set_scan_buffer(Scan *const buffer, const size_t size)
|
||||
|
||||
void BufferingScanTarget::set_line_buffer(
|
||||
Line *const line_buffer,
|
||||
LineMetadata *const metadata_buffer,
|
||||
const size_t size
|
||||
) {
|
||||
line_buffer_ = line_buffer;
|
||||
line_metadata_buffer_ = metadata_buffer;
|
||||
line_buffer_size_ = size;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
void set_scan_buffer(Scan *buffer, size_t size);
|
||||
|
||||
/// Sets the area of memory to use as line and line metadata buffers.
|
||||
void set_line_buffer(Line *line_buffer, LineMetadata *metadata_buffer, size_t size);
|
||||
void set_line_buffer(Line *line_buffer, size_t size);
|
||||
|
||||
/// Sets a new base address for the texture.
|
||||
/// When called this will flush all existing data and load up the
|
||||
@@ -282,7 +282,6 @@ private:
|
||||
|
||||
// The owner-supplied line buffer and size.
|
||||
Line *line_buffer_ = nullptr;
|
||||
LineMetadata *line_metadata_buffer_ = nullptr;
|
||||
size_t line_buffer_size_ = 0;
|
||||
|
||||
// Current modals and whether they've yet been returned
|
||||
|
||||
Reference in New Issue
Block a user