Commit 1860ff95 authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

[507] Fix translucent plots of 32k/64k source into 16M

The combining shifts for
  4k source are  0/4/8   <-- all even, OK
  32k source are 0/5/10
  64k source are 0/5/11
When the destination is a 16M colour mode (ie. full 8bpp mask) this results in an attempt to generate an odd shift of &FF which can't be encoded in a 12b immediate. The code generator asserts ("ror < 32") and thus no plot is produced.

Spot this case and stick in an extra LSL by 1 to ensure the mask can be represented, then compensate with an extra right shift during the combining ORR.

Version 1.85. Tagged as 'SprExtend-1_85'
parent ee46a69f
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "1.84"
Module_Version SETA 184
Module_MajorVersion SETS "1.85"
Module_Version SETA 185
Module_MinorVersion SETS ""
Module_Date SETS "15 Feb 2020"
Module_ApplicationDate SETS "15-Feb-20"
Module_Date SETS "12 May 2021"
Module_ApplicationDate SETS "12-May-21"
Module_ComponentName SETS "SprExtend"
Module_FullVersion SETS "1.84"
Module_HelpVersion SETS "1.84 (15 Feb 2020)"
Module_FullVersion SETS "1.85"
Module_HelpVersion SETS "1.85 (12 May 2021)"
END
/* (1.84)
/* (1.85)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 1.84
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 15 Feb 2020
#define Module_MajorVersion_CMHG 1.85
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 12 May 2021
#define Module_MajorVersion "1.84"
#define Module_Version 184
#define Module_MajorVersion "1.85"
#define Module_Version 185
#define Module_MinorVersion ""
#define Module_Date "15 Feb 2020"
#define Module_Date "12 May 2021"
#define Module_ApplicationDate "15-Feb-20"
#define Module_ApplicationDate "12-May-21"
#define Module_ComponentName "SprExtend"
#define Module_FullVersion "1.84"
#define Module_HelpVersion "1.84 (15 Feb 2020)"
#define Module_LibraryVersionInfo "1:84"
#define Module_FullVersion "1.85"
#define Module_HelpVersion "1.85 (12 May 2021)"
#define Module_LibraryVersionInfo "1:85"
......@@ -3084,7 +3084,7 @@ static PixelFormat blend_rgb(asm_workspace *wp, workspace *ws, PixelFormat in_pi
/* TODO use parallel multiply where possible */
/* Assuming that green is always between the red and blue channels! */
int topmost = MAX(in_fmt->top[0],in_fmt->top[2]);
int bits,mask;
int bits,mask,hardmask1,hardmask2;
/* Process red or blue first - whatever is the lowest component in dest */
/* TODO - if alpha shifted correctly, might be fastest to start with highest in dest? could AND to get src contribution of highest, then shifted ORR to add in lowest */
......@@ -3150,16 +3150,30 @@ static PixelFormat blend_rgb(asm_workspace *wp, workspace *ws, PixelFormat in_pi
/* Add in the other two components via mask & shift */
bits = blend_fmt->bits[2-toggle];
mask = ((1<<bits)-1)<<(in_fmt->top[2-toggle]+alpha_top-bits);
hardmask2 = (bits == 8) && ((in_fmt->top[2-toggle]+alpha_top-bits) & 1);
if(hardmask2)
{
/* Component #2 mask of 0xff at an odd bit offset, shift up 1 so mask can be encoded by IMM12 */
mask = mask << 1;
MOV(R(r_temp2),OP2R(R(r_temp2)) | LSLI(1),"MOV r_temp2,r_temp2,LSL#1 ; LSL to ensure mask imm12");
}
dsprintf((a, "AND r_temp2,r_temp2,#&%x ; Mask src %s",mask,COMPONENT_NAME(2-toggle)));
AND(R(r_temp2),R(r_temp2),IMM12(mask),a);
bits = blend_fmt->bits[1];
mask = ((1<<bits)-1)<<(in_fmt->top[1]+alpha_top-bits);
hardmask1 = (bits == 8) && ((in_fmt->top[1]+alpha_top-bits) & 1);
if(hardmask1)
{
/* Component #1 mask of 0xff at an odd bit offset, shift up 1 so mask can be encoded by IMM12 */
mask = mask << 1;
MOV(R(r_pixel),OP2R(R(r_pixel)) | LSLI(1),"MOV r_pixel,r_pixel,LSL#1 ; LSL to ensure mask imm12");
}
dsprintf((a, "AND r_pixel,r_pixel,#&%x ; Mask src green",mask));
AND(R(r_pixel),R(r_pixel),IMM12(mask),a);
/* Now the shift */
bits = in_fmt->top[2-toggle] + alpha_top - blend_fmt->top[2-toggle];
bits = in_fmt->top[2-toggle] + alpha_top - blend_fmt->top[2-toggle] + hardmask2;
if(bits > 0)
{
dsprintf((a,"ORR r_temp2,r_temp1,r_temp2,LSR #%i ; Add in src %s",bits,COMPONENT_NAME(2-toggle)));
......@@ -3197,7 +3211,7 @@ static PixelFormat blend_rgb(asm_workspace *wp, workspace *ws, PixelFormat in_pi
}
/* Add in sprite green */
bits = in_fmt->top[1] + alpha_top - blend_fmt->top[1];
bits = in_fmt->top[1] + alpha_top - blend_fmt->top[1] + hardmask1;
if(bits > 0)
{
dsprintf((a,"ORR r_pixel,r_temp2,r_pixel,LSR #%i ; Add in src green",bits));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment