datafrost
Data format and acceleration structure management
datafrost is a data-oriented resource management and scheduling library. It implements a graphics API-inspired interface that allows one to cleanly and efficiently:
- Create primary data objects, and define "derived" datatypes whose contents are generated from the primary format.
- Track how a primary object changes and automatically update the affected parts of the derived formats.
- Map the contents of data objects and read them on the main thread.
- Schedule commands to asynchronously and concurrently read or modify data objects.
datafrostguarantees optimal scheduling by building a directed acyclic graph to represent pending operations.- Multiple commands which reference different data, or immutably reference the same data, will execute in parallel.
- Commands which mutably access the same data run in sequence, without the possibility of data races.
Usage
The following is an abridged example of how to use datafrost. The full code may be found in the
examples folder. To begin, we define the data formats that our code will use:
use *;
use *;
/// First, we define a general "kind" of data that our program will use.
/// In this case, let's imagine that we want to efficiently deal with
/// arrays of numbers.
;
/// Defines the layout of an array of numbers.
/// Next, we define the primary data format that we would like
/// to use and modify - an array of specifically `u32`s.
;
/// Now, let's imagine that we want to efficiently maintain an
/// acceleration structure containing all of the numbers in
/// the array, but doubled. So, we define the format.
;
/// Our goal is for `datafrost` to automatically update the doubled
/// array whenever the primary array changes. Thus, we implement
/// a way for it do so.
;
Now that our data and its derived formats are defined, we can create instances of it and schedule commands to act upon the data:
// Create a new context.
let ctx = new;
// Allocate a new primary array object, which has a doubled
// array as a derived format.
let data = ctx.;
// Create a command buffer to record operations to execute
// on our data.
let mut command_buffer = new;
// Schedule a command to fill the primary number array with some data.
let view = data.;
let view_clone = view.clone;
command_buffer.schedule;
// Schedule a command to map the contents of the derived acceleration structure
// so that we may view them synchronously.
let derived = command_buffer.map;
// Submit the buffer for processing.
ctx.submit;
// The doubled acceleration structure automatically contains the
// correct, up-to-date data!
assert_eq!;