@@ -124,7 +124,7 @@ public static Vector4 Screen(Vector4 backdrop, Vector4 source)
124
124
public static Vector256 < float > Screen ( Vector256 < float > backdrop , Vector256 < float > source )
125
125
{
126
126
Vector256 < float > vOne = Vector256 . Create ( 1F ) ;
127
- return Avx . Subtract ( vOne , Avx . Multiply ( Avx . Subtract ( vOne , backdrop ) , Avx . Subtract ( vOne , source ) ) ) ;
127
+ return SimdUtils . HwIntrinsics . MultiplyAddNegated ( Avx . Subtract ( vOne , backdrop ) , Avx . Subtract ( vOne , source ) , vOne ) ;
128
128
}
129
129
130
130
/// <summary>
@@ -244,10 +244,10 @@ private static float OverlayValueFunction(float backdrop, float source)
244
244
public static Vector256 < float > OverlayValueFunction ( Vector256 < float > backdrop , Vector256 < float > source )
245
245
{
246
246
Vector256 < float > vOne = Vector256 . Create ( 1F ) ;
247
- Vector256 < float > vTwo = Vector256 . Create ( 2F ) ;
248
247
Vector256 < float > left = Avx . Multiply ( Avx . Add ( backdrop , backdrop ) , source ) ;
249
- Vector256 < float > right = Avx . Subtract ( vOne , Avx . Multiply ( Avx . Multiply ( vTwo , Avx . Subtract ( vOne , source ) ) , Avx . Subtract ( vOne , backdrop ) ) ) ;
250
248
249
+ Vector256 < float > vOneMinusSource = Avx . Subtract ( vOne , source ) ;
250
+ Vector256 < float > right = SimdUtils . HwIntrinsics . MultiplyAddNegated ( Avx . Add ( vOneMinusSource , vOneMinusSource ) , Avx . Subtract ( vOne , backdrop ) , vOne ) ;
251
251
Vector256 < float > cmp = Avx . CompareGreaterThan ( backdrop , Vector256 . Create ( .5F ) ) ;
252
252
return Avx . BlendVariable ( left , right , cmp ) ;
253
253
}
@@ -430,9 +430,7 @@ public static Vector4 Out(Vector4 destination, Vector4 source)
430
430
public static Vector256 < float > Out ( Vector256 < float > destination , Vector256 < float > source )
431
431
{
432
432
// calculate alpha
433
- Vector256 < float > sW = Avx . Shuffle ( source , source , ShuffleAlphaControl ) ;
434
- Vector256 < float > dW = Avx . Shuffle ( destination , destination , ShuffleAlphaControl ) ;
435
- Vector256 < float > alpha = Avx . Multiply ( Avx . Subtract ( Vector256 . Create ( 1F ) , dW ) , sW ) ;
433
+ Vector256 < float > alpha = Avx . Permute ( Avx . Multiply ( source , Avx . Subtract ( Vector256 . Create ( 1F ) , destination ) ) , ShuffleAlphaControl ) ;
436
434
437
435
// premultiply
438
436
Vector256 < float > color = Avx . Multiply ( source , alpha ) ;
0 commit comments