Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Order of Texture Binding

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2

    Question Order of Texture Binding

    Hi,

    Hopefully a quick question!

    I am writing a large-ish number of quads to the screen (say 10000) from a pool of about 15 different textures. As the code loops across the screen it binds and then displays the appropriate texture, each in turn. My question is -> Would there be any performance benefit to writing all of one type of texture first before writing a second? The cost would be in the numerous (*15) passes of the display loop and if statements, but the benefit (?) would be in binding a maximum of 15 times instead of 10,000?

    Regardless of the textures displayed, they are varied with glColor3f().

    Many thanks for reading.

    Dan

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,190
    It depends on what your bottleneck(s) is on your specific hardware and OpenGL driver.

    Assuming the distribution of textures across your quads is fairly uniform, then binding 15 times is likely to be faster than binding 10,000 times. It's the same number of quads and approximately the same amount of fill and CPU work given the same quad submission approach.

    However, you're talking about efficiency, but yet you say you're using immediate mode (e.g. glColor3f). Immediate mode alone is in competition with performance. You can put in a display list to help, or better you can put a bunch of quads in a vertex array or VBO and launch them all at once in a single batch (that cuts down on a lot of CPU work submitting quads). If you're fill bound and your quads are opaque, consider rendering them front-to-back and/or do a depth-only pass first.

  3. #3
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2
    Many thanks Dark Photon! Lots there to think about.

    I am using glColor3f to alter the shade of a texture. I'll see if rendering the different shades of textures upfront makes a difference.
    As for display lists, I didn't use them because I thought they were deprecated?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,190
    Quote Originally Posted by BoundRed View Post
    As for display lists, I didn't use them because I thought they were deprecated?
    Not deprecated, removed from the core profile. Immediate mode is in the same boat though.

    The key question you have to answer is are you going to target the core profile or the compatibility profile. In the latest core profile, these are both gone. In the compatibility profile, you can still use them both.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •