I'm not sure the test code is good unless you use a 256x256 image. When I was using an image in-game it was 48x38 (so a 64x64 texture). Here's another version of the code:
SuperStrict
SuperStrict
Graphics 800,600,0
Local image1:timage=LoadImage("64x64white.png")
Local t1:Int,t2:Int,t3:Int,t4:Int
Const LOOP_SIZE%=100
Const FLIP_AFTER%=0
While Not KeyHit(key_space)
Cls
DrawText "press space to start",0,0
Flip
Wend
'Send to VRAM
Cls
DrawImage image1,0,0
Flip
t1=MilliSecs()
For Local x:Int=0 To LOOP_SIZE-1
Cls
DrawImage image1,0,0
If Not FLIP_AFTER Then Flip -1
Next
If FLIP_AFTER Then Flip -1
t2=MilliSecs()
'Send to VRAM
Cls
DrawRect 0,0,64,64
Flip
t3=MilliSecs()
For Local x:Int=0 To LOOP_SIZE-1
Cls
DrawRect 0,0,64,64
If Not FLIP_AFTER Then Flip -1
Next
If FLIP_AFTER Then Flip -1
t4=MilliSecs()
Print (t2-t1)+" " + (t4-t3)
The image is a white 64x64 png.
I like to let benchmark apps boot up and prompt the user for a key press to ensure all system processes have "settled down" before running a test.
I've also made sure that the image is sent to VRAM with a test draw before the main draw. I've done the same with the DrawRect command for consistency but it's probably not needed.
With FLIP_AFTER=0 I get 1667 1665. With FLIP_AFTER=1 I get 860 859 with a loop size of 10000.
So I tried another test where I draw multiple of each, then FLIP and I do that 100 times:
SuperStrict
Graphics 800,600,0
SetBlend ALPHABLEND
Local image1:timage=LoadImage("64x64white.png")
Local t1:Int,t2:Int,t3:Int,t4:Int
Const LOOP_SIZE%=100
Const LOOP2_SIZE%=100
While Not KeyHit(key_space)
Cls
DrawText "press space to start",0,0
Flip
Wend
'Send to VRAM
Cls
DrawImage image1,0,0
Flip
t1=MilliSecs()
For Local i:Int=0 To LOOP_SIZE-1
For Local j:Int=0 To LOOP2_SIZE-1
Cls
DrawImage image1,0,0
Next
Flip
Next
t2=MilliSecs()
'Send to VRAM
Cls
DrawRect 0,0,64,64
Flip
t3=MilliSecs()
For Local i:Int=0 To LOOP_SIZE-1
For Local j:Int=0 To LOOP2_SIZE-1
Cls
DrawRect 0,0,64,64
Next
Flip
Next
t4=MilliSecs()
Print (t2-t1)+" " + (t4-t3)
EndI got: 1675 and 1672
Note that I've added in SetBlend AlphaBlend as that's what I was using in my game.
So I'm basically getting the SAME. Fascinating. So something else in my game/setup may have been having an effect on the overall drawing speed somehow, weird because I literally substituted one drawrect for a drawimage! This:
DrawRect c.sx,c.sy,48,48
for this:
DrawImage(AreaAffectedImage.Image,c.sx,c.sy)
and there is nearly 100FPS difference. Go figure.