diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2019-12-16 01:59:46 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 9d7a142a48a5f804127fcae2265bb6ec5495d178 (patch) | |
| tree | 4ba4de906d74404760fcbebe9aeb51460252f500 /Ryujinx.Graphics.Gpu/Image | |
| parent | 2eccc7023ae0d1247378516b14507d422e4915c5 (diff) | |
Support texture rectangle targets (non-normalized coords)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 15 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs | 5 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 5 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TexturePool.cs | 15 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureTarget.cs | 4 |
5 files changed, 37 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index 63a42709..ce58e5c5 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -199,6 +199,21 @@ namespace Ryujinx.Graphics.Gpu.Image } } + public TextureDescriptor GetTextureDescriptor(GpuState state, int stageIndex, int handle) + { + int packedId = ReadPackedId(stageIndex, handle); + + int textureId = UnpackTextureId(packedId); + + var poolState = state.Get<PoolState>(MethodOffset.TexturePoolState); + + ulong poolAddress = _context.MemoryManager.Translate(poolState.Address.Pack()); + + TexturePool texturePool = _texturePoolCache.FindOrCreate(poolAddress, poolState.MaximumId); + + return texturePool.GetDescriptor(textureId); + } + private int ReadPackedId(int stage, int wordOffset) { ulong address; diff --git a/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs b/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs index 79e4f55e..6d1f0fb1 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs @@ -101,6 +101,11 @@ namespace Ryujinx.Graphics.Gpu.Image return (int)((Word5 >> 16) & 0x3fff) + 1; } + public bool UnpackTextureCoordNormalized() + { + return (Word5 & (1 << 31)) != 0; + } + public int UnpackBaseLevel() { return (int)(Word7 & 0xf); diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index ce0cc249..73067249 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -129,6 +129,11 @@ namespace Ryujinx.Graphics.Gpu.Image UpdateRenderTargets(); } + public TextureDescriptor GetGraphicsTextureDescriptor(GpuState state, int stageIndex, int handle) + { + return _gpBindingsManager.GetTextureDescriptor(state, stageIndex, handle); + } + private void UpdateRenderTargets() { bool anyChanged = false; diff --git a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index 6014f07c..47fa01b6 100644 --- a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -36,11 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Image if (texture == null) { - ulong address = Address + (ulong)(uint)id * DescriptorSize; - - Span<byte> data = Context.PhysicalMemory.Read(address, DescriptorSize); - - TextureDescriptor descriptor = MemoryMarshal.Cast<byte, TextureDescriptor>(data)[0]; + TextureDescriptor descriptor = GetDescriptor(id); TextureInfo info = GetInfo(descriptor); @@ -66,6 +62,15 @@ namespace Ryujinx.Graphics.Gpu.Image return texture; } + public TextureDescriptor GetDescriptor(int id) + { + ulong address = Address + (ulong)(uint)id * DescriptorSize; + + Span<byte> data = Context.PhysicalMemory.Read(address, DescriptorSize); + + return MemoryMarshal.Cast<byte, TextureDescriptor>(data)[0]; + } + protected override void InvalidateRangeImpl(ulong address, ulong size) { ulong endAddress = address + size; diff --git a/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs b/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs index 8f513903..d42d1e77 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gpu.Image Texture1DArray, Texture2DArray, TextureBuffer, - Texture2DLinear, + Texture2DRect, CubemapArray } @@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gpu.Image { case TextureTarget.Texture1D: return Target.Texture1D; case TextureTarget.Texture2D: return Target.Texture2D; - case TextureTarget.Texture2DLinear: return Target.Texture2D; + case TextureTarget.Texture2DRect: return Target.Texture2D; case TextureTarget.Texture3D: return Target.Texture3D; case TextureTarget.Texture1DArray: return Target.Texture1DArray; case TextureTarget.Texture2DArray: return Target.Texture2DArray; |
