dev-docs/RFCs/v5.3/attribute-buffer-rfc.md
This RFC proposes to move Buffer creation from luma.gl into AttributeManager.
Related discussions: #1527
Since v4, applications are allowed to calculate attributes outside of a layer and then pass in the attribute value as a layer prop. AttributeManager skips the default updating procedure if an external buffer prop is found for an attribute.
Currently, AttributeManager requires the external buffer to be a typed array. The typed array is later used to construct a luma.gl Buffer object when calling model.setAttribute.
The current approach places some limitations on applications:
buffer.subData than uploading the entire attribute array (e.g. editing with Nebula.gl)model.delete() does not remove existing buffers as they might be in use by other models. Therefore adding/removing layers leave behind orphan buffers which are no longer used and whose resources are never released.Selectively port the existing Attribute class in deck.gl to luma.gl.
Props:
id (String)type (Enum)size (Number)value (TypedArray)offset (Number, optional)stride (Number, optional)normalized (Bool, optional)integer (Bool, optional)isGeneric (Bool, optional)isIndexed (Bool, optional)instanced (Bool, optional)Methods:
getBuffer() - if an attribute is not generic and does not contain a buffer object already, create a new buffer from attribute descriptors.finalize() - destroy any buffer object created by itself.Attribute class with deck.gl specific props/methods.LayerAttributeattribute.finalize in attributeManager.remove.attributeManager.finalize method, in which delete all Buffer objects in attributes. Call attributeManager.finalize in layer._finalize.attributeManager.setBuffers method, for layers to set attribute buffers internally (GPGPU use case).