Results 1 to 2 of 2

Thread: Monitoring State Changes

  1. #1
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    Monitoring State Changes

    Okay, on my big projects I'm having a hard time monitoring state changes. Since state changes (ex. glEnable(GL_TEXTURE_2D)) are costly on performance, what is a good system of setting up your code so you can easily tell which states are on, thus reducing redundant calls? Does it come down to performance vs. readability?

  2. #2
    Member Contributor
    Join Date
    Feb 2001
    Location
    Sydney, NSW, Australia
    Posts
    60

    Re: Monitoring State Changes

    State blocks.

    Create a class, say called CStateBlock. It has members, like colour, and array of textures, blending, alpha, etc. When you render a buffer you call the state block to setup state.

    Now since your in to performance what you do next is sort your objects to be rendered by StateBlock, for example just add operator < and use an STL sort on it.

    Now all the object are ordered efficiently, when renderering objects with the same state block don't apply the state.

    To go core you can create a system ordered on state change cost, say 100point for a texture change, 40 points for a light source change etc, this however is probably taking it too far as the CPU cost to determine this is probably more that the savings. On top of that different cards have different costs. It might work if you do a mini performance test on app start to configure the balance of the cost values.

    HTH

    cb
    (Note : I got this tip off two respected pro coders at muckyfoot and oddworld.)

Similar Threads

  1. GPU monitoring tools (UI/commandline)
    By anna_anna in forum OpenCL
    Replies: 2
    Last Post: 12-19-2013, 07:10 AM
  2. Separate sampler state from texture state
    By The Fiddler in forum OpenGL: General
    Replies: 79
    Last Post: 03-15-2010, 05:12 PM
  3. checking state before setting state
    By supagu in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-11-2004, 10:55 PM
  4. state changes again...
    By zen in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 03-03-2003, 02:58 AM
  5. Monitoring the VRAM status...
    By passalis in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 02-19-2002, 03:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean