#140800 - simonjhall - Wed Sep 19, 2007 10:39 pm
Sorry if this all seems a bit vague - I'm having a bit of trouble understanding what's going on!
I've always noticed that when I used fogging, changes in the fogging settings don't seem to appear until one frame after the settings have been made. So geometry will be rendered unfogged in the frame it was enabled in, and then will be fogged in the next frame. I assumed "ok, maybe that's how fogging works, or there's something else wrong in my code" and ignored it.
I've recently rejigged lots of my rendering code to remove redundant state transitions (since I was losing over 1ms/frame with redundant projection matrix changes).
My render loop USED TO look like this:
My render loop now looks like this:
Performance has gone up (slightly - every little helps), and everything looks exactly the same as before.
I've noticed something wrong on the loading screens, after stepping into a teleporter at the end of a level (3D graphics have been on the screen for at least one frame by this point). During loading screens *no geometry is submitted*, however the whole setup/swap buffers loop still occurs, like so.
The render loop looks effectively like this:
After this swap buffers call what I see for a single frame is the previous rendered scene, but drawn (completely correctly) in orthographic mode, despite not having submitted any geometry.
So I assume that there's some crap going on with my rendering code and cut it down to the very bare minimum - just drawing the crosshair, like so.
My render loop now looks like this:
...and I get the crosshair on the screen. Now again, in loading screens no geometry is submitted (not even the crosshair) yet I still get the crosshair on the screen after the swap buffers.
Again, this looks just like the whole system is one frame behind and I'm not too worried by this. But if I change it slightly to this, (note the perspective matrix)
I again get a valid crosshair, since the crosshair was submitted whilst the projection matrix was in perspective mode. But during the loading screen, the code is effectively this:
What I see is the crosshair, but drawn with a perspective matrix.
This looks to me like geometry isn't rendered until the next frame, yet changes to the projection matrix (and fogging settings...and other things too?) don't occur until the next frame. I have no idea of what's going on here - could anyone point out what I'm doing wrong? I'm using the r20 drop from many number of months ago, there's no libnds CVS goodness in here since I'd rather not update unless I really have to.
Btw I realise I could just turn off the 3D layer during loading screens, but I'd rather know what's going on :-D
_________________
Big thanks to everyone who donated for Quake2
I've always noticed that when I used fogging, changes in the fogging settings don't seem to appear until one frame after the settings have been made. So geometry will be rendered unfogged in the frame it was enabled in, and then will be fogged in the next frame. I assumed "ok, maybe that's how fogging works, or there's something else wrong in my code" and ignored it.
I've recently rejigged lots of my rendering code to remove redundant state transitions (since I was losing over 1ms/frame with redundant projection matrix changes).
My render loop USED TO look like this:
Code: |
glReset();
<set up random stuff> set projection matrix to perspective mode <more setup> .... for each gui element set projection matrix to orthographic render game hud, eg weapon info, crosshair gui elements etc set projection matrix to perspective .... render weapon render monsters render world ... swap buffers (GFX_FLUSH = 2) |
My render loop now looks like this:
Code: |
glReset();
<set up random stuff> set projection matrix to orthographic mode <more setup> .... for each gui element render game hud, eg weapon info, crosshair gui elements etc .... set projection matrix to perspective mode ... render weapon render monsters render world ... swap buffers (GFX_FLUSH = 2) |
Performance has gone up (slightly - every little helps), and everything looks exactly the same as before.
I've noticed something wrong on the loading screens, after stepping into a teleporter at the end of a level (3D graphics have been on the screen for at least one frame by this point). During loading screens *no geometry is submitted*, however the whole setup/swap buffers loop still occurs, like so.
The render loop looks effectively like this:
Code: |
glReset();
<set up random stuff> set projection matrix to orthographic mode <more setup> swap buffers (GFX_FLUSH = 2) |
So I assume that there's some crap going on with my rendering code and cut it down to the very bare minimum - just drawing the crosshair, like so.
My render loop now looks like this:
Code: |
glReset();
<set up random stuff> set projection matrix to orthographic mode <more setup> draw crosshair swap buffers (GFX_FLUSH = 2) |
Again, this looks just like the whole system is one frame behind and I'm not too worried by this. But if I change it slightly to this, (note the perspective matrix)
Code: |
glReset();
<set up random stuff> set projection matrix to orthographic mode <more setup> draw crosshair set projection matrix to projection mode swap buffers (GFX_FLUSH = 2) |
Code: |
glReset();
<set up random stuff> set projection matrix to orthographic mode <more setup> <no submission of geometry> set projection matrix to projection mode swap buffers (GFX_FLUSH = 2) |
This looks to me like geometry isn't rendered until the next frame, yet changes to the projection matrix (and fogging settings...and other things too?) don't occur until the next frame. I have no idea of what's going on here - could anyone point out what I'm doing wrong? I'm using the r20 drop from many number of months ago, there's no libnds CVS goodness in here since I'd rather not update unless I really have to.
Btw I realise I could just turn off the 3D layer during loading screens, but I'd rather know what's going on :-D
_________________
Big thanks to everyone who donated for Quake2