Tech/LxEngine/Sandbox/Primitive Buffer

What is a Primitive Buffer?
The primitive buffer is a generalzation of a data buffer in a graphics system. It can be used to represent geometric or image data buffer.

A primitive buffer is composed of an array of streams. These streams in turn are composed of one or more channels of interleaved data. Each channel can be optionally named and semantically labelled.

The semantic labels allow for algorithms to be smart in choosing the correct data channels to activate or operate on. Likewise, the semantic associations allow operations to find all associated data on, for example, interpolation of vertex data after a vertex split.

The primitive buffer also manages iteration over channels so that algorithms can operate without concern about whether relevant data is interleaved or multi-stream.

The representation of the stream is abstracted from the interface, allowing system or video memory buffers to be used in the particular implementation.

The primitive buffer is also a higher-level object than exposed by GPU-based systems since it is not constrained to the capabilities of the hardware; for example, it is capable of storing and maintaining meshes with connectivity data.

Interface at a Glance
Primitive Buffer
 * type
 * stream[]
 * name
 * stride
 * size
 * channels[]
 * name
 * semantic name
 * type

types include point_list, line_list, tri_list, quad_list, image

Example: Heightmap
''This example is incomplete and suggests design issues with the primitive buffer: how is it possible to hide the interpolation of the dependent vertex data from the algorithm (i.e. how can this "just work" regardless of the whether or not the incoming buffer has vertex color or vertex normals or both or neither?). It may be worth considering if a 'mesh' object yields a better design.''