Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6f0395538b | ||
|
b9f1ff3c77 | ||
|
a77af4c5e9 | ||
|
fbcf802fbc | ||
|
c3c41fa4bb | ||
|
356e480bf5 | ||
|
8e119a1e96 | ||
|
e05bf90af6 | ||
|
66f16f4392 | ||
|
729ff5337c | ||
|
2492e7e808 | ||
|
36172ab43b | ||
|
4d69286a9c |
@@ -7,14 +7,15 @@
|
|||||||
public bool F { get; protected set; }
|
public bool F { get; protected set; }
|
||||||
public bool U { get; }
|
public bool U { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32Simd(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32Simd(inst, address, opCode, false);
|
||||||
|
public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32Simd(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32Simd(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32Simd(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Size = (opCode >> 20) & 0x3;
|
Size = (opCode >> 20) & 0x3;
|
||||||
Q = ((opCode >> 6) & 0x1) != 0;
|
Q = ((opCode >> 6) & 0x1) != 0;
|
||||||
F = ((opCode >> 10) & 0x1) != 0;
|
F = ((opCode >> 10) & 0x1) != 0;
|
||||||
U = ((opCode >> 24) & 0x1) != 0;
|
U = ((opCode >> (isThumb ? 28 : 24)) & 0x1) != 0;
|
||||||
Opc = (opCode >> 7) & 0x3;
|
Opc = (opCode >> 7) & 0x3;
|
||||||
|
|
||||||
RegisterSize = Q ? RegisterSize.Simd128 : RegisterSize.Simd64;
|
RegisterSize = Q ? RegisterSize.Simd128 : RegisterSize.Simd64;
|
||||||
|
@@ -47,6 +47,9 @@ namespace ARMeilleure.Decoders
|
|||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpCode32SimdBase(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode) { }
|
protected OpCode32SimdBase(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode)
|
||||||
|
{
|
||||||
|
IsThumb = isThumb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,10 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class OpCode32SimdBinary : OpCode32SimdReg
|
class OpCode32SimdBinary : OpCode32SimdReg
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdBinary(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdBinary(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdBinary(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdBinary(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdBinary(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Size = 3;
|
Size = 3;
|
||||||
|
|
||||||
|
@@ -2,9 +2,10 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdCmpZ : OpCode32Simd
|
class OpCode32SimdCmpZ : OpCode32Simd
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdCmpZ(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdCmpZ(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdCmpZ(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdCmpZ(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdCmpZ(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Size = (opCode >> 18) & 0x3;
|
Size = (opCode >> 18) & 0x3;
|
||||||
|
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdDupElem(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdDupElem(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdDupElem(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdDupElem(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdDupElem(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
var opc = (opCode >> 16) & 0xf;
|
var opc = (opCode >> 16) & 0xf;
|
||||||
|
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Immediate { get; }
|
public int Immediate { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdExt(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdExt(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdExt(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdExt(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdExt(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Immediate = (opCode >> 8) & 0xf;
|
Immediate = (opCode >> 8) & 0xf;
|
||||||
Size = 0;
|
Size = 0;
|
||||||
|
@@ -6,9 +6,10 @@
|
|||||||
public long Immediate { get; }
|
public long Immediate { get; }
|
||||||
public int Elems => GetBytesCount() >> Size;
|
public int Elems => GetBytesCount() >> Size;
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdImm(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdImm(inst, address, opCode, false);
|
||||||
|
public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdImm(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdImm(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdImm(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Vd = (opCode >> 12) & 0xf;
|
Vd = (opCode >> 12) & 0xf;
|
||||||
Vd |= (opCode >> 18) & 0x10;
|
Vd |= (opCode >> 18) & 0x10;
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
|
|
||||||
imm = ((uint)opCode >> 0) & 0xf;
|
imm = ((uint)opCode >> 0) & 0xf;
|
||||||
imm |= ((uint)opCode >> 12) & 0x70;
|
imm |= ((uint)opCode >> 12) & 0x70;
|
||||||
imm |= ((uint)opCode >> 17) & 0x80;
|
imm |= ((uint)opCode >> (isThumb ? 21 : 17)) & 0x80;
|
||||||
|
|
||||||
(Immediate, Size) = OpCodeSimdHelper.GetSimdImmediateAndSize(cMode, op, imm);
|
(Immediate, Size) = OpCodeSimdHelper.GetSimdImmediateAndSize(cMode, op, imm);
|
||||||
|
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public bool U { get; }
|
public bool U { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdLong(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdLong(inst, address, opCode, false);
|
||||||
|
public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdLong(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdLong(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdLong(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
int imm3h = (opCode >> 19) & 0x7;
|
int imm3h = (opCode >> 19) & 0x7;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
case 4: Size = 2; break;
|
case 4: Size = 2; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
U = ((opCode >> 24) & 0x1) != 0;
|
U = ((opCode >> (isThumb ? 28 : 24)) & 0x1) != 0;
|
||||||
|
|
||||||
RegisterSize = RegisterSize.Simd64;
|
RegisterSize = RegisterSize.Simd64;
|
||||||
|
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
using ARMeilleure.State;
|
using ARMeilleure.State;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace ARMeilleure.Decoders
|
namespace ARMeilleure.Decoders
|
||||||
{
|
{
|
||||||
class OpCode32SimdMemPair : OpCode32, IOpCode32Simd
|
class OpCode32SimdMemPair : OpCode32, IOpCode32Simd
|
||||||
{
|
{
|
||||||
private static int[] RegsMap =
|
private static int[] _regsMap =
|
||||||
{
|
{
|
||||||
1, 1, 4, 2,
|
1, 1, 4, 2,
|
||||||
1, 1, 3, 1,
|
1, 1, 3, 1,
|
||||||
@@ -24,10 +23,13 @@ namespace ARMeilleure.Decoders
|
|||||||
public int Regs { get; }
|
public int Regs { get; }
|
||||||
public int Increment { get; }
|
public int Increment { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemPair(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemPair(inst, address, opCode, false);
|
||||||
|
public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemPair(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdMemPair(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdMemPair(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode)
|
||||||
{
|
{
|
||||||
|
IsThumb = isThumb;
|
||||||
|
|
||||||
Vd = (opCode >> 12) & 0xf;
|
Vd = (opCode >> 12) & 0xf;
|
||||||
Vd |= (opCode >> 18) & 0x10;
|
Vd |= (opCode >> 18) & 0x10;
|
||||||
|
|
||||||
@@ -40,9 +42,9 @@ namespace ARMeilleure.Decoders
|
|||||||
WBack = Rm != RegisterAlias.Aarch32Pc;
|
WBack = Rm != RegisterAlias.Aarch32Pc;
|
||||||
RegisterIndex = Rm != RegisterAlias.Aarch32Pc && Rm != RegisterAlias.Aarch32Sp;
|
RegisterIndex = Rm != RegisterAlias.Aarch32Pc && Rm != RegisterAlias.Aarch32Sp;
|
||||||
|
|
||||||
Regs = RegsMap[(opCode >> 8) & 0xf];
|
Regs = _regsMap[(opCode >> 8) & 0xf];
|
||||||
|
|
||||||
Increment = Math.Min(Regs, ((opCode >> 8) & 0x1) + 1);
|
Increment = ((opCode >> 8) & 0x1) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,13 @@ namespace ARMeilleure.Decoders
|
|||||||
public bool Replicate { get; }
|
public bool Replicate { get; }
|
||||||
public int Increment { get; }
|
public int Increment { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemSingle(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemSingle(inst, address, opCode, false);
|
||||||
|
public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemSingle(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdMemSingle(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdMemSingle(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode)
|
||||||
{
|
{
|
||||||
|
IsThumb = isThumb;
|
||||||
|
|
||||||
Vd = (opCode >> 12) & 0xf;
|
Vd = (opCode >> 12) & 0xf;
|
||||||
Vd |= (opCode >> 18) & 0x10;
|
Vd |= (opCode >> 18) & 0x10;
|
||||||
|
|
||||||
|
@@ -2,9 +2,10 @@ namespace ARMeilleure.Decoders
|
|||||||
{
|
{
|
||||||
class OpCode32SimdMovn : OpCode32Simd
|
class OpCode32SimdMovn : OpCode32Simd
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMovn(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMovn(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMovn(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdMovn(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdMovn(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Size = (opCode >> 18) & 0x3;
|
Size = (opCode >> 18) & 0x3;
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,10 @@
|
|||||||
public int In => GetQuadwordSubindex(Vn) << (3 - Size);
|
public int In => GetQuadwordSubindex(Vn) << (3 - Size);
|
||||||
public int Fn => GetQuadwordSubindex(Vn) << (1 - (Size & 1));
|
public int Fn => GetQuadwordSubindex(Vn) << (1 - (Size & 1));
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdReg(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdReg(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdReg(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdReg(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdReg(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Vn = ((opCode >> 3) & 0x10) | ((opCode >> 16) & 0xf);
|
Vn = ((opCode >> 3) & 0x10) | ((opCode >> 16) & 0xf);
|
||||||
|
|
||||||
|
@@ -2,11 +2,12 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdRegElem : OpCode32SimdReg
|
class OpCode32SimdRegElem : OpCode32SimdReg
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElem(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElem(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElem(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdRegElem(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdRegElem(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Q = ((opCode >> 24) & 0x1) != 0;
|
Q = ((opCode >> (isThumb ? 28 : 24)) & 0x1) != 0;
|
||||||
F = ((opCode >> 8) & 0x1) != 0;
|
F = ((opCode >> 8) & 0x1) != 0;
|
||||||
Size = (opCode >> 20) & 0x3;
|
Size = (opCode >> 20) & 0x3;
|
||||||
|
|
||||||
|
@@ -2,9 +2,10 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdRegElemLong : OpCode32SimdRegElem
|
class OpCode32SimdRegElemLong : OpCode32SimdRegElem
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElemLong(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElemLong(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegElemLong(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdRegElemLong(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdRegElemLong(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Q = false;
|
Q = false;
|
||||||
F = false;
|
F = false;
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public bool Polynomial { get; }
|
public bool Polynomial { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegLong(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegLong(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegLong(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdRegLong(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdRegLong(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Q = false;
|
Q = false;
|
||||||
RegisterSize = RegisterSize.Simd64;
|
RegisterSize = RegisterSize.Simd64;
|
||||||
|
@@ -2,9 +2,10 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdRegWide : OpCode32SimdReg
|
class OpCode32SimdRegWide : OpCode32SimdReg
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegWide(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegWide(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRegWide(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdRegWide(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdRegWide(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Q = false;
|
Q = false;
|
||||||
RegisterSize = RegisterSize.Simd64;
|
RegisterSize = RegisterSize.Simd64;
|
||||||
|
@@ -2,9 +2,10 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdRev : OpCode32SimdCmpZ
|
class OpCode32SimdRev : OpCode32SimdCmpZ
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRev(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRev(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdRev(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdRev(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdRev(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
if (Opc + Size >= 3)
|
if (Opc + Size >= 3)
|
||||||
{
|
{
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Shift { get; }
|
public int Shift { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImm(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImm(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImm(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdShImm(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdShImm(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
int imm6 = (opCode >> 16) & 0x3f;
|
int imm6 = (opCode >> 16) & 0x3f;
|
||||||
int limm6 = ((opCode >> 1) & 0x40) | imm6;
|
int limm6 = ((opCode >> 1) & 0x40) | imm6;
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Shift { get; }
|
public int Shift { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmLong(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmLong(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmLong(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdShImmLong(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdShImmLong(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Q = false;
|
Q = false;
|
||||||
RegisterSize = RegisterSize.Simd64;
|
RegisterSize = RegisterSize.Simd64;
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdShImmNarrow : OpCode32SimdShImm
|
class OpCode32SimdShImmNarrow : OpCode32SimdShImm
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmNarrow(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmNarrow(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImmNarrow(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdShImmNarrow(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode) { }
|
public OpCode32SimdShImmNarrow(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,10 @@
|
|||||||
{
|
{
|
||||||
class OpCode32SimdSqrte : OpCode32Simd
|
class OpCode32SimdSqrte : OpCode32Simd
|
||||||
{
|
{
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdSqrte(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdSqrte(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdSqrte(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdSqrte(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdSqrte(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Size = (opCode >> 18) & 0x1;
|
Size = (opCode >> 18) & 0x1;
|
||||||
F = ((opCode >> 8) & 0x1) != 0;
|
F = ((opCode >> 8) & 0x1) != 0;
|
||||||
|
@@ -4,9 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Length { get; }
|
public int Length { get; }
|
||||||
|
|
||||||
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdTbl(inst, address, opCode);
|
public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdTbl(inst, address, opCode, false);
|
||||||
|
public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdTbl(inst, address, opCode, true);
|
||||||
|
|
||||||
public OpCode32SimdTbl(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
|
public OpCode32SimdTbl(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
|
||||||
{
|
{
|
||||||
Length = (opCode >> 8) & 3;
|
Length = (opCode >> 8) & 3;
|
||||||
Size = 0;
|
Size = 0;
|
||||||
|
@@ -93,6 +93,7 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA64("00011010110xxxxx010101xxxxxxxxxx", InstName.Crc32ch, InstEmit.Crc32ch, OpCodeAluBinary.Create);
|
SetA64("00011010110xxxxx010101xxxxxxxxxx", InstName.Crc32ch, InstEmit.Crc32ch, OpCodeAluBinary.Create);
|
||||||
SetA64("00011010110xxxxx010110xxxxxxxxxx", InstName.Crc32cw, InstEmit.Crc32cw, OpCodeAluBinary.Create);
|
SetA64("00011010110xxxxx010110xxxxxxxxxx", InstName.Crc32cw, InstEmit.Crc32cw, OpCodeAluBinary.Create);
|
||||||
SetA64("10011010110xxxxx010111xxxxxxxxxx", InstName.Crc32cx, InstEmit.Crc32cx, OpCodeAluBinary.Create);
|
SetA64("10011010110xxxxx010111xxxxxxxxxx", InstName.Crc32cx, InstEmit.Crc32cx, OpCodeAluBinary.Create);
|
||||||
|
SetA64("11010101000000110010001010011111", InstName.Csdb, InstEmit.Csdb, OpCodeSystem.Create);
|
||||||
SetA64("x0011010100xxxxxxxxx00xxxxxxxxxx", InstName.Csel, InstEmit.Csel, OpCodeCsel.Create);
|
SetA64("x0011010100xxxxxxxxx00xxxxxxxxxx", InstName.Csel, InstEmit.Csel, OpCodeCsel.Create);
|
||||||
SetA64("x0011010100xxxxxxxxx01xxxxxxxxxx", InstName.Csinc, InstEmit.Csinc, OpCodeCsel.Create);
|
SetA64("x0011010100xxxxxxxxx01xxxxxxxxxx", InstName.Csinc, InstEmit.Csinc, OpCodeCsel.Create);
|
||||||
SetA64("x1011010100xxxxxxxxx00xxxxxxxxxx", InstName.Csinv, InstEmit.Csinv, OpCodeCsel.Create);
|
SetA64("x1011010100xxxxxxxxx00xxxxxxxxxx", InstName.Csinv, InstEmit.Csinv, OpCodeCsel.Create);
|
||||||
@@ -107,7 +108,6 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA64("11001010xx0xxxxxxxxxxxxxxxxxxxxx", InstName.Eor, InstEmit.Eor, OpCodeAluRs.Create);
|
SetA64("11001010xx0xxxxxxxxxxxxxxxxxxxxx", InstName.Eor, InstEmit.Eor, OpCodeAluRs.Create);
|
||||||
SetA64("00010011100xxxxx0xxxxxxxxxxxxxxx", InstName.Extr, InstEmit.Extr, OpCodeAluRs.Create);
|
SetA64("00010011100xxxxx0xxxxxxxxxxxxxxx", InstName.Extr, InstEmit.Extr, OpCodeAluRs.Create);
|
||||||
SetA64("10010011110xxxxxxxxxxxxxxxxxxxxx", InstName.Extr, InstEmit.Extr, OpCodeAluRs.Create);
|
SetA64("10010011110xxxxxxxxxxxxxxxxxxxxx", InstName.Extr, InstEmit.Extr, OpCodeAluRs.Create);
|
||||||
SetA64("11010101000000110010xxxxxxx11111", InstName.Hint, InstEmit.Hint, OpCodeSystem.Create);
|
|
||||||
SetA64("11010101000000110011xxxx11011111", InstName.Isb, InstEmit.Isb, OpCodeSystem.Create);
|
SetA64("11010101000000110011xxxx11011111", InstName.Isb, InstEmit.Isb, OpCodeSystem.Create);
|
||||||
SetA64("xx001000110xxxxx1xxxxxxxxxxxxxxx", InstName.Ldar, InstEmit.Ldar, OpCodeMemEx.Create);
|
SetA64("xx001000110xxxxx1xxxxxxxxxxxxxxx", InstName.Ldar, InstEmit.Ldar, OpCodeMemEx.Create);
|
||||||
SetA64("1x001000011xxxxx1xxxxxxxxxxxxxxx", InstName.Ldaxp, InstEmit.Ldaxp, OpCodeMemEx.Create);
|
SetA64("1x001000011xxxxx1xxxxxxxxxxxxxxx", InstName.Ldaxp, InstEmit.Ldaxp, OpCodeMemEx.Create);
|
||||||
@@ -159,6 +159,8 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA64("00010011000xxxxx0xxxxxxxxxxxxxxx", InstName.Sbfm, InstEmit.Sbfm, OpCodeBfm.Create);
|
SetA64("00010011000xxxxx0xxxxxxxxxxxxxxx", InstName.Sbfm, InstEmit.Sbfm, OpCodeBfm.Create);
|
||||||
SetA64("1001001101xxxxxxxxxxxxxxxxxxxxxx", InstName.Sbfm, InstEmit.Sbfm, OpCodeBfm.Create);
|
SetA64("1001001101xxxxxxxxxxxxxxxxxxxxxx", InstName.Sbfm, InstEmit.Sbfm, OpCodeBfm.Create);
|
||||||
SetA64("x0011010110xxxxx000011xxxxxxxxxx", InstName.Sdiv, InstEmit.Sdiv, OpCodeAluBinary.Create);
|
SetA64("x0011010110xxxxx000011xxxxxxxxxx", InstName.Sdiv, InstEmit.Sdiv, OpCodeAluBinary.Create);
|
||||||
|
SetA64("11010101000000110010000010011111", InstName.Sev, InstEmit.Nop, OpCodeSystem.Create);
|
||||||
|
SetA64("11010101000000110010000010111111", InstName.Sevl, InstEmit.Nop, OpCodeSystem.Create);
|
||||||
SetA64("10011011001xxxxx0xxxxxxxxxxxxxxx", InstName.Smaddl, InstEmit.Smaddl, OpCodeMul.Create);
|
SetA64("10011011001xxxxx0xxxxxxxxxxxxxxx", InstName.Smaddl, InstEmit.Smaddl, OpCodeMul.Create);
|
||||||
SetA64("10011011001xxxxx1xxxxxxxxxxxxxxx", InstName.Smsubl, InstEmit.Smsubl, OpCodeMul.Create);
|
SetA64("10011011001xxxxx1xxxxxxxxxxxxxxx", InstName.Smsubl, InstEmit.Smsubl, OpCodeMul.Create);
|
||||||
SetA64("10011011010xxxxx0xxxxxxxxxxxxxxx", InstName.Smulh, InstEmit.Smulh, OpCodeMul.Create);
|
SetA64("10011011010xxxxx0xxxxxxxxxxxxxxx", InstName.Smulh, InstEmit.Smulh, OpCodeMul.Create);
|
||||||
@@ -191,6 +193,9 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA64("10011011101xxxxx0xxxxxxxxxxxxxxx", InstName.Umaddl, InstEmit.Umaddl, OpCodeMul.Create);
|
SetA64("10011011101xxxxx0xxxxxxxxxxxxxxx", InstName.Umaddl, InstEmit.Umaddl, OpCodeMul.Create);
|
||||||
SetA64("10011011101xxxxx1xxxxxxxxxxxxxxx", InstName.Umsubl, InstEmit.Umsubl, OpCodeMul.Create);
|
SetA64("10011011101xxxxx1xxxxxxxxxxxxxxx", InstName.Umsubl, InstEmit.Umsubl, OpCodeMul.Create);
|
||||||
SetA64("10011011110xxxxx0xxxxxxxxxxxxxxx", InstName.Umulh, InstEmit.Umulh, OpCodeMul.Create);
|
SetA64("10011011110xxxxx0xxxxxxxxxxxxxxx", InstName.Umulh, InstEmit.Umulh, OpCodeMul.Create);
|
||||||
|
SetA64("11010101000000110010000001011111", InstName.Wfe, InstEmit.Nop, OpCodeSystem.Create);
|
||||||
|
SetA64("11010101000000110010000001111111", InstName.Wfi, InstEmit.Nop, OpCodeSystem.Create);
|
||||||
|
SetA64("11010101000000110010000000111111", InstName.Yield, InstEmit.Nop, OpCodeSystem.Create);
|
||||||
|
|
||||||
// FP & SIMD
|
// FP & SIMD
|
||||||
SetA64("0101111011100000101110xxxxxxxxxx", InstName.Abs_S, InstEmit.Abs_S, OpCodeSimd.Create);
|
SetA64("0101111011100000101110xxxxxxxxxx", InstName.Abs_S, InstEmit.Abs_S, OpCodeSimd.Create);
|
||||||
@@ -669,6 +674,17 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA32("<<<<0010001xxxxxxxxxxxxxxxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluImm.Create);
|
SetA32("<<<<0010001xxxxxxxxxxxxxxxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluImm.Create);
|
||||||
SetA32("<<<<0000001xxxxxxxxxxxxxxxx0xxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluRsImm.Create);
|
SetA32("<<<<0000001xxxxxxxxxxxxxxxx0xxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluRsImm.Create);
|
||||||
SetA32("<<<<0000001xxxxxxxxxxxxx0xx1xxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluRsReg.Create);
|
SetA32("<<<<0000001xxxxxxxxxxxxx0xx1xxxx", InstName.Eor, InstEmit32.Eor, OpCode32AluRsReg.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000010000", InstName.Esb, InstEmit32.Nop, OpCode32.Create); // Error Synchronization Barrier (FEAT_RAS)
|
||||||
|
SetA32("<<<<001100100000111100000000011x", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000000001xxx", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000000010001", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000000010011", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000000010101", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<001100100000111100000001011x", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000000011xxx", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<00110010000011110000001xxxxx", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<0011001000001111000001xxxxxx", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
|
SetA32("<<<<001100100000111100001xxxxxxx", InstName.Hint, InstEmit32.Nop, OpCode32.Create); // Reserved Hint
|
||||||
SetA32("1111010101111111111100000110xxxx", InstName.Isb, InstEmit32.Nop, OpCode32.Create);
|
SetA32("1111010101111111111100000110xxxx", InstName.Isb, InstEmit32.Nop, OpCode32.Create);
|
||||||
SetA32("<<<<00011001xxxxxxxx110010011111", InstName.Lda, InstEmit32.Lda, OpCode32MemLdEx.Create);
|
SetA32("<<<<00011001xxxxxxxx110010011111", InstName.Lda, InstEmit32.Lda, OpCode32MemLdEx.Create);
|
||||||
SetA32("<<<<00011101xxxxxxxx110010011111", InstName.Ldab, InstEmit32.Ldab, OpCode32MemLdEx.Create);
|
SetA32("<<<<00011101xxxxxxxx110010011111", InstName.Ldab, InstEmit32.Ldab, OpCode32MemLdEx.Create);
|
||||||
@@ -727,11 +743,15 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA32("<<<<0010111xxxxxxxxxxxxxxxxxxxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluImm.Create);
|
SetA32("<<<<0010111xxxxxxxxxxxxxxxxxxxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluImm.Create);
|
||||||
SetA32("<<<<0000111xxxxxxxxxxxxxxxx0xxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluRsImm.Create);
|
SetA32("<<<<0000111xxxxxxxxxxxxxxxx0xxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluRsImm.Create);
|
||||||
SetA32("<<<<0000111xxxxxxxxxxxxx0xx1xxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluRsReg.Create);
|
SetA32("<<<<0000111xxxxxxxxxxxxx0xx1xxxx", InstName.Rsc, InstEmit32.Rsc, OpCode32AluRsReg.Create);
|
||||||
|
SetA32("<<<<01100001xxxxxxxx11111001xxxx", InstName.Sadd8, InstEmit32.Sadd8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<0010110xxxxxxxxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluImm.Create);
|
SetA32("<<<<0010110xxxxxxxxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluImm.Create);
|
||||||
SetA32("<<<<0000110xxxxxxxxxxxxxxxx0xxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluRsImm.Create);
|
SetA32("<<<<0000110xxxxxxxxxxxxxxxx0xxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluRsImm.Create);
|
||||||
SetA32("<<<<0000110xxxxxxxxxxxxx0xx1xxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluRsReg.Create);
|
SetA32("<<<<0000110xxxxxxxxxxxxx0xx1xxxx", InstName.Sbc, InstEmit32.Sbc, OpCode32AluRsReg.Create);
|
||||||
SetA32("<<<<0111101xxxxxxxxxxxxxx101xxxx", InstName.Sbfx, InstEmit32.Sbfx, OpCode32AluBf.Create);
|
SetA32("<<<<0111101xxxxxxxxxxxxxx101xxxx", InstName.Sbfx, InstEmit32.Sbfx, OpCode32AluBf.Create);
|
||||||
SetA32("<<<<01110001xxxx1111xxxx0001xxxx", InstName.Sdiv, InstEmit32.Sdiv, OpCode32AluMla.Create);
|
SetA32("<<<<01110001xxxx1111xxxx0001xxxx", InstName.Sdiv, InstEmit32.Sdiv, OpCode32AluMla.Create);
|
||||||
|
SetA32("<<<<01101000xxxxxxxx11111011xxxx", InstName.Sel, InstEmit32.Sel, OpCode32AluReg.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000000100", InstName.Sev, InstEmit32.Nop, OpCode32.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000000101", InstName.Sevl, InstEmit32.Nop, OpCode32.Create);
|
||||||
SetA32("<<<<01100011xxxxxxxx11111001xxxx", InstName.Shadd8, InstEmit32.Shadd8, OpCode32AluReg.Create);
|
SetA32("<<<<01100011xxxxxxxx11111001xxxx", InstName.Shadd8, InstEmit32.Shadd8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<01100011xxxxxxxx11111111xxxx", InstName.Shsub8, InstEmit32.Shsub8, OpCode32AluReg.Create);
|
SetA32("<<<<01100011xxxxxxxx11111111xxxx", InstName.Shsub8, InstEmit32.Shsub8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<00010000xxxxxxxxxxxx1xx0xxxx", InstName.Smla__, InstEmit32.Smla__, OpCode32AluMla.Create);
|
SetA32("<<<<00010000xxxxxxxxxxxx1xx0xxxx", InstName.Smla__, InstEmit32.Smla__, OpCode32AluMla.Create);
|
||||||
@@ -745,6 +765,7 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA32("<<<<00010010xxxx0000xxxx1x10xxxx", InstName.Smulw_, InstEmit32.Smulw_, OpCode32AluMla.Create);
|
SetA32("<<<<00010010xxxx0000xxxx1x10xxxx", InstName.Smulw_, InstEmit32.Smulw_, OpCode32AluMla.Create);
|
||||||
SetA32("<<<<0110101xxxxxxxxxxxxxxx01xxxx", InstName.Ssat, InstEmit32.Ssat, OpCode32Sat.Create);
|
SetA32("<<<<0110101xxxxxxxxxxxxxxx01xxxx", InstName.Ssat, InstEmit32.Ssat, OpCode32Sat.Create);
|
||||||
SetA32("<<<<01101010xxxxxxxx11110011xxxx", InstName.Ssat16, InstEmit32.Ssat16, OpCode32Sat16.Create);
|
SetA32("<<<<01101010xxxxxxxx11110011xxxx", InstName.Ssat16, InstEmit32.Ssat16, OpCode32Sat16.Create);
|
||||||
|
SetA32("<<<<01100001xxxxxxxx11111111xxxx", InstName.Ssub8, InstEmit32.Ssub8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<00011000xxxx111111001001xxxx", InstName.Stl, InstEmit32.Stl, OpCode32MemStEx.Create);
|
SetA32("<<<<00011000xxxx111111001001xxxx", InstName.Stl, InstEmit32.Stl, OpCode32MemStEx.Create);
|
||||||
SetA32("<<<<00011100xxxx111111001001xxxx", InstName.Stlb, InstEmit32.Stlb, OpCode32MemStEx.Create);
|
SetA32("<<<<00011100xxxx111111001001xxxx", InstName.Stlb, InstEmit32.Stlb, OpCode32MemStEx.Create);
|
||||||
SetA32("<<<<00011000xxxxxxxx11101001xxxx", InstName.Stlex, InstEmit32.Stlex, OpCode32MemStEx.Create);
|
SetA32("<<<<00011000xxxxxxxx11101001xxxx", InstName.Stlex, InstEmit32.Stlex, OpCode32MemStEx.Create);
|
||||||
@@ -776,9 +797,11 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA32("<<<<00010011xxxx0000xxxxxxx0xxxx", InstName.Teq, InstEmit32.Teq, OpCode32AluRsImm.Create);
|
SetA32("<<<<00010011xxxx0000xxxxxxx0xxxx", InstName.Teq, InstEmit32.Teq, OpCode32AluRsImm.Create);
|
||||||
SetA32("<<<<00010011xxxx0000xxxx0xx1xxxx", InstName.Teq, InstEmit32.Teq, OpCode32AluRsReg.Create);
|
SetA32("<<<<00010011xxxx0000xxxx0xx1xxxx", InstName.Teq, InstEmit32.Teq, OpCode32AluRsReg.Create);
|
||||||
SetA32("<<<<0111111111111101111011111110", InstName.Trap, InstEmit32.Trap, OpCode32Exception.Create);
|
SetA32("<<<<0111111111111101111011111110", InstName.Trap, InstEmit32.Trap, OpCode32Exception.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000010010", InstName.Tsb, InstEmit32.Nop, OpCode32.Create); // Trace Synchronization Barrier (FEAT_TRF)
|
||||||
SetA32("<<<<00110001xxxx0000xxxxxxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluImm.Create);
|
SetA32("<<<<00110001xxxx0000xxxxxxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluImm.Create);
|
||||||
SetA32("<<<<00010001xxxx0000xxxxxxx0xxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluRsImm.Create);
|
SetA32("<<<<00010001xxxx0000xxxxxxx0xxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluRsImm.Create);
|
||||||
SetA32("<<<<00010001xxxx0000xxxx0xx1xxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluRsReg.Create);
|
SetA32("<<<<00010001xxxx0000xxxx0xx1xxxx", InstName.Tst, InstEmit32.Tst, OpCode32AluRsReg.Create);
|
||||||
|
SetA32("<<<<01100101xxxxxxxx11111001xxxx", InstName.Uadd8, InstEmit32.Uadd8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<0111111xxxxxxxxxxxxxx101xxxx", InstName.Ubfx, InstEmit32.Ubfx, OpCode32AluBf.Create);
|
SetA32("<<<<0111111xxxxxxxxxxxxxx101xxxx", InstName.Ubfx, InstEmit32.Ubfx, OpCode32AluBf.Create);
|
||||||
SetA32("<<<<01110011xxxx1111xxxx0001xxxx", InstName.Udiv, InstEmit32.Udiv, OpCode32AluMla.Create);
|
SetA32("<<<<01110011xxxx1111xxxx0001xxxx", InstName.Udiv, InstEmit32.Udiv, OpCode32AluMla.Create);
|
||||||
SetA32("<<<<01100111xxxxxxxx11111001xxxx", InstName.Uhadd8, InstEmit32.Uhadd8, OpCode32AluReg.Create);
|
SetA32("<<<<01100111xxxxxxxx11111001xxxx", InstName.Uhadd8, InstEmit32.Uhadd8, OpCode32AluReg.Create);
|
||||||
@@ -788,9 +811,13 @@ namespace ARMeilleure.Decoders
|
|||||||
SetA32("<<<<0000100xxxxxxxxxxxxx1001xxxx", InstName.Umull, InstEmit32.Umull, OpCode32AluUmull.Create);
|
SetA32("<<<<0000100xxxxxxxxxxxxx1001xxxx", InstName.Umull, InstEmit32.Umull, OpCode32AluUmull.Create);
|
||||||
SetA32("<<<<0110111xxxxxxxxxxxxxxx01xxxx", InstName.Usat, InstEmit32.Usat, OpCode32Sat.Create);
|
SetA32("<<<<0110111xxxxxxxxxxxxxxx01xxxx", InstName.Usat, InstEmit32.Usat, OpCode32Sat.Create);
|
||||||
SetA32("<<<<01101110xxxxxxxx11110011xxxx", InstName.Usat16, InstEmit32.Usat16, OpCode32Sat16.Create);
|
SetA32("<<<<01101110xxxxxxxx11110011xxxx", InstName.Usat16, InstEmit32.Usat16, OpCode32Sat16.Create);
|
||||||
|
SetA32("<<<<01100101xxxxxxxx11111111xxxx", InstName.Usub8, InstEmit32.Usub8, OpCode32AluReg.Create);
|
||||||
SetA32("<<<<01101110xxxxxxxxxx000111xxxx", InstName.Uxtb, InstEmit32.Uxtb, OpCode32AluUx.Create);
|
SetA32("<<<<01101110xxxxxxxxxx000111xxxx", InstName.Uxtb, InstEmit32.Uxtb, OpCode32AluUx.Create);
|
||||||
SetA32("<<<<01101100xxxxxxxxxx000111xxxx", InstName.Uxtb16, InstEmit32.Uxtb16, OpCode32AluUx.Create);
|
SetA32("<<<<01101100xxxxxxxxxx000111xxxx", InstName.Uxtb16, InstEmit32.Uxtb16, OpCode32AluUx.Create);
|
||||||
SetA32("<<<<01101111xxxxxxxxxx000111xxxx", InstName.Uxth, InstEmit32.Uxth, OpCode32AluUx.Create);
|
SetA32("<<<<01101111xxxxxxxxxx000111xxxx", InstName.Uxth, InstEmit32.Uxth, OpCode32AluUx.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000000010", InstName.Wfe, InstEmit32.Nop, OpCode32.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000000011", InstName.Wfi, InstEmit32.Nop, OpCode32.Create);
|
||||||
|
SetA32("<<<<0011001000001111000000000001", InstName.Yield, InstEmit32.Nop, OpCode32.Create);
|
||||||
|
|
||||||
// VFP
|
// VFP
|
||||||
SetVfp("<<<<11101x110000xxxx101x11x0xxxx", InstName.Vabs, InstEmit32.Vabs_S, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
SetVfp("<<<<11101x110000xxxx101x11x0xxxx", InstName.Vabs, InstEmit32.Vabs_S, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||||
@@ -847,150 +874,174 @@ namespace ARMeilleure.Decoders
|
|||||||
SetVfp("<<<<11100x11xxxxxxxx101xx1x0xxxx", InstName.Vsub, InstEmit32.Vsub_S, OpCode32SimdRegS.Create, OpCode32SimdRegS.CreateT32);
|
SetVfp("<<<<11100x11xxxxxxxx101xx1x0xxxx", InstName.Vsub, InstEmit32.Vsub_S, OpCode32SimdRegS.Create, OpCode32SimdRegS.CreateT32);
|
||||||
|
|
||||||
// ASIMD
|
// ASIMD
|
||||||
SetA32("111100111x110000xxx0001101x0xxx0", InstName.Aesd_V, InstEmit32.Aesd_V, OpCode32Simd.Create);
|
SetAsimd("111100111x110000xxx0001101x0xxx0", InstName.Aesd_V, InstEmit32.Aesd_V, OpCode32Simd.Create, OpCode32Simd.CreateT32);
|
||||||
SetA32("111100111x110000xxx0001100x0xxx0", InstName.Aese_V, InstEmit32.Aese_V, OpCode32Simd.Create);
|
SetAsimd("111100111x110000xxx0001100x0xxx0", InstName.Aese_V, InstEmit32.Aese_V, OpCode32Simd.Create, OpCode32Simd.CreateT32);
|
||||||
SetA32("111100111x110000xxx0001111x0xxx0", InstName.Aesimc_V, InstEmit32.Aesimc_V, OpCode32Simd.Create);
|
SetAsimd("111100111x110000xxx0001111x0xxx0", InstName.Aesimc_V, InstEmit32.Aesimc_V, OpCode32Simd.Create, OpCode32Simd.CreateT32);
|
||||||
SetA32("111100111x110000xxx0001110x0xxx0", InstName.Aesmc_V, InstEmit32.Aesmc_V, OpCode32Simd.Create);
|
SetAsimd("111100111x110000xxx0001110x0xxx0", InstName.Aesmc_V, InstEmit32.Aesmc_V, OpCode32Simd.Create, OpCode32Simd.CreateT32);
|
||||||
SetA32("111100110x00xxx0xxx01100x1x0xxx0", InstName.Sha256h_V, InstEmit32.Sha256h_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110x00xxx0xxx01100x1x0xxx0", InstName.Sha256h_V, InstEmit32.Sha256h_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100110x01xxx0xxx01100x1x0xxx0", InstName.Sha256h2_V, InstEmit32.Sha256h2_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110x01xxx0xxx01100x1x0xxx0", InstName.Sha256h2_V, InstEmit32.Sha256h2_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x111010xxx0001111x0xxx0", InstName.Sha256su0_V, InstEmit32.Sha256su0_V, OpCode32Simd.Create);
|
SetAsimd("111100111x111010xxx0001111x0xxx0", InstName.Sha256su0_V, InstEmit32.Sha256su0_V, OpCode32Simd.Create, OpCode32Simd.CreateT32);
|
||||||
SetA32("111100110x10xxx0xxx01100x1x0xxx0", InstName.Sha256su1_V, InstEmit32.Sha256su1_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110x10xxx0xxx01100x1x0xxx0", InstName.Sha256su1_V, InstEmit32.Sha256su1_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0111xxx0xxxx", InstName.Vabd, InstEmit32.Vabd_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx0111xxx0xxxx", InstName.Vabd, InstEmit32.Vabd_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxxx0111x0x0xxxx", InstName.Vabdl, InstEmit32.Vabdl_I, OpCode32SimdRegLong.Create);
|
SetAsimd("1111001x1x<<xxxxxxxx0111x0x0xxxx", InstName.Vabdl, InstEmit32.Vabdl_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
SetA32("111100111x11<<01xxxx00110xx0xxxx", InstName.Vabs, InstEmit32.Vabs_V, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11<<01xxxx00110xx0xxxx", InstName.Vabs, InstEmit32.Vabs_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x111001xxxx01110xx0xxxx", InstName.Vabs, InstEmit32.Vabs_V, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x111001xxxx01110xx0xxxx", InstName.Vabs, InstEmit32.Vabs_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100100xxxxxxxxxxx1000xxx0xxxx", InstName.Vadd, InstEmit32.Vadd_I, OpCode32SimdReg.Create);
|
SetAsimd("111100100xxxxxxxxxxx1000xxx0xxxx", InstName.Vadd, InstEmit32.Vadd_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1101xxx0xxxx", InstName.Vadd, InstEmit32.Vadd_V, OpCode32SimdReg.Create);
|
SetAsimd("111100100x00xxxxxxxx1101xxx0xxxx", InstName.Vadd, InstEmit32.Vadd_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxx00000x0x0xxxx", InstName.Vaddl, InstEmit32.Vaddl_I, OpCode32SimdRegLong.Create);
|
SetAsimd("1111001x1x<<xxxxxxx00000x0x0xxxx", InstName.Vaddl, InstEmit32.Vaddl_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxx00001x0x0xxxx", InstName.Vaddw, InstEmit32.Vaddw_I, OpCode32SimdRegWide.Create);
|
SetAsimd("1111001x1x<<xxxxxxx00001x0x0xxxx", InstName.Vaddw, InstEmit32.Vaddw_I, OpCode32SimdRegWide.Create, OpCode32SimdRegWide.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx0001xxx1xxxx", InstName.Vand, InstEmit32.Vand_I, OpCode32SimdBinary.Create);
|
SetAsimd("111100100x00xxxxxxxx0001xxx1xxxx", InstName.Vand, InstEmit32.Vand_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100100x01xxxxxxxx0001xxx1xxxx", InstName.Vbic, InstEmit32.Vbic_I, OpCode32SimdBinary.Create);
|
SetAsimd("111100100x01xxxxxxxx0001xxx1xxxx", InstName.Vbic, InstEmit32.Vbic_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx<<x10x11xxxx", InstName.Vbic, InstEmit32.Vbic_II, OpCode32SimdImm.Create);
|
SetAsimd("1111001x1x000xxxxxxx<<x10x11xxxx", InstName.Vbic, InstEmit32.Vbic_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32);
|
||||||
SetA32("111100110x11xxxxxxxx0001xxx1xxxx", InstName.Vbif, InstEmit32.Vbif, OpCode32SimdBinary.Create);
|
SetAsimd("111100110x11xxxxxxxx0001xxx1xxxx", InstName.Vbif, InstEmit32.Vbif, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100110x10xxxxxxxx0001xxx1xxxx", InstName.Vbit, InstEmit32.Vbit, OpCode32SimdBinary.Create);
|
SetAsimd("111100110x10xxxxxxxx0001xxx1xxxx", InstName.Vbit, InstEmit32.Vbit, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100110x01xxxxxxxx0001xxx1xxxx", InstName.Vbsl, InstEmit32.Vbsl, OpCode32SimdBinary.Create);
|
SetAsimd("111100110x01xxxxxxxx0001xxx1xxxx", InstName.Vbsl, InstEmit32.Vbsl, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100110x<<xxxxxxxx1000xxx1xxxx", InstName.Vceq, InstEmit32.Vceq_I, OpCode32SimdReg.Create);
|
SetAsimd("111100110x<<xxxxxxxx1000xxx1xxxx", InstName.Vceq, InstEmit32.Vceq_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1110xxx0xxxx", InstName.Vceq, InstEmit32.Vceq_V, OpCode32SimdReg.Create);
|
SetAsimd("111100100x00xxxxxxxx1110xxx0xxxx", InstName.Vceq, InstEmit32.Vceq_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x11xx01xxxx0x010xx0xxxx", InstName.Vceq, InstEmit32.Vceq_Z, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11xx01xxxx0x010xx0xxxx", InstName.Vceq, InstEmit32.Vceq_Z, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0011xxx1xxxx", InstName.Vcge, InstEmit32.Vcge_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx0011xxx1xxxx", InstName.Vcge, InstEmit32.Vcge_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100110x00xxxxxxxx1110xxx0xxxx", InstName.Vcge, InstEmit32.Vcge_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110x00xxxxxxxx1110xxx0xxxx", InstName.Vcge, InstEmit32.Vcge_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x11xx01xxxx0x001xx0xxxx", InstName.Vcge, InstEmit32.Vcge_Z, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11xx01xxxx0x001xx0xxxx", InstName.Vcge, InstEmit32.Vcge_Z, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0011xxx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx0011xxx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100110x10xxxxxxxx1110xxx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110x10xxxxxxxx1110xxx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x11xx01xxxx0x000xx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_Z, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11xx01xxxx0x000xx0xxxx", InstName.Vcgt, InstEmit32.Vcgt_Z, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x11xx01xxxx0x011xx0xxxx", InstName.Vcle, InstEmit32.Vcle_Z, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11xx01xxxx0x011xx0xxxx", InstName.Vcle, InstEmit32.Vcle_Z, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x11xx01xxxx0x100xx0xxxx", InstName.Vclt, InstEmit32.Vclt_Z, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11xx01xxxx0x100xx0xxxx", InstName.Vclt, InstEmit32.Vclt_Z, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x110000xxxx01010xx0xxxx", InstName.Vcnt, InstEmit32.Vcnt, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x110000xxxx01010xx0xxxx", InstName.Vcnt, InstEmit32.Vcnt, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x111011xxxx011xxxx0xxxx", InstName.Vcvt, InstEmit32.Vcvt_V, OpCode32SimdCmpZ.Create); // FP and integer, vector.
|
SetAsimd("111100111x111011xxxx011xxxx0xxxx", InstName.Vcvt, InstEmit32.Vcvt_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32); // FP and integer, vector.
|
||||||
SetA32("111100111x11xxxxxxxx11000xx0xxxx", InstName.Vdup, InstEmit32.Vdup_1, OpCode32SimdDupElem.Create);
|
SetAsimd("111100111x11xxxxxxxx11000xx0xxxx", InstName.Vdup, InstEmit32.Vdup_1, OpCode32SimdDupElem.Create, OpCode32SimdDupElem.CreateT32);
|
||||||
SetA32("111100110x00xxxxxxxx0001xxx1xxxx", InstName.Veor, InstEmit32.Veor_I, OpCode32SimdBinary.Create);
|
SetAsimd("111100110x00xxxxxxxx0001xxx1xxxx", InstName.Veor, InstEmit32.Veor_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100101x11xxxxxxxxxxxxxxx0xxxx", InstName.Vext, InstEmit32.Vext, OpCode32SimdExt.Create);
|
SetAsimd("111100101x11xxxxxxxxxxxxxxx0xxxx", InstName.Vext, InstEmit32.Vext, OpCode32SimdExt.Create, OpCode32SimdExt.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1100xxx1xxxx", InstName.Vfma, InstEmit32.Vfma_V, OpCode32SimdReg.Create);
|
SetAsimd("111100100x00xxxxxxxx1100xxx1xxxx", InstName.Vfma, InstEmit32.Vfma_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx1100xxx1xxxx", InstName.Vfms, InstEmit32.Vfms_V, OpCode32SimdReg.Create);
|
SetAsimd("111100100x10xxxxxxxx1100xxx1xxxx", InstName.Vfms, InstEmit32.Vfms_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0000xxx0xxxx", InstName.Vhadd, InstEmit32.Vhadd, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx0000xxx0xxxx", InstName.Vhadd, InstEmit32.Vhadd, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111101001x10xxxxxxxxxx00xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create);
|
SetAsimd("111101001x10xxxxxxxx0000xxx0xxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx0111xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create); // Regs = 1.
|
SetAsimd("111101001x10xxxxxxxx0100xx0xxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx1010xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create); // Regs = 2.
|
SetAsimd("111101001x10xxxxxxxx1000x000xxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx0110xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create); // Regs = 3.
|
SetAsimd("111101001x10xxxxxxxx1000x011xxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx0010xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create); // Regs = 4.
|
SetAsimd("111101001x10xxxxxxxx110000x0xxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101001x10xxxxxxxxxx01xxxxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemSingle.Create);
|
SetAsimd("111101001x10xxxxxxxx110001xxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx100xxxxxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemPair.Create); // Regs = 1, inc = 1/2 (itype).
|
SetAsimd("111101001x10xxxxxxxx110010xxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111101000x10xxxxxxxx0011xxxxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemPair.Create); // Regs = 2, inc = 2.
|
SetAsimd("111101000x10xxxxxxxx0111xx0xxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1.
|
||||||
SetA32("111101001x10xxxxxxxxxx10xxxxxxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemSingle.Create);
|
SetAsimd("111101000x10xxxxxxxx1010xx<<xxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 2.
|
||||||
SetA32("111101000x10xxxxxxxx010xxxxxxxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemPair.Create); // Inc = 1/2 (itype).
|
SetAsimd("111101000x10xxxxxxxx0110xx0xxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 3.
|
||||||
SetA32("111101001x10xxxxxxxxxx11xxxxxxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemSingle.Create);
|
SetAsimd("111101000x10xxxxxxxx0010xxxxxxxx", InstName.Vld1, InstEmit32.Vld1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 4.
|
||||||
SetA32("111101000x10xxxxxxxx000xxxxxxxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemPair.Create); // Inc = 1/2 (itype).
|
SetAsimd("111101001x10xxxxxxxx0x01xxxxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0110xxx0xxxx", InstName.Vmax, InstEmit32.Vmax_I, OpCode32SimdReg.Create);
|
SetAsimd("111101001x10xxxxxxxx1001xx0xxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1111xxx0xxxx", InstName.Vmax, InstEmit32.Vmax_V, OpCode32SimdReg.Create);
|
SetAsimd("111101001x10xxxxxxxx1101<<xxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0110xxx1xxxx", InstName.Vmin, InstEmit32.Vmin_I, OpCode32SimdReg.Create);
|
SetAsimd("111101000x10xxxxxxxx100x<<0xxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1, inc = 1/2 (itype).
|
||||||
SetA32("111100100x10xxxxxxxx1111xxx0xxxx", InstName.Vmin, InstEmit32.Vmin_V, OpCode32SimdReg.Create);
|
SetAsimd("111101000x10xxxxxxxx100x<<10xxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1, inc = 1/2 (itype).
|
||||||
SetA32("111100110x0xxxxxxxxx1111xxx1xxxx", InstName.Vmaxnm, InstEmit32.Vmaxnm_V, OpCode32SimdReg.Create);
|
SetAsimd("111101000x10xxxxxxxx0011<<xxxxxx", InstName.Vld2, InstEmit32.Vld2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 2, inc = 2.
|
||||||
SetA32("111100110x1xxxxxxxxx1111xxx1xxxx", InstName.Vminnm, InstEmit32.Vminnm_V, OpCode32SimdReg.Create);
|
SetAsimd("111101001x10xxxxxxxx0x10xxx0xxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxxx000xx1x0xxxx", InstName.Vmla, InstEmit32.Vmla_1, OpCode32SimdRegElem.Create);
|
SetAsimd("111101001x10xxxxxxxx1010xx00xxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100100xxxxxxxxxxx1001xxx0xxxx", InstName.Vmla, InstEmit32.Vmla_I, OpCode32SimdReg.Create);
|
SetAsimd("111101001x10xxxxxxxx1110<<x0xxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1101xxx1xxxx", InstName.Vmla, InstEmit32.Vmla_V, OpCode32SimdReg.Create);
|
SetAsimd("111101000x10xxxxxxxx010x<<0xxxxx", InstName.Vld3, InstEmit32.Vld3, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Inc = 1/2 (itype).
|
||||||
SetA32("1111001x1x<<xxxxxxx01000x0x0xxxx", InstName.Vmlal, InstEmit32.Vmlal_I, OpCode32SimdRegLong.Create);
|
SetAsimd("111101001x10xxxxxxxx0x11xxxxxxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxxx010xx1x0xxxx", InstName.Vmls, InstEmit32.Vmls_1, OpCode32SimdRegElem.Create);
|
SetAsimd("111101001x10xxxxxxxx1011xx<<xxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx1101xxx1xxxx", InstName.Vmls, InstEmit32.Vmls_V, OpCode32SimdReg.Create);
|
SetAsimd("111101001x10xxxxxxxx1111<<x>xxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100110xxxxxxxxxxx1001xxx0xxxx", InstName.Vmls, InstEmit32.Vmls_I, OpCode32SimdReg.Create);
|
SetAsimd("111101000x10xxxxxxxx000x<<xxxxxx", InstName.Vld4, InstEmit32.Vld4, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Inc = 1/2 (itype).
|
||||||
SetA32("1111001x1x<<xxxxxxx01010x0x0xxxx", InstName.Vmlsl, InstEmit32.Vmlsl_I, OpCode32SimdRegLong.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx0110xxx0xxxx", InstName.Vmax, InstEmit32.Vmax_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx0xx00x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create); // D/Q vector I32.
|
SetAsimd("111100100x00xxxxxxxx1111xxx0xxxx", InstName.Vmax, InstEmit32.Vmax_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx10x00x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create); // D/Q I16.
|
SetAsimd("1111001x0x<<xxxxxxxx0110xxx1xxxx", InstName.Vmin, InstEmit32.Vmin_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx11xx0x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create); // D/Q (dt - from cmode).
|
SetAsimd("111100100x10xxxxxxxx1111xxx0xxxx", InstName.Vmin, InstEmit32.Vmin_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx11100x11xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create); // D/Q I64.
|
SetAsimd("111100110x0xxxxxxxxx1111xxx1xxxx", InstName.Vmaxnm, InstEmit32.Vmaxnm_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x001000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create);
|
SetAsimd("111100110x1xxxxxxxxx1111xxx1xxxx", InstName.Vminnm, InstEmit32.Vminnm_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x010000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create);
|
SetAsimd("1111001x1x<<xxxxxxxx000xx1x0xxxx", InstName.Vmla, InstEmit32.Vmla_1, OpCode32SimdRegElem.Create, OpCode32SimdRegElem.CreateT32);
|
||||||
SetA32("1111001x1x100000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create);
|
SetAsimd("111100100xxxxxxxxxxx1001xxx0xxxx", InstName.Vmla, InstEmit32.Vmla_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx001000x0xxx0", InstName.Vmovn, InstEmit32.Vmovn, OpCode32SimdMovn.Create);
|
SetAsimd("111100100x00xxxxxxxx1101xxx1xxxx", InstName.Vmla, InstEmit32.Vmla_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxxx100xx1x0xxxx", InstName.Vmul, InstEmit32.Vmul_1, OpCode32SimdRegElem.Create);
|
SetAsimd("1111001x1x<<xxxxxxx01000x0x0xxxx", InstName.Vmlal, InstEmit32.Vmlal_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
SetA32("111100100x<<xxxxxxxx1001xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x<<xxxxxxxx010xx1x0xxxx", InstName.Vmls, InstEmit32.Vmls_1, OpCode32SimdRegElem.Create, OpCode32SimdRegElem.CreateT32);
|
||||||
SetA32("111100110x00xxxxxxxx1001xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_I, OpCode32SimdReg.Create);
|
SetAsimd("111100100x10xxxxxxxx1101xxx1xxxx", InstName.Vmls, InstEmit32.Vmls_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100110x00xxxxxxxx1101xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_V, OpCode32SimdReg.Create);
|
SetAsimd("111100110xxxxxxxxxxx1001xxx0xxxx", InstName.Vmls, InstEmit32.Vmls_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxx01010x1x0xxxx", InstName.Vmull, InstEmit32.Vmull_1, OpCode32SimdRegElemLong.Create);
|
SetAsimd("1111001x1x<<xxxxxxx01010x0x0xxxx", InstName.Vmlsl, InstEmit32.Vmlsl_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxx01100x0x0xxxx", InstName.Vmull, InstEmit32.Vmull_I, OpCode32SimdRegLong.Create);
|
SetAsimd("1111001x1x000xxxxxxx0xx00x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32); // D/Q vector I32.
|
||||||
SetA32("111100101xx0xxxxxxx01110x0x0xxxx", InstName.Vmull, InstEmit32.Vmull_I, OpCode32SimdRegLong.Create); // P8/P64
|
SetAsimd("1111001x1x000xxxxxxx10x00x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32); // D/Q I16.
|
||||||
SetA32("111100111x110000xxxx01011xx0xxxx", InstName.Vmvn, InstEmit32.Vmvn_I, OpCode32SimdBinary.Create);
|
SetAsimd("1111001x1x000xxxxxxx11xx0x01xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32); // D/Q (dt - from cmode).
|
||||||
SetA32("1111001x1x000xxxxxxx0xx00x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create); // D/Q vector I32.
|
SetAsimd("1111001x1x000xxxxxxx11100x11xxxx", InstName.Vmov, InstEmit32.Vmov_I, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32); // D/Q I64.
|
||||||
SetA32("1111001x1x000xxxxxxx10x00x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create);
|
SetAsimd("1111001x1x001000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create, OpCode32SimdLong.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx110x0x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create);
|
SetAsimd("1111001x1x010000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create, OpCode32SimdLong.CreateT32);
|
||||||
SetA32("111100111x11<<01xxxx00111xx0xxxx", InstName.Vneg, InstEmit32.Vneg_V, OpCode32SimdCmpZ.Create);
|
SetAsimd("1111001x1x100000xxx0101000x1xxxx", InstName.Vmovl, InstEmit32.Vmovl, OpCode32SimdLong.Create, OpCode32SimdLong.CreateT32);
|
||||||
SetA32("111100111x111001xxxx01111xx0xxxx", InstName.Vneg, InstEmit32.Vneg_V, OpCode32SimdCmpZ.Create);
|
SetAsimd("111100111x11<<10xxxx001000x0xxx0", InstName.Vmovn, InstEmit32.Vmovn, OpCode32SimdMovn.Create, OpCode32SimdMovn.CreateT32);
|
||||||
SetA32("111100100x11xxxxxxxx0001xxx1xxxx", InstName.Vorn, InstEmit32.Vorn_I, OpCode32SimdBinary.Create);
|
SetAsimd("1111001x1x<<xxxxxxxx100xx1x0xxxx", InstName.Vmul, InstEmit32.Vmul_1, OpCode32SimdRegElem.Create, OpCode32SimdRegElem.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx0001xxx1xxxx", InstName.Vorr, InstEmit32.Vorr_I, OpCode32SimdBinary.Create);
|
SetAsimd("111100100x<<xxxxxxxx1001xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x000xxxxxxx<<x10x01xxxx", InstName.Vorr, InstEmit32.Vorr_II, OpCode32SimdImm.Create);
|
SetAsimd("111100110x00xxxxxxxx1001xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x<<xxxxxxxx1011x0x1xxxx", InstName.Vpadd, InstEmit32.Vpadd_I, OpCode32SimdReg.Create);
|
SetAsimd("111100110x00xxxxxxxx1101xxx1xxxx", InstName.Vmul, InstEmit32.Vmul_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100110x00xxxxxxxx1101x0x0xxxx", InstName.Vpadd, InstEmit32.Vpadd_V, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x<<xxxxxxx01010x1x0xxxx", InstName.Vmull, InstEmit32.Vmull_1, OpCode32SimdRegElemLong.Create, OpCode32SimdRegElemLong.CreateT32);
|
||||||
SetA32("111100111x11<<00xxxx0010xxx0xxxx", InstName.Vpaddl, InstEmit32.Vpaddl, OpCode32SimdCmpZ.Create);
|
SetAsimd("1111001x1x<<xxxxxxx01100x0x0xxxx", InstName.Vmull, InstEmit32.Vmull_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx1010x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_I, OpCode32SimdReg.Create);
|
SetAsimd("111100101xx0xxxxxxx01110x0x0xxxx", InstName.Vmull, InstEmit32.Vmull_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32); // P8/P64
|
||||||
SetA32("111100110x00xxxxxxxx1111x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_V, OpCode32SimdReg.Create);
|
SetAsimd("111100111x110000xxxx01011xx0xxxx", InstName.Vmvn, InstEmit32.Vmvn_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx1010x0x1xxxx", InstName.Vpmin, InstEmit32.Vpmin_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x000xxxxxxx0xx00x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32); // D/Q vector I32.
|
||||||
SetA32("111100110x10xxxxxxxx1111x0x0xxxx", InstName.Vpmin, InstEmit32.Vpmin_V, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x000xxxxxxx10x00x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32);
|
||||||
SetA32("1111001x0xxxxxxxxxxx0000xxx1xxxx", InstName.Vqadd, InstEmit32.Vqadd, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x000xxxxxxx110x0x11xxxx", InstName.Vmvn, InstEmit32.Vmvn_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32);
|
||||||
SetA32("111100100x01xxxxxxxx1011xxx0xxxx", InstName.Vqdmulh, InstEmit32.Vqdmulh, OpCode32SimdReg.Create);
|
SetAsimd("111100111x11<<01xxxx00111xx0xxxx", InstName.Vneg, InstEmit32.Vneg_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx1011xxx0xxxx", InstName.Vqdmulh, InstEmit32.Vqdmulh, OpCode32SimdReg.Create);
|
SetAsimd("111100111x111001xxxx01111xx0xxxx", InstName.Vneg, InstEmit32.Vneg_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx00101xx0xxx0", InstName.Vqmovn, InstEmit32.Vqmovn, OpCode32SimdMovn.Create);
|
SetAsimd("111100100x11xxxxxxxx0001xxx1xxxx", InstName.Vorn, InstEmit32.Vorn_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx001001x0xxx0", InstName.Vqmovun, InstEmit32.Vqmovun, OpCode32SimdMovn.Create);
|
SetAsimd("111100100x10xxxxxxxx0001xxx1xxxx", InstName.Vorr, InstEmit32.Vorr_I, OpCode32SimdBinary.Create, OpCode32SimdBinary.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx100101x1xxx0", InstName.Vqrshrn, InstEmit32.Vqrshrn, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("1111001x1x000xxxxxxx<<x10x01xxxx", InstName.Vorr, InstEmit32.Vorr_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32);
|
||||||
SetA32("111100111x>>>xxxxxxx100001x1xxx0", InstName.Vqrshrun, InstEmit32.Vqrshrun, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("111100100x<<xxxxxxxx1011x0x1xxxx", InstName.Vpadd, InstEmit32.Vpadd_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx100100x1xxx0", InstName.Vqshrn, InstEmit32.Vqshrn, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("111100110x00xxxxxxxx1101x0x0xxxx", InstName.Vpadd, InstEmit32.Vpadd_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x>>>xxxxxxx100000x1xxx0", InstName.Vqshrun, InstEmit32.Vqshrun, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("111100111x11<<00xxxx0010xxx0xxxx", InstName.Vpaddl, InstEmit32.Vpaddl, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("1111001x0xxxxxxxxxxx0010xxx1xxxx", InstName.Vqsub, InstEmit32.Vqsub, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx1010x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x111011xxxx010x0xx0xxxx", InstName.Vrecpe, InstEmit32.Vrecpe, OpCode32SimdSqrte.Create);
|
SetAsimd("111100110x00xxxxxxxx1111x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x00xxxxxxxx1111xxx1xxxx", InstName.Vrecps, InstEmit32.Vrecps, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0x<<xxxxxxxx1010x0x1xxxx", InstName.Vpmin, InstEmit32.Vpmin_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x11xx00xxxx000<<xx0xxxx", InstName.Vrev, InstEmit32.Vrev, OpCode32SimdRev.Create);
|
SetAsimd("111100110x10xxxxxxxx1111x0x0xxxx", InstName.Vpmin, InstEmit32.Vpmin_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x0x<<xxxxxxxx0001xxx0xxxx", InstName.Vrhadd, InstEmit32.Vrhadd, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0xxxxxxxxxxx0000xxx1xxxx", InstName.Vqadd, InstEmit32.Vqadd, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx0010>xx1xxxx", InstName.Vrshr, InstEmit32.Vrshr, OpCode32SimdShImm.Create);
|
SetAsimd("111100100x01xxxxxxxx1011xxx0xxxx", InstName.Vqdmulh, InstEmit32.Vqdmulh, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100101x>>>xxxxxxx100001x1xxx0", InstName.Vrshrn, InstEmit32.Vrshrn, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("111100100x10xxxxxxxx1011xxx0xxxx", InstName.Vqdmulh, InstEmit32.Vqdmulh, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100111x111011xxxx010x1xx0xxxx", InstName.Vrsqrte, InstEmit32.Vrsqrte, OpCode32SimdSqrte.Create);
|
SetAsimd("111100111x11<<10xxxx00101xx0xxx0", InstName.Vqmovn, InstEmit32.Vqmovn, OpCode32SimdMovn.Create, OpCode32SimdMovn.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx1111xxx1xxxx", InstName.Vrsqrts, InstEmit32.Vrsqrts, OpCode32SimdReg.Create);
|
SetAsimd("111100111x11<<10xxxx001001x0xxx0", InstName.Vqmovun, InstEmit32.Vqmovun, OpCode32SimdMovn.Create, OpCode32SimdMovn.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx0011>xx1xxxx", InstName.Vrsra, InstEmit32.Vrsra, OpCode32SimdShImm.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx100101x1xxx0", InstName.Vqrshrn, InstEmit32.Vqrshrn, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("111100101x>>>xxxxxxx0101>xx1xxxx", InstName.Vshl, InstEmit32.Vshl, OpCode32SimdShImm.Create);
|
SetAsimd("111100111x>>>xxxxxxx100001x1xxx0", InstName.Vqrshrun, InstEmit32.Vqrshrun, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("1111001x0xxxxxxxxxxx0100xxx0xxxx", InstName.Vshl, InstEmit32.Vshl_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx100100x1xxx0", InstName.Vqshrn, InstEmit32.Vqshrn, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx101000x1xxxx", InstName.Vshll, InstEmit32.Vshll, OpCode32SimdShImmLong.Create); // A1 encoding.
|
SetAsimd("111100111x>>>xxxxxxx100000x1xxx0", InstName.Vqshrun, InstEmit32.Vqshrun, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx0000>xx1xxxx", InstName.Vshr, InstEmit32.Vshr, OpCode32SimdShImm.Create);
|
SetAsimd("1111001x0xxxxxxxxxxx0010xxx1xxxx", InstName.Vqsub, InstEmit32.Vqsub, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100101x>>>xxxxxxx100000x1xxx0", InstName.Vshrn, InstEmit32.Vshrn, OpCode32SimdShImmNarrow.Create);
|
SetAsimd("111100111x111011xxxx010x0xx0xxxx", InstName.Vrecpe, InstEmit32.Vrecpe, OpCode32SimdSqrte.Create, OpCode32SimdSqrte.CreateT32);
|
||||||
SetA32("1111001x1x>>>xxxxxxx0001>xx1xxxx", InstName.Vsra, InstEmit32.Vsra, OpCode32SimdShImm.Create);
|
SetAsimd("111100100x00xxxxxxxx1111xxx1xxxx", InstName.Vrecps, InstEmit32.Vrecps, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111101001x00xxxxxxxx<<00xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemSingle.Create);
|
SetAsimd("111100111x11xx00xxxx000<<xx0xxxx", InstName.Vrev, InstEmit32.Vrev, OpCode32SimdRev.Create, OpCode32SimdRev.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx0111xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create); // Regs = 1.
|
SetAsimd("1111001x0x<<xxxxxxxx0001xxx0xxxx", InstName.Vrhadd, InstEmit32.Vrhadd, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx1010xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create); // Regs = 2.
|
SetAsimd("111100111x111010xxxx01010xx0xxxx", InstName.Vrinta, InstEmit32.Vrinta_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx0110xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create); // Regs = 3.
|
SetAsimd("111100111x111010xxxx01101xx0xxxx", InstName.Vrintm, InstEmit32.Vrintm_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx0010xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create); // Regs = 4.
|
SetAsimd("111100111x111010xxxx01000xx0xxxx", InstName.Vrintn, InstEmit32.Vrintn_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111101001x00xxxxxxxx<<01xxxxxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemSingle.Create);
|
SetAsimd("111100111x111010xxxx01111xx0xxxx", InstName.Vrintp, InstEmit32.Vrintp_V, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx100xxxxxxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemPair.Create); // Regs = 1, inc = 1/2 (itype).
|
SetAsimd("1111001x1x>>>xxxxxxx0010>xx1xxxx", InstName.Vrshr, InstEmit32.Vrshr, OpCode32SimdShImm.Create, OpCode32SimdShImm.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx0011xxxxxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemPair.Create); // Regs = 2, inc = 2.
|
SetAsimd("111100101x>>>xxxxxxx100001x1xxx0", InstName.Vrshrn, InstEmit32.Vrshrn, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("111101001x00xxxxxxxx<<10xxxxxxxx", InstName.Vst3, InstEmit32.Vst3, OpCode32SimdMemSingle.Create);
|
SetAsimd("111100111x111011xxxx010x1xx0xxxx", InstName.Vrsqrte, InstEmit32.Vrsqrte, OpCode32SimdSqrte.Create, OpCode32SimdSqrte.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx010xxxxxxxxx", InstName.Vst3, InstEmit32.Vst3, OpCode32SimdMemPair.Create); // Inc = 1/2 (itype).
|
SetAsimd("111100100x10xxxxxxxx1111xxx1xxxx", InstName.Vrsqrts, InstEmit32.Vrsqrts, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111101001x00xxxxxxxx<<11xxxxxxxx", InstName.Vst4, InstEmit32.Vst4, OpCode32SimdMemSingle.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx0011>xx1xxxx", InstName.Vrsra, InstEmit32.Vrsra, OpCode32SimdShImm.Create, OpCode32SimdShImm.CreateT32);
|
||||||
SetA32("111101000x00xxxxxxxx000xxxxxxxxx", InstName.Vst4, InstEmit32.Vst4, OpCode32SimdMemPair.Create); // Inc = 1/2 (itype).
|
SetAsimd("111100101x>>>xxxxxxx0101>xx1xxxx", InstName.Vshl, InstEmit32.Vshl, OpCode32SimdShImm.Create, OpCode32SimdShImm.CreateT32);
|
||||||
SetA32("111100110xxxxxxxxxxx1000xxx0xxxx", InstName.Vsub, InstEmit32.Vsub_I, OpCode32SimdReg.Create);
|
SetAsimd("1111001x0xxxxxxxxxxx0100xxx0xxxx", InstName.Vshl, InstEmit32.Vshl_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
SetA32("111100100x10xxxxxxxx1101xxx0xxxx", InstName.Vsub, InstEmit32.Vsub_V, OpCode32SimdReg.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx101000x1xxxx", InstName.Vshll, InstEmit32.Vshll, OpCode32SimdShImmLong.Create, OpCode32SimdShImmLong.CreateT32); // A1 encoding.
|
||||||
SetA32("1111001x1x<<xxxxxxx00010x0x0xxxx", InstName.Vsubl, InstEmit32.Vsubl_I, OpCode32SimdRegLong.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx0000>xx1xxxx", InstName.Vshr, InstEmit32.Vshr, OpCode32SimdShImm.Create, OpCode32SimdShImm.CreateT32);
|
||||||
SetA32("1111001x1x<<xxxxxxx00011x0x0xxxx", InstName.Vsubw, InstEmit32.Vsubw_I, OpCode32SimdRegWide.Create);
|
SetAsimd("111100101x>>>xxxxxxx100000x1xxx0", InstName.Vshrn, InstEmit32.Vshrn, OpCode32SimdShImmNarrow.Create, OpCode32SimdShImmNarrow.CreateT32);
|
||||||
SetA32("111100111x11xxxxxxxx10xxxxx0xxxx", InstName.Vtbl, InstEmit32.Vtbl, OpCode32SimdTbl.Create);
|
SetAsimd("1111001x1x>>>xxxxxxx0001>xx1xxxx", InstName.Vsra, InstEmit32.Vsra, OpCode32SimdShImm.Create, OpCode32SimdShImm.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx00001xx0xxxx", InstName.Vtrn, InstEmit32.Vtrn, OpCode32SimdCmpZ.Create);
|
SetAsimd("111101001x00xxxxxxxx0000xxx0xxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100100x<<xxxxxxxx1000xxx1xxxx", InstName.Vtst, InstEmit32.Vtst, OpCode32SimdReg.Create);
|
SetAsimd("111101001x00xxxxxxxx0100xx0xxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx00010xx0xxxx", InstName.Vuzp, InstEmit32.Vuzp, OpCode32SimdCmpZ.Create);
|
SetAsimd("111101001x00xxxxxxxx1000x000xxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
SetA32("111100111x11<<10xxxx00011xx0xxxx", InstName.Vzip, InstEmit32.Vzip, OpCode32SimdCmpZ.Create);
|
SetAsimd("111101001x00xxxxxxxx1000x011xxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101000x00xxxxxxxx0111xx0xxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1.
|
||||||
|
SetAsimd("111101000x00xxxxxxxx1010xx<<xxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 2.
|
||||||
|
SetAsimd("111101000x00xxxxxxxx0110xx0xxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 3.
|
||||||
|
SetAsimd("111101000x00xxxxxxxx0010xxxxxxxx", InstName.Vst1, InstEmit32.Vst1, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 4.
|
||||||
|
SetAsimd("111101001x00xxxxxxxx0x01xxxxxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101001x00xxxxxxxx1001xx0xxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101000x00xxxxxxxx100x<<0xxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1, inc = 1/2 (itype).
|
||||||
|
SetAsimd("111101000x00xxxxxxxx100x<<10xxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 1, inc = 1/2 (itype).
|
||||||
|
SetAsimd("111101000x00xxxxxxxx0011<<xxxxxx", InstName.Vst2, InstEmit32.Vst2, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Regs = 2, inc = 2.
|
||||||
|
SetAsimd("111101001x00xxxxxxxx0x10xxx0xxxx", InstName.Vst3, InstEmit32.Vst3, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101001x00xxxxxxxx1010xx00xxxx", InstName.Vst3, InstEmit32.Vst3, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101000x00xxxxxxxx010x<<0xxxxx", InstName.Vst3, InstEmit32.Vst3, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Inc = 1/2 (itype).
|
||||||
|
SetAsimd("111101001x00xxxxxxxx0x11xxxxxxxx", InstName.Vst4, InstEmit32.Vst4, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101001x00xxxxxxxx1011xx<<xxxx", InstName.Vst4, InstEmit32.Vst4, OpCode32SimdMemSingle.Create, OpCode32SimdMemSingle.CreateT32);
|
||||||
|
SetAsimd("111101000x00xxxxxxxx000x<<xxxxxx", InstName.Vst4, InstEmit32.Vst4, OpCode32SimdMemPair.Create, OpCode32SimdMemPair.CreateT32); // Inc = 1/2 (itype).
|
||||||
|
SetAsimd("111100110xxxxxxxxxxx1000xxx0xxxx", InstName.Vsub, InstEmit32.Vsub_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
|
SetAsimd("111100100x10xxxxxxxx1101xxx0xxxx", InstName.Vsub, InstEmit32.Vsub_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
|
SetAsimd("1111001x1x<<xxxxxxx00010x0x0xxxx", InstName.Vsubl, InstEmit32.Vsubl_I, OpCode32SimdRegLong.Create, OpCode32SimdRegLong.CreateT32);
|
||||||
|
SetAsimd("1111001x1x<<xxxxxxx00011x0x0xxxx", InstName.Vsubw, InstEmit32.Vsubw_I, OpCode32SimdRegWide.Create, OpCode32SimdRegWide.CreateT32);
|
||||||
|
SetAsimd("111100111x11xxxxxxxx10xxxxx0xxxx", InstName.Vtbl, InstEmit32.Vtbl, OpCode32SimdTbl.Create, OpCode32SimdTbl.CreateT32);
|
||||||
|
SetAsimd("111100111x11<<10xxxx00001xx0xxxx", InstName.Vtrn, InstEmit32.Vtrn, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
|
SetAsimd("111100100x<<xxxxxxxx1000xxx1xxxx", InstName.Vtst, InstEmit32.Vtst, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||||
|
SetAsimd("111100111x11<<10xxxx00010xx0xxxx", InstName.Vuzp, InstEmit32.Vuzp, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
|
SetAsimd("111100111x11<<10xxxx00011xx0xxxx", InstName.Vzip, InstEmit32.Vzip, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region "OpCode Table (AArch32, T16)"
|
#region "OpCode Table (AArch32, T16)"
|
||||||
@@ -1056,7 +1107,14 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT16("1011101011xxxxxx", InstName.Revsh, InstEmit32.Revsh, OpCodeT16AluRegLow.Create);
|
SetT16("1011101011xxxxxx", InstName.Revsh, InstEmit32.Revsh, OpCodeT16AluRegLow.Create);
|
||||||
SetT16("101110x1xxxxxxxx", InstName.Cbnz, InstEmit32.Cbnz, OpCodeT16BImmCmp.Create);
|
SetT16("101110x1xxxxxxxx", InstName.Cbnz, InstEmit32.Cbnz, OpCodeT16BImmCmp.Create);
|
||||||
SetT16("1011110xxxxxxxxx", InstName.Pop, InstEmit32.Ldm, OpCodeT16MemStack.Create);
|
SetT16("1011110xxxxxxxxx", InstName.Pop, InstEmit32.Ldm, OpCodeT16MemStack.Create);
|
||||||
SetT16("10111111xxxx0000", InstName.Nop, InstEmit32.Nop, OpCodeT16.Create);
|
SetT16("1011111100000000", InstName.Nop, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("1011111100010000", InstName.Yield, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("1011111100100000", InstName.Wfe, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("1011111100110000", InstName.Wfi, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("1011111101000000", InstName.Sev, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("1011111101010000", InstName.Sevl, InstEmit32.Nop, OpCodeT16.Create);
|
||||||
|
SetT16("10111111011x0000", InstName.Hint, InstEmit32.Nop, OpCodeT16.Create); // Hint instruction
|
||||||
|
SetT16("101111111xxx0000", InstName.Hint, InstEmit32.Nop, OpCodeT16.Create); // Hint instruction
|
||||||
SetT16("10111111xxxx>>>>", InstName.It, InstEmit32.It, OpCodeT16IfThen.Create);
|
SetT16("10111111xxxx>>>>", InstName.It, InstEmit32.It, OpCodeT16IfThen.Create);
|
||||||
SetT16("11000xxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT16MemMult.Create);
|
SetT16("11000xxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT16MemMult.Create);
|
||||||
SetT16("11001xxxxxxxxxxx", InstName.Ldm, InstEmit32.Ldm, OpCodeT16MemMult.Create);
|
SetT16("11001xxxxxxxxxxx", InstName.Ldm, InstEmit32.Ldm, OpCodeT16MemMult.Create);
|
||||||
@@ -1087,8 +1145,20 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("11110x010001xxxx0xxx1111xxxxxxxx", InstName.Cmn, InstEmit32.Cmn, OpCodeT32AluImm.Create);
|
SetT32("11110x010001xxxx0xxx1111xxxxxxxx", InstName.Cmn, InstEmit32.Cmn, OpCodeT32AluImm.Create);
|
||||||
SetT32("111010111011xxxx0xxx1111xxxxxxxx", InstName.Cmp, InstEmit32.Cmp, OpCodeT32AluRsImm.Create);
|
SetT32("111010111011xxxx0xxx1111xxxxxxxx", InstName.Cmp, InstEmit32.Cmp, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x011011xxxx0xxx1111xxxxxxxx", InstName.Cmp, InstEmit32.Cmp, OpCodeT32AluImm.Create);
|
SetT32("11110x011011xxxx0xxx1111xxxxxxxx", InstName.Cmp, InstEmit32.Cmp, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("11110011101011111000000000010100", InstName.Csdb, InstEmit32.Csdb, OpCodeT32.Create);
|
||||||
SetT32("11101010100<xxxx0xxx<<<<xxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCodeT32AluRsImm.Create);
|
SetT32("11101010100<xxxx0xxx<<<<xxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x00100<xxxx0xxx<<<<xxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCodeT32AluImm.Create);
|
SetT32("11110x00100<xxxx0xxx<<<<xxxxxxxx", InstName.Eor, InstEmit32.Eor, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("11110011101011111000000000010000", InstName.Esb, InstEmit32.Nop, OpCodeT32.Create); // Error Synchronization Barrier (FEAT_RAS)
|
||||||
|
SetT32("1111001110101111100000000000011x", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000000001xxx", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000000010001", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000000010011", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000000010101", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("1111001110101111100000000001011x", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000000011xxx", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("111100111010111110000000001xxxxx", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("11110011101011111000000001xxxxxx", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
|
SetT32("1111001110101111100000001xxxxxxx", InstName.Hint, InstEmit32.Nop, OpCodeT32.Create); // Reserved Hint
|
||||||
SetT32("111010001101xxxxxxxx111110101111", InstName.Lda, InstEmit32.Lda, OpCodeT32MemLdEx.Create);
|
SetT32("111010001101xxxxxxxx111110101111", InstName.Lda, InstEmit32.Lda, OpCodeT32MemLdEx.Create);
|
||||||
SetT32("111010001101xxxxxxxx111110001111", InstName.Ldab, InstEmit32.Ldab, OpCodeT32MemLdEx.Create);
|
SetT32("111010001101xxxxxxxx111110001111", InstName.Ldab, InstEmit32.Ldab, OpCodeT32MemLdEx.Create);
|
||||||
SetT32("111010001101xxxxxxxx111111101111", InstName.Ldaex, InstEmit32.Ldaex, OpCodeT32MemLdEx.Create);
|
SetT32("111010001101xxxxxxxx111111101111", InstName.Ldaex, InstEmit32.Ldaex, OpCodeT32MemLdEx.Create);
|
||||||
@@ -1104,26 +1174,26 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("111110001101xxxxxxxxxxxxxxxxxxxx", InstName.Ldr, InstEmit32.Ldr, OpCodeT32MemImm12.Create);
|
SetT32("111110001101xxxxxxxxxxxxxxxxxxxx", InstName.Ldr, InstEmit32.Ldr, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000101<<<<xxxx000000xxxxxx", InstName.Ldr, InstEmit32.Ldr, OpCodeT32MemRsImm.Create);
|
SetT32("111110000101<<<<xxxx000000xxxxxx", InstName.Ldr, InstEmit32.Ldr, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("111110000001xxxxxxxx10x1xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
SetT32("111110000001xxxxxxxx10x1xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110000001xxxxxxxx1100xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
SetT32("111110000001xxxx<<<<1100xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110000001xxxxxxxx11x1xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
SetT32("111110000001xxxxxxxx11x1xxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110001001xxxxxxxxxxxxxxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm12.Create);
|
SetT32("111110001001xxxx<<<<xxxxxxxxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000001xxxx<<<<000000xxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemRsImm.Create);
|
SetT32("111110000001xxxx<<<<000000xxxxxx", InstName.Ldrb, InstEmit32.Ldrb, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("11101000x111<<<<xxxxxxxxxxxxxxxx", InstName.Ldrd, InstEmit32.Ldrd, OpCodeT32MemImm8D.Create);
|
SetT32("11101000x111<<<<xxxxxxxxxxxxxxxx", InstName.Ldrd, InstEmit32.Ldrd, OpCodeT32MemImm8D.Create);
|
||||||
SetT32("11101001x1x1<<<<xxxxxxxxxxxxxxxx", InstName.Ldrd, InstEmit32.Ldrd, OpCodeT32MemImm8D.Create);
|
SetT32("11101001x1x1<<<<xxxxxxxxxxxxxxxx", InstName.Ldrd, InstEmit32.Ldrd, OpCodeT32MemImm8D.Create);
|
||||||
SetT32("111110000011xxxxxxxx10x1xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
SetT32("111110000011xxxxxxxx10x1xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110000011xxxxxxxx1100xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
SetT32("111110000011xxxx<<<<1100xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110000011xxxxxxxx11x1xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
SetT32("111110000011xxxxxxxx11x1xxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110001011xxxxxxxxxxxxxxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm12.Create);
|
SetT32("111110001011xxxx<<<<xxxxxxxxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000011xxxx<<<<000000xxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemRsImm.Create);
|
SetT32("111110000011xxxx<<<<000000xxxxxx", InstName.Ldrh, InstEmit32.Ldrh, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("111110010001xxxxxxxx10x1xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
SetT32("111110010001xxxxxxxx10x1xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110010001xxxxxxxx1100xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
SetT32("111110010001xxxx<<<<1100xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110010001xxxxxxxx11x1xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
SetT32("111110010001xxxxxxxx11x1xxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110011001xxxxxxxxxxxxxxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm12.Create);
|
SetT32("111110011001xxxx<<<<xxxxxxxxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110010001xxxx<<<<000000xxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemRsImm.Create);
|
SetT32("111110010001xxxx<<<<000000xxxxxx", InstName.Ldrsb, InstEmit32.Ldrsb, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("111110010011xxxxxxxx10x1xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
SetT32("111110010011xxxxxxxx10x1xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110010011xxxxxxxx1100xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
SetT32("111110010011xxxx<<<<1100xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110010011xxxxxxxx11x1xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
SetT32("111110010011xxxxxxxx11x1xxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110011011xxxxxxxxxxxxxxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm12.Create);
|
SetT32("111110011011xxxx<<<<xxxxxxxxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110010011xxxx<<<<000000xxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemRsImm.Create);
|
SetT32("111110010011xxxx<<<<000000xxxxxx", InstName.Ldrsh, InstEmit32.Ldrsh, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("111110110000xxxx<<<<xxxx0000xxxx", InstName.Mla, InstEmit32.Mla, OpCodeT32AluMla.Create);
|
SetT32("111110110000xxxx<<<<xxxx0000xxxx", InstName.Mla, InstEmit32.Mla, OpCodeT32AluMla.Create);
|
||||||
SetT32("111110110000xxxxxxxxxxxx0001xxxx", InstName.Mls, InstEmit32.Mls, OpCodeT32AluMla.Create);
|
SetT32("111110110000xxxxxxxxxxxx0001xxxx", InstName.Mls, InstEmit32.Mls, OpCodeT32AluMla.Create);
|
||||||
@@ -1140,12 +1210,21 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("11110x00011x<<<<0xxxxxxxxxxxxxxx", InstName.Orn, InstEmit32.Orn, OpCodeT32AluImm.Create);
|
SetT32("11110x00011x<<<<0xxxxxxxxxxxxxxx", InstName.Orn, InstEmit32.Orn, OpCodeT32AluImm.Create);
|
||||||
SetT32("11101010010x<<<<0xxxxxxxxxxxxxxx", InstName.Orr, InstEmit32.Orr, OpCodeT32AluRsImm.Create);
|
SetT32("11101010010x<<<<0xxxxxxxxxxxxxxx", InstName.Orr, InstEmit32.Orr, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x00010x<<<<0xxxxxxxxxxxxxxx", InstName.Orr, InstEmit32.Orr, OpCodeT32AluImm.Create);
|
SetT32("11110x00010x<<<<0xxxxxxxxxxxxxxx", InstName.Orr, InstEmit32.Orr, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("1111100010x1xxxx1111xxxxxxxxxxxx", InstName.Pld, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
|
SetT32("1111100000x1xxxx11111100xxxxxxxx", InstName.Pld, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
|
SetT32("1111100000x1xxxx1111000000xxxxxx", InstName.Pld, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
SetT32("11101011110xxxxx0xxxxxxxxxxxxxxx", InstName.Rsb, InstEmit32.Rsb, OpCodeT32AluRsImm.Create);
|
SetT32("11101011110xxxxx0xxxxxxxxxxxxxxx", InstName.Rsb, InstEmit32.Rsb, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x01110xxxxx0xxxxxxxxxxxxxxx", InstName.Rsb, InstEmit32.Rsb, OpCodeT32AluImm.Create);
|
SetT32("11110x01110xxxxx0xxxxxxxxxxxxxxx", InstName.Rsb, InstEmit32.Rsb, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("111110101000xxxx1111xxxx0000xxxx", InstName.Sadd8, InstEmit32.Sadd8, OpCodeT32AluReg.Create);
|
||||||
SetT32("11101011011xxxxx0xxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCodeT32AluRsImm.Create);
|
SetT32("11101011011xxxxx0xxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x01011xxxxx0xxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCodeT32AluImm.Create);
|
SetT32("11110x01011xxxxx0xxxxxxxxxxxxxxx", InstName.Sbc, InstEmit32.Sbc, OpCodeT32AluImm.Create);
|
||||||
SetT32("111100110100xxxx0xxxxxxxxx0xxxxx", InstName.Sbfx, InstEmit32.Sbfx, OpCodeT32AluBf.Create);
|
SetT32("111100110100xxxx0xxxxxxxxx0xxxxx", InstName.Sbfx, InstEmit32.Sbfx, OpCodeT32AluBf.Create);
|
||||||
SetT32("111110111001xxxx1111xxxx1111xxxx", InstName.Sdiv, InstEmit32.Sdiv, OpCodeT32AluMla.Create);
|
SetT32("111110111001xxxx1111xxxx1111xxxx", InstName.Sdiv, InstEmit32.Sdiv, OpCodeT32AluMla.Create);
|
||||||
|
SetT32("111110101010xxxx1111xxxx1000xxxx", InstName.Sel, InstEmit32.Sel, OpCodeT32AluReg.Create);
|
||||||
|
SetT32("111110101000xxxx1111xxxx0010xxxx", InstName.Shadd8, InstEmit32.Shadd8, OpCodeT32AluReg.Create);
|
||||||
|
SetT32("111110101100xxxx1111xxxx0010xxxx", InstName.Shsub8, InstEmit32.Shsub8, OpCodeT32AluReg.Create);
|
||||||
|
SetT32("11110011101011111000000000000100", InstName.Sev, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
|
SetT32("11110011101011111000000000000101", InstName.Sevl, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
SetT32("111110110001xxxx<<<<xxxx00xxxxxx", InstName.Smla__, InstEmit32.Smla__, OpCodeT32AluMla.Create);
|
SetT32("111110110001xxxx<<<<xxxx00xxxxxx", InstName.Smla__, InstEmit32.Smla__, OpCodeT32AluMla.Create);
|
||||||
SetT32("111110111100xxxxxxxxxxxx0000xxxx", InstName.Smlal, InstEmit32.Smlal, OpCodeT32AluUmull.Create);
|
SetT32("111110111100xxxxxxxxxxxx0000xxxx", InstName.Smlal, InstEmit32.Smlal, OpCodeT32AluUmull.Create);
|
||||||
SetT32("111110111100xxxxxxxxxxxx10xxxxxx", InstName.Smlal__, InstEmit32.Smlal__, OpCodeT32AluUmull.Create);
|
SetT32("111110111100xxxxxxxxxxxx10xxxxxx", InstName.Smlal__, InstEmit32.Smlal__, OpCodeT32AluUmull.Create);
|
||||||
@@ -1155,6 +1234,7 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("111110110001xxxx1111xxxx00xxxxxx", InstName.Smul__, InstEmit32.Smul__, OpCodeT32AluMla.Create);
|
SetT32("111110110001xxxx1111xxxx00xxxxxx", InstName.Smul__, InstEmit32.Smul__, OpCodeT32AluMla.Create);
|
||||||
SetT32("111110111000xxxxxxxxxxxx0000xxxx", InstName.Smull, InstEmit32.Smull, OpCodeT32AluUmull.Create);
|
SetT32("111110111000xxxxxxxxxxxx0000xxxx", InstName.Smull, InstEmit32.Smull, OpCodeT32AluUmull.Create);
|
||||||
SetT32("111110110011xxxx1111xxxx000xxxxx", InstName.Smulw_, InstEmit32.Smulw_, OpCodeT32AluMla.Create);
|
SetT32("111110110011xxxx1111xxxx000xxxxx", InstName.Smulw_, InstEmit32.Smulw_, OpCodeT32AluMla.Create);
|
||||||
|
SetT32("111110101100xxxx1111xxxx0000xxxx", InstName.Ssub8, InstEmit32.Ssub8, OpCodeT32AluReg.Create);
|
||||||
SetT32("111010001100xxxxxxxx111110101111", InstName.Stl, InstEmit32.Stl, OpCodeT32MemStEx.Create);
|
SetT32("111010001100xxxxxxxx111110101111", InstName.Stl, InstEmit32.Stl, OpCodeT32MemStEx.Create);
|
||||||
SetT32("111010001100xxxxxxxx111110001111", InstName.Stlb, InstEmit32.Stlb, OpCodeT32MemStEx.Create);
|
SetT32("111010001100xxxxxxxx111110001111", InstName.Stlb, InstEmit32.Stlb, OpCodeT32MemStEx.Create);
|
||||||
SetT32("111010001100xxxxxxxx11111110xxxx", InstName.Stlex, InstEmit32.Stlex, OpCodeT32MemStEx.Create);
|
SetT32("111010001100xxxxxxxx11111110xxxx", InstName.Stlex, InstEmit32.Stlex, OpCodeT32MemStEx.Create);
|
||||||
@@ -1164,19 +1244,26 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("111010001100xxxxxxxx111110011111", InstName.Stlh, InstEmit32.Stlh, OpCodeT32MemStEx.Create);
|
SetT32("111010001100xxxxxxxx111110011111", InstName.Stlh, InstEmit32.Stlh, OpCodeT32MemStEx.Create);
|
||||||
SetT32("1110100010x0xxxx0xxxxxxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT32MemMult.Create);
|
SetT32("1110100010x0xxxx0xxxxxxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT32MemMult.Create);
|
||||||
SetT32("1110100100x0xxxx0xxxxxxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT32MemMult.Create);
|
SetT32("1110100100x0xxxx0xxxxxxxxxxxxxxx", InstName.Stm, InstEmit32.Stm, OpCodeT32MemMult.Create);
|
||||||
SetT32("111110000100xxxxxxxx1<<>xxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm8.Create);
|
SetT32("111110000100<<<<xxxx10x1xxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110001100xxxxxxxxxxxxxxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm12.Create);
|
SetT32("111110000100<<<<xxxx1100xxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110000100<<<<xxxx11x1xxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110001100<<<<xxxxxxxxxxxxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000100<<<<xxxx000000xxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemRsImm.Create);
|
SetT32("111110000100<<<<xxxx000000xxxxxx", InstName.Str, InstEmit32.Str, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("111110000000xxxxxxxx1<<>xxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm8.Create);
|
SetT32("111110000000<<<<xxxx10x1xxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110001000xxxxxxxxxxxxxxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm12.Create);
|
SetT32("111110000000<<<<xxxx1100xxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110000000<<<<xxxx11x1xxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110001000<<<<xxxxxxxxxxxxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000000<<<<xxxx000000xxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemRsImm.Create);
|
SetT32("111110000000<<<<xxxx000000xxxxxx", InstName.Strb, InstEmit32.Strb, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("11101000x110<<<<xxxxxxxxxxxxxxxx", InstName.Strd, InstEmit32.Strd, OpCodeT32MemImm8D.Create);
|
SetT32("11101000x110<<<<xxxxxxxxxxxxxxxx", InstName.Strd, InstEmit32.Strd, OpCodeT32MemImm8D.Create);
|
||||||
SetT32("11101001x1x0<<<<xxxxxxxxxxxxxxxx", InstName.Strd, InstEmit32.Strd, OpCodeT32MemImm8D.Create);
|
SetT32("11101001x1x0<<<<xxxxxxxxxxxxxxxx", InstName.Strd, InstEmit32.Strd, OpCodeT32MemImm8D.Create);
|
||||||
SetT32("111110000010xxxxxxxx1<<>xxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm8.Create);
|
SetT32("111110000010<<<<xxxx10x1xxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm8.Create);
|
||||||
SetT32("111110001010xxxxxxxxxxxxxxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm12.Create);
|
SetT32("111110000010<<<<xxxx1100xxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110000010<<<<xxxx11x1xxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm8.Create);
|
||||||
|
SetT32("111110001010<<<<xxxxxxxxxxxxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemImm12.Create);
|
||||||
SetT32("111110000010<<<<xxxx000000xxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemRsImm.Create);
|
SetT32("111110000010<<<<xxxx000000xxxxxx", InstName.Strh, InstEmit32.Strh, OpCodeT32MemRsImm.Create);
|
||||||
SetT32("11101011101<xxxx0xxx<<<<xxxxxxxx", InstName.Sub, InstEmit32.Sub, OpCodeT32AluRsImm.Create);
|
SetT32("11101011101<xxxx0xxx<<<<xxxxxxxx", InstName.Sub, InstEmit32.Sub, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x01101<xxxx0xxx<<<<xxxxxxxx", InstName.Sub, InstEmit32.Sub, OpCodeT32AluImm.Create);
|
SetT32("11110x01101<xxxx0xxx<<<<xxxxxxxx", InstName.Sub, InstEmit32.Sub, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("11110x101010xxxx0xxxxxxxxxxxxxxx", InstName.Sub, InstEmit32.Sub, OpCodeT32AluImm12.Create);
|
||||||
SetT32("111110100100xxxx1111xxxx10xxxxxx", InstName.Sxtb, InstEmit32.Sxtb, OpCodeT32AluUx.Create);
|
SetT32("111110100100xxxx1111xxxx10xxxxxx", InstName.Sxtb, InstEmit32.Sxtb, OpCodeT32AluUx.Create);
|
||||||
SetT32("111110100010xxxx1111xxxx10xxxxxx", InstName.Sxtb16, InstEmit32.Sxtb16, OpCodeT32AluUx.Create);
|
SetT32("111110100010xxxx1111xxxx10xxxxxx", InstName.Sxtb16, InstEmit32.Sxtb16, OpCodeT32AluUx.Create);
|
||||||
SetT32("111110100000xxxx1111xxxx10xxxxxx", InstName.Sxth, InstEmit32.Sxth, OpCodeT32AluUx.Create);
|
SetT32("111110100000xxxx1111xxxx10xxxxxx", InstName.Sxth, InstEmit32.Sxth, OpCodeT32AluUx.Create);
|
||||||
@@ -1184,16 +1271,24 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32("111010001101xxxx111100000001xxxx", InstName.Tbh, InstEmit32.Tbh, OpCodeT32Tb.Create);
|
SetT32("111010001101xxxx111100000001xxxx", InstName.Tbh, InstEmit32.Tbh, OpCodeT32Tb.Create);
|
||||||
SetT32("111010101001xxxx0xxx1111xxxxxxxx", InstName.Teq, InstEmit32.Teq, OpCodeT32AluRsImm.Create);
|
SetT32("111010101001xxxx0xxx1111xxxxxxxx", InstName.Teq, InstEmit32.Teq, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x001001xxxx0xxx1111xxxxxxxx", InstName.Teq, InstEmit32.Teq, OpCodeT32AluImm.Create);
|
SetT32("11110x001001xxxx0xxx1111xxxxxxxx", InstName.Teq, InstEmit32.Teq, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("11110011101011111000000000010010", InstName.Tsb, InstEmit32.Nop, OpCodeT32.Create); // Trace Synchronization Barrier (FEAT_TRF)
|
||||||
SetT32("111010100001xxxx0xxx1111xxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCodeT32AluRsImm.Create);
|
SetT32("111010100001xxxx0xxx1111xxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCodeT32AluRsImm.Create);
|
||||||
SetT32("11110x000001xxxx0xxx1111xxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCodeT32AluImm.Create);
|
SetT32("11110x000001xxxx0xxx1111xxxxxxxx", InstName.Tst, InstEmit32.Tst, OpCodeT32AluImm.Create);
|
||||||
|
SetT32("111110101000xxxx1111xxxx0100xxxx", InstName.Uadd8, InstEmit32.Uadd8, OpCodeT32AluReg.Create);
|
||||||
SetT32("111100111100xxxx0xxxxxxxxx0xxxxx", InstName.Ubfx, InstEmit32.Ubfx, OpCodeT32AluBf.Create);
|
SetT32("111100111100xxxx0xxxxxxxxx0xxxxx", InstName.Ubfx, InstEmit32.Ubfx, OpCodeT32AluBf.Create);
|
||||||
SetT32("111110111011xxxx1111xxxx1111xxxx", InstName.Udiv, InstEmit32.Udiv, OpCodeT32AluMla.Create);
|
SetT32("111110111011xxxx1111xxxx1111xxxx", InstName.Udiv, InstEmit32.Udiv, OpCodeT32AluMla.Create);
|
||||||
|
SetT32("111110101000xxxx1111xxxx0110xxxx", InstName.Uhadd8, InstEmit32.Uhadd8, OpCodeT32AluReg.Create);
|
||||||
|
SetT32("111110101100xxxx1111xxxx0110xxxx", InstName.Uhsub8, InstEmit32.Uhsub8, OpCodeT32AluReg.Create);
|
||||||
SetT32("111110111110xxxxxxxxxxxx0110xxxx", InstName.Umaal, InstEmit32.Umaal, OpCodeT32AluUmull.Create);
|
SetT32("111110111110xxxxxxxxxxxx0110xxxx", InstName.Umaal, InstEmit32.Umaal, OpCodeT32AluUmull.Create);
|
||||||
SetT32("111110111110xxxxxxxxxxxx0000xxxx", InstName.Umlal, InstEmit32.Umlal, OpCodeT32AluUmull.Create);
|
SetT32("111110111110xxxxxxxxxxxx0000xxxx", InstName.Umlal, InstEmit32.Umlal, OpCodeT32AluUmull.Create);
|
||||||
SetT32("111110111010xxxxxxxxxxxx0000xxxx", InstName.Umull, InstEmit32.Umull, OpCodeT32AluUmull.Create);
|
SetT32("111110111010xxxxxxxxxxxx0000xxxx", InstName.Umull, InstEmit32.Umull, OpCodeT32AluUmull.Create);
|
||||||
|
SetT32("111110101100xxxx1111xxxx0100xxxx", InstName.Usub8, InstEmit32.Usub8, OpCodeT32AluReg.Create);
|
||||||
SetT32("111110100101xxxx1111xxxx10xxxxxx", InstName.Uxtb, InstEmit32.Uxtb, OpCodeT32AluUx.Create);
|
SetT32("111110100101xxxx1111xxxx10xxxxxx", InstName.Uxtb, InstEmit32.Uxtb, OpCodeT32AluUx.Create);
|
||||||
SetT32("111110100011xxxx1111xxxx10xxxxxx", InstName.Uxtb16, InstEmit32.Uxtb16, OpCodeT32AluUx.Create);
|
SetT32("111110100011xxxx1111xxxx10xxxxxx", InstName.Uxtb16, InstEmit32.Uxtb16, OpCodeT32AluUx.Create);
|
||||||
SetT32("111110100001xxxx1111xxxx10xxxxxx", InstName.Uxth, InstEmit32.Uxth, OpCodeT32AluUx.Create);
|
SetT32("111110100001xxxx1111xxxx10xxxxxx", InstName.Uxth, InstEmit32.Uxth, OpCodeT32AluUx.Create);
|
||||||
|
SetT32("11110011101011111000000000000010", InstName.Wfe, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
|
SetT32("11110011101011111000000000000011", InstName.Wfi, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
|
SetT32("11110011101011111000000000000001", InstName.Yield, InstEmit32.Nop, OpCodeT32.Create);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
FillFastLookupTable(InstA32FastLookup, AllInstA32, ToFastLookupIndexA);
|
FillFastLookupTable(InstA32FastLookup, AllInstA32, ToFastLookupIndexA);
|
||||||
@@ -1262,6 +1357,34 @@ namespace ARMeilleure.Decoders
|
|||||||
SetT32(thumbEncoding, name, emitter, makeOpT32);
|
SetT32(thumbEncoding, name, emitter, makeOpT32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SetAsimd(string encoding, InstName name, InstEmitter emitter, MakeOp makeOpA32, MakeOp makeOpT32)
|
||||||
|
{
|
||||||
|
SetA32(encoding, name, emitter, makeOpA32);
|
||||||
|
|
||||||
|
string thumbEncoding = encoding;
|
||||||
|
if (thumbEncoding.StartsWith("11110100"))
|
||||||
|
{
|
||||||
|
thumbEncoding = "11111001" + encoding.Substring(8);
|
||||||
|
}
|
||||||
|
else if (thumbEncoding.StartsWith("1111001x"))
|
||||||
|
{
|
||||||
|
thumbEncoding = "111x1111" + encoding.Substring(8);
|
||||||
|
}
|
||||||
|
else if (thumbEncoding.StartsWith("11110010"))
|
||||||
|
{
|
||||||
|
thumbEncoding = "11101111" + encoding.Substring(8);
|
||||||
|
}
|
||||||
|
else if (thumbEncoding.StartsWith("11110011"))
|
||||||
|
{
|
||||||
|
thumbEncoding = "11111111" + encoding.Substring(8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Invalid ASIMD instruction encoding");
|
||||||
|
}
|
||||||
|
SetT32(thumbEncoding, name, emitter, makeOpT32);
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetA64(string encoding, InstName name, InstEmitter emitter, MakeOp makeOp)
|
private static void SetA64(string encoding, InstName name, InstEmitter emitter, MakeOp makeOp)
|
||||||
{
|
{
|
||||||
Set(encoding, AllInstA64, new InstDescriptor(name, emitter), makeOp);
|
Set(encoding, AllInstA64, new InstDescriptor(name, emitter), makeOp);
|
||||||
|
@@ -363,6 +363,11 @@ namespace ARMeilleure.Instructions
|
|||||||
EmitAluStore(context, res);
|
EmitAluStore(context, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Sadd8(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
EmitAddSub8(context, add: true, unsigned: false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Sbc(ArmEmitterContext context)
|
public static void Sbc(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
IOpCode32Alu op = (IOpCode32Alu)context.CurrOp;
|
IOpCode32Alu op = (IOpCode32Alu)context.CurrOp;
|
||||||
@@ -401,17 +406,38 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Sdiv(ArmEmitterContext context)
|
public static void Sdiv(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitDiv(context, false);
|
EmitDiv(context, unsigned: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Sel(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
IOpCode32AluReg op = (IOpCode32AluReg)context.CurrOp;
|
||||||
|
|
||||||
|
Operand n = GetIntA32(context, op.Rn);
|
||||||
|
Operand m = GetIntA32(context, op.Rm);
|
||||||
|
|
||||||
|
Operand ge0 = context.ZeroExtend8(OperandType.I32, context.Negate(GetFlag(PState.GE0Flag)));
|
||||||
|
Operand ge1 = context.ZeroExtend8(OperandType.I32, context.Negate(GetFlag(PState.GE1Flag)));
|
||||||
|
Operand ge2 = context.ZeroExtend8(OperandType.I32, context.Negate(GetFlag(PState.GE2Flag)));
|
||||||
|
Operand ge3 = context.Negate(GetFlag(PState.GE3Flag));
|
||||||
|
|
||||||
|
Operand mask = context.BitwiseOr(ge0, context.ShiftLeft(ge1, Const(8)));
|
||||||
|
mask = context.BitwiseOr(mask, context.ShiftLeft(ge2, Const(16)));
|
||||||
|
mask = context.BitwiseOr(mask, context.ShiftLeft(ge3, Const(24)));
|
||||||
|
|
||||||
|
Operand res = context.BitwiseOr(context.BitwiseAnd(n, mask), context.BitwiseAnd(m, context.BitwiseNot(mask)));
|
||||||
|
|
||||||
|
SetIntA32(context, op.Rd, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Shadd8(ArmEmitterContext context)
|
public static void Shadd8(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitHadd8(context, false);
|
EmitHadd8(context, unsigned: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Shsub8(ArmEmitterContext context)
|
public static void Shsub8(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitHsub8(context, false);
|
EmitHsub8(context, unsigned: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Ssat(ArmEmitterContext context)
|
public static void Ssat(ArmEmitterContext context)
|
||||||
@@ -428,6 +454,11 @@ namespace ARMeilleure.Instructions
|
|||||||
EmitSat16(context, -(1 << op.SatImm), (1 << op.SatImm) - 1);
|
EmitSat16(context, -(1 << op.SatImm), (1 << op.SatImm) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Ssub8(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
EmitAddSub8(context, add: false, unsigned: false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Sub(ArmEmitterContext context)
|
public static void Sub(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
IOpCode32Alu op = (IOpCode32Alu)context.CurrOp;
|
IOpCode32Alu op = (IOpCode32Alu)context.CurrOp;
|
||||||
@@ -482,6 +513,11 @@ namespace ARMeilleure.Instructions
|
|||||||
EmitNZFlagsCheck(context, res);
|
EmitNZFlagsCheck(context, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Uadd8(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
EmitAddSub8(context, add: true, unsigned: true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Ubfx(ArmEmitterContext context)
|
public static void Ubfx(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
IOpCode32AluBf op = (IOpCode32AluBf)context.CurrOp;
|
IOpCode32AluBf op = (IOpCode32AluBf)context.CurrOp;
|
||||||
@@ -496,17 +532,17 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Udiv(ArmEmitterContext context)
|
public static void Udiv(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitDiv(context, true);
|
EmitDiv(context, unsigned: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uhadd8(ArmEmitterContext context)
|
public static void Uhadd8(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitHadd8(context, true);
|
EmitHadd8(context, unsigned: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uhsub8(ArmEmitterContext context)
|
public static void Uhsub8(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitHsub8(context, true);
|
EmitHsub8(context, unsigned: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Usat(ArmEmitterContext context)
|
public static void Usat(ArmEmitterContext context)
|
||||||
@@ -523,6 +559,11 @@ namespace ARMeilleure.Instructions
|
|||||||
EmitSat16(context, 0, (1 << op.SatImm) - 1);
|
EmitSat16(context, 0, (1 << op.SatImm) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Usub8(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
EmitAddSub8(context, add: false, unsigned: true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Uxtb(ArmEmitterContext context)
|
public static void Uxtb(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitSignExtend(context, false, 8);
|
EmitSignExtend(context, false, 8);
|
||||||
@@ -678,9 +719,40 @@ namespace ARMeilleure.Instructions
|
|||||||
context.MarkLabel(lblEnd);
|
context.MarkLabel(lblEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void EmitAddSub8(ArmEmitterContext context, bool add, bool unsigned)
|
||||||
|
{
|
||||||
|
IOpCode32AluReg op = (IOpCode32AluReg)context.CurrOp;
|
||||||
|
|
||||||
|
Operand n = GetIntA32(context, op.Rn);
|
||||||
|
Operand m = GetIntA32(context, op.Rm);
|
||||||
|
|
||||||
|
Operand res = Const(0);
|
||||||
|
|
||||||
|
for (int byteSel = 0; byteSel < 4; byteSel++)
|
||||||
|
{
|
||||||
|
Operand shift = Const(byteSel * 8);
|
||||||
|
|
||||||
|
Operand nByte = context.ShiftRightUI(n, shift);
|
||||||
|
Operand mByte = context.ShiftRightUI(m, shift);
|
||||||
|
|
||||||
|
nByte = unsigned ? context.ZeroExtend8(OperandType.I32, nByte) : context.SignExtend8(OperandType.I32, nByte);
|
||||||
|
mByte = unsigned ? context.ZeroExtend8(OperandType.I32, mByte) : context.SignExtend8(OperandType.I32, mByte);
|
||||||
|
|
||||||
|
Operand resByte = add ? context.Add(nByte, mByte) : context.Subtract(nByte, mByte);
|
||||||
|
|
||||||
|
res = context.BitwiseOr(res, context.ShiftLeft(context.ZeroExtend8(OperandType.I32, resByte), shift));
|
||||||
|
|
||||||
|
SetFlag(context, PState.GE0Flag + byteSel, unsigned && add
|
||||||
|
? context.ShiftRightUI(resByte, Const(8))
|
||||||
|
: context.ShiftRightUI(context.BitwiseNot(resByte), Const(31)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetIntA32(context, op.Rd, res);
|
||||||
|
}
|
||||||
|
|
||||||
private static void EmitHadd8(ArmEmitterContext context, bool unsigned)
|
private static void EmitHadd8(ArmEmitterContext context, bool unsigned)
|
||||||
{
|
{
|
||||||
OpCode32AluReg op = (OpCode32AluReg)context.CurrOp;
|
IOpCode32AluReg op = (IOpCode32AluReg)context.CurrOp;
|
||||||
|
|
||||||
Operand m = GetIntA32(context, op.Rm);
|
Operand m = GetIntA32(context, op.Rm);
|
||||||
Operand n = GetIntA32(context, op.Rn);
|
Operand n = GetIntA32(context, op.Rn);
|
||||||
@@ -710,7 +782,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
private static void EmitHsub8(ArmEmitterContext context, bool unsigned)
|
private static void EmitHsub8(ArmEmitterContext context, bool unsigned)
|
||||||
{
|
{
|
||||||
OpCode32AluReg op = (OpCode32AluReg)context.CurrOp;
|
IOpCode32AluReg op = (IOpCode32AluReg)context.CurrOp;
|
||||||
|
|
||||||
Operand m = GetIntA32(context, op.Rm);
|
Operand m = GetIntA32(context, op.Rm);
|
||||||
Operand n = GetIntA32(context, op.Rn);
|
Operand n = GetIntA32(context, op.Rn);
|
||||||
|
@@ -26,6 +26,11 @@ namespace ARMeilleure.Instructions
|
|||||||
EmitClearExclusive(context);
|
EmitClearExclusive(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Csdb(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
// Execute as no-op.
|
||||||
|
}
|
||||||
|
|
||||||
public static void Dmb(ArmEmitterContext context) => EmitBarrier(context);
|
public static void Dmb(ArmEmitterContext context) => EmitBarrier(context);
|
||||||
public static void Dsb(ArmEmitterContext context) => EmitBarrier(context);
|
public static void Dsb(ArmEmitterContext context) => EmitBarrier(context);
|
||||||
|
|
||||||
|
@@ -323,6 +323,60 @@ namespace ARMeilleure.Instructions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VRINTA (vector).
|
||||||
|
public static void Vrinta_V(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpF32(context, (m) => EmitRoundMathCall(context, MidpointRounding.AwayFromZero, m));
|
||||||
|
}
|
||||||
|
|
||||||
|
// VRINTM (vector).
|
||||||
|
public static void Vrintm_V(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
if (Optimizations.UseSse2)
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpSimd32(context, (m) =>
|
||||||
|
{
|
||||||
|
return context.AddIntrinsic(Intrinsic.X86Roundps, m, Const(X86GetRoundControl(FPRoundingMode.TowardsMinusInfinity)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpF32(context, (m) => EmitUnaryMathCall(context, nameof(Math.Floor), m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// VRINTN (vector).
|
||||||
|
public static void Vrintn_V(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
if (Optimizations.UseSse2)
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpSimd32(context, (m) =>
|
||||||
|
{
|
||||||
|
return context.AddIntrinsic(Intrinsic.X86Roundps, m, Const(X86GetRoundControl(FPRoundingMode.ToNearest)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpF32(context, (m) => EmitRoundMathCall(context, MidpointRounding.ToEven, m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// VRINTP (vector).
|
||||||
|
public static void Vrintp_V(ArmEmitterContext context)
|
||||||
|
{
|
||||||
|
if (Optimizations.UseSse2)
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpSimd32(context, (m) =>
|
||||||
|
{
|
||||||
|
return context.AddIntrinsic(Intrinsic.X86Roundps, m, Const(X86GetRoundControl(FPRoundingMode.TowardsPlusInfinity)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EmitVectorUnaryOpF32(context, (m) => EmitUnaryMathCall(context, nameof(Math.Ceiling), m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// VRINTZ (floating-point).
|
// VRINTZ (floating-point).
|
||||||
public static void Vrint_Z(ArmEmitterContext context)
|
public static void Vrint_Z(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
|
@@ -1533,29 +1533,88 @@ namespace ARMeilleure.Instructions
|
|||||||
context.Copy(d, res);
|
context.Copy(d, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TSrc (16bit, 32bit, 64bit; signed) > TDst (8bit, 16bit, 32bit; signed, unsigned).
|
// long SignedSignSatQ(long op, int size);
|
||||||
// long SignedSrcSignedDstSatQ(long op, int size); ulong SignedSrcUnsignedDstSatQ(long op, int size);
|
public static Operand EmitSignedSignSatQ(ArmEmitterContext context, Operand op, int size)
|
||||||
public static Operand EmitSignedSrcSatQ(ArmEmitterContext context, Operand op, int sizeDst, bool signedDst)
|
|
||||||
{
|
{
|
||||||
Debug.Assert(op.Type == OperandType.I64 && (uint)sizeDst <= 2u);
|
int eSize = 8 << size;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||||
|
|
||||||
Operand lbl1 = Label();
|
Operand lbl1 = Label();
|
||||||
Operand lblEnd = Label();
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
int eSize = 8 << sizeDst;
|
Operand zeroL = Const(0L);
|
||||||
|
Operand maxT = Const((1L << (eSize - 1)) - 1L);
|
||||||
|
Operand minT = Const(-(1L << (eSize - 1)));
|
||||||
|
|
||||||
Operand maxT = signedDst ? Const((1L << (eSize - 1)) - 1L) : Const((1UL << eSize) - 1UL);
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), zeroL);
|
||||||
Operand minT = signedDst ? Const(-(1L << (eSize - 1))) : Const(0UL);
|
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
context.BranchIf(lbl1, op, zeroL, Comparison.LessOrEqual);
|
||||||
|
|
||||||
context.BranchIf(lbl1, res, maxT, Comparison.LessOrEqual);
|
|
||||||
context.Copy(res, maxT);
|
context.Copy(res, maxT);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
context.MarkLabel(lbl1);
|
context.MarkLabel(lbl1);
|
||||||
context.BranchIf(lblEnd, res, minT, Comparison.GreaterOrEqual);
|
context.BranchIf(lblEnd, op, zeroL, Comparison.GreaterOrEqual);
|
||||||
|
context.Copy(res, minT);
|
||||||
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private static ulong UnsignedSignSatQ(ulong op, int size);
|
||||||
|
public static Operand EmitUnsignedSignSatQ(ArmEmitterContext context, Operand op, int size)
|
||||||
|
{
|
||||||
|
int eSize = 8 << size;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||||
|
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand zeroUL = Const(0UL);
|
||||||
|
Operand maxT = Const(ulong.MaxValue >> (64 - eSize));
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), zeroUL);
|
||||||
|
|
||||||
|
context.BranchIf(lblEnd, op, zeroUL, Comparison.LessOrEqualUI);
|
||||||
|
context.Copy(res, maxT);
|
||||||
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TSrc (16bit, 32bit, 64bit; signed) > TDst (8bit, 16bit, 32bit; signed, unsigned).
|
||||||
|
// long SignedSrcSignedDstSatQ(long op, int size); ulong SignedSrcUnsignedDstSatQ(long op, int size);
|
||||||
|
public static Operand EmitSignedSrcSatQ(ArmEmitterContext context, Operand op, int sizeDst, bool signedDst)
|
||||||
|
{
|
||||||
|
int eSizeDst = 8 << sizeDst;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(eSizeDst == 8 || eSizeDst == 16 || eSizeDst == 32);
|
||||||
|
|
||||||
|
Operand lbl1 = Label();
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand maxT = signedDst ? Const((1L << (eSizeDst - 1)) - 1L) : Const((1UL << eSizeDst) - 1UL);
|
||||||
|
Operand minT = signedDst ? Const(-(1L << (eSizeDst - 1))) : Const(0UL);
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||||
|
|
||||||
|
context.BranchIf(lbl1, op, maxT, Comparison.LessOrEqual);
|
||||||
|
context.Copy(res, maxT);
|
||||||
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lbl1);
|
||||||
|
context.BranchIf(lblEnd, op, minT, Comparison.GreaterOrEqual);
|
||||||
context.Copy(res, minT);
|
context.Copy(res, minT);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1569,18 +1628,19 @@ namespace ARMeilleure.Instructions
|
|||||||
// long UnsignedSrcSignedDstSatQ(ulong op, int size); ulong UnsignedSrcUnsignedDstSatQ(ulong op, int size);
|
// long UnsignedSrcSignedDstSatQ(ulong op, int size); ulong UnsignedSrcUnsignedDstSatQ(ulong op, int size);
|
||||||
public static Operand EmitUnsignedSrcSatQ(ArmEmitterContext context, Operand op, int sizeDst, bool signedDst)
|
public static Operand EmitUnsignedSrcSatQ(ArmEmitterContext context, Operand op, int sizeDst, bool signedDst)
|
||||||
{
|
{
|
||||||
Debug.Assert(op.Type == OperandType.I64 && (uint)sizeDst <= 2u);
|
int eSizeDst = 8 << sizeDst;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(eSizeDst == 8 || eSizeDst == 16 || eSizeDst == 32);
|
||||||
|
|
||||||
Operand lblEnd = Label();
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
int eSize = 8 << sizeDst;
|
Operand maxT = signedDst ? Const((1L << (eSizeDst - 1)) - 1L) : Const((1UL << eSizeDst) - 1UL);
|
||||||
|
|
||||||
Operand maxL = signedDst ? Const((1L << (eSize - 1)) - 1L) : Const((1UL << eSize) - 1UL);
|
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||||
|
|
||||||
context.BranchIf(lblEnd, res, maxL, Comparison.LessOrEqualUI);
|
context.BranchIf(lblEnd, op, maxT, Comparison.LessOrEqualUI);
|
||||||
context.Copy(res, maxL);
|
context.Copy(res, maxT);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
@@ -1601,7 +1661,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||||
|
|
||||||
context.BranchIf(lblEnd, res, minL, Comparison.NotEqual);
|
context.BranchIf(lblEnd, op, minL, Comparison.NotEqual);
|
||||||
context.Copy(res, maxL);
|
context.Copy(res, maxL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1620,15 +1680,16 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand minL = Const(long.MinValue);
|
Operand minL = Const(long.MinValue);
|
||||||
Operand maxL = Const(long.MaxValue);
|
Operand maxL = Const(long.MaxValue);
|
||||||
Operand zero = Const(0L);
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Add(op1, op2));
|
Operand add = context.Add(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), add);
|
||||||
|
|
||||||
Operand left = context.BitwiseNot(context.BitwiseExclusiveOr(op1, op2));
|
Operand left = context.BitwiseNot(context.BitwiseExclusiveOr(op1, op2));
|
||||||
Operand right = context.BitwiseExclusiveOr(op1, res);
|
Operand right = context.BitwiseExclusiveOr(op1, add);
|
||||||
context.BranchIf(lblEnd, context.BitwiseAnd(left, right), zero, Comparison.GreaterOrEqual);
|
context.BranchIf(lblEnd, context.BitwiseAnd(left, right), zeroL, Comparison.GreaterOrEqual);
|
||||||
|
|
||||||
Operand isPositive = context.ICompareGreaterOrEqual(op1, zero);
|
Operand isPositive = context.ICompareGreaterOrEqual(op1, zeroL);
|
||||||
context.Copy(res, context.ConditionalSelect(isPositive, maxL, minL));
|
context.Copy(res, context.ConditionalSelect(isPositive, maxL, minL));
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1647,9 +1708,10 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand maxUL = Const(ulong.MaxValue);
|
Operand maxUL = Const(ulong.MaxValue);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Add(op1, op2));
|
Operand add = context.Add(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), add);
|
||||||
|
|
||||||
context.BranchIf(lblEnd, res, op1, Comparison.GreaterOrEqualUI);
|
context.BranchIf(lblEnd, add, op1, Comparison.GreaterOrEqualUI);
|
||||||
context.Copy(res, maxUL);
|
context.Copy(res, maxUL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1668,15 +1730,16 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand minL = Const(long.MinValue);
|
Operand minL = Const(long.MinValue);
|
||||||
Operand maxL = Const(long.MaxValue);
|
Operand maxL = Const(long.MaxValue);
|
||||||
Operand zero = Const(0L);
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Subtract(op1, op2));
|
Operand sub = context.Subtract(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), sub);
|
||||||
|
|
||||||
Operand left = context.BitwiseExclusiveOr(op1, op2);
|
Operand left = context.BitwiseExclusiveOr(op1, op2);
|
||||||
Operand right = context.BitwiseExclusiveOr(op1, res);
|
Operand right = context.BitwiseExclusiveOr(op1, sub);
|
||||||
context.BranchIf(lblEnd, context.BitwiseAnd(left, right), zero, Comparison.GreaterOrEqual);
|
context.BranchIf(lblEnd, context.BitwiseAnd(left, right), zeroL, Comparison.GreaterOrEqual);
|
||||||
|
|
||||||
Operand isPositive = context.ICompareGreaterOrEqual(op1, zero);
|
Operand isPositive = context.ICompareGreaterOrEqual(op1, zeroL);
|
||||||
context.Copy(res, context.ConditionalSelect(isPositive, maxL, minL));
|
context.Copy(res, context.ConditionalSelect(isPositive, maxL, minL));
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1693,12 +1756,13 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand lblEnd = Label();
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
Operand zero = Const(0L);
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Subtract(op1, op2));
|
Operand sub = context.Subtract(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), sub);
|
||||||
|
|
||||||
context.BranchIf(lblEnd, op1, op2, Comparison.GreaterOrEqualUI);
|
context.BranchIf(lblEnd, op1, op2, Comparison.GreaterOrEqualUI);
|
||||||
context.Copy(res, zero);
|
context.Copy(res, zeroL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
@@ -1717,25 +1781,26 @@ namespace ARMeilleure.Instructions
|
|||||||
Operand lblEnd = Label();
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
Operand maxL = Const(long.MaxValue);
|
Operand maxL = Const(long.MaxValue);
|
||||||
Operand zero = Const(0L);
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Add(op1, op2));
|
Operand add = context.Add(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), add);
|
||||||
|
|
||||||
context.BranchIf(lbl1, op1, maxL, Comparison.GreaterUI);
|
context.BranchIf(lbl1, op1, maxL, Comparison.GreaterUI);
|
||||||
Operand notOp2AndRes = context.BitwiseAnd(context.BitwiseNot(op2), res);
|
Operand notOp2AndRes = context.BitwiseAnd(context.BitwiseNot(op2), add);
|
||||||
context.BranchIf(lblEnd, notOp2AndRes, zero, Comparison.GreaterOrEqual);
|
context.BranchIf(lblEnd, notOp2AndRes, zeroL, Comparison.GreaterOrEqual);
|
||||||
context.Copy(res, maxL);
|
context.Copy(res, maxL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
context.MarkLabel(lbl1);
|
context.MarkLabel(lbl1);
|
||||||
context.BranchIf(lbl2, op2, zero, Comparison.Less);
|
context.BranchIf(lbl2, op2, zeroL, Comparison.Less);
|
||||||
context.Copy(res, maxL);
|
context.Copy(res, maxL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
context.MarkLabel(lbl2);
|
context.MarkLabel(lbl2);
|
||||||
context.BranchIf(lblEnd, res, maxL, Comparison.LessOrEqualUI);
|
context.BranchIf(lblEnd, add, maxL, Comparison.LessOrEqualUI);
|
||||||
context.Copy(res, maxL);
|
context.Copy(res, maxL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
@@ -1755,20 +1820,21 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
Operand maxUL = Const(ulong.MaxValue);
|
Operand maxUL = Const(ulong.MaxValue);
|
||||||
Operand maxL = Const(long.MaxValue);
|
Operand maxL = Const(long.MaxValue);
|
||||||
Operand zero = Const(0L);
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), context.Add(op1, op2));
|
Operand add = context.Add(op1, op2);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), add);
|
||||||
|
|
||||||
context.BranchIf(lbl1, op1, zero, Comparison.Less);
|
context.BranchIf(lbl1, op1, zeroL, Comparison.Less);
|
||||||
context.BranchIf(lblEnd, res, op1, Comparison.GreaterOrEqualUI);
|
context.BranchIf(lblEnd, add, op1, Comparison.GreaterOrEqualUI);
|
||||||
context.Copy(res, maxUL);
|
context.Copy(res, maxUL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
context.MarkLabel(lbl1);
|
context.MarkLabel(lbl1);
|
||||||
context.BranchIf(lblEnd, op2, maxL, Comparison.GreaterUI);
|
context.BranchIf(lblEnd, op2, maxL, Comparison.GreaterUI);
|
||||||
context.BranchIf(lblEnd, res, zero, Comparison.GreaterOrEqual);
|
context.BranchIf(lblEnd, add, zeroL, Comparison.GreaterOrEqual);
|
||||||
context.Copy(res, zero);
|
context.Copy(res, zeroL);
|
||||||
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpsrQc)));
|
||||||
context.Branch(lblEnd);
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
// Write an element from a double simd register.
|
// Accesses an element from a double simd register.
|
||||||
Operand address = context.Add(n, Const(offset));
|
Operand address = context.Add(n, Const(offset));
|
||||||
if (eBytes == 8)
|
if (eBytes == 8)
|
||||||
{
|
{
|
||||||
@@ -131,6 +131,7 @@ namespace ARMeilleure.Instructions
|
|||||||
{
|
{
|
||||||
OpCode32SimdMemPair op = (OpCode32SimdMemPair)context.CurrOp;
|
OpCode32SimdMemPair op = (OpCode32SimdMemPair)context.CurrOp;
|
||||||
|
|
||||||
|
int increment = count > 1 ? op.Increment : 1;
|
||||||
int eBytes = 1 << op.Size;
|
int eBytes = 1 << op.Size;
|
||||||
|
|
||||||
Operand n = context.Copy(GetIntA32(context, op.Rn));
|
Operand n = context.Copy(GetIntA32(context, op.Rn));
|
||||||
@@ -144,7 +145,7 @@ namespace ARMeilleure.Instructions
|
|||||||
int elemD = d + reg;
|
int elemD = d + reg;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
// Write an element from a double simd register
|
// Accesses an element from a double simd register,
|
||||||
// add ebytes for each element.
|
// add ebytes for each element.
|
||||||
Operand address = context.Add(n, Const(offset));
|
Operand address = context.Add(n, Const(offset));
|
||||||
int index = ((elemD & 1) << (3 - op.Size)) + elem;
|
int index = ((elemD & 1) << (3 - op.Size)) + elem;
|
||||||
@@ -161,7 +162,6 @@ namespace ARMeilleure.Instructions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (load)
|
if (load)
|
||||||
{
|
{
|
||||||
EmitLoadSimd(context, address, GetVecA32(elemD >> 1), elemD >> 1, index, op.Size);
|
EmitLoadSimd(context, address, GetVecA32(elemD >> 1), elemD >> 1, index, op.Size);
|
||||||
@@ -173,7 +173,7 @@ namespace ARMeilleure.Instructions
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset += eBytes;
|
offset += eBytes;
|
||||||
elemD += op.Increment;
|
elemD += increment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -188,23 +188,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Sqrshl_V(ArmEmitterContext context)
|
public static void Sqrshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Signed | ShlRegFlags.Round | ShlRegFlags.Saturating);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractSx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractSx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShlRegSatQ)), ne, me, Const(1), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Sqrshrn_S(ArmEmitterContext context)
|
public static void Sqrshrn_S(ArmEmitterContext context)
|
||||||
@@ -229,23 +213,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Sqshl_V(ArmEmitterContext context)
|
public static void Sqshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Signed | ShlRegFlags.Saturating);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractSx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractSx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShlRegSatQ)), ne, me, Const(0), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Sqshrn_S(ArmEmitterContext context)
|
public static void Sqshrn_S(ArmEmitterContext context)
|
||||||
@@ -280,23 +248,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Srshl_V(ArmEmitterContext context)
|
public static void Srshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Signed | ShlRegFlags.Round);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractSx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractSx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShlReg)), ne, me, Const(1), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Srshr_S(ArmEmitterContext context)
|
public static void Srshr_S(ArmEmitterContext context)
|
||||||
@@ -393,12 +345,12 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Sshl_S(ArmEmitterContext context)
|
public static void Sshl_S(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitSshlOrUshl(context, signed: true, scalar: true);
|
EmitShlRegOp(context, ShlRegFlags.Scalar | ShlRegFlags.Signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Sshl_V(ArmEmitterContext context)
|
public static void Sshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitSshlOrUshl(context, signed: true, scalar: false);
|
EmitShlRegOp(context, ShlRegFlags.Signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Sshll_V(ArmEmitterContext context)
|
public static void Sshll_V(ArmEmitterContext context)
|
||||||
@@ -506,23 +458,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Uqrshl_V(ArmEmitterContext context)
|
public static void Uqrshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Round | ShlRegFlags.Saturating);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractZx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractZx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShlRegSatQ)), ne, me, Const(1), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uqrshrn_S(ArmEmitterContext context)
|
public static void Uqrshrn_S(ArmEmitterContext context)
|
||||||
@@ -537,23 +473,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Uqshl_V(ArmEmitterContext context)
|
public static void Uqshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Saturating);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractZx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractZx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShlRegSatQ)), ne, me, Const(0), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uqshrn_S(ArmEmitterContext context)
|
public static void Uqshrn_S(ArmEmitterContext context)
|
||||||
@@ -568,23 +488,7 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Urshl_V(ArmEmitterContext context)
|
public static void Urshl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
EmitShlRegOp(context, ShlRegFlags.Round);
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
|
||||||
|
|
||||||
int elems = op.GetBytesCount() >> op.Size;
|
|
||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
|
||||||
{
|
|
||||||
Operand ne = EmitVectorExtractZx(context, op.Rn, index, op.Size);
|
|
||||||
Operand me = EmitVectorExtractZx(context, op.Rm, index, op.Size);
|
|
||||||
|
|
||||||
Operand e = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShlReg)), ne, me, Const(1), Const(op.Size));
|
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Urshr_S(ArmEmitterContext context)
|
public static void Urshr_S(ArmEmitterContext context)
|
||||||
@@ -677,12 +581,12 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
public static void Ushl_S(ArmEmitterContext context)
|
public static void Ushl_S(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitSshlOrUshl(context, signed: false, scalar: true);
|
EmitShlRegOp(context, ShlRegFlags.Scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Ushl_V(ArmEmitterContext context)
|
public static void Ushl_V(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
EmitSshlOrUshl(context, signed: false, scalar: false);
|
EmitShlRegOp(context, ShlRegFlags.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Ushll_V(ArmEmitterContext context)
|
public static void Ushll_V(ArmEmitterContext context)
|
||||||
@@ -872,43 +776,6 @@ namespace ARMeilleure.Instructions
|
|||||||
context.Copy(GetVec(op.Rd), res);
|
context.Copy(GetVec(op.Rd), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Operand EmitShlRegOp(ArmEmitterContext context, Operand op, Operand shiftLsB, int size, bool signed)
|
|
||||||
{
|
|
||||||
Debug.Assert(op.Type == OperandType.I64);
|
|
||||||
Debug.Assert(shiftLsB.Type == OperandType.I32);
|
|
||||||
Debug.Assert((uint)size < 4u);
|
|
||||||
|
|
||||||
Operand negShiftLsB = context.Negate(shiftLsB);
|
|
||||||
|
|
||||||
Operand isInRange = context.BitwiseAnd(
|
|
||||||
context.ICompareLess(shiftLsB, Const(8 << size)),
|
|
||||||
context.ICompareLess(negShiftLsB, Const(8 << size)));
|
|
||||||
|
|
||||||
Operand isPositive = context.ICompareGreaterOrEqual(shiftLsB, Const(0));
|
|
||||||
|
|
||||||
Operand shl = context.ShiftLeft(op, shiftLsB);
|
|
||||||
|
|
||||||
Operand sarOrShr = signed
|
|
||||||
? context.ShiftRightSI(op, negShiftLsB)
|
|
||||||
: context.ShiftRightUI(op, negShiftLsB);
|
|
||||||
|
|
||||||
Operand res = context.ConditionalSelect(isPositive, shl, sarOrShr);
|
|
||||||
|
|
||||||
if (signed)
|
|
||||||
{
|
|
||||||
Operand isPositive2 = context.ICompareGreaterOrEqual(op, Const(0L));
|
|
||||||
|
|
||||||
Operand res2 = context.ConditionalSelect(isPositive2, Const(0L), Const(-1L));
|
|
||||||
res2 = context.ConditionalSelect(isPositive, Const(0L), res2);
|
|
||||||
|
|
||||||
return context.ConditionalSelect(isInRange, res, res2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return context.ConditionalSelect(isInRange, res, Const(0UL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void EmitVectorShrImmNarrowOpZx(ArmEmitterContext context, bool round)
|
private static void EmitVectorShrImmNarrowOpZx(ArmEmitterContext context, bool round)
|
||||||
{
|
{
|
||||||
OpCodeSimdShImm op = (OpCodeSimdShImm)context.CurrOp;
|
OpCodeSimdShImm op = (OpCodeSimdShImm)context.CurrOp;
|
||||||
@@ -1168,8 +1035,23 @@ namespace ARMeilleure.Instructions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EmitSshlOrUshl(ArmEmitterContext context, bool signed, bool scalar)
|
[Flags]
|
||||||
|
private enum ShlRegFlags
|
||||||
{
|
{
|
||||||
|
None = 0,
|
||||||
|
Scalar = 1 << 0,
|
||||||
|
Signed = 1 << 1,
|
||||||
|
Round = 1 << 2,
|
||||||
|
Saturating = 1 << 3
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EmitShlRegOp(ArmEmitterContext context, ShlRegFlags flags = ShlRegFlags.None)
|
||||||
|
{
|
||||||
|
bool scalar = flags.HasFlag(ShlRegFlags.Scalar);
|
||||||
|
bool signed = flags.HasFlag(ShlRegFlags.Signed);
|
||||||
|
bool round = flags.HasFlag(ShlRegFlags.Round);
|
||||||
|
bool saturating = flags.HasFlag(ShlRegFlags.Saturating);
|
||||||
|
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
||||||
|
|
||||||
Operand res = context.VectorZero();
|
Operand res = context.VectorZero();
|
||||||
@@ -1178,15 +1060,225 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
for (int index = 0; index < elems; index++)
|
for (int index = 0; index < elems; index++)
|
||||||
{
|
{
|
||||||
Operand ne = EmitVectorExtract (context, op.Rn, index, op.Size, signed);
|
Operand ne = EmitVectorExtract(context, op.Rn, index, op.Size, signed);
|
||||||
Operand me = EmitVectorExtractSx(context, op.Rm, index << op.Size, 0);
|
Operand me = EmitVectorExtractSx(context, op.Rm, index << op.Size, size: 0);
|
||||||
|
|
||||||
Operand e = EmitShlRegOp(context, ne, context.ConvertI64ToI32(me), op.Size, signed);
|
Operand e = !saturating
|
||||||
|
? EmitShlReg(context, ne, context.ConvertI64ToI32(me), round, op.Size, signed)
|
||||||
|
: EmitShlRegSatQ(context, ne, context.ConvertI64ToI32(me), round, op.Size, signed);
|
||||||
|
|
||||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
res = EmitVectorInsert(context, res, e, index, op.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Copy(GetVec(op.Rd), res);
|
context.Copy(GetVec(op.Rd), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// long SignedShlReg(long op, int shiftLsB, bool round, int size);
|
||||||
|
// ulong UnsignedShlReg(ulong op, int shiftLsB, bool round, int size);
|
||||||
|
private static Operand EmitShlReg(ArmEmitterContext context, Operand op, Operand shiftLsB, bool round, int size, bool signed)
|
||||||
|
{
|
||||||
|
int eSize = 8 << size;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(shiftLsB.Type == OperandType.I32);
|
||||||
|
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||||
|
|
||||||
|
Operand lbl1 = Label();
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand eSizeOp = Const(eSize);
|
||||||
|
Operand zero = Const(0);
|
||||||
|
Operand zeroL = Const(0L);
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||||
|
|
||||||
|
context.BranchIf(lbl1, shiftLsB, zero, Comparison.GreaterOrEqual);
|
||||||
|
context.Copy(res, signed
|
||||||
|
? EmitSignedShrReg(context, op, context.Negate(shiftLsB), round, eSize)
|
||||||
|
: EmitUnsignedShrReg(context, op, context.Negate(shiftLsB), round, eSize));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lbl1);
|
||||||
|
context.BranchIf(lblEnd, shiftLsB, zero, Comparison.LessOrEqual);
|
||||||
|
Operand shl = context.ShiftLeft(op, shiftLsB);
|
||||||
|
Operand isGreaterOrEqual = context.ICompareGreaterOrEqual(shiftLsB, eSizeOp);
|
||||||
|
context.Copy(res, context.ConditionalSelect(isGreaterOrEqual, zeroL, shl));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// long SignedShlRegSatQ(long op, int shiftLsB, bool round, int size);
|
||||||
|
// ulong UnsignedShlRegSatQ(ulong op, int shiftLsB, bool round, int size);
|
||||||
|
private static Operand EmitShlRegSatQ(ArmEmitterContext context, Operand op, Operand shiftLsB, bool round, int size, bool signed)
|
||||||
|
{
|
||||||
|
int eSize = 8 << size;
|
||||||
|
|
||||||
|
Debug.Assert(op.Type == OperandType.I64);
|
||||||
|
Debug.Assert(shiftLsB.Type == OperandType.I32);
|
||||||
|
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||||
|
|
||||||
|
Operand lbl1 = Label();
|
||||||
|
Operand lbl2 = Label();
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand eSizeOp = Const(eSize);
|
||||||
|
Operand zero = Const(0);
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||||
|
|
||||||
|
context.BranchIf(lbl1, shiftLsB, zero, Comparison.GreaterOrEqual);
|
||||||
|
context.Copy(res, signed
|
||||||
|
? EmitSignedShrReg(context, op, context.Negate(shiftLsB), round, eSize)
|
||||||
|
: EmitUnsignedShrReg(context, op, context.Negate(shiftLsB), round, eSize));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lbl1);
|
||||||
|
context.BranchIf(lblEnd, shiftLsB, zero, Comparison.LessOrEqual);
|
||||||
|
context.BranchIf(lbl2, shiftLsB, eSizeOp, Comparison.Less);
|
||||||
|
context.Copy(res, signed
|
||||||
|
? EmitSignedSignSatQ(context, op, size)
|
||||||
|
: EmitUnsignedSignSatQ(context, op, size));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lbl2);
|
||||||
|
Operand shl = context.ShiftLeft(op, shiftLsB);
|
||||||
|
if (eSize == 64)
|
||||||
|
{
|
||||||
|
Operand sarOrShr = signed
|
||||||
|
? context.ShiftRightSI(shl, shiftLsB)
|
||||||
|
: context.ShiftRightUI(shl, shiftLsB);
|
||||||
|
context.Copy(res, shl);
|
||||||
|
context.BranchIf(lblEnd, sarOrShr, op, Comparison.Equal);
|
||||||
|
context.Copy(res, signed
|
||||||
|
? EmitSignedSignSatQ(context, op, size)
|
||||||
|
: EmitUnsignedSignSatQ(context, op, size));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Copy(res, signed
|
||||||
|
? EmitSignedSrcSatQ(context, shl, size, signedDst: true)
|
||||||
|
: EmitUnsignedSrcSatQ(context, shl, size, signedDst: false));
|
||||||
|
}
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// shift := [1, 128]; eSize := {8, 16, 32, 64}.
|
||||||
|
// long SignedShrReg(long op, int shift, bool round, int eSize);
|
||||||
|
private static Operand EmitSignedShrReg(ArmEmitterContext context, Operand op, Operand shift, bool round, int eSize)
|
||||||
|
{
|
||||||
|
if (round)
|
||||||
|
{
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand eSizeOp = Const(eSize);
|
||||||
|
Operand zeroL = Const(0L);
|
||||||
|
Operand one = Const(1);
|
||||||
|
Operand oneL = Const(1L);
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), zeroL);
|
||||||
|
|
||||||
|
context.BranchIf(lblEnd, shift, eSizeOp, Comparison.GreaterOrEqual);
|
||||||
|
Operand roundConst = context.ShiftLeft(oneL, context.Subtract(shift, one));
|
||||||
|
Operand add = context.Add(op, roundConst);
|
||||||
|
Operand sar = context.ShiftRightSI(add, shift);
|
||||||
|
if (eSize == 64)
|
||||||
|
{
|
||||||
|
Operand shr = context.ShiftRightUI(add, shift);
|
||||||
|
Operand left = context.BitwiseAnd(context.Negate(op), context.BitwiseExclusiveOr(op, add));
|
||||||
|
Operand isLess = context.ICompareLess(left, zeroL);
|
||||||
|
context.Copy(res, context.ConditionalSelect(isLess, shr, sar));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Copy(res, sar);
|
||||||
|
}
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand eSizeOp = Const(eSize);
|
||||||
|
Operand zeroL = Const(0L);
|
||||||
|
Operand negOneL = Const(-1L);
|
||||||
|
|
||||||
|
Operand sar = context.ShiftRightSI(op, shift);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), sar);
|
||||||
|
|
||||||
|
context.BranchIf(lblEnd, shift, eSizeOp, Comparison.Less);
|
||||||
|
Operand isLess = context.ICompareLess(op, zeroL);
|
||||||
|
context.Copy(res, context.ConditionalSelect(isLess, negOneL, zeroL));
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// shift := [1, 128]; eSize := {8, 16, 32, 64}.
|
||||||
|
// ulong UnsignedShrReg(ulong op, int shift, bool round, int eSize);
|
||||||
|
private static Operand EmitUnsignedShrReg(ArmEmitterContext context, Operand op, Operand shift, bool round, int eSize)
|
||||||
|
{
|
||||||
|
if (round)
|
||||||
|
{
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand zeroUL = Const(0UL);
|
||||||
|
Operand one = Const(1);
|
||||||
|
Operand oneUL = Const(1UL);
|
||||||
|
Operand eSizeMaxOp = Const(64);
|
||||||
|
Operand oneShl63UL = Const(1UL << 63);
|
||||||
|
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), zeroUL);
|
||||||
|
|
||||||
|
context.BranchIf(lblEnd, shift, eSizeMaxOp, Comparison.Greater);
|
||||||
|
Operand roundConst = context.ShiftLeft(oneUL, context.Subtract(shift, one));
|
||||||
|
Operand add = context.Add(op, roundConst);
|
||||||
|
Operand shr = context.ShiftRightUI(add, shift);
|
||||||
|
Operand isEqual = context.ICompareEqual(shift, eSizeMaxOp);
|
||||||
|
context.Copy(res, context.ConditionalSelect(isEqual, zeroUL, shr));
|
||||||
|
if (eSize == 64)
|
||||||
|
{
|
||||||
|
context.BranchIf(lblEnd, add, op, Comparison.GreaterOrEqualUI);
|
||||||
|
Operand right = context.BitwiseOr(shr, context.ShiftRightUI(oneShl63UL, context.Subtract(shift, one)));
|
||||||
|
context.Copy(res, context.ConditionalSelect(isEqual, oneUL, right));
|
||||||
|
}
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Operand lblEnd = Label();
|
||||||
|
|
||||||
|
Operand eSizeOp = Const(eSize);
|
||||||
|
Operand zeroUL = Const(0UL);
|
||||||
|
|
||||||
|
Operand shr = context.ShiftRightUI(op, shift);
|
||||||
|
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), shr);
|
||||||
|
|
||||||
|
context.BranchIf(lblEnd, shift, eSizeOp, Comparison.Less);
|
||||||
|
context.Copy(res, zeroUL);
|
||||||
|
context.Branch(lblEnd);
|
||||||
|
|
||||||
|
context.MarkLabel(lblEnd);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,11 +15,6 @@ namespace ARMeilleure.Instructions
|
|||||||
private const int DczSizeLog2 = 4; // Log2 size in words
|
private const int DczSizeLog2 = 4; // Log2 size in words
|
||||||
public const int DczSizeInBytes = 4 << DczSizeLog2;
|
public const int DczSizeInBytes = 4 << DczSizeLog2;
|
||||||
|
|
||||||
public static void Hint(ArmEmitterContext context)
|
|
||||||
{
|
|
||||||
// Execute as no-op.
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Isb(ArmEmitterContext context)
|
public static void Isb(ArmEmitterContext context)
|
||||||
{
|
{
|
||||||
// Execute as no-op.
|
// Execute as no-op.
|
||||||
|
@@ -45,6 +45,7 @@ namespace ARMeilleure.Instructions
|
|||||||
Dsb,
|
Dsb,
|
||||||
Eon,
|
Eon,
|
||||||
Eor,
|
Eor,
|
||||||
|
Esb,
|
||||||
Extr,
|
Extr,
|
||||||
Hint,
|
Hint,
|
||||||
Isb,
|
Isb,
|
||||||
@@ -81,6 +82,9 @@ namespace ARMeilleure.Instructions
|
|||||||
Sbcs,
|
Sbcs,
|
||||||
Sbfm,
|
Sbfm,
|
||||||
Sdiv,
|
Sdiv,
|
||||||
|
Sel,
|
||||||
|
Sev,
|
||||||
|
Sevl,
|
||||||
Shsub8,
|
Shsub8,
|
||||||
Smaddl,
|
Smaddl,
|
||||||
Smsubl,
|
Smsubl,
|
||||||
@@ -104,12 +108,16 @@ namespace ARMeilleure.Instructions
|
|||||||
Sys,
|
Sys,
|
||||||
Tbnz,
|
Tbnz,
|
||||||
Tbz,
|
Tbz,
|
||||||
|
Tsb,
|
||||||
Ubfm,
|
Ubfm,
|
||||||
Udiv,
|
Udiv,
|
||||||
Umaddl,
|
Umaddl,
|
||||||
Umsubl,
|
Umsubl,
|
||||||
Umulh,
|
Umulh,
|
||||||
Und,
|
Und,
|
||||||
|
Wfe,
|
||||||
|
Wfi,
|
||||||
|
Yield,
|
||||||
|
|
||||||
// FP & SIMD (AArch64)
|
// FP & SIMD (AArch64)
|
||||||
Abs_S,
|
Abs_S,
|
||||||
@@ -519,6 +527,7 @@ namespace ARMeilleure.Instructions
|
|||||||
Revsh,
|
Revsh,
|
||||||
Rsb,
|
Rsb,
|
||||||
Rsc,
|
Rsc,
|
||||||
|
Sadd8,
|
||||||
Sbfx,
|
Sbfx,
|
||||||
Shadd8,
|
Shadd8,
|
||||||
Smla__,
|
Smla__,
|
||||||
@@ -529,6 +538,7 @@ namespace ARMeilleure.Instructions
|
|||||||
Smmls,
|
Smmls,
|
||||||
Smul__,
|
Smul__,
|
||||||
Smmul,
|
Smmul,
|
||||||
|
Ssub8,
|
||||||
Stl,
|
Stl,
|
||||||
Stlb,
|
Stlb,
|
||||||
Stlex,
|
Stlex,
|
||||||
@@ -550,6 +560,7 @@ namespace ARMeilleure.Instructions
|
|||||||
Teq,
|
Teq,
|
||||||
Trap,
|
Trap,
|
||||||
Tst,
|
Tst,
|
||||||
|
Uadd8,
|
||||||
Ubfx,
|
Ubfx,
|
||||||
Uhadd8,
|
Uhadd8,
|
||||||
Uhsub8,
|
Uhsub8,
|
||||||
@@ -558,6 +569,7 @@ namespace ARMeilleure.Instructions
|
|||||||
Umull,
|
Umull,
|
||||||
Usat,
|
Usat,
|
||||||
Usat16,
|
Usat16,
|
||||||
|
Usub8,
|
||||||
Uxtb,
|
Uxtb,
|
||||||
Uxtb16,
|
Uxtb16,
|
||||||
Uxth,
|
Uxth,
|
||||||
@@ -636,6 +648,10 @@ namespace ARMeilleure.Instructions
|
|||||||
Vrev,
|
Vrev,
|
||||||
Vrhadd,
|
Vrhadd,
|
||||||
Vrint,
|
Vrint,
|
||||||
|
Vrinta,
|
||||||
|
Vrintm,
|
||||||
|
Vrintn,
|
||||||
|
Vrintp,
|
||||||
Vrintx,
|
Vrintx,
|
||||||
Vrshr,
|
Vrshr,
|
||||||
Vrshrn,
|
Vrshrn,
|
||||||
|
@@ -5,287 +5,6 @@ namespace ARMeilleure.Instructions
|
|||||||
{
|
{
|
||||||
static class SoftFallback
|
static class SoftFallback
|
||||||
{
|
{
|
||||||
#region "ShlReg"
|
|
||||||
public static long SignedShlReg(long value, long shift, bool round, int size)
|
|
||||||
{
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
int shiftLsB = (sbyte)shift;
|
|
||||||
|
|
||||||
if (shiftLsB < 0)
|
|
||||||
{
|
|
||||||
return SignedShrReg(value, -shiftLsB, round, eSize);
|
|
||||||
}
|
|
||||||
else if (shiftLsB > 0)
|
|
||||||
{
|
|
||||||
if (shiftLsB >= eSize)
|
|
||||||
{
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value << shiftLsB;
|
|
||||||
}
|
|
||||||
else /* if (shiftLsB == 0) */
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ulong UnsignedShlReg(ulong value, ulong shift, bool round, int size)
|
|
||||||
{
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
int shiftLsB = (sbyte)shift;
|
|
||||||
|
|
||||||
if (shiftLsB < 0)
|
|
||||||
{
|
|
||||||
return UnsignedShrReg(value, -shiftLsB, round, eSize);
|
|
||||||
}
|
|
||||||
else if (shiftLsB > 0)
|
|
||||||
{
|
|
||||||
if (shiftLsB >= eSize)
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value << shiftLsB;
|
|
||||||
}
|
|
||||||
else /* if (shiftLsB == 0) */
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long SignedShlRegSatQ(long value, long shift, bool round, int size)
|
|
||||||
{
|
|
||||||
ExecutionContext context = NativeInterface.GetContext();
|
|
||||||
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
int shiftLsB = (sbyte)shift;
|
|
||||||
|
|
||||||
if (shiftLsB < 0)
|
|
||||||
{
|
|
||||||
return SignedShrReg(value, -shiftLsB, round, eSize);
|
|
||||||
}
|
|
||||||
else if (shiftLsB > 0)
|
|
||||||
{
|
|
||||||
if (shiftLsB >= eSize)
|
|
||||||
{
|
|
||||||
return SignedSignSatQ(value, eSize, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eSize == 64)
|
|
||||||
{
|
|
||||||
long shl = value << shiftLsB;
|
|
||||||
long shr = shl >> shiftLsB;
|
|
||||||
|
|
||||||
if (shr != value)
|
|
||||||
{
|
|
||||||
return SignedSignSatQ(value, eSize, context);
|
|
||||||
}
|
|
||||||
else /* if (shr == value) */
|
|
||||||
{
|
|
||||||
return shl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (eSize != 64) */
|
|
||||||
{
|
|
||||||
return SignedSrcSignedDstSatQ(value << shiftLsB, size); // InstEmitSimdHelper.EmitSignedSrcSatQ(signedDst: true).
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (shiftLsB == 0) */
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ulong UnsignedShlRegSatQ(ulong value, ulong shift, bool round, int size)
|
|
||||||
{
|
|
||||||
ExecutionContext context = NativeInterface.GetContext();
|
|
||||||
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
int shiftLsB = (sbyte)shift;
|
|
||||||
|
|
||||||
if (shiftLsB < 0)
|
|
||||||
{
|
|
||||||
return UnsignedShrReg(value, -shiftLsB, round, eSize);
|
|
||||||
}
|
|
||||||
else if (shiftLsB > 0)
|
|
||||||
{
|
|
||||||
if (shiftLsB >= eSize)
|
|
||||||
{
|
|
||||||
return UnsignedSignSatQ(value, eSize, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eSize == 64)
|
|
||||||
{
|
|
||||||
ulong shl = value << shiftLsB;
|
|
||||||
ulong shr = shl >> shiftLsB;
|
|
||||||
|
|
||||||
if (shr != value)
|
|
||||||
{
|
|
||||||
return UnsignedSignSatQ(value, eSize, context);
|
|
||||||
}
|
|
||||||
else /* if (shr == value) */
|
|
||||||
{
|
|
||||||
return shl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (eSize != 64) */
|
|
||||||
{
|
|
||||||
return UnsignedSrcUnsignedDstSatQ(value << shiftLsB, size); // InstEmitSimdHelper.EmitUnsignedSrcSatQ(signedDst: false).
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (shiftLsB == 0) */
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long SignedShrReg(long value, int shift, bool round, int eSize) // shift := [1, 128]; eSize := {8, 16, 32, 64}.
|
|
||||||
{
|
|
||||||
if (round)
|
|
||||||
{
|
|
||||||
if (shift >= eSize)
|
|
||||||
{
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
long roundConst = 1L << (shift - 1);
|
|
||||||
|
|
||||||
long add = value + roundConst;
|
|
||||||
|
|
||||||
if (eSize == 64)
|
|
||||||
{
|
|
||||||
if ((~value & (value ^ add)) < 0L)
|
|
||||||
{
|
|
||||||
return (long)((ulong)add >> shift);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return add >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (eSize != 64) */
|
|
||||||
{
|
|
||||||
return add >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (!round) */
|
|
||||||
{
|
|
||||||
if (shift >= eSize)
|
|
||||||
{
|
|
||||||
if (value < 0L)
|
|
||||||
{
|
|
||||||
return -1L;
|
|
||||||
}
|
|
||||||
else /* if (value >= 0L) */
|
|
||||||
{
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ulong UnsignedShrReg(ulong value, int shift, bool round, int eSize) // shift := [1, 128]; eSize := {8, 16, 32, 64}.
|
|
||||||
{
|
|
||||||
if (round)
|
|
||||||
{
|
|
||||||
if (shift > 64)
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong roundConst = 1UL << (shift - 1);
|
|
||||||
|
|
||||||
ulong add = value + roundConst;
|
|
||||||
|
|
||||||
if (eSize == 64)
|
|
||||||
{
|
|
||||||
if ((add < value) && (add < roundConst))
|
|
||||||
{
|
|
||||||
if (shift == 64)
|
|
||||||
{
|
|
||||||
return 1UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (add >> shift) | (0x8000000000000000UL >> (shift - 1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (shift == 64)
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return add >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (eSize != 64) */
|
|
||||||
{
|
|
||||||
if (shift == 64)
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return add >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* if (!round) */
|
|
||||||
{
|
|
||||||
if (shift >= eSize)
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value >> shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long SignedSignSatQ(long op, int eSize, ExecutionContext context) // eSize := {8, 16, 32, 64}.
|
|
||||||
{
|
|
||||||
long tMaxValue = (1L << (eSize - 1)) - 1L;
|
|
||||||
long tMinValue = -(1L << (eSize - 1));
|
|
||||||
|
|
||||||
if (op > 0L)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMaxValue;
|
|
||||||
}
|
|
||||||
else if (op < 0L)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMinValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ulong UnsignedSignSatQ(ulong op, int eSize, ExecutionContext context) // eSize := {8, 16, 32, 64}.
|
|
||||||
{
|
|
||||||
ulong tMaxValue = ulong.MaxValue >> (64 - eSize);
|
|
||||||
|
|
||||||
if (op > 0UL)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMaxValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region "ShrImm64"
|
#region "ShrImm64"
|
||||||
public static long SignedShrImm64(long value, long roundConst, int shift)
|
public static long SignedShrImm64(long value, long roundConst, int shift)
|
||||||
{
|
{
|
||||||
@@ -508,55 +227,6 @@ namespace ARMeilleure.Instructions
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region "Saturating"
|
|
||||||
private static long SignedSrcSignedDstSatQ(long op, int size)
|
|
||||||
{
|
|
||||||
ExecutionContext context = NativeInterface.GetContext();
|
|
||||||
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
long tMaxValue = (1L << (eSize - 1)) - 1L;
|
|
||||||
long tMinValue = -(1L << (eSize - 1));
|
|
||||||
|
|
||||||
if (op > tMaxValue)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMaxValue;
|
|
||||||
}
|
|
||||||
else if (op < tMinValue)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMinValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ulong UnsignedSrcUnsignedDstSatQ(ulong op, int size)
|
|
||||||
{
|
|
||||||
ExecutionContext context = NativeInterface.GetContext();
|
|
||||||
|
|
||||||
int eSize = 8 << size;
|
|
||||||
|
|
||||||
ulong tMaxValue = (1UL << eSize) - 1UL;
|
|
||||||
|
|
||||||
if (op > tMaxValue)
|
|
||||||
{
|
|
||||||
context.Fpsr |= FPSR.Qc;
|
|
||||||
|
|
||||||
return tMaxValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region "Count"
|
#region "Count"
|
||||||
public static ulong CountLeadingSigns(ulong value, int size) // size is 8, 16, 32 or 64 (SIMD&FP or Base Inst.).
|
public static ulong CountLeadingSigns(ulong value, int size) // size is 8, 16, 32 or 64 (SIMD&FP or Base Inst.).
|
||||||
{
|
{
|
||||||
|
@@ -4,6 +4,10 @@ namespace ARMeilleure.State
|
|||||||
{
|
{
|
||||||
TFlag = 5,
|
TFlag = 5,
|
||||||
EFlag = 9,
|
EFlag = 9,
|
||||||
|
GE0Flag = 16,
|
||||||
|
GE1Flag = 17,
|
||||||
|
GE2Flag = 18,
|
||||||
|
GE3Flag = 19,
|
||||||
QFlag = 27,
|
QFlag = 27,
|
||||||
VFlag = 28,
|
VFlag = 28,
|
||||||
CFlag = 29,
|
CFlag = 29,
|
||||||
|
@@ -179,8 +179,6 @@ namespace ARMeilleure.Translation
|
|||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart2)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart2)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha256SchedulePart1)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha256SchedulePart1)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha256SchedulePart2)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha256SchedulePart2)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShlReg)));
|
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShlRegSatQ)));
|
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShrImm64)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.SignedShrImm64)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbl1)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbl1)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbl2)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbl2)));
|
||||||
@@ -190,8 +188,6 @@ namespace ARMeilleure.Translation
|
|||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx2)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx2)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx3)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx3)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx4)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Tbx4)));
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShlReg)));
|
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShlRegSatQ)));
|
|
||||||
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShrImm64)));
|
SetDelegateInfo(typeof(SoftFallback).GetMethod(nameof(SoftFallback.UnsignedShrImm64)));
|
||||||
|
|
||||||
SetDelegateInfo(typeof(SoftFloat16_32).GetMethod(nameof(SoftFloat16_32.FPConvert)));
|
SetDelegateInfo(typeof(SoftFloat16_32).GetMethod(nameof(SoftFloat16_32.FPConvert)));
|
||||||
|
@@ -27,7 +27,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
||||||
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
||||||
|
|
||||||
private const uint InternalVersion = 3683; //! To be incremented manually for each change to the ARMeilleure project.
|
private const uint InternalVersion = 3700; //! To be incremented manually for each change to the ARMeilleure project.
|
||||||
|
|
||||||
private const string ActualDir = "0";
|
private const string ActualDir = "0";
|
||||||
private const string BackupDir = "1";
|
private const string BackupDir = "1";
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<img src="https://raw.githubusercontent.com/Ryujinx/Ryujinx-Website/master/static/public/shell_fullsize.png">
|
<img src="https://raw.githubusercontent.com/Ryujinx/Ryujinx-Website/master/public/assets/images/shell.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h5 align="center">
|
<h5 align="center">
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using ARMeilleure.Translation;
|
using ARMeilleure.Translation;
|
||||||
using ARMeilleure.Translation.PTC;
|
using ARMeilleure.Translation.PTC;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
@@ -12,10 +11,8 @@ using Ryujinx.Audio.Integration;
|
|||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.Input;
|
using Ryujinx.Ava.Input;
|
||||||
using Ryujinx.Ava.Ui.Backend.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Controls;
|
using Ryujinx.Ava.Ui.Controls;
|
||||||
using Ryujinx.Ava.Ui.Models;
|
using Ryujinx.Ava.Ui.Models;
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Windows;
|
using Ryujinx.Ava.Ui.Windows;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
@@ -39,6 +36,7 @@ using SixLabors.ImageSharp;
|
|||||||
using SixLabors.ImageSharp.Formats.Png;
|
using SixLabors.ImageSharp.Formats.Png;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using SPB.Graphics.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -58,24 +56,24 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
private const int CursorHideIdleTime = 8; // Hide Cursor seconds
|
private const int CursorHideIdleTime = 8; // Hide Cursor seconds
|
||||||
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
|
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
|
||||||
|
private const int TargetFps = 60;
|
||||||
|
|
||||||
private static readonly Cursor InvisibleCursor = new Cursor(StandardCursorType.None);
|
private static readonly Cursor InvisibleCursor = new Cursor(StandardCursorType.None);
|
||||||
|
|
||||||
|
private readonly long _ticksPerFrame;
|
||||||
|
private readonly Stopwatch _chrono;
|
||||||
private readonly AccountManager _accountManager;
|
private readonly AccountManager _accountManager;
|
||||||
private readonly UserChannelPersistence _userChannelPersistence;
|
private readonly UserChannelPersistence _userChannelPersistence;
|
||||||
|
|
||||||
private readonly InputManager _inputManager;
|
private readonly InputManager _inputManager;
|
||||||
|
|
||||||
private readonly IKeyboard _keyboardInterface;
|
|
||||||
|
|
||||||
private readonly MainWindow _parent;
|
private readonly MainWindow _parent;
|
||||||
|
private readonly IKeyboard _keyboardInterface;
|
||||||
private readonly GraphicsDebugLevel _glLogLevel;
|
private readonly GraphicsDebugLevel _glLogLevel;
|
||||||
|
|
||||||
private bool _hideCursorOnIdle;
|
private bool _hideCursorOnIdle;
|
||||||
private bool _isStopped;
|
private bool _isStopped;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private long _lastCursorMoveTime;
|
private long _lastCursorMoveTime;
|
||||||
|
private long _ticks = 0;
|
||||||
|
|
||||||
private KeyboardHotkeyState _prevHotkeyState;
|
private KeyboardHotkeyState _prevHotkeyState;
|
||||||
|
|
||||||
@@ -93,7 +91,7 @@ namespace Ryujinx.Ava
|
|||||||
public event EventHandler AppExit;
|
public event EventHandler AppExit;
|
||||||
public event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
|
public event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
|
||||||
|
|
||||||
public RendererControl Renderer { get; }
|
public RendererHost Renderer { get; }
|
||||||
public VirtualFileSystem VirtualFileSystem { get; }
|
public VirtualFileSystem VirtualFileSystem { get; }
|
||||||
public ContentManager ContentManager { get; }
|
public ContentManager ContentManager { get; }
|
||||||
public Switch Device { get; set; }
|
public Switch Device { get; set; }
|
||||||
@@ -111,7 +109,7 @@ namespace Ryujinx.Ava
|
|||||||
private object _lockObject = new();
|
private object _lockObject = new();
|
||||||
|
|
||||||
public AppHost(
|
public AppHost(
|
||||||
RendererControl renderer,
|
RendererHost renderer,
|
||||||
InputManager inputManager,
|
InputManager inputManager,
|
||||||
string applicationPath,
|
string applicationPath,
|
||||||
VirtualFileSystem virtualFileSystem,
|
VirtualFileSystem virtualFileSystem,
|
||||||
@@ -128,7 +126,7 @@ namespace Ryujinx.Ava
|
|||||||
_hideCursorOnIdle = ConfigurationState.Instance.HideCursorOnIdle;
|
_hideCursorOnIdle = ConfigurationState.Instance.HideCursorOnIdle;
|
||||||
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
||||||
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
|
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
|
||||||
_inputManager.SetMouseDriver(new AvaloniaMouseDriver(renderer));
|
_inputManager.SetMouseDriver(new AvaloniaMouseDriver(_parent, renderer));
|
||||||
_keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
|
_keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
|
||||||
|
|
||||||
NpadManager = _inputManager.CreateNpadManager();
|
NpadManager = _inputManager.CreateNpadManager();
|
||||||
@@ -138,6 +136,9 @@ namespace Ryujinx.Ava
|
|||||||
VirtualFileSystem = virtualFileSystem;
|
VirtualFileSystem = virtualFileSystem;
|
||||||
ContentManager = contentManager;
|
ContentManager = contentManager;
|
||||||
|
|
||||||
|
_chrono = new Stopwatch();
|
||||||
|
_ticksPerFrame = Stopwatch.Frequency / TargetFps;
|
||||||
|
|
||||||
if (ApplicationPath.StartsWith("@SystemContent"))
|
if (ApplicationPath.StartsWith("@SystemContent"))
|
||||||
{
|
{
|
||||||
ApplicationPath = _parent.VirtualFileSystem.SwitchPathToSystemPath(ApplicationPath);
|
ApplicationPath = _parent.VirtualFileSystem.SwitchPathToSystemPath(ApplicationPath);
|
||||||
@@ -177,7 +178,7 @@ namespace Ryujinx.Ava
|
|||||||
if (_renderer != null)
|
if (_renderer != null)
|
||||||
{
|
{
|
||||||
double scale = _parent.PlatformImpl.RenderScaling;
|
double scale = _parent.PlatformImpl.RenderScaling;
|
||||||
_renderer.Window.SetSize((int)(size.Width * scale), (int)(size.Height * scale));
|
_renderer.Window?.SetSize((int)(size.Width * scale), (int)(size.Height * scale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,8 +336,6 @@ namespace Ryujinx.Ava
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AvaloniaLocator.Current.GetService<VulkanPlatformInterface>()?.MainSurface.Display.ChangeVSyncMode(true);
|
|
||||||
|
|
||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
}
|
}
|
||||||
@@ -376,6 +375,8 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
_gpuCancellationTokenSource.Cancel();
|
_gpuCancellationTokenSource.Cancel();
|
||||||
_gpuCancellationTokenSource.Dispose();
|
_gpuCancellationTokenSource.Dispose();
|
||||||
|
|
||||||
|
_chrono.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeGpu()
|
public void DisposeGpu()
|
||||||
@@ -390,7 +391,6 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
Device.DisposeGpu();
|
Device.DisposeGpu();
|
||||||
|
|
||||||
Renderer?.DestroyBackgroundContext();
|
|
||||||
Renderer?.MakeCurrent(null);
|
Renderer?.MakeCurrent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,16 +596,11 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
IRenderer renderer;
|
IRenderer renderer;
|
||||||
|
|
||||||
if (Program.UseVulkan)
|
if (Renderer.IsVulkan)
|
||||||
{
|
{
|
||||||
var vulkan = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
string preferredGpu = ConfigurationState.Instance.Graphics.PreferredGpu.Value;
|
||||||
|
|
||||||
renderer = new VulkanRenderer(vulkan.Instance.InternalHandle,
|
renderer = new VulkanRenderer(Renderer.CreateVulkanSurface, VulkanHelper.GetRequiredInstanceExtensions, preferredGpu);
|
||||||
vulkan.MainSurface.Device.InternalHandle,
|
|
||||||
vulkan.PhysicalDevice.InternalHandle,
|
|
||||||
vulkan.MainSurface.Device.Queue.InternalHandle,
|
|
||||||
vulkan.PhysicalDevice.QueueFamilyIndex,
|
|
||||||
vulkan.MainSurface.Device.Lock);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -778,12 +773,8 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
Width = (int)e.Width;
|
Width = (int)e.Width;
|
||||||
Height = (int)e.Height;
|
Height = (int)e.Height;
|
||||||
|
|
||||||
if (!Program.UseVulkan)
|
|
||||||
{
|
|
||||||
SetRendererWindowSize(e);
|
SetRendererWindowSize(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void MainLoop()
|
private void MainLoop()
|
||||||
{
|
{
|
||||||
@@ -822,12 +813,10 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
_renderer.ScreenCaptured += Renderer_ScreenCaptured;
|
_renderer.ScreenCaptured += Renderer_ScreenCaptured;
|
||||||
|
|
||||||
(_renderer as OpenGLRenderer)?.InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext((Renderer as OpenGLRendererControl).GameContext));
|
(_renderer as OpenGLRenderer)?.InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext(Renderer.GetContext()));
|
||||||
|
|
||||||
Renderer.MakeCurrent();
|
Renderer.MakeCurrent();
|
||||||
|
|
||||||
AvaloniaLocator.Current.GetService<VulkanPlatformInterface>()?.MainSurface?.Display?.ChangeVSyncMode(Device.EnableDeviceVsync);
|
|
||||||
|
|
||||||
Device.Gpu.Renderer.Initialize(_glLogLevel);
|
Device.Gpu.Renderer.Initialize(_glLogLevel);
|
||||||
|
|
||||||
Width = (int)Renderer.Bounds.Width;
|
Width = (int)Renderer.Bounds.Width;
|
||||||
@@ -835,16 +824,20 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
_renderer.Window.SetSize((int)(Width * _parent.PlatformImpl.RenderScaling), (int)(Height * _parent.PlatformImpl.RenderScaling));
|
_renderer.Window.SetSize((int)(Width * _parent.PlatformImpl.RenderScaling), (int)(Height * _parent.PlatformImpl.RenderScaling));
|
||||||
|
|
||||||
|
_chrono.Start();
|
||||||
|
|
||||||
Device.Gpu.Renderer.RunLoop(() =>
|
Device.Gpu.Renderer.RunLoop(() =>
|
||||||
{
|
{
|
||||||
Device.Gpu.SetGpuThread();
|
Device.Gpu.SetGpuThread();
|
||||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||||
Translator.IsReadyForTranslation.Set();
|
Translator.IsReadyForTranslation.Set();
|
||||||
|
|
||||||
Renderer.Start();
|
|
||||||
|
|
||||||
while (_isActive)
|
while (_isActive)
|
||||||
{
|
{
|
||||||
|
_ticks += _chrono.ElapsedTicks;
|
||||||
|
|
||||||
|
_chrono.Restart();
|
||||||
|
|
||||||
if (Device.WaitFifo())
|
if (Device.WaitFifo())
|
||||||
{
|
{
|
||||||
Device.Statistics.RecordFifoStart();
|
Device.Statistics.RecordFifoStart();
|
||||||
@@ -860,19 +853,20 @@ namespace Ryujinx.Ava
|
|||||||
_parent.SwitchToGameControl();
|
_parent.SwitchToGameControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
Device.PresentFrame(Present);
|
Device.PresentFrame(() => Renderer?.SwapBuffers());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer.Stop();
|
if (_ticks >= _ticksPerFrame)
|
||||||
|
{
|
||||||
|
UpdateStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Renderer?.MakeCurrent(null);
|
Renderer?.MakeCurrent(null);
|
||||||
|
|
||||||
Renderer.SizeChanged -= Window_SizeChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Present(object image)
|
public void UpdateStatus()
|
||||||
{
|
{
|
||||||
// Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued
|
// Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued
|
||||||
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance["Docked"] : LocaleManager.Instance["Handheld"];
|
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance["Docked"] : LocaleManager.Instance["Handheld"];
|
||||||
@@ -886,24 +880,12 @@ namespace Ryujinx.Ava
|
|||||||
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
||||||
Device.EnableDeviceVsync,
|
Device.EnableDeviceVsync,
|
||||||
Device.GetVolume(),
|
Device.GetVolume(),
|
||||||
Program.UseVulkan ? "Vulkan" : "OpenGL",
|
Renderer.IsVulkan ? "Vulkan" : "OpenGL",
|
||||||
dockedMode,
|
dockedMode,
|
||||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||||
LocaleManager.Instance["Game"] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
|
LocaleManager.Instance["Game"] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
|
||||||
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
|
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
|
||||||
$"GPU: {_renderer.GetHardwareInfo().GpuVendor}"));
|
$"GPU: {_renderer.GetHardwareInfo().GpuVendor}"));
|
||||||
|
|
||||||
if (Program.UseVulkan)
|
|
||||||
{
|
|
||||||
var platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
if (platformInterface.MainSurface.Display.IsSurfaceChanged())
|
|
||||||
{
|
|
||||||
SetRendererWindowSize(new Size(Width, Height));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Renderer.Present(image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ShowExitPrompt()
|
public async Task ShowExitPrompt()
|
||||||
@@ -985,8 +967,6 @@ namespace Ryujinx.Ava
|
|||||||
case KeyboardHotkeyState.ToggleVSync:
|
case KeyboardHotkeyState.ToggleVSync:
|
||||||
Device.EnableDeviceVsync = !Device.EnableDeviceVsync;
|
Device.EnableDeviceVsync = !Device.EnableDeviceVsync;
|
||||||
|
|
||||||
AvaloniaLocator.Current.GetService<VulkanPlatformInterface>()?.MainSurface?.Display?.ChangeVSyncMode(Device.EnableDeviceVsync);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case KeyboardHotkeyState.Screenshot:
|
case KeyboardHotkeyState.Screenshot:
|
||||||
ScreenshotRequested = true;
|
ScreenshotRequested = true;
|
||||||
|
@@ -14,21 +14,28 @@ namespace Ryujinx.Ava.Input
|
|||||||
private Control _widget;
|
private Control _widget;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
private Size _size;
|
private Size _size;
|
||||||
|
private readonly Window _window;
|
||||||
|
|
||||||
public bool[] PressedButtons { get; }
|
public bool[] PressedButtons { get; }
|
||||||
|
|
||||||
public Vector2 CurrentPosition { get; private set; }
|
public Vector2 CurrentPosition { get; private set; }
|
||||||
public Vector2 Scroll { get; private set; }
|
public Vector2 Scroll { get; private set; }
|
||||||
|
|
||||||
public AvaloniaMouseDriver(Control parent)
|
public AvaloniaMouseDriver(Window window, Control parent)
|
||||||
{
|
{
|
||||||
_widget = parent;
|
_widget = parent;
|
||||||
|
_window = window;
|
||||||
|
|
||||||
_widget.PointerMoved += Parent_PointerMovedEvent;
|
_widget.PointerMoved += Parent_PointerMovedEvent;
|
||||||
_widget.PointerPressed += Parent_PointerPressEvent;
|
_widget.PointerPressed += Parent_PointerPressEvent;
|
||||||
_widget.PointerReleased += Parent_PointerReleaseEvent;
|
_widget.PointerReleased += Parent_PointerReleaseEvent;
|
||||||
_widget.PointerWheelChanged += Parent_ScrollEvent;
|
_widget.PointerWheelChanged += Parent_ScrollEvent;
|
||||||
|
|
||||||
|
_window.PointerMoved += Parent_PointerMovedEvent;
|
||||||
|
_window.PointerPressed += Parent_PointerPressEvent;
|
||||||
|
_window.PointerReleased += Parent_PointerReleaseEvent;
|
||||||
|
_window.PointerWheelChanged += Parent_ScrollEvent;
|
||||||
|
|
||||||
PressedButtons = new bool[(int)MouseButton.Count];
|
PressedButtons = new bool[(int)MouseButton.Count];
|
||||||
|
|
||||||
_size = new Size((int)parent.Bounds.Width, (int)parent.Bounds.Height);
|
_size = new Size((int)parent.Bounds.Width, (int)parent.Bounds.Height);
|
||||||
@@ -47,7 +54,6 @@ namespace Ryujinx.Ava.Input
|
|||||||
|
|
||||||
private void Parent_PointerReleaseEvent(object o, PointerReleasedEventArgs args)
|
private void Parent_PointerReleaseEvent(object o, PointerReleasedEventArgs args)
|
||||||
{
|
{
|
||||||
var pointerProperties = args.GetCurrentPoint(_widget).Properties;
|
|
||||||
PressedButtons[(int)args.InitialPressMouseButton - 1] = false;
|
PressedButtons[(int)args.InitialPressMouseButton - 1] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +131,11 @@ namespace Ryujinx.Ava.Input
|
|||||||
_widget.PointerReleased -= Parent_PointerReleaseEvent;
|
_widget.PointerReleased -= Parent_PointerReleaseEvent;
|
||||||
_widget.PointerWheelChanged -= Parent_ScrollEvent;
|
_widget.PointerWheelChanged -= Parent_ScrollEvent;
|
||||||
|
|
||||||
|
_window.PointerMoved -= Parent_PointerMovedEvent;
|
||||||
|
_window.PointerPressed -= Parent_PointerPressEvent;
|
||||||
|
_window.PointerReleased -= Parent_PointerReleaseEvent;
|
||||||
|
_window.PointerWheelChanged -= Parent_ScrollEvent;
|
||||||
|
|
||||||
_widget = null;
|
_widget = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
using ARMeilleure.Translation.PTC;
|
using ARMeilleure.Translation.PTC;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.OpenGL;
|
|
||||||
using Avalonia.Rendering;
|
using Avalonia.Rendering;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Ryujinx.Ava.Ui.Backend;
|
|
||||||
using Ryujinx.Ava.Ui.Controls;
|
using Ryujinx.Ava.Ui.Controls;
|
||||||
using Ryujinx.Ava.Ui.Windows;
|
using Ryujinx.Ava.Ui.Windows;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
@@ -12,12 +10,10 @@ using Ryujinx.Common.GraphicsDriver;
|
|||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Common.System;
|
using Ryujinx.Common.System;
|
||||||
using Ryujinx.Common.SystemInfo;
|
using Ryujinx.Common.SystemInfo;
|
||||||
using Ryujinx.Graphics.Vulkan;
|
|
||||||
using Ryujinx.Modules;
|
using Ryujinx.Modules;
|
||||||
using Ryujinx.Ui.Common;
|
using Ryujinx.Ui.Common;
|
||||||
using Ryujinx.Ui.Common.Configuration;
|
using Ryujinx.Ui.Common.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -34,7 +30,6 @@ namespace Ryujinx.Ava
|
|||||||
public static bool PreviewerDetached { get; private set; }
|
public static bool PreviewerDetached { get; private set; }
|
||||||
|
|
||||||
public static RenderTimer RenderTimer { get; private set; }
|
public static RenderTimer RenderTimer { get; private set; }
|
||||||
public static bool UseVulkan { get; private set; }
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
public static extern int MessageBoxA(IntPtr hWnd, string text, string caption, uint type);
|
public static extern int MessageBoxA(IntPtr hWnd, string text, string caption, uint type);
|
||||||
@@ -71,36 +66,16 @@ namespace Ryujinx.Ava
|
|||||||
EnableMultiTouch = true,
|
EnableMultiTouch = true,
|
||||||
EnableIme = true,
|
EnableIme = true,
|
||||||
UseEGL = false,
|
UseEGL = false,
|
||||||
UseGpu = !UseVulkan,
|
UseGpu = false
|
||||||
GlProfiles = new List<GlVersion>()
|
|
||||||
{
|
|
||||||
new GlVersion(GlProfileType.OpenGL, 4, 3)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.With(new Win32PlatformOptions
|
.With(new Win32PlatformOptions
|
||||||
{
|
{
|
||||||
EnableMultitouch = true,
|
EnableMultitouch = true,
|
||||||
UseWgl = !UseVulkan,
|
UseWgl = false,
|
||||||
WglProfiles = new List<GlVersion>()
|
|
||||||
{
|
|
||||||
new GlVersion(GlProfileType.OpenGL, 4, 3)
|
|
||||||
},
|
|
||||||
AllowEglInitialization = false,
|
AllowEglInitialization = false,
|
||||||
CompositionBackdropCornerRadius = 8f,
|
CompositionBackdropCornerRadius = 8f,
|
||||||
})
|
})
|
||||||
.UseSkia()
|
.UseSkia()
|
||||||
.With(new Ui.Vulkan.VulkanOptions()
|
|
||||||
{
|
|
||||||
ApplicationName = "Ryujinx.Graphics.Vulkan",
|
|
||||||
MaxQueueCount = 2,
|
|
||||||
PreferDiscreteGpu = true,
|
|
||||||
PreferredDevice = !PreviewerDetached ? "" : ConfigurationState.Instance.Graphics.PreferredGpu.Value,
|
|
||||||
UseDebug = !PreviewerDetached ? false : ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value != GraphicsDebugLevel.None,
|
|
||||||
})
|
|
||||||
.With(new SkiaOptions()
|
|
||||||
{
|
|
||||||
CustomGpuFactory = UseVulkan ? SkiaGpuFactory.CreateVulkanGpu : null
|
|
||||||
})
|
|
||||||
.AfterSetup(_ =>
|
.AfterSetup(_ =>
|
||||||
{
|
{
|
||||||
AvaloniaLocator.CurrentMutable
|
AvaloniaLocator.CurrentMutable
|
||||||
@@ -176,26 +151,7 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
ReloadConfig();
|
ReloadConfig();
|
||||||
|
|
||||||
UseVulkan = PreviewerDetached ? ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan : false;
|
|
||||||
|
|
||||||
if (UseVulkan)
|
|
||||||
{
|
|
||||||
if (VulkanRenderer.GetPhysicalDevices().Length == 0)
|
|
||||||
{
|
|
||||||
UseVulkan = false;
|
|
||||||
|
|
||||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
|
|
||||||
|
|
||||||
Logger.Warning?.PrintMsg(LogClass.Application, "A suitable Vulkan physical device is not available. Falling back to OpenGL");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UseVulkan)
|
|
||||||
{
|
|
||||||
// With a custom gpu backend, avalonia doesn't enable dpi awareness, so the backend must handle it. This isn't so for the opengl backed,
|
|
||||||
// as that uses avalonia's gpu backend and it's enabled there.
|
|
||||||
ForceDpiAware.Windows();
|
ForceDpiAware.Windows();
|
||||||
}
|
|
||||||
|
|
||||||
WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor();
|
WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor();
|
||||||
ActualScaleFactor = ForceDpiAware.GetActualScaleFactor() / BaseDpi;
|
ActualScaleFactor = ForceDpiAware.GetActualScaleFactor() / BaseDpi;
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
@@ -59,10 +60,26 @@ namespace Ryujinx.Ava.Ui.Controls
|
|||||||
|
|
||||||
string input = string.Empty;
|
string input = string.Empty;
|
||||||
|
|
||||||
|
var overlay = new ContentDialogOverlayWindow()
|
||||||
|
{
|
||||||
|
Height = window.Bounds.Height,
|
||||||
|
Width = window.Bounds.Width,
|
||||||
|
Position = window.PointToScreen(new Point())
|
||||||
|
};
|
||||||
|
|
||||||
|
window.PositionChanged += OverlayOnPositionChanged;
|
||||||
|
|
||||||
|
void OverlayOnPositionChanged(object sender, PixelPointEventArgs e)
|
||||||
|
{
|
||||||
|
overlay.Position = window.PointToScreen(new Point());
|
||||||
|
}
|
||||||
|
|
||||||
|
contentDialog = overlay.ContentDialog;
|
||||||
|
|
||||||
|
bool opened = false;
|
||||||
|
|
||||||
content.SetInputLengthValidation(args.StringLengthMin, args.StringLengthMax);
|
content.SetInputLengthValidation(args.StringLengthMin, args.StringLengthMax);
|
||||||
|
|
||||||
if (contentDialog != null)
|
|
||||||
{
|
|
||||||
content._host = contentDialog;
|
content._host = contentDialog;
|
||||||
contentDialog.Title = title;
|
contentDialog.Title = title;
|
||||||
contentDialog.PrimaryButtonText = args.SubmitText;
|
contentDialog.PrimaryButtonText = args.SubmitText;
|
||||||
@@ -70,6 +87,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
|||||||
contentDialog.SecondaryButtonText = "";
|
contentDialog.SecondaryButtonText = "";
|
||||||
contentDialog.CloseButtonText = LocaleManager.Instance["InputDialogCancel"];
|
contentDialog.CloseButtonText = LocaleManager.Instance["InputDialogCancel"];
|
||||||
contentDialog.Content = content;
|
contentDialog.Content = content;
|
||||||
|
|
||||||
TypedEventHandler<ContentDialog, ContentDialogClosedEventArgs> handler = (sender, eventArgs) =>
|
TypedEventHandler<ContentDialog, ContentDialogClosedEventArgs> handler = (sender, eventArgs) =>
|
||||||
{
|
{
|
||||||
if (eventArgs.Result == ContentDialogResult.Primary)
|
if (eventArgs.Result == ContentDialogResult.Primary)
|
||||||
@@ -79,9 +97,26 @@ namespace Ryujinx.Ava.Ui.Controls
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
contentDialog.Closed += handler;
|
contentDialog.Closed += handler;
|
||||||
|
|
||||||
|
overlay.Opened += OverlayOnActivated;
|
||||||
|
|
||||||
|
async void OverlayOnActivated(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opened = true;
|
||||||
|
|
||||||
|
overlay.Position = window.PointToScreen(new Point());
|
||||||
|
|
||||||
await contentDialog.ShowAsync();
|
await contentDialog.ShowAsync();
|
||||||
contentDialog.Closed -= handler;
|
contentDialog.Closed -= handler;
|
||||||
}
|
overlay.Close();
|
||||||
|
};
|
||||||
|
|
||||||
|
await overlay.ShowDialog(window);
|
||||||
|
|
||||||
return (result, input);
|
return (result, input);
|
||||||
}
|
}
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using static Ryujinx.Ava.Ui.Backend.Interop;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend
|
|
||||||
{
|
|
||||||
public abstract class BackendSurface : IDisposable
|
|
||||||
{
|
|
||||||
protected IntPtr Display => _display;
|
|
||||||
|
|
||||||
private IntPtr _display = IntPtr.Zero;
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6")]
|
|
||||||
public static extern IntPtr XOpenDisplay(IntPtr display);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6")]
|
|
||||||
public static extern int XCloseDisplay(IntPtr display);
|
|
||||||
|
|
||||||
private PixelSize _currentSize;
|
|
||||||
public IntPtr Handle { get; protected set; }
|
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
|
||||||
|
|
||||||
public BackendSurface(IntPtr handle)
|
|
||||||
{
|
|
||||||
Handle = handle;
|
|
||||||
|
|
||||||
if (OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
_display = XOpenDisplay(IntPtr.Zero);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PixelSize Size
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
PixelSize size = new PixelSize();
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
GetClientRect(Handle, out var rect);
|
|
||||||
size = new PixelSize(rect.right, rect.bottom);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
XWindowAttributes attributes = new XWindowAttributes();
|
|
||||||
XGetWindowAttributes(Display, Handle, ref attributes);
|
|
||||||
|
|
||||||
size = new PixelSize(attributes.width, attributes.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentSize = size;
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PixelSize CurrentSize => _currentSize;
|
|
||||||
|
|
||||||
public virtual void Dispose()
|
|
||||||
{
|
|
||||||
if (IsDisposed)
|
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(nameof(BackendSurface));
|
|
||||||
}
|
|
||||||
|
|
||||||
IsDisposed = true;
|
|
||||||
|
|
||||||
if (_display != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
XCloseDisplay(_display);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
using FluentAvalonia.Interop;
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend
|
|
||||||
{
|
|
||||||
public static class Interop
|
|
||||||
{
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct XWindowAttributes
|
|
||||||
{
|
|
||||||
public int x;
|
|
||||||
public int y;
|
|
||||||
public int width;
|
|
||||||
public int height;
|
|
||||||
public int border_width;
|
|
||||||
public int depth;
|
|
||||||
public IntPtr visual;
|
|
||||||
public IntPtr root;
|
|
||||||
public int c_class;
|
|
||||||
public int bit_gravity;
|
|
||||||
public int win_gravity;
|
|
||||||
public int backing_store;
|
|
||||||
public IntPtr backing_planes;
|
|
||||||
public IntPtr backing_pixel;
|
|
||||||
public int save_under;
|
|
||||||
public IntPtr colormap;
|
|
||||||
public int map_installed;
|
|
||||||
public int map_state;
|
|
||||||
public IntPtr all_event_masks;
|
|
||||||
public IntPtr your_event_mask;
|
|
||||||
public IntPtr do_not_propagate_mask;
|
|
||||||
public int override_direct;
|
|
||||||
public IntPtr screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern bool GetClientRect(IntPtr hwnd, out RECT lpRect);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6")]
|
|
||||||
public static extern int XCloseDisplay(IntPtr display);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6")]
|
|
||||||
public static extern int XGetWindowAttributes(IntPtr display, IntPtr window, ref XWindowAttributes attributes);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6")]
|
|
||||||
public static extern IntPtr XOpenDisplay(IntPtr display);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Skia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Backend.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend
|
|
||||||
{
|
|
||||||
public static class SkiaGpuFactory
|
|
||||||
{
|
|
||||||
public static ISkiaGpu CreateVulkanGpu()
|
|
||||||
{
|
|
||||||
var skiaOptions = AvaloniaLocator.Current.GetService<SkiaOptions>() ?? new SkiaOptions();
|
|
||||||
var platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
|
|
||||||
if (platformInterface == null)
|
|
||||||
{
|
|
||||||
VulkanPlatformInterface.TryInitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
var gpu = new VulkanSkiaGpu(skiaOptions.MaxGpuResourceSizeBytes);
|
|
||||||
AvaloniaLocator.CurrentMutable.Bind<VulkanSkiaGpu>().ToConstant(gpu);
|
|
||||||
|
|
||||||
return gpu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
public static class ResultExtensions
|
|
||||||
{
|
|
||||||
public static void ThrowOnError(this Result result)
|
|
||||||
{
|
|
||||||
// Only negative result codes are errors.
|
|
||||||
if ((int)result < (int)Result.Success)
|
|
||||||
{
|
|
||||||
throw new Exception($"Unexpected API error \"{result}\".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,201 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Skia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using SkiaSharp;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanRenderTarget : ISkiaGpuRenderTarget
|
|
||||||
{
|
|
||||||
public GRContext GrContext { get; private set; }
|
|
||||||
|
|
||||||
private readonly VulkanSurfaceRenderTarget _surface;
|
|
||||||
private readonly VulkanPlatformInterface _vulkanPlatformInterface;
|
|
||||||
private readonly IVulkanPlatformSurface _vulkanPlatformSurface;
|
|
||||||
private GRVkBackendContext _grVkBackend;
|
|
||||||
|
|
||||||
public VulkanRenderTarget(VulkanPlatformInterface vulkanPlatformInterface, IVulkanPlatformSurface vulkanPlatformSurface)
|
|
||||||
{
|
|
||||||
_surface = vulkanPlatformInterface.CreateRenderTarget(vulkanPlatformSurface);
|
|
||||||
_vulkanPlatformInterface = vulkanPlatformInterface;
|
|
||||||
_vulkanPlatformSurface = vulkanPlatformSurface;
|
|
||||||
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Initialize()
|
|
||||||
{
|
|
||||||
GRVkGetProcedureAddressDelegate getProc = GetVulkanProcAddress;
|
|
||||||
|
|
||||||
_grVkBackend = new GRVkBackendContext()
|
|
||||||
{
|
|
||||||
VkInstance = _surface.Device.Handle,
|
|
||||||
VkPhysicalDevice = _vulkanPlatformInterface.PhysicalDevice.Handle,
|
|
||||||
VkDevice = _surface.Device.Handle,
|
|
||||||
VkQueue = _surface.Device.Queue.Handle,
|
|
||||||
GraphicsQueueIndex = _vulkanPlatformInterface.PhysicalDevice.QueueFamilyIndex,
|
|
||||||
GetProcedureAddress = getProc
|
|
||||||
};
|
|
||||||
|
|
||||||
GrContext = GRContext.CreateVulkan(_grVkBackend);
|
|
||||||
|
|
||||||
var gpu = AvaloniaLocator.Current.GetService<VulkanSkiaGpu>();
|
|
||||||
|
|
||||||
if (gpu.MaxResourceBytes.HasValue)
|
|
||||||
{
|
|
||||||
GrContext.SetResourceCacheLimit(gpu.MaxResourceBytes.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntPtr GetVulkanProcAddress(string name, IntPtr instanceHandle, IntPtr deviceHandle)
|
|
||||||
{
|
|
||||||
IntPtr addr;
|
|
||||||
|
|
||||||
if (deviceHandle != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
addr = _vulkanPlatformInterface.Api.GetDeviceProcAddr(new Device(deviceHandle), name);
|
|
||||||
|
|
||||||
if (addr != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = _vulkanPlatformInterface.Api.GetDeviceProcAddr(new Device(_surface.Device.Handle), name);
|
|
||||||
|
|
||||||
if (addr != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = _vulkanPlatformInterface.Api.GetInstanceProcAddr(new Instance(_vulkanPlatformInterface.Instance.Handle), name);
|
|
||||||
|
|
||||||
if (addr == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
addr = _vulkanPlatformInterface.Api.GetInstanceProcAddr(new Instance(instanceHandle), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_grVkBackend.Dispose();
|
|
||||||
GrContext.Dispose();
|
|
||||||
_surface.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISkiaGpuRenderSession BeginRenderingSession()
|
|
||||||
{
|
|
||||||
var session = _surface.BeginDraw(_vulkanPlatformSurface.Scaling);
|
|
||||||
bool success = false;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var disp = session.Display;
|
|
||||||
var api = session.Api;
|
|
||||||
|
|
||||||
var size = session.Size;
|
|
||||||
var scaling = session.Scaling;
|
|
||||||
if (size.Width <= 0 || size.Height <= 0 || scaling < 0)
|
|
||||||
{
|
|
||||||
size = new Avalonia.PixelSize(1, 1);
|
|
||||||
scaling = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (GrContext)
|
|
||||||
{
|
|
||||||
GrContext.ResetContext();
|
|
||||||
|
|
||||||
var image = _surface.GetImage();
|
|
||||||
|
|
||||||
var imageInfo = new GRVkImageInfo()
|
|
||||||
{
|
|
||||||
CurrentQueueFamily = disp.QueueFamilyIndex,
|
|
||||||
Format = (uint)image.Format,
|
|
||||||
Image = image.Handle,
|
|
||||||
ImageLayout = (uint)image.CurrentLayout,
|
|
||||||
ImageTiling = (uint)image.Tiling,
|
|
||||||
ImageUsageFlags = _surface.UsageFlags,
|
|
||||||
LevelCount = _surface.MipLevels,
|
|
||||||
SampleCount = 1,
|
|
||||||
Protected = false,
|
|
||||||
Alloc = new GRVkAlloc()
|
|
||||||
{
|
|
||||||
Memory = image.MemoryHandle,
|
|
||||||
Flags = 0,
|
|
||||||
Offset = 0,
|
|
||||||
Size = _surface.MemorySize
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var renderTarget =
|
|
||||||
new GRBackendRenderTarget((int)size.Width, (int)size.Height, 1,
|
|
||||||
imageInfo);
|
|
||||||
var surface = SKSurface.Create(GrContext, renderTarget,
|
|
||||||
GRSurfaceOrigin.TopLeft,
|
|
||||||
_surface.IsRgba ? SKColorType.Rgba8888 : SKColorType.Bgra8888, SKColorSpace.CreateSrgb());
|
|
||||||
|
|
||||||
if (surface == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(
|
|
||||||
"Surface can't be created with the provided render target");
|
|
||||||
}
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
|
|
||||||
return new VulkanGpuSession(GrContext, renderTarget, surface, session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
session.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsCorrupted { get; }
|
|
||||||
|
|
||||||
internal class VulkanGpuSession : ISkiaGpuRenderSession
|
|
||||||
{
|
|
||||||
private readonly GRBackendRenderTarget _backendRenderTarget;
|
|
||||||
private readonly VulkanSurfaceRenderingSession _vulkanSession;
|
|
||||||
|
|
||||||
public VulkanGpuSession(GRContext grContext,
|
|
||||||
GRBackendRenderTarget backendRenderTarget,
|
|
||||||
SKSurface surface,
|
|
||||||
VulkanSurfaceRenderingSession vulkanSession)
|
|
||||||
{
|
|
||||||
GrContext = grContext;
|
|
||||||
_backendRenderTarget = backendRenderTarget;
|
|
||||||
SkSurface = surface;
|
|
||||||
_vulkanSession = vulkanSession;
|
|
||||||
|
|
||||||
SurfaceOrigin = GRSurfaceOrigin.TopLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
lock (_vulkanSession.Display.Lock)
|
|
||||||
{
|
|
||||||
SkSurface.Canvas.Flush();
|
|
||||||
|
|
||||||
SkSurface.Dispose();
|
|
||||||
_backendRenderTarget.Dispose();
|
|
||||||
GrContext.Flush();
|
|
||||||
|
|
||||||
_vulkanSession.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GRContext GrContext { get; }
|
|
||||||
public SKSurface SkSurface { get; }
|
|
||||||
public double ScaleFactor => _vulkanSession.Scaling;
|
|
||||||
public GRSurfaceOrigin SurfaceOrigin { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,61 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Skia;
|
|
||||||
using Avalonia.X11;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using SkiaSharp;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
|
||||||
{
|
|
||||||
public class VulkanSkiaGpu : ISkiaGpu
|
|
||||||
{
|
|
||||||
private readonly VulkanPlatformInterface _vulkan;
|
|
||||||
public long? MaxResourceBytes { get; }
|
|
||||||
|
|
||||||
public VulkanSkiaGpu(long? maxResourceBytes)
|
|
||||||
{
|
|
||||||
_vulkan = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
MaxResourceBytes = maxResourceBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISkiaGpuRenderTarget TryCreateRenderTarget(IEnumerable<object> surfaces)
|
|
||||||
{
|
|
||||||
foreach (var surface in surfaces)
|
|
||||||
{
|
|
||||||
VulkanWindowSurface window;
|
|
||||||
|
|
||||||
if (surface is IPlatformHandle handle)
|
|
||||||
{
|
|
||||||
window = new VulkanWindowSurface(handle.Handle);
|
|
||||||
}
|
|
||||||
else if (surface is X11FramebufferSurface x11FramebufferSurface)
|
|
||||||
{
|
|
||||||
// As of Avalonia 0.10.13, an IPlatformHandle isn't passed for linux, so use reflection to otherwise get the window id
|
|
||||||
var xId = (IntPtr)x11FramebufferSurface.GetType().GetField(
|
|
||||||
"_xid",
|
|
||||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(x11FramebufferSurface);
|
|
||||||
|
|
||||||
window = new VulkanWindowSurface(xId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
VulkanRenderTarget vulkanRenderTarget = new VulkanRenderTarget(_vulkan, window);
|
|
||||||
|
|
||||||
return vulkanRenderTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISkiaSurface TryCreateSurface(PixelSize size, ISkiaGpuRenderSession session)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,53 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using Silk.NET.Vulkan.Extensions.KHR;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanWindowSurface : BackendSurface, IVulkanPlatformSurface
|
|
||||||
{
|
|
||||||
public float Scaling => (float)Program.ActualScaleFactor;
|
|
||||||
|
|
||||||
public PixelSize SurfaceSize => Size;
|
|
||||||
|
|
||||||
public VulkanWindowSurface(IntPtr handle) : base(handle)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe SurfaceKHR CreateSurface(VulkanInstance instance)
|
|
||||||
{
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrWin32Surface surfaceExtension))
|
|
||||||
{
|
|
||||||
var createInfo = new Win32SurfaceCreateInfoKHR() { Hinstance = 0, Hwnd = Handle, SType = StructureType.Win32SurfaceCreateInfoKhr };
|
|
||||||
|
|
||||||
surfaceExtension.CreateWin32Surface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();
|
|
||||||
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrXlibSurface surfaceExtension))
|
|
||||||
{
|
|
||||||
var createInfo = new XlibSurfaceCreateInfoKHR()
|
|
||||||
{
|
|
||||||
SType = StructureType.XlibSurfaceCreateInfoKhr,
|
|
||||||
Dpy = (nint*)Display,
|
|
||||||
Window = Handle
|
|
||||||
};
|
|
||||||
|
|
||||||
surfaceExtension.CreateXlibSurface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();
|
|
||||||
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new PlatformNotSupportedException("The current platform does not support surface creation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan.Surfaces
|
|
||||||
{
|
|
||||||
public interface IVulkanPlatformSurface : IDisposable
|
|
||||||
{
|
|
||||||
float Scaling { get; }
|
|
||||||
PixelSize SurfaceSize { get; }
|
|
||||||
SurfaceKHR CreateSurface(VulkanInstance instance);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,134 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Ryujinx.Graphics.Vulkan;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan.Surfaces
|
|
||||||
{
|
|
||||||
internal class VulkanSurfaceRenderTarget : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanPlatformInterface _platformInterface;
|
|
||||||
private readonly Format _format;
|
|
||||||
|
|
||||||
private VulkanCommandBufferPool.VulkanCommandBuffer _commandBuffer;
|
|
||||||
private VulkanImage Image { get; set; }
|
|
||||||
private object _lock = new object();
|
|
||||||
|
|
||||||
public uint MipLevels => Image.MipLevels;
|
|
||||||
public VulkanDevice Device { get; }
|
|
||||||
|
|
||||||
public VulkanSurfaceRenderTarget(VulkanPlatformInterface platformInterface, VulkanSurface surface)
|
|
||||||
{
|
|
||||||
_platformInterface = platformInterface;
|
|
||||||
|
|
||||||
var device = VulkanInitialization.CreateDevice(platformInterface.Api,
|
|
||||||
platformInterface.PhysicalDevice.InternalHandle,
|
|
||||||
platformInterface.PhysicalDevice.QueueFamilyIndex,
|
|
||||||
VulkanInitialization.GetSupportedExtensions(platformInterface.Api, platformInterface.PhysicalDevice.InternalHandle),
|
|
||||||
platformInterface.PhysicalDevice.QueueCount);
|
|
||||||
|
|
||||||
Device = new VulkanDevice(device, platformInterface.PhysicalDevice, platformInterface.Api);
|
|
||||||
|
|
||||||
Display = VulkanDisplay.CreateDisplay(
|
|
||||||
platformInterface.Instance,
|
|
||||||
Device,
|
|
||||||
platformInterface.PhysicalDevice,
|
|
||||||
surface);
|
|
||||||
Surface = surface;
|
|
||||||
|
|
||||||
// Skia seems to only create surfaces from images with unorm format
|
|
||||||
IsRgba = Display.SurfaceFormat.Format >= Format.R8G8B8A8Unorm &&
|
|
||||||
Display.SurfaceFormat.Format <= Format.R8G8B8A8Srgb;
|
|
||||||
|
|
||||||
_format = IsRgba ? Format.R8G8B8A8Unorm : Format.B8G8R8A8Unorm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsRgba { get; }
|
|
||||||
|
|
||||||
public uint ImageFormat => (uint)_format;
|
|
||||||
|
|
||||||
public ulong MemorySize => Image.MemorySize;
|
|
||||||
|
|
||||||
public VulkanDisplay Display { get; private set; }
|
|
||||||
|
|
||||||
public VulkanSurface Surface { get; private set; }
|
|
||||||
|
|
||||||
public uint UsageFlags => Image.UsageFlags;
|
|
||||||
|
|
||||||
public PixelSize Size { get; private set; }
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
DestroyImage();
|
|
||||||
Display?.Dispose();
|
|
||||||
Surface?.Dispose();
|
|
||||||
Device?.Dispose();
|
|
||||||
|
|
||||||
Display = null;
|
|
||||||
Surface = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanSurfaceRenderingSession BeginDraw(float scaling)
|
|
||||||
{
|
|
||||||
if (Image == null)
|
|
||||||
{
|
|
||||||
RecreateImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
_commandBuffer?.WaitForFence();
|
|
||||||
_commandBuffer = null;
|
|
||||||
|
|
||||||
var session = new VulkanSurfaceRenderingSession(Display, Device, this, scaling);
|
|
||||||
|
|
||||||
Image.TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr);
|
|
||||||
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RecreateImage()
|
|
||||||
{
|
|
||||||
DestroyImage();
|
|
||||||
CreateImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateImage()
|
|
||||||
{
|
|
||||||
Size = Display.Size;
|
|
||||||
|
|
||||||
Image = new VulkanImage(Device, _platformInterface.PhysicalDevice, Display.CommandBufferPool, ImageFormat, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyImage()
|
|
||||||
{
|
|
||||||
_commandBuffer?.WaitForFence();
|
|
||||||
_commandBuffer = null;
|
|
||||||
Image?.Dispose();
|
|
||||||
Image = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanImage GetImage()
|
|
||||||
{
|
|
||||||
return Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EndDraw()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
if (Display == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_commandBuffer = Display.StartPresentation();
|
|
||||||
|
|
||||||
Display.BlitImageToCurrentImage(this, _commandBuffer.InternalHandle);
|
|
||||||
|
|
||||||
Display.EndPresentation(_commandBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,215 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanCommandBufferPool : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
private readonly CommandPool _commandPool;
|
|
||||||
|
|
||||||
private readonly List<VulkanCommandBuffer> _usedCommandBuffers = new();
|
|
||||||
private readonly object _lock = new object();
|
|
||||||
|
|
||||||
public unsafe VulkanCommandBufferPool(VulkanDevice device, VulkanPhysicalDevice physicalDevice)
|
|
||||||
{
|
|
||||||
_device = device;
|
|
||||||
|
|
||||||
var commandPoolCreateInfo = new CommandPoolCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.CommandPoolCreateInfo,
|
|
||||||
Flags = CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit,
|
|
||||||
QueueFamilyIndex = physicalDevice.QueueFamilyIndex
|
|
||||||
};
|
|
||||||
|
|
||||||
device.Api.CreateCommandPool(_device.InternalHandle, commandPoolCreateInfo, null, out _commandPool)
|
|
||||||
.ThrowOnError();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandBuffer AllocateCommandBuffer()
|
|
||||||
{
|
|
||||||
var commandBufferAllocateInfo = new CommandBufferAllocateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.CommandBufferAllocateInfo,
|
|
||||||
CommandPool = _commandPool,
|
|
||||||
CommandBufferCount = 1,
|
|
||||||
Level = CommandBufferLevel.Primary
|
|
||||||
};
|
|
||||||
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
_device.Api.AllocateCommandBuffers(_device.InternalHandle, commandBufferAllocateInfo, out var commandBuffer);
|
|
||||||
|
|
||||||
return commandBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanCommandBuffer CreateCommandBuffer()
|
|
||||||
{
|
|
||||||
return new(_device, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FreeUsedCommandBuffers()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
foreach (var usedCommandBuffer in _usedCommandBuffers)
|
|
||||||
{
|
|
||||||
usedCommandBuffer.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
_usedCommandBuffers.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisposeCommandBuffer(VulkanCommandBuffer commandBuffer)
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
_usedCommandBuffers.Add(commandBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
FreeUsedCommandBuffers();
|
|
||||||
_device.Api.DestroyCommandPool(_device.InternalHandle, _commandPool, Span<AllocationCallbacks>.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class VulkanCommandBuffer : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanCommandBufferPool _commandBufferPool;
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
private readonly Fence _fence;
|
|
||||||
private bool _hasEnded;
|
|
||||||
private bool _hasStarted;
|
|
||||||
private bool _isDisposed;
|
|
||||||
private object _lock = new object();
|
|
||||||
|
|
||||||
public IntPtr Handle => InternalHandle.Handle;
|
|
||||||
|
|
||||||
internal CommandBuffer InternalHandle { get; }
|
|
||||||
|
|
||||||
internal unsafe VulkanCommandBuffer(VulkanDevice device, VulkanCommandBufferPool commandBufferPool)
|
|
||||||
{
|
|
||||||
_device = device;
|
|
||||||
_commandBufferPool = commandBufferPool;
|
|
||||||
|
|
||||||
InternalHandle = _commandBufferPool.AllocateCommandBuffer();
|
|
||||||
|
|
||||||
var fenceCreateInfo = new FenceCreateInfo()
|
|
||||||
{
|
|
||||||
SType = StructureType.FenceCreateInfo,
|
|
||||||
Flags = FenceCreateFlags.FenceCreateSignaledBit
|
|
||||||
};
|
|
||||||
|
|
||||||
device.Api.CreateFence(device.InternalHandle, fenceCreateInfo, null, out _fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WaitForFence()
|
|
||||||
{
|
|
||||||
if (_isDisposed)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
if (!_isDisposed)
|
|
||||||
{
|
|
||||||
_device.Api.WaitForFences(_device.InternalHandle, 1, _fence, true, ulong.MaxValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BeginRecording()
|
|
||||||
{
|
|
||||||
if (!_hasStarted)
|
|
||||||
{
|
|
||||||
_hasStarted = true;
|
|
||||||
|
|
||||||
var beginInfo = new CommandBufferBeginInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.CommandBufferBeginInfo,
|
|
||||||
Flags = CommandBufferUsageFlags.CommandBufferUsageOneTimeSubmitBit
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api.BeginCommandBuffer(InternalHandle, beginInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EndRecording()
|
|
||||||
{
|
|
||||||
if (_hasStarted && !_hasEnded)
|
|
||||||
{
|
|
||||||
_hasEnded = true;
|
|
||||||
|
|
||||||
_device.Api.EndCommandBuffer(InternalHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Submit()
|
|
||||||
{
|
|
||||||
Submit(null, null, null, _fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe void Submit(
|
|
||||||
ReadOnlySpan<Semaphore> waitSemaphores,
|
|
||||||
ReadOnlySpan<PipelineStageFlags> waitDstStageMask,
|
|
||||||
ReadOnlySpan<Semaphore> signalSemaphores,
|
|
||||||
Fence? fence = null)
|
|
||||||
{
|
|
||||||
EndRecording();
|
|
||||||
|
|
||||||
if (!fence.HasValue)
|
|
||||||
{
|
|
||||||
fence = _fence;
|
|
||||||
}
|
|
||||||
|
|
||||||
fixed (Semaphore* pWaitSemaphores = waitSemaphores, pSignalSemaphores = signalSemaphores)
|
|
||||||
{
|
|
||||||
fixed (PipelineStageFlags* pWaitDstStageMask = waitDstStageMask)
|
|
||||||
{
|
|
||||||
var commandBuffer = InternalHandle;
|
|
||||||
var submitInfo = new SubmitInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.SubmitInfo,
|
|
||||||
WaitSemaphoreCount = waitSemaphores != null ? (uint)waitSemaphores.Length : 0,
|
|
||||||
PWaitSemaphores = pWaitSemaphores,
|
|
||||||
PWaitDstStageMask = pWaitDstStageMask,
|
|
||||||
CommandBufferCount = 1,
|
|
||||||
PCommandBuffers = &commandBuffer,
|
|
||||||
SignalSemaphoreCount = signalSemaphores != null ? (uint)signalSemaphores.Length : 0,
|
|
||||||
PSignalSemaphores = pSignalSemaphores,
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api.ResetFences(_device.InternalHandle, 1, fence.Value);
|
|
||||||
|
|
||||||
_device.Submit(submitInfo, fence.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_commandBufferPool.DisposeCommandBuffer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
if (!_isDisposed)
|
|
||||||
{
|
|
||||||
_isDisposed = true;
|
|
||||||
|
|
||||||
_device.Api.WaitForFences(_device.InternalHandle, 1, _fence, true, ulong.MaxValue);
|
|
||||||
_device.Api.FreeCommandBuffers(_device.InternalHandle, _commandBufferPool._commandPool, 1, InternalHandle);
|
|
||||||
_device.Api.DestroyFence(_device.InternalHandle, _fence, Span<AllocationCallbacks>.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanDevice : IDisposable
|
|
||||||
{
|
|
||||||
private static object _lock = new object();
|
|
||||||
|
|
||||||
public VulkanDevice(Device apiHandle, VulkanPhysicalDevice physicalDevice, Vk api)
|
|
||||||
{
|
|
||||||
InternalHandle = apiHandle;
|
|
||||||
Api = api;
|
|
||||||
|
|
||||||
api.GetDeviceQueue(apiHandle, physicalDevice.QueueFamilyIndex, 0, out var queue);
|
|
||||||
|
|
||||||
Queue = new VulkanQueue(this, queue);
|
|
||||||
|
|
||||||
PresentQueue = Queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Handle => InternalHandle.Handle;
|
|
||||||
|
|
||||||
internal Device InternalHandle { get; }
|
|
||||||
public Vk Api { get; }
|
|
||||||
|
|
||||||
public VulkanQueue Queue { get; private set; }
|
|
||||||
public VulkanQueue PresentQueue { get; }
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
WaitIdle();
|
|
||||||
Queue = null;
|
|
||||||
Api.DestroyDevice(InternalHandle, Span<AllocationCallbacks>.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Submit(SubmitInfo submitInfo, Fence fence = default)
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
Api.QueueSubmit(Queue.InternalHandle, 1, submitInfo, fence).ThrowOnError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WaitIdle()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
Api.DeviceWaitIdle(InternalHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void QueueWaitIdle()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
Api.QueueWaitIdle(Queue.InternalHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Lock => _lock;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,456 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using Avalonia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using Silk.NET.Vulkan.Extensions.KHR;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanDisplay : IDisposable
|
|
||||||
{
|
|
||||||
private static KhrSwapchain _swapchainExtension;
|
|
||||||
private readonly VulkanInstance _instance;
|
|
||||||
private readonly VulkanPhysicalDevice _physicalDevice;
|
|
||||||
private readonly VulkanSemaphorePair _semaphorePair;
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
private uint _nextImage;
|
|
||||||
private readonly VulkanSurface _surface;
|
|
||||||
private SurfaceFormatKHR _surfaceFormat;
|
|
||||||
private SwapchainKHR _swapchain;
|
|
||||||
private Extent2D _swapchainExtent;
|
|
||||||
private Image[] _swapchainImages;
|
|
||||||
private ImageView[] _swapchainImageViews = Array.Empty<ImageView>();
|
|
||||||
private bool _vsyncStateChanged;
|
|
||||||
private bool _vsyncEnabled;
|
|
||||||
private bool _surfaceChanged;
|
|
||||||
|
|
||||||
public event EventHandler Presented;
|
|
||||||
|
|
||||||
public VulkanCommandBufferPool CommandBufferPool { get; set; }
|
|
||||||
|
|
||||||
public object Lock => _device.Lock;
|
|
||||||
|
|
||||||
private VulkanDisplay(VulkanInstance instance, VulkanDevice device,
|
|
||||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface, SwapchainKHR swapchain,
|
|
||||||
Extent2D swapchainExtent)
|
|
||||||
{
|
|
||||||
_instance = instance;
|
|
||||||
_device = device;
|
|
||||||
_physicalDevice = physicalDevice;
|
|
||||||
_swapchain = swapchain;
|
|
||||||
_swapchainExtent = swapchainExtent;
|
|
||||||
_surface = surface;
|
|
||||||
|
|
||||||
CreateSwapchainImages();
|
|
||||||
|
|
||||||
_semaphorePair = new VulkanSemaphorePair(_device);
|
|
||||||
|
|
||||||
CommandBufferPool = new VulkanCommandBufferPool(device, physicalDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PixelSize Size { get; private set; }
|
|
||||||
public uint QueueFamilyIndex => _physicalDevice.QueueFamilyIndex;
|
|
||||||
|
|
||||||
internal SurfaceFormatKHR SurfaceFormat
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_surfaceFormat.Format == Format.Undefined)
|
|
||||||
{
|
|
||||||
_surfaceFormat = _surface.GetSurfaceFormat(_physicalDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _surfaceFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_device.WaitIdle();
|
|
||||||
_semaphorePair?.Dispose();
|
|
||||||
DestroyCurrentImageViews();
|
|
||||||
_swapchainExtension.DestroySwapchain(_device.InternalHandle, _swapchain, Span<AllocationCallbacks>.Empty);
|
|
||||||
CommandBufferPool.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsSurfaceChanged()
|
|
||||||
{
|
|
||||||
var changed = _surfaceChanged;
|
|
||||||
_surfaceChanged = false;
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe SwapchainKHR CreateSwapchain(VulkanInstance instance, VulkanDevice device,
|
|
||||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface, out Extent2D swapchainExtent,
|
|
||||||
SwapchainKHR? oldswapchain = null, bool vsyncEnabled = true)
|
|
||||||
{
|
|
||||||
if (_swapchainExtension == null)
|
|
||||||
{
|
|
||||||
instance.Api.TryGetDeviceExtension(instance.InternalHandle, device.InternalHandle, out _swapchainExtension);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!surface.CanSurfacePresent(physicalDevice))
|
|
||||||
{
|
|
||||||
Thread.Sleep(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfaceCapabilities(physicalDevice.InternalHandle,
|
|
||||||
surface.ApiHandle, out var capabilities);
|
|
||||||
|
|
||||||
var imageCount = capabilities.MinImageCount + 1;
|
|
||||||
if (capabilities.MaxImageCount > 0 && imageCount > capabilities.MaxImageCount)
|
|
||||||
{
|
|
||||||
imageCount = capabilities.MaxImageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
var surfaceFormat = surface.GetSurfaceFormat(physicalDevice);
|
|
||||||
|
|
||||||
bool supportsIdentityTransform = capabilities.SupportedTransforms.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformIdentityBitKhr);
|
|
||||||
bool isRotated = capabilities.CurrentTransform.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformRotate90BitKhr) ||
|
|
||||||
capabilities.CurrentTransform.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformRotate270BitKhr);
|
|
||||||
|
|
||||||
swapchainExtent = GetSwapchainExtent(surface, capabilities);
|
|
||||||
|
|
||||||
CompositeAlphaFlagsKHR compositeAlphaFlags = GetSuitableCompositeAlphaFlags(capabilities);
|
|
||||||
|
|
||||||
PresentModeKHR presentMode = GetSuitablePresentMode(physicalDevice, surface, vsyncEnabled);
|
|
||||||
|
|
||||||
var swapchainCreateInfo = new SwapchainCreateInfoKHR
|
|
||||||
{
|
|
||||||
SType = StructureType.SwapchainCreateInfoKhr,
|
|
||||||
Surface = surface.ApiHandle,
|
|
||||||
MinImageCount = imageCount,
|
|
||||||
ImageFormat = surfaceFormat.Format,
|
|
||||||
ImageColorSpace = surfaceFormat.ColorSpace,
|
|
||||||
ImageExtent = swapchainExtent,
|
|
||||||
ImageUsage =
|
|
||||||
ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit,
|
|
||||||
ImageSharingMode = SharingMode.Exclusive,
|
|
||||||
ImageArrayLayers = 1,
|
|
||||||
PreTransform = supportsIdentityTransform && isRotated ?
|
|
||||||
SurfaceTransformFlagsKHR.SurfaceTransformIdentityBitKhr :
|
|
||||||
capabilities.CurrentTransform,
|
|
||||||
CompositeAlpha = compositeAlphaFlags,
|
|
||||||
PresentMode = presentMode,
|
|
||||||
Clipped = true,
|
|
||||||
OldSwapchain = oldswapchain ?? new SwapchainKHR()
|
|
||||||
};
|
|
||||||
|
|
||||||
_swapchainExtension.CreateSwapchain(device.InternalHandle, swapchainCreateInfo, null, out var swapchain)
|
|
||||||
.ThrowOnError();
|
|
||||||
|
|
||||||
if (oldswapchain != null)
|
|
||||||
{
|
|
||||||
_swapchainExtension.DestroySwapchain(device.InternalHandle, oldswapchain.Value, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return swapchain;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe Extent2D GetSwapchainExtent(VulkanSurface surface, SurfaceCapabilitiesKHR capabilities)
|
|
||||||
{
|
|
||||||
Extent2D swapchainExtent;
|
|
||||||
if (capabilities.CurrentExtent.Width != uint.MaxValue)
|
|
||||||
{
|
|
||||||
swapchainExtent = capabilities.CurrentExtent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var surfaceSize = surface.SurfaceSize;
|
|
||||||
|
|
||||||
var width = Math.Clamp((uint)surfaceSize.Width, capabilities.MinImageExtent.Width, capabilities.MaxImageExtent.Width);
|
|
||||||
var height = Math.Clamp((uint)surfaceSize.Height, capabilities.MinImageExtent.Height, capabilities.MaxImageExtent.Height);
|
|
||||||
|
|
||||||
swapchainExtent = new Extent2D(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
return swapchainExtent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe CompositeAlphaFlagsKHR GetSuitableCompositeAlphaFlags(SurfaceCapabilitiesKHR capabilities)
|
|
||||||
{
|
|
||||||
var compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaOpaqueBitKhr;
|
|
||||||
|
|
||||||
if (capabilities.SupportedCompositeAlpha.HasFlag(CompositeAlphaFlagsKHR.CompositeAlphaPostMultipliedBitKhr))
|
|
||||||
{
|
|
||||||
compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaPostMultipliedBitKhr;
|
|
||||||
}
|
|
||||||
else if (capabilities.SupportedCompositeAlpha.HasFlag(CompositeAlphaFlagsKHR.CompositeAlphaPreMultipliedBitKhr))
|
|
||||||
{
|
|
||||||
compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaPreMultipliedBitKhr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return compositeAlphaFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe PresentModeKHR GetSuitablePresentMode(VulkanPhysicalDevice physicalDevice, VulkanSurface surface, bool vsyncEnabled)
|
|
||||||
{
|
|
||||||
uint presentModesCount;
|
|
||||||
|
|
||||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfacePresentModes(physicalDevice.InternalHandle,
|
|
||||||
surface.ApiHandle,
|
|
||||||
&presentModesCount, null);
|
|
||||||
|
|
||||||
var presentModes = new PresentModeKHR[presentModesCount];
|
|
||||||
|
|
||||||
fixed (PresentModeKHR* pPresentModes = presentModes)
|
|
||||||
{
|
|
||||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfacePresentModes(physicalDevice.InternalHandle,
|
|
||||||
surface.ApiHandle, &presentModesCount, pPresentModes);
|
|
||||||
}
|
|
||||||
|
|
||||||
var modes = presentModes.ToList();
|
|
||||||
|
|
||||||
if (!vsyncEnabled && modes.Contains(PresentModeKHR.PresentModeImmediateKhr))
|
|
||||||
{
|
|
||||||
return PresentModeKHR.PresentModeImmediateKhr;
|
|
||||||
}
|
|
||||||
else if (modes.Contains(PresentModeKHR.PresentModeMailboxKhr))
|
|
||||||
{
|
|
||||||
return PresentModeKHR.PresentModeMailboxKhr;
|
|
||||||
}
|
|
||||||
else if (modes.Contains(PresentModeKHR.PresentModeFifoKhr))
|
|
||||||
{
|
|
||||||
return PresentModeKHR.PresentModeFifoKhr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return PresentModeKHR.PresentModeImmediateKhr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static VulkanDisplay CreateDisplay(VulkanInstance instance, VulkanDevice device,
|
|
||||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface)
|
|
||||||
{
|
|
||||||
var swapchain = CreateSwapchain(instance, device, physicalDevice, surface, out var extent, null, true);
|
|
||||||
|
|
||||||
return new VulkanDisplay(instance, device, physicalDevice, surface, swapchain, extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe void CreateSwapchainImages()
|
|
||||||
{
|
|
||||||
DestroyCurrentImageViews();
|
|
||||||
|
|
||||||
Size = new PixelSize((int)_swapchainExtent.Width, (int)_swapchainExtent.Height);
|
|
||||||
|
|
||||||
uint imageCount = 0;
|
|
||||||
|
|
||||||
_swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, null);
|
|
||||||
|
|
||||||
_swapchainImages = new Image[imageCount];
|
|
||||||
|
|
||||||
fixed (Image* pSwapchainImages = _swapchainImages)
|
|
||||||
{
|
|
||||||
_swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, pSwapchainImages);
|
|
||||||
}
|
|
||||||
|
|
||||||
_swapchainImageViews = new ImageView[imageCount];
|
|
||||||
|
|
||||||
var surfaceFormat = SurfaceFormat;
|
|
||||||
|
|
||||||
for (var i = 0; i < imageCount; i++)
|
|
||||||
{
|
|
||||||
_swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyCurrentImageViews()
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _swapchainImageViews.Length; i++)
|
|
||||||
{
|
|
||||||
_instance.Api.DestroyImageView(_device.InternalHandle, _swapchainImageViews[i], Span<AllocationCallbacks>.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void ChangeVSyncMode(bool vsyncEnabled)
|
|
||||||
{
|
|
||||||
_vsyncStateChanged = true;
|
|
||||||
_vsyncEnabled = vsyncEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Recreate()
|
|
||||||
{
|
|
||||||
_device.WaitIdle();
|
|
||||||
_swapchain = CreateSwapchain(_instance, _device, _physicalDevice, _surface, out _swapchainExtent, _swapchain, _vsyncEnabled);
|
|
||||||
|
|
||||||
CreateSwapchainImages();
|
|
||||||
|
|
||||||
_surfaceChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe ImageView CreateSwapchainImageView(Image swapchainImage, Format format)
|
|
||||||
{
|
|
||||||
var componentMapping = new ComponentMapping(
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity);
|
|
||||||
|
|
||||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, 1, 0, 1);
|
|
||||||
|
|
||||||
var imageCreateInfo = new ImageViewCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageViewCreateInfo,
|
|
||||||
Image = swapchainImage,
|
|
||||||
ViewType = ImageViewType.ImageViewType2D,
|
|
||||||
Format = format,
|
|
||||||
Components = componentMapping,
|
|
||||||
SubresourceRange = subresourceRange
|
|
||||||
};
|
|
||||||
|
|
||||||
_instance.Api.CreateImageView(_device.InternalHandle, imageCreateInfo, null, out var imageView).ThrowOnError();
|
|
||||||
return imageView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool EnsureSwapchainAvailable()
|
|
||||||
{
|
|
||||||
if (Size != _surface.SurfaceSize || _vsyncStateChanged)
|
|
||||||
{
|
|
||||||
_vsyncStateChanged = false;
|
|
||||||
|
|
||||||
Recreate();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal VulkanCommandBufferPool.VulkanCommandBuffer StartPresentation()
|
|
||||||
{
|
|
||||||
_nextImage = 0;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var acquireResult = _swapchainExtension.AcquireNextImage(
|
|
||||||
_device.InternalHandle,
|
|
||||||
_swapchain,
|
|
||||||
ulong.MaxValue,
|
|
||||||
_semaphorePair.ImageAvailableSemaphore,
|
|
||||||
new Fence(),
|
|
||||||
ref _nextImage);
|
|
||||||
|
|
||||||
if (acquireResult == Result.ErrorOutOfDateKhr ||
|
|
||||||
acquireResult == Result.SuboptimalKhr)
|
|
||||||
{
|
|
||||||
Recreate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
acquireResult.ThrowOnError();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var commandBuffer = CommandBufferPool.CreateCommandBuffer();
|
|
||||||
commandBuffer.BeginRecording();
|
|
||||||
|
|
||||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle,
|
|
||||||
_swapchainImages[_nextImage], ImageLayout.Undefined,
|
|
||||||
AccessFlags.AccessNoneKhr,
|
|
||||||
ImageLayout.TransferDstOptimal,
|
|
||||||
AccessFlags.AccessTransferWriteBit,
|
|
||||||
1);
|
|
||||||
|
|
||||||
return commandBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void BlitImageToCurrentImage(VulkanSurfaceRenderTarget renderTarget, CommandBuffer commandBuffer)
|
|
||||||
{
|
|
||||||
var image = renderTarget.GetImage();
|
|
||||||
|
|
||||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer,
|
|
||||||
image.InternalHandle.Value, (ImageLayout)image.CurrentLayout,
|
|
||||||
AccessFlags.AccessNoneKhr,
|
|
||||||
ImageLayout.TransferSrcOptimal,
|
|
||||||
AccessFlags.AccessTransferReadBit,
|
|
||||||
renderTarget.MipLevels);
|
|
||||||
|
|
||||||
var srcBlitRegion = new ImageBlit
|
|
||||||
{
|
|
||||||
SrcOffsets = new ImageBlit.SrcOffsetsBuffer
|
|
||||||
{
|
|
||||||
Element0 = new Offset3D(0, 0, 0),
|
|
||||||
Element1 = new Offset3D(renderTarget.Size.Width, renderTarget.Size.Height, 1),
|
|
||||||
},
|
|
||||||
DstOffsets = new ImageBlit.DstOffsetsBuffer
|
|
||||||
{
|
|
||||||
Element0 = new Offset3D(0, 0, 0),
|
|
||||||
Element1 = new Offset3D(Size.Width, Size.Height, 1),
|
|
||||||
},
|
|
||||||
SrcSubresource = new ImageSubresourceLayers
|
|
||||||
{
|
|
||||||
AspectMask = ImageAspectFlags.ImageAspectColorBit,
|
|
||||||
BaseArrayLayer = 0,
|
|
||||||
LayerCount = 1,
|
|
||||||
MipLevel = 0
|
|
||||||
},
|
|
||||||
DstSubresource = new ImageSubresourceLayers
|
|
||||||
{
|
|
||||||
AspectMask = ImageAspectFlags.ImageAspectColorBit,
|
|
||||||
BaseArrayLayer = 0,
|
|
||||||
LayerCount = 1,
|
|
||||||
MipLevel = 0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api.CmdBlitImage(commandBuffer, image.InternalHandle.Value,
|
|
||||||
ImageLayout.TransferSrcOptimal,
|
|
||||||
_swapchainImages[_nextImage],
|
|
||||||
ImageLayout.TransferDstOptimal,
|
|
||||||
1,
|
|
||||||
srcBlitRegion,
|
|
||||||
Filter.Linear);
|
|
||||||
|
|
||||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer,
|
|
||||||
image.InternalHandle.Value, ImageLayout.TransferSrcOptimal,
|
|
||||||
AccessFlags.AccessTransferReadBit,
|
|
||||||
(ImageLayout)image.CurrentLayout,
|
|
||||||
AccessFlags.AccessNoneKhr,
|
|
||||||
renderTarget.MipLevels);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal unsafe void EndPresentation(VulkanCommandBufferPool.VulkanCommandBuffer commandBuffer)
|
|
||||||
{
|
|
||||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle,
|
|
||||||
_swapchainImages[_nextImage], ImageLayout.TransferDstOptimal,
|
|
||||||
AccessFlags.AccessNoneKhr,
|
|
||||||
ImageLayout.PresentSrcKhr,
|
|
||||||
AccessFlags.AccessNoneKhr,
|
|
||||||
1);
|
|
||||||
|
|
||||||
commandBuffer.Submit(
|
|
||||||
stackalloc[] { _semaphorePair.ImageAvailableSemaphore },
|
|
||||||
stackalloc[] { PipelineStageFlags.PipelineStageColorAttachmentOutputBit },
|
|
||||||
stackalloc[] { _semaphorePair.RenderFinishedSemaphore });
|
|
||||||
|
|
||||||
var semaphore = _semaphorePair.RenderFinishedSemaphore;
|
|
||||||
var swapchain = _swapchain;
|
|
||||||
var nextImage = _nextImage;
|
|
||||||
|
|
||||||
Result result;
|
|
||||||
|
|
||||||
var presentInfo = new PresentInfoKHR
|
|
||||||
{
|
|
||||||
SType = StructureType.PresentInfoKhr,
|
|
||||||
WaitSemaphoreCount = 1,
|
|
||||||
PWaitSemaphores = &semaphore,
|
|
||||||
SwapchainCount = 1,
|
|
||||||
PSwapchains = &swapchain,
|
|
||||||
PImageIndices = &nextImage,
|
|
||||||
PResults = &result
|
|
||||||
};
|
|
||||||
|
|
||||||
lock (_device.Lock)
|
|
||||||
{
|
|
||||||
_swapchainExtension.QueuePresent(_device.PresentQueue.InternalHandle, presentInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandBufferPool.FreeUsedCommandBuffers();
|
|
||||||
|
|
||||||
Presented?.Invoke(this, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,165 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanImage : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
private readonly VulkanPhysicalDevice _physicalDevice;
|
|
||||||
private readonly VulkanCommandBufferPool _commandBufferPool;
|
|
||||||
private ImageLayout _currentLayout;
|
|
||||||
private AccessFlags _currentAccessFlags;
|
|
||||||
private ImageUsageFlags _imageUsageFlags { get; }
|
|
||||||
private ImageView? _imageView { get; set; }
|
|
||||||
private DeviceMemory _imageMemory { get; set; }
|
|
||||||
|
|
||||||
internal Image? InternalHandle { get; private set; }
|
|
||||||
internal Format Format { get; }
|
|
||||||
internal ImageAspectFlags AspectFlags { get; private set; }
|
|
||||||
|
|
||||||
public ulong Handle => InternalHandle?.Handle ?? 0;
|
|
||||||
public ulong ViewHandle => _imageView?.Handle ?? 0;
|
|
||||||
public uint UsageFlags => (uint)_imageUsageFlags;
|
|
||||||
public ulong MemoryHandle => _imageMemory.Handle;
|
|
||||||
public uint MipLevels { get; private set; }
|
|
||||||
public PixelSize Size { get; }
|
|
||||||
public ulong MemorySize { get; private set; }
|
|
||||||
public uint CurrentLayout => (uint)_currentLayout;
|
|
||||||
|
|
||||||
public VulkanImage(
|
|
||||||
VulkanDevice device,
|
|
||||||
VulkanPhysicalDevice physicalDevice,
|
|
||||||
VulkanCommandBufferPool commandBufferPool,
|
|
||||||
uint format,
|
|
||||||
PixelSize size,
|
|
||||||
uint mipLevels = 0)
|
|
||||||
{
|
|
||||||
_device = device;
|
|
||||||
_physicalDevice = physicalDevice;
|
|
||||||
_commandBufferPool = commandBufferPool;
|
|
||||||
Format = (Format)format;
|
|
||||||
Size = size;
|
|
||||||
MipLevels = mipLevels;
|
|
||||||
_imageUsageFlags =
|
|
||||||
ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit |
|
|
||||||
ImageUsageFlags.ImageUsageTransferSrcBit | ImageUsageFlags.ImageUsageSampledBit;
|
|
||||||
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe void Initialize()
|
|
||||||
{
|
|
||||||
if (!InternalHandle.HasValue)
|
|
||||||
{
|
|
||||||
MipLevels = MipLevels != 0 ? MipLevels : (uint)Math.Floor(Math.Log(Math.Max(Size.Width, Size.Height), 2));
|
|
||||||
|
|
||||||
var imageCreateInfo = new ImageCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageCreateInfo,
|
|
||||||
ImageType = ImageType.ImageType2D,
|
|
||||||
Format = Format,
|
|
||||||
Extent = new Extent3D((uint?)Size.Width, (uint?)Size.Height, 1),
|
|
||||||
MipLevels = MipLevels,
|
|
||||||
ArrayLayers = 1,
|
|
||||||
Samples = SampleCountFlags.SampleCount1Bit,
|
|
||||||
Tiling = Tiling,
|
|
||||||
Usage = _imageUsageFlags,
|
|
||||||
SharingMode = SharingMode.Exclusive,
|
|
||||||
InitialLayout = ImageLayout.Undefined,
|
|
||||||
Flags = ImageCreateFlags.ImageCreateMutableFormatBit
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api.CreateImage(_device.InternalHandle, imageCreateInfo, null, out var image).ThrowOnError();
|
|
||||||
InternalHandle = image;
|
|
||||||
|
|
||||||
_device.Api.GetImageMemoryRequirements(_device.InternalHandle, InternalHandle.Value,
|
|
||||||
out var memoryRequirements);
|
|
||||||
|
|
||||||
var memoryAllocateInfo = new MemoryAllocateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.MemoryAllocateInfo,
|
|
||||||
AllocationSize = memoryRequirements.Size,
|
|
||||||
MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex(
|
|
||||||
_physicalDevice,
|
|
||||||
memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit)
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api.AllocateMemory(_device.InternalHandle, memoryAllocateInfo, null,
|
|
||||||
out var imageMemory);
|
|
||||||
|
|
||||||
_imageMemory = imageMemory;
|
|
||||||
|
|
||||||
_device.Api.BindImageMemory(_device.InternalHandle, InternalHandle.Value, _imageMemory, 0);
|
|
||||||
|
|
||||||
MemorySize = memoryRequirements.Size;
|
|
||||||
|
|
||||||
var componentMapping = new ComponentMapping(
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity,
|
|
||||||
ComponentSwizzle.Identity);
|
|
||||||
|
|
||||||
AspectFlags = ImageAspectFlags.ImageAspectColorBit;
|
|
||||||
|
|
||||||
var subresourceRange = new ImageSubresourceRange(AspectFlags, 0, MipLevels, 0, 1);
|
|
||||||
|
|
||||||
var imageViewCreateInfo = new ImageViewCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageViewCreateInfo,
|
|
||||||
Image = InternalHandle.Value,
|
|
||||||
ViewType = ImageViewType.ImageViewType2D,
|
|
||||||
Format = Format,
|
|
||||||
Components = componentMapping,
|
|
||||||
SubresourceRange = subresourceRange
|
|
||||||
};
|
|
||||||
|
|
||||||
_device.Api
|
|
||||||
.CreateImageView(_device.InternalHandle, imageViewCreateInfo, null, out var imageView)
|
|
||||||
.ThrowOnError();
|
|
||||||
|
|
||||||
_imageView = imageView;
|
|
||||||
|
|
||||||
_currentLayout = ImageLayout.Undefined;
|
|
||||||
|
|
||||||
TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageTiling Tiling => ImageTiling.Optimal;
|
|
||||||
|
|
||||||
internal void TransitionLayout(ImageLayout destinationLayout, AccessFlags destinationAccessFlags)
|
|
||||||
{
|
|
||||||
var commandBuffer = _commandBufferPool.CreateCommandBuffer();
|
|
||||||
commandBuffer.BeginRecording();
|
|
||||||
|
|
||||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle, InternalHandle.Value,
|
|
||||||
_currentLayout,
|
|
||||||
_currentAccessFlags,
|
|
||||||
destinationLayout, destinationAccessFlags,
|
|
||||||
MipLevels);
|
|
||||||
|
|
||||||
commandBuffer.EndRecording();
|
|
||||||
|
|
||||||
commandBuffer.Submit();
|
|
||||||
|
|
||||||
_currentLayout = destinationLayout;
|
|
||||||
_currentAccessFlags = destinationAccessFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (InternalHandle != null)
|
|
||||||
{
|
|
||||||
_device.Api.DestroyImageView(_device.InternalHandle, _imageView.Value, Span<AllocationCallbacks>.Empty);
|
|
||||||
_device.Api.DestroyImage(_device.InternalHandle, InternalHandle.Value, Span<AllocationCallbacks>.Empty);
|
|
||||||
_device.Api.FreeMemory(_device.InternalHandle, _imageMemory, Span<AllocationCallbacks>.Empty);
|
|
||||||
|
|
||||||
_imageView = default;
|
|
||||||
InternalHandle = null;
|
|
||||||
_imageMemory = default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,135 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Silk.NET.Core;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using Silk.NET.Vulkan.Extensions.EXT;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
public class VulkanInstance : IDisposable
|
|
||||||
{
|
|
||||||
private const string EngineName = "Avalonia Vulkan";
|
|
||||||
|
|
||||||
private VulkanInstance(Instance apiHandle, Vk api)
|
|
||||||
{
|
|
||||||
InternalHandle = apiHandle;
|
|
||||||
Api = api;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Handle => InternalHandle.Handle;
|
|
||||||
|
|
||||||
internal Instance InternalHandle { get; }
|
|
||||||
public Vk Api { get; }
|
|
||||||
|
|
||||||
internal static IEnumerable<string> RequiredInstanceExtensions
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
yield return "VK_KHR_surface";
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
||||||
{
|
|
||||||
yield return "VK_KHR_xlib_surface";
|
|
||||||
}
|
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
|
||||||
yield return "VK_KHR_win32_surface";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Api?.DestroyInstance(InternalHandle, Span<AllocationCallbacks>.Empty);
|
|
||||||
Api?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static unsafe VulkanInstance Create(VulkanOptions options)
|
|
||||||
{
|
|
||||||
var api = Vk.GetApi();
|
|
||||||
var applicationName = Marshal.StringToHGlobalAnsi(options.ApplicationName);
|
|
||||||
var engineName = Marshal.StringToHGlobalAnsi(EngineName);
|
|
||||||
var enabledExtensions = new List<string>(options.InstanceExtensions);
|
|
||||||
|
|
||||||
enabledExtensions.AddRange(RequiredInstanceExtensions);
|
|
||||||
|
|
||||||
var applicationInfo = new ApplicationInfo
|
|
||||||
{
|
|
||||||
PApplicationName = (byte*)applicationName,
|
|
||||||
ApiVersion = Vk.Version12.Value,
|
|
||||||
PEngineName = (byte*)engineName,
|
|
||||||
EngineVersion = new Version32(1, 0, 0),
|
|
||||||
ApplicationVersion = new Version32(1, 0, 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
var enabledLayers = new HashSet<string>();
|
|
||||||
|
|
||||||
if (options.UseDebug)
|
|
||||||
{
|
|
||||||
enabledExtensions.Add(ExtDebugUtils.ExtensionName);
|
|
||||||
enabledExtensions.Add(ExtDebugReport.ExtensionName);
|
|
||||||
if (IsLayerAvailable(api, "VK_LAYER_KHRONOS_validation"))
|
|
||||||
enabledLayers.Add("VK_LAYER_KHRONOS_validation");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var layer in options.EnabledLayers)
|
|
||||||
enabledLayers.Add(layer);
|
|
||||||
|
|
||||||
var ppEnabledExtensions = stackalloc IntPtr[enabledExtensions.Count];
|
|
||||||
var ppEnabledLayers = stackalloc IntPtr[enabledLayers.Count];
|
|
||||||
|
|
||||||
for (var i = 0; i < enabledExtensions.Count; i++)
|
|
||||||
ppEnabledExtensions[i] = Marshal.StringToHGlobalAnsi(enabledExtensions[i]);
|
|
||||||
|
|
||||||
var layers = enabledLayers.ToList();
|
|
||||||
|
|
||||||
for (var i = 0; i < enabledLayers.Count; i++)
|
|
||||||
ppEnabledLayers[i] = Marshal.StringToHGlobalAnsi(layers[i]);
|
|
||||||
|
|
||||||
var instanceCreateInfo = new InstanceCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.InstanceCreateInfo,
|
|
||||||
PApplicationInfo = &applicationInfo,
|
|
||||||
PpEnabledExtensionNames = (byte**)ppEnabledExtensions,
|
|
||||||
PpEnabledLayerNames = (byte**)ppEnabledLayers,
|
|
||||||
EnabledExtensionCount = (uint)enabledExtensions.Count,
|
|
||||||
EnabledLayerCount = (uint)enabledLayers.Count
|
|
||||||
};
|
|
||||||
|
|
||||||
api.CreateInstance(in instanceCreateInfo, null, out var instance).ThrowOnError();
|
|
||||||
|
|
||||||
Marshal.FreeHGlobal(applicationName);
|
|
||||||
Marshal.FreeHGlobal(engineName);
|
|
||||||
|
|
||||||
for (var i = 0; i < enabledExtensions.Count; i++) Marshal.FreeHGlobal(ppEnabledExtensions[i]);
|
|
||||||
|
|
||||||
for (var i = 0; i < enabledLayers.Count; i++) Marshal.FreeHGlobal(ppEnabledLayers[i]);
|
|
||||||
|
|
||||||
return new VulkanInstance(instance, api);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe bool IsLayerAvailable(Vk api, string layerName)
|
|
||||||
{
|
|
||||||
uint layerPropertiesCount;
|
|
||||||
|
|
||||||
api.EnumerateInstanceLayerProperties(&layerPropertiesCount, null).ThrowOnError();
|
|
||||||
|
|
||||||
var layerProperties = new LayerProperties[layerPropertiesCount];
|
|
||||||
|
|
||||||
fixed (LayerProperties* pLayerProperties = layerProperties)
|
|
||||||
{
|
|
||||||
api.EnumerateInstanceLayerProperties(&layerPropertiesCount, layerProperties).ThrowOnError();
|
|
||||||
|
|
||||||
for (var i = 0; i < layerPropertiesCount; i++)
|
|
||||||
{
|
|
||||||
var currentLayerName = Marshal.PtrToStringAnsi((IntPtr)pLayerProperties[i].LayerName);
|
|
||||||
|
|
||||||
if (currentLayerName == layerName) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,59 +0,0 @@
|
|||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal static class VulkanMemoryHelper
|
|
||||||
{
|
|
||||||
internal static int FindSuitableMemoryTypeIndex(VulkanPhysicalDevice physicalDevice, uint memoryTypeBits,
|
|
||||||
MemoryPropertyFlags flags)
|
|
||||||
{
|
|
||||||
physicalDevice.Api.GetPhysicalDeviceMemoryProperties(physicalDevice.InternalHandle, out var properties);
|
|
||||||
|
|
||||||
for (var i = 0; i < properties.MemoryTypeCount; i++)
|
|
||||||
{
|
|
||||||
var type = properties.MemoryTypes[i];
|
|
||||||
|
|
||||||
if ((memoryTypeBits & (1 << i)) != 0 && type.PropertyFlags.HasFlag(flags)) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static unsafe void TransitionLayout(VulkanDevice device,
|
|
||||||
CommandBuffer commandBuffer,
|
|
||||||
Image image,
|
|
||||||
ImageLayout sourceLayout,
|
|
||||||
AccessFlags sourceAccessMask,
|
|
||||||
ImageLayout destinationLayout,
|
|
||||||
AccessFlags destinationAccessMask,
|
|
||||||
uint mipLevels)
|
|
||||||
{
|
|
||||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, mipLevels, 0, 1);
|
|
||||||
|
|
||||||
var barrier = new ImageMemoryBarrier
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageMemoryBarrier,
|
|
||||||
SrcAccessMask = sourceAccessMask,
|
|
||||||
DstAccessMask = destinationAccessMask,
|
|
||||||
OldLayout = sourceLayout,
|
|
||||||
NewLayout = destinationLayout,
|
|
||||||
SrcQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
|
||||||
DstQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
|
||||||
Image = image,
|
|
||||||
SubresourceRange = subresourceRange
|
|
||||||
};
|
|
||||||
|
|
||||||
device.Api.CmdPipelineBarrier(
|
|
||||||
commandBuffer,
|
|
||||||
PipelineStageFlags.PipelineStageAllCommandsBit,
|
|
||||||
PipelineStageFlags.PipelineStageAllCommandsBit,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
1,
|
|
||||||
barrier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
public class VulkanOptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the application name of the Vulkan instance
|
|
||||||
/// </summary>
|
|
||||||
public string ApplicationName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Specifies additional extensions to enable if available on the instance
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<string> InstanceExtensions { get; set; } = Enumerable.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Specifies layers to enable if available on the instance
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<string> EnabledLayers { get; set; } = Enumerable.Empty<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enables the debug layer
|
|
||||||
/// </summary>
|
|
||||||
public bool UseDebug { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Selects the first suitable discrete GPU available
|
|
||||||
/// </summary>
|
|
||||||
public bool PreferDiscreteGpu { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the device to use if available and suitable.
|
|
||||||
/// </summary>
|
|
||||||
public string PreferredDevice { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Max number of device queues to request
|
|
||||||
/// </summary>
|
|
||||||
public uint MaxQueueCount { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,219 +0,0 @@
|
|||||||
using Ryujinx.Graphics.Vulkan;
|
|
||||||
using Silk.NET.Core;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using Silk.NET.Vulkan.Extensions.KHR;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
public unsafe class VulkanPhysicalDevice
|
|
||||||
{
|
|
||||||
private VulkanPhysicalDevice(PhysicalDevice apiHandle, Vk api, uint queueCount, uint queueFamilyIndex)
|
|
||||||
{
|
|
||||||
InternalHandle = apiHandle;
|
|
||||||
Api = api;
|
|
||||||
QueueCount = queueCount;
|
|
||||||
QueueFamilyIndex = queueFamilyIndex;
|
|
||||||
|
|
||||||
api.GetPhysicalDeviceProperties(apiHandle, out var properties);
|
|
||||||
|
|
||||||
DeviceName = Marshal.PtrToStringAnsi((IntPtr)properties.DeviceName);
|
|
||||||
DeviceId = VulkanInitialization.StringFromIdPair(properties.VendorID, properties.DeviceID);
|
|
||||||
|
|
||||||
var version = (Version32)properties.ApiVersion;
|
|
||||||
ApiVersion = new Version((int)version.Major, (int)version.Minor, 0, (int)version.Patch);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal PhysicalDevice InternalHandle { get; }
|
|
||||||
internal Vk Api { get; }
|
|
||||||
public uint QueueCount { get; }
|
|
||||||
public uint QueueFamilyIndex { get; }
|
|
||||||
public IntPtr Handle => InternalHandle.Handle;
|
|
||||||
|
|
||||||
public string DeviceName { get; }
|
|
||||||
public string DeviceId { get; }
|
|
||||||
public Version ApiVersion { get; }
|
|
||||||
public static Dictionary<PhysicalDevice, PhysicalDeviceProperties> PhysicalDevices { get; private set; }
|
|
||||||
public static IEnumerable<KeyValuePair<PhysicalDevice, PhysicalDeviceProperties>> SuitableDevices { get; private set; }
|
|
||||||
|
|
||||||
internal static void SelectAvailableDevices(VulkanInstance instance,
|
|
||||||
VulkanSurface surface, bool preferDiscreteGpu, string preferredDevice)
|
|
||||||
{
|
|
||||||
uint physicalDeviceCount;
|
|
||||||
|
|
||||||
instance.Api.EnumeratePhysicalDevices(instance.InternalHandle, &physicalDeviceCount, null).ThrowOnError();
|
|
||||||
|
|
||||||
var physicalDevices = new PhysicalDevice[physicalDeviceCount];
|
|
||||||
|
|
||||||
fixed (PhysicalDevice* pPhysicalDevices = physicalDevices)
|
|
||||||
{
|
|
||||||
instance.Api.EnumeratePhysicalDevices(instance.InternalHandle, &physicalDeviceCount, pPhysicalDevices)
|
|
||||||
.ThrowOnError();
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysicalDevices = new Dictionary<PhysicalDevice, PhysicalDeviceProperties>();
|
|
||||||
|
|
||||||
foreach (var physicalDevice in physicalDevices)
|
|
||||||
{
|
|
||||||
instance.Api.GetPhysicalDeviceProperties(physicalDevice, out var properties);
|
|
||||||
PhysicalDevices.Add(physicalDevice, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
SuitableDevices = PhysicalDevices.Where(x => IsSuitableDevice(
|
|
||||||
instance.Api,
|
|
||||||
x.Key,
|
|
||||||
x.Value,
|
|
||||||
surface.ApiHandle,
|
|
||||||
out _,
|
|
||||||
out _));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static VulkanPhysicalDevice FindSuitablePhysicalDevice(VulkanInstance instance,
|
|
||||||
VulkanSurface surface, bool preferDiscreteGpu, string preferredDevice)
|
|
||||||
{
|
|
||||||
SelectAvailableDevices(instance, surface, preferDiscreteGpu, preferredDevice);
|
|
||||||
|
|
||||||
uint queueFamilyIndex = 0;
|
|
||||||
uint queueCount = 0;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(preferredDevice))
|
|
||||||
{
|
|
||||||
var physicalDevice = SuitableDevices.FirstOrDefault(x => VulkanInitialization.StringFromIdPair(x.Value.VendorID, x.Value.DeviceID) == preferredDevice);
|
|
||||||
|
|
||||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, physicalDevice.Key,
|
|
||||||
surface.ApiHandle, out queueCount);
|
|
||||||
if (queueFamilyIndex != int.MaxValue)
|
|
||||||
{
|
|
||||||
return new VulkanPhysicalDevice(physicalDevice.Key, instance.Api, queueCount, queueFamilyIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preferDiscreteGpu)
|
|
||||||
{
|
|
||||||
var discreteGpus = SuitableDevices.Where(p => p.Value.DeviceType == PhysicalDeviceType.DiscreteGpu);
|
|
||||||
|
|
||||||
foreach (var gpu in discreteGpus)
|
|
||||||
{
|
|
||||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, gpu.Key,
|
|
||||||
surface.ApiHandle, out queueCount);
|
|
||||||
if (queueFamilyIndex != int.MaxValue)
|
|
||||||
{
|
|
||||||
return new VulkanPhysicalDevice(gpu.Key, instance.Api, queueCount, queueFamilyIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var physicalDevice in SuitableDevices)
|
|
||||||
{
|
|
||||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, physicalDevice.Key,
|
|
||||||
surface.ApiHandle, out queueCount);
|
|
||||||
if (queueFamilyIndex != int.MaxValue)
|
|
||||||
{
|
|
||||||
return new VulkanPhysicalDevice(physicalDevice.Key, instance.Api, queueCount, queueFamilyIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception("No suitable physical device found");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static unsafe bool IsSuitableDevice(Vk api, PhysicalDevice physicalDevice, PhysicalDeviceProperties properties, SurfaceKHR surface,
|
|
||||||
out uint queueCount, out uint familyIndex)
|
|
||||||
{
|
|
||||||
queueCount = 0;
|
|
||||||
familyIndex = 0;
|
|
||||||
|
|
||||||
if (properties.DeviceType == PhysicalDeviceType.Cpu) return false;
|
|
||||||
|
|
||||||
var extensionMatches = 0;
|
|
||||||
uint propertiesCount;
|
|
||||||
|
|
||||||
api.EnumerateDeviceExtensionProperties(physicalDevice, (byte*)null, &propertiesCount, null).ThrowOnError();
|
|
||||||
|
|
||||||
var extensionProperties = new ExtensionProperties[propertiesCount];
|
|
||||||
|
|
||||||
fixed (ExtensionProperties* pExtensionProperties = extensionProperties)
|
|
||||||
{
|
|
||||||
api.EnumerateDeviceExtensionProperties(
|
|
||||||
physicalDevice,
|
|
||||||
(byte*)null,
|
|
||||||
&propertiesCount,
|
|
||||||
pExtensionProperties).ThrowOnError();
|
|
||||||
|
|
||||||
for (var i = 0; i < propertiesCount; i++)
|
|
||||||
{
|
|
||||||
var extensionName = Marshal.PtrToStringAnsi((IntPtr)pExtensionProperties[i].ExtensionName);
|
|
||||||
|
|
||||||
if (VulkanInitialization.RequiredExtensions.Contains(extensionName))
|
|
||||||
{
|
|
||||||
extensionMatches++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extensionMatches == VulkanInitialization.RequiredExtensions.Length)
|
|
||||||
{
|
|
||||||
familyIndex = FindSuitableQueueFamily(api, physicalDevice, surface, out queueCount);
|
|
||||||
|
|
||||||
return familyIndex != uint.MaxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal unsafe string[] GetSupportedExtensions()
|
|
||||||
{
|
|
||||||
uint propertiesCount;
|
|
||||||
|
|
||||||
Api.EnumerateDeviceExtensionProperties(InternalHandle, (byte*)null, &propertiesCount, null).ThrowOnError();
|
|
||||||
|
|
||||||
var extensionProperties = new ExtensionProperties[propertiesCount];
|
|
||||||
|
|
||||||
fixed (ExtensionProperties* pExtensionProperties = extensionProperties)
|
|
||||||
{
|
|
||||||
Api.EnumerateDeviceExtensionProperties(InternalHandle, (byte*)null, &propertiesCount, pExtensionProperties)
|
|
||||||
.ThrowOnError();
|
|
||||||
}
|
|
||||||
|
|
||||||
return extensionProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.ExtensionName)).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static uint FindSuitableQueueFamily(Vk api, PhysicalDevice physicalDevice, SurfaceKHR surface,
|
|
||||||
out uint queueCount)
|
|
||||||
{
|
|
||||||
const QueueFlags RequiredFlags = QueueFlags.QueueGraphicsBit | QueueFlags.QueueComputeBit;
|
|
||||||
|
|
||||||
var khrSurface = new KhrSurface(api.Context);
|
|
||||||
|
|
||||||
uint propertiesCount;
|
|
||||||
|
|
||||||
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, null);
|
|
||||||
|
|
||||||
var properties = new QueueFamilyProperties[propertiesCount];
|
|
||||||
|
|
||||||
fixed (QueueFamilyProperties* pProperties = properties)
|
|
||||||
{
|
|
||||||
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, pProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint index = 0; index < propertiesCount; index++)
|
|
||||||
{
|
|
||||||
var queueFlags = properties[index].QueueFlags;
|
|
||||||
|
|
||||||
khrSurface.GetPhysicalDeviceSurfaceSupport(physicalDevice, index, surface, out var surfaceSupported)
|
|
||||||
.ThrowOnError();
|
|
||||||
|
|
||||||
if (queueFlags.HasFlag(RequiredFlags) && surfaceSupported)
|
|
||||||
{
|
|
||||||
queueCount = properties[index].QueueCount;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queueCount = 0;
|
|
||||||
return uint.MaxValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Ryujinx.Graphics.Vulkan;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanPlatformInterface : IDisposable
|
|
||||||
{
|
|
||||||
private static VulkanOptions _options;
|
|
||||||
|
|
||||||
private VulkanPlatformInterface(VulkanInstance instance)
|
|
||||||
{
|
|
||||||
Instance = instance;
|
|
||||||
Api = instance.Api;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanPhysicalDevice PhysicalDevice { get; private set; }
|
|
||||||
public VulkanInstance Instance { get; }
|
|
||||||
public Vk Api { get; private set; }
|
|
||||||
public VulkanSurfaceRenderTarget MainSurface { get; set; }
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Instance?.Dispose();
|
|
||||||
Api?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static VulkanPlatformInterface TryCreate()
|
|
||||||
{
|
|
||||||
_options = AvaloniaLocator.Current.GetService<VulkanOptions>() ?? new VulkanOptions();
|
|
||||||
|
|
||||||
var instance = VulkanInstance.Create(_options);
|
|
||||||
|
|
||||||
return new VulkanPlatformInterface(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryInitialize()
|
|
||||||
{
|
|
||||||
var feature = TryCreate();
|
|
||||||
if (feature != null)
|
|
||||||
{
|
|
||||||
AvaloniaLocator.CurrentMutable.Bind<VulkanPlatformInterface>().ToConstant(feature);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanSurfaceRenderTarget CreateRenderTarget(IVulkanPlatformSurface platformSurface)
|
|
||||||
{
|
|
||||||
var surface = VulkanSurface.CreateSurface(Instance, platformSurface);
|
|
||||||
|
|
||||||
if (PhysicalDevice == null)
|
|
||||||
{
|
|
||||||
PhysicalDevice = VulkanPhysicalDevice.FindSuitablePhysicalDevice(Instance, surface, _options.PreferDiscreteGpu, _options.PreferredDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
var renderTarget = new VulkanSurfaceRenderTarget(this, surface);
|
|
||||||
|
|
||||||
if (MainSurface == null && surface != null)
|
|
||||||
{
|
|
||||||
MainSurface = renderTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
return renderTarget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanQueue
|
|
||||||
{
|
|
||||||
public VulkanQueue(VulkanDevice device, Queue apiHandle)
|
|
||||||
{
|
|
||||||
Device = device;
|
|
||||||
InternalHandle = apiHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanDevice Device { get; }
|
|
||||||
public IntPtr Handle => InternalHandle.Handle;
|
|
||||||
internal Queue InternalHandle { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanSemaphorePair : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
|
|
||||||
public unsafe VulkanSemaphorePair(VulkanDevice device)
|
|
||||||
{
|
|
||||||
_device = device;
|
|
||||||
|
|
||||||
var semaphoreCreateInfo = new SemaphoreCreateInfo { SType = StructureType.SemaphoreCreateInfo };
|
|
||||||
|
|
||||||
_device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out var semaphore).ThrowOnError();
|
|
||||||
ImageAvailableSemaphore = semaphore;
|
|
||||||
|
|
||||||
_device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out semaphore).ThrowOnError();
|
|
||||||
RenderFinishedSemaphore = semaphore;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal Semaphore ImageAvailableSemaphore { get; }
|
|
||||||
internal Semaphore RenderFinishedSemaphore { get; }
|
|
||||||
|
|
||||||
public unsafe void Dispose()
|
|
||||||
{
|
|
||||||
_device.Api.DestroySemaphore(_device.InternalHandle, ImageAvailableSemaphore, null);
|
|
||||||
_device.Api.DestroySemaphore(_device.InternalHandle, RenderFinishedSemaphore, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,75 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using Silk.NET.Vulkan.Extensions.KHR;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
public class VulkanSurface : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanInstance _instance;
|
|
||||||
private readonly IVulkanPlatformSurface _vulkanPlatformSurface;
|
|
||||||
|
|
||||||
private VulkanSurface(IVulkanPlatformSurface vulkanPlatformSurface, VulkanInstance instance)
|
|
||||||
{
|
|
||||||
_vulkanPlatformSurface = vulkanPlatformSurface;
|
|
||||||
_instance = instance;
|
|
||||||
ApiHandle = vulkanPlatformSurface.CreateSurface(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal SurfaceKHR ApiHandle { get; }
|
|
||||||
|
|
||||||
internal static KhrSurface SurfaceExtension { get; private set; }
|
|
||||||
|
|
||||||
internal PixelSize SurfaceSize => _vulkanPlatformSurface.SurfaceSize;
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
SurfaceExtension.DestroySurface(_instance.InternalHandle, ApiHandle, Span<AllocationCallbacks>.Empty);
|
|
||||||
_vulkanPlatformSurface.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static VulkanSurface CreateSurface(VulkanInstance instance, IVulkanPlatformSurface vulkanPlatformSurface)
|
|
||||||
{
|
|
||||||
if (SurfaceExtension == null)
|
|
||||||
{
|
|
||||||
instance.Api.TryGetInstanceExtension(instance.InternalHandle, out KhrSurface extension);
|
|
||||||
|
|
||||||
SurfaceExtension = extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new VulkanSurface(vulkanPlatformSurface, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool CanSurfacePresent(VulkanPhysicalDevice physicalDevice)
|
|
||||||
{
|
|
||||||
SurfaceExtension.GetPhysicalDeviceSurfaceSupport(physicalDevice.InternalHandle, physicalDevice.QueueFamilyIndex, ApiHandle, out var isSupported);
|
|
||||||
|
|
||||||
return isSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal SurfaceFormatKHR GetSurfaceFormat(VulkanPhysicalDevice physicalDevice)
|
|
||||||
{
|
|
||||||
Span<uint> surfaceFormatsCount = stackalloc uint[1];
|
|
||||||
SurfaceExtension.GetPhysicalDeviceSurfaceFormats(physicalDevice.InternalHandle, ApiHandle, surfaceFormatsCount, Span<SurfaceFormatKHR>.Empty);
|
|
||||||
Span<SurfaceFormatKHR> surfaceFormats = stackalloc SurfaceFormatKHR[(int)surfaceFormatsCount[0]];
|
|
||||||
SurfaceExtension.GetPhysicalDeviceSurfaceFormats(physicalDevice.InternalHandle, ApiHandle, surfaceFormatsCount, surfaceFormats);
|
|
||||||
|
|
||||||
if (surfaceFormats.Length == 1 && surfaceFormats[0].Format == Format.Undefined)
|
|
||||||
{
|
|
||||||
return new SurfaceFormatKHR(Format.B8G8R8A8Unorm, ColorSpaceKHR.ColorspaceSrgbNonlinearKhr);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var format in surfaceFormats)
|
|
||||||
{
|
|
||||||
if (format.Format == Format.B8G8R8A8Unorm && format.ColorSpace == ColorSpaceKHR.ColorspaceSrgbNonlinearKhr)
|
|
||||||
{
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return surfaceFormats[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,43 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Avalonia;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Vulkan
|
|
||||||
{
|
|
||||||
internal class VulkanSurfaceRenderingSession : IDisposable
|
|
||||||
{
|
|
||||||
private readonly VulkanDevice _device;
|
|
||||||
private readonly VulkanSurfaceRenderTarget _renderTarget;
|
|
||||||
|
|
||||||
public VulkanSurfaceRenderingSession(VulkanDisplay display, VulkanDevice device,
|
|
||||||
VulkanSurfaceRenderTarget renderTarget, float scaling)
|
|
||||||
{
|
|
||||||
Display = display;
|
|
||||||
_device = device;
|
|
||||||
_renderTarget = renderTarget;
|
|
||||||
Scaling = scaling;
|
|
||||||
Begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VulkanDisplay Display { get; }
|
|
||||||
|
|
||||||
public PixelSize Size => _renderTarget.Size;
|
|
||||||
public Vk Api => _device.Api;
|
|
||||||
|
|
||||||
public float Scaling { get; }
|
|
||||||
|
|
||||||
private void Begin()
|
|
||||||
{
|
|
||||||
if (!Display.EnsureSwapchainAvailable())
|
|
||||||
{
|
|
||||||
_renderTarget.RecreateImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_renderTarget.EndDraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,4 +1,8 @@
|
|||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Media;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
@@ -27,9 +31,69 @@ namespace Ryujinx.Ava.Ui.Controls
|
|||||||
{
|
{
|
||||||
UserResult result = UserResult.None;
|
UserResult result = UserResult.None;
|
||||||
|
|
||||||
ContentDialog contentDialog = new ContentDialog();
|
bool useOverlay = false;
|
||||||
|
Window mainWindow = null;
|
||||||
|
|
||||||
|
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime al)
|
||||||
|
{
|
||||||
|
foreach (var item in al.Windows)
|
||||||
|
{
|
||||||
|
if (item.IsActive && item is MainWindow window && window.ViewModel.IsGameRunning)
|
||||||
|
{
|
||||||
|
mainWindow = window;
|
||||||
|
useOverlay = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentDialog contentDialog = null;
|
||||||
|
ContentDialogOverlayWindow overlay = null;
|
||||||
|
|
||||||
|
if (useOverlay)
|
||||||
|
{
|
||||||
|
overlay = new ContentDialogOverlayWindow()
|
||||||
|
{
|
||||||
|
Height = mainWindow.Bounds.Height,
|
||||||
|
Width = mainWindow.Bounds.Width,
|
||||||
|
Position = mainWindow.PointToScreen(new Point())
|
||||||
|
};
|
||||||
|
|
||||||
|
mainWindow.PositionChanged += OverlayOnPositionChanged;
|
||||||
|
|
||||||
|
void OverlayOnPositionChanged(object sender, PixelPointEventArgs e)
|
||||||
|
{
|
||||||
|
overlay.Position = mainWindow.PointToScreen(new Point());
|
||||||
|
}
|
||||||
|
|
||||||
|
contentDialog = overlay.ContentDialog;
|
||||||
|
|
||||||
|
bool opened = false;
|
||||||
|
|
||||||
|
overlay.Opened += OverlayOnActivated;
|
||||||
|
|
||||||
|
async void OverlayOnActivated(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opened = true;
|
||||||
|
|
||||||
|
overlay.Position = mainWindow.PointToScreen(new Point());
|
||||||
|
|
||||||
await ShowDialog();
|
await ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
await overlay.ShowDialog(mainWindow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
contentDialog = new ContentDialog();
|
||||||
|
|
||||||
|
await ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
async Task ShowDialog()
|
async Task ShowDialog()
|
||||||
{
|
{
|
||||||
@@ -53,6 +117,14 @@ namespace Ryujinx.Ava.Ui.Controls
|
|||||||
});
|
});
|
||||||
|
|
||||||
await contentDialog.ShowAsync(ContentDialogPlacement.Popup);
|
await contentDialog.ShowAsync(ContentDialogPlacement.Popup);
|
||||||
|
|
||||||
|
overlay?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useOverlay)
|
||||||
|
{
|
||||||
|
overlay.Content = null;
|
||||||
|
overlay.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
204
Ryujinx.Ava/Ui/Controls/EmbeddedWindow.cs
Normal file
204
Ryujinx.Ava/Ui/Controls/EmbeddedWindow.cs
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Platform;
|
||||||
|
using SPB.Graphics;
|
||||||
|
using SPB.Platform;
|
||||||
|
using SPB.Platform.GLX;
|
||||||
|
using SPB.Platform.X11;
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static Ryujinx.Ava.Ui.Controls.Win32NativeInterop;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui.Controls
|
||||||
|
{
|
||||||
|
public unsafe class EmbeddedWindow : NativeControlHost
|
||||||
|
{
|
||||||
|
private WindowProc _wndProcDelegate;
|
||||||
|
private string _className;
|
||||||
|
|
||||||
|
protected GLXWindow X11Window { get; private set; }
|
||||||
|
protected IntPtr WindowHandle { get; set; }
|
||||||
|
protected IntPtr X11Display { get; set; }
|
||||||
|
|
||||||
|
public event EventHandler<IntPtr> WindowCreated;
|
||||||
|
public event EventHandler<Size> SizeChanged;
|
||||||
|
|
||||||
|
protected virtual void OnWindowDestroyed() { }
|
||||||
|
protected virtual void OnWindowDestroying()
|
||||||
|
{
|
||||||
|
WindowHandle = IntPtr.Zero;
|
||||||
|
X11Display = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmbeddedWindow()
|
||||||
|
{
|
||||||
|
var stateObserverable = this.GetObservable(Control.BoundsProperty);
|
||||||
|
|
||||||
|
stateObserverable.Subscribe(StateChanged);
|
||||||
|
|
||||||
|
this.Initialized += NativeEmbeddedWindow_Initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnWindowCreated() { }
|
||||||
|
|
||||||
|
private void NativeEmbeddedWindow_Initialized(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OnWindowCreated();
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
WindowCreated?.Invoke(this, WindowHandle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StateChanged(Rect rect)
|
||||||
|
{
|
||||||
|
SizeChanged?.Invoke(this, rect.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent)
|
||||||
|
{
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
return CreateLinux(parent);
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
return CreateWin32(parent);
|
||||||
|
}
|
||||||
|
return base.CreateNativeControlCore(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DestroyNativeControlCore(IPlatformHandle control)
|
||||||
|
{
|
||||||
|
OnWindowDestroying();
|
||||||
|
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
DestroyLinux();
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
DestroyWin32(control);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.DestroyNativeControlCore(control);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnWindowDestroyed();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("linux")]
|
||||||
|
IPlatformHandle CreateLinux(IPlatformHandle parent)
|
||||||
|
{
|
||||||
|
X11Window = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100) as GLXWindow;
|
||||||
|
|
||||||
|
WindowHandle = X11Window.WindowHandle.RawHandle;
|
||||||
|
|
||||||
|
X11Display = X11Window.DisplayHandle.RawHandle;
|
||||||
|
|
||||||
|
return new PlatformHandle(WindowHandle, "X11");
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
unsafe IPlatformHandle CreateWin32(IPlatformHandle parent)
|
||||||
|
{
|
||||||
|
_className = "NativeWindow-" + Guid.NewGuid();
|
||||||
|
_wndProcDelegate = WndProc;
|
||||||
|
var wndClassEx = new WNDCLASSEX
|
||||||
|
{
|
||||||
|
cbSize = Marshal.SizeOf<WNDCLASSEX>(),
|
||||||
|
hInstance = GetModuleHandle(null),
|
||||||
|
lpfnWndProc = _wndProcDelegate,
|
||||||
|
style = ClassStyles.CS_OWNDC,
|
||||||
|
lpszClassName = _className,
|
||||||
|
hCursor = LoadCursor(IntPtr.Zero, (IntPtr)Cursors.IDC_ARROW)
|
||||||
|
};
|
||||||
|
|
||||||
|
var atom = RegisterClassEx(ref wndClassEx);
|
||||||
|
|
||||||
|
var handle = CreateWindowEx(
|
||||||
|
0,
|
||||||
|
_className,
|
||||||
|
"NativeWindow",
|
||||||
|
WindowStyles.WS_CHILD,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
640,
|
||||||
|
480,
|
||||||
|
parent.Handle,
|
||||||
|
IntPtr.Zero,
|
||||||
|
IntPtr.Zero,
|
||||||
|
IntPtr.Zero);
|
||||||
|
|
||||||
|
WindowHandle = handle;
|
||||||
|
|
||||||
|
return new PlatformHandle(WindowHandle, "HWND");
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
internal IntPtr WndProc(IntPtr hWnd, WindowsMessages msg, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
var point = new Point((long)lParam & 0xFFFF, ((long)lParam >> 16) & 0xFFFF);
|
||||||
|
var root = VisualRoot as Window;
|
||||||
|
bool isLeft = false;
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WindowsMessages.LBUTTONDOWN:
|
||||||
|
case WindowsMessages.RBUTTONDOWN:
|
||||||
|
isLeft = msg == WindowsMessages.LBUTTONDOWN;
|
||||||
|
this.RaiseEvent(new PointerPressedEventArgs(
|
||||||
|
this,
|
||||||
|
new Avalonia.Input.Pointer(0, PointerType.Mouse, true),
|
||||||
|
root,
|
||||||
|
this.TranslatePoint(point, root).Value,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
new PointerPointProperties(isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton, isLeft ? PointerUpdateKind.LeftButtonPressed : PointerUpdateKind.RightButtonPressed),
|
||||||
|
KeyModifiers.None));
|
||||||
|
break;
|
||||||
|
case WindowsMessages.LBUTTONUP:
|
||||||
|
case WindowsMessages.RBUTTONUP:
|
||||||
|
isLeft = msg == WindowsMessages.LBUTTONUP;
|
||||||
|
this.RaiseEvent(new PointerReleasedEventArgs(
|
||||||
|
this,
|
||||||
|
new Avalonia.Input.Pointer(0, PointerType.Mouse, true),
|
||||||
|
root,
|
||||||
|
this.TranslatePoint(point, root).Value,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
new PointerPointProperties(isLeft ? RawInputModifiers.LeftMouseButton : RawInputModifiers.RightMouseButton, isLeft ? PointerUpdateKind.LeftButtonReleased : PointerUpdateKind.RightButtonReleased),
|
||||||
|
KeyModifiers.None,
|
||||||
|
isLeft ? MouseButton.Left : MouseButton.Right));
|
||||||
|
break;
|
||||||
|
case WindowsMessages.MOUSEMOVE:
|
||||||
|
this.RaiseEvent(new PointerEventArgs(
|
||||||
|
PointerMovedEvent,
|
||||||
|
this,
|
||||||
|
new Avalonia.Input.Pointer(0, PointerType.Mouse, true),
|
||||||
|
root,
|
||||||
|
this.TranslatePoint(point, root).Value,
|
||||||
|
(ulong)Environment.TickCount64,
|
||||||
|
new PointerPointProperties(RawInputModifiers.None, PointerUpdateKind.Other),
|
||||||
|
KeyModifiers.None));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return DefWindowProc(hWnd, msg, (IntPtr)wParam, (IntPtr)lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyLinux()
|
||||||
|
{
|
||||||
|
X11Window?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
void DestroyWin32(IPlatformHandle handle)
|
||||||
|
{
|
||||||
|
DestroyWindow(handle.Handle);
|
||||||
|
UnregisterClass(_className, GetModuleHandle(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
Ryujinx.Ava/Ui/Controls/OpenGLEmbeddedWindow.cs
Normal file
85
Ryujinx.Ava/Ui/Controls/OpenGLEmbeddedWindow.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.OpenGL;
|
||||||
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using SPB.Graphics;
|
||||||
|
using SPB.Graphics.OpenGL;
|
||||||
|
using SPB.Platform;
|
||||||
|
using SPB.Platform.GLX;
|
||||||
|
using SPB.Platform.WGL;
|
||||||
|
using SPB.Windowing;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui.Controls
|
||||||
|
{
|
||||||
|
public class OpenGLEmbeddedWindow : EmbeddedWindow
|
||||||
|
{
|
||||||
|
private readonly int _major;
|
||||||
|
private readonly int _minor;
|
||||||
|
private readonly GraphicsDebugLevel _graphicsDebugLevel;
|
||||||
|
private SwappableNativeWindowBase _window;
|
||||||
|
public OpenGLContextBase Context { get; set; }
|
||||||
|
|
||||||
|
public OpenGLEmbeddedWindow(int major, int minor, GraphicsDebugLevel graphicsDebugLevel)
|
||||||
|
{
|
||||||
|
_major = major;
|
||||||
|
_minor = minor;
|
||||||
|
_graphicsDebugLevel = graphicsDebugLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnWindowDestroying()
|
||||||
|
{
|
||||||
|
Context.Dispose();
|
||||||
|
base.OnWindowDestroying();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnWindowCreated()
|
||||||
|
{
|
||||||
|
base.OnWindowCreated();
|
||||||
|
|
||||||
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
_window = new WGLWindow(new NativeHandle(WindowHandle));
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
_window = X11Window;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
var flags = OpenGLContextFlags.Compat;
|
||||||
|
if (_graphicsDebugLevel != GraphicsDebugLevel.None)
|
||||||
|
{
|
||||||
|
flags |= OpenGLContextFlags.Debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, _major, _minor, flags);
|
||||||
|
|
||||||
|
Context.Initialize(_window);
|
||||||
|
Context.MakeCurrent(_window);
|
||||||
|
|
||||||
|
var bindingsContext = new OpenToolkitBindingsContext(Context.GetProcAddress);
|
||||||
|
|
||||||
|
GL.LoadBindings(bindingsContext);
|
||||||
|
Context.MakeCurrent(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MakeCurrent()
|
||||||
|
{
|
||||||
|
Context.MakeCurrent(_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MakeCurrent(NativeWindowBase window)
|
||||||
|
{
|
||||||
|
Context.MakeCurrent(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SwapBuffers()
|
||||||
|
{
|
||||||
|
_window.SwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,192 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.OpenGL;
|
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Rendering.SceneGraph;
|
|
||||||
using Avalonia.Skia;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
using OpenTK.Graphics.OpenGL;
|
|
||||||
using Ryujinx.Common.Configuration;
|
|
||||||
using SkiaSharp;
|
|
||||||
using SPB.Graphics;
|
|
||||||
using SPB.Graphics.OpenGL;
|
|
||||||
using SPB.Platform;
|
|
||||||
using SPB.Windowing;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Controls
|
|
||||||
{
|
|
||||||
internal class OpenGLRendererControl : RendererControl
|
|
||||||
{
|
|
||||||
public int Major { get; }
|
|
||||||
public int Minor { get; }
|
|
||||||
public OpenGLContextBase GameContext { get; set; }
|
|
||||||
|
|
||||||
public static OpenGLContextBase PrimaryContext =>
|
|
||||||
AvaloniaLocator.Current.GetService<IPlatformOpenGlInterface>()
|
|
||||||
.PrimaryContext.AsOpenGLContextBase();
|
|
||||||
|
|
||||||
private SwappableNativeWindowBase _gameBackgroundWindow;
|
|
||||||
|
|
||||||
private IntPtr _fence;
|
|
||||||
|
|
||||||
public OpenGLRendererControl(int major, int minor, GraphicsDebugLevel graphicsDebugLevel) : base(graphicsDebugLevel)
|
|
||||||
{
|
|
||||||
Major = major;
|
|
||||||
Minor = minor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DestroyBackgroundContext()
|
|
||||||
{
|
|
||||||
Image = null;
|
|
||||||
|
|
||||||
if (_fence != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
DrawOperation.Dispose();
|
|
||||||
GL.DeleteSync(_fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlDrawOperation.DeleteFramebuffer();
|
|
||||||
|
|
||||||
GameContext?.Dispose();
|
|
||||||
|
|
||||||
_gameBackgroundWindow?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Present(object image)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
Image = (int)image;
|
|
||||||
|
|
||||||
InvalidateVisual();
|
|
||||||
}).Wait();
|
|
||||||
|
|
||||||
if (_fence != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
GL.DeleteSync(_fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
_fence = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None);
|
|
||||||
|
|
||||||
InvalidateVisual();
|
|
||||||
|
|
||||||
_gameBackgroundWindow.SwapBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void MakeCurrent()
|
|
||||||
{
|
|
||||||
GameContext.MakeCurrent(_gameBackgroundWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void MakeCurrent(SwappableNativeWindowBase window)
|
|
||||||
{
|
|
||||||
GameContext.MakeCurrent(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateWindow()
|
|
||||||
{
|
|
||||||
var flags = OpenGLContextFlags.Compat;
|
|
||||||
if (DebugLevel != GraphicsDebugLevel.None)
|
|
||||||
{
|
|
||||||
flags |= OpenGLContextFlags.Debug;
|
|
||||||
}
|
|
||||||
_gameBackgroundWindow = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
|
|
||||||
_gameBackgroundWindow.Hide();
|
|
||||||
|
|
||||||
GameContext = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, Major, Minor, flags, shareContext: PrimaryContext);
|
|
||||||
GameContext.Initialize(_gameBackgroundWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ICustomDrawOperation CreateDrawOperation()
|
|
||||||
{
|
|
||||||
return new GlDrawOperation(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class GlDrawOperation : ICustomDrawOperation
|
|
||||||
{
|
|
||||||
private static int _framebuffer;
|
|
||||||
|
|
||||||
public Rect Bounds { get; }
|
|
||||||
|
|
||||||
private readonly OpenGLRendererControl _control;
|
|
||||||
|
|
||||||
public GlDrawOperation(OpenGLRendererControl control)
|
|
||||||
{
|
|
||||||
_control = control;
|
|
||||||
Bounds = _control.Bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
|
|
||||||
public static void DeleteFramebuffer()
|
|
||||||
{
|
|
||||||
if (_framebuffer == 0)
|
|
||||||
{
|
|
||||||
GL.DeleteFramebuffer(_framebuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
_framebuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(ICustomDrawOperation other)
|
|
||||||
{
|
|
||||||
return other is GlDrawOperation operation && Equals(this, operation) && operation.Bounds == Bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HitTest(Point p)
|
|
||||||
{
|
|
||||||
return Bounds.Contains(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateRenderTarget()
|
|
||||||
{
|
|
||||||
_framebuffer = GL.GenFramebuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Render(IDrawingContextImpl context)
|
|
||||||
{
|
|
||||||
if (_control.Image == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_framebuffer == 0)
|
|
||||||
{
|
|
||||||
CreateRenderTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentFramebuffer = GL.GetInteger(GetPName.FramebufferBinding);
|
|
||||||
|
|
||||||
var image = _control.Image;
|
|
||||||
var fence = _control._fence;
|
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _framebuffer);
|
|
||||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, (int)image, 0);
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, currentFramebuffer);
|
|
||||||
|
|
||||||
if (context is not ISkiaDrawingContextImpl skiaDrawingContextImpl)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var imageInfo = new SKImageInfo((int)_control.RenderSize.Width, (int)_control.RenderSize.Height, SKColorType.Rgba8888);
|
|
||||||
var glInfo = new GRGlFramebufferInfo((uint)_framebuffer, SKColorType.Rgba8888.ToGlSizedFormat());
|
|
||||||
|
|
||||||
GL.WaitSync(fence, WaitSyncFlags.None, ulong.MaxValue);
|
|
||||||
|
|
||||||
using var backendTexture = new GRBackendRenderTarget(imageInfo.Width, imageInfo.Height, 1, 0, glInfo);
|
|
||||||
using var surface = SKSurface.Create(skiaDrawingContextImpl.GrContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
|
|
||||||
|
|
||||||
if (surface == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rect = new Rect(new Point(), _control.RenderSize);
|
|
||||||
|
|
||||||
using var snapshot = surface.Snapshot();
|
|
||||||
skiaDrawingContextImpl.SkCanvas.DrawImage(snapshot, rect.ToSKRect(), _control.Bounds.ToSKRect(), new SKPaint());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,96 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Data;
|
|
||||||
using Avalonia.Media;
|
|
||||||
using Avalonia.Rendering.SceneGraph;
|
|
||||||
using Ryujinx.Common.Configuration;
|
|
||||||
using SPB.Windowing;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Controls
|
|
||||||
{
|
|
||||||
internal abstract class RendererControl : Control
|
|
||||||
{
|
|
||||||
protected object Image { get; set; }
|
|
||||||
|
|
||||||
public event EventHandler<EventArgs> RendererInitialized;
|
|
||||||
public event EventHandler<Size> SizeChanged;
|
|
||||||
|
|
||||||
protected Size RenderSize { get; private set; }
|
|
||||||
public bool IsStarted { get; private set; }
|
|
||||||
|
|
||||||
public GraphicsDebugLevel DebugLevel { get; }
|
|
||||||
|
|
||||||
private bool _isInitialized;
|
|
||||||
|
|
||||||
protected ICustomDrawOperation DrawOperation { get; private set; }
|
|
||||||
|
|
||||||
public RendererControl(GraphicsDebugLevel graphicsDebugLevel)
|
|
||||||
{
|
|
||||||
DebugLevel = graphicsDebugLevel;
|
|
||||||
IObservable<Rect> resizeObservable = this.GetObservable(BoundsProperty);
|
|
||||||
|
|
||||||
resizeObservable.Subscribe(Resized);
|
|
||||||
|
|
||||||
Focusable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Resized(Rect rect)
|
|
||||||
{
|
|
||||||
SizeChanged?.Invoke(this, rect.Size);
|
|
||||||
|
|
||||||
if (!rect.IsEmpty)
|
|
||||||
{
|
|
||||||
RenderSize = rect.Size * VisualRoot.RenderScaling;
|
|
||||||
DrawOperation = CreateDrawOperation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract ICustomDrawOperation CreateDrawOperation();
|
|
||||||
protected abstract void CreateWindow();
|
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
|
||||||
{
|
|
||||||
if (!_isInitialized)
|
|
||||||
{
|
|
||||||
CreateWindow();
|
|
||||||
|
|
||||||
OnRendererInitialized();
|
|
||||||
_isInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsStarted || Image == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DrawOperation != null)
|
|
||||||
{
|
|
||||||
context.Custom(DrawOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Render(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnRendererInitialized()
|
|
||||||
{
|
|
||||||
RendererInitialized?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal abstract void Present(object image);
|
|
||||||
|
|
||||||
internal void Start()
|
|
||||||
{
|
|
||||||
IsStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Stop()
|
|
||||||
{
|
|
||||||
IsStarted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void DestroyBackgroundContext();
|
|
||||||
internal abstract void MakeCurrent();
|
|
||||||
internal abstract void MakeCurrent(SwappableNativeWindowBase window);
|
|
||||||
}
|
|
||||||
}
|
|
14
Ryujinx.Ava/Ui/Controls/RendererHost.axaml
Normal file
14
Ryujinx.Ava/Ui/Controls/RendererHost.axaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Ryujinx.Ava.Ui.Controls.RendererHost">
|
||||||
|
<ContentControl
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Stretch"
|
||||||
|
Name="View"
|
||||||
|
/>
|
||||||
|
</UserControl>
|
126
Ryujinx.Ava/Ui/Controls/RendererHost.axaml.cs
Normal file
126
Ryujinx.Ava/Ui/Controls/RendererHost.axaml.cs
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Silk.NET.Vulkan;
|
||||||
|
using SPB.Graphics.OpenGL;
|
||||||
|
using SPB.Windowing;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui.Controls
|
||||||
|
{
|
||||||
|
public partial class RendererHost : UserControl, IDisposable
|
||||||
|
{
|
||||||
|
private readonly GraphicsDebugLevel _graphicsDebugLevel;
|
||||||
|
private EmbeddedWindow _currentWindow;
|
||||||
|
|
||||||
|
public bool IsVulkan { get; private set; }
|
||||||
|
|
||||||
|
public RendererHost(GraphicsDebugLevel graphicsDebugLevel)
|
||||||
|
{
|
||||||
|
_graphicsDebugLevel = graphicsDebugLevel;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RendererHost()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOpenGL()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
|
||||||
|
_currentWindow = new OpenGLEmbeddedWindow(3, 3, _graphicsDebugLevel);
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
IsVulkan = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Initialize()
|
||||||
|
{
|
||||||
|
_currentWindow.WindowCreated += CurrentWindow_WindowCreated;
|
||||||
|
_currentWindow.SizeChanged += CurrentWindow_SizeChanged;
|
||||||
|
View.Content = _currentWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateVulkan()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
|
||||||
|
_currentWindow = new VulkanEmbeddedWindow();
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
IsVulkan = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenGLContextBase GetContext()
|
||||||
|
{
|
||||||
|
if (_currentWindow is OpenGLEmbeddedWindow openGlEmbeddedWindow)
|
||||||
|
{
|
||||||
|
return openGlEmbeddedWindow.Context;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDetachedFromVisualTree(e);
|
||||||
|
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentWindow_SizeChanged(object sender, Size e)
|
||||||
|
{
|
||||||
|
SizeChanged?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentWindow_WindowCreated(object sender, IntPtr e)
|
||||||
|
{
|
||||||
|
RendererInitialized?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MakeCurrent()
|
||||||
|
{
|
||||||
|
if (_currentWindow is OpenGLEmbeddedWindow openGlEmbeddedWindow)
|
||||||
|
{
|
||||||
|
openGlEmbeddedWindow.MakeCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MakeCurrent(SwappableNativeWindowBase window)
|
||||||
|
{
|
||||||
|
if (_currentWindow is OpenGLEmbeddedWindow openGlEmbeddedWindow)
|
||||||
|
{
|
||||||
|
openGlEmbeddedWindow.MakeCurrent(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SwapBuffers()
|
||||||
|
{
|
||||||
|
if (_currentWindow is OpenGLEmbeddedWindow openGlEmbeddedWindow)
|
||||||
|
{
|
||||||
|
openGlEmbeddedWindow.SwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler<EventArgs> RendererInitialized;
|
||||||
|
public event Action<object, Size> SizeChanged;
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_currentWindow != null)
|
||||||
|
{
|
||||||
|
_currentWindow.WindowCreated -= CurrentWindow_WindowCreated;
|
||||||
|
_currentWindow.SizeChanged -= CurrentWindow_SizeChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SurfaceKHR CreateVulkanSurface(Instance instance, Vk api)
|
||||||
|
{
|
||||||
|
return (_currentWindow is VulkanEmbeddedWindow vulkanEmbeddedWindow)
|
||||||
|
? vulkanEmbeddedWindow.CreateSurface(instance)
|
||||||
|
: default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
Ryujinx.Ava/Ui/Controls/VulkanEmbeddedWindow.cs
Normal file
33
Ryujinx.Ava/Ui/Controls/VulkanEmbeddedWindow.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Ryujinx.Ava.Ui.Controls;
|
||||||
|
using Silk.NET.Vulkan;
|
||||||
|
using SPB.Graphics.Vulkan;
|
||||||
|
using SPB.Platform.Win32;
|
||||||
|
using SPB.Platform.X11;
|
||||||
|
using SPB.Windowing;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui
|
||||||
|
{
|
||||||
|
public class VulkanEmbeddedWindow : EmbeddedWindow
|
||||||
|
{
|
||||||
|
private NativeWindowBase _window;
|
||||||
|
|
||||||
|
public SurfaceKHR CreateSurface(Instance instance)
|
||||||
|
{
|
||||||
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
_window = new SimpleWin32Window(new NativeHandle(WindowHandle));
|
||||||
|
}
|
||||||
|
else if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
_window = X11Window;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SurfaceKHR((ulong?)VulkanHelper.CreateWindowSurface(instance.Handle, _window));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,220 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Media;
|
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Rendering.SceneGraph;
|
|
||||||
using Avalonia.Skia;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
using Ryujinx.Ava.Ui.Backend.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Common.Configuration;
|
|
||||||
using Ryujinx.Graphics.Vulkan;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using SkiaSharp;
|
|
||||||
using SPB.Windowing;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Ui.Controls
|
|
||||||
{
|
|
||||||
internal class VulkanRendererControl : RendererControl
|
|
||||||
{
|
|
||||||
private const int MaxImagesInFlight = 3;
|
|
||||||
|
|
||||||
private VulkanPlatformInterface _platformInterface;
|
|
||||||
private ConcurrentQueue<PresentImageInfo> _imagesInFlight;
|
|
||||||
private PresentImageInfo _currentImage;
|
|
||||||
|
|
||||||
public VulkanRendererControl(GraphicsDebugLevel graphicsDebugLevel) : base(graphicsDebugLevel)
|
|
||||||
{
|
|
||||||
_platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
|
|
||||||
_imagesInFlight = new ConcurrentQueue<PresentImageInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DestroyBackgroundContext()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ICustomDrawOperation CreateDrawOperation()
|
|
||||||
{
|
|
||||||
return new VulkanDrawOperation(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnDetachedFromVisualTree(e);
|
|
||||||
|
|
||||||
_imagesInFlight.Clear();
|
|
||||||
|
|
||||||
if (_platformInterface.MainSurface.Display != null)
|
|
||||||
{
|
|
||||||
_platformInterface.MainSurface.Display.Presented -= Window_Presented;
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentImage?.Put();
|
|
||||||
_currentImage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnAttachedToVisualTree(e);
|
|
||||||
|
|
||||||
_platformInterface.MainSurface.Display.Presented += Window_Presented;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Window_Presented(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_platformInterface.MainSurface.Device.QueueWaitIdle();
|
|
||||||
_currentImage?.Put();
|
|
||||||
_currentImage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
|
||||||
{
|
|
||||||
base.Render(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void MakeCurrent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void MakeCurrent(SwappableNativeWindowBase window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Present(object image)
|
|
||||||
{
|
|
||||||
Image = image;
|
|
||||||
|
|
||||||
_imagesInFlight.Enqueue((PresentImageInfo)image);
|
|
||||||
|
|
||||||
if (_imagesInFlight.Count > MaxImagesInFlight)
|
|
||||||
{
|
|
||||||
_imagesInFlight.TryDequeue(out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(InvalidateVisual);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PresentImageInfo GetImage()
|
|
||||||
{
|
|
||||||
lock (_imagesInFlight)
|
|
||||||
{
|
|
||||||
if (!_imagesInFlight.TryDequeue(out _currentImage))
|
|
||||||
{
|
|
||||||
_currentImage = (PresentImageInfo)Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _currentImage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class VulkanDrawOperation : ICustomDrawOperation
|
|
||||||
{
|
|
||||||
public Rect Bounds { get; }
|
|
||||||
|
|
||||||
private readonly VulkanRendererControl _control;
|
|
||||||
private bool _isDestroyed;
|
|
||||||
|
|
||||||
public VulkanDrawOperation(VulkanRendererControl control)
|
|
||||||
{
|
|
||||||
_control = control;
|
|
||||||
Bounds = _control.Bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_isDestroyed)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_isDestroyed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(ICustomDrawOperation other)
|
|
||||||
{
|
|
||||||
return other is VulkanDrawOperation operation && Equals(this, operation) && operation.Bounds == Bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HitTest(Point p)
|
|
||||||
{
|
|
||||||
return Bounds.Contains(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe void Render(IDrawingContextImpl context)
|
|
||||||
{
|
|
||||||
if (_isDestroyed || _control.Image == null || _control.RenderSize.Width == 0 || _control.RenderSize.Height == 0 ||
|
|
||||||
context is not ISkiaDrawingContextImpl skiaDrawingContextImpl)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var image = _control.GetImage();
|
|
||||||
|
|
||||||
if (!image.State.IsValid)
|
|
||||||
{
|
|
||||||
_control._currentImage = null;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var gpu = AvaloniaLocator.Current.GetService<VulkanSkiaGpu>();
|
|
||||||
|
|
||||||
image.Get();
|
|
||||||
|
|
||||||
var imageInfo = new GRVkImageInfo()
|
|
||||||
{
|
|
||||||
CurrentQueueFamily = _control._platformInterface.PhysicalDevice.QueueFamilyIndex,
|
|
||||||
Format = (uint)Format.R8G8B8A8Unorm,
|
|
||||||
Image = image.Image.Handle,
|
|
||||||
ImageLayout = (uint)ImageLayout.TransferSrcOptimal,
|
|
||||||
ImageTiling = (uint)ImageTiling.Optimal,
|
|
||||||
ImageUsageFlags = (uint)(ImageUsageFlags.ImageUsageColorAttachmentBit
|
|
||||||
| ImageUsageFlags.ImageUsageTransferSrcBit
|
|
||||||
| ImageUsageFlags.ImageUsageTransferDstBit),
|
|
||||||
LevelCount = 1,
|
|
||||||
SampleCount = 1,
|
|
||||||
Protected = false,
|
|
||||||
Alloc = new GRVkAlloc()
|
|
||||||
{
|
|
||||||
Memory = image.Memory.Handle,
|
|
||||||
Flags = 0,
|
|
||||||
Offset = image.MemoryOffset,
|
|
||||||
Size = image.MemorySize
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using var backendTexture = new GRBackendRenderTarget(
|
|
||||||
(int)image.Extent.Width,
|
|
||||||
(int)image.Extent.Height,
|
|
||||||
1,
|
|
||||||
imageInfo);
|
|
||||||
|
|
||||||
var vulkan = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
|
|
||||||
using var surface = SKSurface.Create(
|
|
||||||
skiaDrawingContextImpl.GrContext,
|
|
||||||
backendTexture,
|
|
||||||
GRSurfaceOrigin.TopLeft,
|
|
||||||
SKColorType.Rgba8888);
|
|
||||||
|
|
||||||
if (surface == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rect = new Rect(new Point(), new Size(image.Extent.Width, image.Extent.Height));
|
|
||||||
|
|
||||||
using var snapshot = surface.Snapshot();
|
|
||||||
skiaDrawingContextImpl.SkCanvas.DrawImage(snapshot, rect.ToSKRect(), _control.Bounds.ToSKRect(),
|
|
||||||
new SKPaint());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
113
Ryujinx.Ava/Ui/Controls/Win32NativeInterop.cs
Normal file
113
Ryujinx.Ava/Ui/Controls/Win32NativeInterop.cs
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui.Controls
|
||||||
|
{
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
internal class Win32NativeInterop
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum ClassStyles : uint
|
||||||
|
{
|
||||||
|
CS_CLASSDC = 0x40,
|
||||||
|
CS_OWNDC = 0x20,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum WindowStyles : uint
|
||||||
|
{
|
||||||
|
WS_CHILD = 0x40000000
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Cursors : uint
|
||||||
|
{
|
||||||
|
IDC_ARROW = 32512
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WindowsMessages : uint
|
||||||
|
{
|
||||||
|
MOUSEMOVE = 0x0200,
|
||||||
|
LBUTTONDOWN = 0x0201,
|
||||||
|
LBUTTONUP = 0x0202,
|
||||||
|
LBUTTONDBLCLK = 0x0203,
|
||||||
|
RBUTTONDOWN = 0x0204,
|
||||||
|
RBUTTONUP = 0x0205,
|
||||||
|
RBUTTONDBLCLK = 0x0206,
|
||||||
|
MBUTTONDOWN = 0x0207,
|
||||||
|
MBUTTONUP = 0x0208,
|
||||||
|
MBUTTONDBLCLK = 0x0209,
|
||||||
|
MOUSEWHEEL = 0x020A,
|
||||||
|
XBUTTONDOWN = 0x020B,
|
||||||
|
XBUTTONUP = 0x020C,
|
||||||
|
XBUTTONDBLCLK = 0x020D,
|
||||||
|
MOUSEHWHEEL = 0x020E,
|
||||||
|
MOUSELAST = 0x020E
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
||||||
|
internal delegate IntPtr WindowProc(IntPtr hWnd, WindowsMessages msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
public struct WNDCLASSEX
|
||||||
|
{
|
||||||
|
public int cbSize;
|
||||||
|
public ClassStyles style;
|
||||||
|
[MarshalAs(UnmanagedType.FunctionPtr)]
|
||||||
|
public WindowProc lpfnWndProc; // not WndProc
|
||||||
|
public int cbClsExtra;
|
||||||
|
public int cbWndExtra;
|
||||||
|
public IntPtr hInstance;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
public IntPtr hCursor;
|
||||||
|
public IntPtr hbrBackground;
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
public string lpszMenuName;
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
public string lpszClassName;
|
||||||
|
public IntPtr hIconSm;
|
||||||
|
|
||||||
|
public static WNDCLASSEX Create()
|
||||||
|
{
|
||||||
|
return new WNDCLASSEX
|
||||||
|
{
|
||||||
|
cbSize = Marshal.SizeOf<WNDCLASSEX>()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
public static extern ushort RegisterClassEx(ref WNDCLASSEX param);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
public static extern short UnregisterClass([MarshalAs(UnmanagedType.LPWStr)] string lpClassName, IntPtr instance);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||||
|
public static extern IntPtr DefWindowProc(IntPtr hWnd, WindowsMessages msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool DestroyWindow(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
public static extern IntPtr LoadCursor(IntPtr hInstance, IntPtr lpCursorName);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
public static extern IntPtr CreateWindowEx(
|
||||||
|
uint dwExStyle,
|
||||||
|
string lpClassName,
|
||||||
|
string lpWindowName,
|
||||||
|
WindowStyles dwStyle,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
IntPtr hWndParent,
|
||||||
|
IntPtr hMenu,
|
||||||
|
IntPtr hInstance,
|
||||||
|
IntPtr lpParam);
|
||||||
|
}
|
||||||
|
}
|
@@ -10,7 +10,6 @@ using Ryujinx.Audio.Backends.SoundIo;
|
|||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.Input;
|
using Ryujinx.Ava.Input;
|
||||||
using Ryujinx.Ava.Ui.Controls;
|
using Ryujinx.Ava.Ui.Controls;
|
||||||
using Ryujinx.Ava.Ui.Vulkan;
|
|
||||||
using Ryujinx.Ava.Ui.Windows;
|
using Ryujinx.Ava.Ui.Windows;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
@@ -252,8 +251,6 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
{
|
{
|
||||||
_gpuIds = new List<string>();
|
_gpuIds = new List<string>();
|
||||||
List<string> names = new List<string>();
|
List<string> names = new List<string>();
|
||||||
if (!Program.UseVulkan)
|
|
||||||
{
|
|
||||||
var devices = VulkanRenderer.GetPhysicalDevices();
|
var devices = VulkanRenderer.GetPhysicalDevices();
|
||||||
|
|
||||||
if (devices.Length == 0)
|
if (devices.Length == 0)
|
||||||
@@ -269,19 +266,6 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
names.Add($"{device.Name} {(device.IsDiscrete ? "(dGPU)" : "")}");
|
names.Add($"{device.Name} {(device.IsDiscrete ? "(dGPU)" : "")}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var device in VulkanPhysicalDevice.SuitableDevices)
|
|
||||||
{
|
|
||||||
_gpuIds.Add(
|
|
||||||
VulkanInitialization.StringFromIdPair(device.Value.VendorID, device.Value.DeviceID));
|
|
||||||
var value = device.Value;
|
|
||||||
var name = value.DeviceName;
|
|
||||||
names.Add(
|
|
||||||
$"{Marshal.PtrToStringAnsi((IntPtr)name)} {(device.Value.DeviceType == PhysicalDeviceType.DiscreteGpu ? "(dGPU)" : "")}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AvailableGpus.Clear();
|
AvailableGpus.Clear();
|
||||||
AvailableGpus.AddRange(names.Select(x => new ComboBoxItem() { Content = x }));
|
AvailableGpus.AddRange(names.Select(x => new ComboBoxItem() { Content = x }));
|
||||||
@@ -407,7 +391,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
_previousVolumeLevel = Volume;
|
_previousVolumeLevel = Volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveSettings()
|
public void SaveSettings()
|
||||||
{
|
{
|
||||||
ConfigurationState config = ConfigurationState.Instance;
|
ConfigurationState config = ConfigurationState.Instance;
|
||||||
|
|
||||||
@@ -422,8 +406,6 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
config.System.TimeZone.Value = TimeZone;
|
config.System.TimeZone.Value = TimeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool requiresRestart = config.Graphics.GraphicsBackend.Value != (GraphicsBackend)GraphicsBackendIndex;
|
|
||||||
|
|
||||||
config.Logger.EnableError.Value = EnableError;
|
config.Logger.EnableError.Value = EnableError;
|
||||||
config.Logger.EnableTrace.Value = EnableTrace;
|
config.Logger.EnableTrace.Value = EnableTrace;
|
||||||
config.Logger.EnableWarn.Value = EnableWarn;
|
config.Logger.EnableWarn.Value = EnableWarn;
|
||||||
@@ -456,19 +438,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
config.System.Language.Value = (Language)Language;
|
config.System.Language.Value = (Language)Language;
|
||||||
config.System.Region.Value = (Region)Region;
|
config.System.Region.Value = (Region)Region;
|
||||||
|
|
||||||
var selectedGpu = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
|
config.Graphics.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
|
||||||
if (!requiresRestart)
|
|
||||||
{
|
|
||||||
var platform = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
|
||||||
if (platform != null)
|
|
||||||
{
|
|
||||||
var physicalDevice = platform.PhysicalDevice;
|
|
||||||
|
|
||||||
requiresRestart = physicalDevice.DeviceId != selectedGpu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config.Graphics.PreferredGpu.Value = selectedGpu;
|
|
||||||
|
|
||||||
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
|
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
|
||||||
{
|
{
|
||||||
@@ -507,20 +477,6 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
|||||||
MainWindow.UpdateGraphicsConfig();
|
MainWindow.UpdateGraphicsConfig();
|
||||||
|
|
||||||
_previousVolumeLevel = Volume;
|
_previousVolumeLevel = Volume;
|
||||||
|
|
||||||
if (requiresRestart)
|
|
||||||
{
|
|
||||||
var choice = await ContentDialogHelper.CreateChoiceDialog(
|
|
||||||
LocaleManager.Instance["SettingsAppRequiredRestartMessage"],
|
|
||||||
LocaleManager.Instance["SettingsGpuBackendRestartMessage"],
|
|
||||||
LocaleManager.Instance["SettingsGpuBackendRestartSubMessage"]);
|
|
||||||
|
|
||||||
if (choice)
|
|
||||||
{
|
|
||||||
Process.Start(Environment.ProcessPath);
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RevertIfNotSaved()
|
public void RevertIfNotSaved()
|
||||||
|
27
Ryujinx.Ava/Ui/Windows/ContentDialogOverlayWindow.axaml
Normal file
27
Ryujinx.Ava/Ui/Windows/ContentDialogOverlayWindow.axaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<window:StyleableWindow xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
x:Class="Ryujinx.Ava.Ui.Windows.ContentDialogOverlayWindow"
|
||||||
|
xmlns:window="clr-namespace:Ryujinx.Ava.Ui.Windows"
|
||||||
|
Title="ContentDialogOverlayWindow">
|
||||||
|
<window:StyleableWindow.Styles>
|
||||||
|
<Style Selector="ui|ContentDialog /template/ Panel#LayoutRoot">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</window:StyleableWindow.Styles>
|
||||||
|
<ContentControl
|
||||||
|
Focusable="False"
|
||||||
|
IsVisible="False"
|
||||||
|
KeyboardNavigation.IsTabStop="False">
|
||||||
|
<ui:ContentDialog Name="ContentDialog"
|
||||||
|
IsPrimaryButtonEnabled="True"
|
||||||
|
IsSecondaryButtonEnabled="True"
|
||||||
|
IsVisible="False" />
|
||||||
|
</ContentControl>
|
||||||
|
</window:StyleableWindow>
|
25
Ryujinx.Ava/Ui/Windows/ContentDialogOverlayWindow.axaml.cs
Normal file
25
Ryujinx.Ava/Ui/Windows/ContentDialogOverlayWindow.axaml.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Ui.Windows
|
||||||
|
{
|
||||||
|
public partial class ContentDialogOverlayWindow : StyleableWindow
|
||||||
|
{
|
||||||
|
public ContentDialogOverlayWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
#if DEBUG
|
||||||
|
this.AttachDevTools();
|
||||||
|
#endif
|
||||||
|
ExtendClientAreaToDecorationsHint = true;
|
||||||
|
TransparencyLevelHint = WindowTransparencyLevel.Transparent;
|
||||||
|
WindowStartupLocation = WindowStartupLocation.Manual;
|
||||||
|
SystemDecorations = SystemDecorations.None;
|
||||||
|
ExtendClientAreaTitleBarHeightHint = 0;
|
||||||
|
Background = Brushes.Transparent;
|
||||||
|
CanResize = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -462,6 +462,7 @@
|
|||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Background="{DynamicResource ThemeContentBackgroundColor}"
|
Background="{DynamicResource ThemeContentBackgroundColor}"
|
||||||
IsVisible="{Binding ShowLoadProgress}"
|
IsVisible="{Binding ShowLoadProgress}"
|
||||||
|
Name="LoadingView"
|
||||||
ZIndex="1000">
|
ZIndex="1000">
|
||||||
<Grid
|
<Grid
|
||||||
Margin="40"
|
Margin="40"
|
||||||
|
@@ -58,7 +58,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
internal AppHost AppHost { get; private set; }
|
internal AppHost AppHost { get; private set; }
|
||||||
public InputManager InputManager { get; private set; }
|
public InputManager InputManager { get; private set; }
|
||||||
|
|
||||||
internal RendererControl RendererControl { get; private set; }
|
internal RendererHost RendererControl { get; private set; }
|
||||||
internal MainWindowViewModel ViewModel { get; private set; }
|
internal MainWindowViewModel ViewModel { get; private set; }
|
||||||
public SettingsWindow SettingsWindow { get; set; }
|
public SettingsWindow SettingsWindow { get; set; }
|
||||||
|
|
||||||
@@ -237,7 +237,16 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
|
|
||||||
_mainViewContent = MainContent.Content as Control;
|
_mainViewContent = MainContent.Content as Control;
|
||||||
|
|
||||||
RendererControl = Program.UseVulkan ? new VulkanRendererControl(ConfigurationState.Instance.Logger.GraphicsDebugLevel) : new OpenGLRendererControl(3, 3, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
RendererControl = new RendererHost(ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
||||||
|
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.OpenGl)
|
||||||
|
{
|
||||||
|
RendererControl.CreateOpenGL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RendererControl.CreateVulkan();
|
||||||
|
}
|
||||||
|
|
||||||
AppHost = new AppHost(RendererControl, InputManager, path, VirtualFileSystem, ContentManager, AccountManager, _userChannelPersistence, this);
|
AppHost = new AppHost(RendererControl, InputManager, path, VirtualFileSystem, ContentManager, AccountManager, _userChannelPersistence, this);
|
||||||
|
|
||||||
if (!AppHost.LoadGuestApplication().Result)
|
if (!AppHost.LoadGuestApplication().Result)
|
||||||
@@ -296,8 +305,8 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
|
|
||||||
public void SwitchToGameControl(bool startFullscreen = false)
|
public void SwitchToGameControl(bool startFullscreen = false)
|
||||||
{
|
{
|
||||||
ViewModel.ShowContent = true;
|
|
||||||
ViewModel.ShowLoadProgress = false;
|
ViewModel.ShowLoadProgress = false;
|
||||||
|
ViewModel.ShowContent = true;
|
||||||
ViewModel.IsLoadingIndeterminate = false;
|
ViewModel.IsLoadingIndeterminate = false;
|
||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
@@ -346,17 +355,17 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
if (MainContent.Content != _mainViewContent)
|
|
||||||
{
|
|
||||||
MainContent.Content = _mainViewContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewModel.ShowMenuAndStatusBar = true;
|
ViewModel.ShowMenuAndStatusBar = true;
|
||||||
ViewModel.ShowContent = true;
|
ViewModel.ShowContent = true;
|
||||||
ViewModel.ShowLoadProgress = false;
|
ViewModel.ShowLoadProgress = false;
|
||||||
ViewModel.IsLoadingIndeterminate = false;
|
ViewModel.IsLoadingIndeterminate = false;
|
||||||
Cursor = Cursor.Default;
|
Cursor = Cursor.Default;
|
||||||
|
|
||||||
|
if (MainContent.Content != _mainViewContent)
|
||||||
|
{
|
||||||
|
MainContent.Content = _mainViewContent;
|
||||||
|
}
|
||||||
|
|
||||||
AppHost = null;
|
AppHost = null;
|
||||||
|
|
||||||
HandleRelaunch();
|
HandleRelaunch();
|
||||||
|
@@ -211,9 +211,9 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SaveButton_Clicked(object sender, RoutedEventArgs e)
|
private void SaveButton_Clicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await SaveSettings();
|
SaveSettings();
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@@ -224,14 +224,14 @@ namespace Ryujinx.Ava.Ui.Windows
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ApplyButton_Clicked(object sender, RoutedEventArgs e)
|
private void ApplyButton_Clicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveSettings()
|
private void SaveSettings()
|
||||||
{
|
{
|
||||||
await ViewModel.SaveSettings();
|
ViewModel.SaveSettings();
|
||||||
|
|
||||||
ControllerSettings?.SaveCurrentProfile();
|
ControllerSettings?.SaveCurrentProfile();
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
{
|
{
|
||||||
public interface IWindow
|
public interface IWindow
|
||||||
{
|
{
|
||||||
void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback);
|
void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback);
|
||||||
|
|
||||||
void SetSize(int width, int height);
|
void SetSize(int width, int height);
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Window
|
|||||||
public CommandType CommandType => CommandType.WindowPresent;
|
public CommandType CommandType => CommandType.WindowPresent;
|
||||||
private TableRef<ThreadedTexture> _texture;
|
private TableRef<ThreadedTexture> _texture;
|
||||||
private ImageCrop _crop;
|
private ImageCrop _crop;
|
||||||
private TableRef<Action<object>> _swapBuffersCallback;
|
private TableRef<Action> _swapBuffersCallback;
|
||||||
|
|
||||||
public void Set(TableRef<ThreadedTexture> texture, ImageCrop crop, TableRef<Action<object>> swapBuffersCallback)
|
public void Set(TableRef<ThreadedTexture> texture, ImageCrop crop, TableRef<Action> swapBuffersCallback)
|
||||||
{
|
{
|
||||||
_texture = texture;
|
_texture = texture;
|
||||||
_crop = crop;
|
_crop = crop;
|
||||||
|
@@ -16,13 +16,13 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
|||||||
_impl = impl;
|
_impl = impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback)
|
public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
// If there's already a frame in the pipeline, wait for it to be presented first.
|
// If there's already a frame in the pipeline, wait for it to be presented first.
|
||||||
// This is a multithread rate limit - we can't be more than one frame behind the command queue.
|
// This is a multithread rate limit - we can't be more than one frame behind the command queue.
|
||||||
|
|
||||||
_renderer.WaitForFrame();
|
_renderer.WaitForFrame();
|
||||||
_renderer.New<WindowPresentCommand>().Set(new TableRef<ThreadedTexture>(_renderer, texture as ThreadedTexture), crop, new TableRef<Action<object>>(_renderer, swapBuffersCallback));
|
_renderer.New<WindowPresentCommand>().Set(new TableRef<ThreadedTexture>(_renderer, texture as ThreadedTexture), crop, new TableRef<Action>(_renderer, swapBuffersCallback));
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
{
|
{
|
||||||
@@ -151,10 +152,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
|
|
||||||
ulong ticks = _context.GetTimestamp();
|
ulong ticks = _context.GetTimestamp();
|
||||||
|
|
||||||
|
float divisor = type switch
|
||||||
|
{
|
||||||
|
ReportCounterType.SamplesPassed => _channel.TextureManager.RenderTargetScale * _channel.TextureManager.RenderTargetScale,
|
||||||
|
_ => 1f
|
||||||
|
};
|
||||||
|
|
||||||
ICounterEvent counter = null;
|
ICounterEvent counter = null;
|
||||||
|
|
||||||
void resultHandler(object evt, ulong result)
|
void resultHandler(object evt, ulong result)
|
||||||
{
|
{
|
||||||
|
if (divisor != 1f)
|
||||||
|
{
|
||||||
|
result = (ulong)MathF.Ceiling(result / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
CounterData counterData = new CounterData
|
CounterData counterData = new CounterData
|
||||||
{
|
{
|
||||||
Counter = result,
|
Counter = result,
|
||||||
|
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
private const ushort FileFormatVersionMajor = 1;
|
private const ushort FileFormatVersionMajor = 1;
|
||||||
private const ushort FileFormatVersionMinor = 2;
|
private const ushort FileFormatVersionMinor = 2;
|
||||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||||
private const uint CodeGenVersion = 3644;
|
private const uint CodeGenVersion = 3697;
|
||||||
|
|
||||||
private const string SharedTocFileName = "shared.toc";
|
private const string SharedTocFileName = "shared.toc";
|
||||||
private const string SharedDataFileName = "shared.data";
|
private const string SharedDataFileName = "shared.data";
|
||||||
|
@@ -191,7 +191,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
/// If the queue is empty, then no texture is presented.
|
/// If the queue is empty, then no texture is presented.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="swapBuffersCallback">Callback method to call when a new texture should be presented on the screen</param>
|
/// <param name="swapBuffersCallback">Callback method to call when a new texture should be presented on the screen</param>
|
||||||
public void Present(Action<object> swapBuffersCallback)
|
public void Present(Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
_context.AdvanceSequence();
|
_context.AdvanceSequence();
|
||||||
|
|
||||||
|
@@ -12,11 +12,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
|
|
||||||
private int _width;
|
private int _width;
|
||||||
private int _height;
|
private int _height;
|
||||||
private bool _sizeChanged;
|
|
||||||
private int _copyFramebufferHandle;
|
private int _copyFramebufferHandle;
|
||||||
private int _stagingFrameBuffer;
|
|
||||||
private int[] _stagingTextures;
|
|
||||||
private int _currentTexture;
|
|
||||||
|
|
||||||
internal BackgroundContextWorker BackgroundContext { get; private set; }
|
internal BackgroundContextWorker BackgroundContext { get; private set; }
|
||||||
|
|
||||||
@@ -25,28 +21,15 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
public Window(OpenGLRenderer renderer)
|
public Window(OpenGLRenderer renderer)
|
||||||
{
|
{
|
||||||
_renderer = renderer;
|
_renderer = renderer;
|
||||||
_stagingTextures = new int[TextureCount];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback)
|
public void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.FramebufferSrgb);
|
GL.Disable(EnableCap.FramebufferSrgb);
|
||||||
|
|
||||||
if (_sizeChanged)
|
|
||||||
{
|
|
||||||
if (_stagingFrameBuffer != 0)
|
|
||||||
{
|
|
||||||
GL.DeleteTextures(_stagingTextures.Length, _stagingTextures);
|
|
||||||
GL.DeleteFramebuffer(_stagingFrameBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateStagingFramebuffer();
|
|
||||||
_sizeChanged = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
(int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();
|
(int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();
|
||||||
|
|
||||||
CopyTextureToFrameBufferRGB(_stagingFrameBuffer, GetCopyFramebufferHandleLazy(), (TextureView)texture, crop, swapBuffersCallback);
|
CopyTextureToFrameBufferRGB(0, GetCopyFramebufferHandleLazy(), (TextureView)texture, crop, swapBuffersCallback);
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
|
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
|
||||||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);
|
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);
|
||||||
@@ -59,41 +42,17 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
|
|
||||||
public void ChangeVSyncMode(bool vsyncEnabled) { }
|
public void ChangeVSyncMode(bool vsyncEnabled) { }
|
||||||
|
|
||||||
private void CreateStagingFramebuffer()
|
|
||||||
{
|
|
||||||
_stagingFrameBuffer = GL.GenFramebuffer();
|
|
||||||
GL.GenTextures(_stagingTextures.Length, _stagingTextures);
|
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _stagingFrameBuffer);
|
|
||||||
|
|
||||||
foreach (var stagingTexture in _stagingTextures)
|
|
||||||
{
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, stagingTexture);
|
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, _width, _height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
|
|
||||||
|
|
||||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
|
|
||||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
|
|
||||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, stagingTexture, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSize(int width, int height)
|
public void SetSize(int width, int height)
|
||||||
{
|
{
|
||||||
_width = width;
|
_width = width;
|
||||||
_height = height;
|
_height = height;
|
||||||
_sizeChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyTextureToFrameBufferRGB(int drawFramebuffer, int readFramebuffer, TextureView view, ImageCrop crop, Action<object> swapBuffersCallback)
|
private void CopyTextureToFrameBufferRGB(int drawFramebuffer, int readFramebuffer, TextureView view, ImageCrop crop, Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, drawFramebuffer);
|
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, drawFramebuffer);
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, readFramebuffer);
|
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, readFramebuffer);
|
||||||
|
|
||||||
GL.FramebufferTexture2D(FramebufferTarget.DrawFramebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, _stagingTextures[_currentTexture], 0);
|
|
||||||
|
|
||||||
TextureView viewConverted = view.Format.IsBgr() ? _renderer.TextureCopy.BgraSwap(view) : view;
|
TextureView viewConverted = view.Format.IsBgr() ? _renderer.TextureCopy.BgraSwap(view) : view;
|
||||||
|
|
||||||
GL.FramebufferTexture(
|
GL.FramebufferTexture(
|
||||||
@@ -189,12 +148,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
// Set clip control, viewport and the framebuffer to the output to placate overlays and OBS capture.
|
// Set clip control, viewport and the framebuffer to the output to placate overlays and OBS capture.
|
||||||
GL.ClipControl(ClipOrigin.LowerLeft, ClipDepthMode.NegativeOneToOne);
|
GL.ClipControl(ClipOrigin.LowerLeft, ClipDepthMode.NegativeOneToOne);
|
||||||
GL.Viewport(0, 0, _width, _height);
|
GL.Viewport(0, 0, _width, _height);
|
||||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, drawFramebuffer);
|
|
||||||
|
|
||||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, _stagingFrameBuffer);
|
swapBuffersCallback();
|
||||||
|
|
||||||
swapBuffersCallback((object)_stagingTextures[_currentTexture]);
|
|
||||||
_currentTexture = ++_currentTexture % _stagingTextures.Length;
|
|
||||||
|
|
||||||
((Pipeline)_renderer.Pipeline).RestoreClipControl();
|
((Pipeline)_renderer.Pipeline).RestoreClipControl();
|
||||||
((Pipeline)_renderer.Pipeline).RestoreScissor0Enable();
|
((Pipeline)_renderer.Pipeline).RestoreScissor0Enable();
|
||||||
@@ -246,14 +201,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
|
|
||||||
_copyFramebufferHandle = 0;
|
_copyFramebufferHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_stagingFrameBuffer != 0)
|
|
||||||
{
|
|
||||||
GL.DeleteTextures(_stagingTextures.Length, _stagingTextures);
|
|
||||||
GL.DeleteFramebuffer(_stagingFrameBuffer);
|
|
||||||
_stagingFrameBuffer = 0;
|
|
||||||
_stagingTextures = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||||||
{ 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 }
|
{ 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 }
|
||||||
};
|
};
|
||||||
|
|
||||||
private const bool Sample1DAs2D = true;
|
public const bool Sample1DAs2D = true;
|
||||||
|
|
||||||
private enum TexsType
|
private enum TexsType
|
||||||
{
|
{
|
||||||
|
@@ -180,6 +180,18 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||||||
_sources[index] = source;
|
_sources[index] = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InsertSource(int index, Operand source)
|
||||||
|
{
|
||||||
|
Operand[] newSources = new Operand[_sources.Length + 1];
|
||||||
|
|
||||||
|
Array.Copy(_sources, 0, newSources, 0, index);
|
||||||
|
Array.Copy(_sources, index, newSources, index + 1, _sources.Length - index);
|
||||||
|
|
||||||
|
newSources[index] = source;
|
||||||
|
|
||||||
|
_sources = newSources;
|
||||||
|
}
|
||||||
|
|
||||||
protected void RemoveSource(int index)
|
protected void RemoveSource(int index)
|
||||||
{
|
{
|
||||||
SetSource(index, null);
|
SetSource(index, null);
|
||||||
|
@@ -60,5 +60,10 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||||||
CbufSlot = cbufSlot;
|
CbufSlot = cbufSlot;
|
||||||
Handle = handle;
|
Handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLodLevelFlag()
|
||||||
|
{
|
||||||
|
Flags |= TextureFlags.LodLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
using Ryujinx.Graphics.Shader.Instructions;
|
||||||
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
||||||
@@ -30,11 +31,19 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
texOp.Inst == Instruction.TextureSize)
|
texOp.Inst == Instruction.TextureSize)
|
||||||
{
|
{
|
||||||
Operand bindlessHandle = Utils.FindLastOperation(texOp.GetSource(0), block);
|
Operand bindlessHandle = Utils.FindLastOperation(texOp.GetSource(0), block);
|
||||||
bool rewriteSamplerType = texOp.Inst == Instruction.TextureSize;
|
|
||||||
|
// Some instructions do not encode an accurate sampler type:
|
||||||
|
// - Most instructions uses the same type for 1D and Buffer.
|
||||||
|
// - Query instructions may not have any type.
|
||||||
|
// For those cases, we need to try getting the type from current GPU state,
|
||||||
|
// as long bindless elimination is successful and we know where the texture descriptor is located.
|
||||||
|
bool rewriteSamplerType =
|
||||||
|
texOp.Type == SamplerType.TextureBuffer ||
|
||||||
|
texOp.Inst == Instruction.TextureSize;
|
||||||
|
|
||||||
if (bindlessHandle.Type == OperandType.ConstantBuffer)
|
if (bindlessHandle.Type == OperandType.ConstantBuffer)
|
||||||
{
|
{
|
||||||
SetHandle(config, texOp, bindlessHandle.GetCbufOffset(), bindlessHandle.GetCbufSlot(), rewriteSamplerType);
|
SetHandle(config, texOp, bindlessHandle.GetCbufOffset(), bindlessHandle.GetCbufSlot(), rewriteSamplerType, isImage: false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +146,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
texOp,
|
texOp,
|
||||||
TextureHandle.PackOffsets(src0.GetCbufOffset(), ((src1.Value >> 20) & 0xfff), handleType),
|
TextureHandle.PackOffsets(src0.GetCbufOffset(), ((src1.Value >> 20) & 0xfff), handleType),
|
||||||
TextureHandle.PackSlots(src0.GetCbufSlot(), 0),
|
TextureHandle.PackSlots(src0.GetCbufSlot(), 0),
|
||||||
rewriteSamplerType);
|
rewriteSamplerType,
|
||||||
|
isImage: false);
|
||||||
}
|
}
|
||||||
else if (src1.Type == OperandType.ConstantBuffer)
|
else if (src1.Type == OperandType.ConstantBuffer)
|
||||||
{
|
{
|
||||||
@@ -146,7 +156,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
texOp,
|
texOp,
|
||||||
TextureHandle.PackOffsets(src0.GetCbufOffset(), src1.GetCbufOffset(), handleType),
|
TextureHandle.PackOffsets(src0.GetCbufOffset(), src1.GetCbufOffset(), handleType),
|
||||||
TextureHandle.PackSlots(src0.GetCbufSlot(), src1.GetCbufSlot()),
|
TextureHandle.PackSlots(src0.GetCbufSlot(), src1.GetCbufSlot()),
|
||||||
rewriteSamplerType);
|
rewriteSamplerType,
|
||||||
|
isImage: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (texOp.Inst == Instruction.ImageLoad ||
|
else if (texOp.Inst == Instruction.ImageLoad ||
|
||||||
@@ -172,7 +183,9 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHandle(config, texOp, cbufOffset, cbufSlot, false);
|
bool rewriteSamplerType = texOp.Type == SamplerType.TextureBuffer;
|
||||||
|
|
||||||
|
SetHandle(config, texOp, cbufOffset, cbufSlot, rewriteSamplerType, isImage: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,13 +222,39 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetHandle(ShaderConfig config, TextureOperation texOp, int cbufOffset, int cbufSlot, bool rewriteSamplerType)
|
private static void SetHandle(ShaderConfig config, TextureOperation texOp, int cbufOffset, int cbufSlot, bool rewriteSamplerType, bool isImage)
|
||||||
{
|
{
|
||||||
texOp.SetHandle(cbufOffset, cbufSlot);
|
texOp.SetHandle(cbufOffset, cbufSlot);
|
||||||
|
|
||||||
if (rewriteSamplerType)
|
if (rewriteSamplerType)
|
||||||
{
|
{
|
||||||
texOp.Type = config.GpuAccessor.QuerySamplerType(cbufOffset, cbufSlot);
|
SamplerType newType = config.GpuAccessor.QuerySamplerType(cbufOffset, cbufSlot);
|
||||||
|
|
||||||
|
if (texOp.Inst.IsTextureQuery())
|
||||||
|
{
|
||||||
|
texOp.Type = newType;
|
||||||
|
}
|
||||||
|
else if (texOp.Type == SamplerType.TextureBuffer && newType == SamplerType.Texture1D)
|
||||||
|
{
|
||||||
|
int coordsCount = 1;
|
||||||
|
|
||||||
|
if (InstEmit.Sample1DAs2D)
|
||||||
|
{
|
||||||
|
newType = SamplerType.Texture2D;
|
||||||
|
texOp.InsertSource(coordsCount++, OperandHelper.Const(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isImage &&
|
||||||
|
(texOp.Flags & TextureFlags.IntCoords) != 0 &&
|
||||||
|
(texOp.Flags & TextureFlags.LodLevel) == 0)
|
||||||
|
{
|
||||||
|
// IntCoords textures must always have explicit LOD.
|
||||||
|
texOp.SetLodLevelFlag();
|
||||||
|
texOp.InsertSource(coordsCount, OperandHelper.Const(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
texOp.Type = newType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.SetUsedTexture(texOp.Inst, texOp.Type, texOp.Format, texOp.Flags, cbufSlot, cbufOffset);
|
config.SetUsedTexture(texOp.Inst, texOp.Type, texOp.Format, texOp.Flags, cbufSlot, cbufOffset);
|
||||||
|
73
Ryujinx.Graphics.Vulkan/AutoFlushCounter.cs
Normal file
73
Ryujinx.Graphics.Vulkan/AutoFlushCounter.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
|
{
|
||||||
|
internal class AutoFlushCounter
|
||||||
|
{
|
||||||
|
// How often to flush on framebuffer change.
|
||||||
|
private readonly static long FramebufferFlushTimer = Stopwatch.Frequency / 1000;
|
||||||
|
|
||||||
|
private const int MinDrawCountForFlush = 10;
|
||||||
|
private const int InitialQueryCountForFlush = 32;
|
||||||
|
|
||||||
|
private long _lastFlush;
|
||||||
|
private ulong _lastDrawCount;
|
||||||
|
private bool _hasPendingQuery;
|
||||||
|
private int _queryCount;
|
||||||
|
|
||||||
|
public void RegisterFlush(ulong drawCount)
|
||||||
|
{
|
||||||
|
_lastFlush = Stopwatch.GetTimestamp();
|
||||||
|
_lastDrawCount = drawCount;
|
||||||
|
|
||||||
|
_hasPendingQuery = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RegisterPendingQuery()
|
||||||
|
{
|
||||||
|
_hasPendingQuery = true;
|
||||||
|
|
||||||
|
// Interrupt render passes to flush queries, so that early results arrive sooner.
|
||||||
|
if (++_queryCount == InitialQueryCountForFlush)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShouldFlushQuery()
|
||||||
|
{
|
||||||
|
return _hasPendingQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShouldFlush(ulong drawCount)
|
||||||
|
{
|
||||||
|
_queryCount = 0;
|
||||||
|
|
||||||
|
if (_hasPendingQuery)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
long draws = (long)(drawCount - _lastDrawCount);
|
||||||
|
|
||||||
|
if (draws < MinDrawCountForFlush)
|
||||||
|
{
|
||||||
|
if (draws == 0)
|
||||||
|
{
|
||||||
|
_lastFlush = Stopwatch.GetTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long flushTimeout = FramebufferFlushTimer;
|
||||||
|
|
||||||
|
long now = Stopwatch.GetTimestamp();
|
||||||
|
|
||||||
|
return now > _lastFlush + flushTimeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -108,6 +108,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
{
|
{
|
||||||
format = VkFormat.D32SfloatS8Uint;
|
format = VkFormat.D32SfloatS8Uint;
|
||||||
}
|
}
|
||||||
|
else if (srcFormat == GAL.Format.R4G4B4A4Unorm)
|
||||||
|
{
|
||||||
|
format = VkFormat.R4G4B4A4UnormPack16;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Error?.Print(LogClass.Gpu, $"Format {srcFormat} is not supported by the host.");
|
Logger.Error?.Print(LogClass.Gpu, $"Format {srcFormat} is not supported by the host.");
|
||||||
|
@@ -6,11 +6,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
{
|
{
|
||||||
static class FormatTable
|
static class FormatTable
|
||||||
{
|
{
|
||||||
private static readonly VkFormat[] Table;
|
private static readonly VkFormat[] _table;
|
||||||
|
|
||||||
static FormatTable()
|
static FormatTable()
|
||||||
{
|
{
|
||||||
Table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
|
_table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
|
||||||
|
|
||||||
Add(Format.R8Unorm, VkFormat.R8Unorm);
|
Add(Format.R8Unorm, VkFormat.R8Unorm);
|
||||||
Add(Format.R8Snorm, VkFormat.R8SNorm);
|
Add(Format.R8Snorm, VkFormat.R8SNorm);
|
||||||
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Add(Format.D32FloatS8Uint, VkFormat.D32SfloatS8Uint);
|
Add(Format.D32FloatS8Uint, VkFormat.D32SfloatS8Uint);
|
||||||
Add(Format.R8G8B8A8Srgb, VkFormat.R8G8B8A8Srgb);
|
Add(Format.R8G8B8A8Srgb, VkFormat.R8G8B8A8Srgb);
|
||||||
Add(Format.R4G4Unorm, VkFormat.R4G4UnormPack8);
|
Add(Format.R4G4Unorm, VkFormat.R4G4UnormPack8);
|
||||||
Add(Format.R4G4B4A4Unorm, VkFormat.R4G4B4A4UnormPack16);
|
Add(Format.R4G4B4A4Unorm, VkFormat.A4B4G4R4UnormPack16Ext);
|
||||||
Add(Format.R5G5B5X1Unorm, VkFormat.A1R5G5B5UnormPack16);
|
Add(Format.R5G5B5X1Unorm, VkFormat.A1R5G5B5UnormPack16);
|
||||||
Add(Format.R5G5B5A1Unorm, VkFormat.A1R5G5B5UnormPack16);
|
Add(Format.R5G5B5A1Unorm, VkFormat.A1R5G5B5UnormPack16);
|
||||||
Add(Format.R5G6B5Unorm, VkFormat.R5G6B5UnormPack16);
|
Add(Format.R5G6B5Unorm, VkFormat.R5G6B5UnormPack16);
|
||||||
@@ -161,12 +161,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
private static void Add(Format format, VkFormat vkFormat)
|
private static void Add(Format format, VkFormat vkFormat)
|
||||||
{
|
{
|
||||||
Table[(int)format] = vkFormat;
|
_table[(int)format] = vkFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VkFormat GetFormat(Format format)
|
public static VkFormat GetFormat(Format format)
|
||||||
{
|
{
|
||||||
return Table[(int)format];
|
return _table[(int)format];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,429 +0,0 @@
|
|||||||
using Ryujinx.Graphics.GAL;
|
|
||||||
using Silk.NET.Vulkan;
|
|
||||||
using System;
|
|
||||||
using VkFormat = Silk.NET.Vulkan.Format;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
|
||||||
{
|
|
||||||
class ImageWindow : WindowBase, IWindow, IDisposable
|
|
||||||
{
|
|
||||||
internal const VkFormat Format = VkFormat.R8G8B8A8Unorm;
|
|
||||||
|
|
||||||
private const int ImageCount = 3;
|
|
||||||
private const int SurfaceWidth = 1280;
|
|
||||||
private const int SurfaceHeight = 720;
|
|
||||||
|
|
||||||
private readonly VulkanRenderer _gd;
|
|
||||||
private readonly PhysicalDevice _physicalDevice;
|
|
||||||
private readonly Device _device;
|
|
||||||
|
|
||||||
private Auto<DisposableImage>[] _images;
|
|
||||||
private Auto<DisposableImageView>[] _imageViews;
|
|
||||||
private Auto<MemoryAllocation>[] _imageAllocationAuto;
|
|
||||||
private ImageState[] _states;
|
|
||||||
private PresentImageInfo[] _presentedImages;
|
|
||||||
private FenceHolder[] _fences;
|
|
||||||
|
|
||||||
private ulong[] _imageSizes;
|
|
||||||
private ulong[] _imageOffsets;
|
|
||||||
|
|
||||||
private int _width = SurfaceWidth;
|
|
||||||
private int _height = SurfaceHeight;
|
|
||||||
private bool _recreateImages;
|
|
||||||
private int _nextImage;
|
|
||||||
|
|
||||||
public unsafe ImageWindow(VulkanRenderer gd, PhysicalDevice physicalDevice, Device device)
|
|
||||||
{
|
|
||||||
_gd = gd;
|
|
||||||
_physicalDevice = physicalDevice;
|
|
||||||
_device = device;
|
|
||||||
|
|
||||||
_images = new Auto<DisposableImage>[ImageCount];
|
|
||||||
_imageAllocationAuto = new Auto<MemoryAllocation>[ImageCount];
|
|
||||||
_imageSizes = new ulong[ImageCount];
|
|
||||||
_imageOffsets = new ulong[ImageCount];
|
|
||||||
_states = new ImageState[ImageCount];
|
|
||||||
_presentedImages = new PresentImageInfo[ImageCount];
|
|
||||||
|
|
||||||
CreateImages();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecreateImages()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ImageCount; i++)
|
|
||||||
{
|
|
||||||
lock (_states[i])
|
|
||||||
{
|
|
||||||
_states[i].IsValid = false;
|
|
||||||
_fences[i]?.Wait();
|
|
||||||
_fences[i]?.Put();
|
|
||||||
_imageViews[i]?.Dispose();
|
|
||||||
_imageAllocationAuto[i]?.Dispose();
|
|
||||||
_images[i]?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_presentedImages = null;
|
|
||||||
|
|
||||||
CreateImages();
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe void CreateImages()
|
|
||||||
{
|
|
||||||
_imageViews = new Auto<DisposableImageView>[ImageCount];
|
|
||||||
_fences = new FenceHolder[ImageCount];
|
|
||||||
_presentedImages = new PresentImageInfo[ImageCount];
|
|
||||||
|
|
||||||
_nextImage = 0;
|
|
||||||
var cbs = _gd.CommandBufferPool.Rent();
|
|
||||||
|
|
||||||
var imageCreateInfo = new ImageCreateInfo
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageCreateInfo,
|
|
||||||
ImageType = ImageType.ImageType2D,
|
|
||||||
Format = Format,
|
|
||||||
Extent = new Extent3D((uint?)_width, (uint?)_height, 1),
|
|
||||||
MipLevels = 1,
|
|
||||||
ArrayLayers = 1,
|
|
||||||
Samples = SampleCountFlags.SampleCount1Bit,
|
|
||||||
Tiling = ImageTiling.Optimal,
|
|
||||||
Usage = ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferSrcBit | ImageUsageFlags.ImageUsageTransferDstBit,
|
|
||||||
SharingMode = SharingMode.Exclusive,
|
|
||||||
InitialLayout = ImageLayout.Undefined,
|
|
||||||
Flags = ImageCreateFlags.ImageCreateMutableFormatBit
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < _images.Length; i++)
|
|
||||||
{
|
|
||||||
_gd.Api.CreateImage(_device, imageCreateInfo, null, out var image).ThrowOnError();
|
|
||||||
_images[i] = new Auto<DisposableImage>(new DisposableImage(_gd.Api, _device, image));
|
|
||||||
|
|
||||||
_gd.Api.GetImageMemoryRequirements(_device, image,
|
|
||||||
out var memoryRequirements);
|
|
||||||
var allocation = _gd.MemoryAllocator.AllocateDeviceMemory(_physicalDevice, memoryRequirements, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit);
|
|
||||||
|
|
||||||
_imageSizes[i] = allocation.Size;
|
|
||||||
_imageOffsets[i] = allocation.Offset;
|
|
||||||
|
|
||||||
_imageAllocationAuto[i] = new Auto<MemoryAllocation>(allocation);
|
|
||||||
|
|
||||||
_gd.Api.BindImageMemory(_device, image, allocation.Memory, allocation.Offset);
|
|
||||||
|
|
||||||
_imageViews[i] = CreateImageView(image, Format);
|
|
||||||
|
|
||||||
Transition(
|
|
||||||
cbs.CommandBuffer,
|
|
||||||
image,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
ImageLayout.Undefined,
|
|
||||||
ImageLayout.TransferSrcOptimal);
|
|
||||||
|
|
||||||
_states[i] = new ImageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
_gd.CommandBufferPool.Return(cbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe Auto<DisposableImageView> CreateImageView(Image image, VkFormat format)
|
|
||||||
{
|
|
||||||
var componentMapping = new ComponentMapping(
|
|
||||||
ComponentSwizzle.R,
|
|
||||||
ComponentSwizzle.G,
|
|
||||||
ComponentSwizzle.B,
|
|
||||||
ComponentSwizzle.A);
|
|
||||||
|
|
||||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, 1, 0, 1);
|
|
||||||
|
|
||||||
var imageCreateInfo = new ImageViewCreateInfo()
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageViewCreateInfo,
|
|
||||||
Image = image,
|
|
||||||
ViewType = ImageViewType.ImageViewType2D,
|
|
||||||
Format = format,
|
|
||||||
Components = componentMapping,
|
|
||||||
SubresourceRange = subresourceRange
|
|
||||||
};
|
|
||||||
|
|
||||||
_gd.Api.CreateImageView(_device, imageCreateInfo, null, out var imageView).ThrowOnError();
|
|
||||||
return new Auto<DisposableImageView>(new DisposableImageView(_gd.Api, _device, imageView));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override unsafe void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback)
|
|
||||||
{
|
|
||||||
if (_recreateImages)
|
|
||||||
{
|
|
||||||
RecreateImages();
|
|
||||||
_recreateImages = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var image = _images[_nextImage];
|
|
||||||
|
|
||||||
_gd.FlushAllCommands();
|
|
||||||
|
|
||||||
var cbs = _gd.CommandBufferPool.Rent();
|
|
||||||
|
|
||||||
Transition(
|
|
||||||
cbs.CommandBuffer,
|
|
||||||
image.GetUnsafe().Value,
|
|
||||||
0,
|
|
||||||
AccessFlags.AccessTransferWriteBit,
|
|
||||||
ImageLayout.TransferSrcOptimal,
|
|
||||||
ImageLayout.General);
|
|
||||||
|
|
||||||
var view = (TextureView)texture;
|
|
||||||
|
|
||||||
int srcX0, srcX1, srcY0, srcY1;
|
|
||||||
float scale = view.ScaleFactor;
|
|
||||||
|
|
||||||
if (crop.Left == 0 && crop.Right == 0)
|
|
||||||
{
|
|
||||||
srcX0 = 0;
|
|
||||||
srcX1 = (int)(view.Width / scale);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srcX0 = crop.Left;
|
|
||||||
srcX1 = crop.Right;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crop.Top == 0 && crop.Bottom == 0)
|
|
||||||
{
|
|
||||||
srcY0 = 0;
|
|
||||||
srcY1 = (int)(view.Height / scale);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srcY0 = crop.Top;
|
|
||||||
srcY1 = crop.Bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scale != 1f)
|
|
||||||
{
|
|
||||||
srcX0 = (int)(srcX0 * scale);
|
|
||||||
srcY0 = (int)(srcY0 * scale);
|
|
||||||
srcX1 = (int)Math.Ceiling(srcX1 * scale);
|
|
||||||
srcY1 = (int)Math.Ceiling(srcY1 * scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ScreenCaptureRequested)
|
|
||||||
{
|
|
||||||
CaptureFrame(view, srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0, view.Info.Format.IsBgr(), crop.FlipX, crop.FlipY);
|
|
||||||
|
|
||||||
ScreenCaptureRequested = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ratioX = crop.IsStretched ? 1.0f : MathF.Min(1.0f, _height * crop.AspectRatioX / (_width * crop.AspectRatioY));
|
|
||||||
float ratioY = crop.IsStretched ? 1.0f : MathF.Min(1.0f, _width * crop.AspectRatioY / (_height * crop.AspectRatioX));
|
|
||||||
|
|
||||||
int dstWidth = (int)(_width * ratioX);
|
|
||||||
int dstHeight = (int)(_height * ratioY);
|
|
||||||
|
|
||||||
int dstPaddingX = (_width - dstWidth) / 2;
|
|
||||||
int dstPaddingY = (_height - dstHeight) / 2;
|
|
||||||
|
|
||||||
int dstX0 = crop.FlipX ? _width - dstPaddingX : dstPaddingX;
|
|
||||||
int dstX1 = crop.FlipX ? dstPaddingX : _width - dstPaddingX;
|
|
||||||
|
|
||||||
int dstY0 = crop.FlipY ? dstPaddingY : _height - dstPaddingY;
|
|
||||||
int dstY1 = crop.FlipY ? _height - dstPaddingY : dstPaddingY;
|
|
||||||
|
|
||||||
_gd.HelperShader.Blit(
|
|
||||||
_gd,
|
|
||||||
cbs,
|
|
||||||
view,
|
|
||||||
_imageViews[_nextImage],
|
|
||||||
_width,
|
|
||||||
_height,
|
|
||||||
Format,
|
|
||||||
new Extents2D(srcX0, srcY0, srcX1, srcY1),
|
|
||||||
new Extents2D(dstX0, dstY1, dstX1, dstY0),
|
|
||||||
true,
|
|
||||||
true);
|
|
||||||
|
|
||||||
Transition(
|
|
||||||
cbs.CommandBuffer,
|
|
||||||
image.GetUnsafe().Value,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
ImageLayout.General,
|
|
||||||
ImageLayout.TransferSrcOptimal);
|
|
||||||
|
|
||||||
_gd.CommandBufferPool.Return(
|
|
||||||
cbs,
|
|
||||||
null,
|
|
||||||
stackalloc[] { PipelineStageFlags.PipelineStageColorAttachmentOutputBit },
|
|
||||||
null);
|
|
||||||
|
|
||||||
_fences[_nextImage]?.Put();
|
|
||||||
_fences[_nextImage] = cbs.GetFence();
|
|
||||||
cbs.GetFence().Get();
|
|
||||||
|
|
||||||
PresentImageInfo info = _presentedImages[_nextImage];
|
|
||||||
|
|
||||||
if (info == null)
|
|
||||||
{
|
|
||||||
info = new PresentImageInfo(
|
|
||||||
image,
|
|
||||||
_imageAllocationAuto[_nextImage],
|
|
||||||
_device,
|
|
||||||
_physicalDevice,
|
|
||||||
_imageSizes[_nextImage],
|
|
||||||
_imageOffsets[_nextImage],
|
|
||||||
new Extent2D((uint)_width, (uint)_height),
|
|
||||||
_states[_nextImage]);
|
|
||||||
|
|
||||||
_presentedImages[_nextImage] = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapBuffersCallback(info);
|
|
||||||
|
|
||||||
_nextImage = (_nextImage + 1) % ImageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe void Transition(
|
|
||||||
CommandBuffer commandBuffer,
|
|
||||||
Image image,
|
|
||||||
AccessFlags srcAccess,
|
|
||||||
AccessFlags dstAccess,
|
|
||||||
ImageLayout srcLayout,
|
|
||||||
ImageLayout dstLayout)
|
|
||||||
{
|
|
||||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, 1, 0, 1);
|
|
||||||
|
|
||||||
var barrier = new ImageMemoryBarrier()
|
|
||||||
{
|
|
||||||
SType = StructureType.ImageMemoryBarrier,
|
|
||||||
SrcAccessMask = srcAccess,
|
|
||||||
DstAccessMask = dstAccess,
|
|
||||||
OldLayout = srcLayout,
|
|
||||||
NewLayout = dstLayout,
|
|
||||||
SrcQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
|
||||||
DstQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
|
||||||
Image = image,
|
|
||||||
SubresourceRange = subresourceRange
|
|
||||||
};
|
|
||||||
|
|
||||||
_gd.Api.CmdPipelineBarrier(
|
|
||||||
commandBuffer,
|
|
||||||
PipelineStageFlags.PipelineStageTopOfPipeBit,
|
|
||||||
PipelineStageFlags.PipelineStageAllCommandsBit,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
1,
|
|
||||||
barrier);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CaptureFrame(TextureView texture, int x, int y, int width, int height, bool isBgra, bool flipX, bool flipY)
|
|
||||||
{
|
|
||||||
byte[] bitmap = texture.GetData(x, y, width, height);
|
|
||||||
|
|
||||||
_gd.OnScreenCaptured(new ScreenCaptureImageInfo(width, height, isBgra, bitmap, flipX, flipY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetSize(int width, int height)
|
|
||||||
{
|
|
||||||
if (_width != width || _height != height)
|
|
||||||
{
|
|
||||||
_recreateImages = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ImageCount; i++)
|
|
||||||
{
|
|
||||||
_states[i].IsValid = false;
|
|
||||||
_fences[i]?.Wait();
|
|
||||||
_fences[i]?.Put();
|
|
||||||
_imageViews[i]?.Dispose();
|
|
||||||
_imageAllocationAuto[i]?.Dispose();
|
|
||||||
_images[i]?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ChangeVSyncMode(bool vsyncEnabled) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ImageState
|
|
||||||
{
|
|
||||||
private bool _isValid = true;
|
|
||||||
|
|
||||||
public bool IsValid
|
|
||||||
{
|
|
||||||
get => _isValid;
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
_isValid = value;
|
|
||||||
|
|
||||||
StateChanged?.Invoke(this, _isValid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler<bool> StateChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PresentImageInfo
|
|
||||||
{
|
|
||||||
private readonly Auto<DisposableImage> _image;
|
|
||||||
private readonly Auto<MemoryAllocation> _memory;
|
|
||||||
|
|
||||||
public Image Image => _image.GetUnsafe().Value;
|
|
||||||
|
|
||||||
public DeviceMemory Memory => _memory.GetUnsafe().Memory;
|
|
||||||
|
|
||||||
public Device Device { get; }
|
|
||||||
public PhysicalDevice PhysicalDevice { get; }
|
|
||||||
public ulong MemorySize { get; }
|
|
||||||
public ulong MemoryOffset { get; }
|
|
||||||
public Extent2D Extent { get; }
|
|
||||||
public ImageState State { get; internal set; }
|
|
||||||
internal PresentImageInfo(
|
|
||||||
Auto<DisposableImage> image,
|
|
||||||
Auto<MemoryAllocation> memory,
|
|
||||||
Device device,
|
|
||||||
PhysicalDevice physicalDevice,
|
|
||||||
ulong memorySize,
|
|
||||||
ulong memoryOffset,
|
|
||||||
Extent2D extent2D,
|
|
||||||
ImageState state)
|
|
||||||
{
|
|
||||||
_image = image;
|
|
||||||
_memory = memory;
|
|
||||||
Device = device;
|
|
||||||
PhysicalDevice = physicalDevice;
|
|
||||||
MemorySize = memorySize;
|
|
||||||
MemoryOffset = memoryOffset;
|
|
||||||
Extent = extent2D;
|
|
||||||
State = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Get()
|
|
||||||
{
|
|
||||||
_memory.IncrementReferenceCount();
|
|
||||||
_image.IncrementReferenceCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Put()
|
|
||||||
{
|
|
||||||
_memory.DecrementReferenceCount();
|
|
||||||
_image.DecrementReferenceCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,6 +19,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
protected readonly Device Device;
|
protected readonly Device Device;
|
||||||
public readonly PipelineCache PipelineCache;
|
public readonly PipelineCache PipelineCache;
|
||||||
|
|
||||||
|
protected readonly AutoFlushCounter AutoFlush;
|
||||||
|
|
||||||
private PipelineDynamicState _dynamicState;
|
private PipelineDynamicState _dynamicState;
|
||||||
private PipelineState _newState;
|
private PipelineState _newState;
|
||||||
private bool _stateDirty;
|
private bool _stateDirty;
|
||||||
@@ -70,6 +72,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Gd = gd;
|
Gd = gd;
|
||||||
Device = device;
|
Device = device;
|
||||||
|
|
||||||
|
AutoFlush = new AutoFlushCounter();
|
||||||
|
|
||||||
var pipelineCacheCreateInfo = new PipelineCacheCreateInfo()
|
var pipelineCacheCreateInfo = new PipelineCacheCreateInfo()
|
||||||
{
|
{
|
||||||
SType = StructureType.PipelineCacheCreateInfo
|
SType = StructureType.PipelineCacheCreateInfo
|
||||||
|
@@ -10,8 +10,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
{
|
{
|
||||||
private const ulong MinByteWeightForFlush = 256 * 1024 * 1024; // MB
|
private const ulong MinByteWeightForFlush = 256 * 1024 * 1024; // MB
|
||||||
|
|
||||||
private bool _hasPendingQuery;
|
|
||||||
|
|
||||||
private readonly List<QueryPool> _activeQueries;
|
private readonly List<QueryPool> _activeQueries;
|
||||||
private CounterQueueEvent _activeConditionalRender;
|
private CounterQueueEvent _activeConditionalRender;
|
||||||
|
|
||||||
@@ -158,9 +156,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
private void FlushPendingQuery()
|
private void FlushPendingQuery()
|
||||||
{
|
{
|
||||||
if (_hasPendingQuery)
|
if (AutoFlush.ShouldFlushQuery())
|
||||||
{
|
{
|
||||||
_hasPendingQuery = false;
|
|
||||||
FlushCommandsImpl();
|
FlushCommandsImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,6 +208,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
public void FlushCommandsImpl()
|
public void FlushCommandsImpl()
|
||||||
{
|
{
|
||||||
|
AutoFlush.RegisterFlush(DrawCount);
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
|
||||||
foreach (var queryPool in _activeQueries)
|
foreach (var queryPool in _activeQueries)
|
||||||
@@ -277,12 +275,18 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
{
|
{
|
||||||
_pendingQueryCopies.Add(query);
|
_pendingQueryCopies.Add(query);
|
||||||
|
|
||||||
_hasPendingQuery = true;
|
if (AutoFlush.RegisterPendingQuery())
|
||||||
|
{
|
||||||
|
FlushCommandsImpl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SignalAttachmentChange()
|
protected override void SignalAttachmentChange()
|
||||||
{
|
{
|
||||||
FlushPendingQuery();
|
if (AutoFlush.ShouldFlush(DrawCount))
|
||||||
|
{
|
||||||
|
FlushCommandsImpl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SignalRenderPassEnd()
|
protected override void SignalRenderPassEnd()
|
||||||
|
@@ -74,17 +74,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
swizzleR = swizzleB;
|
swizzleR = swizzleB;
|
||||||
swizzleB = temp;
|
swizzleB = temp;
|
||||||
}
|
}
|
||||||
else if (info.Format == GAL.Format.R4G4B4A4Unorm)
|
else if (VkFormat == VkFormat.R4G4B4A4UnormPack16 || info.Format == GAL.Format.A1B5G5R5Unorm)
|
||||||
{
|
|
||||||
var tempG = swizzleG;
|
|
||||||
var tempB = swizzleB;
|
|
||||||
|
|
||||||
swizzleB = swizzleA;
|
|
||||||
swizzleG = swizzleR;
|
|
||||||
swizzleR = tempG;
|
|
||||||
swizzleA = tempB;
|
|
||||||
}
|
|
||||||
else if (info.Format == GAL.Format.A1B5G5R5Unorm)
|
|
||||||
{
|
{
|
||||||
var tempB = swizzleB;
|
var tempB = swizzleB;
|
||||||
var tempA = swizzleA;
|
var tempA = swizzleA;
|
||||||
|
@@ -20,7 +20,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
private SurfaceKHR _surface;
|
private SurfaceKHR _surface;
|
||||||
private PhysicalDevice _physicalDevice;
|
private PhysicalDevice _physicalDevice;
|
||||||
private Device _device;
|
private Device _device;
|
||||||
private uint _queueFamilyIndex;
|
|
||||||
private WindowBase _window;
|
private WindowBase _window;
|
||||||
|
|
||||||
internal FormatCapabilities FormatCapabilities { get; private set; }
|
internal FormatCapabilities FormatCapabilities { get; private set; }
|
||||||
@@ -37,7 +36,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
internal ExtDebugReport DebugReportApi { get; private set; }
|
internal ExtDebugReport DebugReportApi { get; private set; }
|
||||||
|
|
||||||
internal uint QueueFamilyIndex { get; private set; }
|
internal uint QueueFamilyIndex { get; private set; }
|
||||||
public bool IsOffScreen { get; }
|
|
||||||
internal Queue Queue { get; private set; }
|
internal Queue Queue { get; private set; }
|
||||||
internal Queue BackgroundQueue { get; private set; }
|
internal Queue BackgroundQueue { get; private set; }
|
||||||
internal object BackgroundQueueLock { get; private set; }
|
internal object BackgroundQueueLock { get; private set; }
|
||||||
@@ -94,22 +92,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Samplers = new HashSet<SamplerHolder>();
|
Samplers = new HashSet<SamplerHolder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VulkanRenderer(Instance instance, Device device, PhysicalDevice physicalDevice, Queue queue, uint queueFamilyIndex, object lockObject)
|
|
||||||
{
|
|
||||||
_instance = instance;
|
|
||||||
_physicalDevice = physicalDevice;
|
|
||||||
_device = device;
|
|
||||||
_queueFamilyIndex = queueFamilyIndex;
|
|
||||||
|
|
||||||
Queue = queue;
|
|
||||||
QueueLock = lockObject;
|
|
||||||
|
|
||||||
IsOffScreen = true;
|
|
||||||
Shaders = new HashSet<ShaderCollection>();
|
|
||||||
Textures = new HashSet<ITexture>();
|
|
||||||
Samplers = new HashSet<SamplerHolder>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe void LoadFeatures(string[] supportedExtensions, uint maxQueueCount, uint queueFamilyIndex)
|
private unsafe void LoadFeatures(string[] supportedExtensions, uint maxQueueCount, uint queueFamilyIndex)
|
||||||
{
|
{
|
||||||
FormatCapabilities = new FormatCapabilities(Api, _physicalDevice);
|
FormatCapabilities = new FormatCapabilities(Api, _physicalDevice);
|
||||||
@@ -286,34 +268,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
_window = new Window(this, _surface, _physicalDevice, _device);
|
_window = new Window(this, _surface, _physicalDevice, _device);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void SetupOffScreenContext(GraphicsDebugLevel logLevel)
|
|
||||||
{
|
|
||||||
var api = Vk.GetApi();
|
|
||||||
|
|
||||||
Api = api;
|
|
||||||
|
|
||||||
VulkanInitialization.CreateDebugCallbacks(api, logLevel, _instance, out var debugReport, out _debugReportCallback);
|
|
||||||
|
|
||||||
DebugReportApi = debugReport;
|
|
||||||
|
|
||||||
var supportedExtensions = VulkanInitialization.GetSupportedExtensions(api, _physicalDevice);
|
|
||||||
|
|
||||||
uint propertiesCount;
|
|
||||||
|
|
||||||
api.GetPhysicalDeviceQueueFamilyProperties(_physicalDevice, &propertiesCount, null);
|
|
||||||
|
|
||||||
QueueFamilyProperties[] queueFamilyProperties = new QueueFamilyProperties[propertiesCount];
|
|
||||||
|
|
||||||
fixed (QueueFamilyProperties* pProperties = queueFamilyProperties)
|
|
||||||
{
|
|
||||||
api.GetPhysicalDeviceQueueFamilyProperties(_physicalDevice, &propertiesCount, pProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadFeatures(supportedExtensions, queueFamilyProperties[0].QueueCount, _queueFamilyIndex);
|
|
||||||
|
|
||||||
_window = new ImageWindow(this, _physicalDevice, _device);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferHandle CreateBuffer(int size)
|
public BufferHandle CreateBuffer(int size)
|
||||||
{
|
{
|
||||||
return BufferManager.CreateWithHandle(this, size, false);
|
return BufferManager.CreateWithHandle(this, size, false);
|
||||||
@@ -518,15 +472,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(GraphicsDebugLevel logLevel)
|
public void Initialize(GraphicsDebugLevel logLevel)
|
||||||
{
|
|
||||||
if (IsOffScreen)
|
|
||||||
{
|
|
||||||
SetupOffScreenContext(logLevel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SetupContext(logLevel);
|
SetupContext(logLevel);
|
||||||
}
|
|
||||||
|
|
||||||
PrintGpuInformation();
|
PrintGpuInformation();
|
||||||
}
|
}
|
||||||
@@ -638,8 +585,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
sampler.Dispose();
|
sampler.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsOffScreen)
|
|
||||||
{
|
|
||||||
SurfaceApi.DestroySurface(_instance, _surface, null);
|
SurfaceApi.DestroySurface(_instance, _surface, null);
|
||||||
|
|
||||||
Api.DestroyDevice(_device, null);
|
Api.DestroyDevice(_device, null);
|
||||||
@@ -648,5 +593,4 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
Api.DestroyInstance(_instance, null);
|
Api.DestroyInstance(_instance, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe override void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback)
|
public unsafe override void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
uint nextImage = 0;
|
uint nextImage = 0;
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
public bool ScreenCaptureRequested { get; set; }
|
public bool ScreenCaptureRequested { get; set; }
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
public abstract void Present(ITexture texture, ImageCrop crop, Action<object> swapBuffersCallback);
|
public abstract void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback);
|
||||||
public abstract void SetSize(int width, int height);
|
public abstract void SetSize(int width, int height);
|
||||||
public abstract void ChangeVSyncMode(bool vsyncEnabled);
|
public abstract void ChangeVSyncMode(bool vsyncEnabled);
|
||||||
}
|
}
|
||||||
|
@@ -117,7 +117,7 @@ namespace Ryujinx.HLE
|
|||||||
return Gpu.Window.ConsumeFrameAvailable();
|
return Gpu.Window.ConsumeFrameAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PresentFrame(Action<object> swapBuffersCallback)
|
public void PresentFrame(Action swapBuffersCallback)
|
||||||
{
|
{
|
||||||
Gpu.Window.Present(swapBuffersCallback);
|
Gpu.Window.Present(swapBuffersCallback);
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user