Improve performance when converting texture formats.

Still more work to do.
This commit is contained in:
riperiperi
2020-05-17 12:41:45 +01:00
parent 6416bc1938
commit fc2d5086e7
3 changed files with 231 additions and 49 deletions

View File

@ -33,6 +33,10 @@ namespace Ryujinx.Graphics.Texture
private int _robSize;
private int _sliceSize;
// Variables for built in iteration.
private int _yPart;
private int _zPart;
public BlockLinearLayout(
int width,
int height,
@ -97,5 +101,50 @@ namespace Ryujinx.Graphics.Texture
return offset;
}
// Functions for built in iteration.
// Components of the offset can be updated separately, and combined to save some time.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetY(int y)
{
int yh = y / GobHeight;
int offset = (yh >> _bhShift) * _robSize;
offset += (yh & _bhMask) * GobSize;
offset += ((y & 0x07) >> 1) << 6;
offset += ((y & 0x01) >> 0) << 4;
_yPart = offset;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetZ(int z)
{
int offset = (z >> _bdShift) * _sliceSize;
offset += ((z & _bdMask) * GobSize) << _bhShift;
_zPart = offset;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetOffsetWithLineOffset(int x)
{
int offset = (x / GobStride) << _xShift;
offset += ((x & 0x3f) >> 5) << 8;
offset += ((x & 0x1f) >> 4) << 5;
offset += (x & 0x0f);
return offset + _yPart + _zPart;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetOffset(int x)
{
return GetOffsetWithLineOffset(x << _bppShift);
}
}
}