This commit is contained in:
Ryan Oldenburg 2022-07-27 00:30:29 -05:00
parent 2d39091c44
commit 0e1df4b0c8
2 changed files with 7 additions and 7 deletions

View file

@ -110,7 +110,7 @@ proc toPremultipliedAlphaAvx2*(data: var seq[ColorRGBA | ColorRGBX]) {.simd.} =
oddMask = mm256_set1_epi16(0xff00)
vec128 = mm256_set1_epi16(128)
hiMask = mm256_set1_epi16(255 shl 8)
iterations = data.len div 8
iterations = (data.len - i) div 8
for _ in 0 ..< iterations:
let
values = mm256_load_si256(cast[pointer](p))
@ -163,7 +163,7 @@ proc invertAvx2*(image: Image) {.simd.} =
let
vec255 = mm256_set1_epi8(255)
iterations = image.data.len div 16
iterations = (image.data.len - i) div 16
for _ in 0 ..< iterations:
let
a = mm256_load_si256(cast[pointer](p))
@ -211,7 +211,7 @@ proc applyOpacityAvx2*(image: Image, opacity: float32) {.simd.} =
div255 = mm256_set1_epi16(0x8081)
zeroVec = mm256_setzero_si256()
opacityVec = mm256_slli_epi16(mm256_set1_epi16(opacity), 8)
iterations = image.data.len div 8
iterations = (image.data.len - i) div 8
for _ in 0 ..< iterations:
let
values = mm256_load_si256(cast[pointer](p))
@ -257,7 +257,7 @@ proc ceilAvx2*(image: Image) {.simd.} =
let
vecZero = mm256_setzero_si256()
vec255 = mm256_set1_epi8(255)
iterations = image.data.len div 8
iterations = (image.data.len - i) div 8
for _ in 0 ..< iterations:
var values = mm256_load_si256(cast[pointer](p))
values = mm256_cmpeq_epi8(values, vecZero)

View file

@ -212,7 +212,7 @@ proc invertSse2*(image: Image) {.simd.} =
let
vec255 = mm_set1_epi8(255)
iterations = image.data.len div 16
iterations = (image.data.len - i) div 16
for _ in 0 ..< iterations:
let
a = mm_load_si128(cast[pointer](p))
@ -264,7 +264,7 @@ proc applyOpacitySse2*(image: Image, opacity: float32) {.simd.} =
div255 = mm_set1_epi16(0x8081)
zeroVec = mm_setzero_si128()
opacityVec = mm_slli_epi16(mm_set1_epi16(opacity), 8)
iterations = image.data.len div 4
iterations = (image.data.len - i) div 4
for _ in 0 ..< iterations:
let values = mm_loadu_si128(cast[pointer](p))
if mm_movemask_epi8(mm_cmpeq_epi16(values, zeroVec)) != 0xffff:
@ -308,7 +308,7 @@ proc ceilSse2*(image: Image) {.simd.} =
let
vecZero = mm_setzero_si128()
vec255 = mm_set1_epi8(255)
iterations = image.data.len div 8
iterations = (image.data.len - i) div 8
for _ in 0 ..< iterations:
var
values0 = mm_loadu_si128(cast[pointer](p))