English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 05 June 2021, 15:13   #1
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
Blitter Size and game speed

Hi,


I want to optimize the speed of my game. When i started coding, i thought i'd need 16x16 pixel bobs. But now for the main bobs, a height of 3 pixels is sufficient. Now i wonder if it will have a large effect if i change the bob buffering/setting/clipping/clearing routines to a blitsize of 3x16 instead of 16x16 pixels. What do you think? At the moment, i get display problems if there are more than 8 Bobs are active, because the calculations need more time than a VBlank.


Greetings
Christian
geldo79 is offline  
Old 05 June 2021, 18:38   #2
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
The time required to blit Bobs consists of two main parts: the time to set up the Blitter and the time the Blitter itself takes to complete the request*. The cost for the first part is usually fairly static, the cost for the second part scales linearly with the size of the Blit.

So, yes, dropping the size should give you more speed (in fact, the Blitter itself will be done over 5x as fast). However, the question is how much you'll gain in real world performance. This will depend a great deal on your Blitter set up code, as a 16x16 bob doesn't take that much time to draw with the Blitter and thus the static overhead of setting up the blit will become a much larger percentage of the total cost. Therefore, I can't say for sure how much you'll gain. It'll be at most 5,5x the speed, but realistically it'll probably be closer to 2,5-3,5x the speed due to the overhead of setting up the blit (assuming you use the CPU to set up the Blitter).

*) There is also the time spend waiting on the Blitter to complete it's previous action, but if programmed well this can be seen as a static overhead that is part of the time to set up the Blitter for the next blit.
roondar is offline  
Old 05 June 2021, 21:56   #3
guy lateur
Registered User
 
guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
Quote:
Originally Posted by roondar View Post
The time required to blit Bobs consists of two main parts: the time to set up the Blitter and the time the Blitter itself takes to complete the request*. The cost for the first part is usually fairly static, the cost for the second part scales linearly with the size of the Blit.
I always kinda assumed that, for the same blit size, it would be faster to blit fewer long lines than it would be to blit more small lines. Eg, blitting 16 lines of 64 pixels each would be faster than blitting 64 lines of 16 pixels.

The only reason I have for thinking this is you have to do the offset calculation after each line. Do you think this could make a real difference, or is this usually negligible?
guy lateur is offline  
Old 05 June 2021, 22:19   #4
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
Thanks roondar,

this gives me the motivation i needed....even if it would be only 2 times faster (-:
geldo79 is offline  
Old 05 June 2021, 22:48   #5
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
Quote:
Originally Posted by guy lateur View Post
I always kinda assumed that, for the same blit size, it would be faster to blit fewer long lines than it would be to blit more small lines. Eg, blitting 16 lines of 64 pixels each would be faster than blitting 64 lines of 16 pixels.

The only reason I have for thinking this is you have to do the offset calculation after each line. Do you think this could make a real difference, or is this usually negligible?
It is indeed true that blitting longer lines is faster for bobs (but usually not for other operations). But the reason isn't to do with calculations (the Blitter adds the modulo/offset for free between lines), but rather with the need to shift the image to get to get to the location on the screen that is desired.

To be able to shift, the Blitter needs to draw 16 additional pixels per line (which is where the shifting is done into). These extra 16 pixels cost as much as any other 16 pixel block. With this is mind, we can say it's least efficient to have 16 pixel wide objects for blitting bobs and that blitting becomes progressively more efficient the wider the object becomes, though you reach diminishing returns pretty quickly.
Quote:
Originally Posted by geldo79 View Post
Thanks roondar,

this gives me the motivation i needed....even if it would be only 2 times faster (-:
You're welcome!
If you don't mind me asking, what is the reason you have to be done during the Vertical Blank? Do you use a single buffered display perhaps?
Because that's quite rare on the Amiga

Last edited by roondar; 05 June 2021 at 22:57.
roondar is offline  
Old 05 June 2021, 23:12   #6
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
Quote:
Originally Posted by roondar View Post
You're welcome!
If you don't mind me asking, what is the reason you have to be done during the Vertical Blank? Do you use a single buffered display perhaps?
Because that's quite rare on the Amiga

Hmm,.I don't know if i got the point. I want my game to be fast....with a maximum framerate (50 fps). Calculations have to be done in the vb period I think. Not?
geldo79 is offline  
Old 05 June 2021, 23:18   #7
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
Quote:
Originally Posted by geldo79 View Post
Hmm,.I don't know if i got the point. I want my game to be fast....with a maximum framerate (50 fps). Calculations have to be done in the vb period I think. Not?
On the Amiga, most games use double buffering. Some even use a form of triple buffering. The idea of double buffering is that you show one buffer while you draw the next one. That way, you can use up to the entire frame to calculate & draw bobs rather than just the time of the vertical blank.

The frame rate you get using that method will be the same (50fps), but you do introduce a slight latency/lag of 1 frame between drawing and showing. The reason it's so popular is because it allows you to draw more objects per frame without getting visual artefacts.
roondar is offline  
Old 05 June 2021, 23:45   #8
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
That sounds interesting. Maybe i have to switch over to double buffering. Are there any examples? Thus, i would have to define a second bitplanes-buffer in memory, and switch the bitplane pointers every frame to the other buffer?
geldo79 is offline  
Old 06 June 2021, 00:27   #9
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
Quote:
Originally Posted by geldo79 View Post
Thus, i would have to define a second bitplanes-buffer in memory, and switch the bitplane pointers every frame to the other buffer?
Yes, that's standard for games/demos. You use all the frame to draw your scene and then switch pointers to display.
Antiriad_UK is offline  
Old 06 June 2021, 00:36   #10
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
either switch copperlist pointer or switch bitplane pointers at the end of the frame (BOF) or on copper interrupt. Pretty easy.

On Bagman I went from racing the beam (which didn't work) to double buffering very quickly.
jotd is offline  
Old 06 June 2021, 13:19   #11
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
I think a good practice to handle the cpu overhead of different bob sizes and their setup, is to allow any height, but restrict their width to a few values that you will actually need (16 and 32 pixel width should be enough for most games). Cache the blitter size for each of your bobs and blit all of a given width one after the other. So you can save a lot of blitter setup time because all modulos stay the same.
In C++ i need around one rasterline of setup time for a complex bob, that supports custom height, x+y clipping and copper splits. As a moving 16x16 bob on 4 planes takes around 3 rasterlines to blit, every height reduction is a win.

Last edited by pink^abyss; 06 June 2021 at 13:31.
pink^abyss is offline  
Old 06 June 2021, 16:21   #12
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
When you say end of frame (BOF), can i use the start of the vblank too? I mean, is the start of the vblank the correct time to switch the bitplane pointers to the next buffer when using double buffering?
geldo79 is offline  
Old 06 June 2021, 16:28   #13
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by geldo79 View Post
When you say end of frame (BOF), can i use the start of the vblank too? I mean, is the start of the vblank the correct time to switch the bitplane pointers to the next buffer when using double buffering?

Usually the bitplane pointers are set with a copper list. One apporach is to set the new copper list pointer on the line after your last gfx has been displayed. Then you should start right away with blitting because the blitter can now run at full speed because not bitplane dma is running.
pink^abyss is offline  
Old 06 June 2021, 22:15   #14
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Just don't do what I did in my first game and restored the screen buffer using the sprite positions from the current frame.

You'll know you've screwed it up because you'll get graphical glitches. You need to restore the positions from the previous frame.

I might be able to dig out an example if you still need one.

Geezer
mcgeezer is offline  
Old 07 June 2021, 12:26   #15
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
Quote:
Originally Posted by geldo79 View Post
When you say end of frame (BOF), can i use the start of the vblank too? I mean, is the start of the vblank the correct time to switch the bitplane pointers to the next buffer when using double buffering?
It's often a copper-list which is swapped. Every copper-list, usually at the beginning, then sets BPL pointers to an appropriate buffer (hence the double-buffering). It's more convenient to swap just one copper-list pointer (COP1LC) instead of changing all BPL pointers again and again. You can do it anytime after vblank because Copper fetches that address on vblank (automatic strobe of COPJMP1).
P.S.: However to answer your question: You can change BPL pointers (by any mean) anytime before BPL DMA starts fetching words from bitplanes to BPLxDAT registers and after that fetching stops (see DIWSTRT/DIWSTOP registers) as changing it during the bitplane data fetching would obviously corrupt your displayed image.

Last edited by defor; 07 June 2021 at 13:38.
defor is offline  
Old 07 June 2021, 18:46   #16
geldo79
Registered User
 
geldo79's Avatar
 
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
It works now. I just swap the pointers at the beginning of vblank. Perfect result....now 20 bobs at once are no problem any more. Have to check the limits again now. I just worry why i did not have the idea of using two buffers by myself.....:-) Thanks again.
geldo79 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
Question about blitter speed / DMA usage LaBodilsen Coders. Asm / Hardware 3 25 January 2018 11:14
Throttle Blitter speed amilo3438 support.WinUAE 5 12 August 2017 19:47
Maximum blitter speed with pipelining zero Coders. Asm / Hardware 41 25 November 2016 20:35
Blitter filling speed, how much? sandruzzo Coders. Asm / Hardware 7 03 July 2015 14:38
WHDLoad blitter speed tests - needs you! girv project.WHDLoad 44 22 February 2008 13:43

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 15:53.

Top

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