[comp.sys.amiga] rp.Mask and fast graphics

coy@ssc-vax.UUCP (Stephen B Coy) (12/16/87)

	...what's all this talk I hear about lion eaters?

Hi,
    I've got a question about how to get the most speed out of the
Amiga's drawing routines.  In the RastPort structure there is a byte
called Mask which masks off which bitplanes are "drawable" and which
aren't.  What I'd like to know is how deep into the various drawing
routines is this looked at.  ie on a 5-bit deep screen if I want to
do a RectFill in color 4 and I know that the screen is blank (all 0)
do I gain much by setting rp.Mask = 0x04 before making the RectFill
call?  What I'm hoping to hear is that the blitter is only set up
once because only one plane can be drawn to.  Is this true?  I'd be
quite disappointed if I found that the blitter is set up for each
bit plane and then the mask byte is looked at.  Also, how about
WritePixel?  I know the savings on this won't be much but at times
just about anything is useful.

Thanks in advance for any useful insights.

Stephen Coy
uw-beaver!ssc-vax!coy

		"Only the mediocre are always at their best."

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (12/18/87)

In article <1593@ssc-vax.UUCP> coy@ssc-vax.UUCP (Stephen B Coy) writes:
:In the RastPort structure there is a byte
:called Mask which masks off which bitplanes are "drawable" and which
:aren't.  What I'd like to know is how deep into the various drawing
:routines is this looked at.  ie on a 5-bit deep screen if I want to
:do a RectFill in color 4 and I know that the screen is blank (all 0)
:do I gain much by setting rp.Mask = 0x04 before making the RectFill
:call?

	Yup.  The RectFill() call (assuming I'm reading Dale's mind
correctly) will blit into all the planes of the destination.  This includes
zeros.  So setting the RastPort.Mask field will gain you something.  Exactly
how much you will gain depends on how large the rectangle is.

:I'd be quite disappointed if I found that the blitter is set up for each
:bit plane and then the mask byte is looked at.

	You'd lose compute time, yes.  But the real time-sink is the actual
rendering by the blitter.  So you'd still win.  Masks are observed as far
down as BltBitMap(), the work-horse of the rendering system.

:Also, how about
:WritePixel?  I know the savings on this won't be much but at times
:just about anything is useful.
:
	I think the savings on this one are almost negligible, but yes, the
mask field works with this one, too.

:Thanks in advance for any useful insights.
:
	It's nice to see someone else thinking about things of this sort,
too.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	ihnp4!ptsfa -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

bryce@hoser.berkeley.edu (Bryce Nesbitt) (12/19/87)

In article <1593@ssc-vax.UUCP> coy@ssc-vax.UUCP (Stephen B Coy) writes: >
>
>    I've got a question about how to get the most speed out of the
>Amiga's drawing routines. 
>[If I want to] do a RectFill in color 4 and I know that the screen is blank
>(all 0) do I gain much by setting rp.Mask = 0x04 before making the RectFill
>call?

Yes, you gain.  I got some respectible speed increases when playing with
this a while back.  Problem is I ran into a bug**; if you set rp_Mask
of an Intuition window the graphics routines respect this for *all*
operations.  Great, but what about depth gadgets?  You guessed it,
only the selected planes get moved.

** Definition "Bug": something that when I asked Dale Luck about it, he
said "Yeah, that's a bug [...] we'd like to fix that some day."


>Thanks in advance for any useful insights.

You can also get some speed increase in many real applications with
multiple viewports.  In the stripes of screen were you need less colors,
use less bitplanes.

The Atari group is all fired up over the "Colorburst" kludge.  With the
copper you could play the same color-pallete games, but still keep
the CPU speed intact.
I'd like to see a bitplane minimizer that uses the copper to switch
some pallete colors so the picture is not affected at all by the dropped
planes.

|\ /|  . Ack! (NAK, SOH, EOT)
{o O} . bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce (or try "cogsci")
 (")
  U	"Your theory is crazy... but not crazy enought to be true." -Niels Bohr

steveb@cbmvax.UUCP (Steve Beats) (12/22/87)

In article <22238@ucbvax.BERKELEY.EDU> bryce@hoser.berkeley.edu (Bryce Nesbitt) writes:
>I'd like to see a bitplane minimizer that uses the copper to switch
>some pallete colors so the picture is not affected at all by the dropped
>planes.

I played around with this for a while way back there when we got our first
Amigas.  The first hack I did managed to get all 4096 colors onto a 0, yes
zero, bit-plane display.  You will find that the copper only has a set amount
of discrete positions where the display color can be changed. Using the
following copper instructions:-

	CWAIT row,column
	CMOVE color,color0
	CMOVE color,color0
	CMOVE color,color0
	...

allows you to change color0 once every 4 pixels in lores mode.  This bandwidth
is halved in hi-res mode (actually it stays the same but the pixel bandwidth
doubles) so you can only change the colors every 8 pixels.

I did find a useful place for this though.  You know those annoying fringes in
HAM mode, this technique works really well for getting rid of them.  Basically
you have to scan the line you are interested in and use the CPU to find out
which pixels are furthest from the desired color and replace them with a real
color from the pallette (1-15).  Do this recursively for 14 colors and re-do
the HAM calculations after each pass.  Once you've done this, construct a
copper list that WAITs for the end of the line above and then loads the pallette
with the 14 colors you just calculated.  Repeat for all lines of the display.
The resultant images are really good (I used some demo images from digiview).

Sidenote:  The only real way to store this in an IFF compatible format is to
save the image as 12 bitplane data and re-calculate the copper list each time
the picture is displayed.  Wouldn't it be nice if there was an IFF form to
save the copper list directly (Carolyn). :-)

	Steve Beats