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