From 7e4d986a731e9cba05f24b2efd14e18ebc39e75d Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 10 Feb 2020 21:10:05 -0300 Subject: Support compute uniform buffers emulated with global memory (#924) --- Ryujinx.Graphics.Gpu/Engine/Compute.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Engine/Compute.cs') 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 cbDescriptorData = _context.PhysicalMemory.GetSpan(cbDescAddress, 0x10); + + SbDescriptor cbDescriptor = MemoryMarshal.Cast(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]; -- cgit v1.2.3