1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-11 04:36:40 +00:00
Ryujinx/Ryujinx.Graphics/Gal/Shader/ShaderDecodeFlow.cs
ReinUsesLisp 42dc925c3d Implement SSY/SYNC shader instructions (#382)
* Use a program counter to control shaders' flow

* Cleanup

* Implement SSY/SYNC

* Address feedback

* Fixup commentary

* Fixup Ssy instruction
2018-08-31 13:14:04 -03:00

67 lines
No EOL
2.1 KiB
C#

using System;
using static Ryujinx.Graphics.Gal.Shader.ShaderDecodeHelper;
namespace Ryujinx.Graphics.Gal.Shader
{
static partial class ShaderDecode
{
public static void Bra(ShaderIrBlock Block, long OpCode, long Position)
{
if ((OpCode & 0x20) != 0)
{
//This reads the target offset from the constant buffer.
//Almost impossible to support with GLSL.
throw new NotImplementedException();
}
int Target = ((int)(OpCode >> 20) << 8) >> 8;
ShaderIrOperImm Imm = new ShaderIrOperImm(Target);
Block.AddNode(GetPredNode(new ShaderIrOp(ShaderIrInst.Bra, Imm), OpCode));
}
public static void Exit(ShaderIrBlock Block, long OpCode, long Position)
{
int CCode = (int)OpCode & 0x1f;
//TODO: Figure out what the other condition codes mean...
if (CCode == 0xf)
{
Block.AddNode(GetPredNode(new ShaderIrOp(ShaderIrInst.Exit), OpCode));
}
}
public static void Kil(ShaderIrBlock Block, long OpCode, long Position)
{
Block.AddNode(GetPredNode(new ShaderIrOp(ShaderIrInst.Kil), OpCode));
}
public static void Ssy(ShaderIrBlock Block, long OpCode, long Position)
{
if ((OpCode & 0x20) != 0)
{
//This reads the target offset from the constant buffer.
//Almost impossible to support with GLSL.
throw new NotImplementedException();
}
int Offset = ((int)(OpCode >> 20) << 8) >> 8;
int Target = (int)(Position + Offset);
ShaderIrOperImm Imm = new ShaderIrOperImm(Target);
Block.AddNode(new ShaderIrOp(ShaderIrInst.Ssy, Imm));
}
public static void Sync(ShaderIrBlock Block, long OpCode, long Position)
{
//TODO: Implement Sync condition codes
Block.AddNode(GetPredNode(new ShaderIrOp(ShaderIrInst.Sync), OpCode));
}
}
}