with-mapped-buffer-array ( ..a buffer access c-type quot: ( ..a array -- ..b ) -- ..b ) (original) (raw)

with-mapped-buffer-array ( ..a buffer access c-type quot: ( ..a array -- ..b ) -- ..b )
GPU-accelerated rendering » Buffer objects

Prev: with-mapped-buffer ( ..a buffer access quot: ( ..a alien -- ..b ) -- ..b )

Vocabulary
gpu.buffers

Inputs

buffer a buffer
access a buffer-access-mode
c-type a C type
quot a quotation with stack effect ( ..a array -- ..b )

Outputs
None

Word description
Maps buffer into CPU address space with access for the dynamic extent of quot. quot is called with the pointer to the mapped memory wrapped in a specialized array of c-type.

Notes
The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. See the specialized-arrays vocabulary for details on the underlying sequence type constructed.

Definition

USING: alien.c-types alien.data kernel math ;

IN: gpu.buffers

:: with-mapped-buffer-array
( ..a buffer access c-type quot: ( ..a array -- ..b ) -- ..b )
buffer buffer-size c-type heap-size /i :> len buffer access
[ len c-type quot call ] with-mapped-buffer
; inline