Class VertexBuffer
Holds interleaved vertex data for a Mesh. The backing store is allocated
through the platform SIMD allocator (Simd.allocFloat(int)) so that on
ParparVM the array lives at a fixed, aligned native address and can be handed
to the GPU with no intermediate copy. On other platforms the same array is an
ordinary float[].
Mutate the data through setData or by writing into getData() and then
calling setDirty(); the bound GraphicsDevice re-uploads dirty buffers
before the next draw.
-
Constructor Summary
ConstructorsConstructorDescriptionVertexBuffer(VertexFormat format, int vertexCount) Allocates a vertex buffer for the supplied format and vertex count. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the dirty flag.float[]getData()Returns the SIMD aligned backing array.intReturns the number of meaningful floats in the backing array (vertexCount * format.getFloatsPerVertex()).Returns the vertex layout of this buffer.Returns the opaque backend GPU handle, or null if not yet uploaded.intReturns the number of vertices this buffer holds.booleanisDirty()Returns true if the buffer has pending changes that must be uploaded.voidsetData(float[] src) Copiessrcinto the backing array starting at float index 0 and marks the buffer dirty.voidsetDirty()Marks the buffer as needing re-upload to the GPU before the next draw.voidStores the opaque backend GPU handle.
-
Constructor Details
-
VertexBuffer
Allocates a vertex buffer for the supplied format and vertex count. The backing array is SIMD aligned. Prefer creating buffers through
GraphicsDevice.createVertexBuffer(VertexFormat, int)so the GPU handle is tracked by the device.Parameters
-
format: the interleaved vertex layout -
vertexCount: the number of vertices the buffer can hold
-
-
-
Method Details
-
getFormat
Returns the vertex layout of this buffer. -
getVertexCount
public int getVertexCount()Returns the number of vertices this buffer holds. -
getFloatCount
public int getFloatCount()Returns the number of meaningful floats in the backing array (vertexCount * format.getFloatsPerVertex()). The array itself may be padded to a larger SIMD friendly size. -
getData
public float[] getData()Returns the SIMD aligned backing array. Write vertex floats directly here for maximum throughput, then callsetDirty(). -
setData
public void setData(float[] src) Copies
srcinto the backing array starting at float index 0 and marks the buffer dirty.Parameters
src: the interleaved float data; length must not exceed the buffer
-
setDirty
public void setDirty()Marks the buffer as needing re-upload to the GPU before the next draw. -
isDirty
public boolean isDirty()Returns true if the buffer has pending changes that must be uploaded. Intended for backend use. -
clearDirty
public void clearDirty()Clears the dirty flag. Intended for backend use after an upload. -
getHandle
Returns the opaque backend GPU handle, or null if not yet uploaded. Intended for backend use. -
setHandle
Stores the opaque backend GPU handle. Intended for backend use.
Parameters
handle: the backend specific GPU resource handle
-