RyuKen/Ryujinx.Graphics/Gal/Shader/ShaderDecodeHelper.cs
ReinUsesLisp ce1d5be212 Move GPU emulation from Ryujinx.HLE to Ryujinx.Graphics and misc changes (#402)
* Move GPU LLE emulation from HLE to Graphics

* Graphics: Move Gal/Texture to Texture

* Remove Engines/ directory and namespace

* Use tables for image formats

* Abstract OpCode decoding

* Simplify image table

* Do not leak Read* symbols in TextureReader

* Fixups

* Rename IGalFrameBuffer -> IGalRenderTarget

* Remove MaxBpp hardcoded value

* Change yet again texture data and add G8R8 flipping

* Rename GalFrameBufferFormat to GalSurfaceFormat

* Unident EnsureSetup in ImageHandler

* Add IsCompressed

* Address some feedback
2018-09-08 14:51:50 -03:00

72 lines
No EOL
2.2 KiB
C#

using System;
namespace Ryujinx.Graphics.Gal.Shader
{
static class ShaderDecodeHelper
{
public static ShaderIrNode GetAluFabsFneg(ShaderIrNode Node, bool Abs, bool Neg)
{
return GetAluFneg(GetAluFabs(Node, Abs), Neg);
}
public static ShaderIrNode GetAluFabs(ShaderIrNode Node, bool Abs)
{
return Abs ? new ShaderIrOp(ShaderIrInst.Fabs, Node) : Node;
}
public static ShaderIrNode GetAluFneg(ShaderIrNode Node, bool Neg)
{
return Neg ? new ShaderIrOp(ShaderIrInst.Fneg, Node) : Node;
}
public static ShaderIrNode GetAluIabsIneg(ShaderIrNode Node, bool Abs, bool Neg)
{
return GetAluIneg(GetAluIabs(Node, Abs), Neg);
}
public static ShaderIrNode GetAluIabs(ShaderIrNode Node, bool Abs)
{
return Abs ? new ShaderIrOp(ShaderIrInst.Abs, Node) : Node;
}
public static ShaderIrNode GetAluIneg(ShaderIrNode Node, bool Neg)
{
return Neg ? new ShaderIrOp(ShaderIrInst.Neg, Node) : Node;
}
public static ShaderIrNode GetAluNot(ShaderIrNode Node, bool Not)
{
return Not ? new ShaderIrOp(ShaderIrInst.Not, Node) : Node;
}
public static ShaderIrNode ExtendTo32(ShaderIrNode Node, bool Signed, int Size)
{
int Shift = 32 - Size;
ShaderIrInst RightShift = Signed
? ShaderIrInst.Asr
: ShaderIrInst.Lsr;
Node = new ShaderIrOp(ShaderIrInst.Lsl, Node, new ShaderIrOperImm(Shift));
Node = new ShaderIrOp(RightShift, Node, new ShaderIrOperImm(Shift));
return Node;
}
public static ShaderIrNode ExtendTo32(ShaderIrNode Node, bool Signed, ShaderIrNode Size)
{
ShaderIrOperImm WordSize = new ShaderIrOperImm(32);
ShaderIrOp Shift = new ShaderIrOp(ShaderIrInst.Sub, WordSize, Size);
ShaderIrInst RightShift = Signed
? ShaderIrInst.Asr
: ShaderIrInst.Lsr;
Node = new ShaderIrOp(ShaderIrInst.Lsl, Node, Shift);
Node = new ShaderIrOp(RightShift, Node, Shift);
return Node;
}
}
}