Page 2 of 3

Posted: Wed Feb 08, 2006 4:44 pm
by va!n
i have noticed some wirded things... i will try to solve the bug(s) and i will release very soon a reduced test version without music...

about the high CPU ussage... i am using following line in my code...

Code: Select all

FlipBuffers(1) : Delay(1)
I have tried to set the FlipBuffers to 2 as i thought it would save some CPU ussage.. but it doesnt seems so... i could add Delay(10) but it this how people should code?

I will try to get in contact with Fred and ask some small things... maybe he can help me explaining something special...

About the FPS... i dont like the way to use constant FPS.. in this small example i just only used...

Code: Select all

 rotate.f = timegettime_() / 10000

Posted: Wed Feb 08, 2006 6:20 pm
by va!n
now i did a small special version without any music and drawing the result on another (slow) way... this version isnt optimized, so it could be a bit slow on some systems!? But on modern PCs it should work fine...

I added two versions (both versions using the same engine) In one version the fx is in one color and the other example using something like multicolor, just something for the eye :)

please report if the FX is working (smooth !?) and if the program crash when exit... If you have any problems, please tell me your hard-/softwareconfig... thanks! If this examples works on all machines (it should), i will try part2 and optimize it again to work with some more performance... this is just the first beta phase...

www.secretly.de/purebasic/BugHunting_v0.1.zip

Posted: Wed Feb 08, 2006 6:41 pm
by THCM
I tried your bughunt versions. The exit crash is gone, but movement is still jerky! Could you please include a testversion with SetFrameRate(60)? Processorusage is about 30% here.

Posted: Wed Feb 08, 2006 6:56 pm
by va!n
@THCM:
Yes, i will release a test version using SetFrameRate(60) very soon... Could you tell me please your CPU/Memory/Windows/DirectX versions?
btw... here is a source for all people had problems with the music and CPU ussage... just test it...

Code: Select all

; -------- Test the Module PlayerRoutine and the CPU ussage....

  cFile$ = OpenFileRequester("Please select your Protracker Module","","",0)

  If cFile$ = ""
    MessageRequester("Error","Cant find Module!",0)
    End
  EndIf

  If InitSprite() = 0
    MessageRequester("Error","Cant Init Sprite!",0)
    End
  EndIf
 
  If InitKeyboard() = 0
    MessageRequester("Error","Cant Init Keyboard!",0)
    End
  EndIf
  
  If InitSound() = 0
    MessageRequester("Error","Cant Init Sound!",0)
    End
  EndIf
  
  If InitModule() = 0
    MessageRequester("Error","Cant Init Module!",0)
    End
  EndIf
    
  If OpenWindow(0,0,0,640,480,#PB_Window_WindowCentered |#PB_Window_ScreenCentered ,"PlayModule and Screeb CPU ussage Test") = 0
    MessageRequester("Error","Cant open Window!",0)
    End
  EndIf
    
  If OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0) = 0
    MessageRequester("Error","Cant open Windowed Screen!",0)
    End
  EndIf

; -------- Load and Play Protracker Module --------

  LoadModule(0,cFile$)
  PlayModule(0)

; -------- Draw on Screen any play Module --------

Repeat
  lEvent = WindowEvent()

  ExamineKeyboard()
  ClearScreen(0)

  StartDrawing(ScreenOutput())
    Box( Random(640-20), Random(480-20), 20, 20, $ffffff ) 
  StopDrawing()

  FlipBuffers(1)
  Delay(1)
  
Until KeyboardPushed(#PB_Key_Escape)

End

Posted: Wed Feb 08, 2006 7:01 pm
by THCM
Amd Athlon X2 4400+ @2.7 Ghz, Asus A8NSLI32-Deluxe, 2x 1 GB DDR 400, Microsoft Windows XP Prof. SP2 all Security Updates installed, Ati Radeon X1900XTX with DirectX 9 December Enduser Runtime.

Posted: Wed Feb 08, 2006 7:11 pm
by va!n
here is a version, using SetFrameRate(60) !!!!

http://www.secretly.de/purebasic/BugHun ... tFPS60.exe

Posted: Wed Feb 08, 2006 7:53 pm
by THCM
Weird, still not smooth. Could you please make it fullscreen?

Posted: Wed Feb 08, 2006 8:15 pm
by va!n
yes... possible TimeGetTime_ is the result of not running smooth??
i have no idea... :cry:

Posted: Wed Feb 08, 2006 9:54 pm
by Jan Vooijs
@Va!n,
The frame 60 version runs very smooth only one or two small hick-ups every odd 20 or 30secs, but it still uses all the CPU cycles!! So no other app can run (like playing a DVD) or we stutter like madd (that is both DVD and your prog).

Posted: Wed Feb 08, 2006 11:18 pm
by djes
Jan Vooijs wrote:@Va!n,
The frame 60 version runs very smooth only one or two small hick-ups every odd 20 or 30secs, but it still uses all the CPU cycles!! So no other app can run (like playing a DVD) or we stutter like madd (that is both DVD and your prog).
Completely insane! It's a demo! Why would you play a DVD while running a demo?! :evil:
Maybe you don't know : a demo try to push the computer limits. If you have no cpu time left, maybe it's because the code is using it.

MrVain> However, controlling frame rate on a PC is not easy. Maybe we could share our knowledge to do it efficiently?

Posted: Thu Feb 09, 2006 12:08 am
by Jan Vooijs
djes wrote:
Jan Vooijs wrote:@Va!n,
The frame 60 version runs very smooth only one or two small hick-ups every odd 20 or 30secs, but it still uses all the CPU cycles!! So no other app can run (like playing a DVD) or we stutter like madd (that is both DVD and your prog).
Completely insane! It's a demo! Why would you play a DVD while running a demo?! :evil:
Maybe you don't know : a demo try to push the computer limits. If you have no cpu time left, maybe it's because the code is using it.

MrVain> However, controlling frame rate on a PC is not easy. Maybe we could share our knowledge to do it efficiently?
Well thank YOU :twisted: :evil: and the same back!! The purpose is to look if the demo runs at any rate!! Not to steel all the CPU cycles which it does now and stutters, but running smooth. There is a problem with the way the demo is build inside, aka wrong type of "engine" which looking at the provided source code makes me wonder this runs beter:

Code: Select all


; -------- Test the Module PlayerRoutine and the CPU ussage....

... code removed was unchanged ...
 
; -------- Draw on Screen any play Module --------

Repeat
  lEvent = WaitWindowEvent( 2)

  ExamineKeyboard()
  ; ClearScreen(0)

  StartDrawing(ScreenOutput())
    Box( Random(640-20), Random(480-20), 20, 20, $ffffff )
  StopDrawing()

  FlipBuffers(1)
  ; Delay(1)
 
Until KeyboardPushed(#PB_Key_Escape)

End 
Note the " WaitWindowEvent( 2)" and removal of "; ClearScreen(0)" and the "Delay(1)". But the program stops if the mouse is NO longer on the window (side effect)... :lol: This version runs about 30% and still NO stutter!!! I even can play a DVD while this litle demo version runs...

Hope this helps....

Posted: Thu Feb 09, 2006 9:25 am
by djes
:D

Posted: Thu Feb 09, 2006 9:36 am
by dmoc
You could try a variable Delay(). Calculate loop time and increase delay until fps halfs (missed frame) then back it off a little. This has the advantage that it's dynamic, ie, if a demo does more work at one stage than another then the delay will be adjusted. Not perfect but easy to implement. One variation is to try to sync processing so it completes just before the next frame refresh, pushing spare processing time to *after* the frame refresh. The objective is to ensure maximum processing time while minimising possibility of missing the next refresh (which otherwise results in jittery graphics).

Posted: Thu Feb 09, 2006 12:09 pm
by va!n
Jan Vooijs wrote: Note the " WaitWindowEvent( 2)" and removal of "; ClearScreen(0)" and the "Delay(1)". But the program stops if the mouse is NO longer on the window (side effect)... :lol: This version runs about 30% and still NO stutter!!! I even can play a DVD while this litle demo version runs...

Hope this helps....
What should WaitWindowEvent(2) do??? This command dont use/need any arguments! So i dont understand the "2"... In the original effect code i dont used any ClearScreen(), because the complete screen will be redrawed each frame, so i didnt used ClearScreen() .. Delay(1) was used because i dont wanted 100% CPU ussage...

Posted: Thu Feb 09, 2006 1:25 pm
by Tranquil
va!n wrote:
Jan Vooijs wrote: Note the " WaitWindowEvent( 2)" and removal of "; ClearScreen(0)" and the "Delay(1)". But the program stops if the mouse is NO longer on the window (side effect)... :lol: This version runs about 30% and still NO stutter!!! I even can play a DVD while this litle demo version runs...

Hope this helps....
What should WaitWindowEvent(2) do??? This command dont use/need any arguments! So i dont understand the "2"... In the original effect code i dont used any ClearScreen(), because the complete screen will be redrawed each frame, so i didnt used ClearScreen() .. Delay(1) was used because i dont wanted 100% CPU ussage...
WaitWindowEvent(2) sets a timeout to the command, which means its something like Delay(2) but includes window message processing.