![]() |
Mali OpenCL SDK v1.1.0
|
An overview of OpenCL image objects including sample code.
Textures (images) are a huge part of modern graphics applications. As such, graphics hardware has developed to allow high perfomance access and operations on textures.
To make use of this specialised hardware, OpenCL includes an optional image data type. These 'images objects' are supported on all Mali-T600 series GPUs.
Images represent large grids of data which can be processed in parallel. As such, image data and image operations are usually a good fit for accelerating in OpenCL.
Images data can be stored/manipulated by OpenCL in two ways; buffers and images.
Memory buffers are just plain arrays of data.
Because they are suitable for all forms of data (e.g. images, grids, linear arrays, etc.), various image operations are difficult:
Image objects are a specialist memory type which makes it easier to work with image data. Image objects:
Whether to use image objects or not depends on the application. You should take the following considerations into account:
When using image objects, only 1 pixel can be processed per cycle. Using buffers, if your image format is less than 32-bits per channel you can process multiple pixels per cycle.
For example, if the image format is RGBA8888 (each pixel is 32-bits), using buffers, you can vectorize the algorithm to operate on 4 pixels at once (32-bits * 4 pixels = 128-bits, the recommended vector width for Mali-T600 series GPUs.) But with image objects the speed is fixed at one pixel per cycle.
If the format is 32-bits per channel or greater, this advantage of image objects is lost because only one pixel can be processed per cycle using either method. For example, if the image format is RGBA32 (each pixel is 128-bits), only 1 pixel can be processed per cycle because 1 pixel fills the recommended vector width.
For more information about vectorization, see Vectorizing your OpenCL code.
In more complex cases, maximum performance comes from balancing load across the system. On Mali-T600 series GPUS, image objects use the Texture pipeline which is seperate from the Load/Store and Arithmetic pipelines. As such, it might be beneficial to use both image objects and buffers in order to make maximum use of the system.
For example, loading input images with image objects and then loading the data to alter the images in memory buffers (e.g. a convolution filter).
How to resize an image using OpenCL image objects.