Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WidenLatin1ToUtf16_Sse2()

static unsafe void System.Text.Latin1Utility.WidenLatin1ToUtf16_Sse2 ( byte * pLatin1Buffer,
char * pUtf16Buffer,
nuint elementCount )
inlinestaticprivate

Definition at line 496 of file Latin1Utility.cs.

497 {
498 uint num = (uint)Unsafe.SizeOf<Vector128<byte>>();
499 nuint num2 = num - 1;
500 nuint num3 = 0u;
502 if (elementCount >= num)
503 {
504 Vector128<byte> left = Sse2.LoadScalarVector128((ulong*)pLatin1Buffer).AsByte();
505 Sse2.Store((byte*)pUtf16Buffer, Sse2.UnpackLow(left, zero));
506 num3 = (num >> 1) - (((nuint)pUtf16Buffer >> 1) & (num2 >> 1));
507 char* ptr = pUtf16Buffer + num3;
508 nuint num4 = elementCount - num;
509 while (num3 <= num4)
510 {
511 left = Sse2.LoadVector128(pLatin1Buffer + num3);
512 Vector128<byte> source = Sse2.UnpackLow(left, zero);
513 Sse2.StoreAligned((byte*)ptr, source);
514 Vector128<byte> source2 = Sse2.UnpackHigh(left, zero);
515 Sse2.StoreAligned((byte*)ptr + num, source2);
516 num3 += num;
517 ptr += num;
518 }
519 }
520 uint num5 = (uint)((int)elementCount - (int)num3);
521 if ((num5 & 8u) != 0)
522 {
523 Vector128<byte> left = Sse2.LoadScalarVector128((ulong*)(pLatin1Buffer + num3)).AsByte();
524 Sse2.Store((byte*)(pUtf16Buffer + num3), Sse2.UnpackLow(left, zero));
525 num3 += 8;
526 }
527 if ((num5 & 4u) != 0)
528 {
529 Vector128<byte> left = Sse2.LoadScalarVector128((uint*)(pLatin1Buffer + num3)).AsByte();
530 Sse2.StoreScalar((ulong*)(pUtf16Buffer + num3), Sse2.UnpackLow(left, zero).AsUInt64());
531 num3 += 4;
532 }
533 if ((num5 & 3) == 0)
534 {
535 return;
536 }
537 pUtf16Buffer[num3] = (char)pLatin1Buffer[num3];
538 if ((num5 & 2u) != 0)
539 {
540 pUtf16Buffer[num3 + 1] = (char)pLatin1Buffer[num3 + 1];
541 if ((num5 & (true ? 1u : 0u)) != 0)
542 {
543 pUtf16Buffer[num3 + 2] = (char)pLatin1Buffer[num3 + 2];
544 }
545 }
546 }
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
Definition Sse2.cs:582
static unsafe Vector128< double > LoadScalarVector128(double *address)
Definition Sse2.cs:627
static unsafe void StoreScalar(double *address, Vector128< double > source)
Definition Sse2.cs:1172
static unsafe void Store(sbyte *address, Vector128< sbyte > source)
Definition Sse2.cs:1287
static unsafe void StoreAligned(sbyte *address, Vector128< sbyte > source)
Definition Sse2.cs:1197
static Vector128< byte > UnpackLow(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:1467
static Vector128< byte > UnpackHigh(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:1422

References System.Runtime.Intrinsics.X86.Sse2.LoadScalarVector128(), System.Runtime.Intrinsics.X86.Sse2.LoadVector128(), System.source, System.Runtime.Intrinsics.X86.Sse2.Store(), System.Runtime.Intrinsics.X86.Sse2.StoreAligned(), System.Runtime.Intrinsics.X86.Sse2.StoreScalar(), System.Runtime.Intrinsics.X86.Sse2.UnpackHigh(), System.Runtime.Intrinsics.X86.Sse2.UnpackLow(), and System.Runtime.Intrinsics.Vector128< T >.Zero.

Referenced by System.Text.Latin1Utility.WidenLatin1ToUtf16().