Why is this so slow?!

Discuss any general programming issues here
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Why is this so slow?!

Post by ArtBlink »

Hello,

Try this code and see FPS

Code: Select all

@SCREEN {Mode = "ask", Width = 640, Height = 400}
CreateBrush(1,32,32,#GREEN)
CreateBrush(2,32,32,#BLUE)
Dim Carte[26][15]

Carte[0]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[1]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[2]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[3]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[4]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[5]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[6]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[7]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[8]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[9]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[10]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[11]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[12]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[13]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[14]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[15]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[16]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[17]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[18]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[19]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[20]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[21]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[22]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[23]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}
Carte[24]={1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}
Carte[25]={2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1}

CreateBrush(3,800,800)
SelectBrush(3)
For Y = 0 To 25 
	For X = 0 To 25 
		DisplayBrush (carte[Y][X],X*32,Y*32)
	Next
Next
EndSelect
Y=0
Function Controle()
	If IsKeyDown("Left")=True Then Gauche() ; Vers la gauche
	If IsKeyDown("Right")=True Then Droite() ; Vers la droite
	
	If IsKeyDown("a")=True Then Zoomin() ; Zoom in
	If IsKeyDown("z")=True Then Zoomout() ; Zoom Out	
EndFunction

Function Gauche()
	Y=Y+1
	If Y>359 Then Y=0
EndFunction

Function Droite()
	Y=Y-1
	If A<0 Then A=359
EndFunction


Function Zoomin()
	Z=Z+10
	If Z>600 Then Z=600
EndFunction

Function Zoomout()
	Z=Z-10
	If Z<150 Then Z=150
EndFunction
Function rotation()
	StartTimer(1)
controle()
DisplayBrush(3,320,240,{rotate=Y,anchorx=0.5,anchory=0.5})
Local Temps=GetTimer(1)
TextOut (520,1,"FPS :",#BLUE)
If temps<>0 Then TextOut (586,1,Round((1/Temps)*1000))

EndFunction
SetInterval(1,rotation,1000/50)

Repeat
WaitEvent
Forever	
Press left and right arrow and read the fps (on AMigaOne PPC)
Why is it too slow, it's just a rotation of picture, if i make the same thing with the rotation of multiple brush, the result is more slower :shock: :shock:

On Amos, i have make the same thing, but with scroll, and on amiga 1200 (in 320x256), Why my microAone PPC, (only the double of number of pixel) the same thing is more more slower?

Have you got a code to accelerate this?

Thanks
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Why?!

Post by djrikki »

On a 640x480 screen using AmigaOne 500, I get 125 FPS.

Seems okay to me.

EDIT: Hold on you mean during rotation... 5-6FPS.. I'll take a look see if I can suggest anything.

PS: Zooming is calling the functions, but not changing anything visually.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Why?!

Post by djrikki »

I don't know why its generally slow.. perhaps might wanna explore drawing the grid using polygons/boxes instead of relying on brushes and rotation.

However, if you use add Smoothscale=false into the DisplayBrush FPS speed doubles.

You could also increase the pixel movement from 1 to 2 pixel each function call. 3 or higher and it seems to look less smooth to me.

DisplayBrush(3,320,240,{rotate=Y,anchorx=0.5,anchory=0.5,smoothscale=false})
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
jalih
Posts: 281
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Why?!

Post by jalih »

I noticed, you use hand defined tables for a checker board map. You can easily automatically create a checker board map table of any size using two For loops.

Something like:

Code: Select all

; Create and display a checker board
@DISPLAY {Width = 320, Height = 320}

@INCLUDE "hgf/game.hws"

Const #TILEX = 32
Const #TILEY = 32
Const #BSZ = 10

game:init()
CreateBrush(1, 320, 320)
Local img = image:new(1)   
Local yscol = 0
Local col = 0
Local p = point:new()
Local tiler = rect:new( { min = { x = 0, y = 0 }, max = { x = #TILEX, y = #TILEY } } )
Local color = {}
color[0] = #GREEN
color[1] = #BLUE
SetFillStyle(#FILLCOLOR)
For Local i = 1 To #BSZ
	yscol = yscol ~ 1
	col = yscol
	For Local j = 1 To #BSZ
		img:drawRect(tiler:addpt(p), color[col])
		p.x = p.x + #TILEX
		col = col ~ 1
	Next
	p.x = 0
	p.y = p.y + #TILEY
Next
game.buffer:drawImg(img.r, img, point:new())
Flip()
WaitLeftMouse()
Above example uses my library primitives, but you get the idea...
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Why?!

Post by ArtBlink »

Hi all,

No, don't use primitive, it's more slower.

I use table because it's the speeder method to create scroll, i have create a rotate scroll but on microAone, the FPS is 1 :lol:

So, i think we can't create rotate sroll with hollywood.

Smoothscale is normaly false, no?
Zooming aren't implemented, it is slow without, so if i add this, i think the result can be more slower.

grrrr!!!
User avatar
Tuxedo
Posts: 355
Joined: Sun Feb 14, 2010 12:41 pm

Re: Why?!

Post by Tuxedo »

we need JIT Hollywood player then :)
Simone"Tuxedo"Monsignori, Perugia, ITALY.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Why?!

Post by airsoftsoftwair »

Hollywood is doing all these things in software and that is slow. Hardware acceleration would be nice to have but it would also impose a lot of restrictions on Hollywood which many people won't like. Also it would decrease the portability of Hollywood.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

n

Post by ArtBlink »

@Andreas:

Is it possible to accelerate AOS and Morphos Engine, on win,macos and linux, the problem isn't present because Computer are more speeder than ANG and Mac PPC, IF you accelerate AOS and morphos version, you're langage Hollywood can be the first langage on this system... For information, portableIE is more faster and french programmer is create a PPC version of AMOS...

A strategic point of view (mine), the priority must be on optimisation of Hollywood 2D engine on AOS and Morphos, when i read an practice hollywood command, i read a powerfull langage and easy to use. At this time, hollywood is portable on all système, continue, but don't forget origin, if hollywood can help all coders to create game and application and quickly with a powerfull engine, all Amiga users (NG,mac ppc,6800x0) buy it ;-)

It's my point of view, but if it interessant, i code with C ansi and portableIE, i have more good result... sic... I prefer hollywood, and your big work, but, i think sometimes to change.

So, continue you're work but don't forget AMiga user with their little computer ;-)

At this time, a game (scroll+big sprite+light effect+rotozoom+...) in 640x480 on Amiga ng can be work at 50 FPS... normally... of course ;-)

Good chritmas at all 8-)
User avatar
Tuxedo
Posts: 355
Joined: Sun Feb 14, 2010 12:41 pm

Re: Why?!

Post by Tuxedo »

I think same things of ArtBlnk...
We need an optimised Hollywood engine for AmigaOS like systes imho...
On win and mac the enormous difference of cpu power compensates the non hw acceleration I think...
So plz add hw acceleration on AmigaOS systems and left it out on non AmigaOS systems(also on AROS if it causes problems)...
That was werid that Amiga hollywood programmers cant made amiga fast programs but only win and mac fast programs... :(
I duno if can be other ways to have that solved...but plz do something!
Simone"Tuxedo"Monsignori, Perugia, ITALY.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Why?!

Post by ArtBlink »

AOS and Morphos hardware acceleration in hollywood 5.0?

(4.8=Linux version so 5.0=AOS/Morphos Hard acceleration ;-) )

I have the 2 version of holly, PC and AOS... I would to see speed difference between these version ;-)

@Tuxedo: We have the same opinion ;)

I want to create good 2D game on AOS and Morphos... at this time, i can't, because 2D engine is too slow :cry:
Post Reply