From fda90c5aef7efb9f8a290de45ba5ab9834defe28 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 20 Nov 2016 09:11:24 +0800 Subject: [PATCH] Documented. --- Outputs/CRT/Internals/ArrayBuilder.cpp | 10 ++++----- Outputs/CRT/Internals/ArrayBuilder.hpp | 30 +++++++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Outputs/CRT/Internals/ArrayBuilder.cpp b/Outputs/CRT/Internals/ArrayBuilder.cpp index 514f827d8..d04e394cc 100644 --- a/Outputs/CRT/Internals/ArrayBuilder.cpp +++ b/Outputs/CRT/Internals/ArrayBuilder.cpp @@ -34,9 +34,9 @@ uint8_t *ArrayBuilder::get_input_storage(size_t size) return get_storage(size, input_); } -uint8_t *ArrayBuilder::reget_input_storage(size_t &size) +uint8_t *ArrayBuilder::get_unflushed_input(size_t &size) { - return input_.reget_storage(size); + return input_.get_unflushed(size); } uint8_t *ArrayBuilder::get_output_storage(size_t size) @@ -44,9 +44,9 @@ uint8_t *ArrayBuilder::get_output_storage(size_t size) return get_storage(size, output_); } -uint8_t *ArrayBuilder::reget_output_storage(size_t &size) +uint8_t *ArrayBuilder::get_unflushed_input(size_t &size) { - return output_.reget_storage(size); + return output_.get_unflushed(size); } void ArrayBuilder::flush() @@ -127,7 +127,7 @@ uint8_t *ArrayBuilder::Buffer::get_storage(size_t size) return pointer; } -uint8_t *ArrayBuilder::Buffer::reget_storage(size_t &size) +uint8_t *ArrayBuilder::Buffer::get_unflushed(size_t &size) { if(is_full) { diff --git a/Outputs/CRT/Internals/ArrayBuilder.hpp b/Outputs/CRT/Internals/ArrayBuilder.hpp index b9d84b28a..ed72b98af 100644 --- a/Outputs/CRT/Internals/ArrayBuilder.hpp +++ b/Outputs/CRT/Internals/ArrayBuilder.hpp @@ -37,22 +37,43 @@ class ArrayBuilder { /// to the @c submission_function. [Teleological: this is provided as a testing hook.] ArrayBuilder(size_t input_size, size_t output_size, std::function submission_function); - /// Attempts to add @c size bytes + /// Attempts to add @c size bytes to the input set. + /// @returns a pointer to the allocated area if allocation was possible; @c nullptr otherwise. uint8_t *get_input_storage(size_t size); - uint8_t *reget_input_storage(size_t &size); + /// Gets the size of and a pointer to all data so far added to the input set but not yet flushed. + /// @returns a pointer from which it is safe to access @c size elements, which contains all regions returned via + /// @c get_input_storage in FIFO order. + uint8_t *get_unflushed_input(size_t &size); + + /// Attempts to add @c size bytes to the output set. + /// @returns a pointer to the allocated area if allocation was possible; @c nullptr otherwise. uint8_t *get_output_storage(size_t size); - uint8_t *reget_output_storage(size_t &size); + /// Gets the size of and a pointer to all data so far added to the output set but not yet flushed. + /// @returns a pointer from which it is safe to access @c size elements, which contains all regions returned via + /// @c get_input_storage in FIFO order. + uint8_t *get_unflushed_output(size_t &size); + + /// @returns @c true if either of the input or output storage areas is currently exhausted; @c false otherwise. bool is_full(); + + /// If neither input nor output was exhausted since the last flush, atomically commits both input and output + /// up to the currently allocated size for use upon the next @c submit. Otherwise acts as a no-op. void flush(); + /// Binds the input array to GL_ARRAY_BUFFER. void bind_input(); + + /// Binds the output array to GL_ARRAY_BUFFER. void bind_output(); struct Submission { size_t input_size, output_size; }; + + /// Submits all flushed input and output data to the corresponding arrays. + /// @returns A @c Submission record, indicating how much data of each type was submitted. Submission submit(); private: @@ -62,7 +83,7 @@ class ArrayBuilder { ~Buffer(); uint8_t *get_storage(size_t size); - uint8_t *reget_storage(size_t &size); + uint8_t *get_unflushed(size_t &size); void flush(); size_t submit(bool is_input); @@ -82,7 +103,6 @@ class ArrayBuilder { std::mutex buffer_mutex_; bool is_full_; - ; }; }