simd draw bugfix
This commit is contained in:
parent
47544f64c4
commit
60bcff9bb2
2 changed files with 24 additions and 13 deletions
|
@ -757,24 +757,35 @@ proc drawUber(
|
||||||
when type(a) is Image:
|
when type(a) is Image:
|
||||||
if blendMode.hasSimdBlender():
|
if blendMode.hasSimdBlender():
|
||||||
let blenderSimd = blendMode.blenderSimd()
|
let blenderSimd = blendMode.blenderSimd()
|
||||||
for _ in countup(x, xMax - 4, 4):
|
for _ in countup(x, xMax - 16, 16):
|
||||||
|
# Always take steps of 16 indices since masks will be reading
|
||||||
|
# 16 bytes even if we only use 4 from the last read.
|
||||||
let
|
let
|
||||||
srcPos = p + dx * x.float32 + dy * y.float32
|
srcPos = p + dx * x.float32 + dy * y.float32
|
||||||
sx = srcPos.x.int
|
sx = srcPos.x.int
|
||||||
sy = srcPos.y.int
|
sy = srcPos.y.int
|
||||||
backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr)
|
|
||||||
when type(b) is Image:
|
when type(b) is Image:
|
||||||
let source = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
for q in [0, 4, 8, 12]:
|
||||||
|
let
|
||||||
|
backdrop = mm_loadu_si128(a.data[a.dataIndex(x + q, y)].addr)
|
||||||
|
source = mm_loadu_si128(b.data[b.dataIndex(sx + q, sy)].addr)
|
||||||
|
mm_storeu_si128(
|
||||||
|
a.data[a.dataIndex(x + q, y)].addr,
|
||||||
|
blenderSimd(backdrop, source)
|
||||||
|
)
|
||||||
else: # b is a Mask
|
else: # b is a Mask
|
||||||
# Need to move 4 mask values into the alpha slots
|
var values = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
||||||
var source = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
for q in [0, 4, 8, 12]:
|
||||||
source = unpackAlphaValues(source)
|
let
|
||||||
|
backdrop = mm_loadu_si128(a.data[a.dataIndex(x + q, y)].addr)
|
||||||
mm_storeu_si128(
|
source = unpackAlphaValues(values)
|
||||||
a.data[a.dataIndex(x, y)].addr,
|
mm_storeu_si128(
|
||||||
blenderSimd(backdrop, source)
|
a.data[a.dataIndex(x + q, y)].addr,
|
||||||
)
|
blenderSimd(backdrop, source)
|
||||||
x += 4
|
)
|
||||||
|
# Shuffle 32 bits off for the next iteration
|
||||||
|
values = mm_srli_si128(values, 4)
|
||||||
|
x += 16
|
||||||
else: # is a Mask
|
else: # is a Mask
|
||||||
if blendMode.hasSimdMasker():
|
if blendMode.hasSimdMasker():
|
||||||
let maskerSimd = blendMode.maskerSimd()
|
let maskerSimd = blendMode.maskerSimd()
|
||||||
|
|
|
@ -95,7 +95,7 @@ block:
|
||||||
|
|
||||||
timeIt "shadow":
|
timeIt "shadow":
|
||||||
b.fill(rgba(0, 0, 0, 255))
|
b.fill(rgba(0, 0, 0, 255))
|
||||||
a.draw(b, vec2(25, 25))
|
a.draw(b, translate(vec2(25, 25)))
|
||||||
|
|
||||||
let shadow = a.shadow(
|
let shadow = a.shadow(
|
||||||
offset = vec2(0, 0),
|
offset = vec2(0, 0),
|
||||||
|
|
Loading…
Reference in a new issue