Pixel Mixer

The Propeller 2 supports a set of four "Pixel Mixer" instructions that are designed to accelerate operations on graphics data, particularily 32 bit RGBA and 8 bit greyscale formats. For 16 bit RGB support, see RGBEXP and RGBSQZ.

All pixel mixer operations perform the following math:

\[\newcommand{\DMIX}{\mathit{DMIX}} \newcommand{\SMIX}{\mathit{SMIX}} D'[31:24] \approx \min\left({{D[31:24] *\DMIX+S[31:24] *\SMIX+255}\over 256},255\right) \\ D'[23:16] \approx \min\left({{D[23:16] *\DMIX+S[23:16] *\SMIX+255}\over 256},255\right) \\ D'[15:~~8] \approx \min\left({{D[15:~~8] *\DMIX+S[15:~~8] *\SMIX+255}\over 256},255\right) \\ D'[~~7:~~0] \approx \min\left({{D[~~7:~~0] *\DMIX+S[~~7:~~0] *\SMIX+255}\over 256},255\right)\]

wherein DMIX and SMIX depend on the instruction:

Instr. DMIX SMIX
ADDPIX 255 255
MULPIX S[byte] 0
BLNPIX 255 - PIV PIV
MIXPIX PIX[5:3] = %000 -> 0
PIX[5:3] = %001 -> 255
PIX[5:3] = %010 -> PIV
PIX[5:3] = %011 -> 255 - PIV
PIX[5:3] = %100 -> S[byte]
PIX[5:3] = %101 -> 255 - S[byte]
PIX[5:3] = %110 -> D[byte]
PIX[5:3] = %111 -> 255 - D[byte]
PIX[2:0] = %000 -> 0
PIX[2:0] = %001 -> 255
PIX[2:0] = %010 -> PIV
PIX[2:0] = %011 -> 255 - PIV
PIX[2:0] = %100 -> S[byte]
PIX[2:0] = %101 -> 255 - S[byte]
PIX[2:0] = %110 -> D[byte]
PIX[2:0] = %111 -> 255 - D[byte]

The equivalent SETPIX value for ADDPIX is %001_001.

The equivalent SETPIX value for MULPIX is %100_000.

The equivalent SETPIX value for BLNPIX is %011_010.

Instructions

ADDPIX D,{#}S - Add colors

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1010010 00I DDDDDDDDD SSSSSSSSS D --- --- 7 7 No

ADDPIX performs a per-byte saturated addition of Source into Destination. I.e. if the addition of a byte overflows, the result is capped to 255.

\[D'[31:24] = \min\left({D[31:24]+S[31:24]},255\right) \\ D'[23:16] = \min\left({D[23:16]+S[23:16]},255\right) \\ D'[15:~~8] = \min\left({D[15:~~8]+S[15:~~8]},255\right) \\ D'[~~7:~~0] = \min\left({D[~~7:~~0]+S[~~7:~~0]},255\right)\]

MULPIX D,{#}S - Multiply colors

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1010010 01I DDDDDDDDD SSSSSSSSS D --- --- 7 7 No

BLNPIX D,{#}S - Blend between colors

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1010010 10I DDDDDDDDD SSSSSSSSS D --- --- 7 7 No

MIXPIX D,{#}S - Generic color mixing operation

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1010010 11I DDDDDDDDD SSSSSSSSS D --- --- 7 7 No

MIXPIX performs an arbitrary pixel mix operation between Source and Destination, as configured by SETPIX. Also see above.

TODO more

SETPIV {#}D - Set blend factor

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1101011 00L DDDDDDDDD 000111101 none --- --- 2 2 No

SETPIX {#}D - Configure MIXPIX

Encoding Register
Written
C Flag Z Flag Cycles
(cogexec)
Cycles
(hubexec)
IRQ
Shield
EEEE 1101011 00L DDDDDDDDD 000111110 none --- --- 2 2 No