Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 2012 Rob Clark <robdclark@gmail.com>
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the
  9.  * Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21.  * SOFTWARE.
  22.  */
  23.  
  24. #ifndef INSTR_A2XX_H_
  25. #define INSTR_A2XX_H_
  26.  
  27. #define PACKED __attribute__((__packed__))
  28.  
  29. #include "util/u_math.h"
  30. #include "adreno_common.xml.h"
  31. #include "adreno_pm4.xml.h"
  32. #include "a2xx.xml.h"
  33.  
  34.  
  35. /*
  36.  * ALU instructions:
  37.  */
  38.  
  39. typedef enum {
  40.         ADDs = 0,
  41.         ADD_PREVs = 1,
  42.         MULs = 2,
  43.         MUL_PREVs = 3,
  44.         MUL_PREV2s = 4,
  45.         MAXs = 5,
  46.         MINs = 6,
  47.         SETEs = 7,
  48.         SETGTs = 8,
  49.         SETGTEs = 9,
  50.         SETNEs = 10,
  51.         FRACs = 11,
  52.         TRUNCs = 12,
  53.         FLOORs = 13,
  54.         EXP_IEEE = 14,
  55.         LOG_CLAMP = 15,
  56.         LOG_IEEE = 16,
  57.         RECIP_CLAMP = 17,
  58.         RECIP_FF = 18,
  59.         RECIP_IEEE = 19,
  60.         RECIPSQ_CLAMP = 20,
  61.         RECIPSQ_FF = 21,
  62.         RECIPSQ_IEEE = 22,
  63.         MOVAs = 23,
  64.         MOVA_FLOORs = 24,
  65.         SUBs = 25,
  66.         SUB_PREVs = 26,
  67.         PRED_SETEs = 27,
  68.         PRED_SETNEs = 28,
  69.         PRED_SETGTs = 29,
  70.         PRED_SETGTEs = 30,
  71.         PRED_SET_INVs = 31,
  72.         PRED_SET_POPs = 32,
  73.         PRED_SET_CLRs = 33,
  74.         PRED_SET_RESTOREs = 34,
  75.         KILLEs = 35,
  76.         KILLGTs = 36,
  77.         KILLGTEs = 37,
  78.         KILLNEs = 38,
  79.         KILLONEs = 39,
  80.         SQRT_IEEE = 40,
  81.         MUL_CONST_0 = 42,
  82.         MUL_CONST_1 = 43,
  83.         ADD_CONST_0 = 44,
  84.         ADD_CONST_1 = 45,
  85.         SUB_CONST_0 = 46,
  86.         SUB_CONST_1 = 47,
  87.         SIN = 48,
  88.         COS = 49,
  89.         RETAIN_PREV = 50,
  90. } instr_scalar_opc_t;
  91.  
  92. typedef enum {
  93.         ADDv = 0,
  94.         MULv = 1,
  95.         MAXv = 2,
  96.         MINv = 3,
  97.         SETEv = 4,
  98.         SETGTv = 5,
  99.         SETGTEv = 6,
  100.         SETNEv = 7,
  101.         FRACv = 8,
  102.         TRUNCv = 9,
  103.         FLOORv = 10,
  104.         MULADDv = 11,
  105.         CNDEv = 12,
  106.         CNDGTEv = 13,
  107.         CNDGTv = 14,
  108.         DOT4v = 15,
  109.         DOT3v = 16,
  110.         DOT2ADDv = 17,
  111.         CUBEv = 18,
  112.         MAX4v = 19,
  113.         PRED_SETE_PUSHv = 20,
  114.         PRED_SETNE_PUSHv = 21,
  115.         PRED_SETGT_PUSHv = 22,
  116.         PRED_SETGTE_PUSHv = 23,
  117.         KILLEv = 24,
  118.         KILLGTv = 25,
  119.         KILLGTEv = 26,
  120.         KILLNEv = 27,
  121.         DSTv = 28,
  122.         MOVAv = 29,
  123. } instr_vector_opc_t;
  124.  
  125. typedef struct PACKED {
  126.         /* dword0: */
  127.         uint8_t             vector_dest              : 6;
  128.         uint8_t             vector_dest_rel          : 1;
  129.         uint8_t             low_precision_16b_fp     : 1;
  130.         uint8_t             scalar_dest              : 6;
  131.         uint8_t             scalar_dest_rel          : 1;
  132.         uint8_t             export_data              : 1;
  133.         uint8_t             vector_write_mask        : 4;
  134.         uint8_t             scalar_write_mask        : 4;
  135.         uint8_t             vector_clamp             : 1;
  136.         uint8_t             scalar_clamp             : 1;
  137.         instr_scalar_opc_t  scalar_opc               : 6;
  138.         /* dword1: */
  139.         uint8_t             src3_swiz                : 8;
  140.         uint8_t             src2_swiz                : 8;
  141.         uint8_t             src1_swiz                : 8;
  142.         uint8_t             src3_reg_negate          : 1;
  143.         uint8_t             src2_reg_negate          : 1;
  144.         uint8_t             src1_reg_negate          : 1;
  145.         uint8_t             pred_select              : 2;
  146.         uint8_t             relative_addr            : 1;
  147.         uint8_t             const_1_rel_abs          : 1;
  148.         uint8_t             const_0_rel_abs          : 1;
  149.         /* dword2: */
  150.         uint8_t             src3_reg                 : 6;
  151.         uint8_t             src3_reg_select          : 1;
  152.         uint8_t             src3_reg_abs             : 1;
  153.         uint8_t             src2_reg                 : 6;
  154.         uint8_t             src2_reg_select          : 1;
  155.         uint8_t             src2_reg_abs             : 1;
  156.         uint8_t             src1_reg                 : 6;
  157.         uint8_t             src1_reg_select          : 1;
  158.         uint8_t             src1_reg_abs             : 1;
  159.         instr_vector_opc_t  vector_opc               : 5;
  160.         uint8_t             src3_sel                 : 1;
  161.         uint8_t             src2_sel                 : 1;
  162.         uint8_t             src1_sel                 : 1;
  163. } instr_alu_t;
  164.  
  165.  
  166.  
  167. /*
  168.  * CF instructions:
  169.  */
  170.  
  171. typedef enum {
  172.         NOP = 0,
  173.         EXEC = 1,
  174.         EXEC_END = 2,
  175.         COND_EXEC = 3,
  176.         COND_EXEC_END = 4,
  177.         COND_PRED_EXEC = 5,
  178.         COND_PRED_EXEC_END = 6,
  179.         LOOP_START = 7,
  180.         LOOP_END = 8,
  181.         COND_CALL = 9,
  182.         RETURN = 10,
  183.         COND_JMP = 11,
  184.         ALLOC = 12,
  185.         COND_EXEC_PRED_CLEAN = 13,
  186.         COND_EXEC_PRED_CLEAN_END = 14,
  187.         MARK_VS_FETCH_DONE = 15,
  188. } instr_cf_opc_t;
  189.  
  190. typedef enum {
  191.         RELATIVE_ADDR = 0,
  192.         ABSOLUTE_ADDR = 1,
  193. } instr_addr_mode_t;
  194.  
  195. typedef enum {
  196.         SQ_NO_ALLOC = 0,
  197.         SQ_POSITION = 1,
  198.         SQ_PARAMETER_PIXEL = 2,
  199.         SQ_MEMORY = 3,
  200. } instr_alloc_type_t;
  201.  
  202. typedef struct PACKED {
  203.         uint16_t            address                  : 9;
  204.         uint8_t             reserved0                : 3;
  205.         uint8_t             count                    : 3;
  206.         uint8_t             yeild                    : 1;
  207.         uint16_t            serialize                : 12;
  208.         uint8_t             vc                       : 6;   /* vertex cache? */
  209.         uint8_t             bool_addr                : 8;
  210.         uint8_t             condition                : 1;
  211.         instr_addr_mode_t   address_mode             : 1;
  212.         instr_cf_opc_t      opc                      : 4;
  213. } instr_cf_exec_t;
  214.  
  215. typedef struct PACKED {
  216.         uint16_t            address                  : 10;
  217.         uint8_t             reserved0                : 6;
  218.         uint8_t             loop_id                  : 5;
  219.         uint32_t            reserved1                : 22;
  220.         instr_addr_mode_t   address_mode             : 1;
  221.         instr_cf_opc_t      opc                      : 4;
  222. } instr_cf_loop_t;
  223.  
  224. typedef struct PACKED {
  225.         uint16_t            address                  : 10;
  226.         uint8_t             reserved0                : 3;
  227.         uint8_t             force_call               : 1;
  228.         uint8_t             predicated_jmp           : 1;
  229.         uint32_t            reserved1                : 18;
  230.         uint8_t             direction                : 1;
  231.         uint8_t             bool_addr                : 8;
  232.         uint8_t             condition                : 1;
  233.         instr_addr_mode_t   address_mode             : 1;
  234.         instr_cf_opc_t      opc                      : 4;
  235. } instr_cf_jmp_call_t;
  236.  
  237. typedef struct PACKED {
  238.         uint8_t             size                     : 4;
  239.         uint64_t            reserved0                : 36;
  240.         uint8_t             no_serial                : 1;
  241.         instr_alloc_type_t  buffer_select            : 2;
  242.         uint8_t             alloc_mode               : 1;
  243.         instr_cf_opc_t      opc                      : 4;
  244. } instr_cf_alloc_t;
  245.  
  246. typedef union PACKED {
  247.         instr_cf_exec_t     exec;
  248.         instr_cf_loop_t     loop;
  249.         instr_cf_jmp_call_t jmp_call;
  250.         instr_cf_alloc_t    alloc;
  251.         struct PACKED {
  252.                 uint64_t        dummy                    : 44;
  253.                 instr_cf_opc_t  opc                      : 4;
  254.         };
  255. } instr_cf_t;
  256.  
  257.  
  258.  
  259. /*
  260.  * FETCH instructions:
  261.  */
  262.  
  263. typedef enum {
  264.         VTX_FETCH = 0,
  265.         TEX_FETCH = 1,
  266.         TEX_GET_BORDER_COLOR_FRAC = 16,
  267.         TEX_GET_COMP_TEX_LOD = 17,
  268.         TEX_GET_GRADIENTS = 18,
  269.         TEX_GET_WEIGHTS = 19,
  270.         TEX_SET_TEX_LOD = 24,
  271.         TEX_SET_GRADIENTS_H = 25,
  272.         TEX_SET_GRADIENTS_V = 26,
  273.         TEX_RESERVED_4 = 27,
  274. } instr_fetch_opc_t;
  275.  
  276. typedef enum {
  277.         TEX_FILTER_POINT = 0,
  278.         TEX_FILTER_LINEAR = 1,
  279.         TEX_FILTER_BASEMAP = 2,            /* only applicable for mip-filter */
  280.         TEX_FILTER_USE_FETCH_CONST = 3,
  281. } instr_tex_filter_t;
  282.  
  283. typedef enum {
  284.         ANISO_FILTER_DISABLED = 0,
  285.         ANISO_FILTER_MAX_1_1 = 1,
  286.         ANISO_FILTER_MAX_2_1 = 2,
  287.         ANISO_FILTER_MAX_4_1 = 3,
  288.         ANISO_FILTER_MAX_8_1 = 4,
  289.         ANISO_FILTER_MAX_16_1 = 5,
  290.         ANISO_FILTER_USE_FETCH_CONST = 7,
  291. } instr_aniso_filter_t;
  292.  
  293. typedef enum {
  294.         ARBITRARY_FILTER_2X4_SYM = 0,
  295.         ARBITRARY_FILTER_2X4_ASYM = 1,
  296.         ARBITRARY_FILTER_4X2_SYM = 2,
  297.         ARBITRARY_FILTER_4X2_ASYM = 3,
  298.         ARBITRARY_FILTER_4X4_SYM = 4,
  299.         ARBITRARY_FILTER_4X4_ASYM = 5,
  300.         ARBITRARY_FILTER_USE_FETCH_CONST = 7,
  301. } instr_arbitrary_filter_t;
  302.  
  303. typedef enum {
  304.         SAMPLE_CENTROID = 0,
  305.         SAMPLE_CENTER = 1,
  306. } instr_sample_loc_t;
  307.  
  308. typedef enum a2xx_sq_surfaceformat instr_surf_fmt_t;
  309.  
  310. typedef struct PACKED {
  311.         /* dword0: */
  312.         instr_fetch_opc_t   opc                      : 5;
  313.         uint8_t             src_reg                  : 6;
  314.         uint8_t             src_reg_am               : 1;
  315.         uint8_t             dst_reg                  : 6;
  316.         uint8_t             dst_reg_am               : 1;
  317.         uint8_t             fetch_valid_only         : 1;
  318.         uint8_t             const_idx                : 5;
  319.         uint8_t             tx_coord_denorm          : 1;
  320.         uint8_t             src_swiz                 : 6;
  321.         /* dword1: */
  322.         uint16_t            dst_swiz                 : 12;
  323.         instr_tex_filter_t  mag_filter               : 2;
  324.         instr_tex_filter_t  min_filter               : 2;
  325.         instr_tex_filter_t  mip_filter               : 2;
  326.         instr_aniso_filter_t aniso_filter            : 3;
  327.         instr_arbitrary_filter_t arbitrary_filter    : 3;
  328.         instr_tex_filter_t  vol_mag_filter           : 2;
  329.         instr_tex_filter_t  vol_min_filter           : 2;
  330.         uint8_t             use_comp_lod             : 1;
  331.         uint8_t             use_reg_lod              : 2;  /* 0 for cube, 1 for 2d */
  332.         uint8_t             pred_select              : 1;
  333.         /* dword2: */
  334.         uint8_t             use_reg_gradients        : 1;
  335.         instr_sample_loc_t  sample_location          : 1;
  336.         uint8_t             lod_bias                 : 7;
  337.         uint8_t             unused                   : 7;
  338.         uint8_t             offset_x                 : 5;
  339.         uint8_t             offset_y                 : 5;
  340.         uint8_t             offset_z                 : 5;
  341.         uint8_t             pred_condition           : 1;
  342. } instr_fetch_tex_t;
  343.  
  344. typedef struct PACKED {
  345.         /* dword0: */
  346.         instr_fetch_opc_t   opc                      : 5;
  347.         uint8_t             src_reg                  : 6;
  348.         uint8_t             src_reg_am               : 1;
  349.         uint8_t             dst_reg                  : 6;
  350.         uint8_t             dst_reg_am               : 1;
  351.         uint8_t             must_be_one              : 1;
  352.         uint8_t             const_index              : 5;
  353.         uint8_t             const_index_sel          : 2;
  354.         uint8_t             reserved0                : 3;
  355.         uint8_t             src_swiz                 : 2;
  356.         /* dword1: */
  357.         uint16_t            dst_swiz                 : 12;
  358.         uint8_t             format_comp_all          : 1;   /* '1' for signed, '0' for unsigned? */
  359.         uint8_t             num_format_all           : 1;   /* '0' for normalized, '1' for unnormalized */
  360.         uint8_t             signed_rf_mode_all       : 1;
  361.         uint8_t             reserved1                : 1;
  362.         instr_surf_fmt_t    format                   : 6;
  363.         uint8_t             reserved2                : 1;
  364.         uint8_t             exp_adjust_all           : 7;
  365.         uint8_t             reserved3                : 1;
  366.         uint8_t             pred_select              : 1;
  367.         /* dword2: */
  368.         uint8_t             stride                   : 8;
  369.         /* possibly offset and reserved4 are swapped on a200? */
  370.         uint8_t             offset                   : 8;
  371.         uint8_t             reserved4                : 8;
  372.         uint8_t             reserved5                : 7;
  373.         uint8_t             pred_condition           : 1;
  374. } instr_fetch_vtx_t;
  375.  
  376. typedef union PACKED {
  377.         instr_fetch_tex_t   tex;
  378.         instr_fetch_vtx_t   vtx;
  379.         struct PACKED {
  380.                 /* dword0: */
  381.                 instr_fetch_opc_t opc                    : 5;
  382.                 uint32_t        dummy0                   : 27;
  383.                 /* dword1: */
  384.                 uint32_t        dummy1                   : 32;
  385.                 /* dword2: */
  386.                 uint32_t        dummy2                   : 32;
  387.         };
  388. } instr_fetch_t;
  389.  
  390. #endif /* INSTR_H_ */
  391.