[PATCH 2/2] fbdev: Improve performance of sys_imageblit()
Thomas Zimmermann
tzimmermann at suse.de
Thu Feb 17 12:08:55 UTC 2022
Hi
Am 17.02.22 um 12:05 schrieb Gerd Hoffmann:
>> - for (j = k; j--; ) {
>> - shift -= ppw;
>> - end_mask = tab[(*src >> shift) & bit_mask];
>> - *dst++ = (end_mask & eorx) ^ bgx;
>> - if (!shift) {
>> - shift = 8;
>> - src++;
>> + for (j = k; j; j -= jdecr, ++src) {
>> + switch (ppw) {
>> + case 4: /* 8 bpp */
>> + *dst++ = colortab[(*src >> 4) & bit_mask];
>> + *dst++ = colortab[(*src >> 0) & bit_mask];
>> + break;
>> + case 2: /* 16 bpp */
>> + *dst++ = colortab[(*src >> 6) & bit_mask];
>> + *dst++ = colortab[(*src >> 4) & bit_mask];
>> + *dst++ = colortab[(*src >> 2) & bit_mask];
>> + *dst++ = colortab[(*src >> 0) & bit_mask];
>> + break;
>> + case 1: /* 32 bpp */
>> + *dst++ = colortab[(*src >> 7) & bit_mask];
>> + *dst++ = colortab[(*src >> 6) & bit_mask];
>> + *dst++ = colortab[(*src >> 5) & bit_mask];
>> + *dst++ = colortab[(*src >> 4) & bit_mask];
>> + *dst++ = colortab[(*src >> 3) & bit_mask];
>> + *dst++ = colortab[(*src >> 2) & bit_mask];
>> + *dst++ = colortab[(*src >> 1) & bit_mask];
>> + *dst++ = colortab[(*src >> 0) & bit_mask];
>> + break;
>> }
>
> How about moving the switch out of the loop, i.e.
>
> switch (ppw) {
> case 4:
> for (j = ...) {
> *dst++ = colortab[(*src >> 4) & bit_mask];
> *dst++ = colortab[(*src >> 0) & bit_mask];
> }
> [ ... ]
> }
>
> ?
No difference. Values for the microbenchmark (rdtsc around
sys_imageblit()) and the directory listing stabilize at the same
numbers. I'll still go with you suggestion, because the code is more
readable.
Best regards
Thomas
>
> take care,
> Gerd
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20220217/6974fc45/attachment.sig>
More information about the dri-devel
mailing list