@@ -19,49 +19,48 @@ namespace SixLabors.ImageSharp;
19
19
internal interface IComponentShuffle
20
20
{
21
21
/// <summary>
22
- /// Shuffles then slices 8-bit integers within 128-bit lanes in <paramref name="source"/>
23
- /// using the control and store the results in <paramref name="dest"/>.
22
+ /// Shuffles then slices 8-bit integers in <paramref name="source"/>
23
+ /// using the control and store the results in <paramref name="destination"/>.
24
+ /// If successful, this method will reduce the length of <paramref name="source"/> length
25
+ /// by the shuffle amount.
24
26
/// </summary>
25
27
/// <param name="source">The source span of bytes.</param>
26
- /// <param name="dest ">The destination span of bytes.</param>
27
- void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest ) ;
28
+ /// <param name="destination ">The destination span of bytes.</param>
29
+ void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination ) ;
28
30
29
31
/// <summary>
30
- /// Shuffle 8-bit integers within 128-bit lanes in <paramref name="source"/>
31
- /// using the control and store the results in <paramref name="dest "/>.
32
+ /// Shuffle 8-bit integers in <paramref name="source"/>
33
+ /// using the control and store the results in <paramref name="destination "/>.
32
34
/// </summary>
33
35
/// <param name="source">The source span of bytes.</param>
34
- /// <param name="dest ">The destination span of bytes.</param>
36
+ /// <param name="destination ">The destination span of bytes.</param>
35
37
/// <remarks>
36
- /// Implementation can assume that source.Length is less or equal than dest .Length.
38
+ /// Implementation can assume that source.Length is less or equal than destination .Length.
37
39
/// Loops should iterate using source.Length.
38
40
/// </remarks>
39
- void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest ) ;
41
+ void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination ) ;
40
42
}
41
43
42
44
/// <inheritdoc/>
43
45
internal interface IShuffle4 : IComponentShuffle
44
46
{
45
47
}
46
48
47
- internal readonly struct DefaultShuffle4 : IShuffle4
49
+ internal readonly struct DefaultShuffle4 ( byte control ) : IShuffle4
48
50
{
49
- public DefaultShuffle4 ( byte control )
50
- => this . Control = control ;
51
-
52
- public byte Control { get ; }
51
+ public byte Control { get ; } = control ;
53
52
54
53
[ MethodImpl ( InliningOptions . ShortMethod ) ]
55
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
56
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , this . Control ) ;
54
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
55
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , this . Control ) ;
57
56
58
57
[ MethodImpl ( InliningOptions . ShortMethod ) ]
59
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
58
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
60
59
{
61
60
ref byte sBase = ref MemoryMarshal . GetReference ( source ) ;
62
- ref byte dBase = ref MemoryMarshal . GetReference ( dest ) ;
61
+ ref byte dBase = ref MemoryMarshal . GetReference ( destination ) ;
63
62
64
- Shuffle . InverseMMShuffle ( this . Control , out uint p3 , out uint p2 , out uint p1 , out uint p0 ) ;
63
+ SimdUtils . Shuffle . InverseMMShuffle ( this . Control , out uint p3 , out uint p2 , out uint p1 , out uint p0 ) ;
65
64
66
65
for ( nuint i = 0 ; i < ( uint ) source . Length ; i += 4 )
67
66
{
@@ -76,14 +75,14 @@ public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest)
76
75
internal readonly struct WXYZShuffle4 : IShuffle4
77
76
{
78
77
[ MethodImpl ( InliningOptions . ShortMethod ) ]
79
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
80
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , Shuffle . MMShuffle2103 ) ;
78
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
79
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , SimdUtils . Shuffle . MMShuffle2103 ) ;
81
80
82
81
[ MethodImpl ( InliningOptions . ShortMethod ) ]
83
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
82
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
84
83
{
85
84
ref uint sBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( source ) ) ;
86
- ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( dest ) ) ;
85
+ ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( destination ) ) ;
87
86
uint n = ( uint ) source . Length / 4 ;
88
87
89
88
for ( nuint i = 0 ; i < n ; i ++ )
@@ -100,14 +99,14 @@ public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest)
100
99
internal readonly struct WZYXShuffle4 : IShuffle4
101
100
{
102
101
[ MethodImpl ( InliningOptions . ShortMethod ) ]
103
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
104
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , Shuffle . MMShuffle0123 ) ;
102
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
103
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , SimdUtils . Shuffle . MMShuffle0123 ) ;
105
104
106
105
[ MethodImpl ( InliningOptions . ShortMethod ) ]
107
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
106
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
108
107
{
109
108
ref uint sBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( source ) ) ;
110
- ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( dest ) ) ;
109
+ ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( destination ) ) ;
111
110
uint n = ( uint ) source . Length / 4 ;
112
111
113
112
for ( nuint i = 0 ; i < n ; i ++ )
@@ -124,14 +123,14 @@ public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest)
124
123
internal readonly struct YZWXShuffle4 : IShuffle4
125
124
{
126
125
[ MethodImpl ( InliningOptions . ShortMethod ) ]
127
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
128
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , Shuffle . MMShuffle0321 ) ;
126
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
127
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , SimdUtils . Shuffle . MMShuffle0321 ) ;
129
128
130
129
[ MethodImpl ( InliningOptions . ShortMethod ) ]
131
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
130
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
132
131
{
133
132
ref uint sBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( source ) ) ;
134
- ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( dest ) ) ;
133
+ ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( destination ) ) ;
135
134
uint n = ( uint ) source . Length / 4 ;
136
135
137
136
for ( nuint i = 0 ; i < n ; i ++ )
@@ -148,14 +147,14 @@ public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest)
148
147
internal readonly struct ZYXWShuffle4 : IShuffle4
149
148
{
150
149
[ MethodImpl ( InliningOptions . ShortMethod ) ]
151
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
152
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , Shuffle . MMShuffle3012 ) ;
150
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
151
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , SimdUtils . Shuffle . MMShuffle3012 ) ;
153
152
154
153
[ MethodImpl ( InliningOptions . ShortMethod ) ]
155
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
154
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
156
155
{
157
156
ref uint sBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( source ) ) ;
158
- ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( dest ) ) ;
157
+ ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( destination ) ) ;
159
158
uint n = ( uint ) source . Length / 4 ;
160
159
161
160
for ( nuint i = 0 ; i < n ; i ++ )
@@ -179,14 +178,14 @@ public void RunFallbackShuffle(ReadOnlySpan<byte> source, Span<byte> dest)
179
178
internal readonly struct XWZYShuffle4 : IShuffle4
180
179
{
181
180
[ MethodImpl ( InliningOptions . ShortMethod ) ]
182
- public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > dest )
183
- => HwIntrinsics . Shuffle4Reduce ( ref source , ref dest , Shuffle . MMShuffle1230 ) ;
181
+ public void ShuffleReduce ( ref ReadOnlySpan < byte > source , ref Span < byte > destination )
182
+ => HwIntrinsics . Shuffle4Reduce ( ref source , ref destination , SimdUtils . Shuffle . MMShuffle1230 ) ;
184
183
185
184
[ MethodImpl ( InliningOptions . ShortMethod ) ]
186
- public void RunFallbackShuffle ( ReadOnlySpan < byte > source , Span < byte > dest )
185
+ public void Shuffle ( ReadOnlySpan < byte > source , Span < byte > destination )
187
186
{
188
187
ref uint sBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( source ) ) ;
189
- ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( dest ) ) ;
188
+ ref uint dBase = ref Unsafe . As < byte , uint > ( ref MemoryMarshal . GetReference ( destination ) ) ;
190
189
uint n = ( uint ) source . Length / 4 ;
191
190
192
191
for ( nuint i = 0 ; i < n ; i ++ )
0 commit comments