Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
18 crawler(s) on-line.
 128 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 clint:  9 mins ago
 RickSkid:  19 mins ago
 bhabbott:  25 mins ago
 BigD:  27 mins ago
 Diane:  30 mins ago
 VooDoo:  33 mins ago
 A1200:  37 mins ago
 pixie:  50 mins ago
 retrofaza:  50 mins ago
 DiscreetFX:  1 hr 11 mins ago

/  Forum Index
   /  Amiga Development
      /  Packed Versus Planar: FIGHT
Register To Post

Goto page ( 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 Next Page )
PosterThread
Karlos 
Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 11:40:55
#1 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

There has been a significant amount of discussion regarding packed versus planar pixels and their relative strengths and weaknesses. The only way to settle this, is like nerds.

So, I thought it might be fun to throw down the gauntlet. I've written a small c source (C99) that defines Packed and Planar bitmap structures for between 1-8 bits per pixel and the associated allocator routines. These guarantee that the data are contiguous and that each row starts on a 32-bit aligned boundary. To do this, they align the requested width in pixels to a value that satisfies the above guarantees.

The idea is to go on to define sets of raster operations for each type bitmap and benchmark them. I propose the following initial set of primitives:

void SetPixel(uint32 x, uint32 y, uint8 pen)
uint8 GetPixel(uint32 x, uint32 y)
void DrawSpan(uint32 x, uint32 y, uint32 w, uint8 pen)
void DrawLine(uint32 x1, uint32 y1, uint32 y1, uint32 y2, uint8 pen)

This can be expanded out with more elaborate operations later. For example, filled trapezoids (needs the same general line drawing logic to determine the start and end coordinates of a set of spans), filled circles, etc.

See: https://gist.github.com/0xABADCAFE/21820334fa39b6d5bc3edff1d9a03197

Note: In order to have some sort of convention, while we allow the pixel data to be accessed at different sizes, when accessing the data at the 32 bit level of our hypothetical bus, the left most pixel/fragment shall occupy the most significant bits of the word.

Last edited by Karlos on 05-Jun-2022 at 03:44 PM.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:07:51
#2 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

There is not really Fight, we already know packed is faster, did we already conclude that.
Imaginary packed formats, is kind useless as nothing is using this.

1bit,2bit,4bit,8bit,16bit (only 15bit used),32bit (only 24bit used)
formats are typical Macintosh graphics (chunky).

1bit,2bit,3bit,4bit,5bit,6bit,7bit,8bit
format is the Amiga Formats (planar).

Interestingly the 1bit format can be considered planar and chunky.

Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:09 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:25:18
#3 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

You give up so easily? For example, I'm sure you can implement the span routine in a way that is basically as performant as packed for spans over some minimum width. As in you'll be talking difference of cycles. We know that simple power of two packed modes are fast because they have machine addressable pixels, but all other sizes are not directly machine addressable and so will have some of the same issues that planar has.

Anyways, it's just for fun.

Quote:
Interestingly the 1bit format can be considered planar and chunky


Indeed. And if you look at the code, you'll see that PlanarBitmap and PackedBitmap reduce to the same data structure for 1bpp too.

Last edited by Karlos on 05-Jun-2022 at 12:28 PM.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:28:45
#4 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

Of course, you can pack the 3bit, 5bit, 7bit, you can simply use a lookup table (or 3).

The good thing about look table, you have a input, and get output, between input and output, there is no masking, or logical operations, it’s a 1 to 1 convention.

One example of this, is Basilisk II, where have 15bit mode BE format, and on AmigaONE side I have 16bit graphic card, using LE format,

so instead of shuffling bits around, and doing the R5G5B5 to R5G6B5 and then swap the bytes.
I go from A to B by a simple index read.

Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:42 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:35 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:33 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:32 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:30 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:34:07
#5 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

Why use a lookup table? The packed bitmap here is completely contiguous, so you should be able to calculate the exact bitfield location of any pixel. You'll observe all the odd numbered depths have widths aligned to 32 bit pixels. They are essentially congruent with the 1bpp case...

Quote:
The good thing about look table, you have a input, and get output, between input and output, there is no masking, or logical operations, it’s a 1 to 1 convention.


How big is this lookup table? If it's very small and can fit in a few cache lines you're golden. If it's big and randomly accessed, not so much.

Last edited by Karlos on 05-Jun-2022 at 12:51 PM.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:38:36
#6 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

Because or else you end up with masking and shifting,
so you have load, mask, shift, or, store, ++ all boilerplate code.

Of course, you can round it up to 8bit, and not use the other bits, for 3bit, 5bit, 7bit chunky modes, then you don’t need to convert bits.

Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:45 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:44 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 12:41 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 12:44:41
#7 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

Less talk. Moar code!

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 14:55:10
#8 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

Quote:
Of course, you can round it up to 8bit, and not use the other bits, for 3bit, 5bit, 7bit chunky modes, then you don’t need to convert bits.


This defeats the exercise. We are comparing packed and planar at each bit depth explicitly.

Speaking of which, first blood. Given the constraint that bitmaps are contiguous and rows begin at 32-bit aligned boundaries, planar concedes the first defeat:

- For planar, width has to be rounded to next nearest 32 pixels (unless already aligned) for all planes at all bit depths.

- For packed, this is only a requirement for odd numbered bit depths. For even numbered bit depths, width can be rounded to a smaller interval, e.g. 16 pixels for 2 and 6 BPP, 8 pixels for 4 BPP and 4 pixels for 8 BPP. These will ensure the desired 32-bit row alignment is achieved regardless.

- There's also a small contribution from the additional plane pointers, but this is is not significant except for extremely tiny bitmaps.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
IridiumFX 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 17:24:45
#9 ]
Member
Joined: 7-Apr-2017
Posts: 80
From: London, UK

@Karlos

Let's be real. When it comes to being a PC, nothing beats packed graphics. You don't need a coding exercise, it's evident even with closed eyes.

Planar is undeniably slower, and random pixel access is a nail in its coffin. Yet, it was what the original Amiga design needed.

It made easier to have dual playfieds with the right display adapter. You can check the horrors of the atari forums for examples of pre-shifted sprite charts.

If you want to take it to the extreme, planar would still make sense ... in a purely 2D fantasy world with flexible playfied allocation. Given the complexity of the alpha blending formula and the need to alpha/compose per pixel each layer separately

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 17:30:07
#10 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@IridiumFX

We aren't talking about your mother's packed pixels here though. We're allowing non-power of two depths.

Quote:
Yet, it was what the original Amiga design needed


That's what were here to reflect on, to some extent.

Last edited by Karlos on 05-Jun-2022 at 05:32 PM.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
IridiumFX 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 17:35:27
#11 ]
Member
Joined: 7-Apr-2017
Posts: 80
From: London, UK

@Karlos

packed pixels still hold the advantage. Even if you had 17 bits per pixels, what's that ? a 16 bit load/store and an 8 bit load, mask, store ? in the same cache line because they are sequential ? planar would need 17 plane access right ? without cache to the rescue ?

The speed factor for a single layer is so evident that there's no competition possible. Planar would always lose. It was not made to be fast and it could never be made fast.

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 17:38:00
#12 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@IridiumFX

You'd be surprised how many people don't seem to see that. There was a long, long discussion about it in another thread, so I spun it out here.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 18:08:26
#13 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

I believe that stopped, once I started posting examples.

Last edited by NutsAboutAmiga on 05-Jun-2022 at 06:15 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 06:08 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 19:53:30
#14 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

There's no doubt that pixel plotting in planar is about as bad as it gets. However, for horizontal spans, it out to be the case that you can normalise the difference, particularly for longer spans. There's more indirection for the planar case but it's no longer dominated by the fact you're doing a write per plane since you are setting all bits to a value.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 19:56:39
#15 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

Plotting squares that are 16bit aligned on X axes, where the width is dividable by 16 pixels

Last edited by NutsAboutAmiga on 05-Jun-2022 at 07:57 PM.
Last edited by NutsAboutAmiga on 05-Jun-2022 at 07:57 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 20:42:18
#16 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@NutsAboutAmiga

Why only 16? The challenge is for the bitmap described in the gist. It allows byte and long accesses too.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 21:10:34
#17 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Karlos

I'm thinking Amiga... sure if not a Amiga you can do 32bit,
as I understand it ECS-> AGA only slightly upgraded. and OCS was 16bit.
I can be wrong about this.

Last edited by NutsAboutAmiga on 05-Jun-2022 at 09:11 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
matthey 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 23:24:47
#18 ]
Super Member
Joined: 14-Mar-2007
Posts: 1968
From: Kansas

Packed CLUT format makes sense for 2 (1 bit), 4 (2 bit), 16 (4 bit) and 256 (8 bit) color bitmaps as pixels never cross byte boundaries and remain byte aligned so only need one memory access. The original Amiga chipset did not have enough bandwidth for a 256 color packed CLUT so this would have meant the Amiga only would have had 16 colors max instead of 32 (no 4096 color HAM or 64 color EHB using 6 bit planes either). This would have only affected low resolution which would have been limited to 16 colors like high resolution. Planar also saved some memory if 8 colors (3 bit planes) was adequate. I wonder if there would have been more motivation to upgrade the Amiga custom chips and gfx memory to have enough bandwidth for 256 colors had they gone the packed route. Jay Miner wanted dual ported VRAM for the Ranger chipset upgrade but even it only supported 128 colors (7 bit planes). Planar was more flexible, could save memory and could save bandwidth. Aligned packed mode would have been faster. It should have been possible to make a blitter that could have handled unaligned packed formats but it would have increased complexity.

Original bit plane Amiga
low res: 2, 4, 8, 16, 32 colors + 4096 color HAM6 & 64 color EHB
high res: 2, 4, 8, 16 colors

Upgraded bit plane AGA Amiga
low res: 2, 4, 8, 16, 32, 64, 128, 256 colors + 262,144 color HAM8, 4096 color HAM6 & 64 color EHB
high res: 2, 4, 8, 16, 32, 64, 128, 256 colors + 262,144 color HAM8, 4096 color HAM6 & 64 color EHB

Packed Amiga
low res: 2, 4, 16 colors
high res: 2, 4, 16 colors

Upgraded packed Amiga
low res: 2, 4, 16, 256 colors (packed HAM8?)
high res: 2, 4, 16, 256 colors (packed HAM8?)

All would have likely moved to true 16 bit chunky with no CLUT after this as CBM was planning for AA+. Packed CLUT modes likely would have been faster which may have been noticeable with more colors. Would the packed performance have been more important than the flexibility of planar which allowed more colors and sometimes reduced memory requirements?

Last edited by matthey on 05-Jun-2022 at 11:32 PM.
Last edited by matthey on 05-Jun-2022 at 11:30 PM.
Last edited by matthey on 05-Jun-2022 at 11:27 PM.

 Status: Offline
Profile     Report this post  
Karlos 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 23:48:50
#19 ]
Elite Member
Joined: 24-Aug-2003
Posts: 4394
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@matthey

We aren't talking about vanilla power of two packed pixels in this nerd-off. It's the hypothetical "any bit depth from 1-8" packed pixels versus bit planes, based on the arguments being made in whichever "port to x86" thread before.

Check the gist. It contains test code to create both planar and packed bitmap structures, where the bitmap data are both contiguous and 32-bit aligned at each row, regardless of the depth.

The challenge is to see how such "odd depth" packed pixels, with their awkward dense bit packing that results in some pixels spanning byte boundaries compare to pure planar.

_________________
Doing stupid things for fun...

 Status: Offline
Profile     Report this post  
MEGA_RJ_MICAL 
Re: Packed Versus Planar: FIGHT
Posted on 5-Jun-2022 23:56:51
#20 ]
Super Member
Joined: 13-Dec-2019
Posts: 1200
From: AMIGAWORLD.NET WAS ORIGINALLY FOUNDED BY DAVID DOYLE

PADDING!!!!!!

_________________
I HAVE ABS OF STEEL
--
CAN YOU SEE ME? CAN YOU HEAR ME? OK FOR WORK

 Status: Offline
Profile     Report this post  
Goto page ( 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 Next Page )

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle