Renaming part 10
This commit is contained in:
parent
bed93cc871
commit
26f3e0ffbe
15 changed files with 386 additions and 386 deletions
|
@ -8,41 +8,41 @@ namespace Ryujinx.Graphics
|
|||
private const int MethSetMethod = 0x10;
|
||||
private const int MethSetData = 0x11;
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
public CdmaProcessor(NvGpu Gpu)
|
||||
public CdmaProcessor(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
}
|
||||
|
||||
public void PushCommands(NvGpuVmm Vmm, int[] CmdBuffer)
|
||||
public void PushCommands(NvGpuVmm vmm, int[] cmdBuffer)
|
||||
{
|
||||
List<ChCommand> Commands = new List<ChCommand>();
|
||||
List<ChCommand> commands = new List<ChCommand>();
|
||||
|
||||
ChClassId CurrentClass = 0;
|
||||
ChClassId currentClass = 0;
|
||||
|
||||
for (int Index = 0; Index < CmdBuffer.Length; Index++)
|
||||
for (int index = 0; index < cmdBuffer.Length; index++)
|
||||
{
|
||||
int Cmd = CmdBuffer[Index];
|
||||
int cmd = cmdBuffer[index];
|
||||
|
||||
int Value = (Cmd >> 0) & 0xffff;
|
||||
int MethodOffset = (Cmd >> 16) & 0xfff;
|
||||
int value = (cmd >> 0) & 0xffff;
|
||||
int methodOffset = (cmd >> 16) & 0xfff;
|
||||
|
||||
ChSubmissionMode SubmissionMode = (ChSubmissionMode)((Cmd >> 28) & 0xf);
|
||||
ChSubmissionMode submissionMode = (ChSubmissionMode)((cmd >> 28) & 0xf);
|
||||
|
||||
switch (SubmissionMode)
|
||||
switch (submissionMode)
|
||||
{
|
||||
case ChSubmissionMode.SetClass: CurrentClass = (ChClassId)(Value >> 6); break;
|
||||
case ChSubmissionMode.SetClass: currentClass = (ChClassId)(value >> 6); break;
|
||||
|
||||
case ChSubmissionMode.Incrementing:
|
||||
{
|
||||
int Count = Value;
|
||||
int count = value;
|
||||
|
||||
for (int ArgIdx = 0; ArgIdx < Count; ArgIdx++)
|
||||
for (int argIdx = 0; argIdx < count; argIdx++)
|
||||
{
|
||||
int Argument = CmdBuffer[++Index];
|
||||
int argument = cmdBuffer[++index];
|
||||
|
||||
Commands.Add(new ChCommand(CurrentClass, MethodOffset + ArgIdx, Argument));
|
||||
commands.Add(new ChCommand(currentClass, methodOffset + argIdx, argument));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -50,44 +50,44 @@ namespace Ryujinx.Graphics
|
|||
|
||||
case ChSubmissionMode.NonIncrementing:
|
||||
{
|
||||
int Count = Value;
|
||||
int count = value;
|
||||
|
||||
int[] Arguments = new int[Count];
|
||||
int[] arguments = new int[count];
|
||||
|
||||
for (int ArgIdx = 0; ArgIdx < Count; ArgIdx++)
|
||||
for (int argIdx = 0; argIdx < count; argIdx++)
|
||||
{
|
||||
Arguments[ArgIdx] = CmdBuffer[++Index];
|
||||
arguments[argIdx] = cmdBuffer[++index];
|
||||
}
|
||||
|
||||
Commands.Add(new ChCommand(CurrentClass, MethodOffset, Arguments));
|
||||
commands.Add(new ChCommand(currentClass, methodOffset, arguments));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessCommands(Vmm, Commands.ToArray());
|
||||
ProcessCommands(vmm, commands.ToArray());
|
||||
}
|
||||
|
||||
private void ProcessCommands(NvGpuVmm Vmm, ChCommand[] Commands)
|
||||
private void ProcessCommands(NvGpuVmm vmm, ChCommand[] commands)
|
||||
{
|
||||
int MethodOffset = 0;
|
||||
int methodOffset = 0;
|
||||
|
||||
foreach (ChCommand Command in Commands)
|
||||
foreach (ChCommand command in commands)
|
||||
{
|
||||
switch (Command.MethodOffset)
|
||||
switch (command.MethodOffset)
|
||||
{
|
||||
case MethSetMethod: MethodOffset = Command.Arguments[0]; break;
|
||||
case MethSetMethod: methodOffset = command.Arguments[0]; break;
|
||||
|
||||
case MethSetData:
|
||||
{
|
||||
if (Command.ClassId == ChClassId.NvDec)
|
||||
if (command.ClassId == ChClassId.NvDec)
|
||||
{
|
||||
Gpu.VideoDecoder.Process(Vmm, MethodOffset, Command.Arguments);
|
||||
_gpu.VideoDecoder.Process(vmm, methodOffset, command.Arguments);
|
||||
}
|
||||
else if (Command.ClassId == ChClassId.GraphicsVic)
|
||||
else if (command.ClassId == ChClassId.GraphicsVic)
|
||||
{
|
||||
Gpu.VideoImageComposer.Process(Vmm, MethodOffset, Command.Arguments);
|
||||
_gpu.VideoImageComposer.Process(vmm, methodOffset, command.Arguments);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -2,7 +2,7 @@ namespace Ryujinx.Graphics
|
|||
{
|
||||
enum ChClassId
|
||||
{
|
||||
Host1x = 0x1,
|
||||
Host1X = 0x1,
|
||||
VideoEncodeMpeg = 0x20,
|
||||
VideoEncodeNvEnc = 0x21,
|
||||
VideoStreamingVi = 0x30,
|
||||
|
@ -10,7 +10,7 @@ namespace Ryujinx.Graphics
|
|||
VideoStreamingIspB = 0x34,
|
||||
VideoStreamingViI2c = 0x36,
|
||||
GraphicsVic = 0x5d,
|
||||
Graphics3d = 0x60,
|
||||
Graphics3D = 0x60,
|
||||
GraphicsGpu = 0x61,
|
||||
Tsec = 0xe0,
|
||||
TsecB = 0xe1,
|
||||
|
|
|
@ -8,11 +8,11 @@ namespace Ryujinx.Graphics
|
|||
|
||||
public int[] Arguments { get; private set; }
|
||||
|
||||
public ChCommand(ChClassId ClassId, int MethodOffset, params int[] Arguments)
|
||||
public ChCommand(ChClassId classId, int methodOffset, params int[] arguments)
|
||||
{
|
||||
this.ClassId = ClassId;
|
||||
this.MethodOffset = MethodOffset;
|
||||
this.Arguments = Arguments;
|
||||
ClassId = classId;
|
||||
MethodOffset = methodOffset;
|
||||
Arguments = arguments;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,10 +6,10 @@ namespace Ryujinx.Graphics
|
|||
{
|
||||
public class DmaPusher
|
||||
{
|
||||
private ConcurrentQueue<(NvGpuVmm, long)> IbBuffer;
|
||||
private ConcurrentQueue<(NvGpuVmm, long)> _ibBuffer;
|
||||
|
||||
private long DmaPut;
|
||||
private long DmaGet;
|
||||
private long _dmaPut;
|
||||
private long _dmaGet;
|
||||
|
||||
private struct DmaState
|
||||
{
|
||||
|
@ -21,43 +21,43 @@ namespace Ryujinx.Graphics
|
|||
public int LengthPending;
|
||||
}
|
||||
|
||||
private DmaState State;
|
||||
private DmaState _state;
|
||||
|
||||
private bool SliEnable;
|
||||
private bool SliActive;
|
||||
private bool _sliEnable;
|
||||
private bool _sliActive;
|
||||
|
||||
private bool IbEnable;
|
||||
private bool NonMain;
|
||||
private bool _ibEnable;
|
||||
private bool _nonMain;
|
||||
|
||||
private long DmaMGet;
|
||||
private long _dmaMGet;
|
||||
|
||||
private NvGpuVmm Vmm;
|
||||
private NvGpuVmm _vmm;
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
private AutoResetEvent Event;
|
||||
private AutoResetEvent _event;
|
||||
|
||||
public DmaPusher(NvGpu Gpu)
|
||||
public DmaPusher(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
IbBuffer = new ConcurrentQueue<(NvGpuVmm, long)>();
|
||||
_ibBuffer = new ConcurrentQueue<(NvGpuVmm, long)>();
|
||||
|
||||
IbEnable = true;
|
||||
_ibEnable = true;
|
||||
|
||||
Event = new AutoResetEvent(false);
|
||||
_event = new AutoResetEvent(false);
|
||||
}
|
||||
|
||||
public void Push(NvGpuVmm Vmm, long Entry)
|
||||
public void Push(NvGpuVmm vmm, long entry)
|
||||
{
|
||||
IbBuffer.Enqueue((Vmm, Entry));
|
||||
_ibBuffer.Enqueue((vmm, entry));
|
||||
|
||||
Event.Set();
|
||||
_event.Set();
|
||||
}
|
||||
|
||||
public bool WaitForCommands()
|
||||
{
|
||||
return Event.WaitOne(8);
|
||||
return _event.WaitOne(8);
|
||||
}
|
||||
|
||||
public void DispatchCalls()
|
||||
|
@ -67,101 +67,101 @@ namespace Ryujinx.Graphics
|
|||
|
||||
private bool Step()
|
||||
{
|
||||
if (DmaGet != DmaPut)
|
||||
if (_dmaGet != _dmaPut)
|
||||
{
|
||||
int Word = Vmm.ReadInt32(DmaGet);
|
||||
int word = _vmm.ReadInt32(_dmaGet);
|
||||
|
||||
DmaGet += 4;
|
||||
_dmaGet += 4;
|
||||
|
||||
if (!NonMain)
|
||||
if (!_nonMain)
|
||||
{
|
||||
DmaMGet = DmaGet;
|
||||
_dmaMGet = _dmaGet;
|
||||
}
|
||||
|
||||
if (State.LengthPending != 0)
|
||||
if (_state.LengthPending != 0)
|
||||
{
|
||||
State.LengthPending = 0;
|
||||
State.MethodCount = Word & 0xffffff;
|
||||
_state.LengthPending = 0;
|
||||
_state.MethodCount = word & 0xffffff;
|
||||
}
|
||||
else if (State.MethodCount != 0)
|
||||
else if (_state.MethodCount != 0)
|
||||
{
|
||||
if (!SliEnable || SliActive)
|
||||
if (!_sliEnable || _sliActive)
|
||||
{
|
||||
CallMethod(Word);
|
||||
CallMethod(word);
|
||||
}
|
||||
|
||||
if (!State.NonIncrementing)
|
||||
if (!_state.NonIncrementing)
|
||||
{
|
||||
State.Method++;
|
||||
_state.Method++;
|
||||
}
|
||||
|
||||
if (State.IncrementOnce)
|
||||
if (_state.IncrementOnce)
|
||||
{
|
||||
State.NonIncrementing = true;
|
||||
_state.NonIncrementing = true;
|
||||
}
|
||||
|
||||
State.MethodCount--;
|
||||
_state.MethodCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
int SumissionMode = (Word >> 29) & 7;
|
||||
int sumissionMode = (word >> 29) & 7;
|
||||
|
||||
switch (SumissionMode)
|
||||
switch (sumissionMode)
|
||||
{
|
||||
case 1:
|
||||
//Incrementing.
|
||||
SetNonImmediateState(Word);
|
||||
SetNonImmediateState(word);
|
||||
|
||||
State.NonIncrementing = false;
|
||||
State.IncrementOnce = false;
|
||||
_state.NonIncrementing = false;
|
||||
_state.IncrementOnce = false;
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//Non-incrementing.
|
||||
SetNonImmediateState(Word);
|
||||
SetNonImmediateState(word);
|
||||
|
||||
State.NonIncrementing = true;
|
||||
State.IncrementOnce = false;
|
||||
_state.NonIncrementing = true;
|
||||
_state.IncrementOnce = false;
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
//Immediate.
|
||||
State.Method = (Word >> 0) & 0x1fff;
|
||||
State.SubChannel = (Word >> 13) & 7;
|
||||
State.NonIncrementing = true;
|
||||
State.IncrementOnce = false;
|
||||
_state.Method = (word >> 0) & 0x1fff;
|
||||
_state.SubChannel = (word >> 13) & 7;
|
||||
_state.NonIncrementing = true;
|
||||
_state.IncrementOnce = false;
|
||||
|
||||
CallMethod((Word >> 16) & 0x1fff);
|
||||
CallMethod((word >> 16) & 0x1fff);
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
//Increment-once.
|
||||
SetNonImmediateState(Word);
|
||||
SetNonImmediateState(word);
|
||||
|
||||
State.NonIncrementing = false;
|
||||
State.IncrementOnce = true;
|
||||
_state.NonIncrementing = false;
|
||||
_state.IncrementOnce = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IbEnable && IbBuffer.TryDequeue(out (NvGpuVmm Vmm, long Entry) Tuple))
|
||||
else if (_ibEnable && _ibBuffer.TryDequeue(out (NvGpuVmm Vmm, long Entry) tuple))
|
||||
{
|
||||
this.Vmm = Tuple.Vmm;
|
||||
_vmm = tuple.Vmm;
|
||||
|
||||
long Entry = Tuple.Entry;
|
||||
long entry = tuple.Entry;
|
||||
|
||||
int Length = (int)(Entry >> 42) & 0x1fffff;
|
||||
int length = (int)(entry >> 42) & 0x1fffff;
|
||||
|
||||
DmaGet = Entry & 0xfffffffffc;
|
||||
DmaPut = DmaGet + Length * 4;
|
||||
_dmaGet = entry & 0xfffffffffc;
|
||||
_dmaPut = _dmaGet + length * 4;
|
||||
|
||||
NonMain = (Entry & (1L << 41)) != 0;
|
||||
_nonMain = (entry & (1L << 41)) != 0;
|
||||
|
||||
Gpu.ResourceManager.ClearPbCache();
|
||||
_gpu.ResourceManager.ClearPbCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -171,20 +171,20 @@ namespace Ryujinx.Graphics
|
|||
return true;
|
||||
}
|
||||
|
||||
private void SetNonImmediateState(int Word)
|
||||
private void SetNonImmediateState(int word)
|
||||
{
|
||||
State.Method = (Word >> 0) & 0x1fff;
|
||||
State.SubChannel = (Word >> 13) & 7;
|
||||
State.MethodCount = (Word >> 16) & 0x1fff;
|
||||
_state.Method = (word >> 0) & 0x1fff;
|
||||
_state.SubChannel = (word >> 13) & 7;
|
||||
_state.MethodCount = (word >> 16) & 0x1fff;
|
||||
}
|
||||
|
||||
private void CallMethod(int Argument)
|
||||
private void CallMethod(int argument)
|
||||
{
|
||||
Gpu.Fifo.CallMethod(Vmm, new GpuMethodCall(
|
||||
State.Method,
|
||||
Argument,
|
||||
State.SubChannel,
|
||||
State.MethodCount));
|
||||
_gpu.Fifo.CallMethod(_vmm, new GpuMethodCall(
|
||||
_state.Method,
|
||||
argument,
|
||||
_state.SubChannel,
|
||||
_state.MethodCount));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,15 +10,15 @@ namespace Ryujinx.Graphics
|
|||
public bool IsLastCall => MethodCount <= 1;
|
||||
|
||||
public GpuMethodCall(
|
||||
int Method,
|
||||
int Argument,
|
||||
int SubChannel = 0,
|
||||
int MethodCount = 0)
|
||||
int method,
|
||||
int argument,
|
||||
int subChannel = 0,
|
||||
int methodCount = 0)
|
||||
{
|
||||
this.Method = Method;
|
||||
this.Argument = Argument;
|
||||
this.SubChannel = SubChannel;
|
||||
this.MethodCount = MethodCount;
|
||||
Method = method;
|
||||
Argument = argument;
|
||||
SubChannel = subChannel;
|
||||
MethodCount = methodCount;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,124 +18,124 @@ namespace Ryujinx.Graphics
|
|||
ZetaBuffer
|
||||
}
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
private HashSet<long>[] UploadedKeys;
|
||||
private HashSet<long>[] _uploadedKeys;
|
||||
|
||||
private Dictionary<long, ImageType> ImageTypes;
|
||||
private Dictionary<long, int> MirroredTextures;
|
||||
private Dictionary<long, ImageType> _imageTypes;
|
||||
private Dictionary<long, int> _mirroredTextures;
|
||||
|
||||
public GpuResourceManager(NvGpu Gpu)
|
||||
public GpuResourceManager(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
UploadedKeys = new HashSet<long>[(int)NvGpuBufferType.Count];
|
||||
_uploadedKeys = new HashSet<long>[(int)NvGpuBufferType.Count];
|
||||
|
||||
for (int Index = 0; Index < UploadedKeys.Length; Index++)
|
||||
for (int index = 0; index < _uploadedKeys.Length; index++)
|
||||
{
|
||||
UploadedKeys[Index] = new HashSet<long>();
|
||||
_uploadedKeys[index] = new HashSet<long>();
|
||||
}
|
||||
|
||||
ImageTypes = new Dictionary<long, ImageType>();
|
||||
MirroredTextures = new Dictionary<long, int>();
|
||||
_imageTypes = new Dictionary<long, ImageType>();
|
||||
_mirroredTextures = new Dictionary<long, int>();
|
||||
}
|
||||
|
||||
public void SendColorBuffer(NvGpuVmm Vmm, long Position, int Attachment, GalImage NewImage)
|
||||
public void SendColorBuffer(NvGpuVmm vmm, long position, int attachment, GalImage newImage)
|
||||
{
|
||||
long Size = (uint)ImageUtils.GetSize(NewImage);
|
||||
long size = (uint)ImageUtils.GetSize(newImage);
|
||||
|
||||
ImageTypes[Position] = ImageType.ColorBuffer;
|
||||
_imageTypes[position] = ImageType.ColorBuffer;
|
||||
|
||||
if (!TryReuse(Vmm, Position, NewImage))
|
||||
if (!TryReuse(vmm, position, newImage))
|
||||
{
|
||||
Gpu.Renderer.Texture.Create(Position, (int)Size, NewImage);
|
||||
_gpu.Renderer.Texture.Create(position, (int)size, newImage);
|
||||
}
|
||||
|
||||
Gpu.Renderer.RenderTarget.BindColor(Position, Attachment);
|
||||
_gpu.Renderer.RenderTarget.BindColor(position, attachment);
|
||||
}
|
||||
|
||||
public void SendZetaBuffer(NvGpuVmm Vmm, long Position, GalImage NewImage)
|
||||
public void SendZetaBuffer(NvGpuVmm vmm, long position, GalImage newImage)
|
||||
{
|
||||
long Size = (uint)ImageUtils.GetSize(NewImage);
|
||||
long size = (uint)ImageUtils.GetSize(newImage);
|
||||
|
||||
ImageTypes[Position] = ImageType.ZetaBuffer;
|
||||
_imageTypes[position] = ImageType.ZetaBuffer;
|
||||
|
||||
if (!TryReuse(Vmm, Position, NewImage))
|
||||
if (!TryReuse(vmm, position, newImage))
|
||||
{
|
||||
Gpu.Renderer.Texture.Create(Position, (int)Size, NewImage);
|
||||
_gpu.Renderer.Texture.Create(position, (int)size, newImage);
|
||||
}
|
||||
|
||||
Gpu.Renderer.RenderTarget.BindZeta(Position);
|
||||
_gpu.Renderer.RenderTarget.BindZeta(position);
|
||||
}
|
||||
|
||||
public void SendTexture(NvGpuVmm Vmm, long Position, GalImage NewImage)
|
||||
public void SendTexture(NvGpuVmm vmm, long position, GalImage newImage)
|
||||
{
|
||||
PrepareSendTexture(Vmm, Position, NewImage);
|
||||
PrepareSendTexture(vmm, position, newImage);
|
||||
|
||||
ImageTypes[Position] = ImageType.Texture;
|
||||
_imageTypes[position] = ImageType.Texture;
|
||||
}
|
||||
|
||||
public bool TryGetTextureLayer(long Position, out int LayerIndex)
|
||||
public bool TryGetTextureLayer(long position, out int layerIndex)
|
||||
{
|
||||
if (MirroredTextures.TryGetValue(Position, out LayerIndex))
|
||||
if (_mirroredTextures.TryGetValue(position, out layerIndex))
|
||||
{
|
||||
ImageType Type = ImageTypes[Position];
|
||||
ImageType type = _imageTypes[position];
|
||||
|
||||
// FIXME(thog): I'm actually unsure if we should deny all other image type, gpu testing needs to be done here.
|
||||
if (Type != ImageType.Texture && Type != ImageType.TextureArrayLayer)
|
||||
if (type != ImageType.Texture && type != ImageType.TextureArrayLayer)
|
||||
{
|
||||
LayerIndex = -1;
|
||||
layerIndex = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LayerIndex = -1;
|
||||
layerIndex = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetTextureArrayLayer(long Position, int LayerIndex)
|
||||
public void SetTextureArrayLayer(long position, int layerIndex)
|
||||
{
|
||||
ImageTypes[Position] = ImageType.TextureArrayLayer;
|
||||
MirroredTextures[Position] = LayerIndex;
|
||||
_imageTypes[position] = ImageType.TextureArrayLayer;
|
||||
_mirroredTextures[position] = layerIndex;
|
||||
}
|
||||
|
||||
private void PrepareSendTexture(NvGpuVmm Vmm, long Position, GalImage NewImage)
|
||||
private void PrepareSendTexture(NvGpuVmm vmm, long position, GalImage newImage)
|
||||
{
|
||||
long Size = ImageUtils.GetSize(NewImage);
|
||||
long size = ImageUtils.GetSize(newImage);
|
||||
|
||||
bool SkipCheck = false;
|
||||
bool skipCheck = false;
|
||||
|
||||
if (ImageTypes.TryGetValue(Position, out ImageType OldType))
|
||||
if (_imageTypes.TryGetValue(position, out ImageType oldType))
|
||||
{
|
||||
if (OldType == ImageType.ColorBuffer || OldType == ImageType.ZetaBuffer)
|
||||
if (oldType == ImageType.ColorBuffer || oldType == ImageType.ZetaBuffer)
|
||||
{
|
||||
//Avoid data destruction
|
||||
MemoryRegionModified(Vmm, Position, Size, NvGpuBufferType.Texture);
|
||||
MemoryRegionModified(vmm, position, size, NvGpuBufferType.Texture);
|
||||
|
||||
SkipCheck = true;
|
||||
skipCheck = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (SkipCheck || !MemoryRegionModified(Vmm, Position, Size, NvGpuBufferType.Texture))
|
||||
if (skipCheck || !MemoryRegionModified(vmm, position, size, NvGpuBufferType.Texture))
|
||||
{
|
||||
if (TryReuse(Vmm, Position, NewImage))
|
||||
if (TryReuse(vmm, position, newImage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] Data = ImageUtils.ReadTexture(Vmm, NewImage, Position);
|
||||
byte[] data = ImageUtils.ReadTexture(vmm, newImage, position);
|
||||
|
||||
Gpu.Renderer.Texture.Create(Position, Data, NewImage);
|
||||
_gpu.Renderer.Texture.Create(position, data, newImage);
|
||||
}
|
||||
|
||||
private bool TryReuse(NvGpuVmm Vmm, long Position, GalImage NewImage)
|
||||
private bool TryReuse(NvGpuVmm vmm, long position, GalImage newImage)
|
||||
{
|
||||
if (Gpu.Renderer.Texture.TryGetImage(Position, out GalImage CachedImage) && CachedImage.TextureTarget == NewImage.TextureTarget && CachedImage.SizeMatches(NewImage))
|
||||
if (_gpu.Renderer.Texture.TryGetImage(position, out GalImage cachedImage) && cachedImage.TextureTarget == newImage.TextureTarget && cachedImage.SizeMatches(newImage))
|
||||
{
|
||||
Gpu.Renderer.RenderTarget.Reinterpret(Position, NewImage);
|
||||
_gpu.Renderer.RenderTarget.Reinterpret(position, newImage);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -143,29 +143,29 @@ namespace Ryujinx.Graphics
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool MemoryRegionModified(NvGpuVmm Vmm, long Position, long Size, NvGpuBufferType Type)
|
||||
public bool MemoryRegionModified(NvGpuVmm vmm, long position, long size, NvGpuBufferType type)
|
||||
{
|
||||
HashSet<long> Uploaded = UploadedKeys[(int)Type];
|
||||
HashSet<long> uploaded = _uploadedKeys[(int)type];
|
||||
|
||||
if (!Uploaded.Add(Position))
|
||||
if (!uploaded.Add(position))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Vmm.IsRegionModified(Position, Size, Type);
|
||||
return vmm.IsRegionModified(position, size, type);
|
||||
}
|
||||
|
||||
public void ClearPbCache()
|
||||
{
|
||||
for (int Index = 0; Index < UploadedKeys.Length; Index++)
|
||||
for (int index = 0; index < _uploadedKeys.Length; index++)
|
||||
{
|
||||
UploadedKeys[Index].Clear();
|
||||
_uploadedKeys[index].Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearPbCache(NvGpuBufferType Type)
|
||||
public void ClearPbCache(NvGpuBufferType type)
|
||||
{
|
||||
UploadedKeys[(int)Type].Clear();
|
||||
_uploadedKeys[(int)type].Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,9 +224,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
vmm.IsRegionModified(dstKey, ImageUtils.GetSize(dstTexture), NvGpuBufferType.Texture);
|
||||
}
|
||||
|
||||
private static GalMemoryLayout GetLayout(bool Linear)
|
||||
private static GalMemoryLayout GetLayout(bool linear)
|
||||
{
|
||||
return Linear
|
||||
return linear
|
||||
? GalMemoryLayout.Pitch
|
||||
: GalMemoryLayout.BlockLinear;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
private void Call2DMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
_gpu.Engine2d.CallMethod(vmm, methCall);
|
||||
_gpu.Engine2D.CallMethod(vmm, methCall);
|
||||
}
|
||||
|
||||
private void Call3DMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
|
@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
int position = methCall.Argument;
|
||||
|
||||
_macros[_currMacroBindIndex] = new CachedMacro(this, _gpu.Engine3d, position);
|
||||
_macros[_currMacroBindIndex] = new CachedMacro(this, _gpu.Engine3D, position);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
}
|
||||
else if (methCall.Method < 0xe00)
|
||||
{
|
||||
_gpu.Engine3d.CallMethod(vmm, methCall);
|
||||
_gpu.Engine3D.CallMethod(vmm, methCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -8,177 +8,177 @@ namespace Ryujinx.Graphics.Memory
|
|||
{
|
||||
public const long AddrSize = 1L << 40;
|
||||
|
||||
private const int PTLvl0Bits = 14;
|
||||
private const int PTLvl1Bits = 14;
|
||||
private const int PTPageBits = 12;
|
||||
private const int PtLvl0Bits = 14;
|
||||
private const int PtLvl1Bits = 14;
|
||||
private const int PtPageBits = 12;
|
||||
|
||||
private const int PTLvl0Size = 1 << PTLvl0Bits;
|
||||
private const int PTLvl1Size = 1 << PTLvl1Bits;
|
||||
public const int PageSize = 1 << PTPageBits;
|
||||
private const int PtLvl0Size = 1 << PtLvl0Bits;
|
||||
private const int PtLvl1Size = 1 << PtLvl1Bits;
|
||||
public const int PageSize = 1 << PtPageBits;
|
||||
|
||||
private const int PTLvl0Mask = PTLvl0Size - 1;
|
||||
private const int PTLvl1Mask = PTLvl1Size - 1;
|
||||
private const int PtLvl0Mask = PtLvl0Size - 1;
|
||||
private const int PtLvl1Mask = PtLvl1Size - 1;
|
||||
public const int PageMask = PageSize - 1;
|
||||
|
||||
private const int PTLvl0Bit = PTPageBits + PTLvl1Bits;
|
||||
private const int PTLvl1Bit = PTPageBits;
|
||||
private const int PtLvl0Bit = PtPageBits + PtLvl1Bits;
|
||||
private const int PtLvl1Bit = PtPageBits;
|
||||
|
||||
public MemoryManager Memory { get; private set; }
|
||||
|
||||
private NvGpuVmmCache Cache;
|
||||
private NvGpuVmmCache _cache;
|
||||
|
||||
private const long PteUnmapped = -1;
|
||||
private const long PteReserved = -2;
|
||||
|
||||
private long[][] PageTable;
|
||||
private long[][] _pageTable;
|
||||
|
||||
public NvGpuVmm(MemoryManager Memory)
|
||||
public NvGpuVmm(MemoryManager memory)
|
||||
{
|
||||
this.Memory = Memory;
|
||||
Memory = memory;
|
||||
|
||||
Cache = new NvGpuVmmCache(Memory);
|
||||
_cache = new NvGpuVmmCache(memory);
|
||||
|
||||
PageTable = new long[PTLvl0Size][];
|
||||
_pageTable = new long[PtLvl0Size][];
|
||||
}
|
||||
|
||||
public long Map(long PA, long VA, long Size)
|
||||
public long Map(long pa, long va, long size)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(VA + Offset, PA + Offset);
|
||||
SetPte(va + offset, pa + offset);
|
||||
}
|
||||
}
|
||||
|
||||
return VA;
|
||||
return va;
|
||||
}
|
||||
|
||||
public long Map(long PA, long Size)
|
||||
public long Map(long pa, long size)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
long VA = GetFreePosition(Size);
|
||||
long va = GetFreePosition(size);
|
||||
|
||||
if (VA != -1)
|
||||
if (va != -1)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(VA + Offset, PA + Offset);
|
||||
SetPte(va + offset, pa + offset);
|
||||
}
|
||||
}
|
||||
|
||||
return VA;
|
||||
return va;
|
||||
}
|
||||
}
|
||||
|
||||
public long MapLow(long PA, long Size)
|
||||
public long MapLow(long pa, long size)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
long VA = GetFreePosition(Size, 1, PageSize);
|
||||
long va = GetFreePosition(size, 1, PageSize);
|
||||
|
||||
if (VA != -1 && (ulong)VA <= uint.MaxValue && (ulong)(VA + Size) <= uint.MaxValue)
|
||||
if (va != -1 && (ulong)va <= uint.MaxValue && (ulong)(va + size) <= uint.MaxValue)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(VA + Offset, PA + Offset);
|
||||
SetPte(va + offset, pa + offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VA = -1;
|
||||
va = -1;
|
||||
}
|
||||
|
||||
return VA;
|
||||
return va;
|
||||
}
|
||||
}
|
||||
|
||||
public long ReserveFixed(long VA, long Size)
|
||||
public long ReserveFixed(long va, long size)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
if (IsPageInUse(VA + Offset))
|
||||
if (IsPageInUse(va + offset))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(VA + Offset, PteReserved);
|
||||
SetPte(va + offset, PteReserved);
|
||||
}
|
||||
}
|
||||
|
||||
return VA;
|
||||
return va;
|
||||
}
|
||||
|
||||
public long Reserve(long Size, long Align)
|
||||
public long Reserve(long size, long align)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
long Position = GetFreePosition(Size, Align);
|
||||
long position = GetFreePosition(size, align);
|
||||
|
||||
if (Position != -1)
|
||||
if (position != -1)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(Position + Offset, PteReserved);
|
||||
SetPte(position + offset, PteReserved);
|
||||
}
|
||||
}
|
||||
|
||||
return Position;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
public void Free(long VA, long Size)
|
||||
public void Free(long va, long size)
|
||||
{
|
||||
lock (PageTable)
|
||||
lock (_pageTable)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(VA + Offset, PteUnmapped);
|
||||
SetPte(va + offset, PteUnmapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long GetFreePosition(long Size, long Align = 1, long Start = 1L << 32)
|
||||
private long GetFreePosition(long size, long align = 1, long start = 1L << 32)
|
||||
{
|
||||
//Note: Address 0 is not considered valid by the driver,
|
||||
//when 0 is returned it's considered a mapping error.
|
||||
long Position = Start;
|
||||
long FreeSize = 0;
|
||||
long position = start;
|
||||
long freeSize = 0;
|
||||
|
||||
if (Align < 1)
|
||||
if (align < 1)
|
||||
{
|
||||
Align = 1;
|
||||
align = 1;
|
||||
}
|
||||
|
||||
Align = (Align + PageMask) & ~PageMask;
|
||||
align = (align + PageMask) & ~PageMask;
|
||||
|
||||
while (Position + FreeSize < AddrSize)
|
||||
while (position + freeSize < AddrSize)
|
||||
{
|
||||
if (!IsPageInUse(Position + FreeSize))
|
||||
if (!IsPageInUse(position + freeSize))
|
||||
{
|
||||
FreeSize += PageSize;
|
||||
freeSize += PageSize;
|
||||
|
||||
if (FreeSize >= Size)
|
||||
if (freeSize >= size)
|
||||
{
|
||||
return Position;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Position += FreeSize + PageSize;
|
||||
FreeSize = 0;
|
||||
position += freeSize + PageSize;
|
||||
freeSize = 0;
|
||||
|
||||
long Remainder = Position % Align;
|
||||
long remainder = position % align;
|
||||
|
||||
if (Remainder != 0)
|
||||
if (remainder != 0)
|
||||
{
|
||||
Position = (Position - Remainder) + Align;
|
||||
position = (position - remainder) + align;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,23 +186,23 @@ namespace Ryujinx.Graphics.Memory
|
|||
return -1;
|
||||
}
|
||||
|
||||
public long GetPhysicalAddress(long VA)
|
||||
public long GetPhysicalAddress(long va)
|
||||
{
|
||||
long BasePos = GetPte(VA);
|
||||
long basePos = GetPte(va);
|
||||
|
||||
if (BasePos < 0)
|
||||
if (basePos < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return BasePos + (VA & PageMask);
|
||||
return basePos + (va & PageMask);
|
||||
}
|
||||
|
||||
public bool IsRegionFree(long VA, long Size)
|
||||
public bool IsRegionFree(long va, long size)
|
||||
{
|
||||
for (long Offset = 0; Offset < Size; Offset += PageSize)
|
||||
for (long offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
if (IsPageInUse(VA + Offset))
|
||||
if (IsPageInUse(va + offset))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -211,189 +211,189 @@ namespace Ryujinx.Graphics.Memory
|
|||
return true;
|
||||
}
|
||||
|
||||
private bool IsPageInUse(long VA)
|
||||
private bool IsPageInUse(long va)
|
||||
{
|
||||
if (VA >> PTLvl0Bits + PTLvl1Bits + PTPageBits != 0)
|
||||
if (va >> PtLvl0Bits + PtLvl1Bits + PtPageBits != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long L0 = (VA >> PTLvl0Bit) & PTLvl0Mask;
|
||||
long L1 = (VA >> PTLvl1Bit) & PTLvl1Mask;
|
||||
long l0 = (va >> PtLvl0Bit) & PtLvl0Mask;
|
||||
long l1 = (va >> PtLvl1Bit) & PtLvl1Mask;
|
||||
|
||||
if (PageTable[L0] == null)
|
||||
if (_pageTable[l0] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return PageTable[L0][L1] != PteUnmapped;
|
||||
return _pageTable[l0][l1] != PteUnmapped;
|
||||
}
|
||||
|
||||
private long GetPte(long Position)
|
||||
private long GetPte(long position)
|
||||
{
|
||||
long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask;
|
||||
long L1 = (Position >> PTLvl1Bit) & PTLvl1Mask;
|
||||
long l0 = (position >> PtLvl0Bit) & PtLvl0Mask;
|
||||
long l1 = (position >> PtLvl1Bit) & PtLvl1Mask;
|
||||
|
||||
if (PageTable[L0] == null)
|
||||
if (_pageTable[l0] == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return PageTable[L0][L1];
|
||||
return _pageTable[l0][l1];
|
||||
}
|
||||
|
||||
private void SetPte(long Position, long TgtAddr)
|
||||
private void SetPte(long position, long tgtAddr)
|
||||
{
|
||||
long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask;
|
||||
long L1 = (Position >> PTLvl1Bit) & PTLvl1Mask;
|
||||
long l0 = (position >> PtLvl0Bit) & PtLvl0Mask;
|
||||
long l1 = (position >> PtLvl1Bit) & PtLvl1Mask;
|
||||
|
||||
if (PageTable[L0] == null)
|
||||
if (_pageTable[l0] == null)
|
||||
{
|
||||
PageTable[L0] = new long[PTLvl1Size];
|
||||
_pageTable[l0] = new long[PtLvl1Size];
|
||||
|
||||
for (int Index = 0; Index < PTLvl1Size; Index++)
|
||||
for (int index = 0; index < PtLvl1Size; index++)
|
||||
{
|
||||
PageTable[L0][Index] = PteUnmapped;
|
||||
_pageTable[l0][index] = PteUnmapped;
|
||||
}
|
||||
}
|
||||
|
||||
PageTable[L0][L1] = TgtAddr;
|
||||
_pageTable[l0][l1] = tgtAddr;
|
||||
}
|
||||
|
||||
public bool IsRegionModified(long PA, long Size, NvGpuBufferType BufferType)
|
||||
public bool IsRegionModified(long pa, long size, NvGpuBufferType bufferType)
|
||||
{
|
||||
return Cache.IsRegionModified(PA, Size, BufferType);
|
||||
return _cache.IsRegionModified(pa, size, bufferType);
|
||||
}
|
||||
|
||||
public bool TryGetHostAddress(long Position, long Size, out IntPtr Ptr)
|
||||
public bool TryGetHostAddress(long position, long size, out IntPtr ptr)
|
||||
{
|
||||
return Memory.TryGetHostAddress(GetPhysicalAddress(Position), Size, out Ptr);
|
||||
return Memory.TryGetHostAddress(GetPhysicalAddress(position), size, out ptr);
|
||||
}
|
||||
|
||||
public byte ReadByte(long Position)
|
||||
public byte ReadByte(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadByte(Position);
|
||||
return Memory.ReadByte(position);
|
||||
}
|
||||
|
||||
public ushort ReadUInt16(long Position)
|
||||
public ushort ReadUInt16(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadUInt16(Position);
|
||||
return Memory.ReadUInt16(position);
|
||||
}
|
||||
|
||||
public uint ReadUInt32(long Position)
|
||||
public uint ReadUInt32(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadUInt32(Position);
|
||||
return Memory.ReadUInt32(position);
|
||||
}
|
||||
|
||||
public ulong ReadUInt64(long Position)
|
||||
public ulong ReadUInt64(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadUInt64(Position);
|
||||
return Memory.ReadUInt64(position);
|
||||
}
|
||||
|
||||
public sbyte ReadSByte(long Position)
|
||||
public sbyte ReadSByte(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadSByte(Position);
|
||||
return Memory.ReadSByte(position);
|
||||
}
|
||||
|
||||
public short ReadInt16(long Position)
|
||||
public short ReadInt16(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadInt16(Position);
|
||||
return Memory.ReadInt16(position);
|
||||
}
|
||||
|
||||
public int ReadInt32(long Position)
|
||||
public int ReadInt32(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadInt32(Position);
|
||||
return Memory.ReadInt32(position);
|
||||
}
|
||||
|
||||
public long ReadInt64(long Position)
|
||||
public long ReadInt64(long position)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadInt64(Position);
|
||||
return Memory.ReadInt64(position);
|
||||
}
|
||||
|
||||
public byte[] ReadBytes(long Position, long Size)
|
||||
public byte[] ReadBytes(long position, long size)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
return Memory.ReadBytes(Position, Size);
|
||||
return Memory.ReadBytes(position, size);
|
||||
}
|
||||
|
||||
public void WriteByte(long Position, byte Value)
|
||||
public void WriteByte(long position, byte value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteByte(Position, Value);
|
||||
Memory.WriteByte(position, value);
|
||||
}
|
||||
|
||||
public void WriteUInt16(long Position, ushort Value)
|
||||
public void WriteUInt16(long position, ushort value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteUInt16(Position, Value);
|
||||
Memory.WriteUInt16(position, value);
|
||||
}
|
||||
|
||||
public void WriteUInt32(long Position, uint Value)
|
||||
public void WriteUInt32(long position, uint value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteUInt32(Position, Value);
|
||||
Memory.WriteUInt32(position, value);
|
||||
}
|
||||
|
||||
public void WriteUInt64(long Position, ulong Value)
|
||||
public void WriteUInt64(long position, ulong value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteUInt64(Position, Value);
|
||||
Memory.WriteUInt64(position, value);
|
||||
}
|
||||
|
||||
public void WriteSByte(long Position, sbyte Value)
|
||||
public void WriteSByte(long position, sbyte value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteSByte(Position, Value);
|
||||
Memory.WriteSByte(position, value);
|
||||
}
|
||||
|
||||
public void WriteInt16(long Position, short Value)
|
||||
public void WriteInt16(long position, short value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteInt16(Position, Value);
|
||||
Memory.WriteInt16(position, value);
|
||||
}
|
||||
|
||||
public void WriteInt32(long Position, int Value)
|
||||
public void WriteInt32(long position, int value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteInt32(Position, Value);
|
||||
Memory.WriteInt32(position, value);
|
||||
}
|
||||
|
||||
public void WriteInt64(long Position, long Value)
|
||||
public void WriteInt64(long position, long value)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteInt64(Position, Value);
|
||||
Memory.WriteInt64(position, value);
|
||||
}
|
||||
|
||||
public void WriteBytes(long Position, byte[] Data)
|
||||
public void WriteBytes(long position, byte[] data)
|
||||
{
|
||||
Position = GetPhysicalAddress(Position);
|
||||
position = GetPhysicalAddress(position);
|
||||
|
||||
Memory.WriteBytes(Position, Data);
|
||||
Memory.WriteBytes(position, data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Memory
|
|||
private const long PageSize = MemoryManager.PageSize;
|
||||
private const long PageMask = MemoryManager.PageMask;
|
||||
|
||||
private ConcurrentDictionary<long, int>[] CachedPages;
|
||||
private ConcurrentDictionary<long, int>[] _cachedPages;
|
||||
|
||||
private MemoryManager _memory;
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Memory
|
|||
{
|
||||
_memory = memory;
|
||||
|
||||
CachedPages = new ConcurrentDictionary<long, int>[1 << 20];
|
||||
_cachedPages = new ConcurrentDictionary<long, int>[1 << 20];
|
||||
}
|
||||
|
||||
public bool IsRegionModified(long position, long size, NvGpuBufferType bufferType)
|
||||
|
@ -41,17 +41,17 @@ namespace Ryujinx.Graphics.Memory
|
|||
{
|
||||
long page = _memory.GetPhysicalAddress(va) >> PageBits;
|
||||
|
||||
ConcurrentDictionary<long, int> dictionary = CachedPages[page];
|
||||
ConcurrentDictionary<long, int> dictionary = _cachedPages[page];
|
||||
|
||||
if (dictionary == null)
|
||||
{
|
||||
dictionary = new ConcurrentDictionary<long, int>();
|
||||
|
||||
CachedPages[page] = dictionary;
|
||||
_cachedPages[page] = dictionary;
|
||||
}
|
||||
else if (modified)
|
||||
{
|
||||
CachedPages[page].Clear();
|
||||
_cachedPages[page].Clear();
|
||||
}
|
||||
|
||||
if (dictionary.TryGetValue(pa, out int currBuffMask))
|
||||
|
|
|
@ -15,45 +15,45 @@ namespace Ryujinx.Graphics
|
|||
public DmaPusher Pusher { get; private set; }
|
||||
|
||||
internal NvGpuFifo Fifo { get; private set; }
|
||||
internal NvGpuEngine2D Engine2d { get; private set; }
|
||||
internal NvGpuEngine3D Engine3d { get; private set; }
|
||||
internal NvGpuEngine2D Engine2D { get; private set; }
|
||||
internal NvGpuEngine3D Engine3D { get; private set; }
|
||||
internal NvGpuEngineM2mf EngineM2mf { get; private set; }
|
||||
internal NvGpuEngineP2mf EngineP2mf { get; private set; }
|
||||
|
||||
private CdmaProcessor CdmaProcessor;
|
||||
private CdmaProcessor _cdmaProcessor;
|
||||
internal VideoDecoder VideoDecoder { get; private set; }
|
||||
internal VideoImageComposer VideoImageComposer { get; private set; }
|
||||
|
||||
public NvGpu(IGalRenderer Renderer)
|
||||
public NvGpu(IGalRenderer renderer)
|
||||
{
|
||||
this.Renderer = Renderer;
|
||||
Renderer = renderer;
|
||||
|
||||
ResourceManager = new GpuResourceManager(this);
|
||||
|
||||
Pusher = new DmaPusher(this);
|
||||
|
||||
Fifo = new NvGpuFifo(this);
|
||||
Engine2d = new NvGpuEngine2D(this);
|
||||
Engine3d = new NvGpuEngine3D(this);
|
||||
Engine2D = new NvGpuEngine2D(this);
|
||||
Engine3D = new NvGpuEngine3D(this);
|
||||
EngineM2mf = new NvGpuEngineM2mf(this);
|
||||
EngineP2mf = new NvGpuEngineP2mf(this);
|
||||
|
||||
CdmaProcessor = new CdmaProcessor(this);
|
||||
_cdmaProcessor = new CdmaProcessor(this);
|
||||
VideoDecoder = new VideoDecoder(this);
|
||||
VideoImageComposer = new VideoImageComposer(this);
|
||||
}
|
||||
|
||||
public void PushCommandBuffer(NvGpuVmm Vmm, int[] CmdBuffer)
|
||||
public void PushCommandBuffer(NvGpuVmm vmm, int[] cmdBuffer)
|
||||
{
|
||||
lock (CdmaProcessor)
|
||||
lock (_cdmaProcessor)
|
||||
{
|
||||
CdmaProcessor.PushCommands(Vmm, CmdBuffer);
|
||||
_cdmaProcessor.PushCommands(vmm, cmdBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void UninitializeVideoDecoder()
|
||||
{
|
||||
lock (CdmaProcessor)
|
||||
lock (_cdmaProcessor)
|
||||
{
|
||||
FFmpegWrapper.Uninitialize();
|
||||
}
|
||||
|
|
|
@ -4,33 +4,33 @@ namespace Ryujinx.Graphics
|
|||
{
|
||||
static class QuadHelper
|
||||
{
|
||||
public static int ConvertSizeQuadsToTris(int Size)
|
||||
public static int ConvertSizeQuadsToTris(int size)
|
||||
{
|
||||
return Size <= 0 ? 0 : (Size / 4) * 6;
|
||||
return size <= 0 ? 0 : (size / 4) * 6;
|
||||
}
|
||||
|
||||
public static int ConvertSizeQuadStripToTris(int Size)
|
||||
public static int ConvertSizeQuadStripToTris(int size)
|
||||
{
|
||||
return Size <= 1 ? 0 : ((Size - 2) / 2) * 6;
|
||||
return size <= 1 ? 0 : ((size - 2) / 2) * 6;
|
||||
}
|
||||
|
||||
public static byte[] ConvertQuadsToTris(byte[] Data, int EntrySize, int Count)
|
||||
public static byte[] ConvertQuadsToTris(byte[] data, int entrySize, int count)
|
||||
{
|
||||
int PrimitivesCount = Count / 4;
|
||||
int primitivesCount = count / 4;
|
||||
|
||||
int QuadPrimSize = 4 * EntrySize;
|
||||
int TrisPrimSize = 6 * EntrySize;
|
||||
int quadPrimSize = 4 * entrySize;
|
||||
int trisPrimSize = 6 * entrySize;
|
||||
|
||||
byte[] Output = new byte[PrimitivesCount * 6 * EntrySize];
|
||||
byte[] output = new byte[primitivesCount * 6 * entrySize];
|
||||
|
||||
for (int Prim = 0; Prim < PrimitivesCount; Prim++)
|
||||
for (int prim = 0; prim < primitivesCount; prim++)
|
||||
{
|
||||
void AssignIndex(int Src, int Dst, int CopyCount = 1)
|
||||
void AssignIndex(int src, int dst, int copyCount = 1)
|
||||
{
|
||||
Src = Prim * QuadPrimSize + Src * EntrySize;
|
||||
Dst = Prim * TrisPrimSize + Dst * EntrySize;
|
||||
src = prim * quadPrimSize + src * entrySize;
|
||||
dst = prim * trisPrimSize + dst * entrySize;
|
||||
|
||||
Buffer.BlockCopy(Data, Src, Output, Dst, CopyCount * EntrySize);
|
||||
Buffer.BlockCopy(data, src, output, dst, copyCount * entrySize);
|
||||
}
|
||||
|
||||
//0 1 2 -> 0 1 2.
|
||||
|
@ -43,26 +43,26 @@ namespace Ryujinx.Graphics
|
|||
AssignIndex(0, 5);
|
||||
}
|
||||
|
||||
return Output;
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] ConvertQuadStripToTris(byte[] Data, int EntrySize, int Count)
|
||||
public static byte[] ConvertQuadStripToTris(byte[] data, int entrySize, int count)
|
||||
{
|
||||
int PrimitivesCount = (Count - 2) / 2;
|
||||
int primitivesCount = (count - 2) / 2;
|
||||
|
||||
int QuadPrimSize = 2 * EntrySize;
|
||||
int TrisPrimSize = 6 * EntrySize;
|
||||
int quadPrimSize = 2 * entrySize;
|
||||
int trisPrimSize = 6 * entrySize;
|
||||
|
||||
byte[] Output = new byte[PrimitivesCount * 6 * EntrySize];
|
||||
byte[] output = new byte[primitivesCount * 6 * entrySize];
|
||||
|
||||
for (int Prim = 0; Prim < PrimitivesCount; Prim++)
|
||||
for (int prim = 0; prim < primitivesCount; prim++)
|
||||
{
|
||||
void AssignIndex(int Src, int Dst, int CopyCount = 1)
|
||||
void AssignIndex(int src, int dst, int copyCount = 1)
|
||||
{
|
||||
Src = Prim * QuadPrimSize + Src * EntrySize + 2 * EntrySize;
|
||||
Dst = Prim * TrisPrimSize + Dst * EntrySize;
|
||||
src = prim * quadPrimSize + src * entrySize + 2 * entrySize;
|
||||
dst = prim * trisPrimSize + dst * entrySize;
|
||||
|
||||
Buffer.BlockCopy(Data, Src, Output, Dst, CopyCount * EntrySize);
|
||||
Buffer.BlockCopy(data, src, output, dst, copyCount * entrySize);
|
||||
}
|
||||
|
||||
//-2 -1 0 -> 0 1 2.
|
||||
|
@ -75,7 +75,7 @@ namespace Ryujinx.Graphics
|
|||
AssignIndex(-2, 5);
|
||||
}
|
||||
|
||||
return Output;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Graphics.Vic
|
|||
|
||||
public StructUnpacker(NvGpuVmm vmm, long position)
|
||||
{
|
||||
this._vmm = vmm;
|
||||
this._position = position;
|
||||
_vmm = vmm;
|
||||
_position = position;
|
||||
|
||||
_buffPos = 64;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace Ryujinx.Graphics.Vic
|
|||
long outputSurfaceChromaUAddress,
|
||||
long outputSurfaceChromaVAddress)
|
||||
{
|
||||
this.PixelFormat = pixelFormat;
|
||||
this.SurfaceWidth = surfaceWidth;
|
||||
this.SurfaceHeight = surfaceHeight;
|
||||
this.GobBlockHeight = gobBlockHeight;
|
||||
this.SurfaceLumaAddress = outputSurfaceLumaAddress;
|
||||
this.SurfaceChromaUAddress = outputSurfaceChromaUAddress;
|
||||
this.SurfaceChromaVAddress = outputSurfaceChromaVAddress;
|
||||
PixelFormat = pixelFormat;
|
||||
SurfaceWidth = surfaceWidth;
|
||||
SurfaceHeight = surfaceHeight;
|
||||
GobBlockHeight = gobBlockHeight;
|
||||
SurfaceLumaAddress = outputSurfaceLumaAddress;
|
||||
SurfaceChromaUAddress = outputSurfaceChromaUAddress;
|
||||
SurfaceChromaVAddress = outputSurfaceChromaVAddress;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Vic
|
|||
|
||||
public VideoImageComposer(NvGpu gpu)
|
||||
{
|
||||
this._gpu = gpu;
|
||||
_gpu = gpu;
|
||||
}
|
||||
|
||||
public void Process(NvGpuVmm vmm, int methodOffset, int[] arguments)
|
||||
|
|
Loading…
Add table
Reference in a new issue