Add a pass to turn global memory access into storage access, and do all storage related transformations on IR

This commit is contained in:
gdk
2019-11-30 23:53:09 -03:00
committed by Thog
parent 396768f3b4
commit 6a98c643ca
28 changed files with 532 additions and 282 deletions

View File

@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu
Window = new Window(this);
_caps = new Lazy<Capabilities>(GetCapabilities);
_caps = new Lazy<Capabilities>(Renderer.GetCapabilities);
}
internal void AdvanceSequence()
@@ -53,11 +53,6 @@ namespace Ryujinx.Graphics.Gpu
SequenceNumber++;
}
private Capabilities GetCapabilities()
{
return Renderer.GetCapabilities();
}
public void SetVmm(IPhysicalMemory mm)
{
PhysicalMemory = mm;

View File

@@ -1,3 +1,4 @@
using Ryujinx.Common;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.GAL.InputAssembler;
using Ryujinx.Graphics.Gpu.State;
@@ -113,10 +114,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
public void SetComputeStorageBuffer(int index, ulong gpuVa, ulong size)
{
// TODO: Improve
size += gpuVa & 0x3fUL;
size += gpuVa & ((ulong)_context.Capabilities.StorageBufferOffsetAlignment - 1);
gpuVa &= ~0x3fUL;
gpuVa = BitUtils.AlignDown(gpuVa, _context.Capabilities.StorageBufferOffsetAlignment);
ulong address = TranslateAndCreateBuffer(gpuVa, size);
@@ -125,10 +125,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
public void SetGraphicsStorageBuffer(int stage, int index, ulong gpuVa, ulong size)
{
// TODO: Improve
size += gpuVa & 0x3fUL;
size += gpuVa & ((ulong)_context.Capabilities.StorageBufferOffsetAlignment - 1);
gpuVa &= ~0x3fUL;
gpuVa = BitUtils.AlignDown(gpuVa, _context.Capabilities.StorageBufferOffsetAlignment);
ulong address = TranslateAndCreateBuffer(gpuVa, size);

View File

@@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
Span<byte> code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
program = Translator.Translate(code, flags);
program = Translator.Translate(code, GetShaderCapabilities(), flags);
int[] codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
@@ -238,7 +238,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
Span<byte> codeA = _context.MemoryAccessor.Read(gpuVaA, MaxProgramSize);
Span<byte> codeB = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
program = Translator.Translate(codeA, codeB, flags);
program = Translator.Translate(codeA, codeB, GetShaderCapabilities(), flags);
// TODO: We should also check "codeA" into account.
codeCached = MemoryMarshal.Cast<byte, int>(codeB.Slice(0, program.Size)).ToArray();
@@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
Span<byte> code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
program = Translator.Translate(code, flags);
program = Translator.Translate(code, GetShaderCapabilities(), flags);
codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
@@ -342,5 +342,10 @@ namespace Ryujinx.Graphics.Gpu.Shader
isFirst = false;
}
}
private ShaderCapabilities GetShaderCapabilities()
{
return new ShaderCapabilities(_context.Capabilities.StorageBufferOffsetAlignment);
}
}
}