module Buf:sig..end
Buffers are linear arrays of scalars of a given scalar
type. At a given point in time the scalars may exist only on the
CPU side, only on the GPU side or on both sides (synchronized or not).
typeusage =[ `Dynamic_copy
| `Dynamic_draw
| `Dynamic_read
| `Static_copy
| `Static_draw
| `Static_read
| `Stream_copy
| `Stream_draw
| `Stream_read ]
`Static_*, specify once and use many times.`Stream_*, specify once and use once or a few times.`Dynamic_*, specify and use many times.`*_Draw, CPU to GPU.`*_Read, GPU to CPU.`*_Copy, GPU to GPU.val pp_usage : Format.formatter -> usage -> unitpp_usage ppf usage prints an uspecified representation of usage on
ppf.type('a, 'b)init =[ `Cpu of Gg.Ba.scalar_type * int
| `Float16 of (int, Bigarray.int16_unsigned_elt) Gg.bigarray
| `Float32 of (float, Bigarray.float32_elt) Gg.bigarray
| `Float64 of (float, Bigarray.float64_elt) Gg.bigarray
| `Gpu of Gg.Ba.scalar_type * int
| `Int16 of (int, Bigarray.int16_signed_elt) Gg.bigarray
| `Int32 of (int32, Bigarray.int32_elt) Gg.bigarray
| `Int64 of (int64, Bigarray.int64_elt) Gg.bigarray
| `Int8 of (int, Bigarray.int8_signed_elt) Gg.bigarray
| `UInt16 of (int, Bigarray.int16_unsigned_elt) Gg.bigarray
| `UInt32 of (int32, Bigarray.int32_elt) Gg.bigarray
| `UInt64 of (int64, Bigarray.int64_elt) Gg.bigarray
| `UInt8 of (int, Bigarray.int8_unsigned_elt) Gg.bigarray ]
Gg.buffer value, uses the buffer for the CPU side buffer and will
allocate a corresponding buffer on the GPU.`Cpu (st, count), allocates a CPU side buffer of scalar type
st with count scalars and will allocate a corresponding buffer
on the GPU.`Gpu (st, count), allocates no CPU side buffer, will allocate
a GPU buffer of scalar type st with count scalars.typet =Lit.buf
val create : ?cpu_autorelease:bool ->
?usage:usage -> ('a, 'b) init -> Lit.bufcreate cpu_autorelease usage init is a buffer value such that:
init is the buffer initialisation, see Lit.Buf.init.usage, hint specifiying the buffer usage, see Lit.Buf.usage
(defaults to `Static_draw).cpu_autorelease, if true (default) the CPU buffer is
automatically released by setting it to None once
it is uploaded to the GPU buffer.Note that while CPU and GPU buffer length may change, their scalar type is immutable.
At creation time Lit.Buf.gpu_upload is true this means that
the GPU buffer will be automatically created the first time the
buffer is used.
val usage : Lit.buf -> usageusage b is the usage of b.val scalar_type : Lit.buf -> Gg.Ba.scalar_typescalar_type b is the scalar type of b.val pp : Format.formatter -> Lit.buf -> unitpp ppf b prints an unspecified representation of b on ppf.val gpu_count : Lit.buf -> intgpu_count b is the number of scalars in the GPU buffer of b.val gpu_exists : Lit.buf -> boolgpu_exists b is true if the GPU buffer of b exists.val gpu_upload : Lit.buf -> boolgpu_upload b is true if the CPU scalars will uploaded
to the GPU next time the renderer uses the buffer.val set_gpu_upload : Lit.buf -> bool -> unitset_gpu_upload b u if u is true sets b to upload its CPU
buffer to the GPU buffer next time the renderer sees the buffer.
Warning If Lit.Buf.cpu is None at the time of upload this will zero
any existing data on the GPU buffer.
val sync_gpu_to_cpu : Lit.renderer -> Lit.buf -> unitgpu_to_cpu r b reads back b's GPU buffer into b's CPU
buffer. A CPU buffer is created in none existed yet or if the
size of the CPU buffer is different from the size of the GPU
buffer.Invalid_argument if Lit.Buf.gpu_exists is false.val gpu_map : Lit.renderer ->
[ `R | `RW | `W ] ->
Lit.buf -> ('a, 'b) Gg.Ba.ba_scalar_type -> ('a, 'b) Gg.bigarraygpu_map r access b st maps the GPU buffer of b with
access access.
Warning. A mapped buffer cannot be used in a render
operation, you need to unmap it first. Once unmapped the
bigarray becomes invalid. Don't try to access it, it may result
in program termination.
Raises Invalid_argument if st does not match buf's
scalar type.
val gpu_unmap : Lit.renderer -> Lit.buf -> unitgpu_unmap r b unmaps the buffer b.
Warning. This invalidates the memory pointed to
by the bigarray returned by Lit.Buf.gpu_map or gpu_map_buffer, do not
try to access it after this function has been called it may
result in program termination.
val cpu_count : Lit.buf -> intcpu_count b is the number of scalars in the CPU buffer of b.val cpu_exists : Lit.buf -> boolcpu_exists b is true if the CPU buffer of b exists.val cpu : Lit.buf -> ('a, 'b) Gg.Ba.ba_scalar_type -> ('a, 'b) Gg.bigarray optioncpu b st is the CPU buffer of b (if any).
Note. If you want changes you made to the buffer to be picked
up by the GPU side buffer you must call Lit.Buf.set_gpu_upload.
Raises Invalid_argument if scalar type st is not the
scalar type of b.
val cpu_buffer : Lit.buf -> Gg.buffer option
val get_cpu : Lit.buf -> ('a, 'b) Gg.Ba.ba_scalar_type -> ('a, 'b) Gg.bigarrayget_cpu b st is cpu b st but raises if there's no
cpu buffer.Invalid_argument if cpu b st raises or if
cpu_exists b is false.val get_cpu_buffer : Lit.buf -> Gg.buffer
val set_cpu : Lit.buf -> ('a, 'b) Gg.bigarray option -> unitset_cpu b ba sets the CPU buffer of b to ba.
Note. If you want changes to the scalars to be picked
up by the GPU side buffer you must call Lit.Buf.set_gpu_upload.
Raises Invalid_argument if the bigarray kind of b is not compatible
with the scalar type of b.
val set_cpu_buffer : Lit.buf -> Gg.buffer option -> unit
val cpu_autorelease : Lit.buf -> boolcpu_autorelease buf is true if the CPU buffer is set to None
once uploaded to the GPU.val set_cpu_autorelease : Lit.buf -> bool -> unitset_cpu_autorelease b bool sets the autorelease behaviour to bool.val sync_cpu_to_gpu : Lit.renderer -> Lit.buf -> unitsync_cpu_to_gpu r b uploads the CPU buffer of b to the GPU buffer.
A GPU buffer is created if none existed yet.Invalid_argument if Lit.Buf.cpu_exists is false.