mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 09:35:27 +00:00
b9aa3966c0
interpreter, and a rewrite of the GPU code.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
namespace Ryujinx.Graphics.Gal.Shader
|
|
{
|
|
static class ShaderDecoder
|
|
{
|
|
public static ShaderIrBlock DecodeBasicBlock(int[] Code, int Offset, GalShaderType ShaderType)
|
|
{
|
|
ShaderIrBlock Block = new ShaderIrBlock();
|
|
|
|
while (Offset + 2 <= Code.Length)
|
|
{
|
|
uint Word0 = (uint)Code[Offset++];
|
|
uint Word1 = (uint)Code[Offset++];
|
|
|
|
long OpCode = Word0 | (long)Word1 << 32;
|
|
|
|
ShaderDecodeFunc Decode = ShaderOpCodeTable.GetDecoder(OpCode);
|
|
|
|
if (Decode == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
Decode(Block, OpCode);
|
|
|
|
if (Block.GetLastNode() is ShaderIrOp Op && IsFlowChange(Op.Inst))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
Block.RunOptimizationPasses(ShaderType);
|
|
|
|
return Block;
|
|
}
|
|
|
|
private static bool IsFlowChange(ShaderIrInst Inst)
|
|
{
|
|
return Inst == ShaderIrInst.Exit;
|
|
}
|
|
}
|
|
} |