Jacko
Jacko

Reputation: 13195

What is the advantage of using a 1d image over a 1d buffer?

I understand that in 2d, images are cached in x and y directions.

But in 1d, why would you want to use an image? Is the memory used for images faster than memory used for buffers?

Upvotes: 0

Views: 728

Answers (1)

Roman Arzumanyan
Roman Arzumanyan

Reputation: 1814

1D Image stays the image, so it has all advantages that Image has against Buffer. That is:

  1. Image IO operations are usually well-cached.
  2. Samplers can be used, which gives benefits like computationally cheap interpolation, hardware-resolved out-ouf-bound access, etc.

Though, you should remember that Image has some constraints in comparison to regular Buffer:

  1. Single Image can be used either for reading or for writing within one kernel.
  2. You can't use vloadN / vstoreN operations, which can handle up to 16 values per call. Your best option is read_imageX & write_imageX functions, which can load / store up to 4 values per one call. That can be serious issue on GPU, with vector architecture.
  3. If you are not using 4-component format, usually, you are loosing part of performance as many functions process samples from color planes simultaneously. So, payload is decreasing.

If we talk about GPU, different parts of hardware are involved into processing of Images & Buffers, so it's difficult to draw up, how one is better than another. Carefull benchmarking & algorithm optimizations are needed.

Upvotes: 3

Related Questions