Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using BitArrayExtensions;
- /* LICENSE
- Largely translated from:
- https://github.com/benvanik/xenia/blob/master/src/xenia/gpu/ucode.h
- Copyright (c) 2015, Ben Vanik.
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the project nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL BEN VANIK BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- namespace xps_3_0_INTERPRETER.Freedreno
- {
- public class Instruction
- {
- }
- public class Instruction_CF : Instruction
- {
- public class Exec : Instruction_CF
- {
- [BitField(size = 0x09)] public short address;
- [BitField(size = 0x03)] public byte reserved0;
- [BitField(size = 0x03)] public byte count;
- [BitField(size = 0x01)] public bool yield;
- [BitField(size = 0x0C)] public short serialize;
- [BitField(size = 0x06)] public byte vc; // vertex cache?
- [BitField(size = 0x08)] public byte bool_address;
- [BitField(size = 0x01)] public bool condition;
- [BitField(size = 0x01)] public AddressMode address_mode;
- [BitField(size = 0x04)] public ControlFlowOpcode opc;
- }
- public class Loop : Instruction_CF
- {
- [BitField(size = 0x0A)] public short address;
- [BitField(size = 0x06)] public byte reserved0;
- [BitField(size = 0x05)] public byte loop_id;
- [BitField(size = 0x16)] public int reserved1;
- [BitField(size = 0x01)] public AddressMode address_mode;
- [BitField(size = 0x04)] public ControlFlowOpcode opc;
- }
- public class JumpCall : Instruction_CF
- {
- [BitField(size = 0x0A)] public short address;
- [BitField(size = 0x03)] public byte reserved0;
- [BitField(size = 0x01)] public bool force_call;
- [BitField(size = 0x01)] public bool predicated_jmp;
- [BitField(size = 0x12)] public int reserved1;
- [BitField(size = 0x01)] public byte direction;
- [BitField(size = 0x08)] public byte bool_addr;
- [BitField(size = 0x01)] public byte condition;
- [BitField(size = 0x01)] public AddressMode address_mode;
- [BitField(size = 0x04)] public ControlFlowOpcode opc;
- }
- public class Alloc : Instruction_CF
- {
- [BitField(size = 0x04)] public byte size;
- [BitField(size = 0x24)] public long reserved0;
- [BitField(size = 0x01)] public bool no_serial;
- [BitField(size = 0x02)] public AllocationType buffer_select;
- [BitField(size = 0x04)] public byte alloc_mode;
- [BitField(size = 0x01)] public ControlFlowOpcode opc;
- }
- public enum ControlFlowOpcode : byte
- {
- cnop = 0, // No-op - used to fill space.
- exec = 1, // Executes fetch or ALU instructions.
- exece = 2, // Executes fetch or ALU instructions then ends execution.
- cexec = 3, // Conditionally executes based on a bool const.
- cexece = 4, // Conditionally executes based on a bool const then ends execution.
- cexec_pred = 5, // Conditionally executes based on the current predicate.
- cexece_pred = 6, // Conditionally executes based on the current predicate then ends execution.
- loop = 7, // Starts a loop that must be terminated with kLoopEnd.
- endloop = 8, // Continues or breaks out of a loop started with kLoopStart.
- ccall = 9, // Conditionally calls a function. A return address is pushed to the stack to be used by a kReturn.
- ret = 10, // Returns from the current function as called by kCondCall. This is a no-op if not in a function.
- cjmp = 11, // Conditionally jumps to an arbitrary address based on a bool const.
- alloc = 12, // Allocates output values.
- cexec_pred_clean = 13, // Conditionally executes based on the current predicate. Optionally resets the predicate value.
- cexece_pred_clean = 14, // Conditionally executes based on the current predicate then ends execution. Optionally resets the predicate value.
- vfetche = 15, // Hints that no more vertex fetches will be performed.
- }
- public enum AddressMode : byte
- {
- Relative = 0,
- Absolute = 1,
- }
- public enum AllocationType : byte
- {
- None = 0,
- Position = 1,
- Interpolators = 2,
- Pixel = 2,
- Memory = 3,
- }
- }
- public class Instruction_ALU : Instruction
- {
- #region DWORD-0
- [BitField(size = 0x06)] public byte vector_dest;
- [BitField(size = 0x01)] public bool vector_dest_rel;
- [BitField(size = 0x01)] public bool low_precision_16b_fp;
- [BitField(size = 0x06)] public byte scalar_dest;
- [BitField(size = 0x01)] public bool scalar_dest_rel;
- [BitField(size = 0x01)] public bool export_data;
- [BitField(size = 0x04)] public Mask vector_write_mask;
- [BitField(size = 0x04)] public Mask scalar_write_mask;
- [BitField(size = 0x01)] public bool vector_clamp;
- [BitField(size = 0x01)] public bool scalar_clamp;
- [BitField(size = 0x06)] public ScalarOpcode scalar_opc;
- #endregion
- #region DWORD-1
- [BitField(size = 0x08)] public Swizzle src3_swiz;
- [BitField(size = 0x08)] public Swizzle src2_swiz;
- [BitField(size = 0x08)] public Swizzle src1_swiz;
- [BitField(size = 0x01)] public bool src3_reg_negate;
- [BitField(size = 0x01)] public bool src2_reg_negate;
- [BitField(size = 0x01)] public bool src1_reg_negate;
- [BitField(size = 0x02)] public Predication pred_select;
- [BitField(size = 0x01)] public bool relative_addr;
- [BitField(size = 0x01)] public bool const_1_rel_abs;
- [BitField(size = 0x01)] public bool const_0_rel_abs;
- #endregion
- #region DWORD-2
- [BitField(size = 0x06)] public byte src3_reg;
- [BitField(size = 0x01)] public bool src3_reg_select;
- [BitField(size = 0x01)] public bool src3_reg_abs;
- [BitField(size = 0x06)] public byte src2_reg;
- [BitField(size = 0x01)] public bool src2_reg_select;
- [BitField(size = 0x01)] public bool src2_reg_abs;
- [BitField(size = 0x06)] public byte src1_reg;
- [BitField(size = 0x01)] public bool src1_reg_select;
- [BitField(size = 0x01)] public bool src1_reg_abs;
- [BitField(size = 0x05)] public VectorOpcode vector_opc;
- [BitField(size = 0x01)] public bool src3_sel;
- [BitField(size = 0x01)] public bool src2_sel ;
- [BitField(size = 0x01)] public bool src1_sel;
- #endregion
- public enum Mask : byte
- {
- A_Vector = 0x01, // Vector destination mask
- B_Vector = 0x02, // Vector destination mask
- C_Vector = 0x04, // Vector destination mask
- D_Vector = 0x08, // Vector destination mask
- }
- public enum ScalarOpcode : byte
- {
- adds = 0x00,
- adds_prev = 0x04,
- muls = 0x08,
- muls_prev = 0x0C,
- muls_prev2 = 0x10,
- maxs = 0x14,
- mins = 0x18,
- seqs = 0x1C,
- sgts = 0x20,
- sges = 0x24,
- snes = 0x28,
- frcs = 0x2C,
- truncs = 0x30,
- floors = 0x34,
- exp = 0x38,
- logc = 0x3C,
- log = 0x40,
- rcpc = 0x44,
- rcpf = 0x48,
- rcp = 0x4C,
- rsqc = 0x50,
- rsqf = 0x54,
- rsq = 0x58,
- maxas = 0x5C,
- maxasf = 0x60,
- subs = 0x64,
- subs_prev = 0x68,
- setpeq = 0x6C,
- setpne = 0x70,
- setpgt = 0x74,
- setpge = 0x78,
- setpinv = 0x7C,
- setppop = 0x80,
- setpclr = 0x84,
- setprstr = 0x88,
- killseq = 0x8C,
- killsgt = 0x90,
- killsge = 0x94,
- killsne = 0x98,
- killsone = 0x9C,
- sqrt = 0xA0,
- opcode_41 = 0xA4, // disassembler calls it this, probably unused garbage.
- mulsc0 = 0xA8, // same as mulsc.
- mulsc1 = 0xAC, // same as mulsc.
- addsc0 = 0xB0, // same as addsc.
- addsc1 = 0xAC, // same as addsc.
- subsc0 = 0xB8, // same as subsc.
- subsc1 = 0xBC, // same as subsc.
- sin = 0xC0,
- cos = 0xC4,
- retain_prev = 0xC8,
- opcode_51 = 0xCC, // disassembler calls it this, probably unused garbage.
- opcode_52 = 0xD0, // disassembler calls it this, probably unused garbage.
- opcode_53 = 0xD4, // disassembler calls it this, probably unused garbage.
- opcode_54 = 0xD8, // disassembler calls it this, probably unused garbage.
- opcode_55 = 0xDC, // disassembler calls it this, probably unused garbage.
- opcode_56 = 0xE0, // disassembler calls it this, probably unused garbage.
- opcode_57 = 0xE4, // disassembler calls it this, probably unused garbage.
- opcode_58 = 0xE8, // disassembler calls it this, probably unused garbage.
- opcode_59 = 0xEC, // disassembler calls it this, probably unused garbage.
- opcode_60 = 0xF0, // disassembler calls it this, probably unused garbage.
- opcode_61 = 0xF4, // disassembler calls it this, probably unused garbage.
- opcode_62 = 0xF8, // disassembler calls it this, probably unused garbage.
- opcode_63 = 0xFC,
- }
- public enum VectorOpcode : byte
- {
- add = 0x00,
- mul = 0x01,
- max = 0x02,
- min = 0x03,
- seq = 0x04,
- sgt = 0x05,
- sge = 0x06,
- sne = 0x07,
- frc = 0x08,
- trunc = 0x09,
- floor = 0x0A,
- mad = 0x0B,
- cndeq = 0x0C,
- cndge = 0x0D,
- cndgt = 0x0E,
- dp4 = 0x0F,
- dp3 = 0x10,
- dp2add = 0x11,
- cube = 0x12,
- max4 = 0x13,
- setp_eq_push = 0x14,
- setp_ne_push = 0x15,
- setp_gt_push = 0x16,
- setp_ge_push = 0x17,
- kill_eq = 0x18,
- kill_gt = 0x19,
- kill_ge = 0x1A,
- kill_ne = 0x1B,
- dst = 0x1C,
- maxa = 0x1D,
- opcode_30 = 0x1E, // disassembler calls it this, probably unused garbage.
- opcode_31 = 0x1F,
- }
- public enum Swizzle : byte
- {
- xyzw = 0x00,
- yyzw = 0x01,
- zyzw = 0x02,
- wyzw = 0x03,
- xzzw = 0x04,
- yzzw = 0x05,
- zzzw = 0x06,
- wzzw = 0x07,
- xwzw = 0x08,
- ywzw = 0x09,
- zwzw = 0x0A,
- wwzw = 0x0B,
- xxzw = 0x0C,
- yxzw = 0x0D,
- zxzw = 0x0E,
- wxzw = 0x0F,
- xyww = 0x10,
- yyww = 0x11,
- zyww = 0x12,
- wyww = 0x13,
- xzww = 0x14,
- yzww = 0x15,
- zzww = 0x16,
- wzww = 0x17,
- xwww = 0x18,
- ywww = 0x19,
- zwww = 0x1A,
- wwww = 0x1B,
- xxww = 0x1C,
- yxww = 0x1D,
- zxww = 0x1E,
- wxww = 0x1F,
- xyxw = 0x20,
- yyxw = 0x21,
- zyxw = 0x22,
- wyxw = 0x23,
- xzxw = 0x24,
- yzxw = 0x25,
- zzxw = 0x26,
- wzxw = 0x27,
- xwxw = 0x28,
- ywxw = 0x29,
- zwxw = 0x2A,
- wwxw = 0x2B,
- xxxw = 0x2C,
- yxxw = 0x2D,
- zxxw = 0x2E,
- wxxw = 0x2F,
- xyyw = 0x30,
- yyyw = 0x31,
- zyyw = 0x32,
- wyyw = 0x33,
- xzyw = 0x34,
- yzyw = 0x35,
- zzyw = 0x36,
- wzyw = 0x37,
- xwyw = 0x38,
- ywyw = 0x39,
- zwyw = 0x3A,
- wwyw = 0x3B,
- xxyw = 0x3C,
- yxyw = 0x3D,
- zxyw = 0x3E,
- wxyw = 0x3F,
- xyzx = 0x40,
- yyzx = 0x41,
- zyzx = 0x42,
- wyzx = 0x43,
- xzzx = 0x44,
- yzzx = 0x45,
- zzzx = 0x46,
- wzzx = 0x47,
- xwzx = 0x48,
- ywzx = 0x49,
- zwzx = 0x4A,
- wwzx = 0x4B,
- xxzx = 0x4C,
- yxzx = 0x4D,
- zxzx = 0x4E,
- wxzx = 0x4F,
- xywx = 0x50,
- yywx = 0x51,
- zywx = 0x52,
- wywx = 0x53,
- xzwx = 0x54,
- yzwx = 0x55,
- zzwx = 0x56,
- wzwx = 0x57,
- xwwx = 0x58,
- ywwx = 0x59,
- zwwx = 0x5A,
- wwwx = 0x5B,
- xxwx = 0x5C,
- yxwx = 0x5D,
- zxwx = 0x5E,
- wxwx = 0x5F,
- xyxx = 0x60,
- yyxx = 0x61,
- zyxx = 0x62,
- wyxx = 0x63,
- xzxx = 0x64,
- yzxx = 0x65,
- zzxx = 0x66,
- wzxx = 0x67,
- xwxx = 0x68,
- ywxx = 0x69,
- zwxx = 0x6A,
- wwxx = 0x6B,
- xxxx = 0x6C,
- yxxx = 0x6D,
- zxxx = 0x6E,
- wxxx = 0x6F,
- xyyx = 0x70,
- yyyx = 0x71,
- zyyx = 0x72,
- wyyx = 0x73,
- xzyx = 0x74,
- yzyx = 0x75,
- zzyx = 0x76,
- wzyx = 0x77,
- xwyx = 0x78,
- ywyx = 0x79,
- zwyx = 0x7A,
- wwyx = 0x7B,
- xxyx = 0x7C,
- yxyx = 0x7D,
- zxyx = 0x7E,
- wxyx = 0x7F,
- xyzy = 0x80,
- yyzy = 0x81,
- zyzy = 0x82,
- wyzy = 0x83,
- xzzy = 0x84,
- yzzy = 0x85,
- zzzy = 0x86,
- wzzy = 0x87,
- xwzy = 0x88,
- ywzy = 0x89,
- zwzy = 0x8A,
- wwzy = 0x8B,
- xxzy = 0x8C,
- yxzy = 0x8D,
- zxzy = 0x8E,
- wxzy = 0x8F,
- xywy = 0x90,
- yywy = 0x91,
- zywy = 0x92,
- wywy = 0x93,
- xzwy = 0x94,
- yzwy = 0x95,
- zzwy = 0x96,
- wzwy = 0x97,
- xwwy = 0x98,
- ywwy = 0x99,
- zwwy = 0x9A,
- wwwy = 0x9B,
- xxwy = 0x9C,
- yxwy = 0x9D,
- zxwy = 0x9E,
- wxwy = 0x9F,
- xyxy = 0xA0,
- yyxy = 0xA1,
- zyxy = 0xA2,
- wyxy = 0xA3,
- xzxy = 0xA4,
- yzxy = 0xA5,
- zzxy = 0xA6,
- wzxy = 0xA7,
- xwxy = 0xA8,
- ywxy = 0xA9,
- zwxy = 0xAA,
- wwxy = 0xAB,
- xxxy = 0xAC,
- yxxy = 0xAD,
- zxxy = 0xAE,
- wxxy = 0xAF,
- xyyy = 0xB0,
- yyyy = 0xB1,
- zyyy = 0xB2,
- wyyy = 0xB3,
- xzyy = 0xB4,
- yzyy = 0xB5,
- zzyy = 0xB6,
- wzyy = 0xB7,
- xwyy = 0xB8,
- ywyy = 0xB9,
- zwyy = 0xBA,
- wwyy = 0xBB,
- xxyy = 0xBC,
- yxyy = 0xBD,
- zxyy = 0xBE,
- wxyy = 0xBF,
- xyzz = 0xC0,
- yyzz = 0xC1,
- zyzz = 0xC2,
- wyzz = 0xC3,
- xzzz = 0xC4,
- yzzz = 0xC5,
- zzzz = 0xC6,
- wzzz = 0xC7,
- xwzz = 0xC8,
- ywzz = 0xC9,
- zwzz = 0xCA,
- wwzz = 0xCB,
- xxzz = 0xCC,
- yxzz = 0xCD,
- zxzz = 0xCE,
- wxzz = 0xCF,
- xywz = 0xD0,
- yywz = 0xD1,
- zywz = 0xD2,
- wywz = 0xD3,
- xzwz = 0xD4,
- yzwz = 0xD5,
- zzwz = 0xD6,
- wzwz = 0xD7,
- xwwz = 0xD8,
- ywwz = 0xD9,
- zwwz = 0xDA,
- wwwz = 0xDB,
- xxwz = 0xDC,
- yxwz = 0xDD,
- zxwz = 0xDE,
- wxwz = 0xDF,
- xyxz = 0xE0,
- yyxz = 0xE1,
- zyxz = 0xE2,
- wyxz = 0xE3,
- xzxz = 0xE4,
- yzxz = 0xE5,
- zzxz = 0xE6,
- wzxz = 0xE7,
- xwxz = 0xE8,
- ywxz = 0xE9,
- zwxz = 0xEA,
- wwxz = 0xEB,
- xxxz = 0xEC,
- yxxz = 0xED,
- zxxz = 0xEE,
- wxxz = 0xEF,
- xyyz = 0xF0,
- yyyz = 0xF1,
- zyyz = 0xF2,
- wyyz = 0xF3,
- xzyz = 0xF4,
- yzyz = 0xF5,
- zzyz = 0xF6,
- wzyz = 0xF7,
- xwyz = 0xF8,
- ywyz = 0xF9,
- zwyz = 0xFA,
- wwyz = 0xFB,
- xxyz = 0xFC,
- yxyz = 0xFD,
- zxyz = 0xFE,
- wxyz = 0xFF,
- }
- public enum Predication : byte
- {
- False = 1,
- True = 2
- }
- }
- public class Instruction_Fetch : Instruction
- {
- public enum FetchOpCode
- {
- vfetch = 0,
- tfetch = 1,
- getBCF = 16,
- getCompTexLOD = 17,
- getGradients = 18,
- getWeights = 19,
- setTexLOD = 24,
- setGradientH = 25,
- setGradientV = 26,
- kUnknownTextureOp = 27,
- }
- public enum TextureFilter
- {
- TEX_FILTER_POINT = 0,
- TEX_FILTER_LINEAR = 1,
- TEX_FILTER_BASEMAP = 2, /* only applicable for mip-filter */
- TEX_FILTER_USE_FETCH_CONST = 3,
- }
- public enum AnisoFilter
- {
- ANISO_FILTER_DISABLED = 0,
- ANISO_FILTER_MAX_1_1 = 1,
- ANISO_FILTER_MAX_2_1 = 2,
- ANISO_FILTER_MAX_4_1 = 3,
- ANISO_FILTER_MAX_8_1 = 4,
- ANISO_FILTER_MAX_16_1 = 5,
- ANISO_FILTER_USE_FETCH_CONST = 7,
- }
- public enum ArbitraryFilter
- {
- ARBITRARY_FILTER_2X4_SYM = 0,
- ARBITRARY_FILTER_2X4_ASYM = 1,
- ARBITRARY_FILTER_4X2_SYM = 2,
- ARBITRARY_FILTER_4X2_ASYM = 3,
- ARBITRARY_FILTER_4X4_SYM = 4,
- ARBITRARY_FILTER_4X4_ASYM = 5,
- ARBITRARY_FILTER_USE_FETCH_CONST = 7,
- }
- public enum SampleLocation
- {
- SAMPLE_CENTROID = 0,
- SAMPLE_CENTER = 1,
- }
- public enum SurfaceFormat
- {
- FMT_1_REVERSE = 0,
- FMT_1 = 1,
- FMT_8 = 2,
- FMT_1_5_5_5 = 3,
- FMT_5_6_5 = 4,
- FMT_6_5_5 = 5,
- FMT_8_8_8_8 = 6,
- FMT_2_10_10_10 = 7,
- FMT_8_A = 8,
- FMT_8_B = 9,
- FMT_8_8 = 10,
- FMT_Cr_Y1_Cb_Y0 = 11,
- FMT_Y1_Cr_Y0_Cb = 12,
- FMT_5_5_5_1 = 13,
- FMT_8_8_8_8_A = 14,
- FMT_4_4_4_4 = 15,
- FMT_10_11_11 = 16,
- FMT_11_11_10 = 17,
- FMT_DXT1 = 18,
- FMT_DXT2_3 = 19,
- FMT_DXT4_5 = 20,
- FMT_24_8 = 22,
- FMT_24_8_FLOAT = 23,
- FMT_16 = 24,
- FMT_16_16 = 25,
- FMT_16_16_16_16 = 26,
- FMT_16_EXPAND = 27,
- FMT_16_16_EXPAND = 28,
- FMT_16_16_16_16_EXPAND = 29,
- FMT_16_FLOAT = 30,
- FMT_16_16_FLOAT = 31,
- FMT_16_16_16_16_FLOAT = 32,
- FMT_32 = 33,
- FMT_32_32 = 34,
- FMT_32_32_32_32 = 35,
- FMT_32_FLOAT = 36,
- FMT_32_32_FLOAT = 37,
- FMT_32_32_32_32_FLOAT = 38,
- FMT_32_AS_8 = 39,
- FMT_32_AS_8_8 = 40,
- FMT_16_MPEG = 41,
- FMT_16_16_MPEG = 42,
- FMT_8_INTERLACED = 43,
- FMT_32_AS_8_INTERLACED = 44,
- FMT_32_AS_8_8_INTERLACED = 45,
- FMT_16_INTERLACED = 46,
- FMT_16_MPEG_INTERLACED = 47,
- FMT_16_16_MPEG_INTERLACED = 48,
- FMT_DXN = 49,
- FMT_8_8_8_8_AS_16_16_16_16 = 50,
- FMT_DXT1_AS_16_16_16_16 = 51,
- FMT_DXT2_3_AS_16_16_16_16 = 52,
- FMT_DXT4_5_AS_16_16_16_16 = 53,
- FMT_2_10_10_10_AS_16_16_16_16 = 54,
- FMT_10_11_11_AS_16_16_16_16 = 55,
- FMT_11_11_10_AS_16_16_16_16 = 56,
- FMT_32_32_32_FLOAT = 57,
- FMT_DXT3A = 58,
- FMT_DXT5A = 59,
- FMT_CTX1 = 60,
- FMT_DXT3A_AS_1_1_1_1 = 61,
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement