Class GpuBuffer<T>
java.lang.Object
dev.engine.graphics.GpuBuffer<T>
- Type Parameters:
T- the record type
A typed GPU buffer backed by a Java record type.
Combines a GPU buffer handle with a StructLayout for automatic
serialization, and a SlangStructGenerator for shader code generation.
Single source of truth: the record defines CPU layout, GPU layout, and shader struct.
-
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Maximum number of elements.static <T> GpuBuffer<T> create(RenderDevice device, Class<T> type, BufferUsage usage, AccessPattern access) Creates a single-element GPU buffer from a record type.static <T> GpuBuffer<T> createArray(RenderDevice device, Class<T> type, int capacity, BufferUsage usage, AccessPattern access) Creates an array GPU buffer that can hold multiple elements.voiddestroy()Destroys the GPU buffer.intSize of a single element in bytes.handle()GPU buffer handle for binding.layout()The struct layout used for serialization.slangCbuffer(String name, int binding) Generates a Slang cbuffer declaration for this buffer.Generates Slang source for this type and all dependencies.Generates the Slang struct definition for this buffer's type.longTotal buffer size in bytes.type()The record type this buffer holds.voidWrites a record at the given index (for array buffers).voidWrites a single record to the buffer (for single-element buffers).
-
Method Details
-
create
public static <T> GpuBuffer<T> create(RenderDevice device, Class<T> type, BufferUsage usage, AccessPattern access) Creates a single-element GPU buffer from a record type. -
createArray
public static <T> GpuBuffer<T> createArray(RenderDevice device, Class<T> type, int capacity, BufferUsage usage, AccessPattern access) Creates an array GPU buffer that can hold multiple elements. -
write
Writes a single record to the buffer (for single-element buffers). -
write
Writes a record at the given index (for array buffers). -
handle
GPU buffer handle for binding. -
type
-
layout
The struct layout used for serialization. -
capacity
public int capacity()Maximum number of elements. -
elementSize
public int elementSize()Size of a single element in bytes. -
totalSize
public long totalSize()Total buffer size in bytes. -
slangStructSource
Generates the Slang struct definition for this buffer's type. -
slangCbuffer
-
slangFullSource
Generates Slang source for this type and all dependencies. -
destroy
public void destroy()Destroys the GPU buffer.
-