Support texture rectangle targets (non-normalized coords)

This commit is contained in:
gdkchan 2019-12-16 01:59:46 -03:00 committed by Thog
parent 2eccc7023a
commit 9d7a142a48
23 changed files with 473 additions and 356 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;