Using a shader lets you take advantage of the processing power of the graphics card processing unit (GPU) instead of relying solely on the system CPU. Also, the GPU can operate on multiple data streams simultaneously. For example, some GPUs can execute a fragment shader on up to 24 fragments (pixels) simultaneously, which provides a significant performance advantage over a CPU which can only process one pixel at a time.
As an example, a typical image processing application may apply several operations to a set of images, store the results in an IDLgrImage object, then displays the image. The figure below illustrates this process. The application performs several image operations, creating intermediate images that may be reused. This process requires a significant amount of computation and data movement before the final image is copied into the image object and the graphic device’s texture memory. Additionally, all or most of this process must be repeated any time the parameters of an operation change, reducing interactive performance.
If we move the same image processing application to a shader program, IDL accomplishes the majority of the processing cycle on the graphics card.
Without a shader program and suitable hardware, updating an image may require several tenths of a second or more. Noticeable display updates may occur with CPU processing.
With a shader program, the display rate with the same amount of processing can be hundreds of frames per second. Display updates will be smooth with GPU processing. Display rates of hundreds of frames per second are not always useful, but when lower rates are used, more CPU resources are available for other operations.