mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-10-02 16:50:20 -07:00

* dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Silence dotnet format IDE0059 warnings * Address or silence dotnet format CA1069 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Fix formatting for switch expressions * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Run dotnet format after rebase * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Run dotnet format after rebase * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Add trailing commas * Remove unused members and most unnecessary value assignments * Remove more unnecessary assignments * Remove NRE suppressor
184 lines
6.4 KiB
C#
184 lines
6.4 KiB
C#
using Ryujinx.Graphics.Shader.Decoders;
|
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
|
using Ryujinx.Graphics.Shader.Translation;
|
|
|
|
using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
|
|
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
|
|
|
|
namespace Ryujinx.Graphics.Shader.Instructions
|
|
{
|
|
static partial class InstEmit
|
|
{
|
|
public static void Vmnmx(EmitterContext context)
|
|
{
|
|
InstVmnmx op = context.GetOp<InstVmnmx>();
|
|
|
|
Operand srcA = InstEmitAluHelper.Extend(context, GetSrcReg(context, op.SrcA), op.ASelect);
|
|
Operand srcC = GetSrcReg(context, op.SrcC);
|
|
Operand srcB;
|
|
|
|
if (op.BVideo)
|
|
{
|
|
srcB = InstEmitAluHelper.Extend(context, GetSrcReg(context, op.SrcB), op.BSelect);
|
|
}
|
|
else
|
|
{
|
|
int imm = op.Imm16;
|
|
|
|
if ((op.BSelect & VectorSelect.S8B0) != 0)
|
|
{
|
|
imm = (imm << 16) >> 16;
|
|
}
|
|
|
|
srcB = Const(imm);
|
|
}
|
|
|
|
Operand res;
|
|
|
|
bool resSigned;
|
|
|
|
if ((op.ASelect & VectorSelect.S8B0) != (op.BSelect & VectorSelect.S8B0))
|
|
{
|
|
// Signedness is different, but for max, result will always fit a U32,
|
|
// since one of the inputs can't be negative, and the result is the one
|
|
// with highest value. For min, it will always fit on a S32, since
|
|
// one of the input can't be greater than INT_MAX and we want the lowest value.
|
|
resSigned = !op.Mn;
|
|
|
|
res = op.Mn ? context.IMaximumU32(srcA, srcB) : context.IMinimumS32(srcA, srcB);
|
|
|
|
if ((op.ASelect & VectorSelect.S8B0) != 0)
|
|
{
|
|
Operand isBGtIntMax = context.ICompareLess(srcB, Const(0));
|
|
|
|
res = context.ConditionalSelect(isBGtIntMax, srcB, res);
|
|
}
|
|
else
|
|
{
|
|
Operand isAGtIntMax = context.ICompareLess(srcA, Const(0));
|
|
|
|
res = context.ConditionalSelect(isAGtIntMax, srcA, res);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Ra and Rb have the same signedness, so doesn't matter which one we test.
|
|
resSigned = (op.ASelect & VectorSelect.S8B0) != 0;
|
|
|
|
if (op.Mn)
|
|
{
|
|
res = resSigned
|
|
? context.IMaximumS32(srcA, srcB)
|
|
: context.IMaximumU32(srcA, srcB);
|
|
}
|
|
else
|
|
{
|
|
res = resSigned
|
|
? context.IMinimumS32(srcA, srcB)
|
|
: context.IMinimumU32(srcA, srcB);
|
|
}
|
|
}
|
|
|
|
if (op.Sat)
|
|
{
|
|
if (op.DFormat && !resSigned)
|
|
{
|
|
res = context.IMinimumU32(res, Const(int.MaxValue));
|
|
}
|
|
else if (!op.DFormat && resSigned)
|
|
{
|
|
res = context.IMaximumS32(res, Const(0));
|
|
}
|
|
}
|
|
|
|
switch (op.VideoOp)
|
|
{
|
|
case VideoOp.Acc:
|
|
res = context.IAdd(res, srcC);
|
|
break;
|
|
case VideoOp.Max:
|
|
res = op.DFormat ? context.IMaximumS32(res, srcC) : context.IMaximumU32(res, srcC);
|
|
break;
|
|
case VideoOp.Min:
|
|
res = op.DFormat ? context.IMinimumS32(res, srcC) : context.IMinimumU32(res, srcC);
|
|
break;
|
|
case VideoOp.Mrg16h:
|
|
res = context.BitfieldInsert(srcC, res, Const(16), Const(16));
|
|
break;
|
|
case VideoOp.Mrg16l:
|
|
res = context.BitfieldInsert(srcC, res, Const(0), Const(16));
|
|
break;
|
|
case VideoOp.Mrg8b0:
|
|
res = context.BitfieldInsert(srcC, res, Const(0), Const(8));
|
|
break;
|
|
case VideoOp.Mrg8b2:
|
|
res = context.BitfieldInsert(srcC, res, Const(16), Const(8));
|
|
break;
|
|
}
|
|
|
|
context.Copy(GetDest(op.Dest), res);
|
|
}
|
|
|
|
public static void Vsetp(EmitterContext context)
|
|
{
|
|
InstVsetp op = context.GetOp<InstVsetp>();
|
|
|
|
Operand srcA = InstEmitAluHelper.Extend(context, GetSrcReg(context, op.SrcA), op.ASelect);
|
|
Operand srcB;
|
|
|
|
if (op.BVideo)
|
|
{
|
|
srcB = InstEmitAluHelper.Extend(context, GetSrcReg(context, op.SrcB), op.BSelect);
|
|
}
|
|
else
|
|
{
|
|
int imm = op.Imm16;
|
|
|
|
if ((op.BSelect & VectorSelect.S8B0) != 0)
|
|
{
|
|
imm = (imm << 16) >> 16;
|
|
}
|
|
|
|
srcB = Const(imm);
|
|
}
|
|
|
|
Operand p0Res;
|
|
|
|
bool signedA = (op.ASelect & VectorSelect.S8B0) != 0;
|
|
bool signedB = (op.BSelect & VectorSelect.S8B0) != 0;
|
|
|
|
if (signedA != signedB)
|
|
{
|
|
bool a32 = (op.ASelect & ~VectorSelect.S8B0) == VectorSelect.U32;
|
|
bool b32 = (op.BSelect & ~VectorSelect.S8B0) == VectorSelect.U32;
|
|
|
|
if (!a32 && !b32)
|
|
{
|
|
// Both values are extended small integer and can always fit in a S32, just do a signed comparison.
|
|
p0Res = GetIntComparison(context, op.VComp, srcA, srcB, isSigned: true, extended: false);
|
|
}
|
|
else
|
|
{
|
|
// TODO: Mismatching sign case.
|
|
p0Res = Const(0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Sign matches, just do a regular comparison.
|
|
p0Res = GetIntComparison(context, op.VComp, srcA, srcB, signedA, extended: false);
|
|
}
|
|
|
|
Operand p1Res = context.BitwiseNot(p0Res);
|
|
|
|
Operand pred = GetPredicate(context, op.SrcPred, op.SrcPredInv);
|
|
|
|
p0Res = InstEmitAluHelper.GetPredLogicalOp(context, op.BoolOp, p0Res, pred);
|
|
p1Res = InstEmitAluHelper.GetPredLogicalOp(context, op.BoolOp, p1Res, pred);
|
|
|
|
context.Copy(Register(op.DestPred, RegisterType.Predicate), p0Res);
|
|
context.Copy(Register(op.DestPredInv, RegisterType.Predicate), p1Res);
|
|
}
|
|
}
|
|
}
|