diff options
| author | gdk <gab.dark.100@gmail.com> | 2019-11-30 23:53:09 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 6a98c643cabeea25dc42e19fe475a687a034a532 (patch) | |
| tree | ccb1ecbfc5b79852be8a1f52e241015142a8a7a9 /Ryujinx.Graphics.Gpu | |
| parent | 396768f3b4494c7dcb0c03942eeb50ef4d47adde (diff) | |
Add a pass to turn global memory access into storage access, and do all storage related transformations on IR
Diffstat (limited to 'Ryujinx.Graphics.Gpu')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/GpuContext.cs | 7 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 11 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 11 |
3 files changed, 14 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/GpuContext.cs b/Ryujinx.Graphics.Gpu/GpuContext.cs index 51961522..0906d10e 100644 --- a/Ryujinx.Graphics.Gpu/GpuContext.cs +++ b/Ryujinx.Graphics.Gpu/GpuContext.cs @@ -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; diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index a066585c..83ca5db5 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -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); diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index a781de42..8e39662d 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -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); + } } }
\ No newline at end of file |
