English Amiga Board


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

 
 
Thread Tools
Old 14 September 2018, 14:25   #1
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,234
68000 vs Blitter on filling

Reading this post: How did games like Starglider 2 get such a high frame rate?, it seems that 68k on ocs/ecs is faster than blitter on polygons filling. It is that true? It is possible that blitter is worthless on it?
sandruzzo is offline  
Old 14 September 2018, 14:38   #2
rothers
Registered User

 
Join Date: Apr 2018
Location: UK
Posts: 27
Weirdly I was just wondering the same after reading a few threads about No second prize etc. Can someone with knowledge give us a detailed answer?
rothers is offline  
Old 14 September 2018, 15:27   #3
dodke
Registered User

 
Join Date: Feb 2018
Location: London / UK
Posts: 24
Not an expert on the subject but CPU can be faster with small polygons that overlap. Blitter is very fast when displaying large filled areas or convex 3d objects. With any large polygon 3d objects the blitter would still be faster I'm sure but more complicated to use efficiently.
With the CPU when drawing a polygon you will set or unset the bits on the bitplanes as you want. If you've already drawn something on the screen it won't matter because the CPU logic can simply draw over everything.
When drawing with the blitter you will first need to draw the edges of the polygon and then separately fill the areas between those edges. This means that if you have to draw over existing image data or other polygons you'll need to add extra passes to first draw the polygon into a clear buffer and only then you can copy it to the actual destination bitplane(s).
This is probably what you'd need to do in a game. So for drawing a single 3 edge polygon to a 4 bitplane (16 colour) screen you will need to set up and call blitter quite a few times:
- Clear temporary polygon buffer. 1 call.
- draw every edge line separately. 3 calls.
- fill the pixels inside the edges. 1 call.
- set or unset bits in every destination bitplane separately. 4 calls.

All this setting up gets costly so if you have very small polygons it will end up being faster to use the CPU.

Maybe, I haven't finished any proper blitter 3d stuff yet
dodke is offline  
Old 14 September 2018, 15:50   #4
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 91
It is definitely faster to use the CPU to fill small polygons.

The difficulty is defining "small".

Quote:
Originally Posted by sandruzzo View Post
Reading this post: How did games like Starglider 2 get such a high frame rate?, it seems that 68k on ocs/ecs is faster than blitter on polygons filling. It is that true? It is possible that blitter is worthless on it?
deimos is online now  
Old 15 September 2018, 20:19   #5
Photon
Moderator
Photon's Avatar
 
Join Date: Nov 2004
Location: Hult / Sweden
Posts: 4,568
It can be faster for very small polygons, if the code is very optimized. But the same is true for any small blit; I think Mega Typhoon and likely other shooters use the CPU to plot bullets and missiles, for example.
Photon is offline  
Old 15 September 2018, 22:16   #6
fstarred
Registered User

fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 85
Quote:
Originally Posted by sandruzzo View Post
l it seems that 68k on ocs/ecs is faster than blitter on polygons filling.
As far I know blitter speed it's the same from A500 to A4000 , so on the latter the CPU may be more convenient
fstarred is offline  
Old 16 September 2018, 01:36   #7
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
The holy grail of amiga OCS 3D, would to be able to plot the edge points for a whole scene, before filling the screen in one blitter fill pass.

It's something i have researched over the last 25 years on and off... but have never got around to coding it up

Pretty much what dodke says hits the nail on the head.

When blitting polygons, the polys could be aligned in such a way that the blitter clear, fill & copy to screen passes are actually working on much more data than is required (due to the fact that blits work on rectangular areas). I am not sure if I ever saw a routine that actually split the poly into smaller more efficient blits
DanScott is offline  
Old 16 September 2018, 12:28   #8
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 91
Quote:
Originally Posted by Photon View Post
It can be faster for very small polygons, if the code is very optimized.
Ignoring the "very optimized" part, which should be a given in this conversation, how do you define "very small"?
deimos is online now  
Old 16 September 2018, 14:31   #9
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
Quote:
Originally Posted by deimos View Post
Ignoring the "very optimized" part, which should be a given in this conversation, how do you define "very small"?
I would say, a polygon that takes less CPU instructions to render, compared to the number of CPU instructions required to set up the blitter for clearing, drawing lines, filling, copying etc... that's quite an overhead to set up the blitter


Linedraw in itself is a large number of calculations and blitter setup per line that is drawn
DanScott is offline  
Old 16 September 2018, 15:45   #10
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 91
Quote:
Originally Posted by DanScott View Post
a polygon that takes less CPU instructions to render, compared to the number of CPU instructions required to set up the blitter
So, what size polygon is that?
deimos is online now  
Old 16 September 2018, 22:24   #11
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
Quote:
Originally Posted by deimos View Post
So, what size polygon is that?
Who knows... it all depends... depends how efficient the CPU renderer is

would need to write some code that generates different polygons and renders them with both methods and compare the times taken to render
DanScott is offline  
Old 17 September 2018, 09:06   #12
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 91
It's really great that you've volunteered to do this.

Quote:
Originally Posted by DanScott View Post
Who knows... it all depends... depends how efficient the CPU renderer is

would need to write some code that generates different polygons and renders them with both methods and compare the times taken to render
deimos is online now  
Old 17 September 2018, 09:18   #13
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
Well.. my time actually would be better spent investigating some other rendering method that I devised a little while ago
DanScott is offline  
Old 17 September 2018, 10:05   #14
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,071
Quote:
Originally Posted by DanScott View Post
Well.. my time actually would be better spent investigating some other rendering method that I devised a little while ago
Filling with copper colors and then 'adjust' the edges?
ross is offline  
Old 17 September 2018, 10:25   #15
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
Quote:
Originally Posted by ross View Post
Filling with copper colors and then 'adjust' the edges?
That's one method we looked at a couple of months ago, but made no progress

The other method is the one I mentioned a few replies ago. Original concept for this was thought up around 1992/1993, but only recently I have gone back to look at how it could be done efficiently
DanScott is offline  
Old 17 September 2018, 10:44   #16
ross
Omnia fert aetas

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,071
Quote:
Originally Posted by DanScott View Post
The other method is the one I mentioned a few replies ago. Original concept for this was thought up around 1992/1993, but only recently I have gone back to look at how it could be done efficiently
ah, ok found it
Yes, this should really be a good method, considering the properties of the blitter that 're-starts' to fill up in the whole rectangle when it finds the pixels in the right way.

But what sure works well is to overlay the tasks:
while calculating the vertices in the meantime use the blitter to draw/clean/fill since not all DMA cycles are occupied by the operation.

Anyway there is too much variables to consider (number of planes, poly dimension and number, processor, fast ram..) so a best/faster method do not exists
ross is offline  
Old 19 September 2018, 14:18   #17
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,234
what about doing line setup with cpu and filling the line with blitter using D=A? in this way we have to setup only 2 blitter register, and masking first word and last word with cpu, or blitter itself.
sandruzzo is offline  
Old 19 September 2018, 15:03   #18
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 305
Quote:
Originally Posted by sandruzzo View Post
what about doing line setup with cpu and filling the line with blitter using D=A? in this way we have to setup only 2 blitter register, and masking first word and last word with cpu, or blitter itself.
Always a possibility, especially for wider scanlines.

Why don't you code it up and see if it's quicker
DanScott is offline  
Old 19 September 2018, 15:23   #19
dodke
Registered User

 
Join Date: Feb 2018
Location: London / UK
Posts: 24
Just code all 3 and do benchmarks on various different sizes. Put winners in a table based on some size attributes and use that table to select which method to use.
Done.

Maybe also include versions with both blitter nasty and normal for the routines that use both the CPU and blitter for the hell of it.
dodke is offline  
Old 20 September 2018, 08:41   #20
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,234
Since @deimos have all code done we can ask him to implement this way: blitter line filling + cpu
sandruzzo 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
Using blitter for filling 3D polygons kovacm Amiga scene 34 25 January 2018 15:30
Blitter filling speed, how much? sandruzzo Coders. Asm / Hardware 7 03 July 2015 14:38
CPU Filling vs. Blitter Filling Routine victim Coders. General 18 26 January 2014 02:15
Blitter filling routine used in games Codetapper Coders. General 2 26 January 2012 10:20
Filling with the blitter... Lonewolf10 Coders. Tutorials 7 13 September 2011 14:30

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 13:54.


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