diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-02-10 21:10:05 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-11 01:10:05 +0100 |
| commit | 7e4d986a731e9cba05f24b2efd14e18ebc39e75d (patch) | |
| tree | 600a7f06c3c0e31d18c80f338e9e4604027fea04 /Ryujinx.Graphics.Gpu | |
| parent | 2e6080ccbb1598fc13d0f68b3d05dd4f416bb0b0 (diff) | |
Support compute uniform buffers emulated with global memory (#924)
Diffstat (limited to 'Ryujinx.Graphics.Gpu')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Constants.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Compute.cs | 28 |
2 files changed, 41 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Gpu/Constants.cs b/Ryujinx.Graphics.Gpu/Constants.cs index 65cd8846..cc476654 100644 --- a/Ryujinx.Graphics.Gpu/Constants.cs +++ b/Ryujinx.Graphics.Gpu/Constants.cs @@ -8,11 +8,18 @@ namespace Ryujinx.Graphics.Gpu /// <summary> /// Maximum number of compute uniform buffers. /// </summary> - public const int TotalCpUniformBuffers = 8; + /// <remarks> + /// This does not reflect the hardware count, the API will emulate some constant buffers using + /// global memory to make up for the low amount of compute constant buffers supported by hardware (only 8). + /// </remarks> + public const int TotalCpUniformBuffers = 17; // 8 hardware constant buffers + 9 emulated (14 available to the user). /// <summary> - /// Maximum number of compute storage buffers (this is an API limitation). + /// Maximum number of compute storage buffers. /// </summary> + /// <remarks> + /// The maximum number of storage buffers is API limited, the hardware supports a unlimited amount. + /// </remarks> public const int TotalCpStorageBuffers = 16; /// <summary> @@ -21,8 +28,11 @@ namespace Ryujinx.Graphics.Gpu public const int TotalGpUniformBuffers = 18; /// <summary> - /// Maximum number of graphics storage buffers (this is an API limitation). + /// Maximum number of graphics storage buffers. /// </summary> + /// <remarks> + /// The maximum number of storage buffers is API limited, the hardware supports a unlimited amount. + /// </remarks> public const int TotalGpStorageBuffers = 16; /// <summary> diff --git a/Ryujinx.Graphics.Gpu/Engine/Compute.cs b/Ryujinx.Graphics.Gpu/Engine/Compute.cs index 9178cfb0..fc257f99 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Compute.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Compute.cs @@ -69,6 +69,34 @@ namespace Ryujinx.Graphics.Gpu.Engine BufferManager.SetComputeUniformBuffer(index, gpuVa, size); } + for (int index = 0; index < info.CBuffers.Count; index++) + { + BufferDescriptor cb = info.CBuffers[index]; + + // NVN uses the "hardware" constant buffer for anything that is less than 8, + // and those are already bound above. + // Anything greater than or equal to 8 uses the emulated constant buffers. + // They are emulated using global memory loads. + if (cb.Slot < 8) + { + continue; + } + + ubEnableMask |= 1u << cb.Slot; + + ulong cbDescAddress = BufferManager.GetComputeUniformBufferAddress(0); + + int cbDescOffset = 0x260 + cb.Slot * 0x10; + + cbDescAddress += (ulong)cbDescOffset; + + ReadOnlySpan<byte> cbDescriptorData = _context.PhysicalMemory.GetSpan(cbDescAddress, 0x10); + + SbDescriptor cbDescriptor = MemoryMarshal.Cast<byte, SbDescriptor>(cbDescriptorData)[0]; + + BufferManager.SetComputeUniformBuffer(cb.Slot, cbDescriptor.PackAddress(), (uint)cbDescriptor.Size); + } + for (int index = 0; index < info.SBuffers.Count; index++) { BufferDescriptor sb = info.SBuffers[index]; |
