StartDrawing(ScreenOutput()):StopDrawing()

Everything else that doesn't fall into one of the other PB categories.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

StartDrawing(ScreenOutput()):StopDrawing()

Post 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. :shock:

Can be done something?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
filperj
User
User
Posts: 77
Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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 :shock: :shock: :!:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
filperj
User
User
Posts: 77
Joined: Tue Sep 16, 2003 8:53 pm
Location: Nevers(France)

Post 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:
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

so strange :roll:
any answer :?:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post 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!? ;)
Post Reply