f
This commit is contained in:
parent
fc9ab2b5f3
commit
aaead7ed84
|
@ -79,16 +79,16 @@ proc fillUnsafe*(
|
|||
) {.raises: [].} =
|
||||
## Fills the image data with the color starting at index start and
|
||||
## continuing for len indices.
|
||||
let rgbx = color.asRgbx()
|
||||
|
||||
when allowSimd and compiles(fillUnsafeSimd):
|
||||
fillUnsafeSimd(
|
||||
cast[ptr UncheckedArray[ColorRGBX]](data[start].addr),
|
||||
len,
|
||||
rgbx
|
||||
color
|
||||
)
|
||||
return
|
||||
|
||||
let rgbx = color.asRgbx()
|
||||
|
||||
# Use memset when every byte has the same value
|
||||
if rgbx.r == rgbx.g and rgbx.r == rgbx.b and rgbx.r == rgbx.a:
|
||||
nimSetMem(data[start].addr, rgbx.r.cint, len * 4)
|
||||
|
|
|
@ -9,8 +9,10 @@ when defined(release):
|
|||
proc fillUnsafeAvx*(
|
||||
data: ptr UncheckedArray[ColorRGBX],
|
||||
len: int,
|
||||
rgbx: ColorRGBX
|
||||
color: SomeColor
|
||||
) =
|
||||
let rgbx = color.asRgbx()
|
||||
|
||||
var i: int
|
||||
while i < len and (cast[uint](data[i].addr) and 31) != 0: # Align to 32 bytes
|
||||
data[i] = rgbx
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import chroma, vmath
|
||||
import chroma
|
||||
|
||||
when defined(release):
|
||||
{.push checks: off.}
|
||||
|
@ -33,11 +33,13 @@ when defined(amd64):
|
|||
proc fillUnsafeSimd*(
|
||||
data: ptr UncheckedArray[ColorRGBX],
|
||||
len: int,
|
||||
rgbx: ColorRGBX
|
||||
color: SomeColor
|
||||
) =
|
||||
if cpuHasAvx and len >= 64:
|
||||
fillUnsafeAvx(data, len, rgbx)
|
||||
fillUnsafeAvx(data, len, color)
|
||||
else:
|
||||
let rgbx = color.asRgbx()
|
||||
|
||||
var i: int
|
||||
while i < len and (cast[uint](data[i].addr) and 15) != 0: # Align to 16 bytes
|
||||
data[i] = rgbx
|
||||
|
|
Loading…
Reference in a new issue