Source file
test/simd/bug2.go
1
2
3
4
5
6
7
8
9
10
11
12 package p
13
14 import (
15 "simd"
16 )
17
18 func PackComplex(b bool) {
19 for {
20 if b {
21 var indices [4]uint32
22 simd.Uint32x4{}.ShiftAllRight(20).Store(&indices)
23 _ = indices[indices[0]]
24 }
25 }
26 }
27
28 func PackComplex2(x0 uint16, src [][4]float32, b, b2 bool) {
29 var out [][4]byte
30 if b2 {
31 for y := range x0 {
32 row := out[:x0]
33 for x := range row {
34 px := &src[y]
35 if b {
36 var indices [4]uint32
37 fu := simd.LoadFloat32x4(px).AsUint32x4()
38 fu.ShiftAllRight(0).Store(nil)
39 entry := simd.LoadUint32x4(&[4]uint32{
40 toSrgbTable[indices[0]],
41 })
42 var res [4]uint32
43 entry.ShiftAllRight(19).Store(nil)
44 row[x] = [4]uint8{
45 uint8(res[0]),
46 uint8(res[1]),
47 uint8(res[2]),
48 }
49 } else {
50 row[x] = [4]uint8{
51 float32ToSrgb8(0),
52 float32ToSrgb8(1),
53 float32ToSrgb8(2),
54 }
55 }
56 }
57 out = out[len(out):]
58 }
59 }
60 }
61
62 var toSrgbTable = [4]uint32{}
63
64 func float32ToSrgb8(f float32) uint8 {
65 f = min(0, f)
66 fu := uint32(f)
67 entry := toSrgbTable[fu]
68 return uint8(entry * fu)
69 }
70
View as plain text