Just come back, but old stuff runs slowly

Blitz3D Forums/Blitz3D Programming/Just come back, but old stuff runs slowly

Euphoria(Posted 2005) [#1]
Hi all,

I stopped using Blitz about a year ago now due to time constraints (who invented work :( ) but thought I would have another play round now. I started to go through some old stuff I wrote back in the day to refresh the old memory on stuff and come across this...well puzzling problem.

I wrote a small (and very ineffecient) demo and always remembering it running with no slow-down...however after a year has gone by I run it a slightly upgraded machine, it drops from 60fps to 30fps

I tried it on three machines, two had this problem, whilst the third (which technically is the worse) had no problem at all.

results
-------

machine: Athlon 3200+ ~2.2ghz, 1gb ram, gfx6800xt
directx: 9.0c
fps: ~30

machine: Athlon 64 ~2ghz, 512mb ram, mobility9600
directx: 9.0c
fps: ~30

machine: Intel 2.2ghz, 1gb ram, some crappy onboard gfx...
directx: 9.0c
fps: 60 (max refresh rate)

The obvious diference between machines is the processor....but I never had this problem when I first wrote it, and I wrote it on an Athlon machine.

To replicate the problem:

download and run: http://www.agilehosting.co.uk/simpleDef.zip

Now everytime you press F1 to get the help up the whole thing slows down dramatically.....this is what never happens and doesn't currently on the intel machine.

I realise that a LOT can be done to speed to the whole thing up (like not printing a page of text every frame, and optimising the mesh) but I am curious as to what has changed to cause this slowdown over the period of this year?

thanks for any advice


Euphoria(Posted 2005) [#2]
Just rerun the test on the mobility 9600 machine and the slowdown is inconsistent....~20 seconds of 60fps, then slows down to 20-30 then ~20 seconds laterbackup to 60...odd

Machine 1 (gfx6800xt) is consistant in slow-down

Machine 3 (internal gfx, intel), just doesnt slow down

I just noticed the source I included is not quite the same as the compiled exe...sorry bout that I actually lost the final source, the only diference should be the fps display.

thanks


VP(Posted 2005) [#3]
Your exe doesn't work (crashed with a MAV).

Your .deform_mesh is bugged. Tries to loop through more vertices than actually exist.

Just change
For vertexcount = 0 To verticesqty
to
For vertexcount = 0 To verticesqty-1

Other than that, the only slowdown might be when the help text is displayed. 'Text' is not a fast command. Better to grab the text as an image, once, then display as required.

Recompile your exe (as changed above) with Blitz 1.90, then come back if it still slows down ;)

**EDIT**

Suddenly dawned on me. Those multiple KeyDown()'s are causing it.

Take the keyboard check out of the loop (apart from check for Esc) and you'll probably see what I mean :)

**FURTHER EDIT**

Do you really need to CountVertices() in .deform_mesh every frame to get verticesqty? This is a fixed value. I don't know what overhead that particular function needs, but every little helps.


Naughty Alien(Posted 2005) [#4]
22 fps here with F1 activated...

P4 2.4 GHz , 4Gig RAM, nVidia 5600XT, 256 MB VidRAM, WinXP SP2


Euphoria(Posted 2005) [#5]
Thanks for your replies.

I apreciate your comments vinylpusher and understand the problems with the actual code, however..

Taking out the keyboard check routine does stop the problem but only because the F1 help isn't being displayed. If you force it to display and leave the keyboard check out the problem remains.

The issue here is not my crappy code :) but the fact that it runs smoothly & constantly (help displayed or not) on one machine which is actually less powerful graphically than the others....a year ago it ran fine on all machines (I am a stippler for not being happy with anything not running smooth)

The only things that have changed are Blitz has been updated, I went from 2000 to XP, increased RAM & direct X has been updated....could it be a problem with how the 'TEXT' command renders and one of them?

apreciate your time on this.


Perturbatio(Posted 2005) [#6]
it's probably related to the nvidia drivers.


big10p(Posted 2005) [#7]
It seems older GFX cards are better at doing pure 2D stuff (like Text) than the newer ones. My 850Mhz/GeForce256 machine is faster at 2D than my 1Ghz/GeForce2 machine. 2D seems to be going the way of the Dodo and card manufacturers are giving it short shrift.


VP(Posted 2005) [#8]
The differences between the systems might be such that however Blitz renders text (which is probably not a great way) runs fine on one system because Blitz and your graphics pipeline nicely mesh together, whereas on the other system, there might be any number of abstractions between Blitz's Text call and the actual rendering in hardware.

I can imagine perhaps nVidia's driver having to (un)mangle a number of calls repeatedly in order to render everything correctly. Nvidia's hardware might not natively support some minor little aspect of the way Blitz is trying to render the text and so the driver has to step in and translate.

Pure conjecture of course, but I can't think of anything else right now.

**EDIT**

I think folks are right when they say 2D stuff isn't exactly concentrated on. 2D stuff on nvidia's hardware is pretty much the driver faking it by using 3D hardware. Things run so fast these days that saying "is your card fast for 2D?" is completely redundant. Most everyone's machine can throw 32 bit colour 1920x1200 images around the screen without breaking a sweat.


Euphoria(Posted 2005) [#9]
you may actually be onto something there. My laptop is running a radeon, but I think the stuttering problem was to do with the audio as disabling it made it run smoothly 100% of the time...

I'll try installing old nvidia drivers to other machine later to see if it cures the problem...

thanks


VP(Posted 2005) [#10]
Euphoria: I think you'll probably find that newer drivers are better. What you would probably see is something of TNT2 or early GeForce class making far less work of Blitz's text rendering. Those cards were 2D with 3D bolted on, rather than newer cards being 3D with 2D emulated.

Would explain why Intel's graphics chip doesn't suffer the slowdown. I've no knowledge about how ATI implement their 2D.

Tried a Matrox?


Euphoria(Posted 2005) [#11]
Rolled back the drivers to 61.77 (as close as I could find to the time of demo creation) and everything ran smoothly, with a steady 62fps with the help displayed....

So the problem would seem to be related to the nVidia drivers and blitz 2d rendering.....not much I can do about that I suppose.

Maybe I should avoid nVidia if I want to do anything 2D in Blitz? As surely it would be silly to write stuff based on old drivers. Do you think this problem could affect the other 2d areas of Blitz, like sprites and stuff?

Might have to run some more tests on the other 2d areas.....

No havent tried a Matrox vinylpusher, only ever had an Nvidia and radeon.

Thanks for the help


VP(Posted 2005) [#12]
Blimey, I wasn't expecting that result!

Wonder what nvidia have done in these newest drivers?!

I think everything else works fine apart from text. Images, when used to display text, are fast.

Even if you grabbed Blitz normal text character by character and then formed a loop that displayed the same text as you are in your demo, it would run faster.

Obviously, the best to do in your demo would be to grab the whole thing as one image, but you get the idea.


Euphoria(Posted 2005) [#13]
Yep I'll just avoid doing that in the future. But will run some other 2d tests on old and new nvidia drivers when I get some time, just to make sure I am not going to be wasting my time writing anything 2d for nvidia cards.

cheerz


Finjogi(Posted 2005) [#14]
With my machine demo was running windowed quite steady 2 frames, even while displaying text. Text printing is slow, as said already. Another slow thing is plotting stars. 500 goes every frame but 1500 not, 4500 is horrible. It is sad but true, current GPU makers do better job with 3d and 2d as plotting pixels and things like that are not so important.


VP(Posted 2005) [#15]
hmm, I can plot somewhere around 50k pixels in a frame using WritePixelFast().

Even something in the 500MHz range should manage 5 to 10k.

There are other, even faster, ways to plot pixels if you really want to go overboard.


Gabriel(Posted 2005) [#16]
Maybe I should avoid nVidia if I want to do anything 2D in Blitz?


Well unless you're going to tell everyone who plays your game what videocards they should buy and avoid, I'd probably be more inclined to either :

(a) Avoid 2d if I want to do anything with Blitz on Nvidia.

or

(b) Avoid Blitz if I want to do anything with 2d on Nvidia.


Finjogi(Posted 2005) [#17]
IMO plot x,y is fine for experimenting things, but better way is like vinylpusher wrote, use WritePixel or WritePixel fast.

Gabriel, "anything with nvidia" comment, it is not so, you just have to take a moment to check out what commands are slow in current GFX card scene... some are slow with Nvidia, some with ATI, some with uh,.. are there any other real GFX cards around :D It is also other way around, you can't expect intel GFX card to push 20 million tris/ frame like some nvidia or ati can.


VP(Posted 2005) [#18]
Gabriel: Dude, that's pretty harsh to say avoid blitz for 2D on Nvidia.

We didn't tell Amiga users "Sorry, get yourself an 060 to play this game", we found a faster way to do what you needed to do.

We've already solved Euphoria's problem (as he is no doubt finding out). From personal experience, I know I can throw almost as many 2D images around as I can 3D sprites (I hit the upper limits of allowed visible tris in 3D).

You can do dozens of layers of parallax and hundreds of on-screen 2D sprites before you even have to think too much about optimisation. 2D speeds really are a non-issue with Blitz right now. Maybe not so much with Bmax, which has its own problems, but with B3D you've got nothing to worry about.

There are well discussed commands that you should avoid overusing in your main game loop (and ways around the problems, too).


Rroff(Posted 2005) [#19]
are you using frapsXP to measure framerate? I find with blitz3d and frapsXP running I get massive slowdowns in blitz stuff, generally around half the fps.


Banshee(Posted 2005) [#20]
I have had trouble with nVidia drivers in the past on an old GeForce2GTS/Pro card. It reported the number of texture layers wrong and this caused me considerable problems so I had to stay with an old driver for about a year until eventually they fixed it (or did I upgrade my card?).

I do not experience much slowdown with my current nVidia card (5200FX) and 2D commands, infact I invariably have quite a few text commands onscreen - it's a near instant command.

My immediate thought on reading your problem was that your Blitz was not up-to-date.

I have not looked at your source code but looking at the demo I see no obvious reason why something like that should not run a lot faster, I only got 32fps here. 2Ghz AMD, 512mb Ram


Euphoria(Posted 2005) [#21]
Using 1.90 (and tried recompiling to exe under it). I also tried older version of Blitz (was on that train of though) but made no difference.

This problem has been resolved thanks to all your help :)

Still need to test the other 2D stuff against old/new nVidia drivers to see if the problem is elsewhere before resigning my Blitz stuff to 3d only...