Move and rename some instruction enums

This commit is contained in:
gdkchan 2019-04-12 15:36:57 -03:00
commit ba15713cf4
14 changed files with 109 additions and 109 deletions

View file

@ -0,0 +1,9 @@
namespace Ryujinx.Graphics.Shader.Decoders
{
enum IntegerHalfPart
{
B32 = 0,
H0 = 1,
H1 = 2
}
}

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Shader.Instructions namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum Iadd3Mode enum IntegerShift
{ {
NoShift = 0, NoShift = 0,
ShiftRight = 1, ShiftRight = 1,

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Graphics.Shader.Instructions namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum MufuOperation enum MufuOperation
{ {

View file

@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{ {
class OpCodeTexs : OpCodeTextureScalar class OpCodeTexs : OpCodeTextureScalar
{ {
public TexsType Type => (TexsType)RawType; public TextureScalarType Type => (TextureScalarType)RawType;
public OpCodeTexs(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) { } public OpCodeTexs(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) { }
} }

View file

@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{ {
class OpCodeTlds : OpCodeTextureScalar class OpCodeTlds : OpCodeTextureScalar
{ {
public TldsType Type => (TldsType)RawType; public TexelLoadScalarType Type => (TexelLoadScalarType)RawType;
public OpCodeTlds(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) { } public OpCodeTlds(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) { }
} }

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Shader.Decoders namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum TldsType enum TexelLoadScalarType
{ {
Texture1DLodZero = 0x0, Texture1DLodZero = 0x0,
Texture1DLodLevel = 0x1, Texture1DLodLevel = 0x1,

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Graphics.Shader.Instructions namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum TextureGatherOffset enum TextureGatherOffset
{ {

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Graphics.Shader.Instructions namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum TextureProperty enum TextureProperty
{ {

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Shader.Decoders namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum TexsType enum TextureScalarType
{ {
Texture1DLodZero = 0x0, Texture1DLodZero = 0x0,
Texture2D = 0x1, Texture2D = 0x1,

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Shader.Instructions namespace Ryujinx.Graphics.Shader.Decoders
{ {
enum XmadMode enum XmadCMode
{ {
Cfull = 0, Cfull = 0,
Clo = 1, Clo = 1,

View file

@ -1,9 +0,0 @@
namespace Ryujinx.Graphics.Shader.Instructions
{
enum Iadd3Part
{
B32 = 0,
H0 = 1,
H1 = 2
}
}

View file

@ -75,28 +75,28 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
OpCodeAlu op = (OpCodeAlu)context.CurrOp; OpCodeAlu op = (OpCodeAlu)context.CurrOp;
Iadd3Part partC = (Iadd3Part)op.RawOpCode.Extract(31, 2); IntegerHalfPart partC = (IntegerHalfPart)op.RawOpCode.Extract(31, 2);
Iadd3Part partB = (Iadd3Part)op.RawOpCode.Extract(33, 2); IntegerHalfPart partB = (IntegerHalfPart)op.RawOpCode.Extract(33, 2);
Iadd3Part partA = (Iadd3Part)op.RawOpCode.Extract(35, 2); IntegerHalfPart partA = (IntegerHalfPart)op.RawOpCode.Extract(35, 2);
Iadd3Mode mode = (Iadd3Mode)op.RawOpCode.Extract(37, 2); IntegerShift mode = (IntegerShift)op.RawOpCode.Extract(37, 2);
bool negateC = op.RawOpCode.Extract(49); bool negateC = op.RawOpCode.Extract(49);
bool negateB = op.RawOpCode.Extract(50); bool negateB = op.RawOpCode.Extract(50);
bool negateA = op.RawOpCode.Extract(51); bool negateA = op.RawOpCode.Extract(51);
Operand Extend(Operand src, Iadd3Part part) Operand Extend(Operand src, IntegerHalfPart part)
{ {
if (!(op is OpCodeAluReg) || part == Iadd3Part.B32) if (!(op is OpCodeAluReg) || part == IntegerHalfPart.B32)
{ {
return src; return src;
} }
if (part == Iadd3Part.H0) if (part == IntegerHalfPart.H0)
{ {
return context.BitwiseAnd(src, Const(0xffff)); return context.BitwiseAnd(src, Const(0xffff));
} }
else if (part == Iadd3Part.H1) else if (part == IntegerHalfPart.H1)
{ {
return context.ShiftRightU32(src, Const(16)); return context.ShiftRightU32(src, Const(16));
} }
@ -114,13 +114,13 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand res = context.IAdd(srcA, srcB); Operand res = context.IAdd(srcA, srcB);
if (op is OpCodeAluReg && mode != Iadd3Mode.NoShift) if (op is OpCodeAluReg && mode != IntegerShift.NoShift)
{ {
if (mode == Iadd3Mode.ShiftLeft) if (mode == IntegerShift.ShiftLeft)
{ {
res = context.ShiftLeft(res, Const(16)); res = context.ShiftLeft(res, Const(16));
} }
else if (mode == Iadd3Mode.ShiftRight) else if (mode == IntegerShift.ShiftRight)
{ {
res = context.ShiftRightU32(res, Const(16)); res = context.ShiftRightU32(res, Const(16));
} }
@ -432,17 +432,17 @@ namespace Ryujinx.Graphics.Shader.Instructions
bool highA = context.CurrOp.RawOpCode.Extract(53); bool highA = context.CurrOp.RawOpCode.Extract(53);
bool highB = false; bool highB = false;
XmadMode mode; XmadCMode mode;
if (op is OpCodeAluReg) if (op is OpCodeAluReg)
{ {
highB = context.CurrOp.RawOpCode.Extract(35); highB = context.CurrOp.RawOpCode.Extract(35);
mode = (XmadMode)context.CurrOp.RawOpCode.Extract(50, 3); mode = (XmadCMode)context.CurrOp.RawOpCode.Extract(50, 3);
} }
else else
{ {
mode = (XmadMode)context.CurrOp.RawOpCode.Extract(50, 2); mode = (XmadCMode)context.CurrOp.RawOpCode.Extract(50, 2);
if (!(op is OpCodeAluImm)) if (!(op is OpCodeAluImm))
{ {
@ -512,19 +512,19 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (mode) switch (mode)
{ {
case XmadMode.Cfull: break; case XmadCMode.Cfull: break;
case XmadMode.Clo: srcC = Extend16To32(srcC, high: false, signed: false); break; case XmadCMode.Clo: srcC = Extend16To32(srcC, high: false, signed: false); break;
case XmadMode.Chi: srcC = Extend16To32(srcC, high: true, signed: false); break; case XmadCMode.Chi: srcC = Extend16To32(srcC, high: true, signed: false); break;
case XmadMode.Cbcc: case XmadCMode.Cbcc:
{ {
srcC = context.IAdd(srcC, context.ShiftLeft(GetSrcB(context), Const(16))); srcC = context.IAdd(srcC, context.ShiftLeft(GetSrcB(context), Const(16)));
break; break;
} }
case XmadMode.Csfu: case XmadCMode.Csfu:
{ {
Operand signAdjustA = context.ShiftLeft(context.ShiftRightU32(srcA, Const(31)), Const(16)); Operand signAdjustA = context.ShiftLeft(context.ShiftRightU32(srcA, Const(31)), Const(16));
Operand signAdjustB = context.ShiftLeft(context.ShiftRightU32(srcB, Const(31)), Const(16)); Operand signAdjustB = context.ShiftLeft(context.ShiftRightU32(srcB, Const(31)), Const(16));

View file

@ -222,40 +222,40 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
switch (texsOp.Type) switch (texsOp.Type)
{ {
case TexsType.Texture1DLodZero: case TextureScalarType.Texture1DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
break; break;
case TexsType.Texture2D: case TextureScalarType.Texture2D:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
break; break;
case TexsType.Texture2DLodZero: case TextureScalarType.Texture2DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(ConstF(0)); sourcesList.Add(ConstF(0));
break; break;
case TexsType.Texture2DLodLevel: case TextureScalarType.Texture2DLodLevel:
case TexsType.Texture2DDepthCompare: case TextureScalarType.Texture2DDepthCompare:
case TexsType.Texture3D: case TextureScalarType.Texture3D:
case TexsType.TextureCube: case TextureScalarType.TextureCube:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
break; break;
case TexsType.Texture2DLodZeroDepthCompare: case TextureScalarType.Texture2DLodZeroDepthCompare:
case TexsType.Texture3DLodZero: case TextureScalarType.Texture3DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(ConstF(0)); sourcesList.Add(ConstF(0));
break; break;
case TexsType.Texture2DLodLevelDepthCompare: case TextureScalarType.Texture2DLodLevelDepthCompare:
case TexsType.TextureCubeLodLevel: case TextureScalarType.TextureCubeLodLevel:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
@ -271,51 +271,51 @@ namespace Ryujinx.Graphics.Shader.Instructions
switch (tldsOp.Type) switch (tldsOp.Type)
{ {
case TldsType.Texture1DLodZero: case TexelLoadScalarType.Texture1DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Const(0)); sourcesList.Add(Const(0));
break; break;
case TldsType.Texture1DLodLevel: case TexelLoadScalarType.Texture1DLodLevel:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
break; break;
case TldsType.Texture2DLodZero: case TexelLoadScalarType.Texture2DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(Const(0)); sourcesList.Add(Const(0));
break; break;
case TldsType.Texture2DLodZeroOffset: case TexelLoadScalarType.Texture2DLodZeroOffset:
case TldsType.Texture2DLodZeroMultisample: case TexelLoadScalarType.Texture2DLodZeroMultisample:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Const(0)); sourcesList.Add(Const(0));
sourcesList.Add(Rb()); sourcesList.Add(Rb());
break; break;
case TldsType.Texture2DLodLevel: case TexelLoadScalarType.Texture2DLodLevel:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
break; break;
case TldsType.Texture3DLodZero: case TexelLoadScalarType.Texture3DLodZero:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(Const(0)); sourcesList.Add(Const(0));
break; break;
case TldsType.Texture2DArrayLodZero: case TexelLoadScalarType.Texture2DArrayLodZero:
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Const(0)); sourcesList.Add(Const(0));
break; break;
case TldsType.Texture2DLodLevelOffset: case TexelLoadScalarType.Texture2DLodLevelOffset:
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Ra()); sourcesList.Add(Ra());
sourcesList.Add(Rb()); sourcesList.Add(Rb());
@ -781,110 +781,110 @@ namespace Ryujinx.Graphics.Shader.Instructions
throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\"."); throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\".");
} }
private static TextureType GetTextureType(TexsType type) private static TextureType GetTextureType(TextureScalarType type)
{ {
switch (type) switch (type)
{ {
case TexsType.Texture1DLodZero: case TextureScalarType.Texture1DLodZero:
return TextureType.Texture1D; return TextureType.Texture1D;
case TexsType.Texture2D: case TextureScalarType.Texture2D:
case TexsType.Texture2DLodZero: case TextureScalarType.Texture2DLodZero:
case TexsType.Texture2DLodLevel: case TextureScalarType.Texture2DLodLevel:
return TextureType.Texture2D; return TextureType.Texture2D;
case TexsType.Texture2DDepthCompare: case TextureScalarType.Texture2DDepthCompare:
case TexsType.Texture2DLodLevelDepthCompare: case TextureScalarType.Texture2DLodLevelDepthCompare:
case TexsType.Texture2DLodZeroDepthCompare: case TextureScalarType.Texture2DLodZeroDepthCompare:
return TextureType.Texture2D | TextureType.Shadow; return TextureType.Texture2D | TextureType.Shadow;
case TexsType.Texture2DArray: case TextureScalarType.Texture2DArray:
case TexsType.Texture2DArrayLodZero: case TextureScalarType.Texture2DArrayLodZero:
return TextureType.Texture2D | TextureType.Array; return TextureType.Texture2D | TextureType.Array;
case TexsType.Texture2DArrayLodZeroDepthCompare: case TextureScalarType.Texture2DArrayLodZeroDepthCompare:
return TextureType.Texture2D | TextureType.Array | TextureType.Shadow; return TextureType.Texture2D | TextureType.Array | TextureType.Shadow;
case TexsType.Texture3D: case TextureScalarType.Texture3D:
case TexsType.Texture3DLodZero: case TextureScalarType.Texture3DLodZero:
return TextureType.Texture3D; return TextureType.Texture3D;
case TexsType.TextureCube: case TextureScalarType.TextureCube:
case TexsType.TextureCubeLodLevel: case TextureScalarType.TextureCubeLodLevel:
return TextureType.TextureCube; return TextureType.TextureCube;
} }
throw new ArgumentException($"Invalid texture type \"{type}\"."); throw new ArgumentException($"Invalid texture type \"{type}\".");
} }
private static TextureType GetTextureType(TldsType type) private static TextureType GetTextureType(TexelLoadScalarType type)
{ {
switch (type) switch (type)
{ {
case TldsType.Texture1DLodZero: case TexelLoadScalarType.Texture1DLodZero:
case TldsType.Texture1DLodLevel: case TexelLoadScalarType.Texture1DLodLevel:
return TextureType.Texture1D; return TextureType.Texture1D;
case TldsType.Texture2DLodZero: case TexelLoadScalarType.Texture2DLodZero:
case TldsType.Texture2DLodZeroOffset: case TexelLoadScalarType.Texture2DLodZeroOffset:
case TldsType.Texture2DLodLevel: case TexelLoadScalarType.Texture2DLodLevel:
case TldsType.Texture2DLodLevelOffset: case TexelLoadScalarType.Texture2DLodLevelOffset:
return TextureType.Texture2D; return TextureType.Texture2D;
case TldsType.Texture2DLodZeroMultisample: case TexelLoadScalarType.Texture2DLodZeroMultisample:
return TextureType.Texture2D | TextureType.Multisample; return TextureType.Texture2D | TextureType.Multisample;
case TldsType.Texture3DLodZero: case TexelLoadScalarType.Texture3DLodZero:
return TextureType.Texture3D; return TextureType.Texture3D;
case TldsType.Texture2DArrayLodZero: case TexelLoadScalarType.Texture2DArrayLodZero:
return TextureType.Texture2D | TextureType.Array; return TextureType.Texture2D | TextureType.Array;
} }
throw new ArgumentException($"Invalid texture type \"{type}\"."); throw new ArgumentException($"Invalid texture type \"{type}\".");
} }
private static TextureFlags GetTextureFlags(TexsType type) private static TextureFlags GetTextureFlags(TextureScalarType type)
{ {
switch (type) switch (type)
{ {
case TexsType.Texture1DLodZero: case TextureScalarType.Texture1DLodZero:
case TexsType.Texture2DLodZero: case TextureScalarType.Texture2DLodZero:
case TexsType.Texture2DLodLevel: case TextureScalarType.Texture2DLodLevel:
case TexsType.Texture2DLodLevelDepthCompare: case TextureScalarType.Texture2DLodLevelDepthCompare:
case TexsType.Texture2DLodZeroDepthCompare: case TextureScalarType.Texture2DLodZeroDepthCompare:
case TexsType.Texture2DArrayLodZero: case TextureScalarType.Texture2DArrayLodZero:
case TexsType.Texture2DArrayLodZeroDepthCompare: case TextureScalarType.Texture2DArrayLodZeroDepthCompare:
case TexsType.Texture3DLodZero: case TextureScalarType.Texture3DLodZero:
case TexsType.TextureCubeLodLevel: case TextureScalarType.TextureCubeLodLevel:
return TextureFlags.LodLevel; return TextureFlags.LodLevel;
case TexsType.Texture2D: case TextureScalarType.Texture2D:
case TexsType.Texture2DDepthCompare: case TextureScalarType.Texture2DDepthCompare:
case TexsType.Texture2DArray: case TextureScalarType.Texture2DArray:
case TexsType.Texture3D: case TextureScalarType.Texture3D:
case TexsType.TextureCube: case TextureScalarType.TextureCube:
return TextureFlags.None; return TextureFlags.None;
} }
throw new ArgumentException($"Invalid texture type \"{type}\"."); throw new ArgumentException($"Invalid texture type \"{type}\".");
} }
private static TextureFlags GetTextureFlags(TldsType type) private static TextureFlags GetTextureFlags(TexelLoadScalarType type)
{ {
switch (type) switch (type)
{ {
case TldsType.Texture1DLodZero: case TexelLoadScalarType.Texture1DLodZero:
case TldsType.Texture1DLodLevel: case TexelLoadScalarType.Texture1DLodLevel:
case TldsType.Texture2DLodZero: case TexelLoadScalarType.Texture2DLodZero:
case TldsType.Texture2DLodLevel: case TexelLoadScalarType.Texture2DLodLevel:
case TldsType.Texture2DLodZeroMultisample: case TexelLoadScalarType.Texture2DLodZeroMultisample:
case TldsType.Texture3DLodZero: case TexelLoadScalarType.Texture3DLodZero:
case TldsType.Texture2DArrayLodZero: case TexelLoadScalarType.Texture2DArrayLodZero:
return TextureFlags.LodLevel; return TextureFlags.LodLevel;
case TldsType.Texture2DLodZeroOffset: case TexelLoadScalarType.Texture2DLodZeroOffset:
case TldsType.Texture2DLodLevelOffset: case TexelLoadScalarType.Texture2DLodLevelOffset:
return TextureFlags.LodLevel | TextureFlags.Offset; return TextureFlags.LodLevel | TextureFlags.Offset;
} }