pixieNoSimd
This commit is contained in:
parent
db0ee90fb2
commit
aec3d91109
2 changed files with 10 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
## Blending modes.
|
## Blending modes.
|
||||||
import chroma, math
|
import chroma, math
|
||||||
|
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
import nimsimd/sse2
|
import nimsimd/sse2
|
||||||
|
|
||||||
# See https://www.w3.org/TR/compositing-1/
|
# See https://www.w3.org/TR/compositing-1/
|
||||||
|
@ -264,7 +264,7 @@ proc blendExcludeMaskFloats*(backdrop, source: Color): Color {.inline.} =
|
||||||
proc blendOverwriteFloats*(backdrop, source: Color): Color {.inline.} =
|
proc blendOverwriteFloats*(backdrop, source: Color): Color {.inline.} =
|
||||||
source
|
source
|
||||||
|
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
proc alphaFix(backdrop, source: ColorRGBA, vb, vs, vm: M128): ColorRGBA =
|
proc alphaFix(backdrop, source: ColorRGBA, vb, vs, vm: M128): ColorRGBA =
|
||||||
let
|
let
|
||||||
sa = source.a.float32
|
sa = source.a.float32
|
||||||
|
@ -417,7 +417,7 @@ proc blendSoftLight(backdrop, source: ColorRGBA): ColorRGBA =
|
||||||
# (2 * source * backdrop) div 255
|
# (2 * source * backdrop) div 255
|
||||||
# ).uint8
|
# ).uint8
|
||||||
|
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
let
|
let
|
||||||
vb = mm_setr_ps(backdrop.r.float32, backdrop.g.float32, backdrop.b.float32, 0)
|
vb = mm_setr_ps(backdrop.r.float32, backdrop.g.float32, backdrop.b.float32, 0)
|
||||||
vs = mm_setr_ps(source.r.float32, source.g.float32, source.b.float32, 0)
|
vs = mm_setr_ps(source.r.float32, source.g.float32, source.b.float32, 0)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import chroma, blends, bumpy, vmath, common, nimsimd/sse2, system/memory
|
import chroma, blends, bumpy, vmath, common, system/memory
|
||||||
|
|
||||||
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
|
import nimsimd/sse2
|
||||||
|
|
||||||
const h = 0.5.float32
|
const h = 0.5.float32
|
||||||
|
|
||||||
|
@ -71,7 +74,7 @@ proc fillUnsafe(data: var seq[ColorRGBA], rgba: ColorRGBA, start, len: int) =
|
||||||
nimSetMem(data[start].addr, rgba.r.cint, len * 4)
|
nimSetMem(data[start].addr, rgba.r.cint, len * 4)
|
||||||
else:
|
else:
|
||||||
var i = start
|
var i = start
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
# When supported, SIMD fill until we run out of room
|
# When supported, SIMD fill until we run out of room
|
||||||
let m = mm_set1_epi32(cast[int32](rgba))
|
let m = mm_set1_epi32(cast[int32](rgba))
|
||||||
for j in countup(i, start + len - 8, 8):
|
for j in countup(i, start + len - 8, 8):
|
||||||
|
@ -178,7 +181,7 @@ proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.}
|
||||||
proc invert*(image: Image) =
|
proc invert*(image: Image) =
|
||||||
## Inverts all of the colors and alpha.
|
## Inverts all of the colors and alpha.
|
||||||
var i: int
|
var i: int
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
let vec255 = mm_set1_epi8(255)
|
let vec255 = mm_set1_epi8(255)
|
||||||
while i < image.data.len - 4:
|
while i < image.data.len - 4:
|
||||||
var m = mm_loadu_si128(image.data[i].addr)
|
var m = mm_loadu_si128(image.data[i].addr)
|
||||||
|
@ -196,7 +199,7 @@ proc invert*(image: Image) =
|
||||||
proc toAlphy*(image: Image) =
|
proc toAlphy*(image: Image) =
|
||||||
## Converts an image to premultiplied alpha from straight.
|
## Converts an image to premultiplied alpha from straight.
|
||||||
var i: int
|
var i: int
|
||||||
when defined(amd64):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
# When supported, SIMD convert as much as possible
|
# When supported, SIMD convert as much as possible
|
||||||
let
|
let
|
||||||
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
|
||||||
|
|
Loading…
Reference in a new issue