private void GenInst2(ShaderProgram Program, uint InstOp) { ShaderOpCode OpCode = (ShaderOpCode)(InstOp >> 26); ShaderInst2 Inst = new ShaderInst2(InstOp); switch (OpCode) { case ShaderOpCode.BreakC: GenBreakC(Program, Inst); break; case ShaderOpCode.Call: GenCall(Program, Inst); break; case ShaderOpCode.CallC: GenCallC(Program, Inst); break; case ShaderOpCode.IfC: GenIfC(Program, Inst); break; case ShaderOpCode.JmpC: GenJmpC(Program, Inst); break; } }
private static string GetCond(ShaderInst2 Inst) { string RefX = Inst.RefX ? string.Empty : "!"; string RefY = Inst.RefY ? string.Empty : "!"; string Cond = string.Empty; switch (Inst.CondOp) { case 0: Cond = $"{RefX}{CmpRegName}.x || {RefY}{CmpRegName}.y"; break; case 1: Cond = $"{RefX}{CmpRegName}.x && {RefY}{CmpRegName}.y"; break; case 2: Cond = $"{RefX}{CmpRegName}.x"; break; case 3: Cond = $"{RefY}{CmpRegName}.y"; break; } return(Cond); }
private void GenJmpC(ShaderProgram Program, ShaderInst2 Inst) { GenJmp(Program, GetCond(Inst), Inst.Dest); }
private void GenIfC(ShaderProgram Program, ShaderInst2 Inst) { GenIf(Program, GetCond(Inst), Inst.Dest, Inst.Count); }
private void GenCallC(ShaderProgram Program, ShaderInst2 Inst) { Append($"if ({GetCond(Inst)}) {GetCall(Program, Inst.Dest, Inst.Count)}"); }
private void GenCall(ShaderProgram Program, ShaderInst2 Inst) { Append(GetCall(Program, Inst.Dest, Inst.Count)); }
private void GenBreakC(ShaderProgram Program, ShaderInst2 Inst) { Append($"if ({GetCond(Inst)}) break;"); }