Revert "Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)"

This reverts merge request !47
This commit is contained in:
GreemDev
2025-06-15 20:45:26 -05:00
parent faf9e3cdd7
commit 77a797f154
307 changed files with 1245 additions and 1016 deletions

View File

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Texture.Astc
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[StructLayout(LayoutKind.Sequential)]
struct AstcPixel
{
internal const int StructSize = 12;

View File

@@ -1,12 +1,14 @@
using Ryujinx.Common.Utilities;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Ryujinx.Graphics.Texture.Astc
{
public struct BitStream128
{
#pragma warning disable IDE0044 // Make field readonly
private Buffer16 _data;
#pragma warning restore IDE0044
public int BitsLeft { get; set; }
public BitStream128(Buffer16 data)
@@ -25,11 +27,13 @@ namespace Ryujinx.Graphics.Texture.Astc
}
int mask = (1 << bitCount) - 1;
int value = Unsafe.As<Buffer16, int>(ref _data) & mask;
int value = _data.As<int>() & mask;
ulong carry = _data.High << (64 - bitCount);
_data.Low = (_data.Low >> bitCount) | carry;
_data.High >>= bitCount;
Span<ulong> span = _data.AsSpan<ulong>();
ulong carry = span[1] << (64 - bitCount);
span[0] = (span[0] >> bitCount) | carry;
span[1] >>= bitCount;
BitsLeft -= bitCount;
@@ -47,21 +51,23 @@ namespace Ryujinx.Graphics.Texture.Astc
ulong maskedValue = (uint)(value & ((1 << bitCount) - 1));
Span<ulong> span = _data.AsSpan<ulong>();
if (BitsLeft < 64)
{
ulong lowMask = maskedValue << BitsLeft;
_data.Low |= lowMask;
span[0] |= lowMask;
}
if (BitsLeft + bitCount > 64)
{
if (BitsLeft > 64)
{
_data.High |= maskedValue << (BitsLeft - 64);
span[1] |= maskedValue << (BitsLeft - 64);
}
else
{
_data.High |= maskedValue >> (64 - BitsLeft);
span[1] |= maskedValue >> (64 - BitsLeft);
}
}