1
votes

As we all know, OpenGL and many image/video formats differ in the origin of the pixel data. So when we draw an image (especially a live image from a camera) using OpenGL, we have the following options.

  1. Flip the image (on CPU) then upload to GPU, draw normally.
  2. Upload directly to GPU and draw using flipped texture coordinates

Now, I don't want to flip the image because it is not free (processing cost) and we may need to do one of the following in case we continue using the image on CPU:

  • Allocate new image buffer -> flip to this new buffer -> upload to GPU -> release new buffer
  • Flip image in-place -> upload to GPU -> flip in-place back again

Both uses extra memory and processing power. (I know new buffer in the first case can be allocated once. Still it consumes memory and flipping is done on CPU.)

So I understand we should use approach (2) above and be extremely careful about flipping texture coordinates correctly. I keep hearing this is the faster approach, however, what no one touching is how fast the GPU will access the textures when we give flipped texture coordinates. Nowadays, many computers (laptops) have integrated GPU which uses the system memory. Wouldn't the texture lookup speed be affected by the way we give texture coordinates?

In summary, my question boils down to this: would texture look-up and filtering speed change depending on the actual layout of the texture in GPU memory? I would like to know this both for dedicated GPUs like nvidia, and integrated GPUs like intels.

PS: This is purely for educational purposes, I realize knowing the answer to this question won't matter much for the application performance, but it's always good to have some inner knowledge. Also I'm curious :)

1
First of all, don't make assumptions on this stuff when using OpenGL. I don't see any reason not to apply common sense here (e.g. try to be cache friendly, try to minimize bandwidth usage), but I would never state that a particular piece of GLSL will execute exactly the same on all supporting hardware. Second, you don't give nearly enough information as to how performance critical your application is and what kinds of processing you're doing on your textures. If you cannot reason about complexity, why would you even start with a presumed impact of flipping tex coords? - thokra
This is not exactly about my application. (2) is faster in all cases anyways, I'm not trying to make it even faster. This was more for the educational purposes. I'm editing the question to state this, thanks. - Sept

1 Answers

3
votes

The TL/DR answer is: No, there would be no perceptible speed change whatsoever.

GPUs, regardless of their origin (NV, AMD, Intel — whoever the manufacturer is), are just designed that way. Texture maps are ubiquitous in modern 3D graphics, so if a GPU can`t cope with affine texture transformations then it`s a bad and unmarketable GPU.