OpenGL pipelining?

BlitzMax Forums/BlitzMax Beginners Area/OpenGL pipelining?

ImaginaryHuman(Posted 2004) [#1]
I know that OpenGL has lists and also can run immediate instruction, so I am wondering, in immediate mode, should I be trying to do `other things` in amongst calls to opengl commands? ie should I be pipelining my code so that the gfx card is preferably active as much time as possible as opposed to having to wait around for the rest of my program? Is it better to do a bunch of gl commands and then a bunch of regular code, or interweave them?


dmoc(Posted 2004) [#2]
There is only "immediate" mode (as far as most situations are concerned). If by "other things" you mean non-rendering tasks then no because you want to push data to the gfx card as fast as poss. It directly impacts on fps as your scenes get more complicated. It would also make your code generally more complicated because the "division-of-labour" will be unclear. Best to consider your code as being (at least) two distinct sections: rendering, ie, purely pushing data to gfx card, and everything else.


flying willy(Posted 2004) [#3]
I believe it is pipelining anyway. When you call drawimage, it begins rendering on the card.


teamonkey(Posted 2004) [#4]
I would structure my main loop so that all rendering is done first followed by the game logic and ending with the buffer swap. (If need be, you could probably stuff some CPU work between the initial Cls and the first rendering bit.) That way, the graphics card can get on and do its thang while the logic's going on. Mind you, it will probably have finished doing its stuff long before the logic has finished, but hey.

Having said that, I've done a couple of tests and I haven't really seen any practical advantage of using things like Vertex Arrays to draw loads of sprites in one go, over using DrawImage.


teamonkey(Posted 2004) [#5]
Just following up my own post. Don't mind me :)

In another thread - http://blitzbasic.com/Community/posts.php?topic=42118 - I found that Cls takes an awful lot of GPU time. I'd now suggest putting a *lot* of game logic between the Cls and the drawing commands and other stuff, perhaps input or networking, between the drawing and Flip.


dmoc(Posted 2005) [#6]
or don't use cls?


Bot Builder(Posted 2005) [#7]
Vertex buffers will be faster cuz you dont have to transfer them to the card every single frame, since a major bottleneck is bus bandwidth not card speed.


Paul "Taiphoz"(Posted 2005) [#8]
How does cls work if its that slow ?

I duno but I always thought that it just nulled the backbuffer. ?

Does it actually go through the backbuffer pixel by pixel ?

Also is that actually true or do you at least think that there would be a speed increase by positioning the Render above the Update ??

This is my normal game loop.

repeat
  cls
   update()
   render()
  flip
until sumtin haps.....


With all game logic being done first, and then Drawing everything to screen afterwarsd.

I'm now wondering just how much faster and just how big an impact it would have by moving these two functions around to draw/push to card first then update, but I dont have anything in max far enough on to notice any change, perhaps some one else does ??


dmoc(Posted 2005) [#9]
Depending on your app, if you are recreating the whole scene each frame (which you are most likely doing) then why bother doing cls? Even a single sq poly is faster than cls if you must clear the frame.


jhague(Posted 2005) [#10]
It is driver and card specific to be sure, but in general OpenGL immediate commands to nothing but add data to an internal buffer. When that buffer is full, or when there's a need to flush it, then it is transferred up to the card and rendered in one shot. That rendering happens in parallel with your code anyway, so don't worry about it.

For the really big rendering performance boosts, you want to use display lists.


teamonkey(Posted 2005) [#11]
Sorry, I was wrong about that. I thought Cls was slow, but it was something else instead. It's fine to use Cls. Just ignore my last post ;)