Example of TextureRanges

nabobnick
Unregistered
 
Post: #1
I'm having trouble with the concept of the glTextureRangeAPPLE extension. I know I'm missing something simple and need a concrete example to trigger the "Oh, now I see!" response.

In my understanding you use glTextureRange to effectively create an array of textures. What I don't understand is how you use anything but the first texture in the array. How do you use the other textures stored in the range and what is gained from this setup? Some short examples would be extremely helpful.

Thanks!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
TextureRange lets you say to the GL, "here's a big blob of memory, I'm gonna put (some of) my texture images in there". The GL can then do funky things with that memory, including making it very efficient to copy data from that block of memory to the graphics card, and very efficient to copy texture images from the graphics card to that block of memory. The precise usage you ask of the texture range will determine precisely what happens.
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #3
It mirrors the Vertex Array Range usage. You allocate say, 8 megs of memory. Then it's up to you what you do with it. It could be one big 8 meg texture, or four 2 megs textures in sequence. You just pass pointers to the start of a texture normally with glTex(Sub)Image, the only difference is how GL copies the data.

If you specify GL_STORAGE_CACHED_APPLE, the GPU pulls the texture up via DMA (no CPU cost) and caches it in VRAM as needed.

If you specify GL_STORAGE_SHARED_APPLE, it doesn't copy at all, and the GPU textures directly from AGP. This makes texture animation (movies, etc) very fast, but now of course there is the potential problem of corrupting your texture as the GPU is using it; see my posts in the Airbust Extreme thread.

Using texture range supposes usage of client storage, and preferably rectangle textures. The texture range sample code shows usage. One thing to point out which is NOT mentioned in that code is that in order to get DMA transfers, the rowbytes of the texture must be a multiple of 32. That is, a multiple of 8 pixels for 32-bit ARGB textures. If your texture has an odd size like 511 pixels wide, then DMA will be disabled; it will fall back to regular GL_STORAGE_PRIVATE_APPLE. You can pad your textures to force AGP DMA (I do this in my comic book viewer.)
Quote this message in a reply
Post Reply