コード例 #1
0
ファイル: ShaderDecoder.cs プロジェクト: tiliarou/Ryujinx
        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);
        }
コード例 #2
0
        public static ShaderIrBlock DecodeBasicBlock(int[] Code, int Offset)
        {
            ShaderIrBlock Block = new ShaderIrBlock();

            while (Offset + 2 <= Code.Length)
            {
                int InstPos = Offset * 4;

                Block.Position = InstPos;

                Block.MarkLabel(InstPos);

                //Ignore scheduling instructions, which are written every 32 bytes.
                if ((Offset & 7) == 0)
                {
                    Offset += 2;

                    continue;
                }

                uint Word0 = (uint)Code[Offset++];
                uint Word1 = (uint)Code[Offset++];

                long OpCode = Word0 | (long)Word1 << 32;

                ShaderDecodeFunc Decode = ShaderOpCodeTable.GetDecoder(OpCode);

                if (AddDbgComments)
                {
                    string DbgOpCode = $"0x{InstPos:x8}: 0x{OpCode:x16} ";

                    Block.AddNode(new ShaderIrCmnt(DbgOpCode + (Decode?.Method.Name ?? "???")));
                }

                if (Decode == null)
                {
                    continue;
                }

                Decode(Block, OpCode);

                if (Block.GetLastNode() is ShaderIrOp Op && Op.Inst == ShaderIrInst.Exit)
                {
                    break;
                }
            }

            return(Block);
        }
コード例 #3
0
ファイル: ShaderDecoder.cs プロジェクト: fantaros/Ryujinx
        public static ShaderIrBlock DecodeBasicBlock(int[] Code, int Offset)
        {
            ShaderIrBlock Block = new ShaderIrBlock();

            while (Offset + 2 <= Code.Length)
            {
                //Ignore scheduling instructions, which are
                //written every 32 bytes.
                if ((Offset & 7) == 0)
                {
                    Offset += 2;

                    continue;
                }

                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;
                }
            }

            return(Block);
        }