Renaming part 7
This commit is contained in:
parent
33cb66370b
commit
171bc34d2e
16 changed files with 975 additions and 975 deletions
|
@ -6,6 +6,6 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
int[] Registers { get; }
|
||||
|
||||
void CallMethod(NvGpuVmm Vmm, GpuMethodCall MethCall);
|
||||
void CallMethod(NvGpuVmm vmm, GpuMethodCall methCall);
|
||||
}
|
||||
}
|
|
@ -42,78 +42,78 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
BitwiseNotAnd = 12
|
||||
}
|
||||
|
||||
private NvGpuFifo PFifo;
|
||||
private INvGpuEngine Engine;
|
||||
private NvGpuFifo _pFifo;
|
||||
private INvGpuEngine _engine;
|
||||
|
||||
public Queue<int> Fifo { get; private set; }
|
||||
|
||||
private int[] Gprs;
|
||||
private int[] _gprs;
|
||||
|
||||
private int MethAddr;
|
||||
private int MethIncr;
|
||||
private int _methAddr;
|
||||
private int _methIncr;
|
||||
|
||||
private bool Carry;
|
||||
private bool _carry;
|
||||
|
||||
private int OpCode;
|
||||
private int _opCode;
|
||||
|
||||
private int PipeOp;
|
||||
private int _pipeOp;
|
||||
|
||||
private int Pc;
|
||||
private int _pc;
|
||||
|
||||
public MacroInterpreter(NvGpuFifo PFifo, INvGpuEngine Engine)
|
||||
public MacroInterpreter(NvGpuFifo pFifo, INvGpuEngine engine)
|
||||
{
|
||||
this.PFifo = PFifo;
|
||||
this.Engine = Engine;
|
||||
_pFifo = pFifo;
|
||||
_engine = engine;
|
||||
|
||||
Fifo = new Queue<int>();
|
||||
|
||||
Gprs = new int[8];
|
||||
_gprs = new int[8];
|
||||
}
|
||||
|
||||
public void Execute(NvGpuVmm Vmm, int[] Mme, int Position, int Param)
|
||||
public void Execute(NvGpuVmm vmm, int[] mme, int position, int param)
|
||||
{
|
||||
Reset();
|
||||
|
||||
Gprs[1] = Param;
|
||||
_gprs[1] = param;
|
||||
|
||||
Pc = Position;
|
||||
_pc = position;
|
||||
|
||||
FetchOpCode(Mme);
|
||||
FetchOpCode(mme);
|
||||
|
||||
while (Step(Vmm, Mme));
|
||||
while (Step(vmm, mme));
|
||||
|
||||
//Due to the delay slot, we still need to execute
|
||||
//one more instruction before we actually exit.
|
||||
Step(Vmm, Mme);
|
||||
Step(vmm, mme);
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
for (int Index = 0; Index < Gprs.Length; Index++)
|
||||
for (int index = 0; index < _gprs.Length; index++)
|
||||
{
|
||||
Gprs[Index] = 0;
|
||||
_gprs[index] = 0;
|
||||
}
|
||||
|
||||
MethAddr = 0;
|
||||
MethIncr = 0;
|
||||
_methAddr = 0;
|
||||
_methIncr = 0;
|
||||
|
||||
Carry = false;
|
||||
_carry = false;
|
||||
}
|
||||
|
||||
private bool Step(NvGpuVmm Vmm, int[] Mme)
|
||||
private bool Step(NvGpuVmm vmm, int[] mme)
|
||||
{
|
||||
int BaseAddr = Pc - 1;
|
||||
int baseAddr = _pc - 1;
|
||||
|
||||
FetchOpCode(Mme);
|
||||
FetchOpCode(mme);
|
||||
|
||||
if ((OpCode & 7) < 7)
|
||||
if ((_opCode & 7) < 7)
|
||||
{
|
||||
//Operation produces a value.
|
||||
AssignmentOperation AsgOp = (AssignmentOperation)((OpCode >> 4) & 7);
|
||||
AssignmentOperation asgOp = (AssignmentOperation)((_opCode >> 4) & 7);
|
||||
|
||||
int Result = GetAluResult();
|
||||
int result = GetAluResult();
|
||||
|
||||
switch (AsgOp)
|
||||
switch (asgOp)
|
||||
{
|
||||
//Fetch parameter and ignore result.
|
||||
case AssignmentOperation.IgnoreAndFetch:
|
||||
|
@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//Move result.
|
||||
case AssignmentOperation.Move:
|
||||
{
|
||||
SetDstGpr(Result);
|
||||
SetDstGpr(result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -134,9 +134,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//Move result and use as Method Address.
|
||||
case AssignmentOperation.MoveAndSetMaddr:
|
||||
{
|
||||
SetDstGpr(Result);
|
||||
SetDstGpr(result);
|
||||
|
||||
SetMethAddr(Result);
|
||||
SetMethAddr(result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
SetDstGpr(FetchParam());
|
||||
|
||||
Send(Vmm, Result);
|
||||
Send(vmm, result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -154,9 +154,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//Move and send result.
|
||||
case AssignmentOperation.MoveAndSend:
|
||||
{
|
||||
SetDstGpr(Result);
|
||||
SetDstGpr(result);
|
||||
|
||||
Send(Vmm, Result);
|
||||
Send(vmm, result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
SetDstGpr(FetchParam());
|
||||
|
||||
SetMethAddr(Result);
|
||||
SetMethAddr(result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -174,11 +174,11 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//Move result and use as Method Address, then fetch and send paramter.
|
||||
case AssignmentOperation.MoveAndSetMaddrThenFetchAndSend:
|
||||
{
|
||||
SetDstGpr(Result);
|
||||
SetDstGpr(result);
|
||||
|
||||
SetMethAddr(Result);
|
||||
SetMethAddr(result);
|
||||
|
||||
Send(Vmm, FetchParam());
|
||||
Send(vmm, FetchParam());
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -186,11 +186,11 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//Move result and use as Method Address, then send bits 17:12 of result.
|
||||
case AssignmentOperation.MoveAndSetMaddrThenSendHigh:
|
||||
{
|
||||
SetDstGpr(Result);
|
||||
SetDstGpr(result);
|
||||
|
||||
SetMethAddr(Result);
|
||||
SetMethAddr(result);
|
||||
|
||||
Send(Vmm, (Result >> 12) & 0x3f);
|
||||
Send(vmm, (result >> 12) & 0x3f);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -199,50 +199,50 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
else
|
||||
{
|
||||
//Branch.
|
||||
bool OnNotZero = ((OpCode >> 4) & 1) != 0;
|
||||
bool onNotZero = ((_opCode >> 4) & 1) != 0;
|
||||
|
||||
bool Taken = OnNotZero
|
||||
bool taken = onNotZero
|
||||
? GetGprA() != 0
|
||||
: GetGprA() == 0;
|
||||
|
||||
if (Taken)
|
||||
if (taken)
|
||||
{
|
||||
Pc = BaseAddr + GetImm();
|
||||
_pc = baseAddr + GetImm();
|
||||
|
||||
bool NoDelays = (OpCode & 0x20) != 0;
|
||||
bool noDelays = (_opCode & 0x20) != 0;
|
||||
|
||||
if (NoDelays)
|
||||
if (noDelays)
|
||||
{
|
||||
FetchOpCode(Mme);
|
||||
FetchOpCode(mme);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Exit = (OpCode & 0x80) != 0;
|
||||
bool exit = (_opCode & 0x80) != 0;
|
||||
|
||||
return !Exit;
|
||||
return !exit;
|
||||
}
|
||||
|
||||
private void FetchOpCode(int[] Mme)
|
||||
private void FetchOpCode(int[] mme)
|
||||
{
|
||||
OpCode = PipeOp;
|
||||
_opCode = _pipeOp;
|
||||
|
||||
PipeOp = Mme[Pc++];
|
||||
_pipeOp = mme[_pc++];
|
||||
}
|
||||
|
||||
private int GetAluResult()
|
||||
{
|
||||
AluOperation Op = (AluOperation)(OpCode & 7);
|
||||
AluOperation op = (AluOperation)(_opCode & 7);
|
||||
|
||||
switch (Op)
|
||||
switch (op)
|
||||
{
|
||||
case AluOperation.AluReg:
|
||||
{
|
||||
AluRegOperation AluOp = (AluRegOperation)((OpCode >> 17) & 0x1f);
|
||||
AluRegOperation aluOp = (AluRegOperation)((_opCode >> 17) & 0x1f);
|
||||
|
||||
return GetAluResult(AluOp, GetGprA(), GetGprB());
|
||||
return GetAluResult(aluOp, GetGprA(), GetGprB());
|
||||
}
|
||||
|
||||
case AluOperation.AddImmediate:
|
||||
|
@ -254,40 +254,40 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
case AluOperation.BitfieldExtractLslImm:
|
||||
case AluOperation.BitfieldExtractLslReg:
|
||||
{
|
||||
int BfSrcBit = (OpCode >> 17) & 0x1f;
|
||||
int BfSize = (OpCode >> 22) & 0x1f;
|
||||
int BfDstBit = (OpCode >> 27) & 0x1f;
|
||||
int bfSrcBit = (_opCode >> 17) & 0x1f;
|
||||
int bfSize = (_opCode >> 22) & 0x1f;
|
||||
int bfDstBit = (_opCode >> 27) & 0x1f;
|
||||
|
||||
int BfMask = (1 << BfSize) - 1;
|
||||
int bfMask = (1 << bfSize) - 1;
|
||||
|
||||
int Dst = GetGprA();
|
||||
int Src = GetGprB();
|
||||
int dst = GetGprA();
|
||||
int src = GetGprB();
|
||||
|
||||
switch (Op)
|
||||
switch (op)
|
||||
{
|
||||
case AluOperation.BitfieldReplace:
|
||||
{
|
||||
Src = (int)((uint)Src >> BfSrcBit) & BfMask;
|
||||
src = (int)((uint)src >> bfSrcBit) & bfMask;
|
||||
|
||||
Dst &= ~(BfMask << BfDstBit);
|
||||
dst &= ~(bfMask << bfDstBit);
|
||||
|
||||
Dst |= Src << BfDstBit;
|
||||
dst |= src << bfDstBit;
|
||||
|
||||
return Dst;
|
||||
return dst;
|
||||
}
|
||||
|
||||
case AluOperation.BitfieldExtractLslImm:
|
||||
{
|
||||
Src = (int)((uint)Src >> Dst) & BfMask;
|
||||
src = (int)((uint)src >> dst) & bfMask;
|
||||
|
||||
return Src << BfDstBit;
|
||||
return src << bfDstBit;
|
||||
}
|
||||
|
||||
case AluOperation.BitfieldExtractLslReg:
|
||||
{
|
||||
Src = (int)((uint)Src >> BfSrcBit) & BfMask;
|
||||
src = (int)((uint)src >> bfSrcBit) & bfMask;
|
||||
|
||||
return Src << Dst;
|
||||
return src << dst;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,117 +300,117 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
}
|
||||
}
|
||||
|
||||
throw new ArgumentException(nameof(OpCode));
|
||||
throw new ArgumentException(nameof(_opCode));
|
||||
}
|
||||
|
||||
private int GetAluResult(AluRegOperation AluOp, int A, int B)
|
||||
private int GetAluResult(AluRegOperation aluOp, int a, int b)
|
||||
{
|
||||
switch (AluOp)
|
||||
switch (aluOp)
|
||||
{
|
||||
case AluRegOperation.Add:
|
||||
{
|
||||
ulong Result = (ulong)A + (ulong)B;
|
||||
ulong result = (ulong)a + (ulong)b;
|
||||
|
||||
Carry = Result > 0xffffffff;
|
||||
_carry = result > 0xffffffff;
|
||||
|
||||
return (int)Result;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
case AluRegOperation.AddWithCarry:
|
||||
{
|
||||
ulong Result = (ulong)A + (ulong)B + (Carry ? 1UL : 0UL);
|
||||
ulong result = (ulong)a + (ulong)b + (_carry ? 1UL : 0UL);
|
||||
|
||||
Carry = Result > 0xffffffff;
|
||||
_carry = result > 0xffffffff;
|
||||
|
||||
return (int)Result;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
case AluRegOperation.Subtract:
|
||||
{
|
||||
ulong Result = (ulong)A - (ulong)B;
|
||||
ulong result = (ulong)a - (ulong)b;
|
||||
|
||||
Carry = Result < 0x100000000;
|
||||
_carry = result < 0x100000000;
|
||||
|
||||
return (int)Result;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
case AluRegOperation.SubtractWithBorrow:
|
||||
{
|
||||
ulong Result = (ulong)A - (ulong)B - (Carry ? 0UL : 1UL);
|
||||
ulong result = (ulong)a - (ulong)b - (_carry ? 0UL : 1UL);
|
||||
|
||||
Carry = Result < 0x100000000;
|
||||
_carry = result < 0x100000000;
|
||||
|
||||
return (int)Result;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
case AluRegOperation.BitwiseExclusiveOr: return A ^ B;
|
||||
case AluRegOperation.BitwiseOr: return A | B;
|
||||
case AluRegOperation.BitwiseAnd: return A & B;
|
||||
case AluRegOperation.BitwiseAndNot: return A & ~B;
|
||||
case AluRegOperation.BitwiseNotAnd: return ~(A & B);
|
||||
case AluRegOperation.BitwiseExclusiveOr: return a ^ b;
|
||||
case AluRegOperation.BitwiseOr: return a | b;
|
||||
case AluRegOperation.BitwiseAnd: return a & b;
|
||||
case AluRegOperation.BitwiseAndNot: return a & ~b;
|
||||
case AluRegOperation.BitwiseNotAnd: return ~(a & b);
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(AluOp));
|
||||
throw new ArgumentOutOfRangeException(nameof(aluOp));
|
||||
}
|
||||
|
||||
private int GetImm()
|
||||
{
|
||||
//Note: The immediate is signed, the sign-extension is intended here.
|
||||
return OpCode >> 14;
|
||||
return _opCode >> 14;
|
||||
}
|
||||
|
||||
private void SetMethAddr(int Value)
|
||||
private void SetMethAddr(int value)
|
||||
{
|
||||
MethAddr = (Value >> 0) & 0xfff;
|
||||
MethIncr = (Value >> 12) & 0x3f;
|
||||
_methAddr = (value >> 0) & 0xfff;
|
||||
_methIncr = (value >> 12) & 0x3f;
|
||||
}
|
||||
|
||||
private void SetDstGpr(int Value)
|
||||
private void SetDstGpr(int value)
|
||||
{
|
||||
Gprs[(OpCode >> 8) & 7] = Value;
|
||||
_gprs[(_opCode >> 8) & 7] = value;
|
||||
}
|
||||
|
||||
private int GetGprA()
|
||||
{
|
||||
return GetGprValue((OpCode >> 11) & 7);
|
||||
return GetGprValue((_opCode >> 11) & 7);
|
||||
}
|
||||
|
||||
private int GetGprB()
|
||||
{
|
||||
return GetGprValue((OpCode >> 14) & 7);
|
||||
return GetGprValue((_opCode >> 14) & 7);
|
||||
}
|
||||
|
||||
private int GetGprValue(int Index)
|
||||
private int GetGprValue(int index)
|
||||
{
|
||||
return Index != 0 ? Gprs[Index] : 0;
|
||||
return index != 0 ? _gprs[index] : 0;
|
||||
}
|
||||
|
||||
private int FetchParam()
|
||||
{
|
||||
int Value;
|
||||
int value;
|
||||
|
||||
if (!Fifo.TryDequeue(out Value))
|
||||
if (!Fifo.TryDequeue(out value))
|
||||
{
|
||||
Logger.PrintWarning(LogClass.Gpu, "Macro attempted to fetch an inexistent argument.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Value;
|
||||
return value;
|
||||
}
|
||||
|
||||
private int Read(int Reg)
|
||||
private int Read(int reg)
|
||||
{
|
||||
return Engine.Registers[Reg];
|
||||
return _engine.Registers[reg];
|
||||
}
|
||||
|
||||
private void Send(NvGpuVmm Vmm, int Value)
|
||||
private void Send(NvGpuVmm vmm, int value)
|
||||
{
|
||||
GpuMethodCall MethCall = new GpuMethodCall(MethAddr, Value);
|
||||
GpuMethodCall methCall = new GpuMethodCall(_methAddr, value);
|
||||
|
||||
Engine.CallMethod(Vmm, MethCall);
|
||||
_engine.CallMethod(vmm, methCall);
|
||||
|
||||
MethAddr += MethIncr;
|
||||
_methAddr += _methIncr;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
enum NvGpuEngine
|
||||
{
|
||||
_2d = 0x902d,
|
||||
_3d = 0xb197,
|
||||
_2D = 0x902d,
|
||||
_3D = 0xb197,
|
||||
Compute = 0xb1c0,
|
||||
P2mf = 0xa140,
|
||||
M2mf = 0xb0b5
|
||||
|
|
|
@ -5,7 +5,7 @@ using Ryujinx.Graphics.Texture;
|
|||
|
||||
namespace Ryujinx.Graphics.Graphics3d
|
||||
{
|
||||
class NvGpuEngine2d : INvGpuEngine
|
||||
class NvGpuEngine2D : INvGpuEngine
|
||||
{
|
||||
private enum CopyOperation
|
||||
{
|
||||
|
@ -20,187 +20,187 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
public int[] Registers { get; private set; }
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
public NvGpuEngine2d(NvGpu Gpu)
|
||||
public NvGpuEngine2D(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
Registers = new int[0x238];
|
||||
}
|
||||
|
||||
public void CallMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
public void CallMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
WriteRegister(MethCall);
|
||||
WriteRegister(methCall);
|
||||
|
||||
if ((NvGpuEngine2dReg)MethCall.Method == NvGpuEngine2dReg.BlitSrcYInt)
|
||||
if ((NvGpuEngine2DReg)methCall.Method == NvGpuEngine2DReg.BlitSrcYInt)
|
||||
{
|
||||
TextureCopy(Vmm);
|
||||
TextureCopy(vmm);
|
||||
}
|
||||
}
|
||||
|
||||
private void TextureCopy(NvGpuVmm Vmm)
|
||||
private void TextureCopy(NvGpuVmm vmm)
|
||||
{
|
||||
CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation);
|
||||
CopyOperation operation = (CopyOperation)ReadRegister(NvGpuEngine2DReg.CopyOperation);
|
||||
|
||||
int DstFormat = ReadRegister(NvGpuEngine2dReg.DstFormat);
|
||||
bool DstLinear = ReadRegister(NvGpuEngine2dReg.DstLinear) != 0;
|
||||
int DstWidth = ReadRegister(NvGpuEngine2dReg.DstWidth);
|
||||
int DstHeight = ReadRegister(NvGpuEngine2dReg.DstHeight);
|
||||
int DstDepth = ReadRegister(NvGpuEngine2dReg.DstDepth);
|
||||
int DstLayer = ReadRegister(NvGpuEngine2dReg.DstLayer);
|
||||
int DstPitch = ReadRegister(NvGpuEngine2dReg.DstPitch);
|
||||
int DstBlkDim = ReadRegister(NvGpuEngine2dReg.DstBlockDimensions);
|
||||
int dstFormat = ReadRegister(NvGpuEngine2DReg.DstFormat);
|
||||
bool dstLinear = ReadRegister(NvGpuEngine2DReg.DstLinear) != 0;
|
||||
int dstWidth = ReadRegister(NvGpuEngine2DReg.DstWidth);
|
||||
int dstHeight = ReadRegister(NvGpuEngine2DReg.DstHeight);
|
||||
int dstDepth = ReadRegister(NvGpuEngine2DReg.DstDepth);
|
||||
int dstLayer = ReadRegister(NvGpuEngine2DReg.DstLayer);
|
||||
int dstPitch = ReadRegister(NvGpuEngine2DReg.DstPitch);
|
||||
int dstBlkDim = ReadRegister(NvGpuEngine2DReg.DstBlockDimensions);
|
||||
|
||||
int SrcFormat = ReadRegister(NvGpuEngine2dReg.SrcFormat);
|
||||
bool SrcLinear = ReadRegister(NvGpuEngine2dReg.SrcLinear) != 0;
|
||||
int SrcWidth = ReadRegister(NvGpuEngine2dReg.SrcWidth);
|
||||
int SrcHeight = ReadRegister(NvGpuEngine2dReg.SrcHeight);
|
||||
int SrcDepth = ReadRegister(NvGpuEngine2dReg.SrcDepth);
|
||||
int SrcLayer = ReadRegister(NvGpuEngine2dReg.SrcLayer);
|
||||
int SrcPitch = ReadRegister(NvGpuEngine2dReg.SrcPitch);
|
||||
int SrcBlkDim = ReadRegister(NvGpuEngine2dReg.SrcBlockDimensions);
|
||||
int srcFormat = ReadRegister(NvGpuEngine2DReg.SrcFormat);
|
||||
bool srcLinear = ReadRegister(NvGpuEngine2DReg.SrcLinear) != 0;
|
||||
int srcWidth = ReadRegister(NvGpuEngine2DReg.SrcWidth);
|
||||
int srcHeight = ReadRegister(NvGpuEngine2DReg.SrcHeight);
|
||||
int srcDepth = ReadRegister(NvGpuEngine2DReg.SrcDepth);
|
||||
int srcLayer = ReadRegister(NvGpuEngine2DReg.SrcLayer);
|
||||
int srcPitch = ReadRegister(NvGpuEngine2DReg.SrcPitch);
|
||||
int srcBlkDim = ReadRegister(NvGpuEngine2DReg.SrcBlockDimensions);
|
||||
|
||||
int DstBlitX = ReadRegister(NvGpuEngine2dReg.BlitDstX);
|
||||
int DstBlitY = ReadRegister(NvGpuEngine2dReg.BlitDstY);
|
||||
int DstBlitW = ReadRegister(NvGpuEngine2dReg.BlitDstW);
|
||||
int DstBlitH = ReadRegister(NvGpuEngine2dReg.BlitDstH);
|
||||
int dstBlitX = ReadRegister(NvGpuEngine2DReg.BlitDstX);
|
||||
int dstBlitY = ReadRegister(NvGpuEngine2DReg.BlitDstY);
|
||||
int dstBlitW = ReadRegister(NvGpuEngine2DReg.BlitDstW);
|
||||
int dstBlitH = ReadRegister(NvGpuEngine2DReg.BlitDstH);
|
||||
|
||||
long BlitDuDx = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDuDxFract);
|
||||
long BlitDvDy = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitDvDyFract);
|
||||
long blitDuDx = ReadRegisterFixed1_31_32(NvGpuEngine2DReg.BlitDuDxFract);
|
||||
long blitDvDy = ReadRegisterFixed1_31_32(NvGpuEngine2DReg.BlitDvDyFract);
|
||||
|
||||
long SrcBlitX = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcXFract);
|
||||
long SrcBlitY = ReadRegisterFixed1_31_32(NvGpuEngine2dReg.BlitSrcYFract);
|
||||
long srcBlitX = ReadRegisterFixed1_31_32(NvGpuEngine2DReg.BlitSrcXFract);
|
||||
long srcBlitY = ReadRegisterFixed1_31_32(NvGpuEngine2DReg.BlitSrcYFract);
|
||||
|
||||
GalImageFormat SrcImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)SrcFormat);
|
||||
GalImageFormat DstImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)DstFormat);
|
||||
GalImageFormat srcImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)srcFormat);
|
||||
GalImageFormat dstImgFormat = ImageUtils.ConvertSurface((GalSurfaceFormat)dstFormat);
|
||||
|
||||
GalMemoryLayout SrcLayout = GetLayout(SrcLinear);
|
||||
GalMemoryLayout DstLayout = GetLayout(DstLinear);
|
||||
GalMemoryLayout srcLayout = GetLayout(srcLinear);
|
||||
GalMemoryLayout dstLayout = GetLayout(dstLinear);
|
||||
|
||||
int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf);
|
||||
int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf);
|
||||
int srcBlockHeight = 1 << ((srcBlkDim >> 4) & 0xf);
|
||||
int dstBlockHeight = 1 << ((dstBlkDim >> 4) & 0xf);
|
||||
|
||||
long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress);
|
||||
long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress);
|
||||
long srcAddress = MakeInt64From2xInt32(NvGpuEngine2DReg.SrcAddress);
|
||||
long dstAddress = MakeInt64From2xInt32(NvGpuEngine2DReg.DstAddress);
|
||||
|
||||
long SrcKey = Vmm.GetPhysicalAddress(SrcAddress);
|
||||
long DstKey = Vmm.GetPhysicalAddress(DstAddress);
|
||||
long srcKey = vmm.GetPhysicalAddress(srcAddress);
|
||||
long dstKey = vmm.GetPhysicalAddress(dstAddress);
|
||||
|
||||
bool IsSrcLayered = false;
|
||||
bool IsDstLayered = false;
|
||||
bool isSrcLayered = false;
|
||||
bool isDstLayered = false;
|
||||
|
||||
GalTextureTarget SrcTarget = GalTextureTarget.TwoD;
|
||||
GalTextureTarget srcTarget = GalTextureTarget.TwoD;
|
||||
|
||||
if (SrcDepth != 0)
|
||||
if (srcDepth != 0)
|
||||
{
|
||||
SrcTarget = GalTextureTarget.TwoDArray;
|
||||
SrcDepth++;
|
||||
IsSrcLayered = true;
|
||||
srcTarget = GalTextureTarget.TwoDArray;
|
||||
srcDepth++;
|
||||
isSrcLayered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SrcDepth = 1;
|
||||
srcDepth = 1;
|
||||
}
|
||||
|
||||
GalTextureTarget DstTarget = GalTextureTarget.TwoD;
|
||||
GalTextureTarget dstTarget = GalTextureTarget.TwoD;
|
||||
|
||||
if (DstDepth != 0)
|
||||
if (dstDepth != 0)
|
||||
{
|
||||
DstTarget = GalTextureTarget.TwoDArray;
|
||||
DstDepth++;
|
||||
IsDstLayered = true;
|
||||
dstTarget = GalTextureTarget.TwoDArray;
|
||||
dstDepth++;
|
||||
isDstLayered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DstDepth = 1;
|
||||
dstDepth = 1;
|
||||
}
|
||||
|
||||
GalImage SrcTexture = new GalImage(
|
||||
SrcWidth,
|
||||
SrcHeight,
|
||||
1, SrcDepth, 1,
|
||||
SrcBlockHeight, 1,
|
||||
SrcLayout,
|
||||
SrcImgFormat,
|
||||
SrcTarget);
|
||||
GalImage srcTexture = new GalImage(
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
1, srcDepth, 1,
|
||||
srcBlockHeight, 1,
|
||||
srcLayout,
|
||||
srcImgFormat,
|
||||
srcTarget);
|
||||
|
||||
GalImage DstTexture = new GalImage(
|
||||
DstWidth,
|
||||
DstHeight,
|
||||
1, DstDepth, 1,
|
||||
DstBlockHeight, 1,
|
||||
DstLayout,
|
||||
DstImgFormat,
|
||||
DstTarget);
|
||||
GalImage dstTexture = new GalImage(
|
||||
dstWidth,
|
||||
dstHeight,
|
||||
1, dstDepth, 1,
|
||||
dstBlockHeight, 1,
|
||||
dstLayout,
|
||||
dstImgFormat,
|
||||
dstTarget);
|
||||
|
||||
SrcTexture.Pitch = SrcPitch;
|
||||
DstTexture.Pitch = DstPitch;
|
||||
srcTexture.Pitch = srcPitch;
|
||||
dstTexture.Pitch = dstPitch;
|
||||
|
||||
long GetLayerOffset(GalImage Image, int Layer)
|
||||
long GetLayerOffset(GalImage image, int layer)
|
||||
{
|
||||
int TargetMipLevel = Image.MaxMipmapLevel <= 1 ? 1 : Image.MaxMipmapLevel - 1;
|
||||
return ImageUtils.GetLayerOffset(Image, TargetMipLevel) * Layer;
|
||||
int targetMipLevel = image.MaxMipmapLevel <= 1 ? 1 : image.MaxMipmapLevel - 1;
|
||||
return ImageUtils.GetLayerOffset(image, targetMipLevel) * layer;
|
||||
}
|
||||
|
||||
int SrcLayerIndex = -1;
|
||||
int srcLayerIndex = -1;
|
||||
|
||||
if (IsSrcLayered && Gpu.ResourceManager.TryGetTextureLayer(SrcKey, out SrcLayerIndex) && SrcLayerIndex != 0)
|
||||
if (isSrcLayered && _gpu.ResourceManager.TryGetTextureLayer(srcKey, out srcLayerIndex) && srcLayerIndex != 0)
|
||||
{
|
||||
SrcKey = SrcKey - GetLayerOffset(SrcTexture, SrcLayerIndex);
|
||||
srcKey = srcKey - GetLayerOffset(srcTexture, srcLayerIndex);
|
||||
}
|
||||
|
||||
int DstLayerIndex = -1;
|
||||
int dstLayerIndex = -1;
|
||||
|
||||
if (IsDstLayered && Gpu.ResourceManager.TryGetTextureLayer(DstKey, out DstLayerIndex) && DstLayerIndex != 0)
|
||||
if (isDstLayered && _gpu.ResourceManager.TryGetTextureLayer(dstKey, out dstLayerIndex) && dstLayerIndex != 0)
|
||||
{
|
||||
DstKey = DstKey - GetLayerOffset(DstTexture, DstLayerIndex);
|
||||
dstKey = dstKey - GetLayerOffset(dstTexture, dstLayerIndex);
|
||||
}
|
||||
|
||||
Gpu.ResourceManager.SendTexture(Vmm, SrcKey, SrcTexture);
|
||||
Gpu.ResourceManager.SendTexture(Vmm, DstKey, DstTexture);
|
||||
_gpu.ResourceManager.SendTexture(vmm, srcKey, srcTexture);
|
||||
_gpu.ResourceManager.SendTexture(vmm, dstKey, dstTexture);
|
||||
|
||||
if (IsSrcLayered && SrcLayerIndex == -1)
|
||||
if (isSrcLayered && srcLayerIndex == -1)
|
||||
{
|
||||
for (int Layer = 0; Layer < SrcTexture.LayerCount; Layer++)
|
||||
for (int layer = 0; layer < srcTexture.LayerCount; layer++)
|
||||
{
|
||||
Gpu.ResourceManager.SetTextureArrayLayer(SrcKey + GetLayerOffset(SrcTexture, Layer), Layer);
|
||||
_gpu.ResourceManager.SetTextureArrayLayer(srcKey + GetLayerOffset(srcTexture, layer), layer);
|
||||
}
|
||||
|
||||
SrcLayerIndex = 0;
|
||||
srcLayerIndex = 0;
|
||||
}
|
||||
|
||||
if (IsDstLayered && DstLayerIndex == -1)
|
||||
if (isDstLayered && dstLayerIndex == -1)
|
||||
{
|
||||
for (int Layer = 0; Layer < DstTexture.LayerCount; Layer++)
|
||||
for (int layer = 0; layer < dstTexture.LayerCount; layer++)
|
||||
{
|
||||
Gpu.ResourceManager.SetTextureArrayLayer(DstKey + GetLayerOffset(DstTexture, Layer), Layer);
|
||||
_gpu.ResourceManager.SetTextureArrayLayer(dstKey + GetLayerOffset(dstTexture, layer), layer);
|
||||
}
|
||||
|
||||
DstLayerIndex = 0;
|
||||
dstLayerIndex = 0;
|
||||
}
|
||||
|
||||
int SrcBlitX1 = (int)(SrcBlitX >> 32);
|
||||
int SrcBlitY1 = (int)(SrcBlitY >> 32);
|
||||
int srcBlitX1 = (int)(srcBlitX >> 32);
|
||||
int srcBlitY1 = (int)(srcBlitY >> 32);
|
||||
|
||||
int SrcBlitX2 = (int)(SrcBlitX + DstBlitW * BlitDuDx >> 32);
|
||||
int SrcBlitY2 = (int)(SrcBlitY + DstBlitH * BlitDvDy >> 32);
|
||||
int srcBlitX2 = (int)(srcBlitX + dstBlitW * blitDuDx >> 32);
|
||||
int srcBlitY2 = (int)(srcBlitY + dstBlitH * blitDvDy >> 32);
|
||||
|
||||
Gpu.Renderer.RenderTarget.Copy(
|
||||
SrcTexture,
|
||||
DstTexture,
|
||||
SrcKey,
|
||||
DstKey,
|
||||
SrcLayerIndex,
|
||||
DstLayerIndex,
|
||||
SrcBlitX1,
|
||||
SrcBlitY1,
|
||||
SrcBlitX2,
|
||||
SrcBlitY2,
|
||||
DstBlitX,
|
||||
DstBlitY,
|
||||
DstBlitX + DstBlitW,
|
||||
DstBlitY + DstBlitH);
|
||||
_gpu.Renderer.RenderTarget.Copy(
|
||||
srcTexture,
|
||||
dstTexture,
|
||||
srcKey,
|
||||
dstKey,
|
||||
srcLayerIndex,
|
||||
dstLayerIndex,
|
||||
srcBlitX1,
|
||||
srcBlitY1,
|
||||
srcBlitX2,
|
||||
srcBlitY2,
|
||||
dstBlitX,
|
||||
dstBlitY,
|
||||
dstBlitX + dstBlitW,
|
||||
dstBlitY + dstBlitH);
|
||||
|
||||
//Do a guest side copy aswell. This is necessary when
|
||||
//the texture is modified by the guest, however it doesn't
|
||||
|
@ -209,19 +209,19 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
// FIXME: SUPPORT MULTILAYER CORRECTLY HERE (this will cause weird stuffs on the first layer)
|
||||
ImageUtils.CopyTexture(
|
||||
Vmm,
|
||||
SrcTexture,
|
||||
DstTexture,
|
||||
SrcAddress,
|
||||
DstAddress,
|
||||
SrcBlitX1,
|
||||
SrcBlitY1,
|
||||
DstBlitX,
|
||||
DstBlitY,
|
||||
DstBlitW,
|
||||
DstBlitH);
|
||||
vmm,
|
||||
srcTexture,
|
||||
dstTexture,
|
||||
srcAddress,
|
||||
dstAddress,
|
||||
srcBlitX1,
|
||||
srcBlitY1,
|
||||
dstBlitX,
|
||||
dstBlitY,
|
||||
dstBlitW,
|
||||
dstBlitH);
|
||||
|
||||
Vmm.IsRegionModified(DstKey, ImageUtils.GetSize(DstTexture), NvGpuBufferType.Texture);
|
||||
vmm.IsRegionModified(dstKey, ImageUtils.GetSize(dstTexture), NvGpuBufferType.Texture);
|
||||
}
|
||||
|
||||
private static GalMemoryLayout GetLayout(bool Linear)
|
||||
|
@ -231,29 +231,29 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
: GalMemoryLayout.BlockLinear;
|
||||
}
|
||||
|
||||
private long MakeInt64From2xInt32(NvGpuEngine2dReg Reg)
|
||||
private long MakeInt64From2xInt32(NvGpuEngine2DReg reg)
|
||||
{
|
||||
return
|
||||
(long)Registers[(int)Reg + 0] << 32 |
|
||||
(uint)Registers[(int)Reg + 1];
|
||||
(long)Registers[(int)reg + 0] << 32 |
|
||||
(uint)Registers[(int)reg + 1];
|
||||
}
|
||||
|
||||
private void WriteRegister(GpuMethodCall MethCall)
|
||||
private void WriteRegister(GpuMethodCall methCall)
|
||||
{
|
||||
Registers[MethCall.Method] = MethCall.Argument;
|
||||
Registers[methCall.Method] = methCall.Argument;
|
||||
}
|
||||
|
||||
private long ReadRegisterFixed1_31_32(NvGpuEngine2dReg Reg)
|
||||
private long ReadRegisterFixed1_31_32(NvGpuEngine2DReg reg)
|
||||
{
|
||||
long Low = (uint)ReadRegister(Reg + 0);
|
||||
long High = (uint)ReadRegister(Reg + 1);
|
||||
long low = (uint)ReadRegister(reg + 0);
|
||||
long high = (uint)ReadRegister(reg + 1);
|
||||
|
||||
return Low | (High << 32);
|
||||
return low | (high << 32);
|
||||
}
|
||||
|
||||
private int ReadRegister(NvGpuEngine2dReg Reg)
|
||||
private int ReadRegister(NvGpuEngine2DReg reg)
|
||||
{
|
||||
return Registers[(int)Reg];
|
||||
return Registers[(int)reg];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace Ryujinx.Graphics.Graphics3d
|
||||
{
|
||||
enum NvGpuEngine2dReg
|
||||
enum NvGpuEngine2DReg
|
||||
{
|
||||
DstFormat = 0x80,
|
||||
DstLinear = 0x81,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
namespace Ryujinx.Graphics.Graphics3d
|
||||
{
|
||||
enum NvGpuEngine3dReg
|
||||
enum NvGpuEngine3DReg
|
||||
{
|
||||
FrameBufferNAddress = 0x200,
|
||||
FrameBufferNWidth = 0x202,
|
||||
|
@ -32,13 +32,13 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
StencilBackMask = 0x3d6,
|
||||
StencilBackFuncMask = 0x3d7,
|
||||
ColorMaskCommon = 0x3e4,
|
||||
RTSeparateFragData = 0x3eb,
|
||||
RtSeparateFragData = 0x3eb,
|
||||
ZetaAddress = 0x3f8,
|
||||
ZetaFormat = 0x3fa,
|
||||
ZetaBlockDimensions = 0x3fb,
|
||||
ZetaLayerStride = 0x3fc,
|
||||
VertexAttribNFormat = 0x458,
|
||||
RTControl = 0x487,
|
||||
RtControl = 0x487,
|
||||
ZetaHoriz = 0x48a,
|
||||
ZetaVert = 0x48b,
|
||||
ZetaArrayMode = 0x48c,
|
||||
|
|
|
@ -9,188 +9,188 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
public int[] Registers { get; private set; }
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
private Dictionary<int, NvGpuMethod> Methods;
|
||||
private Dictionary<int, NvGpuMethod> _methods;
|
||||
|
||||
public NvGpuEngineM2mf(NvGpu Gpu)
|
||||
public NvGpuEngineM2mf(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
Registers = new int[0x1d6];
|
||||
|
||||
Methods = new Dictionary<int, NvGpuMethod>();
|
||||
_methods = new Dictionary<int, NvGpuMethod>();
|
||||
|
||||
void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method)
|
||||
void AddMethod(int meth, int count, int stride, NvGpuMethod method)
|
||||
{
|
||||
while (Count-- > 0)
|
||||
while (count-- > 0)
|
||||
{
|
||||
Methods.Add(Meth, Method);
|
||||
_methods.Add(meth, method);
|
||||
|
||||
Meth += Stride;
|
||||
meth += stride;
|
||||
}
|
||||
}
|
||||
|
||||
AddMethod(0xc0, 1, 1, Execute);
|
||||
}
|
||||
|
||||
public void CallMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
public void CallMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
if (Methods.TryGetValue(MethCall.Method, out NvGpuMethod Method))
|
||||
if (_methods.TryGetValue(methCall.Method, out NvGpuMethod method))
|
||||
{
|
||||
Method(Vmm, MethCall);
|
||||
method(vmm, methCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteRegister(MethCall);
|
||||
WriteRegister(methCall);
|
||||
}
|
||||
}
|
||||
|
||||
private void Execute(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void Execute(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
//TODO: Some registers and copy modes are still not implemented.
|
||||
int Control = MethCall.Argument;
|
||||
int control = methCall.Argument;
|
||||
|
||||
bool SrcLinear = ((Control >> 7) & 1) != 0;
|
||||
bool DstLinear = ((Control >> 8) & 1) != 0;
|
||||
bool Copy2d = ((Control >> 9) & 1) != 0;
|
||||
bool srcLinear = ((control >> 7) & 1) != 0;
|
||||
bool dstLinear = ((control >> 8) & 1) != 0;
|
||||
bool copy2D = ((control >> 9) & 1) != 0;
|
||||
|
||||
long SrcAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.SrcAddress);
|
||||
long DstAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.DstAddress);
|
||||
long srcAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.SrcAddress);
|
||||
long dstAddress = MakeInt64From2xInt32(NvGpuEngineM2mfReg.DstAddress);
|
||||
|
||||
int SrcPitch = ReadRegister(NvGpuEngineM2mfReg.SrcPitch);
|
||||
int DstPitch = ReadRegister(NvGpuEngineM2mfReg.DstPitch);
|
||||
int srcPitch = ReadRegister(NvGpuEngineM2mfReg.SrcPitch);
|
||||
int dstPitch = ReadRegister(NvGpuEngineM2mfReg.DstPitch);
|
||||
|
||||
int XCount = ReadRegister(NvGpuEngineM2mfReg.XCount);
|
||||
int YCount = ReadRegister(NvGpuEngineM2mfReg.YCount);
|
||||
int xCount = ReadRegister(NvGpuEngineM2mfReg.XCount);
|
||||
int yCount = ReadRegister(NvGpuEngineM2mfReg.YCount);
|
||||
|
||||
int Swizzle = ReadRegister(NvGpuEngineM2mfReg.Swizzle);
|
||||
int swizzle = ReadRegister(NvGpuEngineM2mfReg.Swizzle);
|
||||
|
||||
int DstBlkDim = ReadRegister(NvGpuEngineM2mfReg.DstBlkDim);
|
||||
int DstSizeX = ReadRegister(NvGpuEngineM2mfReg.DstSizeX);
|
||||
int DstSizeY = ReadRegister(NvGpuEngineM2mfReg.DstSizeY);
|
||||
int DstSizeZ = ReadRegister(NvGpuEngineM2mfReg.DstSizeZ);
|
||||
int DstPosXY = ReadRegister(NvGpuEngineM2mfReg.DstPosXY);
|
||||
int DstPosZ = ReadRegister(NvGpuEngineM2mfReg.DstPosZ);
|
||||
int dstBlkDim = ReadRegister(NvGpuEngineM2mfReg.DstBlkDim);
|
||||
int dstSizeX = ReadRegister(NvGpuEngineM2mfReg.DstSizeX);
|
||||
int dstSizeY = ReadRegister(NvGpuEngineM2mfReg.DstSizeY);
|
||||
int dstSizeZ = ReadRegister(NvGpuEngineM2mfReg.DstSizeZ);
|
||||
int dstPosXy = ReadRegister(NvGpuEngineM2mfReg.DstPosXy);
|
||||
int dstPosZ = ReadRegister(NvGpuEngineM2mfReg.DstPosZ);
|
||||
|
||||
int SrcBlkDim = ReadRegister(NvGpuEngineM2mfReg.SrcBlkDim);
|
||||
int SrcSizeX = ReadRegister(NvGpuEngineM2mfReg.SrcSizeX);
|
||||
int SrcSizeY = ReadRegister(NvGpuEngineM2mfReg.SrcSizeY);
|
||||
int SrcSizeZ = ReadRegister(NvGpuEngineM2mfReg.SrcSizeZ);
|
||||
int SrcPosXY = ReadRegister(NvGpuEngineM2mfReg.SrcPosXY);
|
||||
int SrcPosZ = ReadRegister(NvGpuEngineM2mfReg.SrcPosZ);
|
||||
int srcBlkDim = ReadRegister(NvGpuEngineM2mfReg.SrcBlkDim);
|
||||
int srcSizeX = ReadRegister(NvGpuEngineM2mfReg.SrcSizeX);
|
||||
int srcSizeY = ReadRegister(NvGpuEngineM2mfReg.SrcSizeY);
|
||||
int srcSizeZ = ReadRegister(NvGpuEngineM2mfReg.SrcSizeZ);
|
||||
int srcPosXy = ReadRegister(NvGpuEngineM2mfReg.SrcPosXy);
|
||||
int srcPosZ = ReadRegister(NvGpuEngineM2mfReg.SrcPosZ);
|
||||
|
||||
int SrcCpp = ((Swizzle >> 20) & 7) + 1;
|
||||
int DstCpp = ((Swizzle >> 24) & 7) + 1;
|
||||
int srcCpp = ((swizzle >> 20) & 7) + 1;
|
||||
int dstCpp = ((swizzle >> 24) & 7) + 1;
|
||||
|
||||
int DstPosX = (DstPosXY >> 0) & 0xffff;
|
||||
int DstPosY = (DstPosXY >> 16) & 0xffff;
|
||||
int dstPosX = (dstPosXy >> 0) & 0xffff;
|
||||
int dstPosY = (dstPosXy >> 16) & 0xffff;
|
||||
|
||||
int SrcPosX = (SrcPosXY >> 0) & 0xffff;
|
||||
int SrcPosY = (SrcPosXY >> 16) & 0xffff;
|
||||
int srcPosX = (srcPosXy >> 0) & 0xffff;
|
||||
int srcPosY = (srcPosXy >> 16) & 0xffff;
|
||||
|
||||
int SrcBlockHeight = 1 << ((SrcBlkDim >> 4) & 0xf);
|
||||
int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf);
|
||||
int srcBlockHeight = 1 << ((srcBlkDim >> 4) & 0xf);
|
||||
int dstBlockHeight = 1 << ((dstBlkDim >> 4) & 0xf);
|
||||
|
||||
long SrcPA = Vmm.GetPhysicalAddress(SrcAddress);
|
||||
long DstPA = Vmm.GetPhysicalAddress(DstAddress);
|
||||
long srcPa = vmm.GetPhysicalAddress(srcAddress);
|
||||
long dstPa = vmm.GetPhysicalAddress(dstAddress);
|
||||
|
||||
if (Copy2d)
|
||||
if (copy2D)
|
||||
{
|
||||
if (SrcLinear)
|
||||
if (srcLinear)
|
||||
{
|
||||
SrcPosX = SrcPosY = SrcPosZ = 0;
|
||||
srcPosX = srcPosY = srcPosZ = 0;
|
||||
}
|
||||
|
||||
if (DstLinear)
|
||||
if (dstLinear)
|
||||
{
|
||||
DstPosX = DstPosY = DstPosZ = 0;
|
||||
dstPosX = dstPosY = dstPosZ = 0;
|
||||
}
|
||||
|
||||
if (SrcLinear && DstLinear)
|
||||
if (srcLinear && dstLinear)
|
||||
{
|
||||
for (int Y = 0; Y < YCount; Y++)
|
||||
for (int y = 0; y < yCount; y++)
|
||||
{
|
||||
int SrcOffset = (SrcPosY + Y) * SrcPitch + SrcPosX * SrcCpp;
|
||||
int DstOffset = (DstPosY + Y) * DstPitch + DstPosX * DstCpp;
|
||||
int srcOffset = (srcPosY + y) * srcPitch + srcPosX * srcCpp;
|
||||
int dstOffset = (dstPosY + y) * dstPitch + dstPosX * dstCpp;
|
||||
|
||||
long Src = SrcPA + (uint)SrcOffset;
|
||||
long Dst = DstPA + (uint)DstOffset;
|
||||
long src = srcPa + (uint)srcOffset;
|
||||
long dst = dstPa + (uint)dstOffset;
|
||||
|
||||
Vmm.Memory.CopyBytes(Src, Dst, XCount * SrcCpp);
|
||||
vmm.Memory.CopyBytes(src, dst, xCount * srcCpp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ISwizzle SrcSwizzle;
|
||||
ISwizzle srcSwizzle;
|
||||
|
||||
if (SrcLinear)
|
||||
if (srcLinear)
|
||||
{
|
||||
SrcSwizzle = new LinearSwizzle(SrcPitch, SrcCpp, SrcSizeX, SrcSizeY);
|
||||
srcSwizzle = new LinearSwizzle(srcPitch, srcCpp, srcSizeX, srcSizeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
SrcSwizzle = new BlockLinearSwizzle(
|
||||
SrcSizeX,
|
||||
SrcSizeY, 1,
|
||||
SrcBlockHeight, 1,
|
||||
SrcCpp);
|
||||
srcSwizzle = new BlockLinearSwizzle(
|
||||
srcSizeX,
|
||||
srcSizeY, 1,
|
||||
srcBlockHeight, 1,
|
||||
srcCpp);
|
||||
}
|
||||
|
||||
ISwizzle DstSwizzle;
|
||||
ISwizzle dstSwizzle;
|
||||
|
||||
if (DstLinear)
|
||||
if (dstLinear)
|
||||
{
|
||||
DstSwizzle = new LinearSwizzle(DstPitch, DstCpp, SrcSizeX, SrcSizeY);
|
||||
dstSwizzle = new LinearSwizzle(dstPitch, dstCpp, srcSizeX, srcSizeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
DstSwizzle = new BlockLinearSwizzle(
|
||||
DstSizeX,
|
||||
DstSizeY, 1,
|
||||
DstBlockHeight, 1,
|
||||
DstCpp);
|
||||
dstSwizzle = new BlockLinearSwizzle(
|
||||
dstSizeX,
|
||||
dstSizeY, 1,
|
||||
dstBlockHeight, 1,
|
||||
dstCpp);
|
||||
}
|
||||
|
||||
for (int Y = 0; Y < YCount; Y++)
|
||||
for (int X = 0; X < XCount; X++)
|
||||
for (int y = 0; y < yCount; y++)
|
||||
for (int x = 0; x < xCount; x++)
|
||||
{
|
||||
int SrcOffset = SrcSwizzle.GetSwizzleOffset(SrcPosX + X, SrcPosY + Y, 0);
|
||||
int DstOffset = DstSwizzle.GetSwizzleOffset(DstPosX + X, DstPosY + Y, 0);
|
||||
int srcOffset = srcSwizzle.GetSwizzleOffset(srcPosX + x, srcPosY + y, 0);
|
||||
int dstOffset = dstSwizzle.GetSwizzleOffset(dstPosX + x, dstPosY + y, 0);
|
||||
|
||||
long Src = SrcPA + (uint)SrcOffset;
|
||||
long Dst = DstPA + (uint)DstOffset;
|
||||
long src = srcPa + (uint)srcOffset;
|
||||
long dst = dstPa + (uint)dstOffset;
|
||||
|
||||
Vmm.Memory.CopyBytes(Src, Dst, SrcCpp);
|
||||
vmm.Memory.CopyBytes(src, dst, srcCpp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vmm.Memory.CopyBytes(SrcPA, DstPA, XCount);
|
||||
vmm.Memory.CopyBytes(srcPa, dstPa, xCount);
|
||||
}
|
||||
}
|
||||
|
||||
private long MakeInt64From2xInt32(NvGpuEngineM2mfReg Reg)
|
||||
private long MakeInt64From2xInt32(NvGpuEngineM2mfReg reg)
|
||||
{
|
||||
return
|
||||
(long)Registers[(int)Reg + 0] << 32 |
|
||||
(uint)Registers[(int)Reg + 1];
|
||||
(long)Registers[(int)reg + 0] << 32 |
|
||||
(uint)Registers[(int)reg + 1];
|
||||
}
|
||||
|
||||
private void WriteRegister(GpuMethodCall MethCall)
|
||||
private void WriteRegister(GpuMethodCall methCall)
|
||||
{
|
||||
Registers[MethCall.Method] = MethCall.Argument;
|
||||
Registers[methCall.Method] = methCall.Argument;
|
||||
}
|
||||
|
||||
private int ReadRegister(NvGpuEngineM2mfReg Reg)
|
||||
private int ReadRegister(NvGpuEngineM2mfReg reg)
|
||||
{
|
||||
return Registers[(int)Reg];
|
||||
return Registers[(int)reg];
|
||||
}
|
||||
|
||||
private void WriteRegister(NvGpuEngineM2mfReg Reg, int Value)
|
||||
private void WriteRegister(NvGpuEngineM2mfReg reg, int value)
|
||||
{
|
||||
Registers[(int)Reg] = Value;
|
||||
Registers[(int)reg] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,12 +14,12 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
DstSizeY = 0x1c5,
|
||||
DstSizeZ = 0x1c6,
|
||||
DstPosZ = 0x1c7,
|
||||
DstPosXY = 0x1c8,
|
||||
DstPosXy = 0x1c8,
|
||||
SrcBlkDim = 0x1ca,
|
||||
SrcSizeX = 0x1cb,
|
||||
SrcSizeY = 0x1cc,
|
||||
SrcSizeZ = 0x1cd,
|
||||
SrcPosZ = 0x1ce,
|
||||
SrcPosXY = 0x1cf
|
||||
SrcPosXy = 0x1cf
|
||||
}
|
||||
}
|
|
@ -9,41 +9,41 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
{
|
||||
public int[] Registers { get; private set; }
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
private Dictionary<int, NvGpuMethod> Methods;
|
||||
private Dictionary<int, NvGpuMethod> _methods;
|
||||
|
||||
private int CopyStartX;
|
||||
private int CopyStartY;
|
||||
private int _copyStartX;
|
||||
private int _copyStartY;
|
||||
|
||||
private int CopyWidth;
|
||||
private int CopyHeight;
|
||||
private int CopyGobBlockHeight;
|
||||
private int _copyWidth;
|
||||
private int _copyHeight;
|
||||
private int _copyGobBlockHeight;
|
||||
|
||||
private long CopyAddress;
|
||||
private long _copyAddress;
|
||||
|
||||
private int CopyOffset;
|
||||
private int CopySize;
|
||||
private int _copyOffset;
|
||||
private int _copySize;
|
||||
|
||||
private bool CopyLinear;
|
||||
private bool _copyLinear;
|
||||
|
||||
private byte[] Buffer;
|
||||
private byte[] _buffer;
|
||||
|
||||
public NvGpuEngineP2mf(NvGpu Gpu)
|
||||
public NvGpuEngineP2mf(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
Registers = new int[0x80];
|
||||
|
||||
Methods = new Dictionary<int, NvGpuMethod>();
|
||||
_methods = new Dictionary<int, NvGpuMethod>();
|
||||
|
||||
void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method)
|
||||
void AddMethod(int meth, int count, int stride, NvGpuMethod method)
|
||||
{
|
||||
while (Count-- > 0)
|
||||
while (count-- > 0)
|
||||
{
|
||||
Methods.Add(Meth, Method);
|
||||
_methods.Add(meth, method);
|
||||
|
||||
Meth += Stride;
|
||||
meth += stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,115 +51,115 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
AddMethod(0x6d, 1, 1, PushData);
|
||||
}
|
||||
|
||||
public void CallMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
public void CallMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
if (Methods.TryGetValue(MethCall.Method, out NvGpuMethod Method))
|
||||
if (_methods.TryGetValue(methCall.Method, out NvGpuMethod method))
|
||||
{
|
||||
Method(Vmm, MethCall);
|
||||
method(vmm, methCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteRegister(MethCall);
|
||||
WriteRegister(methCall);
|
||||
}
|
||||
}
|
||||
|
||||
private void Execute(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void Execute(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
//TODO: Some registers and copy modes are still not implemented.
|
||||
int Control = MethCall.Argument;
|
||||
int control = methCall.Argument;
|
||||
|
||||
long DstAddress = MakeInt64From2xInt32(NvGpuEngineP2mfReg.DstAddress);
|
||||
long dstAddress = MakeInt64From2xInt32(NvGpuEngineP2mfReg.DstAddress);
|
||||
|
||||
int DstPitch = ReadRegister(NvGpuEngineP2mfReg.DstPitch);
|
||||
int DstBlkDim = ReadRegister(NvGpuEngineP2mfReg.DstBlockDim);
|
||||
int dstPitch = ReadRegister(NvGpuEngineP2mfReg.DstPitch);
|
||||
int dstBlkDim = ReadRegister(NvGpuEngineP2mfReg.DstBlockDim);
|
||||
|
||||
int DstX = ReadRegister(NvGpuEngineP2mfReg.DstX);
|
||||
int DstY = ReadRegister(NvGpuEngineP2mfReg.DstY);
|
||||
int dstX = ReadRegister(NvGpuEngineP2mfReg.DstX);
|
||||
int dstY = ReadRegister(NvGpuEngineP2mfReg.DstY);
|
||||
|
||||
int DstWidth = ReadRegister(NvGpuEngineP2mfReg.DstWidth);
|
||||
int DstHeight = ReadRegister(NvGpuEngineP2mfReg.DstHeight);
|
||||
int dstWidth = ReadRegister(NvGpuEngineP2mfReg.DstWidth);
|
||||
int dstHeight = ReadRegister(NvGpuEngineP2mfReg.DstHeight);
|
||||
|
||||
int LineLengthIn = ReadRegister(NvGpuEngineP2mfReg.LineLengthIn);
|
||||
int LineCount = ReadRegister(NvGpuEngineP2mfReg.LineCount);
|
||||
int lineLengthIn = ReadRegister(NvGpuEngineP2mfReg.LineLengthIn);
|
||||
int lineCount = ReadRegister(NvGpuEngineP2mfReg.LineCount);
|
||||
|
||||
CopyLinear = (Control & 1) != 0;
|
||||
_copyLinear = (control & 1) != 0;
|
||||
|
||||
CopyGobBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf);
|
||||
_copyGobBlockHeight = 1 << ((dstBlkDim >> 4) & 0xf);
|
||||
|
||||
CopyStartX = DstX;
|
||||
CopyStartY = DstY;
|
||||
_copyStartX = dstX;
|
||||
_copyStartY = dstY;
|
||||
|
||||
CopyWidth = DstWidth;
|
||||
CopyHeight = DstHeight;
|
||||
_copyWidth = dstWidth;
|
||||
_copyHeight = dstHeight;
|
||||
|
||||
CopyAddress = DstAddress;
|
||||
_copyAddress = dstAddress;
|
||||
|
||||
CopyOffset = 0;
|
||||
CopySize = LineLengthIn * LineCount;
|
||||
_copyOffset = 0;
|
||||
_copySize = lineLengthIn * lineCount;
|
||||
|
||||
Buffer = new byte[CopySize];
|
||||
_buffer = new byte[_copySize];
|
||||
}
|
||||
|
||||
private void PushData(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void PushData(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
if (Buffer == null)
|
||||
if (_buffer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int Shift = 0; Shift < 32 && CopyOffset < CopySize; Shift += 8, CopyOffset++)
|
||||
for (int shift = 0; shift < 32 && _copyOffset < _copySize; shift += 8, _copyOffset++)
|
||||
{
|
||||
Buffer[CopyOffset] = (byte)(MethCall.Argument >> Shift);
|
||||
_buffer[_copyOffset] = (byte)(methCall.Argument >> shift);
|
||||
}
|
||||
|
||||
if (MethCall.IsLastCall)
|
||||
if (methCall.IsLastCall)
|
||||
{
|
||||
if (CopyLinear)
|
||||
if (_copyLinear)
|
||||
{
|
||||
Vmm.WriteBytes(CopyAddress, Buffer);
|
||||
vmm.WriteBytes(_copyAddress, _buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockLinearSwizzle Swizzle = new BlockLinearSwizzle(
|
||||
CopyWidth,
|
||||
CopyHeight, 1,
|
||||
CopyGobBlockHeight, 1, 1);
|
||||
BlockLinearSwizzle swizzle = new BlockLinearSwizzle(
|
||||
_copyWidth,
|
||||
_copyHeight, 1,
|
||||
_copyGobBlockHeight, 1, 1);
|
||||
|
||||
int SrcOffset = 0;
|
||||
int srcOffset = 0;
|
||||
|
||||
for (int Y = CopyStartY; Y < CopyHeight && SrcOffset < CopySize; Y++)
|
||||
for (int X = CopyStartX; X < CopyWidth && SrcOffset < CopySize; X++)
|
||||
for (int y = _copyStartY; y < _copyHeight && srcOffset < _copySize; y++)
|
||||
for (int x = _copyStartX; x < _copyWidth && srcOffset < _copySize; x++)
|
||||
{
|
||||
int DstOffset = Swizzle.GetSwizzleOffset(X, Y, 0);
|
||||
int dstOffset = swizzle.GetSwizzleOffset(x, y, 0);
|
||||
|
||||
Vmm.WriteByte(CopyAddress + DstOffset, Buffer[SrcOffset++]);
|
||||
vmm.WriteByte(_copyAddress + dstOffset, _buffer[srcOffset++]);
|
||||
}
|
||||
}
|
||||
|
||||
Buffer = null;
|
||||
_buffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private long MakeInt64From2xInt32(NvGpuEngineP2mfReg Reg)
|
||||
private long MakeInt64From2xInt32(NvGpuEngineP2mfReg reg)
|
||||
{
|
||||
return
|
||||
(long)Registers[(int)Reg + 0] << 32 |
|
||||
(uint)Registers[(int)Reg + 1];
|
||||
(long)Registers[(int)reg + 0] << 32 |
|
||||
(uint)Registers[(int)reg + 1];
|
||||
}
|
||||
|
||||
private void WriteRegister(GpuMethodCall MethCall)
|
||||
private void WriteRegister(GpuMethodCall methCall)
|
||||
{
|
||||
Registers[MethCall.Method] = MethCall.Argument;
|
||||
Registers[methCall.Method] = methCall.Argument;
|
||||
}
|
||||
|
||||
private int ReadRegister(NvGpuEngineP2mfReg Reg)
|
||||
private int ReadRegister(NvGpuEngineP2mfReg reg)
|
||||
{
|
||||
return Registers[(int)Reg];
|
||||
return Registers[(int)reg];
|
||||
}
|
||||
|
||||
private void WriteRegister(NvGpuEngineP2mfReg Reg, int Value)
|
||||
private void WriteRegister(NvGpuEngineP2mfReg reg, int value)
|
||||
{
|
||||
Registers[(int)Reg] = Value;
|
||||
Registers[(int)reg] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,166 +11,166 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
//a guess here and use 256kb as the size. Increase if needed.
|
||||
private const int MmeWords = 256 * 256;
|
||||
|
||||
private NvGpu Gpu;
|
||||
private NvGpu _gpu;
|
||||
|
||||
private NvGpuEngine[] SubChannels;
|
||||
private NvGpuEngine[] _subChannels;
|
||||
|
||||
private struct CachedMacro
|
||||
{
|
||||
public int Position { get; private set; }
|
||||
|
||||
private bool ExecutionPending;
|
||||
private int Argument;
|
||||
private bool _executionPending;
|
||||
private int _argument;
|
||||
|
||||
private MacroInterpreter Interpreter;
|
||||
private MacroInterpreter _interpreter;
|
||||
|
||||
public CachedMacro(NvGpuFifo PFifo, INvGpuEngine Engine, int Position)
|
||||
public CachedMacro(NvGpuFifo pFifo, INvGpuEngine engine, int position)
|
||||
{
|
||||
this.Position = Position;
|
||||
Position = position;
|
||||
|
||||
ExecutionPending = false;
|
||||
Argument = 0;
|
||||
_executionPending = false;
|
||||
_argument = 0;
|
||||
|
||||
Interpreter = new MacroInterpreter(PFifo, Engine);
|
||||
_interpreter = new MacroInterpreter(pFifo, engine);
|
||||
}
|
||||
|
||||
public void StartExecution(int Argument)
|
||||
public void StartExecution(int argument)
|
||||
{
|
||||
this.Argument = Argument;
|
||||
_argument = argument;
|
||||
|
||||
ExecutionPending = true;
|
||||
_executionPending = true;
|
||||
}
|
||||
|
||||
public void Execute(NvGpuVmm Vmm, int[] Mme)
|
||||
public void Execute(NvGpuVmm vmm, int[] mme)
|
||||
{
|
||||
if (ExecutionPending)
|
||||
if (_executionPending)
|
||||
{
|
||||
ExecutionPending = false;
|
||||
_executionPending = false;
|
||||
|
||||
Interpreter?.Execute(Vmm, Mme, Position, Argument);
|
||||
_interpreter?.Execute(vmm, mme, Position, _argument);
|
||||
}
|
||||
}
|
||||
|
||||
public void PushArgument(int Argument)
|
||||
public void PushArgument(int argument)
|
||||
{
|
||||
Interpreter?.Fifo.Enqueue(Argument);
|
||||
_interpreter?.Fifo.Enqueue(argument);
|
||||
}
|
||||
}
|
||||
|
||||
private int CurrMacroPosition;
|
||||
private int CurrMacroBindIndex;
|
||||
private int _currMacroPosition;
|
||||
private int _currMacroBindIndex;
|
||||
|
||||
private CachedMacro[] Macros;
|
||||
private CachedMacro[] _macros;
|
||||
|
||||
private int[] Mme;
|
||||
private int[] _mme;
|
||||
|
||||
public NvGpuFifo(NvGpu Gpu)
|
||||
public NvGpuFifo(NvGpu gpu)
|
||||
{
|
||||
this.Gpu = Gpu;
|
||||
_gpu = gpu;
|
||||
|
||||
SubChannels = new NvGpuEngine[8];
|
||||
_subChannels = new NvGpuEngine[8];
|
||||
|
||||
Macros = new CachedMacro[MacrosCount];
|
||||
_macros = new CachedMacro[MacrosCount];
|
||||
|
||||
Mme = new int[MmeWords];
|
||||
_mme = new int[MmeWords];
|
||||
}
|
||||
|
||||
public void CallMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
public void CallMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
if ((NvGpuFifoMeth)MethCall.Method == NvGpuFifoMeth.BindChannel)
|
||||
if ((NvGpuFifoMeth)methCall.Method == NvGpuFifoMeth.BindChannel)
|
||||
{
|
||||
NvGpuEngine Engine = (NvGpuEngine)MethCall.Argument;
|
||||
NvGpuEngine engine = (NvGpuEngine)methCall.Argument;
|
||||
|
||||
SubChannels[MethCall.SubChannel] = Engine;
|
||||
_subChannels[methCall.SubChannel] = engine;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (SubChannels[MethCall.SubChannel])
|
||||
switch (_subChannels[methCall.SubChannel])
|
||||
{
|
||||
case NvGpuEngine._2d: Call2dMethod (Vmm, MethCall); break;
|
||||
case NvGpuEngine._3d: Call3dMethod (Vmm, MethCall); break;
|
||||
case NvGpuEngine.P2mf: CallP2mfMethod(Vmm, MethCall); break;
|
||||
case NvGpuEngine.M2mf: CallM2mfMethod(Vmm, MethCall); break;
|
||||
case NvGpuEngine._2D: Call2DMethod (vmm, methCall); break;
|
||||
case NvGpuEngine._3D: Call3DMethod (vmm, methCall); break;
|
||||
case NvGpuEngine.P2mf: CallP2mfMethod(vmm, methCall); break;
|
||||
case NvGpuEngine.M2mf: CallM2mfMethod(vmm, methCall); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Call2dMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void Call2DMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
Gpu.Engine2d.CallMethod(Vmm, MethCall);
|
||||
_gpu.Engine2d.CallMethod(vmm, methCall);
|
||||
}
|
||||
|
||||
private void Call3dMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void Call3DMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
if (MethCall.Method < 0x80)
|
||||
if (methCall.Method < 0x80)
|
||||
{
|
||||
switch ((NvGpuFifoMeth)MethCall.Method)
|
||||
switch ((NvGpuFifoMeth)methCall.Method)
|
||||
{
|
||||
case NvGpuFifoMeth.SetMacroUploadAddress:
|
||||
{
|
||||
CurrMacroPosition = MethCall.Argument;
|
||||
_currMacroPosition = methCall.Argument;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case NvGpuFifoMeth.SendMacroCodeData:
|
||||
{
|
||||
Mme[CurrMacroPosition++] = MethCall.Argument;
|
||||
_mme[_currMacroPosition++] = methCall.Argument;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case NvGpuFifoMeth.SetMacroBindingIndex:
|
||||
{
|
||||
CurrMacroBindIndex = MethCall.Argument;
|
||||
_currMacroBindIndex = methCall.Argument;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case NvGpuFifoMeth.BindMacro:
|
||||
{
|
||||
int Position = MethCall.Argument;
|
||||
int position = methCall.Argument;
|
||||
|
||||
Macros[CurrMacroBindIndex] = new CachedMacro(this, Gpu.Engine3d, Position);
|
||||
_macros[_currMacroBindIndex] = new CachedMacro(this, _gpu.Engine3d, position);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: CallP2mfMethod(Vmm, MethCall); break;
|
||||
default: CallP2mfMethod(vmm, methCall); break;
|
||||
}
|
||||
}
|
||||
else if (MethCall.Method < 0xe00)
|
||||
else if (methCall.Method < 0xe00)
|
||||
{
|
||||
Gpu.Engine3d.CallMethod(Vmm, MethCall);
|
||||
_gpu.Engine3d.CallMethod(vmm, methCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
int MacroIndex = (MethCall.Method >> 1) & MacroIndexMask;
|
||||
int macroIndex = (methCall.Method >> 1) & MacroIndexMask;
|
||||
|
||||
if ((MethCall.Method & 1) != 0)
|
||||
if ((methCall.Method & 1) != 0)
|
||||
{
|
||||
Macros[MacroIndex].PushArgument(MethCall.Argument);
|
||||
_macros[macroIndex].PushArgument(methCall.Argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
Macros[MacroIndex].StartExecution(MethCall.Argument);
|
||||
_macros[macroIndex].StartExecution(methCall.Argument);
|
||||
}
|
||||
|
||||
if (MethCall.IsLastCall)
|
||||
if (methCall.IsLastCall)
|
||||
{
|
||||
Macros[MacroIndex].Execute(Vmm, Mme);
|
||||
_macros[macroIndex].Execute(vmm, _mme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CallP2mfMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void CallP2mfMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
Gpu.EngineP2mf.CallMethod(Vmm, MethCall);
|
||||
_gpu.EngineP2mf.CallMethod(vmm, methCall);
|
||||
}
|
||||
|
||||
private void CallM2mfMethod(NvGpuVmm Vmm, GpuMethodCall MethCall)
|
||||
private void CallM2mfMethod(NvGpuVmm vmm, GpuMethodCall methCall)
|
||||
{
|
||||
Gpu.EngineM2mf.CallMethod(Vmm, MethCall);
|
||||
_gpu.EngineM2mf.CallMethod(vmm, methCall);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,5 +2,5 @@ using Ryujinx.Graphics.Memory;
|
|||
|
||||
namespace Ryujinx.Graphics.Graphics3d
|
||||
{
|
||||
delegate void NvGpuMethod(NvGpuVmm Vmm, GpuMethodCall MethCall);
|
||||
delegate void NvGpuMethod(NvGpuVmm vmm, GpuMethodCall methCall);
|
||||
}
|
|
@ -111,8 +111,8 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
public GobBlockSizes(int gobBlockHeight, int gobBlockDepth)
|
||||
{
|
||||
this.Height = gobBlockHeight;
|
||||
this.Depth = gobBlockDepth;
|
||||
Height = gobBlockHeight;
|
||||
Depth = gobBlockDepth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,8 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
public RobAndSliceSizes(int robSize, int sliceSize)
|
||||
{
|
||||
this.RobSize = robSize;
|
||||
this.SliceSize = sliceSize;
|
||||
RobSize = robSize;
|
||||
SliceSize = sliceSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
public ImageDescriptor(int bytesPerPixel, int blockWidth, int blockHeight, int blockDepth, TargetBuffer target)
|
||||
{
|
||||
this.BytesPerPixel = bytesPerPixel;
|
||||
this.BlockWidth = blockWidth;
|
||||
this.BlockHeight = blockHeight;
|
||||
this.BlockDepth = blockDepth;
|
||||
this.Target = target;
|
||||
BytesPerPixel = bytesPerPixel;
|
||||
BlockWidth = blockWidth;
|
||||
BlockHeight = blockHeight;
|
||||
BlockDepth = blockDepth;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
byte[] data = new byte[dataLayerSize * image.LayerCount];
|
||||
|
||||
int targetMipLevel = image.MaxMipmapLevel <= 1 ? 1 : image.MaxMipmapLevel - 1;
|
||||
int layerOffset = ImageUtils.GetLayerOffset(image, targetMipLevel);
|
||||
int layerOffset = GetLayerOffset(image, targetMipLevel);
|
||||
|
||||
for (int layer = 0; layer < image.LayerCount; layer++)
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
ImageDescriptor desc = GetImageDescriptor(image.Format);
|
||||
|
||||
(int width, int height, int depth) = ImageUtils.GetImageSizeInBlocks(image);
|
||||
(int width, int height, int depth) = GetImageSizeInBlocks(image);
|
||||
|
||||
int bytesPerPixel = desc.BytesPerPixel;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
public LinearSwizzle(int pitch, int bpp, int width, int height)
|
||||
{
|
||||
this._pitch = pitch;
|
||||
this._bpp = bpp;
|
||||
_pitch = pitch;
|
||||
_bpp = bpp;
|
||||
_sliceSize = width * height * bpp;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ 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; }
|
||||
|
||||
|
@ -33,8 +33,8 @@ namespace Ryujinx.Graphics
|
|||
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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue