gfx driver sprite testBlitzPlus Forums/BlitzPlus Programming/gfx driver sprite test
| Ok I looked at the other test but the results weren't what I was getting in my test so I made this example with sprites (made using createimage so no need to download). It's a simple dot but making it larger, multicoloured or framed doesn't seem to change the results. basically the number is the number of milliseconds it takes to move and draw all the sprites to the screen. Native (1) is way faster at lower resolutions but even at higher resolutions can handel way more sprites without slowing than any of the other modes. OGL is fast and less affected by screen size but put to many sprites on screen and it's starts to crunch. 3 DX is slower than all of them but as it's the only one that Vsyncs properly it's way smoother. Anyway try t out the results will shock you. See next post for example |
| The example |
SetGfxDriver 1 Const w=320;screen width Const h=240;screen hight Graphics w,h,16,2 Dim x(50000) Dim y(150000) Dim statex(50000) Dim statey(50000) statey(0)=1 statex(0)=-1 b=500;number of sprites ;create dot sprite sprite=CreateImage(1,1,1) SetBuffer ImageBuffer(sprite) Color 255,255,255 WritePixel 0,0,$ffffff SetBuffer BackBuffer() ;set up sprites For n=0 To b statey(n)=1 statex(n)=-1 x(n)=Rnd(w) y(n)=Rnd(h) Next ;main loop condition While Not KeyHit(1) time1=MilliSecs();start timing Cls For n=0 To b DrawImage sprite,x(n),y(n) ; Draw the image! x(n)=x(n)+1*statex(n) y(n)=y(n)+1*statey(n) If x(n)>w Then statex(n)=-1 If x(n)<0 Then statex(n)=1 If y(n)>h Then statey(n)=-1 If y(n)<0 Then statey(n)=1 Next ;average time ;time2=time2+MilliSecs()-time1 ;time3=time3+1 ;time4=time2/time3 ;text 0,20,time4 Text 0,20,MilliSecs()-time1;find out how quick it was. Flip 0; Wend
| I've tidied up your code a bit, and included a FPS counter. I must say though that I got quite different results to what you said.|
DDRAW was the fastest on all counts, except for in 320x240 when NATIVE beat it (400FPS to 300FPS). OPENGL did quite poorly, staying at 62FPS all the time. But here's what's interesting, even when I changed the Image memory mode to 4 (NON-VRAM) the OPENGL framerate was still about 62, while all the others dropped by at least half. (But still about 80)
Anyway, see for yourself. Just try the constants at the top and let me know what framerates you get..
Const GFXMODE = 3 ;graphics mode 1=NATIVE 2=OPENGL 3=DDRAW Const IMGMODE = 2 ;image mode 1=STABLE 2=FAST 4=NON-VRAM Const w=640 ;screen width Const h=480 ;screen hight Const b=500 ;number of sprites SetGfxDriver GFXMODE Graphics w,h,16,2 Dim x(50000) Dim y(150000) Dim statex(50000) Dim statey(50000) ;create dot sprite sprite=CreateImage(16,16,1,IMGMODE) SetBuffer ImageBuffer(sprite) Color 255,255,255 Rect 0,0,16,16,0 SetBuffer BackBuffer() ;set up sprites For n=0 To b statey(n)=Rand(0,1)*2-1 statex(n)=Rand(0,1)*2-1 x(n)=Rnd(w) y(n)=Rnd(h) Next ;main loop condition time1=MilliSecs() While Not KeyHit(1) Cls For n=0 To b DrawImage sprite,x(n),y(n) ; Draw the image! x(n)=x(n)+1*statex(n) y(n)=y(n)+1*statey(n) If x(n)>w Then statex(n)=-1 If x(n)<0 Then statex(n)=1 If y(n)>h Then statey(n)=-1 If y(n)<0 Then statey(n)=1 Next frames=frames+1 If MilliSecs()-time1>500 Then time1=time1+500 FPS=frames*2 frames=0 Text 0,20,FPS ;find out how quick it was. Flip 0 Wend
| Ok getting more consistent results now a few things to add|
- change it back to a dot by changing the image height and width.
-change b to 50000(yep thats right)
-now notice the speed difference native is way faster.
for lower number of b modes 2 and 3 are faster but start pushing b up and DX and GL grind to a halt.
PS How do you get those cool boxes to put the code in?
| [ code ]|
CODE IN HERE
[/ code ]
By the way, I discovered that Native is VERY fast when it comes to WritePixelFast operations, I get up to 100FPS writing to a whole 640x480 screen. I am trying to get it configured to use the buffer to make it even faster, but Native's buffers are not 4 bytes for color, they seem to use 3 bytes. It's too slow to have 3 PokeByte statements for each colour, so I'm trying to find some kind of work-around....
| OpenGL mode was fastest by far! |
| I sorted out the WPF thing I think. Could you run this BB app and let me know what FPS you get:|
| Around 48FPS on a PIII 1Ghz with a Rage Mobilty Ly 16mb.|
Ps althiugh the colours are off in DX mode it's a constant 78FPS, OGL is 4FPS
| And now, the ImageBuffer test!!!|
I get 26FPS. That may not seem like a lot, but considering there are 5 images of 160x160 size on screen at once, then it IS a lot!!
| Very nice! Get 24FPS here. modes 2 4FPs mode 3 8FPS. This is a must for the code archives. |
| First test|
- Native = 85 fps
- OpenGl = 28 fps
- DirectDraw = 85 fps (nasty glitches)
- - Image mode 1 = 35 fps
- - Image mode 2 = 35 fps
- - Image mode 4 = 35 fps
- - Image mode 1 = 19 fps
- - Image mode 2 = 19 fps
- - Image mode 4 = 19 fps
- - Image mode 1 = 12 fps (nasty glitches)
- - Image mode 2 = 5 fps (nasty glitches)
- - Image mode 4 = 10 fps (nasty glitches)
Radeon 9700 pro
Pentium 4, 2.53ghz
| skn3, the "nasty glitches" are there because modes 1 and 2 handle the bank information differently. Where DirectDraw uses 4 bytes for colour information, Native and OpenGL only use 3. |
| Ah right. Whatever , it seems that native is the way to go !! |
| By the way have either of you tried setting b very high in my first example (with just the dot). Native is very fast comparatively for large amounts of sprites anyone know why? |
| It seems the results vary depending on many factors, especially vid card and driver efficiency. It's nice to know that OGL holds its own, because that bodes well for a cross-platform BMax.|