mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-22 09:03:36 +00:00
May avoid issues with drivers with NVIDIA on linux/older gpus on windows when using large buffers (?) Also some performance things and fixes issues with opengl games loading textures weird.
65 lines
No EOL
1.4 KiB
C#
65 lines
No EOL
1.4 KiB
C#
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
struct BitMap
|
|
{
|
|
private const int IntSize = 64;
|
|
private const int IntMask = IntSize - 1;
|
|
|
|
private readonly long[] _masks;
|
|
|
|
public BitMap(int count)
|
|
{
|
|
_masks = new long[(count + IntMask) / IntSize];
|
|
}
|
|
|
|
public bool AnySet()
|
|
{
|
|
for (int i = 0; i < _masks.Length; i++)
|
|
{
|
|
if (_masks[i] != 0)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool IsSet(int bit)
|
|
{
|
|
int wordIndex = bit / IntSize;
|
|
int wordBit = bit & IntMask;
|
|
|
|
long wordMask = 1L << wordBit;
|
|
|
|
return (_masks[wordIndex] & wordMask) != 0;
|
|
}
|
|
|
|
public bool Set(int bit)
|
|
{
|
|
int wordIndex = bit / IntSize;
|
|
int wordBit = bit & IntMask;
|
|
|
|
long wordMask = 1L << wordBit;
|
|
|
|
if ((_masks[wordIndex] & wordMask) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_masks[wordIndex] |= wordMask;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Clear(int bit)
|
|
{
|
|
int wordIndex = bit / IntSize;
|
|
int wordBit = bit & IntMask;
|
|
|
|
long wordMask = 1L << wordBit;
|
|
|
|
_masks[wordIndex] &= ~wordMask;
|
|
}
|
|
}
|
|
} |