English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 10 July 2015, 00:07   #1
jayminer
Registered User
 
jayminer's Avatar
 
Join Date: Jun 2015
Location: Umeå / Sweden
Posts: 266
Waiting for the blitter...

Me and a friend did some tests today and a very simple program that just moved around some objects over a background could only move around ~18 (16x16 pixel 5 bitplane) objects before it started to lag on a 68000 machine (on my A2000 with 030 it started lagging with about 30 objects, I'm a bit puzzled why the 030 is so much faster when it's mainly the blitter that is doing all the work).

It seems all the commands for blitting stuff in Blitz Basic are waiting for the blitter to finish before they move on with the code. Does anyone here know if there is any (easy) way to queue up blits and let the main program continue running without spending most of it's time waiting for the blitter?
jayminer is offline  
Old 10 July 2015, 20:47   #2
RiskyW
 
Posts: n/a
Hi fellow Amiga fans!
@jayminer: I too did some extensive testing the last few days with BOBs in Blitz. I wanted to make a very simple 50fps shooter for classic Amigas.

Before I dive into it keep in mind that im in no way an advanced Blitz programmer or anything like that. only as of late Ive started to seriously sink my teeth into Blitz.

Anyway here it goes:
My screen setup is a lores dbl buffered 4 bplanes copperlist and Im using QBlits.

The program thus far is a bunch of 12x12 animated BOBs on a black bg moving @ different speeds and headings bouncing off the edges of the screen to the opposite direction. Pretty simple stuff.

Im using inline assembly the only fast way I know off by accessing and manipulating global vars from the a5 register for all main loop math computations including a 16.16 fixed point math routine(again in assembly) for the bob movements. plus Im using constants wherever I can.

The result is max ~35/40 objects before fps drops below 50 on the default A1200 "basic non-expanded configuration" in WinUAE 3.1 (sorry no real hardware to test on atm) which is kinda disappointing tbh and is simply not enough performance for the kind of game i want to make. Ive seen games running with more objects @ 50 fps on a mere unexpanded A500 and at 5 bplanes with larger sprites(16x16) and moving background starfields!

I think I might be doing something wrong here or there exist other optimizations I can make perhaps idk? eg is there a better/faster way of using the inline assembler or perhaps there's a faster external blitting library we can use? or is this in the end all that Blitz can handle? (although I highly doubt that)

Last edited by RiskyW; 10 July 2015 at 20:54.
 
Old 12 July 2015, 05:33   #3
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Nobody can give you help without looking into the source code. Expecting high frame rates and being let down by the machines results might caused by your src?
E.g. fixedpoint math instead of word/lword math?

You give the hint for free:
Quote:
Originally Posted by jayminer View Post
...(on my A2000 with 030 it started lagging with about 30 objects, I'm a bit puzzled why the 030 is so much faster when it's mainly the blitter that is doing all the work).
It's the code!
Cylon is offline  
Old 12 July 2015, 11:10   #4
RiskyW
 
Posts: n/a
Quote:
Originally Posted by Cylon View Post
Nobody can give you help without looking into the source code. Expecting high frame rates and being let down by the machines results might caused by your src?
E.g. fixedpoint math instead of word/lword math?

You give the hint for free:

It's the code!
Hi Cylon
I dont understand. Fixed point math is floating point calculations using only integers. so yes in my case (16.16) lwords.
Anyway do you think its possible to get a better performance out of Blitz than the one I mentioned above?
 
Old 13 July 2015, 13:45   #5
jayminer
Registered User
 
jayminer's Avatar
 
Join Date: Jun 2015
Location: Umeå / Sweden
Posts: 266
Quote:
Originally Posted by Cylon View Post
Nobody can give you help without looking into the source code. Expecting high frame rates and being let down by the machines results might caused by your src?
E.g. fixedpoint math instead of word/lword math?

You give the hint for free:

It's the code!
Well, I don't have the source on this machine but it was a very simple loop that I don't think should strain the CPU much at all, I'm using words (.w) for all my variables (deftype .w)

The code was basically this:

Code:
deftype .w

dim ox(50), oy(50), oxd(50), oyd(50)

I put some randomized start-values into these, ox/oy = object x/y, oxd/oyd = object x/y direction
I also make 3 bitmaps, 2 to use for double-buffering and one that is used with unqueue to repaint the background, the main loop looked like this:

while something
  for loop=0 to max
    ox(loop)=ox(loop)+oxd(loop)
    oy(loop)=oy(loop)+oyd(loop)
    if ox(loop)=320 then oxd(loop)=-1
    if ox(loop)=0 then oxd(loop)=1
    if oy(loop)=256 then oyd(loop)=-1
    if oy(loop)=0 then oyd(loop)=1
    qblit db,1,ox(loop),oy(loop)
  next
  unqueue db,2
;  doublebufferstuff here
wend
I also read two keyboard-keys to be able to change max to add and remove objects, and see where it starts lagging
jayminer is offline  
Old 19 July 2015, 05:45   #6
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quick review shows:
You are blitting ALWAYS, even if nothing changed.
You check xcoords on the right, even if the coords have been confirmed to be left, and vice versa. Dito for vertical.
Means: You check everything everytime. And blit, everytime. Change that.
Cylon is offline  
Old 19 July 2015, 16:52   #7
jayminer
Registered User
 
jayminer's Avatar
 
Join Date: Jun 2015
Location: Umeå / Sweden
Posts: 266
Well since this was a test to see how many objects I can move around I want to blit them all each frame, and the cpu cycles wasted by those extra tests should be negligable, wouldn't they, an object would only get a hit in X every 320 frames so most of the frames both checks would have to be done anyway.

But my original question wasn't about optimizing my really quick and dirty test-code, but I was wondering if there's an somewhat easy way to not halt the program waiting for the blitter to finish at each and every blit. I would like to build up some queue of blits to be done and let blitz handle those while the rest of my program continues to run. Is something like this possible? Any extension that can help?
jayminer is offline  
Old 20 July 2015, 02:11   #8
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Quote:
Originally Posted by RiskyW View Post
The result is max ~35/40 objects before fps drops below 50 on the default A1200 "basic non-expanded configuration" in WinUAE 3.1 (sorry no real hardware to test on atm) which is kinda disappointing tbh and is simply not enough performance for the kind of game i want to make. Ive seen games running with more objects @ 50 fps on a mere unexpanded A500 and at 5 bplanes with larger sprites(16x16) and moving background starfields!
16 pixels (one word) is the smallest width the Blitter can handle, so whether you're using 12x12 objects or 16x12 objects, the load on the Blitter is the same.

Quote:
Originally Posted by RiskyW View Post
Im using inline assembly the only fast way I know off by accessing and manipulating global vars from the a5 register for all main loop math computations including a 16.16 fixed point math routine(again in assembly) for the bob movements. plus Im using constants wherever I can.
How do you access global vars from A5 register?
idrougge is offline  
Old 20 July 2015, 02:12   #9
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Quote:
Originally Posted by Cylon View Post
Quick review shows:
You are blitting ALWAYS, even if nothing changed.
You check xcoords on the right, even if the coords have been confirmed to be left, and vice versa. Dito for vertical.
Means: You check everything everytime. And blit, everytime. Change that.
While that could help his demo, it won't help for the purposes of his shmup, as long as there is a possibility that more than 30 objects move at the same time.
idrougge is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copper - waiting for the end of a line h0ffman Coders. Asm / Hardware 21 14 March 2017 20:59
Blitter busy flag with blitter DMA off? NorthWay Coders. Asm / Hardware 9 23 February 2014 21:05
Have you played Banshee? If not what are you waiting for? vroom6sri Amiga scene 14 18 June 2013 01:01
Waiting for disk activity to finish Dreedo project.WHDLoad 11 07 December 2010 16:07
Which game would you prefer to play while waiting for XCopy to copy Project-X Disk 1? killergorilla Nostalgia & memories 29 11 January 2007 15:59

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:45.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07539 seconds with 15 queries