Chapter 6. Image processing
This chapter covers
Memory objects package data sent between a host and a device, and as discussed in chapter 3, they come in two types: buffer objects and image objects. Buffer objects transfer general-purpose data, and so far, all of the example code in this book has relied exclusively on buffer objects.
Now we’re going to switch gears and focus on image objects. In theory, you could store an image’s data in a buffer object and access its pixels as regular buffer data. But there are four important reasons to use image objects instead:
- On GPUs, image data is stored in special global memory called texture memory. Unlike regular global memory, texture memory is cached for rapid access.
- The functions used to read and write image data can be invoked without regard to how the pixel data is formatted, so long as the format is supported by OpenCL.
- Special data structures called samplers make it possible to configure how color information is read from an image.
- OpenCL provides functions that return image-specific information, such as an image’s dimensions, pixel format, and bit depth.