diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-03-03 11:02:08 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-03 15:02:08 +0100 |
| commit | dc97457bf0121b9383054ca14d3c525b56b92634 (patch) | |
| tree | ecd78f76805b16bb01ec8d81f99f1cb3a2a43895 /Ryujinx.Graphics.Shader/Decoders | |
| parent | 3045c1a18644e50fd843dfce07d809e46d923ada (diff) | |
Initial support for double precision shader instructions. (#963)
* Implement DADD, DFMA and DMUL shader instructions
* Rename FP to FP32
* Correct double immediate
* Classic mistake
Diffstat (limited to 'Ryujinx.Graphics.Shader/Decoders')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Decoders/FPType.cs | 10 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs | 14 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs | 10 |
4 files changed, 50 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs b/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs index 77cd1bf7..3585c35f 100644 --- a/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs +++ b/Ryujinx.Graphics.Shader/Decoders/DecoderHelper.cs @@ -54,5 +54,21 @@ namespace Ryujinx.Graphics.Shader.Decoders return BitConverter.Int32BitsToSingle(imm); } + + public static float DecodeD20Immediate(long opCode) + { + long imm = opCode.Extract(20, 19); + + bool negate = opCode.Extract(56); + + imm <<= 44; + + if (negate) + { + imm |= 1L << 63; + } + + return (float)BitConverter.Int64BitsToDouble(imm); + } } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/FPType.cs b/Ryujinx.Graphics.Shader/Decoders/FPType.cs index e602ad45..b5af2c1d 100644 --- a/Ryujinx.Graphics.Shader/Decoders/FPType.cs +++ b/Ryujinx.Graphics.Shader/Decoders/FPType.cs @@ -1,3 +1,5 @@ +using Ryujinx.Graphics.Shader.IntermediateRepresentation; + namespace Ryujinx.Graphics.Shader.Decoders { enum FPType @@ -6,4 +8,12 @@ namespace Ryujinx.Graphics.Shader.Decoders FP32 = 2, FP64 = 3 } + + static class FPTypeExtensions + { + public static Instruction ToInstFPType(this FPType type) + { + return type == FPType.FP64 ? Instruction.FP64 : Instruction.FP32; + } + } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs b/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs new file mode 100644 index 00000000..99d4cdfd --- /dev/null +++ b/Ryujinx.Graphics.Shader/Decoders/OpCodeDArithImm.cs @@ -0,0 +1,14 @@ +using Ryujinx.Graphics.Shader.Instructions; + +namespace Ryujinx.Graphics.Shader.Decoders +{ + class OpCodeDArithImm : OpCodeFArith, IOpCodeImmF + { + public float Immediate { get; } + + public OpCodeDArithImm(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) + { + Immediate = DecoderHelper.DecodeD20Immediate(opCode); + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs b/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs index 87f1de0c..72f66f4a 100644 --- a/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs +++ b/Ryujinx.Graphics.Shader/Decoders/OpCodeTable.cs @@ -45,6 +45,16 @@ namespace Ryujinx.Graphics.Shader.Decoders Set("111000110100xx", InstEmit.Brk, typeof(OpCodeBranchPop)); Set("111000100101xx", InstEmit.Brx, typeof(OpCodeBranchIndir)); Set("0101000010100x", InstEmit.Csetp, typeof(OpCodePset)); + Set("0100110001110x", InstEmit.Dadd, typeof(OpCodeFArithCbuf)); + Set("0011100x01110x", InstEmit.Dadd, typeof(OpCodeDArithImm)); + Set("0101110001110x", InstEmit.Dadd, typeof(OpCodeFArithReg)); + Set("010010110111xx", InstEmit.Dfma, typeof(OpCodeFArithCbuf)); + Set("0011011x0111xx", InstEmit.Dfma, typeof(OpCodeDArithImm)); + Set("010100110111xx", InstEmit.Dfma, typeof(OpCodeFArithRegCbuf)); + Set("010110110111xx", InstEmit.Dfma, typeof(OpCodeFArithReg)); + Set("0100110010000x", InstEmit.Dmul, typeof(OpCodeFArithCbuf)); + Set("0011100x10000x", InstEmit.Dmul, typeof(OpCodeDArithImm)); + Set("0101110010000x", InstEmit.Dmul, typeof(OpCodeFArithReg)); Set("111000110000xx", InstEmit.Exit, typeof(OpCodeExit)); Set("0100110010101x", InstEmit.F2F, typeof(OpCodeFArithCbuf)); Set("0011100x10101x", InstEmit.F2F, typeof(OpCodeFArithImm)); |
