Attempt to support deswizzle of sparse tiled textures
This commit is contained in:
parent
063fae50fe
commit
06e84b40f4
6 changed files with 46 additions and 29 deletions
|
@ -89,22 +89,25 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
DstSwizzle = TextureSwizzle.BlockLinear;
|
DstSwizzle = TextureSwizzle.BlockLinear;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureInfo DstTexture = new TextureInfo(
|
|
||||||
DstAddress,
|
|
||||||
DstWidth,
|
|
||||||
DstHeight,
|
|
||||||
DstBlockHeight,
|
|
||||||
DstBlockHeight,
|
|
||||||
DstSwizzle,
|
|
||||||
GalTextureFormat.A8B8G8R8);
|
|
||||||
|
|
||||||
if (IsFbTexture)
|
if (IsFbTexture)
|
||||||
{
|
{
|
||||||
//TODO: Change this when the correct frame buffer resolution is used.
|
//TODO: Change this when the correct frame buffer resolution is used.
|
||||||
//Currently, the frame buffer size is hardcoded to 1280x720.
|
//Currently, the frame buffer size is hardcoded to 1280x720.
|
||||||
SrcWidth = 1280;
|
SrcWidth = 1280;
|
||||||
SrcHeight = 720;
|
SrcHeight = 720;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureInfo DstTexture = new TextureInfo(
|
||||||
|
DstAddress,
|
||||||
|
SrcWidth,
|
||||||
|
SrcHeight,
|
||||||
|
DstPitch,
|
||||||
|
DstBlockHeight, 1,
|
||||||
|
DstSwizzle,
|
||||||
|
GalTextureFormat.A8B8G8R8);
|
||||||
|
|
||||||
|
if (IsFbTexture)
|
||||||
|
{
|
||||||
Gpu.Renderer.FrameBuffer.GetBufferData(Key, (byte[] Buffer) =>
|
Gpu.Renderer.FrameBuffer.GetBufferData(Key, (byte[] Buffer) =>
|
||||||
{
|
{
|
||||||
CopyTexture(
|
CopyTexture(
|
||||||
|
|
|
@ -55,9 +55,11 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
int Pitch = (Tic[3] & 0xffff) << 5;
|
int Pitch = (Tic[3] & 0xffff) << 5;
|
||||||
|
|
||||||
int BlockHeightLog2 = (Tic[3] >> 3) & 7;
|
int BlockHeightLog2 = (Tic[3] >> 3) & 7;
|
||||||
|
int TileWidthLog2 = (Tic[3] >> 10) & 7;
|
||||||
|
|
||||||
int BlockHeight = 1 << BlockHeightLog2;
|
int BlockHeight = 1 << BlockHeightLog2;
|
||||||
|
int TileWidth = 1 << TileWidthLog2;
|
||||||
|
|
||||||
int Width = (Tic[4] & 0xffff) + 1;
|
int Width = (Tic[4] & 0xffff) + 1;
|
||||||
int Height = (Tic[5] & 0xffff) + 1;
|
int Height = (Tic[5] & 0xffff) + 1;
|
||||||
|
@ -68,6 +70,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
Height,
|
Height,
|
||||||
Pitch,
|
Pitch,
|
||||||
BlockHeight,
|
BlockHeight,
|
||||||
|
TileWidth,
|
||||||
Swizzle,
|
Swizzle,
|
||||||
Format);
|
Format);
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,14 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
{
|
{
|
||||||
static class TextureHelper
|
static class TextureHelper
|
||||||
{
|
{
|
||||||
public static ISwizzle GetSwizzle(TextureInfo Texture, int Width, int Bpp)
|
public static ISwizzle GetSwizzle(TextureInfo Texture, int BlockWidth, int Bpp)
|
||||||
{
|
{
|
||||||
|
int AlignMask = Texture.TileWidth * 64 - 1;
|
||||||
|
|
||||||
|
int WidthAligned = (Texture.Width + AlignMask) & ~AlignMask;
|
||||||
|
|
||||||
|
WidthAligned = (WidthAligned + (BlockWidth - 1)) / BlockWidth;
|
||||||
|
|
||||||
switch (Texture.Swizzle)
|
switch (Texture.Swizzle)
|
||||||
{
|
{
|
||||||
case TextureSwizzle._1dBuffer:
|
case TextureSwizzle._1dBuffer:
|
||||||
|
@ -18,7 +24,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
case TextureSwizzle.BlockLinear:
|
case TextureSwizzle.BlockLinear:
|
||||||
case TextureSwizzle.BlockLinearColorKey:
|
case TextureSwizzle.BlockLinearColorKey:
|
||||||
return new BlockLinearSwizzle(Width, Bpp, Texture.BlockHeight);
|
return new BlockLinearSwizzle(WidthAligned, Bpp, Texture.BlockHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException(Texture.Swizzle.ToString());
|
throw new NotImplementedException(Texture.Swizzle.ToString());
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
public int Pitch { get; private set; }
|
public int Pitch { get; private set; }
|
||||||
|
|
||||||
public int BlockHeight { get; private set; }
|
public int BlockHeight { get; private set; }
|
||||||
|
public int TileWidth { get; private set; }
|
||||||
|
|
||||||
public TextureSwizzle Swizzle { get; private set; }
|
public TextureSwizzle Swizzle { get; private set; }
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
BlockHeight = 16;
|
BlockHeight = 16;
|
||||||
|
|
||||||
|
TileWidth = 1;
|
||||||
|
|
||||||
Swizzle = TextureSwizzle.BlockLinear;
|
Swizzle = TextureSwizzle.BlockLinear;
|
||||||
|
|
||||||
Format = GalTextureFormat.A8B8G8R8;
|
Format = GalTextureFormat.A8B8G8R8;
|
||||||
|
@ -40,16 +43,18 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
int Height,
|
int Height,
|
||||||
int Pitch,
|
int Pitch,
|
||||||
int BlockHeight,
|
int BlockHeight,
|
||||||
|
int TileWidth,
|
||||||
TextureSwizzle Swizzle,
|
TextureSwizzle Swizzle,
|
||||||
GalTextureFormat Format)
|
GalTextureFormat Format)
|
||||||
{
|
{
|
||||||
this.Position = Position;
|
this.Position = Position;
|
||||||
this.Width = Width;
|
this.Width = Width;
|
||||||
this.Height = Height;
|
this.Height = Height;
|
||||||
this.Pitch = Pitch;
|
this.Pitch = Pitch;
|
||||||
this.BlockHeight = BlockHeight;
|
this.BlockHeight = BlockHeight;
|
||||||
this.Swizzle = Swizzle;
|
this.TileWidth = TileWidth;
|
||||||
this.Format = Format;
|
this.Swizzle = Swizzle;
|
||||||
|
this.Format = Format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height];
|
byte[] Output = new byte[Width * Height];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 1);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 1);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -85,7 +85,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 2];
|
byte[] Output = new byte[Width * Height * 2];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 2);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -123,7 +123,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 2];
|
byte[] Output = new byte[Width * Height * 2];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 2);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -160,7 +160,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 2];
|
byte[] Output = new byte[Width * Height * 2];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 2);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -193,7 +193,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 4];
|
byte[] Output = new byte[Width * Height * 4];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 8];
|
byte[] Output = new byte[Width * Height * 8];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 8);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 8);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -259,7 +259,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 16];
|
byte[] Output = new byte[Width * Height * 16];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 16);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 16);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -294,7 +294,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 8];
|
byte[] Output = new byte[Width * Height * 8];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 8);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 4, 8);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
@ -327,7 +327,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 16];
|
byte[] Output = new byte[Width * Height * 16];
|
||||||
|
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 16);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, BlockWidth, 16);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
int Width,
|
int Width,
|
||||||
int Height)
|
int Height)
|
||||||
{
|
{
|
||||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4);
|
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
|
||||||
|
|
||||||
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
|
||||||
Memory,
|
Memory,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue