Benchmark of state changes 2d vs 3d hw

BlitzMax Forums/BlitzMax Programming/Benchmark of state changes 2d vs 3d hw

Hi,

following code illustrates an important optimisation: that is, drawing your images and treating blitzmax like 2D will result in a *severe* slowdown.

Particularly with tilemaps or in games using lots of different images.

Grouping your drawing by image type should speed things up dramatically.

Can someone verify my findings?


'benchmarking state changes

graphics 640,480,0

'two *different* 512x512 pngs
i1=loadimage("i1.png")
i2=loadimage("i2.png")

'test 1 - drawing to the screen as if you were doing 2D
t1=millisecs()
for reps=1 to 1000
	drawimage i1,0,0
	drawimage i2,0,0
next
t2=millisecs()
print "default:"+(t2-t1)

	
'test 2 - drawing to the screen bearing in mind it's using 3D hardware...
t1=millisecs()
for reps=1 to 1000
	drawimage i1,0,0
next
for reps=1 to 1000
	drawimage i2,0,0
next
t2=millisecs()
print "grouped: "+(t2-t1)