pub struct Image<T: OclPrm> { /* private fields */ }
Expand description
A section of device memory which represents one or many images.
Use ::builder
for an easy way to create. [UNIMPLEMENTED]
Implementations§
source§impl<T: OclPrm> Image<T>
impl<T: OclPrm> Image<T>
sourcepub fn supported_formats(
context: &Context,
flags: MemFlags,
mem_obj_type: MemObjectType
) -> OclResult<Vec<ImageFormatParseResult>>
pub fn supported_formats( context: &Context, flags: MemFlags, mem_obj_type: MemObjectType ) -> OclResult<Vec<ImageFormatParseResult>>
Returns a list of supported image formats.
sourcepub fn builder<'a>() -> ImageBuilder<'a, T>
pub fn builder<'a>() -> ImageBuilder<'a, T>
Returns an ImageBuilder
. This is the recommended method to create
a new Image
.
sourcepub unsafe fn new<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_format: ImageFormat,
image_desc: ImageDescriptor,
host_data: Option<&[T]>
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
pub unsafe fn new<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_format: ImageFormat,
image_desc: ImageDescriptor,
host_data: Option<&[T]>
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
Returns a new Image
.
Prefer ::builder
to create a new image.
sourcepub fn from_gl_texture<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture_target: GlTextureTarget,
miplevel: cl_GLint,
texture: cl_GLuint
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
pub fn from_gl_texture<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture_target: GlTextureTarget,
miplevel: cl_GLint,
texture: cl_GLuint
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
Returns a new Image
from an existant GL texture2D/3D.
Remember to specify the GL context when creating the CL context,
using .properties(ocl_interop::get_properties_list())
Don’t forget to .cmd().gl_acquire().enq()
before using it and
.cmd().gl_release().enq()
after.
sourcepub fn from_gl_renderbuffer<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
renderbuffer: cl_GLuint
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
pub fn from_gl_renderbuffer<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
renderbuffer: cl_GLuint
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
Returns a new Image
from an existant renderbuffer.
Remember to specify the GL context when creating the CL context,
using .properties(ocl_interop::get_properties_list())
Don’t forget to .cmd().gl_acquire().enq()
before using it and
.cmd().gl_release().enq()
after.
sourcepub fn from_d3d11_texture2d<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture: cl_id3d11_texture2d,
subresource: u32
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
pub fn from_d3d11_texture2d<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture: cl_id3d11_texture2d,
subresource: u32
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
Returns a new Image
from an existant ID3D11Texture2D.
Remember to specify the D3D11 device when creating the CL context,
using .properties()
and .set_property_value(ContextPropertyValue::D3d11DeviceKhr(<pointer to ID3D11Device>))
Don’t forget to .cmd().d3d11_acquire().enq()
before using it and
.cmd().d3d11_release().enq()
after.
sourcepub fn from_d3d11_texture3d<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture: cl_id3d11_texture3d,
subresource: u32
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
pub fn from_d3d11_texture3d<'o, Q>(
que_ctx: Q,
flags: MemFlags,
image_desc: ImageDescriptor,
texture: cl_id3d11_texture3d,
subresource: u32
) -> OclResult<Image<T>>where
Q: Into<QueCtx<'o>>,
Returns a new Image
from an existant ID3D11Texture2D.
Remember to specify the D3D11 device when creating the CL context,
using .properties()
and .set_property_value(ContextPropertyValue::D3d11DeviceKhr(<pointer to ID3D11Device>))
Don’t forget to .cmd().d3d11_acquire().enq()
before using it and
.cmd().d3d11_release().enq()
after.
sourcepub fn cmd(&self) -> ImageCmd<'_, T>
pub fn cmd(&self) -> ImageCmd<'_, T>
Returns an image command builder used to read, write, copy, etc.
Call .enq()
to enqueue the command.
See the command builder documentation for more details.
sourcepub fn read<'c, 'd>(&'c self, data: &'d mut [T]) -> ImageCmd<'c, T>where
'd: 'c,
pub fn read<'c, 'd>(&'c self, data: &'d mut [T]) -> ImageCmd<'c, T>where
'd: 'c,
Returns an image command builder set to read.
Call .enq()
to enqueue the command.
See the command builder documentation for more details.
sourcepub fn write<'c, 'd>(&'c self, data: &'d [T]) -> ImageCmd<'c, T>where
'd: 'c,
pub fn write<'c, 'd>(&'c self, data: &'d [T]) -> ImageCmd<'c, T>where
'd: 'c,
Returns an image command builder set to write.
Call .enq()
to enqueue the command.
See the command builder documentation for more details.
sourcepub unsafe fn map<'c>(&'c self) -> ImageMapCmd<'c, T>
pub unsafe fn map<'c>(&'c self) -> ImageMapCmd<'c, T>
Returns a command builder used to map data for reading or writing.
Call .enq()
to enqueue the command.
§Safety
The caller must ensure that only one mapping of a particular memory region exists at a time.
See the command builder documentation for more details.
sourcepub fn set_default_queue<'a>(&'a mut self, queue: Queue) -> &'a mut Image<T>
pub fn set_default_queue<'a>(&'a mut self, queue: Queue) -> &'a mut Image<T>
Changes the default queue.
Returns a ref for chaining i.e.:
image.set_default_queue(queue).write(....);
[NOTE]: Even when used as above, the queue is changed permanently, not just for the one call. Changing the queue is cheap so feel free to change as often as needed.
The new queue must be associated with a valid device.
sourcepub fn default_queue(&self) -> Option<&Queue>
pub fn default_queue(&self) -> Option<&Queue>
Returns a reference to the default queue.
sourcepub fn dims(&self) -> &SpatialDims
pub fn dims(&self) -> &SpatialDims
Returns this image’s dimensions.
sourcepub fn pixel_count(&self) -> usize
pub fn pixel_count(&self) -> usize
Returns the total number of pixels in this image.
sourcepub fn pixel_element_len(&self) -> usize
pub fn pixel_element_len(&self) -> usize
Returns the length of each pixel element.
sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Returns the total number of pixel elements in this image. Equivalent to its length.
sourcepub fn info(&self, info_kind: ImageInfo) -> OclResult<ImageInfoResult>
pub fn info(&self, info_kind: ImageInfo) -> OclResult<ImageInfoResult>
Get information about this image.
sourcepub fn mem_info(&self, info_kind: MemInfo) -> OclResult<MemInfoResult>
pub fn mem_info(&self, info_kind: MemInfo) -> OclResult<MemInfoResult>
Returns info about this image’s memory.