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 3 of 3

Thread: Which statechanges are omptimized by driver?

  1. #1
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Which statechanges are omptimized by driver?

    Hi!

    Thats my first post on this board, so
    dont take it too serios

    Im writing my Renderer and
    I dont know which statechanges i should manage my self.
    Example:
    void renderer::BindTexture(uint id)
    {
    if(id != bound_texture)
    {
    glBindTexture(GL_TEXTURE_2D,id);
    bound_texture = id;
    }
    }

    Is this really neccessary, or does the driver
    this kind of optimization for me?
    Managing all the important states (textures,
    vertexprograms, vbos) my self is ... well, a bit work intesive
    especially when you use textureunits and cubemaps which
    require even more state changes.

    I sort everything in my scene by texture, but every object calls
    renderer->SetTexture(mytexture); in their Render() function.

    So the state managing would only cut down the
    amount of glDoSomeThing calls. Is this really worth the effort?

    Sorry for my bad english

  2. #2
    Intern Contributor
    Join Date
    May 2003
    Location
    Dortmund, Germany
    Posts
    60

    Re: Which statechanges are omptimized by driver?

    Args, damn typo.

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Greece
    Posts
    496

    Re: Which statechanges are omptimized by driver?

    There were a few interesting posts on this subject a while ago in the advanced forum. You better do a search for the long answer. The short one though is:
    the driver doesn't in general do checks to avoid state changes as this would be unnecessary overhead for apps which try to avoid state changes by sorting etc. . Anyway you can either make sure that the state you're trying to set isn't allready set or you can try to minimize state changes by sorting/grouping geometry according to the state they need. The latter should of course be better but also more complex.

Posting Permissions

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