Platforms to show: All Mac Windows Linux Cross-Platform

Back to CLCommandQueueMBS class.

Previous items

CLCommandQueueMBS.EnqueueReadBuffer(buffer as CLMemMBS, offset as Integer, size as Integer, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueue commands to read from a buffer object to host memory.

buffer: Refers to a valid buffer object.
BlockingRead: Optional, Indicates if the read operations are blocking or non-blocking. If BlockingRead is true i.e. the read command is blocking, clEnqueueReadBuffer does not return until the buffer data has been read and copied into memory pointed to by ptr.

If BlockingRead is false i.e. the read command is non-blocking, EnqueueReadBuffer queues a non-blocking read command and returns. The contents of the buffer that ptr points to cannot be used until the read command has completed. The event argument returns an event object which can be used to query the execution status of the read command. When the read command has completed, the contents of the buffer that ptr points to can be used by the application.

offset: The offset in bytes in the buffer object to read from.
size: The size in bytes of data being read.
mem: The pointer to buffer in host memory where data is to be read into.

EventWaitList: Optional, specifies events that need to complete before this particular command can be executed. If EventWaitList is empty or not passed, then this particular command does not wait on any event to complete. The events specified in EventWaitList act as synchronization points. The context associated with events in EventWaitList and command_queue must be the same.

outEvent: Optional, Returns an event object that identifies this particular read command and can be used to query or queue a wait for this particular command to complete.

Calling EnqueueReadBuffer to read a region of the buffer object with the ptr argument value set to mem + offset, where mem is a pointer to the memory region specified when the buffer object being read is created with kMemoryUseHostPtr, must meet the following requirements in order to avoid undefined behavior:

All commands that use this buffer object have finished execution before the read command begins execution
The buffer object is not mapped
The buffer object is not used by any command-queue until the read command has finished execution

Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueReadImage(image as CLMemMBS, BlockingRead as boolean, sourceOriginX as Integer, sourceOriginY as Integer, sourceOriginZ as Integer, RegionWidth as Integer, RegionHeight as Integer, RegionDepth as Integer, RowPitch as Integer, SlicePitch as Integer, mem as Memoryblock, EventWaitList() as CLEventMBS, byref outEvent as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to read from a 2D or 3D image object to host memory.

image: Refers to a valid 2D or 3D image object.

BlockingRead: Optional. Indicates if the read operations are blocking or non-blocking.

If BlockingRead is true i.e. the read command is blocking, clEnqueueReadImage does not return until the buffer data has been read and copied into memory pointed to by mem.

If BlockingRead is false i.e. map operation is non-blocking, clEnqueueReadImage queues a non-blocking read command and returns. The contents of the buffer that mem points to cannot be used until the read command has completed. The event argument returns an event object which can be used to query the execution status of the read command. When the read command has completed, the contents of the buffer that mem points to can be used by the application.

origin: Defines the (x, y, z) offset in pixels in the image from where to read. If image is a 2D image object, the z value given by sourceOriginZ must be 0.

region: Defines the (width, height, depth) in pixels of the 2D or 3D rectangle being read. If image is a 2D image object, the depth value given by RegionDepth must be 1.

RowPitch: The length of each row in bytes. This value must be greater than or equal to the element size in bytes * width. If RowPitch is set to 0, the appropriate row pitch is calculated based on the size of each element in bytes multiplied by width.

SlicePitch: Size in bytes of the 2D slice of the 3D region of a 3D image being read. This must be 0 if image is a 2D image. This value must be greater than or equal to RowPitch * height. If SlicePitch is set to 0, the appropriate slice pitch is calculated based on the RowPitch * height.

mem: The pointer to a buffer in host memory where image data is to be read from.

EventWaitList: Optional, Specify events that need to complete before this particular command can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.

outEvent: Optional, Returns an event object that identifies this particular read command and can be used to query or queue a wait for this particular command to complete. event can be nil in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete.

Calling EnqueueReadImage to read a region of the image object with the mem argument value set to HostPtr + (sourceOriginZ * image slice pitch + sourceOriginY * image row pitch + sourceOriginX * bytes per pixel), where host_ptr is a pointer to the memory region specified when the image object being read is created with kMemoryUseHostPtr, must meet the following requirements in order to avoid undefined behavior:

  • All commands that use this image object have finished execution before the read command begins execution.
  • The RowPitch and SlicePitch argument values in EnqueueReadImage must be set to the image row pitch and slice pitch.
  • The image object is not mapped.
  • The image object is not used by any command-queue until the read command has finished execution.

Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueReadImage(image as CLMemMBS, sourceOriginX as Integer, sourceOriginY as Integer, sourceOriginZ as Integer, RegionWidth as Integer, RegionHeight as Integer, RegionDepth as Integer, RowPitch as Integer, SlicePitch as Integer, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to read from a 2D or 3D image object to host memory..

image: Refers to a valid 2D or 3D image object.

BlockingRead: Optional. Indicates if the read operations are blocking or non-blocking.

If BlockingRead is true i.e. the read command is blocking, clEnqueueReadImage does not return until the buffer data has been read and copied into memory pointed to by mem.

If BlockingRead is false i.e. map operation is non-blocking, clEnqueueReadImage queues a non-blocking read command and returns. The contents of the buffer that mem points to cannot be used until the read command has completed. The event argument returns an event object which can be used to query the execution status of the read command. When the read command has completed, the contents of the buffer that mem points to can be used by the application.

origin: Defines the (x, y, z) offset in pixels in the image from where to read. If image is a 2D image object, the z value given by sourceOriginZ must be 0.

region: Defines the (width, height, depth) in pixels of the 2D or 3D rectangle being read. If image is a 2D image object, the depth value given by RegionDepth must be 1.

RowPitch: The length of each row in bytes. This value must be greater than or equal to the element size in bytes * width. If RowPitch is set to 0, the appropriate row pitch is calculated based on the size of each element in bytes multiplied by width.

SlicePitch: Size in bytes of the 2D slice of the 3D region of a 3D image being read. This must be 0 if image is a 2D image. This value must be greater than or equal to RowPitch * height. If SlicePitch is set to 0, the appropriate slice pitch is calculated based on the RowPitch * height.

mem: The pointer to a buffer in host memory where image data is to be read from.

EventWaitList: Optional, Specify events that need to complete before this particular command can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.

outEvent: Optional, Returns an event object that identifies this particular read command and can be used to query or queue a wait for this particular command to complete. event can be nil in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete.

Calling EnqueueReadImage to read a region of the image object with the mem argument value set to HostPtr + (sourceOriginZ * image slice pitch + sourceOriginY * image row pitch + sourceOriginX * bytes per pixel), where host_ptr is a pointer to the memory region specified when the image object being read is created with kMemoryUseHostPtr, must meet the following requirements in order to avoid undefined behavior:

  • All commands that use this image object have finished execution before the read command begins execution.
  • The RowPitch and SlicePitch argument values in EnqueueReadImage must be set to the image row pitch and slice pitch.
  • The image object is not mapped.
  • The image object is not used by any command-queue until the read command has finished execution.

Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueReadPicture(image as CLMemMBS, sourceOriginX as Integer, sourceOriginY as Integer, RegionWidth as Integer, RegionHeight as Integer, pic as picture)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Enqueues a command to read from a 2D or 3D image object to a Xojo picture object.
Example
const size = 500

// create test picture
dim pic1 as Picture = LogoMBS(size)
// create destination picture
dim pic2 as new Picture(size, size, 32)

// get device list
dim devices() as CLDeviceMBS = OpenCLMBS.AllDevices(CLDeviceMBS.kDeviceTypeAll)
dim device as CLDeviceMBS = devices(0)

// Create context for that device
dim c as new CLContextMBS(device)

// query what format Xojo uses for pictures
dim RowPitch as Integer
dim format as CLImageFormatMBS = OpenCLMBS.GetPictureImageFormat(pic1, RowPitch)

// create a matching memory object
dim m as new CLMemMBS(c, CLMemMBS.kMemoryReadWrite, format, size, size, RowPitch)

// create command queue
dim cq as new CLCommandQueueMBS(c, device, 0)

// copy picture content into CLMem object
cq.EnqueueWritePicture(m, 0, 0, size, size, pic1)

// and copy back to second picture
cq.EnqueueReadPicture(m, 0, 0, size, size, pic2)

// finally display it
Backdrop = pic2

image: Refers to a valid 2D or 3D image object.

origin: Defines the (x, y) offset in pixels in the image from where to read.
region: Defines the (width, heigh) in pixels of the 2D or 3D rectangle being read.

pic: The Xojo picture object to write pixel data to.

This command is always blocking.
Lasterror is set.

Some examples using this method:

CLCommandQueueMBS.EnqueueTask(kernel as CLKernelMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to execute a kernel on a device.

kernel: A valid kernel object. The OpenCL context associated with kernel and command_queue must be the same.
EventWaitList: Optional, Specify events that need to complete before this particular command can be executed. If EventWaitList is not passed or empty, then this particular command does not wait on any event to complete. The events specified in EventWaitList act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.
outEvent: Optional, Returns an event object that identifies this particular kernel execution instance. Event objects are unique and can be used to identify a particular kernel execution instance later on.

The kernel is executed using a single work-item.

EnqueueTask is equivalent to calling EnqueueNDRangeKernel with work_dim = 1, global_work_size set to 1, and local_work_size set to 1.
Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueTask(kernel as CLKernelMBS, EventWaitList() as CLEventMBS, byref outEvent as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to execute a kernel on a device.

kernel: A valid kernel object. The OpenCL context associated with kernel and command_queue must be the same.
EventWaitList: Optional, Specify events that need to complete before this particular command can be executed. If EventWaitList is not passed or empty, then this particular command does not wait on any event to complete. The events specified in EventWaitList act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.
outEvent: Optional, Returns an event object that identifies this particular kernel execution instance. Event objects are unique and can be used to identify a particular kernel execution instance later on.

The kernel is executed using a single work-item.

EnqueueTask is equivalent to calling EnqueueNDRangeKernel with work_dim = 1, global_work_size set to 1, and local_work_size set to 1.
Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueUnmapMemObject(buffer as CLMemMBS, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to unmap a previously mapped region of a memory object.

memobj: A valid memory object. The OpenCL context associated with CLCommandQueueMBS and memobj must be the same.

mem: The host address returned by a previous call to EnqueueMapBuffer or EnqueueMapImage for memobj. Do not use this memoryblock after it has been unmapped.

EventWaitList: Optionally, Specify events that need to complete before EnqueueUnmapMemObject can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.

outEvent: Optionally, Returns an event object that identifies this particular copy command and can be used to query or queue a wait for this particular command to complete.

Reads or writes from the host using the pointer returned by EnqueueMapBuffer or EnqueueMapImage are considered to be complete.

EnqueueMapBuffer and EnqueueMapImage increments the mapped count of the memory object. The initial mapped count value of a memory object is zero. Multiple calls to EnqueueMapBuffer or EnqueueMapImage on the same memory object will increment this mapped count by appropriate number of calls. EnqueueUnmapMemObject decrements the mapped count of the memory object.

EnqueueMapBuffer and clEnqueueMapImage act as synchronization points for a region of the memory object being mapped.

See also:

CLCommandQueueMBS.EnqueueUnmapMemObject(buffer as CLMemMBS, mem as Memoryblock, EventWaitList() as CLEventMBS, byref outEvent as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to unmap a previously mapped region of a memory object.

memobj: A valid memory object. The OpenCL context associated with CLCommandQueueMBS and memobj must be the same.

mem: The host address returned by a previous call to EnqueueMapBuffer or EnqueueMapImage for memobj. Do not use this memoryblock after it has been unmapped.

EventWaitList: Optionally, Specify events that need to complete before EnqueueUnmapMemObject can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.

outEvent: Optionally, Returns an event object that identifies this particular copy command and can be used to query or queue a wait for this particular command to complete.

Reads or writes from the host using the pointer returned by EnqueueMapBuffer or EnqueueMapImage are considered to be complete.

EnqueueMapBuffer and EnqueueMapImage increments the mapped count of the memory object. The initial mapped count value of a memory object is zero. Multiple calls to EnqueueMapBuffer or EnqueueMapImage on the same memory object will increment this mapped count by appropriate number of calls. EnqueueUnmapMemObject decrements the mapped count of the memory object.

EnqueueMapBuffer and clEnqueueMapImage act as synchronization points for a region of the memory object being mapped.

See also:

CLCommandQueueMBS.EnqueueWaitForEvents(EventWaitList() as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a wait for a specific event or a list of events to complete before any future commands queued in the command-queue are executed.

EventWaitList: Events specified in EventWaitList act as synchronization points.

The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.

Lasterror is set.

CLCommandQueueMBS.EnqueueWriteBuffer(buffer as CLMemMBS, BlockingWrite as boolean, offset as Integer, size as Integer, mem as Memoryblock, EventWaitList() as CLEventMBS, byref outEvent as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueue commands to write to a buffer object from host memory.

buffer: Refers to a valid buffer object.
BlockingWrite: Optional, Indicates if the write operations are blocking or nonblocking.

If blocking_write is true, the OpenCL implementation copies the data referred to by mem and enqueues the write operation in the command-queue. The memory pointed to by mem can be reused by the application after the EnqueueWriteBuffer call returns.

If blocking_write is false, the OpenCL implementation will use mem to perform a nonblocking write. As the write is non-blocking the implementation can return immediately. The memory pointed to by mem cannot be reused by the application after the call returns. The event argument returns an event object which can be used to query the execution status of the write command. When the write command has completed, the memory pointed to by mem can then be reused by the application.

offset: The offset in bytes in the buffer object to write to.
size: The size in bytes of data being written.
mem: The pointer to buffer in host memory where data is to be written from.

EventWaitList: Optional. Specifies events that need to complete before this particular command can be executed. If EventWaitList is empty or not passed, then this particular command does not wait on any event to complete. The events specified in EventWaitList act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.

outEvent: Optional. Returns an event object that identifies this particular write command and can be used to query or queue a wait for this particular command to complete.

Calling EnqueueWriteBuffer to update the latest bits in a region of the buffer object with the mem argument value set to host_ptr + offset, where host_ptr is a pointer to the memory region specified when the buffer object being written is created with CL_MEM_USE_HOST_PTR, must meet the following requirements in order to avoid undefined behavior:

The host memory region given by (mem + offset, size) contains the latest bits when the enqueued write command begins execution.
The buffer object is not mapped.
The buffer object is not used by any command-queue until the write command has finished execution.

Lasterror is set.

See also:

Some examples using this method:

CLCommandQueueMBS.EnqueueWriteBuffer(buffer as CLMemMBS, offset as Integer, size as Integer, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueue commands to write to a buffer object from host memory.

buffer: Refers to a valid buffer object.
BlockingWrite: Optional, Indicates if the write operations are blocking or nonblocking.

If blocking_write is true, the OpenCL implementation copies the data referred to by mem and enqueues the write operation in the command-queue. The memory pointed to by mem can be reused by the application after the EnqueueWriteBuffer call returns.

If blocking_write is false, the OpenCL implementation will use mem to perform a nonblocking write. As the write is non-blocking the implementation can return immediately. The memory pointed to by mem cannot be reused by the application after the call returns. The event argument returns an event object which can be used to query the execution status of the write command. When the write command has completed, the memory pointed to by mem can then be reused by the application.

offset: The offset in bytes in the buffer object to write to.
size: The size in bytes of data being written.
mem: The pointer to buffer in host memory where data is to be written from.

EventWaitList: Optional. Specifies events that need to complete before this particular command can be executed. If EventWaitList is empty or not passed, then this particular command does not wait on any event to complete. The events specified in EventWaitList act as synchronization points. The context associated with events in EventWaitList and CLCommandQueueMBS must be the same.

outEvent: Optional. Returns an event object that identifies this particular write command and can be used to query or queue a wait for this particular command to complete.

Calling EnqueueWriteBuffer to update the latest bits in a region of the buffer object with the mem argument value set to host_ptr + offset, where host_ptr is a pointer to the memory region specified when the buffer object being written is created with CL_MEM_USE_HOST_PTR, must meet the following requirements in order to avoid undefined behavior:

The host memory region given by (mem + offset, size) contains the latest bits when the enqueued write command begins execution.
The buffer object is not mapped.
The buffer object is not used by any command-queue until the write command has finished execution.

Lasterror is set.

See also:

CLCommandQueueMBS.EnqueueWriteImage(image as CLMemMBS, BlockingWrite as boolean, sourceOriginX as Integer, sourceOriginY as Integer, sourceOriginZ as Integer, RegionWidth as Integer, RegionHeight as Integer, RegionDepth as Integer, RowPitch as Integer, SlicePitch as Integer, mem as Memoryblock, EventWaitList() as CLEventMBS, byref outEvent as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to write from a 2D or 3D image object to host memory.

image: Refers to a valid 2D or 3D image object.

BlockingWrite: Optional. Indicates if the write operation is blocking or non-blocking.

If BlockingWrite is true the OpenCL implementation copies the data referred to by mem and enqueues the write command in the command-queue. The memory pointed to by mem can be reused by the application after the clEnqueueWriteImage call returns. If BlockingWrite is false the OpenCL implementation will use mem to perform a nonblocking write. As the write is non-blocking the implementation can return immediately. The memory pointed to by mem cannot be reused by the application after the call returns. The event argument returns an event object which can be used to query the execution status of the write command. When the write command has completed, the memory pointed to by mem can then be reused by the application.

origin: Defines the (x, y, z) offset in pixels in the image from where to write or write. If image is a 2D image object, the z value given by sourceOriginZ must be 0.

region: Defines the (width, height, depth) in pixels of the 2D or 3D rectangle being write or written. If image is a 2D image object, the depth value given by RegionDepth must be 1.

RowPitch
The length of each row in bytes. This value must be greater than or equal to the element size in bytes * width. If RowPitch is set to 0, the appropriate row pitch is calculated based on the size of each element in bytes multiplied by width.

RowPitch: Size in bytes of the 2D slice of the 3D region of a 3D image being written. This must be 0 if image is a 2D image. This value must be greater than or equal to RowPitch * height. If SlicePitch is set to 0, the appropriate slice pitch is calculated based on the RowPitch * height.

mem: The pointer to a buffer in host memory where image data is to be written to.

EventWaitList: Optional. Specify events that need to complete before this particular command can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.

outEvent: Optional. Returns an event object that identifies this particular write command and can be used to query or queue a wait for this particular command to complete.

Calling EnqueueWriteImage to update the latest bits in a region of the image object with the mem argument value set to mem + (sourceOriginZ * image slice pitch + sourceOriginY * image row pitch + sourceOriginX * bytes per pixel), where mem is a pointer to the memory region specified when the image object being written is created with kMemoryUseHostPtr, must meet the following requirements in order to avoid undefined behavior:

  • The host memory region being written contains the latest bits when the enqueued write command begins execution.
  • The RowPitch and SlicePitch argument values in EnqueueWriteImage must be set to the image row pitch and slice pitch.
  • The image object is not mapped.
  • The image object is not used by any command-queue until the write command has finished execution.

See also:

CLCommandQueueMBS.EnqueueWriteImage(image as CLMemMBS,sourceOriginX as Integer, sourceOriginY as Integer, sourceOriginZ as Integer, RegionWidth as Integer, RegionHeight as Integer, RegionDepth as Integer, RowPitch as Integer, SlicePitch as Integer, mem as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Enqueues a command to write from a 2D or 3D image object to host memory.

image: Refers to a valid 2D or 3D image object.

BlockingWrite: Optional. Indicates if the write operation is blocking or non-blocking.

If BlockingWrite is true the OpenCL implementation copies the data referred to by mem and enqueues the write command in the command-queue. The memory pointed to by mem can be reused by the application after the clEnqueueWriteImage call returns. If BlockingWrite is false the OpenCL implementation will use mem to perform a nonblocking write. As the write is non-blocking the implementation can return immediately. The memory pointed to by mem cannot be reused by the application after the call returns. The event argument returns an event object which can be used to query the execution status of the write command. When the write command has completed, the memory pointed to by mem can then be reused by the application.

origin: Defines the (x, y, z) offset in pixels in the image from where to write or write. If image is a 2D image object, the z value given by sourceOriginZ must be 0.

region: Defines the (width, height, depth) in pixels of the 2D or 3D rectangle being write or written. If image is a 2D image object, the depth value given by RegionDepth must be 1.

RowPitch
The length of each row in bytes. This value must be greater than or equal to the element size in bytes * width. If RowPitch is set to 0, the appropriate row pitch is calculated based on the size of each element in bytes multiplied by width.

RowPitch: Size in bytes of the 2D slice of the 3D region of a 3D image being written. This must be 0 if image is a 2D image. This value must be greater than or equal to RowPitch * height. If SlicePitch is set to 0, the appropriate slice pitch is calculated based on the RowPitch * height.

mem: The pointer to a buffer in host memory where image data is to be written to.

EventWaitList: Optional. Specify events that need to complete before this particular command can be executed. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.

outEvent: Optional. Returns an event object that identifies this particular write command and can be used to query or queue a wait for this particular command to complete.

Calling EnqueueWriteImage to update the latest bits in a region of the image object with the mem argument value set to mem + (sourceOriginZ * image slice pitch + sourceOriginY * image row pitch + sourceOriginX * bytes per pixel), where mem is a pointer to the memory region specified when the image object being written is created with kMemoryUseHostPtr, must meet the following requirements in order to avoid undefined behavior:

  • The host memory region being written contains the latest bits when the enqueued write command begins execution.
  • The RowPitch and SlicePitch argument values in EnqueueWriteImage must be set to the image row pitch and slice pitch.
  • The image object is not mapped.
  • The image object is not used by any command-queue until the write command has finished execution.

See also:

CLCommandQueueMBS.EnqueueWritePicture(image as CLMemMBS, sourceOriginX as Integer, sourceOriginY as Integer, RegionWidth as Integer, RegionHeight as Integer, pic as picture)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Enqueues a command to write from a 2D or 3D image object to a Xojo Picture.
Example
const size = 500

// create test picture
dim pic1 as Picture = LogoMBS(size)
// create destination picture
dim pic2 as new Picture(size, size, 32)

// get device list
dim devices() as CLDeviceMBS = OpenCLMBS.AllDevices(CLDeviceMBS.kDeviceTypeAll)
dim device as CLDeviceMBS = devices(0)

// Create context for that device
dim c as new CLContextMBS(device)

// query what format Xojo uses for pictures
dim RowPitch as Integer
dim format as CLImageFormatMBS = OpenCLMBS.GetPictureImageFormat(pic1, RowPitch)

// create a matching memory object
dim m as new CLMemMBS(c, CLMemMBS.kMemoryReadWrite, format, size, size, RowPitch)

// create command queue
dim cq as new CLCommandQueueMBS(c, device, 0)

// copy picture content into CLMem object
cq.EnqueueWritePicture(m, 0, 0, size, size, pic1)

// and copy back to second picture
cq.EnqueueReadPicture(m, 0, 0, size, size, pic2)

// finally display it
Backdrop = pic2

image: Refers to a valid 2D or 3D image object.

BlockingWrite: Optional. Indicates if the write operation is blocking or non-blocking.

origin: Defines the (x, y) offset in pixels in the image from where to write or write.

region: Defines the (width, height) in pixels of the 2D or 3D rectangle being write or written.

pic: The target Xojo picture object. This must match in the image format for the image object and the size you specified in region.

This operation is always performed blocked.
Lasterror is set.

Some examples using this method:

CLCommandQueueMBS.Finish

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Blocks until all previously queued OpenCL commands in a command-queue are issued to the associated device and have completed.

Blocks until all previously queued OpenCL commands in command_queue are issued to the associated device and have completed.

Finish does not return until all queued commands in command_queue have been processed and completed. clFinish is also a synchronization point.

Lasterror is set.

CLCommandQueueMBS.Flush

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Issues all previously queued OpenCL commands in a command-queue to the device associated with the command-queue.

Issues all previously queued OpenCL commands in command_queue to the device associated with command_queue.

Flush only guarantees that all queued commands to command_queue get issued to the appropriate device. There is no guarantee that they will be complete after Flush returns.

Lasterror is set.

Any blocking commands queued in a command-queue such as EnqueueReadImage or EnqueueReadBuffer with BlockingRead set to true, EnqueueWriteImage or EnqueueWriteBuffer with BlockingWrite set to true, EnqueueMapImage or EnqueueMapBuffer with BlockingMap set to true or WaitForEvents perform an implicit flush of the command-queue.

To use event objects that refer to commands enqueued in a command-queue as event objects to wait on by commands enqueued in a different command-queue, the application must call a Flush or any blocking commands that perform an implicit flush of the command-queue where the commands that refer to these event objects are enqueued.
Lasterror is set.

CLCommandQueueMBS.Properties as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return the currently specified properties for the command-queue.

Lasterror is set.

CLCommandQueueMBS.ReferenceCount as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return the command-queue reference count.

Lasterror is set.

Previous items

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...