Struct ocl::Buffer[][src]

pub struct Buffer<T: OclPrm> { /* fields omitted */ }

A chunk of memory physically located on a device, such as a GPU.

Data is stored remotely in a memory buffer on the device associated with queue.

Methods

impl<T: OclPrm> Buffer<T>
[src]

Returns a new buffer builder.

This is the preferred (and forward compatible) way to create a buffer.

Creates a new buffer.

[UNSTABLE]: Arguments may still be in a state of flux. It is recommended to use ::builder instead.

See the BufferBuilder and SDK documentation for argument details.

Safety

Incorrectly using flags and/or host_slice is unsafe.

Creates a buffer linked to a previously created OpenGL buffer object.

[UNTESTED]

Errors

Don't forget to .cmd().gl_acquire().enq() before using it and .cmd().gl_release().enq() after.

See the BufferCmd docs for more info.

Returns a command builder used to read, write, copy, etc.

Call .enq() to enqueue the command.

See the command builder documentation for more details.

Returns a command builder used to read data.

Call .enq() to enqueue the command.

See the command builder documentation for more details.

Returns a command builder used to write data.

Call .enq() to enqueue the command.

See the command builder documentation for more details.

Returns a command builder used to map data for reading or writing.

Enqueuing a map command will map a region of a buffer into the host address space and return a MemMap or FutureMemMap, allowing access to this mapped region. Accessing memory via a MemMap is exactly like using a slice.

Call .enq() to enqueue the command.

More Information

See the command builder documentation or official SDK for more details.

Specifies that this command will be a copy operation.

Call .enq() to enqueue the command.

See the command builder documentation for more details.

Returns the offset of the sub-buffer within its buffer if this is a sub-buffer.

Returns the length of the buffer.

Returns true if this is a sub-buffer.

Returns info about the underlying memory object.

Changes the default queue used by this buffer for all subsequent command enqueue operations (reads, writes, etc.).

The default queue is the queue which will be used when enqueuing commands if no queue is specified.

Without a default queue:

This example is not tested
buffer.read(data).queue(&queue).enq()?;

With a default queue:

This example is not tested
buffer.set_default_queue(queue.clone());
buffer.read(data).enq()?;

The default queue can also be set when creating a buffer by using the BufferBuilder::queue method.

This method returns a mutable reference for optional chaining i.e.:

This example is not tested
buffer.set_default_queue(queue).read(....)...;

Returns a reference to the default queue.

The default queue is the queue which will be used when enqueuing commands if no queue is specified.

Returns a reference to the core pointer wrapper, usable by functions in the core module.

Returns the memory flags used during the creation of this buffer.

Creates a new sub-buffer from a region of this buffer.

Flags (adapted from SDK)

[NOTE]: Flags described below can be found in the ocl::flags module or within the MemFlags type (example: [MemFlags::new().read_write()]).

flags: A bit-field that is used to specify allocation and usage information about the sub-buffer memory object being created and is described in the table below. If the MEM_READ_WRITE, MEM_READ_ONLY or MEM_WRITE_ONLY values are not specified in flags, they are inherited from the corresponding memory access qualifers associated with buffer. The MEM_USE_HOST_PTR, MEM_ALLOC_HOST_PTR and MEM_COPY_HOST_PTR values cannot be specified in flags but are inherited from the corresponding memory access qualifiers associated with buffer. If MEM_COPY_HOST_PTR is specified in the memory access qualifier values associated with buffer it does not imply any additional copies when the sub-buffer is created from buffer. If the MEM_HOST_WRITE_ONLY, MEM_HOST_READ_ONLY or MEM_HOST_NO_ACCESS values are not specified in flags, they are inherited from the corresponding memory access qualifiers associated with buffer.

Offset and Dimensions

offset and len set up the region of the sub-buffer within the original buffer and must not fall beyond the boundaries of it.

offset must be a multiple of the DeviceInfo::MemBaseAddrAlign otherwise you will get a CL_MISALIGNED_SUB_BUFFER_OFFSET error. To determine, use Device::mem_base_addr_align for the device associated with the queue which will be use with this sub-buffer.

[MemFlags::new().read_write()] flags/struct.MemFlags.html#method.read_write

Methods from Deref<Target = MemCore>

Returns a pointer, do not store it.

Trait Implementations

impl<T: Debug + OclPrm> Debug for Buffer<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Clone + OclPrm> Clone for Buffer<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: OclPrm> Deref for Buffer<T>
[src]

The resulting type after dereferencing.

Dereferences the value.

impl<T: OclPrm> DerefMut for Buffer<T>
[src]

Mutably dereferences the value.

impl<T: OclPrm> AsRef<MemCore> for Buffer<T>
[src]

Performs the conversion.

impl<T: OclPrm> AsMut<MemCore> for Buffer<T>
[src]

Performs the conversion.

impl<T: OclPrm> AsMem<T> for Buffer<T>
[src]

impl<T: OclPrm> Display for Buffer<T>
[src]

Formats the value using the given formatter. Read more

impl<'a, T> MemCmdRw for Buffer<T> where
    T: OclPrm
[src]

impl<'a, T> MemCmdRw for &'a Buffer<T> where
    T: OclPrm
[src]

impl<'a, T> MemCmdRw for &'a mut Buffer<T> where
    T: OclPrm
[src]

impl<'a, T> MemCmdAll for Buffer<T> where
    T: OclPrm
[src]

impl<'a, T> MemCmdAll for &'a Buffer<T> where
    T: OclPrm
[src]

impl<'a, T> MemCmdAll for &'a mut Buffer<T> where
    T: OclPrm
[src]

Auto Trait Implementations

impl<T> Send for Buffer<T>

impl<T> Sync for Buffer<T>