OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 The Android Open Source Project |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #if defined(__clang__) || (defined(__GNUC__) && !defined(SK_BUILD_FOR_MAC)) |
| 9 |
| 10 #define EXTRACT_ALPHA(var1, var2) \ |
| 11 movdqa %var1, %var2; /* Clone source pixels to extract alpha
*/\ |
| 12 psrlw $8, %var2; /* Discard red and blue, leaving alpha a
nd green */\ |
| 13 pshufhw $0xF5, %var2, %var2; /* Repeat alpha for scaling (high) */\ |
| 14 movdqa %xmm6, %xmm4; \ |
| 15 pshuflw $0xF5, %var2, %var2; /* Repeat alpha for scaling (low) */\ |
| 16 movdqa %xmm5, %xmm3; \ |
| 17 psubw %var2, %xmm4 /* Finalize alpha calculations */ |
| 18 |
| 19 #define SCALE_PIXELS \ |
| 20 psllw $8, %xmm5; /* Filter out red and blue components */
\ |
| 21 pmulhuw %xmm4, %xmm5; /* Scale red and blue */\ |
| 22 psrlw $8, %xmm3; /* Filter out alpha and green components
*/\ |
| 23 pmullw %xmm4, %xmm3 /* Scale alpha and green */ |
| 24 |
| 25 |
| 26 /* |
| 27 * void S32A_Opaque_BlitRow32_SSE4(SkPMColor* SK_RESTRICT dst, |
| 28 * const SkPMColor* SK_RESTRICT src, |
| 29 * int count, U8CPU alpha) |
| 30 * |
| 31 * This function is divided into six blocks: initialization, blit 4-15 pixels, |
| 32 * blit 0-3 pixels, align destination for 16+ pixel blits, |
| 33 * blit 16+ pixels with source unaligned, blit 16+ pixels with source aligned. |
| 34 * There are some code reuse between the blocks. |
| 35 * |
| 36 * The primary optimization comes from checking the source pixels' alpha value. |
| 37 * If the alpha is zero, the pixel can be skipped entirely. |
| 38 * If the alpha is fully opaque, the pixel can be copied directly to the destina
tion. |
| 39 * According to collected statistics, these two cases are the most common. |
| 40 * The main loop(s) uses pre-loading and unrolling in an attempt to reduce the |
| 41 * memory latency worse-case. |
| 42 */ |
| 43 |
| 44 #ifdef __clang__ |
| 45 .text |
| 46 #else |
| 47 .section .text.sse4.2,"ax",@progbits |
| 48 .type S32A_Opaque_BlitRow32_SSE4_asm, @function |
| 49 #endif |
| 50 .p2align 4 |
| 51 #if defined(__clang__) && defined(SK_BUILD_FOR_MAC) |
| 52 .global _S32A_Opaque_BlitRow32_SSE4_asm |
| 53 _S32A_Opaque_BlitRow32_SSE4_asm: |
| 54 #else |
| 55 .global S32A_Opaque_BlitRow32_SSE4_asm |
| 56 S32A_Opaque_BlitRow32_SSE4_asm: |
| 57 #endif |
| 58 .cfi_startproc |
| 59 prefetcht0 (%rsi) |
| 60 movl %edx, %ecx // Pixel count |
| 61 movq %rdi, %rdx // Destination pointer |
| 62 movq %rsi, %rax // Source pointer |
| 63 |
| 64 // Setup SSE constants |
| 65 movdqa .LAlphaCheckMask(%rip), %xmm7 // 0xFF000000 mask to check alpha |
| 66 movdqa .LInverseAlphaCalc(%rip), %xmm6// 16-bit 256 to calculate inv. a
lpha |
| 67 movdqa .LResultMergeMask(%rip), %xmm0 // 0x00FF00FF mask (Must be in xm
m0 because of pblendvb) |
| 68 |
| 69 subl $4, %ecx // Check if we have only 0-3 pixels |
| 70 js .LReallySmall |
| 71 cmpl $11, %ecx // Do we have enough pixels to run the m
ain loop? |
| 72 ja .LBigBlit |
| 73 |
| 74 // Handle small blits (4-15 pixels) |
| 75 ////////////////////////////////////////////////////////////////////////////
//// |
| 76 xorq %rdi, %rdi // Reset offset to zero |
| 77 |
| 78 .LSmallLoop: |
| 79 lddqu (%rax, %rdi), %xmm1 // Load four source pixels |
| 80 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 81 ja .LSmallAlphaNotOpaqueOrZero |
| 82 jz .LSmallAlphaZero |
| 83 movdqu %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 84 .LSmallAlphaZero: |
| 85 addq $16, %rdi |
| 86 subl $4, %ecx // Check if there are four additional pi
xels, at least |
| 87 jns .LSmallLoop |
| 88 jmp .LSmallRemaining |
| 89 |
| 90 // Handle mixed alphas (calculate and scale) |
| 91 .p2align 4 |
| 92 .LSmallAlphaNotOpaqueOrZero: |
| 93 lddqu (%rdx, %rdi), %xmm5 // Load four destination pixels |
| 94 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 95 SCALE_PIXELS // Scale pixels using alpha |
| 96 |
| 97 addq $16, %rdi |
| 98 subl $4, %ecx // Check if there are four additional pi
xels, at least |
| 99 pblendvb %xmm5, %xmm3 // Mask in %xmm0, implicitly |
| 100 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 101 movdqu %xmm1, -16(%rdx, %rdi) // Store four destination pixels |
| 102 jns .LSmallLoop |
| 103 |
| 104 // Handle the last 0-3 pixels (also used by the main loops) |
| 105 .LSmallRemaining: |
| 106 cmpl $-4, %ecx // Check if we are done |
| 107 je .LSmallExit |
| 108 sall $2, %ecx // Calculate offset for last pixels |
| 109 movslq %ecx, %rcx |
| 110 addq %rcx, %rdi |
| 111 |
| 112 lddqu (%rax, %rdi), %xmm1 // Load last four source pixels (overlap
ping) |
| 113 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 114 jc .LSmallRemainingStoreAll// If all alphas are opaque, just store
(overlapping) |
| 115 jz .LSmallExit // If all alphas are zero, skip the pixe
ls completely |
| 116 |
| 117 // Handle mixed alphas (calculate and scale) |
| 118 lddqu (%rdx, %rdi), %xmm5 // Load last four destination pixels (ov
erlapping) |
| 119 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 120 |
| 121 psllw $8, %xmm3 // Filter out red and blue components |
| 122 pmulhuw %xmm4, %xmm3 // Scale red and blue |
| 123 movdqa %xmm5, %xmm2 |
| 124 psrlw $8, %xmm2 // Filter out alpha and green components |
| 125 pmullw %xmm4, %xmm2 // Scale alpha and green |
| 126 |
| 127 cmpl $-8, %ecx // Check how many pixels should be writt
en |
| 128 pblendvb %xmm3, %xmm2 // Combine results (mask in %xmm0, impli
citly) |
| 129 paddb %xmm2, %xmm1 // Add source and destination pixels tog
ether |
| 130 jb .LSmallPixelsLeft1 |
| 131 ja .LSmallPixelsLeft3 // To avoid double-blending the overlapp
ing pixels... |
| 132 pblendw $0xF0, %xmm1, %xmm5 // Merge only the final two pixels to th
e destination |
| 133 movdqu %xmm5, (%rdx, %rdi) // Store last two destination pixels |
| 134 .LSmallExit: |
| 135 ret |
| 136 |
| 137 .LSmallPixelsLeft1: |
| 138 pblendw $0xC0, %xmm1, %xmm5 // Merge only the final pixel to the des
tination |
| 139 movdqu %xmm5, (%rdx, %rdi) // Store last destination pixel |
| 140 ret |
| 141 |
| 142 .LSmallPixelsLeft3: |
| 143 pblendw $0xFC, %xmm1, %xmm5 // Merge only the final three pixels to
the destination |
| 144 movdqu %xmm5, (%rdx, %rdi) // Store last three destination pixels |
| 145 ret |
| 146 |
| 147 .LSmallRemainingStoreAll: |
| 148 movdqu %xmm1, (%rdx, %rdi) // Store last destination pixels (overwr
ite) |
| 149 ret |
| 150 |
| 151 // Handle really small blits (0-3 pixels) |
| 152 ////////////////////////////////////////////////////////////////////////////
//// |
| 153 .LReallySmall: |
| 154 addl $4, %ecx |
| 155 jle .LReallySmallExit |
| 156 pcmpeqd %xmm1, %xmm1 |
| 157 cmpl $2, %ecx // Check how many pixels should be read |
| 158 pinsrd $0x0, (%rax), %xmm1 // Load one source pixel |
| 159 pinsrd $0x0, (%rdx), %xmm5 // Load one destination pixel |
| 160 jb .LReallySmallCalc |
| 161 pinsrd $0x1, 4(%rax), %xmm1 // Load second source pixel |
| 162 pinsrd $0x1, 4(%rdx), %xmm5 // Load second destination pixel |
| 163 je .LReallySmallCalc |
| 164 pinsrd $0x2, 8(%rax), %xmm1 // Load third source pixel |
| 165 pinsrd $0x2, 8(%rdx), %xmm5 // Load third destination pixel |
| 166 |
| 167 .LReallySmallCalc: |
| 168 ptest %xmm7, %xmm1 // Check if all alphas are opaque |
| 169 jc .LReallySmallStore // If all alphas are opaque, just store |
| 170 |
| 171 // Handle mixed alphas (calculate and scale) |
| 172 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 173 |
| 174 pand %xmm0, %xmm5 // Filter out red and blue components |
| 175 pmullw %xmm4, %xmm5 // Scale red and blue |
| 176 psrlw $8, %xmm3 // Filter out alpha and green components |
| 177 pmullw %xmm4, %xmm3 // Scale alpha and green |
| 178 |
| 179 psrlw $8, %xmm5 // Combine results |
| 180 pblendvb %xmm5, %xmm3 // Mask in %xmm0, implicitly |
| 181 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 182 |
| 183 .LReallySmallStore: |
| 184 cmpl $2, %ecx // Check how many pixels should be writt
en |
| 185 pextrd $0x0, %xmm1, (%rdx) // Store one destination pixel |
| 186 jb .LReallySmallExit |
| 187 pextrd $0x1, %xmm1, 4(%rdx) // Store second destination pixel |
| 188 je .LReallySmallExit |
| 189 pextrd $0x2, %xmm1, 8(%rdx) // Store third destination pixel |
| 190 .LReallySmallExit: |
| 191 ret |
| 192 |
| 193 // Handle bigger blit operations (16+ pixels) |
| 194 ////////////////////////////////////////////////////////////////////////////
//// |
| 195 .p2align 4 |
| 196 .LBigBlit: |
| 197 // Align destination? |
| 198 testl $0xF, %edx |
| 199 lddqu (%rax), %xmm1 // Pre-load four source pixels |
| 200 jz .LAligned |
| 201 |
| 202 movq %rdx, %rdi // Calculate alignment of destination po
inter |
| 203 negq %rdi |
| 204 andl $0xF, %edi |
| 205 |
| 206 // Handle 1-3 pixels to align destination |
| 207 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 208 jz .LAlignDone // If all alphas are zero, just skip |
| 209 lddqu (%rdx), %xmm5 // Load four destination pixels |
| 210 jc .LAlignStore // If all alphas are opaque, just store |
| 211 |
| 212 // Handle mixed alphas (calculate and scale) |
| 213 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 214 |
| 215 psllw $8, %xmm3 // Filter out red and blue components |
| 216 pmulhuw %xmm4, %xmm3 // Scale red and blue |
| 217 movdqa %xmm5, %xmm2 |
| 218 psrlw $8, %xmm2 // Filter out alpha and green components |
| 219 pmullw %xmm4, %xmm2 // Scale alpha and green |
| 220 |
| 221 pblendvb %xmm3, %xmm2 // Combine results (mask in %xmm0, impli
citly) |
| 222 paddb %xmm2, %xmm1 // Add source and destination pixels tog
ether |
| 223 |
| 224 .LAlignStore: |
| 225 cmpl $8, %edi // Check how many pixels should be writt
en |
| 226 jb .LAlignPixelsLeft1 |
| 227 ja .LAlignPixelsLeft3 |
| 228 pblendw $0x0F, %xmm1, %xmm5 // Blend two pixels |
| 229 jmp .LAlignStorePixels |
| 230 |
| 231 .LAlignPixelsLeft1: |
| 232 pblendw $0x03, %xmm1, %xmm5 // Blend one pixel |
| 233 jmp .LAlignStorePixels |
| 234 |
| 235 .LAlignPixelsLeft3: |
| 236 pblendw $0x3F, %xmm1, %xmm5 // Blend three pixels |
| 237 |
| 238 .LAlignStorePixels: |
| 239 movdqu %xmm5, (%rdx) // Store destination pixels |
| 240 |
| 241 .LAlignDone: |
| 242 addq %rdi, %rax // Adjust pointers and pixel count |
| 243 addq %rdi, %rdx |
| 244 shrq $2, %rdi |
| 245 lddqu (%rax), %xmm1 // Pre-load new source pixels (after ali
gnment) |
| 246 subl %edi, %ecx |
| 247 |
| 248 .LAligned: // Destination is guaranteed to be 16 by
te aligned |
| 249 xorq %rdi, %rdi // Reset offset to zero |
| 250 subl $8, %ecx // Decrease counter (Reserve four pixels
for the cleanup) |
| 251 testl $0xF, %eax // Check alignment of source pointer |
| 252 jz .LAlignedLoop |
| 253 |
| 254 // Source not aligned to destination |
| 255 ////////////////////////////////////////////////////////////////////////////
//// |
| 256 .p2align 4 |
| 257 .LUnalignedLoop: // Main loop for unaligned, handles eigh
t pixels per iteration |
| 258 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 259 ja .LAlphaNotOpaqueOrZero00 |
| 260 lddqu 16(%rax, %rdi), %xmm2 // Pre-load four source pixels |
| 261 jz .LAlphaZero00 |
| 262 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 263 |
| 264 .LAlphaZero00: |
| 265 ptest %xmm7, %xmm2 // Check if all alphas are zero or opaqu
e |
| 266 ja .LAlphaNotOpaqueOrZero01 |
| 267 lddqu 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 268 jz .LAlphaZero01 |
| 269 movdqa %xmm2, 16(%rdx, %rdi) // Store four destination pixels |
| 270 |
| 271 .LAlphaZero01: |
| 272 addq $32, %rdi // Adjust offset and pixel count |
| 273 subl $8, %ecx |
| 274 jae .LUnalignedLoop |
| 275 addl $8, %ecx // Adjust pixel count |
| 276 jmp .LLoopCleanup0 |
| 277 |
| 278 .p2align 4 |
| 279 .LAlphaNotOpaqueOrZero00: |
| 280 movdqa (%rdx, %rdi), %xmm5 // Load four destination pixels |
| 281 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 282 SCALE_PIXELS // Scale pixels using alpha |
| 283 |
| 284 lddqu 16(%rax, %rdi), %xmm2 // Pre-load four source pixels |
| 285 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 286 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 287 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 288 |
| 289 // Handle next four pixels |
| 290 ptest %xmm7, %xmm2 // Check if all alphas are zero or opaqu
e |
| 291 ja .LAlphaNotOpaqueOrZero01 |
| 292 lddqu 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 293 jz .LAlphaZero02 |
| 294 movdqa %xmm2, 16(%rdx, %rdi) // Store four destination pixels |
| 295 .LAlphaZero02: |
| 296 addq $32, %rdi // Adjust offset and pixel count |
| 297 subl $8, %ecx |
| 298 jae .LUnalignedLoop |
| 299 addl $8, %ecx // Adjust pixel count |
| 300 jmp .LLoopCleanup0 |
| 301 |
| 302 .p2align 4 |
| 303 .LAlphaNotOpaqueOrZero01: |
| 304 movdqa 16(%rdx, %rdi), %xmm5 // Load four destination pixels |
| 305 EXTRACT_ALPHA(xmm2, xmm1) // Extract and clone alpha value |
| 306 SCALE_PIXELS // Scale pixels using alpha |
| 307 |
| 308 lddqu 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 309 addq $32, %rdi |
| 310 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 311 paddb %xmm3, %xmm2 // Add source and destination pixels tog
ether |
| 312 subl $8, %ecx |
| 313 movdqa %xmm2, -16(%rdx, %rdi) // Store four destination pixels |
| 314 jae .LUnalignedLoop |
| 315 addl $8, %ecx // Adjust pixel count |
| 316 |
| 317 // Cleanup - handle pending pixels from loop |
| 318 .LLoopCleanup0: |
| 319 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 320 ja .LAlphaNotOpaqueOrZero02 |
| 321 jz .LAlphaZero03 |
| 322 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 323 .LAlphaZero03: |
| 324 addq $16, %rdi |
| 325 subl $4, %ecx |
| 326 js .LSmallRemaining // Reuse code from small loop |
| 327 |
| 328 .LRemain0: |
| 329 lddqu (%rax, %rdi), %xmm1 // Load four source pixels |
| 330 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 331 ja .LAlphaNotOpaqueOrZero02 |
| 332 jz .LAlphaZero04 |
| 333 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 334 .LAlphaZero04: |
| 335 addq $16, %rdi |
| 336 subl $4, %ecx |
| 337 jmp .LSmallRemaining // Reuse code from small loop |
| 338 |
| 339 .LAlphaNotOpaqueOrZero02: |
| 340 movdqa (%rdx, %rdi), %xmm5 // Load four destination pixels |
| 341 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 342 SCALE_PIXELS // Scale pixels using alpha |
| 343 |
| 344 addq $16, %rdi |
| 345 subl $4, %ecx |
| 346 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 347 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 348 movdqa %xmm1, -16(%rdx, %rdi) // Store four destination pixels |
| 349 js .LSmallRemaining // Reuse code from small loop |
| 350 jmp .LRemain0 |
| 351 |
| 352 // Source aligned to destination |
| 353 ////////////////////////////////////////////////////////////////////////////
//// |
| 354 .p2align 4 |
| 355 .LAlignedLoop: // Main loop for aligned, handles eight
pixels per iteration |
| 356 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 357 ja .LAlphaNotOpaqueOrZero10 |
| 358 movdqa 16(%rax, %rdi), %xmm2 // Pre-load four source pixels |
| 359 jz .LAlphaZero10 |
| 360 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 361 |
| 362 .LAlphaZero10: |
| 363 ptest %xmm7, %xmm2 // Check if all alphas are zero or opaqu
e |
| 364 ja .LAlphaNotOpaqueOrZero11 |
| 365 movdqa 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 366 jz .LAlphaZero11 |
| 367 movdqa %xmm2, 16(%rdx, %rdi) // Store four destination pixels |
| 368 |
| 369 .LAlphaZero11: |
| 370 addq $32, %rdi // Adjust offset and pixel count |
| 371 subl $8, %ecx |
| 372 jae .LAlignedLoop |
| 373 addl $8, %ecx // Adjust pixel count |
| 374 jmp .LLoopCleanup1 |
| 375 |
| 376 .p2align 4 |
| 377 .LAlphaNotOpaqueOrZero10: |
| 378 movdqa (%rdx, %rdi), %xmm5 // Load four destination pixels |
| 379 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 380 SCALE_PIXELS // Scale pixels using alpha |
| 381 |
| 382 movdqa 16(%rax, %rdi), %xmm2 // Pre-load four source pixels |
| 383 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 384 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 385 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 386 |
| 387 // Handle next four pixels |
| 388 ptest %xmm7, %xmm2 // Check if all alphas are zero or opaqu
e |
| 389 ja .LAlphaNotOpaqueOrZero11 |
| 390 movdqa 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 391 jz .LAlphaZero12 |
| 392 movdqa %xmm2, 16(%rdx, %rdi) // Store four destination pixels |
| 393 .LAlphaZero12: |
| 394 addq $32, %rdi // Adjust offset and pixel count |
| 395 subl $8, %ecx |
| 396 jae .LAlignedLoop |
| 397 addl $8, %ecx // Adjust pixel count |
| 398 jmp .LLoopCleanup1 |
| 399 |
| 400 .p2align 4 |
| 401 .LAlphaNotOpaqueOrZero11: |
| 402 movdqa 16(%rdx, %rdi), %xmm5 // Load four destination pixels |
| 403 EXTRACT_ALPHA(xmm2, xmm1) // Extract and clone alpha value |
| 404 SCALE_PIXELS // Scale pixels using alpha |
| 405 movdqa 32(%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 406 |
| 407 addq $32, %rdi |
| 408 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 409 paddb %xmm3, %xmm2 // Add source and destination pixels tog
ether |
| 410 subl $8, %ecx |
| 411 movdqa %xmm2, -16(%rdx, %rdi) // Store four destination pixels |
| 412 jae .LAlignedLoop |
| 413 addl $8, %ecx // Adjust pixel count |
| 414 |
| 415 // Cleanup - handle four pending pixels from loop |
| 416 .LLoopCleanup1: |
| 417 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 418 ja .LAlphaNotOpaqueOrZero12 |
| 419 jz .LAlphaZero13 |
| 420 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 421 .LAlphaZero13: |
| 422 addq $16, %rdi |
| 423 subl $4, %ecx |
| 424 js .LSmallRemaining // Reuse code from small loop |
| 425 |
| 426 .LRemain1: |
| 427 movdqa (%rax, %rdi), %xmm1 // Pre-load four source pixels |
| 428 ptest %xmm7, %xmm1 // Check if all alphas are zero or opaqu
e |
| 429 ja .LAlphaNotOpaqueOrZero12 |
| 430 jz .LAlphaZero14 |
| 431 movdqa %xmm1, (%rdx, %rdi) // Store four destination pixels |
| 432 .LAlphaZero14: |
| 433 addq $16, %rdi |
| 434 subl $4, %ecx |
| 435 jmp .LSmallRemaining // Reuse code from small loop |
| 436 |
| 437 .LAlphaNotOpaqueOrZero12: |
| 438 movdqa (%rdx, %rdi), %xmm5 // Load four destination pixels |
| 439 EXTRACT_ALPHA(xmm1, xmm2) // Extract and clone alpha value |
| 440 SCALE_PIXELS // Scale pixels using alpha |
| 441 |
| 442 addq $16, %rdi |
| 443 subl $4, %ecx |
| 444 pblendvb %xmm5, %xmm3 // Combine results (mask in %xmm0, impli
citly) |
| 445 paddb %xmm3, %xmm1 // Add source and destination pixels tog
ether |
| 446 movdqa %xmm1, -16(%rdx, %rdi) // Store four destination pixels |
| 447 js .LSmallRemaining // Reuse code from small loop |
| 448 jmp .LRemain1 |
| 449 |
| 450 .cfi_endproc |
| 451 #ifndef __clang__ |
| 452 .size S32A_Opaque_BlitRow32_SSE4_asm, .-S32A_Opaque_BlitRow32_SSE4_asm |
| 453 #endif |
| 454 |
| 455 // Constants for SSE code |
| 456 #ifndef __clang__ |
| 457 .section .rodata |
| 458 #endif |
| 459 .p2align 4 |
| 460 .LAlphaCheckMask: |
| 461 .long 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000 |
| 462 .LInverseAlphaCalc: |
| 463 .word 256, 256, 256, 256, 256, 256, 256, 256 |
| 464 .LResultMergeMask: |
| 465 .long 0x00FF00FF, 0x00FF00FF, 0x00FF00FF, 0x00FF00FF |
| 466 #endif |
OLD | NEW |