diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-04-25 10:40:20 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 23:40:20 +1000 |
| commit | 34d19f381cd496ec5e6d4fb13b45d47c141b7a63 (patch) | |
| tree | 0e8c66f59c0d19f2b73c458434b248dc2fab5846 /Ryujinx.Graphics.Texture/LayoutConverter.cs | |
| parent | bcc5b0d21ec68732c3db37147e07800e3851892a (diff) | |
Fix texture level offset/size calculation when sparse tile width is > 1 (#1142)
* Fix texture level offset/size calculation when sparse tile width is > 1
* Sparse tile width affects layer size alignment aswell
Diffstat (limited to 'Ryujinx.Graphics.Texture/LayoutConverter.cs')
| -rw-r--r-- | Ryujinx.Graphics.Texture/LayoutConverter.cs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/Ryujinx.Graphics.Texture/LayoutConverter.cs b/Ryujinx.Graphics.Texture/LayoutConverter.cs index 2c3d641b..ce2b37b5 100644 --- a/Ryujinx.Graphics.Texture/LayoutConverter.cs +++ b/Ryujinx.Graphics.Texture/LayoutConverter.cs @@ -38,11 +38,12 @@ namespace Ryujinx.Graphics.Texture int outOffs = 0; - int wAlignment = gobBlocksInTileX * (GobStride / bytesPerPixel); - int mipGobBlocksInY = gobBlocksInY; int mipGobBlocksInZ = gobBlocksInZ; + int gobWidth = (GobStride / bytesPerPixel) * gobBlocksInTileX; + int gobHeight = gobBlocksInY * GobHeight; + for (int level = 0; level < levels; level++) { int w = Math.Max(1, width >> level); @@ -66,8 +67,16 @@ namespace Ryujinx.Graphics.Texture int xStart = strideTrunc / bytesPerPixel; - int stride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment); - int wAligned = BitUtils.AlignUp(w, wAlignment); + int stride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment); + + int alignment = gobWidth; + + if (d < gobBlocksInZ || w <= gobWidth || h <= gobHeight) + { + alignment = GobStride / bytesPerPixel; + } + + int wAligned = BitUtils.AlignUp(w, alignment); BlockLinearLayout layoutConverter = new BlockLinearLayout( wAligned, @@ -164,11 +173,12 @@ namespace Ryujinx.Graphics.Texture int inOffs = 0; - int wAlignment = gobBlocksInTileX * (GobStride / bytesPerPixel); - int mipGobBlocksInY = gobBlocksInY; int mipGobBlocksInZ = gobBlocksInZ; + int gobWidth = (GobStride / bytesPerPixel) * gobBlocksInTileX; + int gobHeight = gobBlocksInY * GobHeight; + for (int level = 0; level < levels; level++) { int w = Math.Max(1, width >> level); @@ -188,8 +198,16 @@ namespace Ryujinx.Graphics.Texture mipGobBlocksInZ >>= 1; } - int stride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment); - int wAligned = BitUtils.AlignUp(w, wAlignment); + int stride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment); + + int alignment = gobWidth; + + if (d < gobBlocksInZ || w <= gobWidth || h <= gobHeight) + { + alignment = GobStride / bytesPerPixel; + } + + int wAligned = BitUtils.AlignUp(w, alignment); BlockLinearLayout layoutConverter = new BlockLinearLayout( wAligned, |
