Initial work
This commit is contained in:
parent
f617fb542a
commit
1876b346fe
518 changed files with 15170 additions and 12486 deletions
|
@ -24,8 +24,6 @@ namespace Ryujinx.HLE.HOS.Services.Mm
|
|||
// FinalizeOld(u32)
|
||||
public ResultCode FinalizeOld(ServiceCtx context)
|
||||
{
|
||||
context.Device.Gpu.UninitializeVideoDecoder();
|
||||
|
||||
Logger.PrintStub(LogClass.ServiceMm);
|
||||
|
||||
return ResultCode.Success;
|
||||
|
@ -69,8 +67,6 @@ namespace Ryujinx.HLE.HOS.Services.Mm
|
|||
// Finalize(u32)
|
||||
public ResultCode Finalize(ServiceCtx context)
|
||||
{
|
||||
context.Device.Gpu.UninitializeVideoDecoder();
|
||||
|
||||
Logger.PrintStub(LogClass.ServiceMm);
|
||||
|
||||
return ResultCode.Success;
|
||||
|
|
|
@ -102,7 +102,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
byte[] outputData = new byte[outputDataSize];
|
||||
|
||||
context.Memory.ReadBytes(inputDataPosition, outputData, 0, (int)inputDataSize);
|
||||
byte[] temp = context.Memory.ReadBytes(inputDataPosition, inputDataSize);
|
||||
|
||||
Buffer.BlockCopy(temp, 0, outputData, 0, temp.Length);
|
||||
|
||||
arguments = new Span<byte>(outputData);
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
|
|||
{
|
||||
abstract class NvDeviceFile
|
||||
{
|
||||
public readonly ServiceCtx Context;
|
||||
public readonly KProcess Owner;
|
||||
|
||||
public NvDeviceFile(ServiceCtx context)
|
||||
{
|
||||
Owner = context.Process;
|
||||
Context = context;
|
||||
Owner = context.Process;
|
||||
}
|
||||
|
||||
public virtual NvInternalResult QueryEvent(out int eventHandle, uint eventId)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
||||
|
@ -79,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
private NvInternalResult AllocSpace(ref AllocSpaceArguments arguments)
|
||||
{
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Owner);
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Context);
|
||||
|
||||
ulong size = (ulong)arguments.Pages * (ulong)arguments.PageSize;
|
||||
|
||||
|
@ -91,11 +91,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
// the Offset field holds the alignment size instead.
|
||||
if ((arguments.Flags & AddressSpaceFlags.FixedOffset) != 0)
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.ReserveFixed(arguments.Offset, (long)size);
|
||||
arguments.Offset = (long)addressSpaceContext.Gmm.ReserveFixed((ulong)arguments.Offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.Reserve((long)size, arguments.Offset);
|
||||
arguments.Offset = (long)addressSpaceContext.Gmm.Reserve((ulong)size, (ulong)arguments.Offset);
|
||||
}
|
||||
|
||||
if (arguments.Offset < 0)
|
||||
|
@ -117,7 +117,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
private NvInternalResult FreeSpace(ref FreeSpaceArguments arguments)
|
||||
{
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Owner);
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Context);
|
||||
|
||||
NvInternalResult result = NvInternalResult.Success;
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
if (addressSpaceContext.RemoveReservation(arguments.Offset))
|
||||
{
|
||||
addressSpaceContext.Vmm.Free(arguments.Offset, (long)size);
|
||||
addressSpaceContext.Gmm.Free((ulong)arguments.Offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
private NvInternalResult UnmapBuffer(ref UnmapBufferArguments arguments)
|
||||
{
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Owner);
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Context);
|
||||
|
||||
lock (addressSpaceContext)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
if (size != 0)
|
||||
{
|
||||
addressSpaceContext.Vmm.Free(arguments.Offset, size);
|
||||
addressSpaceContext.Gmm.Free((ulong)arguments.Offset, (ulong)size);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -167,7 +167,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
const string mapErrorMsg = "Failed to map fixed buffer with offset 0x{0:x16} and size 0x{1:x16}!";
|
||||
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Owner);
|
||||
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(Context);
|
||||
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, arguments.NvMapHandle, true);
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
physicalAddress += arguments.BufferOffset;
|
||||
|
||||
if (addressSpaceContext.Vmm.Map(physicalAddress, virtualAddress, arguments.MappingSize) < 0)
|
||||
if ((long)addressSpaceContext.Gmm.Map((ulong)physicalAddress, (ulong)virtualAddress, (ulong)arguments.MappingSize) < 0)
|
||||
{
|
||||
string message = string.Format(mapErrorMsg, virtualAddress, arguments.MappingSize);
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
if (addressSpaceContext.ValidateFixedBuffer(arguments.Offset, size))
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(physicalAddress, arguments.Offset, size);
|
||||
arguments.Offset = (long)addressSpaceContext.Gmm.Map((ulong)physicalAddress, (ulong)arguments.Offset, (ulong)size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -244,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
}
|
||||
else
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(physicalAddress, size);
|
||||
arguments.Offset = (long)addressSpaceContext.Gmm.Map((ulong)physicalAddress, (ulong)size);
|
||||
}
|
||||
|
||||
if (arguments.Offset < 0)
|
||||
|
@ -282,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
for (int index = 0; index < arguments.Length; index++)
|
||||
{
|
||||
NvGpuVmm vmm = GetAddressSpaceContext(Owner).Vmm;
|
||||
MemoryManager gmm = GetAddressSpaceContext(Context).Gmm;
|
||||
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, arguments[index].NvMapHandle, true);
|
||||
|
||||
|
@ -293,10 +293,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
long result = vmm.Map(
|
||||
((long)arguments[index].MapOffset << 16) + map.Address,
|
||||
(long)arguments[index].GpuOffset << 16,
|
||||
(long)arguments[index].Pages << 16);
|
||||
long result = (long)gmm.Map(
|
||||
((ulong)arguments[index].MapOffset << 16) + (ulong)map.Address,
|
||||
(ulong)arguments[index].GpuOffset << 16,
|
||||
(ulong)arguments[index].Pages << 16);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
|
@ -312,9 +312,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
public override void Close() { }
|
||||
|
||||
public static AddressSpaceContext GetAddressSpaceContext(KProcess process)
|
||||
public static AddressSpaceContext GetAddressSpaceContext(ServiceCtx context)
|
||||
{
|
||||
return _addressSpaceContextRegistry.GetOrAdd(process, (key) => new AddressSpaceContext(process));
|
||||
return _addressSpaceContextRegistry.GetOrAdd(context.Process, (key) => new AddressSpaceContext(context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
||||
{
|
||||
class AddressSpaceContext
|
||||
{
|
||||
public NvGpuVmm Vmm { get; private set; }
|
||||
|
||||
private class Range
|
||||
{
|
||||
public ulong Start { get; private set; }
|
||||
|
@ -42,9 +38,45 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
private SortedList<long, Range> _maps;
|
||||
private SortedList<long, Range> _reservations;
|
||||
|
||||
public AddressSpaceContext(KProcess process)
|
||||
public MemoryManager Gmm { get; }
|
||||
|
||||
private class MemoryProxy : IPhysicalMemory
|
||||
{
|
||||
Vmm = new NvGpuVmm(process.CpuMemory);
|
||||
private ARMeilleure.Memory.MemoryManager _cpuMemory;
|
||||
|
||||
public MemoryProxy(ARMeilleure.Memory.MemoryManager cpuMemory)
|
||||
{
|
||||
_cpuMemory = cpuMemory;
|
||||
}
|
||||
|
||||
public Span<byte> Read(ulong address, ulong size)
|
||||
{
|
||||
return _cpuMemory.ReadBytes((long)address, (long)size);
|
||||
}
|
||||
|
||||
public void Write(ulong address, Span<byte> data)
|
||||
{
|
||||
_cpuMemory.WriteBytes((long)address, data.ToArray());
|
||||
}
|
||||
|
||||
public (ulong, ulong)[] GetModifiedRanges(ulong address, ulong size)
|
||||
{
|
||||
return _cpuMemory.GetModifiedRanges(address, size);
|
||||
}
|
||||
|
||||
public int GetPageSize()
|
||||
{
|
||||
return 4096;
|
||||
}
|
||||
}
|
||||
|
||||
public AddressSpaceContext(ServiceCtx context)
|
||||
{
|
||||
Gmm = context.Device.Gpu.MemoryManager;
|
||||
|
||||
var memoryProxy = new MemoryProxy(context.Process.CpuMemory);
|
||||
|
||||
context.Device.Gpu.SetVmm(memoryProxy);
|
||||
|
||||
_maps = new SortedList<long, Range>();
|
||||
_reservations = new SortedList<long, Range>();
|
||||
|
@ -61,7 +93,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
}
|
||||
|
||||
// Check if address is page aligned.
|
||||
if ((position & NvGpuVmm.PageMask) != 0)
|
||||
if ((position & (long)MemoryManager.PageMask) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
||||
|
@ -16,8 +15,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
private uint _timeout;
|
||||
private uint _submitTimeout;
|
||||
private uint _timeslice;
|
||||
private NvGpu _gpu;
|
||||
private MemoryManager _memory;
|
||||
private GpuContext _gpu;
|
||||
private ARMeilleure.Memory.MemoryManager _memory;
|
||||
|
||||
public NvHostChannelDeviceFile(ServiceCtx context) : base(context)
|
||||
{
|
||||
|
@ -110,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
int headerSize = Unsafe.SizeOf<SubmitArguments>();
|
||||
SubmitArguments submitHeader = MemoryMarshal.Cast<byte, SubmitArguments>(arguments)[0];
|
||||
Span<CommandBuffer> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBuffer>(arguments.Slice(headerSize)).Slice(0, submitHeader.CmdBufsCount);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Owner).Vmm;
|
||||
MemoryManager gmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Context).Gmm;
|
||||
|
||||
foreach (CommandBuffer commandBufferEntry in commandBufferEntries)
|
||||
{
|
||||
|
@ -123,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
commandBufferData[offset] = _memory.ReadInt32(map.Address + commandBufferEntry.Offset + offset * 4);
|
||||
}
|
||||
|
||||
_gpu.PushCommandBuffer(vmm, commandBufferData);
|
||||
// TODO: Submit command to engines.
|
||||
}
|
||||
|
||||
return NvInternalResult.Success;
|
||||
|
@ -161,7 +160,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>();
|
||||
MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0];
|
||||
Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Owner).Vmm;
|
||||
MemoryManager gmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Context).Gmm;
|
||||
|
||||
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
||||
{
|
||||
|
@ -178,7 +177,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
if (map.DmaMapAddress == 0)
|
||||
{
|
||||
map.DmaMapAddress = vmm.MapLow(map.Address, map.Size);
|
||||
map.DmaMapAddress = (long)gmm.MapLow((ulong)map.Address, (uint)map.Size);
|
||||
}
|
||||
|
||||
commandBufferEntry.MapAddress = (int)map.DmaMapAddress;
|
||||
|
@ -193,7 +192,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>();
|
||||
MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0];
|
||||
Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Owner).Vmm;
|
||||
MemoryManager gmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Context).Gmm;
|
||||
|
||||
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
||||
{
|
||||
|
@ -210,7 +209,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
if (map.DmaMapAddress != 0)
|
||||
{
|
||||
vmm.Free(map.DmaMapAddress, map.Size);
|
||||
gmm.Free((ulong)map.DmaMapAddress, (uint)map.Size);
|
||||
|
||||
map.DmaMapAddress = 0;
|
||||
}
|
||||
|
@ -240,7 +239,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>();
|
||||
SubmitGpfifoArguments gpfifoSubmissionHeader = MemoryMarshal.Cast<byte, SubmitGpfifoArguments>(arguments)[0];
|
||||
Span<long> gpfifoEntries = MemoryMarshal.Cast<byte, long>(arguments.Slice(headerSize)).Slice(0, gpfifoSubmissionHeader.NumEntries);
|
||||
Span<ulong> gpfifoEntries = MemoryMarshal.Cast<byte, ulong>(arguments.Slice(headerSize)).Slice(0, gpfifoSubmissionHeader.NumEntries);
|
||||
|
||||
return SubmitGpfifo(ref gpfifoSubmissionHeader, gpfifoEntries);
|
||||
}
|
||||
|
@ -327,13 +326,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
protected NvInternalResult SubmitGpfifo(ref SubmitGpfifoArguments header, Span<long> entries)
|
||||
protected NvInternalResult SubmitGpfifo(ref SubmitGpfifoArguments header, Span<ulong> entries)
|
||||
{
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(Owner).Vmm;
|
||||
|
||||
foreach (long entry in entries)
|
||||
foreach (ulong entry in entries)
|
||||
{
|
||||
_gpu.Pusher.Push(vmm, entry);
|
||||
_gpu.DmaPusher.Push(entry);
|
||||
}
|
||||
|
||||
header.Fence.Id = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
switch (command.Number)
|
||||
{
|
||||
case 0x1b:
|
||||
result = CallIoctlMethod<SubmitGpfifoArguments, long>(SubmitGpfifoEx, arguments, inlineInBuffer);
|
||||
result = CallIoctlMethod<SubmitGpfifoArguments, ulong>(SubmitGpfifoEx, arguments, inlineInBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
private NvInternalResult SubmitGpfifoEx(ref SubmitGpfifoArguments arguments, Span<long> inlineData)
|
||||
private NvInternalResult SubmitGpfifoEx(ref SubmitGpfifoArguments arguments, Span<ulong> inlineData)
|
||||
{
|
||||
return SubmitGpfifo(ref arguments, inlineData);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
int size = BitUtils.AlignUp(arguments.Size, NvGpuVmm.PageSize);
|
||||
int size = BitUtils.AlignUp(arguments.Size, (int)MemoryManager.PageSize);
|
||||
|
||||
arguments.Handle = CreateHandleFromMap(new NvMapHandle(size));
|
||||
|
||||
|
@ -118,9 +118,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
if ((uint)arguments.Align < NvGpuVmm.PageSize)
|
||||
if ((uint)arguments.Align < MemoryManager.PageSize)
|
||||
{
|
||||
arguments.Align = NvGpuVmm.PageSize;
|
||||
arguments.Align = (int)MemoryManager.PageSize;
|
||||
}
|
||||
|
||||
NvInternalResult result = NvInternalResult.Success;
|
||||
|
@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
map.Align = arguments.Align;
|
||||
map.Kind = (byte)arguments.Kind;
|
||||
|
||||
int size = BitUtils.AlignUp(map.Size, NvGpuVmm.PageSize);
|
||||
int size = BitUtils.AlignUp(map.Size, (int)MemoryManager.PageSize);
|
||||
|
||||
long address = arguments.Address;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
||||
|
@ -23,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
private KEvent _binderEvent;
|
||||
|
||||
private IGalRenderer _renderer;
|
||||
private IRenderer _renderer;
|
||||
|
||||
private const int BufferQueueCount = 0x40;
|
||||
private const int BufferQueueMask = BufferQueueCount - 1;
|
||||
|
@ -34,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
private bool _disposed;
|
||||
|
||||
public NvFlinger(IGalRenderer renderer, KEvent binderEvent)
|
||||
public NvFlinger(IRenderer renderer, KEvent binderEvent)
|
||||
{
|
||||
_commands = new Dictionary<(string, int), ServiceProcessParcel>
|
||||
{
|
||||
|
@ -256,20 +255,20 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private GalImageFormat ConvertColorFormat(ColorFormat colorFormat)
|
||||
private Format ConvertColorFormat(ColorFormat colorFormat)
|
||||
{
|
||||
switch (colorFormat)
|
||||
{
|
||||
case ColorFormat.A8B8G8R8:
|
||||
return GalImageFormat.Rgba8 | GalImageFormat.Unorm;
|
||||
return Format.R8G8B8A8Unorm;
|
||||
case ColorFormat.X8B8G8R8:
|
||||
return GalImageFormat.Rgbx8 | GalImageFormat.Unorm;
|
||||
return Format.R8G8B8A8Unorm;
|
||||
case ColorFormat.R5G6B5:
|
||||
return GalImageFormat.Bgr565 | GalImageFormat.Unorm;
|
||||
return Format.R5G6B5Unorm;
|
||||
case ColorFormat.A8R8G8B8:
|
||||
return GalImageFormat.Bgra8 | GalImageFormat.Unorm;
|
||||
return Format.B8G8R8A8Unorm;
|
||||
case ColorFormat.A4B4G4R4:
|
||||
return GalImageFormat.Rgba4 | GalImageFormat.Unorm;
|
||||
return Format.R4G4B4A4Unorm;
|
||||
default:
|
||||
throw new NotImplementedException($"Color Format \"{colorFormat}\" not implemented!");
|
||||
}
|
||||
|
@ -292,7 +291,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(context.Process, nvMapHandle);
|
||||
|
||||
long fbAddr = map.Address + bufferOffset;
|
||||
ulong fbAddr = (ulong)(map.Address + bufferOffset);
|
||||
|
||||
_bufferQueue[slot].State = BufferState.Acquired;
|
||||
|
||||
|
@ -301,39 +300,42 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
bool flipX = _bufferQueue[slot].Transform.HasFlag(HalTransform.FlipX);
|
||||
bool flipY = _bufferQueue[slot].Transform.HasFlag(HalTransform.FlipY);
|
||||
|
||||
GalImageFormat imageFormat = ConvertColorFormat(_bufferQueue[slot].Data.Buffer.Surfaces[0].ColorFormat);
|
||||
Format format = ConvertColorFormat(_bufferQueue[slot].Data.Buffer.Surfaces[0].ColorFormat);
|
||||
|
||||
int BlockHeight = 1 << _bufferQueue[slot].Data.Buffer.Surfaces[0].BlockHeightLog2;
|
||||
int bytesPerPixel =
|
||||
format == Format.R5G6B5Unorm ||
|
||||
format == Format.R4G4B4A4Unorm ? 2 : 4;
|
||||
|
||||
int gobBlocksInY = 1 << _bufferQueue[slot].Data.Buffer.Surfaces[0].BlockHeightLog2;
|
||||
|
||||
// Note: Rotation is being ignored.
|
||||
|
||||
int top = crop.Top;
|
||||
int left = crop.Left;
|
||||
int right = crop.Right;
|
||||
int bottom = crop.Bottom;
|
||||
ITexture texture = context.Device.Gpu.GetTexture(
|
||||
fbAddr,
|
||||
fbWidth,
|
||||
fbHeight,
|
||||
0,
|
||||
false,
|
||||
gobBlocksInY,
|
||||
format,
|
||||
bytesPerPixel);
|
||||
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(context.Process).Vmm;
|
||||
_renderer.Window.RegisterTextureReleaseCallback(ReleaseBuffer);
|
||||
|
||||
_renderer.QueueAction(() =>
|
||||
{
|
||||
if (!_renderer.Texture.TryGetImage(fbAddr, out GalImage image))
|
||||
{
|
||||
image = new GalImage(
|
||||
fbWidth,
|
||||
fbHeight, 1, 1, 1, BlockHeight, 1,
|
||||
GalMemoryLayout.BlockLinear,
|
||||
imageFormat,
|
||||
GalTextureTarget.TwoD);
|
||||
}
|
||||
ImageCrop imageCrop = new ImageCrop(
|
||||
crop.Left,
|
||||
crop.Right,
|
||||
crop.Top,
|
||||
crop.Bottom,
|
||||
flipX,
|
||||
flipY);
|
||||
|
||||
context.Device.Gpu.ResourceManager.ClearPbCache();
|
||||
context.Device.Gpu.ResourceManager.SendTexture(vmm, fbAddr, image);
|
||||
_renderer.Window.QueueTexture(texture, imageCrop, slot);
|
||||
}
|
||||
|
||||
_renderer.RenderTarget.SetTransform(flipX, flipY, top, left, right, bottom);
|
||||
_renderer.RenderTarget.Present(fbAddr);
|
||||
|
||||
ReleaseBuffer(slot);
|
||||
});
|
||||
private void ReleaseBuffer(object context)
|
||||
{
|
||||
ReleaseBuffer((int)context);
|
||||
}
|
||||
|
||||
private void ReleaseBuffer(int slot)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
|||
|
||||
private NvFlinger _flinger;
|
||||
|
||||
public IHOSBinderDriver(Horizon system, IGalRenderer renderer)
|
||||
public IHOSBinderDriver(Horizon system, IRenderer renderer)
|
||||
{
|
||||
_binderEvent = new KEvent(system);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue