Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: opengl redundant calls

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Location
    Poland
    Posts
    26

    opengl redundant calls

    Hi. Does OpenGL ignore redundant state changes? For example, does using glUseProgram(1); glUseProgram(1); hurt the application same as glUseProgram(1); glUseProgram(2); ?

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: opengl redundant calls

    Yes OpenGL implementations should change states if it not necessary. But since all drivers are not perfect i would not rely on this and you do not prevent the cost of a call to the driver.

  3. #3
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: opengl redundant calls

    I've been measuring cpu-cycles on nVidia drivers in 2.1, 3.0 and 3.1 contexts, redundant calls for binding VBOs, specifying vtx-attrib offsets/sizes/etc, changing textures, changing blending/raster-modes - always take the same time to execute (and it's always 1500+ cycles). Thus, you must remove redundant calls yourself (5-15 cycles).

  4. #4
    Advanced Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: opengl redundant calls

    That's very interesting info. Thanks.

  5. #5
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: opengl redundant calls

    Quote Originally Posted by Ilian Dinev
    I've been measuring cpu-cycles on nVidia drivers in 2.1, 3.0 and 3.1 contexts, redundant calls for binding VBOs, specifying vtx-attrib offsets/sizes/etc, changing textures, changing blending/raster-modes - always take the same time to execute (and it's always 1500+ cycles). Thus, you must remove redundant calls yourself (5-15 cycles).
    Yes I think it certainly depends of the cost/gain in cpu cycle of this kind of optimization. Conditional jumps may very expensive and are not cache friendly...

  6. #6
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: opengl redundant calls

    Conditional jumps are still over a hundred times faster than doing the redundant call.
    Just pack the state-cache nicely in an array or a struct of arrays, otherwise the C++ compiler is free to scatter those vars.

  7. #7
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: opengl redundant calls

    Quote Originally Posted by Ilian Dinev
    Conditional jumps are still over a hundred times faster than doing the redundant call.
    Yes maybe but I need evidences :P This statement does make sense to me since it hardly depends on the platform you are working with, but anyway we are a bit off topic now.

  8. #8
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: opengl redundant calls

    I've been writing in x86/ARM asm for years (serious full-projects and optimizations), so I'd like some trust on that statement .

  9. #9
    Advanced Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: opengl redundant calls

    FWIW I employ my own state tables on both x86 and particularly the iPhone.

    I trust you.

  10. #10
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: opengl redundant calls

    Quote Originally Posted by Ilian Dinev
    I've been writing in x86/ARM asm for years (serious full-projects and optimizations), so I'd like some trust on that statement .
    Haha! Ok Ilian I must believe you now. I must admit that I do not have such an experience in asm programming.

Posting Permissions

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