I have been rolling the idea of using thinking of rendering a particular item to the screen as executing all of the opengl state calls used for that item. All of them.
Meaning glEnable(GL_BLEND), as well as glDisable(GL_CULL_FACE) as well as glUniform and glUseProgram.
Given all the necessary state to render a given object, you have a large state vector. Now it wouldn't be efficient to actually program like this, but it makes sense, and sets the stage to think about things in an interesting way.
There are two concepts that I believe are important here:
First, given the set of objects you intend to render, I can produce a set of opengl state vectors assuming you need to set every single opengl state variable for every single item you want to render.
Now you would like to optimize this. Lets say you render a couple times and record, for each state item, if it was different from the last state item and if so, now many different items you found.
Now you sort each state vector by the number of different instances of each state property you found. Next you sort your entire render list by the state vectors. Now if you walk through the state vectors you are guaranteed to need to change the minimal number of gl state for each item in the state vector. You could add expense information to different operations in the sense that you some gl state properties are expensive to set (glUseProgram) and some aren't.
That gives you an extensible way to order your rendering operations on opengl objects where actually changing the state is slowing the program down.
Lets now take a look at exactly what a state vector is, or perhaps rather what it reminds me of.
The other place I have seen a large number of state items was a CSS system for html I wrote once. The result of a success full CSS system is a large vector of properties you apply to this html object during the rendering phase.
Perhaps there could be a graphics css system where the result is the opengl state vector you need to rendering this particular piece of geometry? I need to think about this for a while to see if it goes anywhere, but it is a start.
Chris
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment