forked from mirrors/linux
		
	drm/format-helper: Optimize 32-to-8-bpp conversion
For ease of implementation, existing line-conversion functions for 8-bit formats write each pixel individually. Optimize the performance by writing multiple pixels in a single 32-bit store. v2: - simplify address calculation (Jani) - fix typo in commit message (Jocelyn) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://lore.kernel.org/r/20250328141709.217283-9-tzimmermann@suse.de
This commit is contained in:
		
							parent
							
								
									3f31a017dd
								
							
						
					
					
						commit
						65931bbc51
					
				
					 1 changed files with 20 additions and 1 deletions
				
			
		|  | @ -253,10 +253,29 @@ static __always_inline void drm_fb_xfrm_line_32to8(void *dbuf, const void *sbuf, | ||||||
| 						   unsigned int pixels, | 						   unsigned int pixels, | ||||||
| 						   u32 (*xfrm_pixel)(u32)) | 						   u32 (*xfrm_pixel)(u32)) | ||||||
| { | { | ||||||
| 	u8 *dbuf8 = dbuf; | 	__le32 *dbuf32 = dbuf; | ||||||
|  | 	u8 *dbuf8; | ||||||
| 	const __le32 *sbuf32 = sbuf; | 	const __le32 *sbuf32 = sbuf; | ||||||
| 	const __le32 *send32 = sbuf32 + pixels; | 	const __le32 *send32 = sbuf32 + pixels; | ||||||
| 
 | 
 | ||||||
|  | 	/* write 4 pixels at once */ | ||||||
|  | 	while (sbuf32 < ALIGN_DOWN_PIXELS(send32, pixels, 4)) { | ||||||
|  | 		u32 pix[4] = { | ||||||
|  | 			le32_to_cpup(sbuf32++), | ||||||
|  | 			le32_to_cpup(sbuf32++), | ||||||
|  | 			le32_to_cpup(sbuf32++), | ||||||
|  | 			le32_to_cpup(sbuf32++), | ||||||
|  | 		}; | ||||||
|  | 		/* write output bytes in reverse order for little endianness */ | ||||||
|  | 		u32 val32 = xfrm_pixel(pix[0]) | | ||||||
|  | 			   (xfrm_pixel(pix[1]) << 8) | | ||||||
|  | 			   (xfrm_pixel(pix[2]) << 16) | | ||||||
|  | 			   (xfrm_pixel(pix[3]) << 24); | ||||||
|  | 		*dbuf32++ = cpu_to_le32(val32); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	/* write trailing pixels */ | ||||||
|  | 	dbuf8 = (u8 __force *)dbuf32; | ||||||
| 	while (sbuf32 < send32) | 	while (sbuf32 < send32) | ||||||
| 		*dbuf8++ = xfrm_pixel(le32_to_cpup(sbuf32++)); | 		*dbuf8++ = xfrm_pixel(le32_to_cpup(sbuf32++)); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Thomas Zimmermann
						Thomas Zimmermann