Small Intro - Thanks for PB v4 (bughunting version added)

Developed or developing a new product in PureBasic? Tell the world about it.
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post 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.
The Human Code Machine / Masters' Design Group
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post 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.
The Human Code Machine / Masters' Design Group
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

here is a version, using SetFrameRate(60) !!!!

http://www.secretly.de/purebasic/BugHun ... tFPS60.exe
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Weird, still not smooth. Could you please make it fullscreen?
The Human Code Machine / Masters' Design Group
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

yes... possible TimeGetTime_ is the result of not running smooth??
i have no idea... :cry:
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post 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).
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post 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?
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post 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....
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

:D
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post 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).
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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...
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
Post Reply