Page 1 of 1
StartDrawing(ScreenOutput()):StopDrawing()
Posted: Sat Mar 19, 2005 7:18 pm
by Psychophanta
These two functions eats a lot of CPU time.
Sorry if i am a purist of saving resources, but in this case, i think it is a disproportionate consumption. About 80% of CPU inter-frame time at 60Hz.
Can be done something?
Posted: Sat Mar 19, 2005 10:41 pm
by filperj
Well...
-1: Test that little test.
-2: Note the results.
-3: Comment the "If StartDrawing..." line.
-4: Test again.
-5: Compare results.
-6:
Code: Select all
InitSprite()
If OpenScreen(800,600,32,"")
CreateSprite(0,100,100)
BeginTime=ElapsedMilliseconds()
For it=1 To 3000
start=ElapsedMilliseconds()
If StartDrawing(ScreenOutput()) : StopDrawing() : EndIf ; <- Comment me !
Drawtime+(ElapsedMilliseconds()-start)
ClearScreen(100,100,80)
start=ElapsedMilliseconds()
For itspr=1 To 400
DisplaySprite(0,Random(700),Random(500))
Next
SpriteTime+(ElapsedMilliseconds()-start)
FlipBuffers(0)
Next
TotalTime=ElapsedMilliseconds()-BeginTime
CloseScreen()
advert$="Total time : "+Str(TotalTime)+#lf$+"Drawing time : "+Str(drawtime)
advert$+(#lf$+"Sprites time : "+Str(SpriteTime))
advert$+(#lf$+"Drawing+Sprites : "+Str(DrawTime+SpriteTime))
MessageRequester("",advert$)
EndIf
Posted: Sat Mar 19, 2005 11:11 pm
by Psychophanta
Nice snip to demonstrate it.
Look this:
Code: Select all
InitSprite()
If OpenScreen(800,600,32,"")
CreateSprite(0,100,100)
BeginTime=ElapsedMilliseconds()
For it=1 To 3000
start=ElapsedMilliseconds()
StartDrawing(ScreenOutput()) : StopDrawing()
Drawtime+(ElapsedMilliseconds()-start)
ClearScreen(100,100,80)
start=ElapsedMilliseconds()
For itspr=1 To 160
DisplaySprite(0,Random(700),Random(500))
Next
SpriteTime+(ElapsedMilliseconds()-start)
FlipBuffers(0)
Next
TotalTime=ElapsedMilliseconds()-BeginTime
CloseScreen()
advert$="Total time : "+Str(TotalTime)+#lf$+"Drawing time : "+Str(drawtime)
advert$+(#lf$+"Sprites time : "+Str(SpriteTime))
advert$+(#lf$+"Drawing+Sprites : "+Str(DrawTime+SpriteTime))
MessageRequester("",advert$)
EndIf
Time used by:
StartDrawing(ScreenOutput()) : StopDrawing()
is about time used by:
For itspr=1 To 160
DisplaySprite(0,Random(700),Random(500))
Next
Incredible

Posted: Sat Mar 19, 2005 11:48 pm
by filperj
Yes but... Did you try to remove the StartDrawing() ? The code won't run that much faster. And as I used FlipBuffers(0) it's not a matter of VSync.
I suppose that there is a "Mysterious Operation" (Let's call it MOP) which has to be done before each FlipBuffers().
If I guess right, when you call StartDrawing(Screenoutput()), it executes the MOP, and when you call FlipBuffers(), it executes the MOP IF the MOP has not been executed before.
So StartDrawing() looks slow but is not...
:roll:
Posted: Sun Mar 20, 2005 12:21 am
by Psychophanta
so strange :roll:
any answer

Posted: Sun Mar 20, 2005 6:08 am
by Ralf
hi Psychophanta! i remember someone posted this some time before and shared an example how to speed it up with direct DX access or whatever it was!? i am not really sure and i havent found the posting yet. maybe you have more luck!?
