Query multiple pages at once with GetWriteWatch (#222)

* Query multiple pages at once with GetWriteWatch

* Allow multiple buffer types to share the same page, aways use the physical address as cache key

* Remove a variable that is no longer needed
This commit is contained in:
gdkchan 2018-07-08 16:55:15 -03:00 committed by GitHub
parent 0f8f40486d
commit 095db47e13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 103 deletions

View file

@ -464,19 +464,17 @@ namespace Ryujinx.HLE.Gpu.Engines
GalTextureSampler Sampler = TextureFactory.MakeSampler(Gpu, Vmm, TscPosition);
long TextureAddress = Vmm.ReadInt64(TicPosition + 4) & 0xffffffffffff;
long Key = Vmm.ReadInt64(TicPosition + 4) & 0xffffffffffff;
long Key = TextureAddress;
Key = Vmm.GetPhysicalAddress(Key);
TextureAddress = Vmm.GetPhysicalAddress(TextureAddress);
if (IsFrameBufferPosition(TextureAddress))
if (IsFrameBufferPosition(Key))
{
//This texture is a frame buffer texture,
//we shouldn't read anything from memory and bind
//the frame buffer texture instead, since we're not
//really writing anything to memory.
Gpu.Renderer.FrameBuffer.BindTexture(TextureAddress, TexIndex);
Gpu.Renderer.FrameBuffer.BindTexture(Key, TexIndex);
}
else
{
@ -544,6 +542,8 @@ namespace Ryujinx.HLE.Gpu.Engines
{
long IndexPosition = MakeInt64From2xInt32(NvGpuEngine3dReg.IndexArrayAddress);
long IboKey = Vmm.GetPhysicalAddress(IndexPosition);
int IndexEntryFmt = ReadRegister(NvGpuEngine3dReg.IndexArrayFormat);
int IndexFirst = ReadRegister(NvGpuEngine3dReg.IndexBatchFirst);
int IndexCount = ReadRegister(NvGpuEngine3dReg.IndexBatchCount);
@ -561,16 +561,16 @@ namespace Ryujinx.HLE.Gpu.Engines
{
int IbSize = IndexCount * IndexEntrySize;
bool IboCached = Gpu.Renderer.Rasterizer.IsIboCached(IndexPosition, (uint)IbSize);
bool IboCached = Gpu.Renderer.Rasterizer.IsIboCached(IboKey, (uint)IbSize);
if (!IboCached || Vmm.IsRegionModified(IndexPosition, (uint)IbSize, NvGpuBufferType.Index))
if (!IboCached || Vmm.IsRegionModified(IboKey, (uint)IbSize, NvGpuBufferType.Index))
{
byte[] Data = Vmm.ReadBytes(IndexPosition, (uint)IbSize);
Gpu.Renderer.Rasterizer.CreateIbo(IndexPosition, Data);
Gpu.Renderer.Rasterizer.CreateIbo(IboKey, Data);
}
Gpu.Renderer.Rasterizer.SetIndexArray(IndexPosition, IbSize, IndexFormat);
Gpu.Renderer.Rasterizer.SetIndexArray(IboKey, IbSize, IndexFormat);
}
List<GalVertexAttrib>[] Attribs = new List<GalVertexAttrib>[32];
@ -619,20 +619,22 @@ namespace Ryujinx.HLE.Gpu.Engines
continue;
}
long VboKey = Vmm.GetPhysicalAddress(VertexPosition);
int Stride = Control & 0xfff;
long VbSize = (VertexEndPos - VertexPosition) + 1;
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VertexPosition, VbSize);
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VboKey, VbSize);
if (!VboCached || Vmm.IsRegionModified(VertexPosition, VbSize, NvGpuBufferType.Vertex))
if (!VboCached || Vmm.IsRegionModified(VboKey, VbSize, NvGpuBufferType.Vertex))
{
byte[] Data = Vmm.ReadBytes(VertexPosition, VbSize);
Gpu.Renderer.Rasterizer.CreateVbo(VertexPosition, Data);
Gpu.Renderer.Rasterizer.CreateVbo(VboKey, Data);
}
Gpu.Renderer.Rasterizer.SetVertexArray(Index, Stride, VertexPosition, Attribs[Index].ToArray());
Gpu.Renderer.Rasterizer.SetVertexArray(Index, Stride, VboKey, Attribs[Index].ToArray());
}
GalPrimitiveType PrimType = (GalPrimitiveType)(PrimCtrl & 0xffff);
@ -641,7 +643,7 @@ namespace Ryujinx.HLE.Gpu.Engines
{
int VertexBase = ReadRegister(NvGpuEngine3dReg.VertexArrayElemBase);
Gpu.Renderer.Rasterizer.DrawElements(IndexPosition, IndexFirst, VertexBase, PrimType);
Gpu.Renderer.Rasterizer.DrawElements(IboKey, IndexFirst, VertexBase, PrimType);
}
else
{