PlayBASIC V1.64N2 / V164N3 (Work In Progress) Gallery

Started by kevin, April 22, 2012, 12:07:12 AM

Previous topic - Next topic

kevin


Quote
In this example too much flash lines.

what does that mean ?

ATLUS

i don't know how it work correct, but that lines changes very fast for 60 fps and more.

kevin


     Seems like there might be an overlap between when the Sync flips the pb screen pages and when the render thread is writing to the PB screens backbuffer.    Because the Sync is also asynchronous, as are more most 'video' memory operations.    If that's the cause, we'd need to force a wait condition so they're both not trying to render to/from the same memory. 

     One way might be force a lock surface, when before calling BlitImageClear.  The lock should, make it wait until all draw operations are complete. 

  Test #1

PlayBASIC Code: [Select]
   #include "BlitIMage"

Type tCircle
x#,y#
SpeedX#
Size
Colour
EndType


Dim Object as tcircle list

For lp =0 to 500
Object= New tCircle
Object.x# =rndrange(-800,1600)
Object.SpeedX# =rndrange#(1,5)
Object.y# =rnd(600)
Object.size =rndrange(10,50)
Object.Colour =rndrgb() and $0f0f0f
next


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)

FrontBUffer=0


; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1



do

BackBUffer=1-FrontBUffer


; start the blitting the from buffer to the PB screen
rendertoscreen

; Calling this function pushes this rendering task onto a second thread
; when threading is ensabled.
lockbuffer
BlitIMageClear Screens(FrontBuffer),0,0,$304050
unlockbuffer


; While the back ground thread is working drawing the Front Buffer image to
; the PB screen, we start drawing on to our backbuffer screen image.
; Meaning it's doing two things at once, we're drawing circle, while it's BlitIMageClear'ing

rendertoimage Screens(BackBuffer)

Inkmode 1+64
For each Object()
x#=Object.x+Object.SpeedX#

circlec x#,Object.y,Object.Size,true,Object.Colour

if x#>1600
x#=-800
endif
Object.x=x#
next
inkmode 1

rendertoscreen

; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitStates=0

; wait until the thread is complete
while GetBlitFXStatus()=1
WaitStates++
wait 1
endwhile
endif


; Press Space to toggle Threading
if Spacekey()
BlitFXThreadingMode 1-GetBlitFXThreadingMode()
flushkeys
endif

Setcursor 0,0
print "Threading:"+Str$(GetBlitFXThreadingMode())
print "Wait States:"+Str$(WaitStates)
print "Fps:"+str$(Fps())

FRontBUffer=1-FrontBuffer
Sync
loop



   



ATLUS


kevin


  What you should be doing is trying to make it work on your end, but without feedback, this will be removed.


  This test saves two bitmaps to a folder on your computer (you set the folder/device), one show the state of the front and back buffer.  If they're not synced, it'll be read/writing to the same memory and hence the corruption.   

PlayBASIC Code: [Select]
   ; Insert your PATH/FOLDER TO SAVE TEMP PICTURES
SavePath$="D:\"


#include "BlitIMage"
#include "SaveBitmap"


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)



; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1


; start the blitting the from buffer to the PB screen
rendertoimage Screens(0)
cls 255

; Calling this function pushes this rendering task onto a second thread
; when threading is enabled.
lockbuffer
BlitIMageClear Screens(1),0,0,$304050
unlockbuffer

rendertoscreen

; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitStates=0

; wait until the thread is complete
while GetBlitFXStatus()=1
WaitStates++
wait 1
endwhile
endif

savebitmap SavePath$+"Picture0.bmp",Screens(0)
savebitmap SavePath$+"Picture1.bmp",Screens(1)


print "done"
Sync
waitkey





  Bellow is the expected result in both pictures.  (converted to PNG to save space on the board.. since the save raw BMP)

kevin

#95
 PlayBASIC V1.64N3 - Beta 9c - Final Threading Test

     Uploaded  another beta with some threading tweaks called Beta #09c.   Works on the systems here, but I have my doubts we can get this into a universally useful state.




Threading Example

  This demo has a bunch of flags for you to tinker with, use them!   You really should be writing your own examples trying to help work out the particular conditions where such problems occurs within, as without some type of context I see little point continuing.  Can't fix what i can't see.


PlayBASIC Code: [Select]
   #include "BlitIMage"

Type tCircle
x#,y#
SpeedX#
Size
Colour
EndType


Dim Object as tcircle list

For lp =0 to 500
Object= New tCircle
Object.x# =rndrange(-800,1600)
Object.SpeedX# =rndrange#(1,5)
Object.y# =rnd(600)
Object.size =rndrange(10,50)
Object.Colour =rndrgb() and $0f0f0f
next


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)

VideoBUffer=NewImage(800,600)
JunkBUffer=NewImage(16,16)


FrontBUffer=0


renderscene=1


; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1




do



; start the blitting the from buffer to the PB screen
rendertoimage VideoBuffer

; try to force a GPU wait
GetImage JunkBUffer,0,0,16,16

; Calling this function pushes this rendering task onto a second thread
; when threading is ensabled.
lockbuffer
BlitIMageClear Screens(FrontBuffer),0,0,$304050
unlockbuffer


; While the back ground thread is working drawing the Front Buffer image to
; the PB screen, we start drawing on to our backbuffer screen image.
; Meaning it's doing two things at once, we're drawing circle, while it's BlitIMageClear'ing

rendertoimage Screens(BackBuffer)


if renderScene
Inkmode 1+64
For each Object()
x#=Object.x+Object.SpeedX#

circlec x#,Object.y,Object.Size,true,Object.Colour

if x#>1600
x#=-800
endif
Object.x=x#
next
inkmode 1
endif


; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitStates=0
WaitOnBlitFX()
endif

rendertoscreen
drawimage VideoBuffer,0,0,false


; Press Space to toggle Threading
if Spacekey()
BlitFXThreadingMode 1-GetBlitFXThreadingMode()
flushkeys
endif

if Keystate(50)
gfxmmx 1-Getgfxmmx()
flushkeys
endif

if Keystate(19)
renderscene=1-renderscene
flushkeys
endif

Setcursor 0,0
print GetBlitFXStatus()
print "Threading:"+Str$(GetBlitFXThreadingMode())
print "Wait States:"+Str$(WaitStates)
print "Fps:"+str$(Fps())
print "MMX:"+str$(GetGFXmmx())

print FrontBuffer
print BackBuffer

for lp =0 to 50
v=QueryAsync(lp)
if V
print Str$(lp)+"="+Str$(v)
endif
next


FrontBUffer=1-FrontBuffer
BackBUffer=1-FrontBUffer

Sync
loop







ATLUS

 PlayBASIC V1.64N3 - Beta 9c on this version code works nice =)

kevin


well, that's a start.   Although your video cards text rendering is terribly slow...  Add the line   MakeBitmapFont 1,-1,8 , and go back and try the previous examples. 

  Been starting on a couple laptops today, and it seems to work ok on one (but slower) and flickery on the other.. No idea why..


ATLUS


kevin


So it doesn't flicker when threaded ?  -  Although, I actually mean test the previous versions of demo.  Which is prolly back on the last page now. 

What CPU (exactly) is in it ?

The core 2 duo here flickers when MMX is enabled, it's fine without it.. I've a bad feeling they cheat in those chips.

 

ATLUS

No, i don't see any lines.
my cpu - AMD Phenom II x3 720
and this example's screenshots
PlayBASIC Code: [Select]
 #include "BlitIMage"

Type tCircle
x#,y#
SpeedX#
Size
Colour
EndType


Dim Object as tcircle list

For lp =0 to 500
Object= New tCircle
Object.x# =rndrange(-800,1600)
Object.SpeedX# =rndrange#(1,5)
Object.y# =rnd(600)
Object.size =rndrange(10,50)
Object.Colour =rndrgb() and $0f0f0f
next


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)

FrontBUffer=0


; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1



do

BackBUffer=1-FrontBUffer


; start the blitting the from buffer to the PB screen
rendertoscreen

; Calling this function, pushes this rendering task onto a second thread
; when threading is ensabled. So
BlitIMageClear Screens(FrontBuffer),0,0,$304050


; While the back ground thread is working drawing the Front Buffer image to
; the PB screen, we start drawing on to our backbuffer screen image.
; Meaing it's doing two things at once, we're drawing circle, while it's BlitIMageClear'ing

rendertoimage Screens(BackBuffer)

Inkmode 1+64
For each Object()
x#=Object.x+Object.SpeedX#

circlec x#,Object.y,Object.Size,true,Object.Colour

if x#>1600
x#=-800
endif
Object.x=x#
next
inkmode 1



rendertoscreen

; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitStates=0

; wait until the thread is complete
while GetBlitFXStatus()=1
WaitStates++
wait 1
endwhile
endif


; Press Space to toggle Threading
if Spacekey()
BlitFXThreadingMode 1-GetBlitFXThreadingMode()
flushkeys
endif

Setcursor 0,0
print "Threading:"+Str$(GetBlitFXThreadingMode())
print "Wait States:"+Str$(WaitStates)
print "Fps:"+str$(Fps())

FRontBUffer=1-FrontBuffer
Sync
loop

kevin


  yeah, that won't work without changing the wait code, like this.

PlayBASIC Code: [Select]
#include "BlitIMage"

Type tCircle
x#,y#
SpeedX#
Size
Colour
EndType


Dim Object as tcircle list

For lp =0 to 500
Object= New tCircle
Object.x# =rndrange(-800,1600)
Object.SpeedX# =rndrange#(1,5)
Object.y# =rnd(600)
Object.size =rndrange(10,50)
Object.Colour =rndrgb() and $0f0f0f
next


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)

FrontBUffer=0


; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1



do

BackBUffer=1-FrontBUffer


; start the blitting the from buffer to the PB screen
rendertoscreen

; Calling this function, pushes this rendering task onto a second thread
; when threading is ensabled. So
BlitIMageClear Screens(FrontBuffer),0,0,$304050


; While the back ground thread is working drawing the Front Buffer image to
; the PB screen, we start drawing on to our backbuffer screen image.
; Meaing it's doing two things at once, we're drawing circle, while it's BlitIMageClear'ing

rendertoimage Screens(BackBuffer)

Inkmode 1+64
For each Object()
x#=Object.x+Object.SpeedX#

circlec x#,Object.y,Object.Size,true,Object.Colour

if x#>1600
x#=-800
endif
Object.x=x#
next
inkmode 1



rendertoscreen

; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitOnBlitFX()
endif

; Press Space to toggle Threading
if Spacekey()
BlitFXThreadingMode 1-GetBlitFXThreadingMode()
flushkeys
endif

Setcursor 0,0
print "Threading:"+Str$(GetBlitFXThreadingMode())
print "Wait States:"+Str$(WaitStates)
print "Fps:"+str$(Fps())

FRontBUffer=1-FrontBuffer
Sync
loop




ATLUS

this code works nice 250-252 fps and not lines =]

kevin


ATLUS

#104
 :) == =] == =)   ;D

I was mean that code is working.