Render slowdown at start of a level

Blitz3D Forums/Blitz3D Programming/Render slowdown at start of a level

JoshK(Posted 2004) [#1]
Has anyone experienced extreme slowdown right when they load a map, and a very high amount of trisrendered()? It's as if Blitz doesn't start culling offscreen or out-of-range surfaces until they get onscreen once. I have to go around the map and look at everything before it will go up to normal speed. Then I go back to my start position, and the polys rendered is much much lower.


Erroneouss(Posted 2004) [#2]
yes, im my Flight $imulator game... it happened when i put in an extra city into it...i forget how, but i fixed it...


BODYPRINT(Posted 2004) [#3]
Are your textures stored in the graphics card vram?

That might help.


jhocking(Posted 2004) [#4]
What you describe is why I have the camera spin around and render everything once as the last step of level loading. I hide these renders from the player by drawing something else to the backbuffer before calling Flip.


Warren(Posted 2004) [#5]
Things aren't actually uploaded to the video card until they are drawn for the first time. JHocking's solution is similar to what we do in the UT games .. "precaching" means "please wait while the game draws everything in the level one time so they're in the video cards memory". Minimizes stuttering and stalling as you walk around a new area.


*(Posted 2004) [#6]
Hunted goes from 3fps at the begining of entering a level to a healthy 70fps in game, I would love to know how to stop the lag as its a killer to any decent game.


jhocking(Posted 2004) [#7]
Um, we just explained.


ryan scott(Posted 2004) [#8]
what is required to do this - do you have to show different sides of each object, or is this enough?

before i hide the entity i am creating for use later, i call this:


Function camera_startup_SHOWOBJECT(ent)
dx#=EntityX(ent)
dy#=EntityY(ent)
dz#=EntityZ(ent)

PositionEntity cam,dx-10,dy-10,dz-10,1
PointEntity cam,ent
RenderWorld
;Flip ; only if you wanna see it
End Function

it seems to help.

but the terrain, i'm not sure what is enough to make this work, and do my objects need to be in place? i'm showing it all the objects separately using the above routine as you see.

i'm scanning the terrain at a height of 150, and moving over by 50 each step. maybe that's not enough information for you. what i am wondering is, how do YOU handle this?

and do SOUNDS need to be precached? i'm apparently getting stuttering based on SOUNDS being played. I tried converting mp3s to wavs and that didn't really seem to help that I can see.


puki(Posted 2004) [#9]
For the record - I noticed this (for the first time) when using BlitzTree3D - I assumed it was their product, perhaps not - I also tend to initially, turn on the spot to resolve the problem.


maximo(Posted 2004) [#10]
This happens to me in BattleField Vietnam, I have to walk around and look around a bit first before game picks up the speed, so it's not only blitz


Warren(Posted 2004) [#11]
It's a general video card thing. If you have to upload new data to the card, you're going to get hitches. This is why it's best to have a large enough card to hold all the data for the game you're playing ... a 16MB or 32MB card these days causes you a lot of pain and anguish.


ryan scott(Posted 2004) [#12]
this is profoundly annoying. i am showing it all objects, even showing it all my particle emitters and setting off all particles on camera for it once. still, i'm getting random in game stutter, and i have no idea why. it's much better than when i wasn't showing it all my objects, but anyway, it will pause for a half second at what appears to be completely random times. not just when there's a lot of objects on screen.

i am uploading a copy of the game here: http://download.runinteractive.com/zdistro.zip

does anyone else see stutter in this game?

(move with arrows, fire with mouse, blow up everything)

mostly seems like when you turn around in a circle and fire. possibly a terrain issue? I am showing it my entire terrain before the game starts. but i can drive way off in the distance and get what feels like a graphic buffer stutter every once in awhile.

i don't know, i just don't get it.


Mustang(Posted 2004) [#13]
Things aren't actually uploaded to the video card until they are drawn for the first time. JHocking's solution is similar to what we do in the UT games .. "precaching" means "please wait while the game draws everything in the level one time so they're in the video cards memory". Minimizes stuttering and stalling as you walk around a new area.


Yup, we "warm up" the cards also at work... of course if you have more textures, geometry and screen buffers than your card can handle at once you are going to see some stuttering because the card unloads/loads textures or geometry on the fly.


JoshK(Posted 2004) [#14]
That makes perfect sense, but why would the FPS be slow when you are just sitting there, not introducing new data? Why would TrisRendered() appear to include every poly in the map?


jfk EO-11110(Posted 2004) [#15]
I have never noticed false TrisRendered Values, as you describe it.

A further brake are animated textures. they are uploaded frame by frame to vram when they are used the first time.

So maybe you should play all frames first. The other issues can be solved by

for i=0 to 360 step 90
rotateentity camera,0,i,0
renderworld()
next


big10p(Posted 2004) [#16]
A further brake are animated textures. they are uploaded frame by frame to vram when they are used the first time.

Ouch!


ryan scott(Posted 2004) [#17]
re mustang:
Yup, we "warm up" the cards also at work... of course if you have more textures, geometry and screen buffers than your card can handle at once you are going to see some stuttering because the card unloads/loads textures or geometry on the fly.

----------
is there way to tell how much of the ram is being used in the card at any given point?

and what about sounds, i'm finding stuters related to sounds sometimes..


Zethrax(Posted 2004) [#18]
is there way to tell how much of the ram is being used in the card at any given point?


Check out the AvailVidMem() and TotalVidMem() commands in the 2D Graphics docs.


Warren(Posted 2004) [#19]
A further brake are animated textures. they are uploaded frame by frame to vram when they are used the first time.

Heh, yeah, I noticed that the first time I tried to do an animated texture. I saw the video ram going up and up and I started to panic until the texture looped and it stabilized. :)


ryan scott(Posted 2004) [#20]
i'm still getting stuttering after showing it every object, every animation, every particle being exploded right in camera view, driving the camera over the entire terrain, and playing all the sounds.

is it possible that objects are forgotten from the buffer if you don't display them after awhile? i'm not using all my video ram, only about half, when the game is playing.

and do i have to show each entity or just the mesh they share?

i'm showing between 0 and 1500 particles at once, combined with my objects gives me 5000 to 13000 triangles rendered whenever i call trisrendered().

that's not a lot, is it? games like unreal tournament 2004 seem to run fine on my computer, although i cannot run games like Lord of the Rings, it's just too slow.

Am I just trying to make my machine do too much? damn it's disappointing if so.

here's the game if anyone wants to give it a try. maybe it doesn't stutter for you? i really would love to know.

i'm running matrox parhelia 128mb 3 head setup. i know it's not the fastest in the world but i don't think blitz should be running as slow as i'm seeing it run.

http://download.runinteractive.com/zdistro.zip


Dreamora(Posted 2004) [#21]
perhaps your program structure is just unoptimized with several nested loops and things like that


jfk EO-11110(Posted 2004) [#22]
If you have a big lot of things, and not enough videoram, it will dynamicly upload the required things. How much VRam do you have? (stutterin sounds a a true OS-bug since the task priority of playing sounds should always be higher than uploading stuff to vram or moving data whereever)


big10p(Posted 2004) [#23]
Does loading your textures with flag 256 (store in VRAM) set make any difference? Maybe you're doing that already but, hey. :)


ryan scott(Posted 2004) [#24]
1. my code doesn't have anything unnecessary in it. i'm a g00d c0der. (really) the slowdown is not overall but just at certain times for a half second or so. not code related

2. here's my ram numbers:
AvailVidMem() = 112,959,488
TotalVidMem() = 131,874,816
TrisRendered() = 9,000 to 13,000

availvidmem does change every once in awhile. it might go up or down a little. it doesn't correspond with the stutter, because the stutter happens a lot more than the change in availvidmem.

this is plenty of memory though, isn't it? i'm using almost nothing.

does anyone have a sick graphic card they can try it on and tell me if it's ok? i'm thinking of tossing this card and going with a new radeon or whatever is the best at the moment. maybe i need to reinstall windows. ew. if it doesn't stutter on a radeon, i'll get a new computer and start over. i can pass this one down to my wife, so it is an option. can someone with a new graphic card give it a try?

3) flag 256, yes i'm doing it, makes no difference.

http://download.runinteractive.com/zdistro.zip

thank you to everyone, this is a great community.


jhocking(Posted 2004) [#25]
No stuttering/slowdown when I play (2.4GHz, 2GB RAM, Quadro FX 1000.)

The game control mechanism is very similar to something I had been experimenting with for a while. It would help a LOT if you put target crosshairs on the screen so that you can tell where the mouse cursor is. You'd probably want some sort of 2D-in-3D method, but even DrawImage cursor,MouseX(),MouseY() would be nice.


ryan scott(Posted 2004) [#26]
well, i think i found the problem.

SpySweeper (perhaps the memory shield)

combined with some unnecessary collision detection

every 10-15 seconds or so, spysweeper shows up in task manager taking up 15 percent of processor. disk makes a head moving sound, and blitz pauses for a split second.

It's very interesting that it doesn't happen for other people's setups.

jhocking: i wrote a game a long time ago in AMOS that used the mouse, it was good that way, and i might do it that way. on the other hand, you can see where you are aiming because the bullets go there, and you just stream them out. it means less to think about - aiming the car *and* the crosshairs turns out to be a little more cumbersome, at least for mouse/keyboard combination. for joystick/mouse, it's a little easier.

thanks for trying it and your help!


jhocking(Posted 2004) [#27]
Crosshairs would be misleading I suppose, since people would expect that they have to get the crosshairs over the target in order to hit it. Still, you need some visual indicator of the mouse position so that people can aim the turret. Without a visual indicator it is impossible to know how you have to move the mouse in order to turn the turret (eg. if the cursor is currently close to the center you only need to make a small wrist movement to turn the turret 180, but if the mouse is toward the edge of the screen you need to make a large arm movement.)


ryan scott(Posted 2004) [#28]
oh the turret is visible on top of the car. it's a problem right now because i'm just using ridiculous placeholder graphics, and don't have anything dialed in. it'll be very obvious when i'm done. i need to find an artist.

did you get any slowdown during lots of action, like when there were lots of explosions? i get slowdown which is sure better than stutter because at least i can get a faster graphic card to fix the slowdown.


jhocking(Posted 2004) [#29]
Well sure you can see the turret, but you can't see the mouse cursor. The player has to be able to see the mouse. Try putting in a mouse indicator; just before Flip

Oval MouseX()-1,MouseY()-1,3,3


Zethrax(Posted 2004) [#30]
Actually I noticed fairly significant slowdown after a few minutes of play. And if I stopped the bot, waited a second or two and then start playing again, the slowdown would disapear for a few seconds before re-occurring.

I was spraying bullets around like there was no tommorrow initially, so this may have triggered it.

Specs are: Athlon 1700XP CPU, 256 Meg ram, GeForce 4 MX440.


Rook Zimbabwe(Posted 2004) [#31]
Ryan... I have the spysweeper lag as well. ONly fix... turn it off and get your firewall to LOCK off the internet. OR if you are playing an internet game... well... I just suffered the lag of the firewall...

-Z


ryan scott(Posted 2004) [#32]
i'm not getting that slowdown, axeman. weird. i just got myself a radeon 9800 (the x series doesn't support multiple monitors at least not the ones at compusa didn't)

anyway, now i'm getting 400fps(! i never expected this), and no slowdown, no stuttering if i shut off that stupid, stupid spysweeper.

rook, what does it mean 'lock off the internet' ? turn off my internet access? that's not a good solution :/

i'd rather just not use spysweeper, or turn it back on after i'm done developing or something.


AbbaRue(Posted 2004) [#33]
In this case I would run Spybot and see if you have
something running in the background you don't know about.
I had a simular problem and found I had spyware & adware on my puter.
I run spybot regularly and it seems it always finds something.
Also check the taskbar. Most stuff on taskbars are not needed most of the time.
I posted this for everybody, not insulting your intellect, mostly for other people with simular problems.
Being a good programmer you probably ruled this out long ago.
Bye.


JoshK(Posted 2004) [#34]
Here is a PreCache function that should work for most cases.

I was getting half the FPS I should be, until I had walked around the entire map. Given that the map is about half a mile wide, and is the smallest map size I would use in the game, this is no small task.

Rendering everything once did not perform the precaching, but rendering once when everything is out of view, and then rendering once with everything in view does the trick. Don't know why:

Function PreCache()
cam=CreateCamera()
CameraRange cam,1,10000000
PositionEntity cam,0,5000000,0
RotateEntity cam,-90,0,0
RenderWorld
RotateEntity cam,90,0,0
RenderWorld
FreeEntity cam
End Function