Sprites 3D question...
-
lethalpolux
- Enthusiast

- Posts: 171
- Joined: Sun Jun 08, 2003 10:50 pm
- Location: France
- Contact:
Sprites 3D question...
Another little thing:
why is it better to display all sprites 3D at the same time ( after Start3D(), display all sprites, Stop3D())..?
Is it more faster?
Because it's not evident to do that.
I want to know if it is valable to modify my code ( at the moment, i display my sprites 3D when i need them and i put start3D() and Stop3D() every time ).
Thanx
why is it better to display all sprites 3D at the same time ( after Start3D(), display all sprites, Stop3D())..?
Is it more faster?
Because it's not evident to do that.
I want to know if it is valable to modify my code ( at the moment, i display my sprites 3D when i need them and i put start3D() and Stop3D() every time ).
Thanx
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
-
Codemonger
- Enthusiast

- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
It is faster to put the code between Start3D and Stop3D, because Directx would not have to make as many state changes and it can flush the sprites to the gpu all at once. But seeing as they are just 3d sprites and if you are running a fast Cpu you probably wouldn't notice a speed difference at all, unless you start to max out the number of sprites you are using, then you will notice a speed decrease. Anyway just my thoughts, all in all I wouldn't worry too much about it.
As far as organising your code it probably would be better and more efficient to have your sprites lumped together.
As far as organising your code it probably would be better and more efficient to have your sprites lumped together.
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
I have made some tests :
In the first loop, I draw 5000 3d sprites (start/stop3d outside the loop), then 5000 classic sprites.
In the second loop, the I draw alternately a 3d sprite and a classic sprite (start/stop3d inside the loop).
Something strange is that in 32 bit screen mode, the difference between the two loops decrease a lot (almost same time for both).
Code: Select all
InitSprite() : InitKeyboard() : InitSprite3D()
OpenScreen(800,600,16,"")
CreateSprite (0,64,64,#PB_Sprite_Texture)
CreateSprite3D(0,0)
CreateSprite (1,64,64,0)
;draw a circle on each sprite
StartDrawing (SpriteOutput(0))
FrontColor (128,0,0) : Circle (32,32,32)
StopDrawing()
StartDrawing (SpriteOutput(1))
FrontColor (0,0,128) : Circle (32,32,32)
StopDrawing()
Repeat
ExamineKeyboard ()
ClearScreen (0,0,0)
;FIRST LOOP
timer = TimeGetTime_()
Start3D()
For i=0 To 5000
DisplaySprite3D(0,320,240,255)
Next
Stop3D()
For i=0 To 5000
DisplayTransparentSprite (1,400,240)
Next
timer1 = TimeGetTime_() - timer
;SECOND LOOP
timer = TimeGetTime_()
For i=0 To 5000
Start3D()
DisplaySprite3D(0,320,240, 255)
Stop3D()
DisplayTransparentSprite (1,400,240)
Next
timer2 = TimeGetTime_() - timer
StartDrawing(ScreenOutput())
FrontColor (255,255,255) : DrawingMode (1)
Locate (200,50) : DrawText ("loop 1 : "+Str(timer1)+" ms")
Locate (200,65) : DrawText ("loop 2 : "+Str(timer2)+" ms")
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
EndIn the second loop, the I draw alternately a 3d sprite and a classic sprite (start/stop3d inside the loop).
Something strange is that in 32 bit screen mode, the difference between the two loops decrease a lot (almost same time for both).
I get a "Error in line 24: Start3D() must be called before DisplaySprite3D()" in your test code
Think you need to have only one Start3D() and Stop3d() in you main flipbuffer() loop.
I do not know for sure, but my guess is that routines like Start3D() is optimized to work within a single flipbuffer() cycle. So using more Start3D() within a flipbuffer() cycle could give various results on different systems.
As for the speed difference in 16 bit mode vs. 32 bit I wouldn't be surprised performance would be better in 32 bit, since newer 3D cards often perfroms better in that mode.
Just my thoughts
Van
Think you need to have only one Start3D() and Stop3d() in you main flipbuffer() loop.
I do not know for sure, but my guess is that routines like Start3D() is optimized to work within a single flipbuffer() cycle. So using more Start3D() within a flipbuffer() cycle could give various results on different systems.
As for the speed difference in 16 bit mode vs. 32 bit I wouldn't be surprised performance would be better in 32 bit, since newer 3D cards often perfroms better in that mode.
Just my thoughts
Van
Tested it abit more, and it seems that Escaping the test code with 'ESC' works very slow on my system. So in my restless mude, I've Alt-Tabbed out of the program to quickly and then i get the Start3D() error. Without beeing restless it works, but it takes 10 secs to quit the app and it dosn't display the "loop1" and "loop2" text.
It works better ,not perfect, with one loop only. Still i don't get any text info
It works better ,not perfect, with one loop only. Still i don't get any text info
-
lethalpolux
- Enthusiast

- Posts: 171
- Joined: Sun Jun 08, 2003 10:50 pm
- Location: France
- Contact:
Thanx codemonger,coma!
But it seems that sprites 3D works better when you use only one Start3D/Stop3D in code ( with GF4 MX it's sure! ).. I've made the tests with my Geforce 4TI4200 128Mo, no problem, but the same program with a GF4 MX 64Mo slow down about 10/20 fps...
Put only one start3D/Stop3D have reduced this difference(5/10)... and i put always sprite3D on sprite2D ( with a little modified code )
To solve the problem of the fps' decrease, i've deleted 5/6 sprites 3D... and the performance returns...
But it seems that sprites 3D works better when you use only one Start3D/Stop3D in code ( with GF4 MX it's sure! ).. I've made the tests with my Geforce 4TI4200 128Mo, no problem, but the same program with a GF4 MX 64Mo slow down about 10/20 fps...
Put only one start3D/Stop3D have reduced this difference(5/10)... and i put always sprite3D on sprite2D ( with a little modified code )
To solve the problem of the fps' decrease, i've deleted 5/6 sprites 3D... and the performance returns...
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
-
lethalpolux
- Enthusiast

- Posts: 171
- Joined: Sun Jun 08, 2003 10:50 pm
- Location: France
- Contact:
Thanx fred! 
But, what is the limit of sprites 3D.. video card memory,chipset?
What make my code run faster on my GF4TI 128Mo than the same on a GF4MX 64Mo ( with same PIV and memory )..?
how to optimized ( if it's possible )?
I'm happy to see you again fred.
( LJ2 : 45% coded - if you want to test the beta... soon )
But, what is the limit of sprites 3D.. video card memory,chipset?
What make my code run faster on my GF4TI 128Mo than the same on a GF4MX 64Mo ( with same PIV and memory )..?
how to optimized ( if it's possible )?
I'm happy to see you again fred.
( LJ2 : 45% coded - if you want to test the beta... soon )
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits

