1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci Copyright (C) Intel Corp. 2006. All Rights Reserved. 3bf215546Sopenharmony_ci Intel funded Tungsten Graphics to 4bf215546Sopenharmony_ci develop this 3D driver. 5bf215546Sopenharmony_ci 6bf215546Sopenharmony_ci Permission is hereby granted, free of charge, to any person obtaining 7bf215546Sopenharmony_ci a copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci distribute, sublicense, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci the following conditions: 13bf215546Sopenharmony_ci 14bf215546Sopenharmony_ci The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci next paragraph) shall be included in all copies or substantial 16bf215546Sopenharmony_ci portions of the Software. 17bf215546Sopenharmony_ci 18bf215546Sopenharmony_ci THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19bf215546Sopenharmony_ci EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21bf215546Sopenharmony_ci IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 22bf215546Sopenharmony_ci LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23bf215546Sopenharmony_ci OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24bf215546Sopenharmony_ci WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci **********************************************************************/ 27bf215546Sopenharmony_ci /* 28bf215546Sopenharmony_ci * Authors: 29bf215546Sopenharmony_ci * Keith Whitwell <keithw@vmware.com> 30bf215546Sopenharmony_ci */ 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#ifndef BRW_EU_H 34bf215546Sopenharmony_ci#define BRW_EU_H 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#include <stdbool.h> 37bf215546Sopenharmony_ci#include <stdio.h> 38bf215546Sopenharmony_ci#include "brw_inst.h" 39bf215546Sopenharmony_ci#include "brw_compiler.h" 40bf215546Sopenharmony_ci#include "brw_eu_defines.h" 41bf215546Sopenharmony_ci#include "brw_isa_info.h" 42bf215546Sopenharmony_ci#include "brw_reg.h" 43bf215546Sopenharmony_ci#include "brw_disasm_info.h" 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci#include "util/bitset.h" 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci#ifdef __cplusplus 48bf215546Sopenharmony_ciextern "C" { 49bf215546Sopenharmony_ci#endif 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci#define BRW_EU_MAX_INSN_STACK 5 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_cistruct brw_insn_state { 54bf215546Sopenharmony_ci /* One of BRW_EXECUTE_* */ 55bf215546Sopenharmony_ci unsigned exec_size:3; 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci /* Group in units of channels */ 58bf215546Sopenharmony_ci unsigned group:5; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci /* Compression control on gfx4-5 */ 61bf215546Sopenharmony_ci bool compressed:1; 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci /* One of BRW_MASK_* */ 64bf215546Sopenharmony_ci unsigned mask_control:1; 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci /* Scheduling info for Gfx12+ */ 67bf215546Sopenharmony_ci struct tgl_swsb swsb; 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci bool saturate:1; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* One of BRW_ALIGN_* */ 72bf215546Sopenharmony_ci unsigned access_mode:1; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci /* One of BRW_PREDICATE_* */ 75bf215546Sopenharmony_ci enum brw_predicate predicate:4; 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_ci bool pred_inv:1; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci /* Flag subreg. Bottom bit is subreg, top bit is reg */ 80bf215546Sopenharmony_ci unsigned flag_subreg:2; 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci bool acc_wr_control:1; 83bf215546Sopenharmony_ci}; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci/* A helper for accessing the last instruction emitted. This makes it easy 87bf215546Sopenharmony_ci * to set various bits on an instruction without having to create temporary 88bf215546Sopenharmony_ci * variable and assign the emitted instruction to those. 89bf215546Sopenharmony_ci */ 90bf215546Sopenharmony_ci#define brw_last_inst (&p->store[p->nr_insn - 1]) 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_cistruct brw_codegen { 93bf215546Sopenharmony_ci brw_inst *store; 94bf215546Sopenharmony_ci int store_size; 95bf215546Sopenharmony_ci unsigned nr_insn; 96bf215546Sopenharmony_ci unsigned int next_insn_offset; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci void *mem_ctx; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci /* Allow clients to push/pop instruction state: 101bf215546Sopenharmony_ci */ 102bf215546Sopenharmony_ci struct brw_insn_state stack[BRW_EU_MAX_INSN_STACK]; 103bf215546Sopenharmony_ci struct brw_insn_state *current; 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci /** Whether or not the user wants automatic exec sizes 106bf215546Sopenharmony_ci * 107bf215546Sopenharmony_ci * If true, codegen will try to automatically infer the exec size of an 108bf215546Sopenharmony_ci * instruction from the width of the destination register. If false, it 109bf215546Sopenharmony_ci * will take whatever is set by brw_set_default_exec_size verbatim. 110bf215546Sopenharmony_ci * 111bf215546Sopenharmony_ci * This is set to true by default in brw_init_codegen. 112bf215546Sopenharmony_ci */ 113bf215546Sopenharmony_ci bool automatic_exec_sizes; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci bool single_program_flow; 116bf215546Sopenharmony_ci const struct brw_isa_info *isa; 117bf215546Sopenharmony_ci const struct intel_device_info *devinfo; 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci /* Control flow stacks: 120bf215546Sopenharmony_ci * - if_stack contains IF and ELSE instructions which must be patched 121bf215546Sopenharmony_ci * (and popped) once the matching ENDIF instruction is encountered. 122bf215546Sopenharmony_ci * 123bf215546Sopenharmony_ci * Just store the instruction pointer(an index). 124bf215546Sopenharmony_ci */ 125bf215546Sopenharmony_ci int *if_stack; 126bf215546Sopenharmony_ci int if_stack_depth; 127bf215546Sopenharmony_ci int if_stack_array_size; 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_ci /** 130bf215546Sopenharmony_ci * loop_stack contains the instruction pointers of the starts of loops which 131bf215546Sopenharmony_ci * must be patched (and popped) once the matching WHILE instruction is 132bf215546Sopenharmony_ci * encountered. 133bf215546Sopenharmony_ci */ 134bf215546Sopenharmony_ci int *loop_stack; 135bf215546Sopenharmony_ci /** 136bf215546Sopenharmony_ci * pre-gfx6, the BREAK and CONT instructions had to tell how many IF/ENDIF 137bf215546Sopenharmony_ci * blocks they were popping out of, to fix up the mask stack. This tracks 138bf215546Sopenharmony_ci * the IF/ENDIF nesting in each current nested loop level. 139bf215546Sopenharmony_ci */ 140bf215546Sopenharmony_ci int *if_depth_in_loop; 141bf215546Sopenharmony_ci int loop_stack_depth; 142bf215546Sopenharmony_ci int loop_stack_array_size; 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_ci struct brw_shader_reloc *relocs; 145bf215546Sopenharmony_ci int num_relocs; 146bf215546Sopenharmony_ci int reloc_array_size; 147bf215546Sopenharmony_ci}; 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_cistruct brw_label { 150bf215546Sopenharmony_ci int offset; 151bf215546Sopenharmony_ci int number; 152bf215546Sopenharmony_ci struct brw_label *next; 153bf215546Sopenharmony_ci}; 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_civoid brw_pop_insn_state( struct brw_codegen *p ); 156bf215546Sopenharmony_civoid brw_push_insn_state( struct brw_codegen *p ); 157bf215546Sopenharmony_ciunsigned brw_get_default_exec_size(struct brw_codegen *p); 158bf215546Sopenharmony_ciunsigned brw_get_default_group(struct brw_codegen *p); 159bf215546Sopenharmony_ciunsigned brw_get_default_access_mode(struct brw_codegen *p); 160bf215546Sopenharmony_cistruct tgl_swsb brw_get_default_swsb(struct brw_codegen *p); 161bf215546Sopenharmony_civoid brw_set_default_exec_size(struct brw_codegen *p, unsigned value); 162bf215546Sopenharmony_civoid brw_set_default_mask_control( struct brw_codegen *p, unsigned value ); 163bf215546Sopenharmony_civoid brw_set_default_saturate( struct brw_codegen *p, bool enable ); 164bf215546Sopenharmony_civoid brw_set_default_access_mode( struct brw_codegen *p, unsigned access_mode ); 165bf215546Sopenharmony_civoid brw_inst_set_compression(const struct intel_device_info *devinfo, 166bf215546Sopenharmony_ci brw_inst *inst, bool on); 167bf215546Sopenharmony_civoid brw_set_default_compression(struct brw_codegen *p, bool on); 168bf215546Sopenharmony_civoid brw_inst_set_group(const struct intel_device_info *devinfo, 169bf215546Sopenharmony_ci brw_inst *inst, unsigned group); 170bf215546Sopenharmony_civoid brw_set_default_group(struct brw_codegen *p, unsigned group); 171bf215546Sopenharmony_civoid brw_set_default_compression_control(struct brw_codegen *p, enum brw_compression c); 172bf215546Sopenharmony_civoid brw_set_default_predicate_control(struct brw_codegen *p, enum brw_predicate pc); 173bf215546Sopenharmony_civoid brw_set_default_predicate_inverse(struct brw_codegen *p, bool predicate_inverse); 174bf215546Sopenharmony_civoid brw_set_default_flag_reg(struct brw_codegen *p, int reg, int subreg); 175bf215546Sopenharmony_civoid brw_set_default_acc_write_control(struct brw_codegen *p, unsigned value); 176bf215546Sopenharmony_civoid brw_set_default_swsb(struct brw_codegen *p, struct tgl_swsb value); 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_civoid brw_init_codegen(const struct brw_isa_info *isa, 179bf215546Sopenharmony_ci struct brw_codegen *p, void *mem_ctx); 180bf215546Sopenharmony_cibool brw_has_jip(const struct intel_device_info *devinfo, enum opcode opcode); 181bf215546Sopenharmony_cibool brw_has_uip(const struct intel_device_info *devinfo, enum opcode opcode); 182bf215546Sopenharmony_ciconst struct brw_label *brw_find_label(const struct brw_label *root, int offset); 183bf215546Sopenharmony_civoid brw_create_label(struct brw_label **labels, int offset, void *mem_ctx); 184bf215546Sopenharmony_ciint brw_disassemble_inst(FILE *file, const struct brw_isa_info *isa, 185bf215546Sopenharmony_ci const struct brw_inst *inst, bool is_compacted, 186bf215546Sopenharmony_ci int offset, const struct brw_label *root_label); 187bf215546Sopenharmony_ciconst struct 188bf215546Sopenharmony_cibrw_label *brw_label_assembly(const struct brw_isa_info *isa, 189bf215546Sopenharmony_ci const void *assembly, int start, int end, 190bf215546Sopenharmony_ci void *mem_ctx); 191bf215546Sopenharmony_civoid brw_disassemble_with_labels(const struct brw_isa_info *isa, 192bf215546Sopenharmony_ci const void *assembly, int start, int end, FILE *out); 193bf215546Sopenharmony_civoid brw_disassemble(const struct brw_isa_info *isa, 194bf215546Sopenharmony_ci const void *assembly, int start, int end, 195bf215546Sopenharmony_ci const struct brw_label *root_label, FILE *out); 196bf215546Sopenharmony_ciconst struct brw_shader_reloc *brw_get_shader_relocs(struct brw_codegen *p, 197bf215546Sopenharmony_ci unsigned *num_relocs); 198bf215546Sopenharmony_ciconst unsigned *brw_get_program( struct brw_codegen *p, unsigned *sz ); 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_cibool brw_try_override_assembly(struct brw_codegen *p, int start_offset, 201bf215546Sopenharmony_ci const char *identifier); 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_civoid brw_realign(struct brw_codegen *p, unsigned align); 204bf215546Sopenharmony_ciint brw_append_data(struct brw_codegen *p, void *data, 205bf215546Sopenharmony_ci unsigned size, unsigned align); 206bf215546Sopenharmony_cibrw_inst *brw_next_insn(struct brw_codegen *p, unsigned opcode); 207bf215546Sopenharmony_civoid brw_add_reloc(struct brw_codegen *p, uint32_t id, 208bf215546Sopenharmony_ci enum brw_shader_reloc_type type, 209bf215546Sopenharmony_ci uint32_t offset, uint32_t delta); 210bf215546Sopenharmony_civoid brw_set_dest(struct brw_codegen *p, brw_inst *insn, struct brw_reg dest); 211bf215546Sopenharmony_civoid brw_set_src0(struct brw_codegen *p, brw_inst *insn, struct brw_reg reg); 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_civoid gfx6_resolve_implied_move(struct brw_codegen *p, 214bf215546Sopenharmony_ci struct brw_reg *src, 215bf215546Sopenharmony_ci unsigned msg_reg_nr); 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci/* Helpers for regular instructions: 218bf215546Sopenharmony_ci */ 219bf215546Sopenharmony_ci#define ALU1(OP) \ 220bf215546Sopenharmony_cibrw_inst *brw_##OP(struct brw_codegen *p, \ 221bf215546Sopenharmony_ci struct brw_reg dest, \ 222bf215546Sopenharmony_ci struct brw_reg src0); 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci#define ALU2(OP) \ 225bf215546Sopenharmony_cibrw_inst *brw_##OP(struct brw_codegen *p, \ 226bf215546Sopenharmony_ci struct brw_reg dest, \ 227bf215546Sopenharmony_ci struct brw_reg src0, \ 228bf215546Sopenharmony_ci struct brw_reg src1); 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_ci#define ALU3(OP) \ 231bf215546Sopenharmony_cibrw_inst *brw_##OP(struct brw_codegen *p, \ 232bf215546Sopenharmony_ci struct brw_reg dest, \ 233bf215546Sopenharmony_ci struct brw_reg src0, \ 234bf215546Sopenharmony_ci struct brw_reg src1, \ 235bf215546Sopenharmony_ci struct brw_reg src2); 236bf215546Sopenharmony_ci 237bf215546Sopenharmony_ciALU1(MOV) 238bf215546Sopenharmony_ciALU2(SEL) 239bf215546Sopenharmony_ciALU1(NOT) 240bf215546Sopenharmony_ciALU2(AND) 241bf215546Sopenharmony_ciALU2(OR) 242bf215546Sopenharmony_ciALU2(XOR) 243bf215546Sopenharmony_ciALU2(SHR) 244bf215546Sopenharmony_ciALU2(SHL) 245bf215546Sopenharmony_ciALU1(DIM) 246bf215546Sopenharmony_ciALU2(ASR) 247bf215546Sopenharmony_ciALU2(ROL) 248bf215546Sopenharmony_ciALU2(ROR) 249bf215546Sopenharmony_ciALU3(CSEL) 250bf215546Sopenharmony_ciALU1(F32TO16) 251bf215546Sopenharmony_ciALU1(F16TO32) 252bf215546Sopenharmony_ciALU2(ADD) 253bf215546Sopenharmony_ciALU3(ADD3) 254bf215546Sopenharmony_ciALU2(AVG) 255bf215546Sopenharmony_ciALU2(MUL) 256bf215546Sopenharmony_ciALU1(FRC) 257bf215546Sopenharmony_ciALU1(RNDD) 258bf215546Sopenharmony_ciALU1(RNDE) 259bf215546Sopenharmony_ciALU1(RNDU) 260bf215546Sopenharmony_ciALU1(RNDZ) 261bf215546Sopenharmony_ciALU2(MAC) 262bf215546Sopenharmony_ciALU2(MACH) 263bf215546Sopenharmony_ciALU1(LZD) 264bf215546Sopenharmony_ciALU2(DP4) 265bf215546Sopenharmony_ciALU2(DPH) 266bf215546Sopenharmony_ciALU2(DP3) 267bf215546Sopenharmony_ciALU2(DP2) 268bf215546Sopenharmony_ciALU3(DP4A) 269bf215546Sopenharmony_ciALU2(LINE) 270bf215546Sopenharmony_ciALU2(PLN) 271bf215546Sopenharmony_ciALU3(MAD) 272bf215546Sopenharmony_ciALU3(LRP) 273bf215546Sopenharmony_ciALU1(BFREV) 274bf215546Sopenharmony_ciALU3(BFE) 275bf215546Sopenharmony_ciALU2(BFI1) 276bf215546Sopenharmony_ciALU3(BFI2) 277bf215546Sopenharmony_ciALU1(FBH) 278bf215546Sopenharmony_ciALU1(FBL) 279bf215546Sopenharmony_ciALU1(CBIT) 280bf215546Sopenharmony_ciALU2(ADDC) 281bf215546Sopenharmony_ciALU2(SUBB) 282bf215546Sopenharmony_ci 283bf215546Sopenharmony_ci#undef ALU1 284bf215546Sopenharmony_ci#undef ALU2 285bf215546Sopenharmony_ci#undef ALU3 286bf215546Sopenharmony_ci 287bf215546Sopenharmony_ci 288bf215546Sopenharmony_ci/* Helpers for SEND instruction: 289bf215546Sopenharmony_ci */ 290bf215546Sopenharmony_ci 291bf215546Sopenharmony_ci/** 292bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified common 293bf215546Sopenharmony_ci * descriptor controls. 294bf215546Sopenharmony_ci */ 295bf215546Sopenharmony_cistatic inline uint32_t 296bf215546Sopenharmony_cibrw_message_desc(const struct intel_device_info *devinfo, 297bf215546Sopenharmony_ci unsigned msg_length, 298bf215546Sopenharmony_ci unsigned response_length, 299bf215546Sopenharmony_ci bool header_present) 300bf215546Sopenharmony_ci{ 301bf215546Sopenharmony_ci if (devinfo->ver >= 5) { 302bf215546Sopenharmony_ci return (SET_BITS(msg_length, 28, 25) | 303bf215546Sopenharmony_ci SET_BITS(response_length, 24, 20) | 304bf215546Sopenharmony_ci SET_BITS(header_present, 19, 19)); 305bf215546Sopenharmony_ci } else { 306bf215546Sopenharmony_ci return (SET_BITS(msg_length, 23, 20) | 307bf215546Sopenharmony_ci SET_BITS(response_length, 19, 16)); 308bf215546Sopenharmony_ci } 309bf215546Sopenharmony_ci} 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_cistatic inline unsigned 312bf215546Sopenharmony_cibrw_message_desc_mlen(const struct intel_device_info *devinfo, uint32_t desc) 313bf215546Sopenharmony_ci{ 314bf215546Sopenharmony_ci if (devinfo->ver >= 5) 315bf215546Sopenharmony_ci return GET_BITS(desc, 28, 25); 316bf215546Sopenharmony_ci else 317bf215546Sopenharmony_ci return GET_BITS(desc, 23, 20); 318bf215546Sopenharmony_ci} 319bf215546Sopenharmony_ci 320bf215546Sopenharmony_cistatic inline unsigned 321bf215546Sopenharmony_cibrw_message_desc_rlen(const struct intel_device_info *devinfo, uint32_t desc) 322bf215546Sopenharmony_ci{ 323bf215546Sopenharmony_ci if (devinfo->ver >= 5) 324bf215546Sopenharmony_ci return GET_BITS(desc, 24, 20); 325bf215546Sopenharmony_ci else 326bf215546Sopenharmony_ci return GET_BITS(desc, 19, 16); 327bf215546Sopenharmony_ci} 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_cistatic inline bool 330bf215546Sopenharmony_cibrw_message_desc_header_present(ASSERTED 331bf215546Sopenharmony_ci const struct intel_device_info *devinfo, 332bf215546Sopenharmony_ci uint32_t desc) 333bf215546Sopenharmony_ci{ 334bf215546Sopenharmony_ci assert(devinfo->ver >= 5); 335bf215546Sopenharmony_ci return GET_BITS(desc, 19, 19); 336bf215546Sopenharmony_ci} 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_cistatic inline unsigned 339bf215546Sopenharmony_cibrw_message_ex_desc(UNUSED const struct intel_device_info *devinfo, 340bf215546Sopenharmony_ci unsigned ex_msg_length) 341bf215546Sopenharmony_ci{ 342bf215546Sopenharmony_ci return SET_BITS(ex_msg_length, 9, 6); 343bf215546Sopenharmony_ci} 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_cistatic inline unsigned 346bf215546Sopenharmony_cibrw_message_ex_desc_ex_mlen(UNUSED const struct intel_device_info *devinfo, 347bf215546Sopenharmony_ci uint32_t ex_desc) 348bf215546Sopenharmony_ci{ 349bf215546Sopenharmony_ci return GET_BITS(ex_desc, 9, 6); 350bf215546Sopenharmony_ci} 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_cistatic inline uint32_t 353bf215546Sopenharmony_cibrw_urb_desc(const struct intel_device_info *devinfo, 354bf215546Sopenharmony_ci unsigned msg_type, 355bf215546Sopenharmony_ci bool per_slot_offset_present, 356bf215546Sopenharmony_ci bool channel_mask_present, 357bf215546Sopenharmony_ci unsigned global_offset) 358bf215546Sopenharmony_ci{ 359bf215546Sopenharmony_ci if (devinfo->ver >= 8) { 360bf215546Sopenharmony_ci return (SET_BITS(per_slot_offset_present, 17, 17) | 361bf215546Sopenharmony_ci SET_BITS(channel_mask_present, 15, 15) | 362bf215546Sopenharmony_ci SET_BITS(global_offset, 14, 4) | 363bf215546Sopenharmony_ci SET_BITS(msg_type, 3, 0)); 364bf215546Sopenharmony_ci } else if (devinfo->ver >= 7) { 365bf215546Sopenharmony_ci assert(!channel_mask_present); 366bf215546Sopenharmony_ci return (SET_BITS(per_slot_offset_present, 16, 16) | 367bf215546Sopenharmony_ci SET_BITS(global_offset, 13, 3) | 368bf215546Sopenharmony_ci SET_BITS(msg_type, 3, 0)); 369bf215546Sopenharmony_ci } else { 370bf215546Sopenharmony_ci unreachable("unhandled URB write generation"); 371bf215546Sopenharmony_ci } 372bf215546Sopenharmony_ci} 373bf215546Sopenharmony_ci 374bf215546Sopenharmony_cistatic inline uint32_t 375bf215546Sopenharmony_cibrw_urb_desc_msg_type(ASSERTED const struct intel_device_info *devinfo, 376bf215546Sopenharmony_ci uint32_t desc) 377bf215546Sopenharmony_ci{ 378bf215546Sopenharmony_ci assert(devinfo->ver >= 7); 379bf215546Sopenharmony_ci return GET_BITS(desc, 3, 0); 380bf215546Sopenharmony_ci} 381bf215546Sopenharmony_ci 382bf215546Sopenharmony_cistatic inline uint32_t 383bf215546Sopenharmony_cibrw_urb_fence_desc(const struct intel_device_info *devinfo) 384bf215546Sopenharmony_ci{ 385bf215546Sopenharmony_ci assert(devinfo->has_lsc); 386bf215546Sopenharmony_ci return brw_urb_desc(devinfo, GFX125_URB_OPCODE_FENCE, false, false, 0); 387bf215546Sopenharmony_ci} 388bf215546Sopenharmony_ci 389bf215546Sopenharmony_ci/** 390bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified sampler 391bf215546Sopenharmony_ci * function controls. 392bf215546Sopenharmony_ci */ 393bf215546Sopenharmony_cistatic inline uint32_t 394bf215546Sopenharmony_cibrw_sampler_desc(const struct intel_device_info *devinfo, 395bf215546Sopenharmony_ci unsigned binding_table_index, 396bf215546Sopenharmony_ci unsigned sampler, 397bf215546Sopenharmony_ci unsigned msg_type, 398bf215546Sopenharmony_ci unsigned simd_mode, 399bf215546Sopenharmony_ci unsigned return_format) 400bf215546Sopenharmony_ci{ 401bf215546Sopenharmony_ci const unsigned desc = (SET_BITS(binding_table_index, 7, 0) | 402bf215546Sopenharmony_ci SET_BITS(sampler, 11, 8)); 403bf215546Sopenharmony_ci 404bf215546Sopenharmony_ci /* From the CHV Bspec: Shared Functions - Message Descriptor - 405bf215546Sopenharmony_ci * Sampling Engine: 406bf215546Sopenharmony_ci * 407bf215546Sopenharmony_ci * SIMD Mode[2] 29 This field is the upper bit of the 3-bit 408bf215546Sopenharmony_ci * SIMD Mode field. 409bf215546Sopenharmony_ci */ 410bf215546Sopenharmony_ci if (devinfo->ver >= 8) 411bf215546Sopenharmony_ci return desc | SET_BITS(msg_type, 16, 12) | 412bf215546Sopenharmony_ci SET_BITS(simd_mode & 0x3, 18, 17) | 413bf215546Sopenharmony_ci SET_BITS(simd_mode >> 2, 29, 29) | 414bf215546Sopenharmony_ci SET_BITS(return_format, 30, 30); 415bf215546Sopenharmony_ci if (devinfo->ver >= 7) 416bf215546Sopenharmony_ci return (desc | SET_BITS(msg_type, 16, 12) | 417bf215546Sopenharmony_ci SET_BITS(simd_mode, 18, 17)); 418bf215546Sopenharmony_ci else if (devinfo->ver >= 5) 419bf215546Sopenharmony_ci return (desc | SET_BITS(msg_type, 15, 12) | 420bf215546Sopenharmony_ci SET_BITS(simd_mode, 17, 16)); 421bf215546Sopenharmony_ci else if (devinfo->verx10 >= 45) 422bf215546Sopenharmony_ci return desc | SET_BITS(msg_type, 15, 12); 423bf215546Sopenharmony_ci else 424bf215546Sopenharmony_ci return (desc | SET_BITS(return_format, 13, 12) | 425bf215546Sopenharmony_ci SET_BITS(msg_type, 15, 14)); 426bf215546Sopenharmony_ci} 427bf215546Sopenharmony_ci 428bf215546Sopenharmony_cistatic inline unsigned 429bf215546Sopenharmony_cibrw_sampler_desc_binding_table_index(UNUSED 430bf215546Sopenharmony_ci const struct intel_device_info *devinfo, 431bf215546Sopenharmony_ci uint32_t desc) 432bf215546Sopenharmony_ci{ 433bf215546Sopenharmony_ci return GET_BITS(desc, 7, 0); 434bf215546Sopenharmony_ci} 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_cistatic inline unsigned 437bf215546Sopenharmony_cibrw_sampler_desc_sampler(UNUSED const struct intel_device_info *devinfo, 438bf215546Sopenharmony_ci uint32_t desc) 439bf215546Sopenharmony_ci{ 440bf215546Sopenharmony_ci return GET_BITS(desc, 11, 8); 441bf215546Sopenharmony_ci} 442bf215546Sopenharmony_ci 443bf215546Sopenharmony_cistatic inline unsigned 444bf215546Sopenharmony_cibrw_sampler_desc_msg_type(const struct intel_device_info *devinfo, uint32_t desc) 445bf215546Sopenharmony_ci{ 446bf215546Sopenharmony_ci if (devinfo->ver >= 7) 447bf215546Sopenharmony_ci return GET_BITS(desc, 16, 12); 448bf215546Sopenharmony_ci else if (devinfo->verx10 >= 45) 449bf215546Sopenharmony_ci return GET_BITS(desc, 15, 12); 450bf215546Sopenharmony_ci else 451bf215546Sopenharmony_ci return GET_BITS(desc, 15, 14); 452bf215546Sopenharmony_ci} 453bf215546Sopenharmony_ci 454bf215546Sopenharmony_cistatic inline unsigned 455bf215546Sopenharmony_cibrw_sampler_desc_simd_mode(const struct intel_device_info *devinfo, 456bf215546Sopenharmony_ci uint32_t desc) 457bf215546Sopenharmony_ci{ 458bf215546Sopenharmony_ci assert(devinfo->ver >= 5); 459bf215546Sopenharmony_ci if (devinfo->ver >= 8) 460bf215546Sopenharmony_ci return GET_BITS(desc, 18, 17) | GET_BITS(desc, 29, 29) << 2; 461bf215546Sopenharmony_ci else if (devinfo->ver >= 7) 462bf215546Sopenharmony_ci return GET_BITS(desc, 18, 17); 463bf215546Sopenharmony_ci else 464bf215546Sopenharmony_ci return GET_BITS(desc, 17, 16); 465bf215546Sopenharmony_ci} 466bf215546Sopenharmony_ci 467bf215546Sopenharmony_cistatic inline unsigned 468bf215546Sopenharmony_cibrw_sampler_desc_return_format(ASSERTED const struct intel_device_info *devinfo, 469bf215546Sopenharmony_ci uint32_t desc) 470bf215546Sopenharmony_ci{ 471bf215546Sopenharmony_ci assert(devinfo->verx10 == 40 || devinfo->ver >= 8); 472bf215546Sopenharmony_ci if (devinfo->ver >= 8) 473bf215546Sopenharmony_ci return GET_BITS(desc, 30, 30); 474bf215546Sopenharmony_ci else 475bf215546Sopenharmony_ci return GET_BITS(desc, 13, 12); 476bf215546Sopenharmony_ci} 477bf215546Sopenharmony_ci 478bf215546Sopenharmony_ci/** 479bf215546Sopenharmony_ci * Construct a message descriptor for the dataport 480bf215546Sopenharmony_ci */ 481bf215546Sopenharmony_cistatic inline uint32_t 482bf215546Sopenharmony_cibrw_dp_desc(const struct intel_device_info *devinfo, 483bf215546Sopenharmony_ci unsigned binding_table_index, 484bf215546Sopenharmony_ci unsigned msg_type, 485bf215546Sopenharmony_ci unsigned msg_control) 486bf215546Sopenharmony_ci{ 487bf215546Sopenharmony_ci /* Prior to gfx6, things are too inconsistent; use the dp_read/write_desc 488bf215546Sopenharmony_ci * helpers instead. 489bf215546Sopenharmony_ci */ 490bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 491bf215546Sopenharmony_ci const unsigned desc = SET_BITS(binding_table_index, 7, 0); 492bf215546Sopenharmony_ci if (devinfo->ver >= 8) { 493bf215546Sopenharmony_ci return (desc | SET_BITS(msg_control, 13, 8) | 494bf215546Sopenharmony_ci SET_BITS(msg_type, 18, 14)); 495bf215546Sopenharmony_ci } else if (devinfo->ver >= 7) { 496bf215546Sopenharmony_ci return (desc | SET_BITS(msg_control, 13, 8) | 497bf215546Sopenharmony_ci SET_BITS(msg_type, 17, 14)); 498bf215546Sopenharmony_ci } else { 499bf215546Sopenharmony_ci return (desc | SET_BITS(msg_control, 12, 8) | 500bf215546Sopenharmony_ci SET_BITS(msg_type, 16, 13)); 501bf215546Sopenharmony_ci } 502bf215546Sopenharmony_ci} 503bf215546Sopenharmony_ci 504bf215546Sopenharmony_cistatic inline unsigned 505bf215546Sopenharmony_cibrw_dp_desc_binding_table_index(UNUSED const struct intel_device_info *devinfo, 506bf215546Sopenharmony_ci uint32_t desc) 507bf215546Sopenharmony_ci{ 508bf215546Sopenharmony_ci return GET_BITS(desc, 7, 0); 509bf215546Sopenharmony_ci} 510bf215546Sopenharmony_ci 511bf215546Sopenharmony_cistatic inline unsigned 512bf215546Sopenharmony_cibrw_dp_desc_msg_type(const struct intel_device_info *devinfo, uint32_t desc) 513bf215546Sopenharmony_ci{ 514bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 515bf215546Sopenharmony_ci if (devinfo->ver >= 8) 516bf215546Sopenharmony_ci return GET_BITS(desc, 18, 14); 517bf215546Sopenharmony_ci else if (devinfo->ver >= 7) 518bf215546Sopenharmony_ci return GET_BITS(desc, 17, 14); 519bf215546Sopenharmony_ci else 520bf215546Sopenharmony_ci return GET_BITS(desc, 16, 13); 521bf215546Sopenharmony_ci} 522bf215546Sopenharmony_ci 523bf215546Sopenharmony_cistatic inline unsigned 524bf215546Sopenharmony_cibrw_dp_desc_msg_control(const struct intel_device_info *devinfo, uint32_t desc) 525bf215546Sopenharmony_ci{ 526bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 527bf215546Sopenharmony_ci if (devinfo->ver >= 7) 528bf215546Sopenharmony_ci return GET_BITS(desc, 13, 8); 529bf215546Sopenharmony_ci else 530bf215546Sopenharmony_ci return GET_BITS(desc, 12, 8); 531bf215546Sopenharmony_ci} 532bf215546Sopenharmony_ci 533bf215546Sopenharmony_ci/** 534bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified dataport read 535bf215546Sopenharmony_ci * function controls. 536bf215546Sopenharmony_ci */ 537bf215546Sopenharmony_cistatic inline uint32_t 538bf215546Sopenharmony_cibrw_dp_read_desc(const struct intel_device_info *devinfo, 539bf215546Sopenharmony_ci unsigned binding_table_index, 540bf215546Sopenharmony_ci unsigned msg_control, 541bf215546Sopenharmony_ci unsigned msg_type, 542bf215546Sopenharmony_ci unsigned target_cache) 543bf215546Sopenharmony_ci{ 544bf215546Sopenharmony_ci if (devinfo->ver >= 6) 545bf215546Sopenharmony_ci return brw_dp_desc(devinfo, binding_table_index, msg_type, msg_control); 546bf215546Sopenharmony_ci else if (devinfo->verx10 >= 45) 547bf215546Sopenharmony_ci return (SET_BITS(binding_table_index, 7, 0) | 548bf215546Sopenharmony_ci SET_BITS(msg_control, 10, 8) | 549bf215546Sopenharmony_ci SET_BITS(msg_type, 13, 11) | 550bf215546Sopenharmony_ci SET_BITS(target_cache, 15, 14)); 551bf215546Sopenharmony_ci else 552bf215546Sopenharmony_ci return (SET_BITS(binding_table_index, 7, 0) | 553bf215546Sopenharmony_ci SET_BITS(msg_control, 11, 8) | 554bf215546Sopenharmony_ci SET_BITS(msg_type, 13, 12) | 555bf215546Sopenharmony_ci SET_BITS(target_cache, 15, 14)); 556bf215546Sopenharmony_ci} 557bf215546Sopenharmony_ci 558bf215546Sopenharmony_cistatic inline unsigned 559bf215546Sopenharmony_cibrw_dp_read_desc_msg_type(const struct intel_device_info *devinfo, 560bf215546Sopenharmony_ci uint32_t desc) 561bf215546Sopenharmony_ci{ 562bf215546Sopenharmony_ci if (devinfo->ver >= 6) 563bf215546Sopenharmony_ci return brw_dp_desc_msg_type(devinfo, desc); 564bf215546Sopenharmony_ci else if (devinfo->verx10 >= 45) 565bf215546Sopenharmony_ci return GET_BITS(desc, 13, 11); 566bf215546Sopenharmony_ci else 567bf215546Sopenharmony_ci return GET_BITS(desc, 13, 12); 568bf215546Sopenharmony_ci} 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_cistatic inline unsigned 571bf215546Sopenharmony_cibrw_dp_read_desc_msg_control(const struct intel_device_info *devinfo, 572bf215546Sopenharmony_ci uint32_t desc) 573bf215546Sopenharmony_ci{ 574bf215546Sopenharmony_ci if (devinfo->ver >= 6) 575bf215546Sopenharmony_ci return brw_dp_desc_msg_control(devinfo, desc); 576bf215546Sopenharmony_ci else if (devinfo->verx10 >= 45) 577bf215546Sopenharmony_ci return GET_BITS(desc, 10, 8); 578bf215546Sopenharmony_ci else 579bf215546Sopenharmony_ci return GET_BITS(desc, 11, 8); 580bf215546Sopenharmony_ci} 581bf215546Sopenharmony_ci 582bf215546Sopenharmony_ci/** 583bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified dataport write 584bf215546Sopenharmony_ci * function controls. 585bf215546Sopenharmony_ci */ 586bf215546Sopenharmony_cistatic inline uint32_t 587bf215546Sopenharmony_cibrw_dp_write_desc(const struct intel_device_info *devinfo, 588bf215546Sopenharmony_ci unsigned binding_table_index, 589bf215546Sopenharmony_ci unsigned msg_control, 590bf215546Sopenharmony_ci unsigned msg_type, 591bf215546Sopenharmony_ci unsigned send_commit_msg) 592bf215546Sopenharmony_ci{ 593bf215546Sopenharmony_ci assert(devinfo->ver <= 6 || !send_commit_msg); 594bf215546Sopenharmony_ci if (devinfo->ver >= 6) { 595bf215546Sopenharmony_ci return brw_dp_desc(devinfo, binding_table_index, msg_type, msg_control) | 596bf215546Sopenharmony_ci SET_BITS(send_commit_msg, 17, 17); 597bf215546Sopenharmony_ci } else { 598bf215546Sopenharmony_ci return (SET_BITS(binding_table_index, 7, 0) | 599bf215546Sopenharmony_ci SET_BITS(msg_control, 11, 8) | 600bf215546Sopenharmony_ci SET_BITS(msg_type, 14, 12) | 601bf215546Sopenharmony_ci SET_BITS(send_commit_msg, 15, 15)); 602bf215546Sopenharmony_ci } 603bf215546Sopenharmony_ci} 604bf215546Sopenharmony_ci 605bf215546Sopenharmony_cistatic inline unsigned 606bf215546Sopenharmony_cibrw_dp_write_desc_msg_type(const struct intel_device_info *devinfo, 607bf215546Sopenharmony_ci uint32_t desc) 608bf215546Sopenharmony_ci{ 609bf215546Sopenharmony_ci if (devinfo->ver >= 6) 610bf215546Sopenharmony_ci return brw_dp_desc_msg_type(devinfo, desc); 611bf215546Sopenharmony_ci else 612bf215546Sopenharmony_ci return GET_BITS(desc, 14, 12); 613bf215546Sopenharmony_ci} 614bf215546Sopenharmony_ci 615bf215546Sopenharmony_cistatic inline unsigned 616bf215546Sopenharmony_cibrw_dp_write_desc_msg_control(const struct intel_device_info *devinfo, 617bf215546Sopenharmony_ci uint32_t desc) 618bf215546Sopenharmony_ci{ 619bf215546Sopenharmony_ci if (devinfo->ver >= 6) 620bf215546Sopenharmony_ci return brw_dp_desc_msg_control(devinfo, desc); 621bf215546Sopenharmony_ci else 622bf215546Sopenharmony_ci return GET_BITS(desc, 11, 8); 623bf215546Sopenharmony_ci} 624bf215546Sopenharmony_ci 625bf215546Sopenharmony_cistatic inline bool 626bf215546Sopenharmony_cibrw_dp_write_desc_write_commit(const struct intel_device_info *devinfo, 627bf215546Sopenharmony_ci uint32_t desc) 628bf215546Sopenharmony_ci{ 629bf215546Sopenharmony_ci assert(devinfo->ver <= 6); 630bf215546Sopenharmony_ci if (devinfo->ver >= 6) 631bf215546Sopenharmony_ci return GET_BITS(desc, 17, 17); 632bf215546Sopenharmony_ci else 633bf215546Sopenharmony_ci return GET_BITS(desc, 15, 15); 634bf215546Sopenharmony_ci} 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci/** 637bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified dataport 638bf215546Sopenharmony_ci * surface function controls. 639bf215546Sopenharmony_ci */ 640bf215546Sopenharmony_cistatic inline uint32_t 641bf215546Sopenharmony_cibrw_dp_surface_desc(const struct intel_device_info *devinfo, 642bf215546Sopenharmony_ci unsigned msg_type, 643bf215546Sopenharmony_ci unsigned msg_control) 644bf215546Sopenharmony_ci{ 645bf215546Sopenharmony_ci assert(devinfo->ver >= 7); 646bf215546Sopenharmony_ci /* We'll OR in the binding table index later */ 647bf215546Sopenharmony_ci return brw_dp_desc(devinfo, 0, msg_type, msg_control); 648bf215546Sopenharmony_ci} 649bf215546Sopenharmony_ci 650bf215546Sopenharmony_cistatic inline uint32_t 651bf215546Sopenharmony_cibrw_dp_untyped_atomic_desc(const struct intel_device_info *devinfo, 652bf215546Sopenharmony_ci unsigned exec_size, /**< 0 for SIMD4x2 */ 653bf215546Sopenharmony_ci unsigned atomic_op, 654bf215546Sopenharmony_ci bool response_expected) 655bf215546Sopenharmony_ci{ 656bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 657bf215546Sopenharmony_ci 658bf215546Sopenharmony_ci unsigned msg_type; 659bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 660bf215546Sopenharmony_ci if (exec_size > 0) { 661bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP; 662bf215546Sopenharmony_ci } else { 663bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2; 664bf215546Sopenharmony_ci } 665bf215546Sopenharmony_ci } else { 666bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_DC_UNTYPED_ATOMIC_OP; 667bf215546Sopenharmony_ci } 668bf215546Sopenharmony_ci 669bf215546Sopenharmony_ci const unsigned msg_control = 670bf215546Sopenharmony_ci SET_BITS(atomic_op, 3, 0) | 671bf215546Sopenharmony_ci SET_BITS(0 < exec_size && exec_size <= 8, 4, 4) | 672bf215546Sopenharmony_ci SET_BITS(response_expected, 5, 5); 673bf215546Sopenharmony_ci 674bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 675bf215546Sopenharmony_ci} 676bf215546Sopenharmony_ci 677bf215546Sopenharmony_cistatic inline uint32_t 678bf215546Sopenharmony_cibrw_dp_untyped_atomic_float_desc(const struct intel_device_info *devinfo, 679bf215546Sopenharmony_ci unsigned exec_size, 680bf215546Sopenharmony_ci unsigned atomic_op, 681bf215546Sopenharmony_ci bool response_expected) 682bf215546Sopenharmony_ci{ 683bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 684bf215546Sopenharmony_ci assert(devinfo->ver >= 9); 685bf215546Sopenharmony_ci 686bf215546Sopenharmony_ci assert(exec_size > 0); 687bf215546Sopenharmony_ci const unsigned msg_type = GFX9_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_FLOAT_OP; 688bf215546Sopenharmony_ci 689bf215546Sopenharmony_ci const unsigned msg_control = 690bf215546Sopenharmony_ci SET_BITS(atomic_op, 1, 0) | 691bf215546Sopenharmony_ci SET_BITS(exec_size <= 8, 4, 4) | 692bf215546Sopenharmony_ci SET_BITS(response_expected, 5, 5); 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 695bf215546Sopenharmony_ci} 696bf215546Sopenharmony_ci 697bf215546Sopenharmony_cistatic inline unsigned 698bf215546Sopenharmony_cibrw_mdc_cmask(unsigned num_channels) 699bf215546Sopenharmony_ci{ 700bf215546Sopenharmony_ci /* See also MDC_CMASK in the SKL PRM Vol 2d. */ 701bf215546Sopenharmony_ci return 0xf & (0xf << num_channels); 702bf215546Sopenharmony_ci} 703bf215546Sopenharmony_ci 704bf215546Sopenharmony_cistatic inline unsigned 705bf215546Sopenharmony_cilsc_cmask(unsigned num_channels) 706bf215546Sopenharmony_ci{ 707bf215546Sopenharmony_ci assert(num_channels > 0 && num_channels <= 4); 708bf215546Sopenharmony_ci return BITSET_MASK(num_channels); 709bf215546Sopenharmony_ci} 710bf215546Sopenharmony_ci 711bf215546Sopenharmony_cistatic inline uint32_t 712bf215546Sopenharmony_cibrw_dp_untyped_surface_rw_desc(const struct intel_device_info *devinfo, 713bf215546Sopenharmony_ci unsigned exec_size, /**< 0 for SIMD4x2 */ 714bf215546Sopenharmony_ci unsigned num_channels, 715bf215546Sopenharmony_ci bool write) 716bf215546Sopenharmony_ci{ 717bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 718bf215546Sopenharmony_ci 719bf215546Sopenharmony_ci unsigned msg_type; 720bf215546Sopenharmony_ci if (write) { 721bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 722bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE; 723bf215546Sopenharmony_ci } else { 724bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_DC_UNTYPED_SURFACE_WRITE; 725bf215546Sopenharmony_ci } 726bf215546Sopenharmony_ci } else { 727bf215546Sopenharmony_ci /* Read */ 728bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 729bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ; 730bf215546Sopenharmony_ci } else { 731bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_DC_UNTYPED_SURFACE_READ; 732bf215546Sopenharmony_ci } 733bf215546Sopenharmony_ci } 734bf215546Sopenharmony_ci 735bf215546Sopenharmony_ci /* SIMD4x2 is only valid for read messages on IVB; use SIMD8 instead */ 736bf215546Sopenharmony_ci if (write && devinfo->verx10 == 70 && exec_size == 0) 737bf215546Sopenharmony_ci exec_size = 8; 738bf215546Sopenharmony_ci 739bf215546Sopenharmony_ci /* See also MDC_SM3 in the SKL PRM Vol 2d. */ 740bf215546Sopenharmony_ci const unsigned simd_mode = exec_size == 0 ? 0 : /* SIMD4x2 */ 741bf215546Sopenharmony_ci exec_size <= 8 ? 2 : 1; 742bf215546Sopenharmony_ci 743bf215546Sopenharmony_ci const unsigned msg_control = 744bf215546Sopenharmony_ci SET_BITS(brw_mdc_cmask(num_channels), 3, 0) | 745bf215546Sopenharmony_ci SET_BITS(simd_mode, 5, 4); 746bf215546Sopenharmony_ci 747bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 748bf215546Sopenharmony_ci} 749bf215546Sopenharmony_ci 750bf215546Sopenharmony_cistatic inline unsigned 751bf215546Sopenharmony_cibrw_mdc_ds(unsigned bit_size) 752bf215546Sopenharmony_ci{ 753bf215546Sopenharmony_ci switch (bit_size) { 754bf215546Sopenharmony_ci case 8: 755bf215546Sopenharmony_ci return GFX7_BYTE_SCATTERED_DATA_ELEMENT_BYTE; 756bf215546Sopenharmony_ci case 16: 757bf215546Sopenharmony_ci return GFX7_BYTE_SCATTERED_DATA_ELEMENT_WORD; 758bf215546Sopenharmony_ci case 32: 759bf215546Sopenharmony_ci return GFX7_BYTE_SCATTERED_DATA_ELEMENT_DWORD; 760bf215546Sopenharmony_ci default: 761bf215546Sopenharmony_ci unreachable("Unsupported bit_size for byte scattered messages"); 762bf215546Sopenharmony_ci } 763bf215546Sopenharmony_ci} 764bf215546Sopenharmony_ci 765bf215546Sopenharmony_cistatic inline uint32_t 766bf215546Sopenharmony_cibrw_dp_byte_scattered_rw_desc(const struct intel_device_info *devinfo, 767bf215546Sopenharmony_ci unsigned exec_size, 768bf215546Sopenharmony_ci unsigned bit_size, 769bf215546Sopenharmony_ci bool write) 770bf215546Sopenharmony_ci{ 771bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 772bf215546Sopenharmony_ci 773bf215546Sopenharmony_ci assert(devinfo->verx10 >= 75); 774bf215546Sopenharmony_ci const unsigned msg_type = 775bf215546Sopenharmony_ci write ? HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_WRITE : 776bf215546Sopenharmony_ci HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_READ; 777bf215546Sopenharmony_ci 778bf215546Sopenharmony_ci assert(exec_size > 0); 779bf215546Sopenharmony_ci const unsigned msg_control = 780bf215546Sopenharmony_ci SET_BITS(exec_size == 16, 0, 0) | 781bf215546Sopenharmony_ci SET_BITS(brw_mdc_ds(bit_size), 3, 2); 782bf215546Sopenharmony_ci 783bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 784bf215546Sopenharmony_ci} 785bf215546Sopenharmony_ci 786bf215546Sopenharmony_cistatic inline uint32_t 787bf215546Sopenharmony_cibrw_dp_dword_scattered_rw_desc(const struct intel_device_info *devinfo, 788bf215546Sopenharmony_ci unsigned exec_size, 789bf215546Sopenharmony_ci bool write) 790bf215546Sopenharmony_ci{ 791bf215546Sopenharmony_ci assert(exec_size == 8 || exec_size == 16); 792bf215546Sopenharmony_ci 793bf215546Sopenharmony_ci unsigned msg_type; 794bf215546Sopenharmony_ci if (write) { 795bf215546Sopenharmony_ci if (devinfo->ver >= 6) { 796bf215546Sopenharmony_ci msg_type = GFX6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE; 797bf215546Sopenharmony_ci } else { 798bf215546Sopenharmony_ci msg_type = BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE; 799bf215546Sopenharmony_ci } 800bf215546Sopenharmony_ci } else { 801bf215546Sopenharmony_ci if (devinfo->ver >= 7) { 802bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_DC_DWORD_SCATTERED_READ; 803bf215546Sopenharmony_ci } else if (devinfo->verx10 >= 45) { 804bf215546Sopenharmony_ci msg_type = G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ; 805bf215546Sopenharmony_ci } else { 806bf215546Sopenharmony_ci msg_type = BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ; 807bf215546Sopenharmony_ci } 808bf215546Sopenharmony_ci } 809bf215546Sopenharmony_ci 810bf215546Sopenharmony_ci const unsigned msg_control = 811bf215546Sopenharmony_ci SET_BITS(1, 1, 1) | /* Legacy SIMD Mode */ 812bf215546Sopenharmony_ci SET_BITS(exec_size == 16, 0, 0); 813bf215546Sopenharmony_ci 814bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 815bf215546Sopenharmony_ci} 816bf215546Sopenharmony_ci 817bf215546Sopenharmony_cistatic inline uint32_t 818bf215546Sopenharmony_cibrw_dp_oword_block_rw_desc(const struct intel_device_info *devinfo, 819bf215546Sopenharmony_ci bool align_16B, 820bf215546Sopenharmony_ci unsigned num_dwords, 821bf215546Sopenharmony_ci bool write) 822bf215546Sopenharmony_ci{ 823bf215546Sopenharmony_ci /* Writes can only have addresses aligned by OWORDs (16 Bytes). */ 824bf215546Sopenharmony_ci assert(!write || align_16B); 825bf215546Sopenharmony_ci 826bf215546Sopenharmony_ci const unsigned msg_type = 827bf215546Sopenharmony_ci write ? GFX7_DATAPORT_DC_OWORD_BLOCK_WRITE : 828bf215546Sopenharmony_ci align_16B ? GFX7_DATAPORT_DC_OWORD_BLOCK_READ : 829bf215546Sopenharmony_ci GFX7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ; 830bf215546Sopenharmony_ci 831bf215546Sopenharmony_ci const unsigned msg_control = 832bf215546Sopenharmony_ci SET_BITS(BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_dwords), 2, 0); 833bf215546Sopenharmony_ci 834bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 835bf215546Sopenharmony_ci} 836bf215546Sopenharmony_ci 837bf215546Sopenharmony_cistatic inline uint32_t 838bf215546Sopenharmony_cibrw_dp_a64_untyped_surface_rw_desc(const struct intel_device_info *devinfo, 839bf215546Sopenharmony_ci unsigned exec_size, /**< 0 for SIMD4x2 */ 840bf215546Sopenharmony_ci unsigned num_channels, 841bf215546Sopenharmony_ci bool write) 842bf215546Sopenharmony_ci{ 843bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 844bf215546Sopenharmony_ci assert(devinfo->ver >= 8); 845bf215546Sopenharmony_ci 846bf215546Sopenharmony_ci unsigned msg_type = 847bf215546Sopenharmony_ci write ? GFX8_DATAPORT_DC_PORT1_A64_UNTYPED_SURFACE_WRITE : 848bf215546Sopenharmony_ci GFX8_DATAPORT_DC_PORT1_A64_UNTYPED_SURFACE_READ; 849bf215546Sopenharmony_ci 850bf215546Sopenharmony_ci /* See also MDC_SM3 in the SKL PRM Vol 2d. */ 851bf215546Sopenharmony_ci const unsigned simd_mode = exec_size == 0 ? 0 : /* SIMD4x2 */ 852bf215546Sopenharmony_ci exec_size <= 8 ? 2 : 1; 853bf215546Sopenharmony_ci 854bf215546Sopenharmony_ci const unsigned msg_control = 855bf215546Sopenharmony_ci SET_BITS(brw_mdc_cmask(num_channels), 3, 0) | 856bf215546Sopenharmony_ci SET_BITS(simd_mode, 5, 4); 857bf215546Sopenharmony_ci 858bf215546Sopenharmony_ci return brw_dp_desc(devinfo, GFX8_BTI_STATELESS_NON_COHERENT, 859bf215546Sopenharmony_ci msg_type, msg_control); 860bf215546Sopenharmony_ci} 861bf215546Sopenharmony_ci 862bf215546Sopenharmony_cistatic inline uint32_t 863bf215546Sopenharmony_cibrw_dp_a64_oword_block_rw_desc(const struct intel_device_info *devinfo, 864bf215546Sopenharmony_ci bool align_16B, 865bf215546Sopenharmony_ci unsigned num_dwords, 866bf215546Sopenharmony_ci bool write) 867bf215546Sopenharmony_ci{ 868bf215546Sopenharmony_ci /* Writes can only have addresses aligned by OWORDs (16 Bytes). */ 869bf215546Sopenharmony_ci assert(!write || align_16B); 870bf215546Sopenharmony_ci 871bf215546Sopenharmony_ci unsigned msg_type = 872bf215546Sopenharmony_ci write ? GFX9_DATAPORT_DC_PORT1_A64_OWORD_BLOCK_WRITE : 873bf215546Sopenharmony_ci GFX9_DATAPORT_DC_PORT1_A64_OWORD_BLOCK_READ; 874bf215546Sopenharmony_ci 875bf215546Sopenharmony_ci unsigned msg_control = 876bf215546Sopenharmony_ci SET_BITS(!align_16B, 4, 3) | 877bf215546Sopenharmony_ci SET_BITS(BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_dwords), 2, 0); 878bf215546Sopenharmony_ci 879bf215546Sopenharmony_ci return brw_dp_desc(devinfo, GFX8_BTI_STATELESS_NON_COHERENT, 880bf215546Sopenharmony_ci msg_type, msg_control); 881bf215546Sopenharmony_ci} 882bf215546Sopenharmony_ci 883bf215546Sopenharmony_ci/** 884bf215546Sopenharmony_ci * Calculate the data size (see MDC_A64_DS in the "Structures" volume of the 885bf215546Sopenharmony_ci * Skylake PRM). 886bf215546Sopenharmony_ci */ 887bf215546Sopenharmony_cistatic inline uint32_t 888bf215546Sopenharmony_cibrw_mdc_a64_ds(unsigned elems) 889bf215546Sopenharmony_ci{ 890bf215546Sopenharmony_ci switch (elems) { 891bf215546Sopenharmony_ci case 1: return 0; 892bf215546Sopenharmony_ci case 2: return 1; 893bf215546Sopenharmony_ci case 4: return 2; 894bf215546Sopenharmony_ci case 8: return 3; 895bf215546Sopenharmony_ci default: 896bf215546Sopenharmony_ci unreachable("Unsupported elmeent count for A64 scattered message"); 897bf215546Sopenharmony_ci } 898bf215546Sopenharmony_ci} 899bf215546Sopenharmony_ci 900bf215546Sopenharmony_cistatic inline uint32_t 901bf215546Sopenharmony_cibrw_dp_a64_byte_scattered_rw_desc(const struct intel_device_info *devinfo, 902bf215546Sopenharmony_ci unsigned exec_size, /**< 0 for SIMD4x2 */ 903bf215546Sopenharmony_ci unsigned bit_size, 904bf215546Sopenharmony_ci bool write) 905bf215546Sopenharmony_ci{ 906bf215546Sopenharmony_ci assert(exec_size <= 8 || exec_size == 16); 907bf215546Sopenharmony_ci assert(devinfo->ver >= 8); 908bf215546Sopenharmony_ci 909bf215546Sopenharmony_ci unsigned msg_type = 910bf215546Sopenharmony_ci write ? GFX8_DATAPORT_DC_PORT1_A64_SCATTERED_WRITE : 911bf215546Sopenharmony_ci GFX9_DATAPORT_DC_PORT1_A64_SCATTERED_READ; 912bf215546Sopenharmony_ci 913bf215546Sopenharmony_ci const unsigned msg_control = 914bf215546Sopenharmony_ci SET_BITS(GFX8_A64_SCATTERED_SUBTYPE_BYTE, 1, 0) | 915bf215546Sopenharmony_ci SET_BITS(brw_mdc_a64_ds(bit_size / 8), 3, 2) | 916bf215546Sopenharmony_ci SET_BITS(exec_size == 16, 4, 4); 917bf215546Sopenharmony_ci 918bf215546Sopenharmony_ci return brw_dp_desc(devinfo, GFX8_BTI_STATELESS_NON_COHERENT, 919bf215546Sopenharmony_ci msg_type, msg_control); 920bf215546Sopenharmony_ci} 921bf215546Sopenharmony_ci 922bf215546Sopenharmony_cistatic inline uint32_t 923bf215546Sopenharmony_cibrw_dp_a64_untyped_atomic_desc(const struct intel_device_info *devinfo, 924bf215546Sopenharmony_ci ASSERTED unsigned exec_size, /**< 0 for SIMD4x2 */ 925bf215546Sopenharmony_ci unsigned bit_size, 926bf215546Sopenharmony_ci unsigned atomic_op, 927bf215546Sopenharmony_ci bool response_expected) 928bf215546Sopenharmony_ci{ 929bf215546Sopenharmony_ci assert(exec_size == 8); 930bf215546Sopenharmony_ci assert(devinfo->ver >= 8); 931bf215546Sopenharmony_ci assert(bit_size == 16 || bit_size == 32 || bit_size == 64); 932bf215546Sopenharmony_ci assert(devinfo->ver >= 12 || bit_size >= 32); 933bf215546Sopenharmony_ci 934bf215546Sopenharmony_ci const unsigned msg_type = bit_size == 16 ? 935bf215546Sopenharmony_ci GFX12_DATAPORT_DC_PORT1_A64_UNTYPED_ATOMIC_HALF_INT_OP : 936bf215546Sopenharmony_ci GFX8_DATAPORT_DC_PORT1_A64_UNTYPED_ATOMIC_OP; 937bf215546Sopenharmony_ci 938bf215546Sopenharmony_ci const unsigned msg_control = 939bf215546Sopenharmony_ci SET_BITS(atomic_op, 3, 0) | 940bf215546Sopenharmony_ci SET_BITS(bit_size == 64, 4, 4) | 941bf215546Sopenharmony_ci SET_BITS(response_expected, 5, 5); 942bf215546Sopenharmony_ci 943bf215546Sopenharmony_ci return brw_dp_desc(devinfo, GFX8_BTI_STATELESS_NON_COHERENT, 944bf215546Sopenharmony_ci msg_type, msg_control); 945bf215546Sopenharmony_ci} 946bf215546Sopenharmony_ci 947bf215546Sopenharmony_cistatic inline uint32_t 948bf215546Sopenharmony_cibrw_dp_a64_untyped_atomic_float_desc(const struct intel_device_info *devinfo, 949bf215546Sopenharmony_ci ASSERTED unsigned exec_size, 950bf215546Sopenharmony_ci unsigned bit_size, 951bf215546Sopenharmony_ci unsigned atomic_op, 952bf215546Sopenharmony_ci bool response_expected) 953bf215546Sopenharmony_ci{ 954bf215546Sopenharmony_ci assert(exec_size == 8); 955bf215546Sopenharmony_ci assert(devinfo->ver >= 9); 956bf215546Sopenharmony_ci assert(bit_size == 16 || bit_size == 32); 957bf215546Sopenharmony_ci assert(devinfo->ver >= 12 || bit_size == 32); 958bf215546Sopenharmony_ci 959bf215546Sopenharmony_ci assert(exec_size > 0); 960bf215546Sopenharmony_ci const unsigned msg_type = bit_size == 32 ? 961bf215546Sopenharmony_ci GFX9_DATAPORT_DC_PORT1_A64_UNTYPED_ATOMIC_FLOAT_OP : 962bf215546Sopenharmony_ci GFX12_DATAPORT_DC_PORT1_A64_UNTYPED_ATOMIC_HALF_FLOAT_OP; 963bf215546Sopenharmony_ci 964bf215546Sopenharmony_ci const unsigned msg_control = 965bf215546Sopenharmony_ci SET_BITS(atomic_op, 1, 0) | 966bf215546Sopenharmony_ci SET_BITS(response_expected, 5, 5); 967bf215546Sopenharmony_ci 968bf215546Sopenharmony_ci return brw_dp_desc(devinfo, GFX8_BTI_STATELESS_NON_COHERENT, 969bf215546Sopenharmony_ci msg_type, msg_control); 970bf215546Sopenharmony_ci} 971bf215546Sopenharmony_ci 972bf215546Sopenharmony_cistatic inline uint32_t 973bf215546Sopenharmony_cibrw_dp_typed_atomic_desc(const struct intel_device_info *devinfo, 974bf215546Sopenharmony_ci unsigned exec_size, 975bf215546Sopenharmony_ci unsigned exec_group, 976bf215546Sopenharmony_ci unsigned atomic_op, 977bf215546Sopenharmony_ci bool response_expected) 978bf215546Sopenharmony_ci{ 979bf215546Sopenharmony_ci assert(exec_size > 0 || exec_group == 0); 980bf215546Sopenharmony_ci assert(exec_group % 8 == 0); 981bf215546Sopenharmony_ci 982bf215546Sopenharmony_ci unsigned msg_type; 983bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 984bf215546Sopenharmony_ci if (exec_size == 0) { 985bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2; 986bf215546Sopenharmony_ci } else { 987bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP; 988bf215546Sopenharmony_ci } 989bf215546Sopenharmony_ci } else { 990bf215546Sopenharmony_ci /* SIMD4x2 typed surface R/W messages only exist on HSW+ */ 991bf215546Sopenharmony_ci assert(exec_size > 0); 992bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_RC_TYPED_ATOMIC_OP; 993bf215546Sopenharmony_ci } 994bf215546Sopenharmony_ci 995bf215546Sopenharmony_ci const bool high_sample_mask = (exec_group / 8) % 2 == 1; 996bf215546Sopenharmony_ci 997bf215546Sopenharmony_ci const unsigned msg_control = 998bf215546Sopenharmony_ci SET_BITS(atomic_op, 3, 0) | 999bf215546Sopenharmony_ci SET_BITS(high_sample_mask, 4, 4) | 1000bf215546Sopenharmony_ci SET_BITS(response_expected, 5, 5); 1001bf215546Sopenharmony_ci 1002bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 1003bf215546Sopenharmony_ci} 1004bf215546Sopenharmony_ci 1005bf215546Sopenharmony_cistatic inline uint32_t 1006bf215546Sopenharmony_cibrw_dp_typed_surface_rw_desc(const struct intel_device_info *devinfo, 1007bf215546Sopenharmony_ci unsigned exec_size, 1008bf215546Sopenharmony_ci unsigned exec_group, 1009bf215546Sopenharmony_ci unsigned num_channels, 1010bf215546Sopenharmony_ci bool write) 1011bf215546Sopenharmony_ci{ 1012bf215546Sopenharmony_ci assert(exec_size > 0 || exec_group == 0); 1013bf215546Sopenharmony_ci assert(exec_group % 8 == 0); 1014bf215546Sopenharmony_ci 1015bf215546Sopenharmony_ci /* Typed surface reads and writes don't support SIMD16 */ 1016bf215546Sopenharmony_ci assert(exec_size <= 8); 1017bf215546Sopenharmony_ci 1018bf215546Sopenharmony_ci unsigned msg_type; 1019bf215546Sopenharmony_ci if (write) { 1020bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 1021bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE; 1022bf215546Sopenharmony_ci } else { 1023bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_RC_TYPED_SURFACE_WRITE; 1024bf215546Sopenharmony_ci } 1025bf215546Sopenharmony_ci } else { 1026bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 1027bf215546Sopenharmony_ci msg_type = HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ; 1028bf215546Sopenharmony_ci } else { 1029bf215546Sopenharmony_ci msg_type = GFX7_DATAPORT_RC_TYPED_SURFACE_READ; 1030bf215546Sopenharmony_ci } 1031bf215546Sopenharmony_ci } 1032bf215546Sopenharmony_ci 1033bf215546Sopenharmony_ci /* See also MDC_SG3 in the SKL PRM Vol 2d. */ 1034bf215546Sopenharmony_ci unsigned msg_control; 1035bf215546Sopenharmony_ci if (devinfo->verx10 >= 75) { 1036bf215546Sopenharmony_ci /* See also MDC_SG3 in the SKL PRM Vol 2d. */ 1037bf215546Sopenharmony_ci const unsigned slot_group = exec_size == 0 ? 0 : /* SIMD4x2 */ 1038bf215546Sopenharmony_ci 1 + ((exec_group / 8) % 2); 1039bf215546Sopenharmony_ci 1040bf215546Sopenharmony_ci msg_control = 1041bf215546Sopenharmony_ci SET_BITS(brw_mdc_cmask(num_channels), 3, 0) | 1042bf215546Sopenharmony_ci SET_BITS(slot_group, 5, 4); 1043bf215546Sopenharmony_ci } else { 1044bf215546Sopenharmony_ci /* SIMD4x2 typed surface R/W messages only exist on HSW+ */ 1045bf215546Sopenharmony_ci assert(exec_size > 0); 1046bf215546Sopenharmony_ci const unsigned slot_group = ((exec_group / 8) % 2); 1047bf215546Sopenharmony_ci 1048bf215546Sopenharmony_ci msg_control = 1049bf215546Sopenharmony_ci SET_BITS(brw_mdc_cmask(num_channels), 3, 0) | 1050bf215546Sopenharmony_ci SET_BITS(slot_group, 5, 5); 1051bf215546Sopenharmony_ci } 1052bf215546Sopenharmony_ci 1053bf215546Sopenharmony_ci return brw_dp_surface_desc(devinfo, msg_type, msg_control); 1054bf215546Sopenharmony_ci} 1055bf215546Sopenharmony_ci 1056bf215546Sopenharmony_cistatic inline uint32_t 1057bf215546Sopenharmony_cibrw_fb_desc(const struct intel_device_info *devinfo, 1058bf215546Sopenharmony_ci unsigned binding_table_index, 1059bf215546Sopenharmony_ci unsigned msg_type, 1060bf215546Sopenharmony_ci unsigned msg_control) 1061bf215546Sopenharmony_ci{ 1062bf215546Sopenharmony_ci /* Prior to gen6, things are too inconsistent; use the fb_(read|write)_desc 1063bf215546Sopenharmony_ci * helpers instead. 1064bf215546Sopenharmony_ci */ 1065bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 1066bf215546Sopenharmony_ci const unsigned desc = SET_BITS(binding_table_index, 7, 0); 1067bf215546Sopenharmony_ci if (devinfo->ver >= 7) { 1068bf215546Sopenharmony_ci return (desc | SET_BITS(msg_control, 13, 8) | 1069bf215546Sopenharmony_ci SET_BITS(msg_type, 17, 14)); 1070bf215546Sopenharmony_ci } else { 1071bf215546Sopenharmony_ci return (desc | SET_BITS(msg_control, 12, 8) | 1072bf215546Sopenharmony_ci SET_BITS(msg_type, 16, 13)); 1073bf215546Sopenharmony_ci } 1074bf215546Sopenharmony_ci} 1075bf215546Sopenharmony_ci 1076bf215546Sopenharmony_cistatic inline unsigned 1077bf215546Sopenharmony_cibrw_fb_desc_binding_table_index(UNUSED const struct intel_device_info *devinfo, 1078bf215546Sopenharmony_ci uint32_t desc) 1079bf215546Sopenharmony_ci{ 1080bf215546Sopenharmony_ci return GET_BITS(desc, 7, 0); 1081bf215546Sopenharmony_ci} 1082bf215546Sopenharmony_ci 1083bf215546Sopenharmony_cistatic inline uint32_t 1084bf215546Sopenharmony_cibrw_fb_desc_msg_control(const struct intel_device_info *devinfo, uint32_t desc) 1085bf215546Sopenharmony_ci{ 1086bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 1087bf215546Sopenharmony_ci if (devinfo->ver >= 7) 1088bf215546Sopenharmony_ci return GET_BITS(desc, 13, 8); 1089bf215546Sopenharmony_ci else 1090bf215546Sopenharmony_ci return GET_BITS(desc, 12, 8); 1091bf215546Sopenharmony_ci} 1092bf215546Sopenharmony_ci 1093bf215546Sopenharmony_cistatic inline unsigned 1094bf215546Sopenharmony_cibrw_fb_desc_msg_type(const struct intel_device_info *devinfo, uint32_t desc) 1095bf215546Sopenharmony_ci{ 1096bf215546Sopenharmony_ci assert(devinfo->ver >= 6); 1097bf215546Sopenharmony_ci if (devinfo->ver >= 7) 1098bf215546Sopenharmony_ci return GET_BITS(desc, 17, 14); 1099bf215546Sopenharmony_ci else 1100bf215546Sopenharmony_ci return GET_BITS(desc, 16, 13); 1101bf215546Sopenharmony_ci} 1102bf215546Sopenharmony_ci 1103bf215546Sopenharmony_cistatic inline uint32_t 1104bf215546Sopenharmony_cibrw_fb_read_desc(const struct intel_device_info *devinfo, 1105bf215546Sopenharmony_ci unsigned binding_table_index, 1106bf215546Sopenharmony_ci unsigned msg_control, 1107bf215546Sopenharmony_ci unsigned exec_size, 1108bf215546Sopenharmony_ci bool per_sample) 1109bf215546Sopenharmony_ci{ 1110bf215546Sopenharmony_ci assert(devinfo->ver >= 9); 1111bf215546Sopenharmony_ci assert(exec_size == 8 || exec_size == 16); 1112bf215546Sopenharmony_ci 1113bf215546Sopenharmony_ci return brw_fb_desc(devinfo, binding_table_index, 1114bf215546Sopenharmony_ci GFX9_DATAPORT_RC_RENDER_TARGET_READ, msg_control) | 1115bf215546Sopenharmony_ci SET_BITS(per_sample, 13, 13) | 1116bf215546Sopenharmony_ci SET_BITS(exec_size == 8, 8, 8) /* Render Target Message Subtype */; 1117bf215546Sopenharmony_ci} 1118bf215546Sopenharmony_ci 1119bf215546Sopenharmony_cistatic inline uint32_t 1120bf215546Sopenharmony_cibrw_fb_write_desc(const struct intel_device_info *devinfo, 1121bf215546Sopenharmony_ci unsigned binding_table_index, 1122bf215546Sopenharmony_ci unsigned msg_control, 1123bf215546Sopenharmony_ci bool last_render_target, 1124bf215546Sopenharmony_ci bool coarse_write) 1125bf215546Sopenharmony_ci{ 1126bf215546Sopenharmony_ci const unsigned msg_type = 1127bf215546Sopenharmony_ci devinfo->ver >= 6 ? 1128bf215546Sopenharmony_ci GFX6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE : 1129bf215546Sopenharmony_ci BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE; 1130bf215546Sopenharmony_ci 1131bf215546Sopenharmony_ci assert(devinfo->ver >= 10 || !coarse_write); 1132bf215546Sopenharmony_ci 1133bf215546Sopenharmony_ci if (devinfo->ver >= 6) { 1134bf215546Sopenharmony_ci return brw_fb_desc(devinfo, binding_table_index, msg_type, msg_control) | 1135bf215546Sopenharmony_ci SET_BITS(last_render_target, 12, 12) | 1136bf215546Sopenharmony_ci SET_BITS(coarse_write, 18, 18); 1137bf215546Sopenharmony_ci } else { 1138bf215546Sopenharmony_ci return (SET_BITS(binding_table_index, 7, 0) | 1139bf215546Sopenharmony_ci SET_BITS(msg_control, 11, 8) | 1140bf215546Sopenharmony_ci SET_BITS(last_render_target, 11, 11) | 1141bf215546Sopenharmony_ci SET_BITS(msg_type, 14, 12)); 1142bf215546Sopenharmony_ci } 1143bf215546Sopenharmony_ci} 1144bf215546Sopenharmony_ci 1145bf215546Sopenharmony_cistatic inline unsigned 1146bf215546Sopenharmony_cibrw_fb_write_desc_msg_type(const struct intel_device_info *devinfo, 1147bf215546Sopenharmony_ci uint32_t desc) 1148bf215546Sopenharmony_ci{ 1149bf215546Sopenharmony_ci if (devinfo->ver >= 6) 1150bf215546Sopenharmony_ci return brw_fb_desc_msg_type(devinfo, desc); 1151bf215546Sopenharmony_ci else 1152bf215546Sopenharmony_ci return GET_BITS(desc, 14, 12); 1153bf215546Sopenharmony_ci} 1154bf215546Sopenharmony_ci 1155bf215546Sopenharmony_cistatic inline unsigned 1156bf215546Sopenharmony_cibrw_fb_write_desc_msg_control(const struct intel_device_info *devinfo, 1157bf215546Sopenharmony_ci uint32_t desc) 1158bf215546Sopenharmony_ci{ 1159bf215546Sopenharmony_ci if (devinfo->ver >= 6) 1160bf215546Sopenharmony_ci return brw_fb_desc_msg_control(devinfo, desc); 1161bf215546Sopenharmony_ci else 1162bf215546Sopenharmony_ci return GET_BITS(desc, 11, 8); 1163bf215546Sopenharmony_ci} 1164bf215546Sopenharmony_ci 1165bf215546Sopenharmony_cistatic inline bool 1166bf215546Sopenharmony_cibrw_fb_write_desc_last_render_target(const struct intel_device_info *devinfo, 1167bf215546Sopenharmony_ci uint32_t desc) 1168bf215546Sopenharmony_ci{ 1169bf215546Sopenharmony_ci if (devinfo->ver >= 6) 1170bf215546Sopenharmony_ci return GET_BITS(desc, 12, 12); 1171bf215546Sopenharmony_ci else 1172bf215546Sopenharmony_ci return GET_BITS(desc, 11, 11); 1173bf215546Sopenharmony_ci} 1174bf215546Sopenharmony_ci 1175bf215546Sopenharmony_cistatic inline bool 1176bf215546Sopenharmony_cibrw_fb_write_desc_write_commit(const struct intel_device_info *devinfo, 1177bf215546Sopenharmony_ci uint32_t desc) 1178bf215546Sopenharmony_ci{ 1179bf215546Sopenharmony_ci assert(devinfo->ver <= 6); 1180bf215546Sopenharmony_ci if (devinfo->ver >= 6) 1181bf215546Sopenharmony_ci return GET_BITS(desc, 17, 17); 1182bf215546Sopenharmony_ci else 1183bf215546Sopenharmony_ci return GET_BITS(desc, 15, 15); 1184bf215546Sopenharmony_ci} 1185bf215546Sopenharmony_ci 1186bf215546Sopenharmony_cistatic inline bool 1187bf215546Sopenharmony_cibrw_fb_write_desc_coarse_write(const struct intel_device_info *devinfo, 1188bf215546Sopenharmony_ci uint32_t desc) 1189bf215546Sopenharmony_ci{ 1190bf215546Sopenharmony_ci assert(devinfo->ver >= 10); 1191bf215546Sopenharmony_ci return GET_BITS(desc, 18, 18); 1192bf215546Sopenharmony_ci} 1193bf215546Sopenharmony_ci 1194bf215546Sopenharmony_cistatic inline bool 1195bf215546Sopenharmony_cilsc_opcode_has_cmask(enum lsc_opcode opcode) 1196bf215546Sopenharmony_ci{ 1197bf215546Sopenharmony_ci return opcode == LSC_OP_LOAD_CMASK || opcode == LSC_OP_STORE_CMASK; 1198bf215546Sopenharmony_ci} 1199bf215546Sopenharmony_ci 1200bf215546Sopenharmony_cistatic inline bool 1201bf215546Sopenharmony_cilsc_opcode_has_transpose(enum lsc_opcode opcode) 1202bf215546Sopenharmony_ci{ 1203bf215546Sopenharmony_ci return opcode == LSC_OP_LOAD || opcode == LSC_OP_STORE; 1204bf215546Sopenharmony_ci} 1205bf215546Sopenharmony_ci 1206bf215546Sopenharmony_cistatic inline uint32_t 1207bf215546Sopenharmony_cilsc_data_size_bytes(enum lsc_data_size data_size) 1208bf215546Sopenharmony_ci{ 1209bf215546Sopenharmony_ci switch (data_size) { 1210bf215546Sopenharmony_ci case LSC_DATA_SIZE_D8: 1211bf215546Sopenharmony_ci return 1; 1212bf215546Sopenharmony_ci case LSC_DATA_SIZE_D16: 1213bf215546Sopenharmony_ci return 2; 1214bf215546Sopenharmony_ci case LSC_DATA_SIZE_D32: 1215bf215546Sopenharmony_ci case LSC_DATA_SIZE_D8U32: 1216bf215546Sopenharmony_ci case LSC_DATA_SIZE_D16U32: 1217bf215546Sopenharmony_ci case LSC_DATA_SIZE_D16BF32: 1218bf215546Sopenharmony_ci return 4; 1219bf215546Sopenharmony_ci case LSC_DATA_SIZE_D64: 1220bf215546Sopenharmony_ci return 8; 1221bf215546Sopenharmony_ci default: 1222bf215546Sopenharmony_ci unreachable("Unsupported data payload size."); 1223bf215546Sopenharmony_ci } 1224bf215546Sopenharmony_ci} 1225bf215546Sopenharmony_ci 1226bf215546Sopenharmony_cistatic inline uint32_t 1227bf215546Sopenharmony_cilsc_addr_size_bytes(enum lsc_addr_size addr_size) 1228bf215546Sopenharmony_ci{ 1229bf215546Sopenharmony_ci switch (addr_size) { 1230bf215546Sopenharmony_ci case LSC_ADDR_SIZE_A16: return 2; 1231bf215546Sopenharmony_ci case LSC_ADDR_SIZE_A32: return 4; 1232bf215546Sopenharmony_ci case LSC_ADDR_SIZE_A64: return 8; 1233bf215546Sopenharmony_ci default: 1234bf215546Sopenharmony_ci unreachable("Unsupported address size."); 1235bf215546Sopenharmony_ci } 1236bf215546Sopenharmony_ci} 1237bf215546Sopenharmony_ci 1238bf215546Sopenharmony_cistatic inline uint32_t 1239bf215546Sopenharmony_cilsc_vector_length(enum lsc_vect_size vect_size) 1240bf215546Sopenharmony_ci{ 1241bf215546Sopenharmony_ci switch (vect_size) { 1242bf215546Sopenharmony_ci case LSC_VECT_SIZE_V1: return 1; 1243bf215546Sopenharmony_ci case LSC_VECT_SIZE_V2: return 2; 1244bf215546Sopenharmony_ci case LSC_VECT_SIZE_V3: return 3; 1245bf215546Sopenharmony_ci case LSC_VECT_SIZE_V4: return 4; 1246bf215546Sopenharmony_ci case LSC_VECT_SIZE_V8: return 8; 1247bf215546Sopenharmony_ci case LSC_VECT_SIZE_V16: return 16; 1248bf215546Sopenharmony_ci case LSC_VECT_SIZE_V32: return 32; 1249bf215546Sopenharmony_ci case LSC_VECT_SIZE_V64: return 64; 1250bf215546Sopenharmony_ci default: 1251bf215546Sopenharmony_ci unreachable("Unsupported size of vector"); 1252bf215546Sopenharmony_ci } 1253bf215546Sopenharmony_ci} 1254bf215546Sopenharmony_ci 1255bf215546Sopenharmony_cistatic inline enum lsc_vect_size 1256bf215546Sopenharmony_cilsc_vect_size(unsigned vect_size) 1257bf215546Sopenharmony_ci{ 1258bf215546Sopenharmony_ci switch(vect_size) { 1259bf215546Sopenharmony_ci case 1: return LSC_VECT_SIZE_V1; 1260bf215546Sopenharmony_ci case 2: return LSC_VECT_SIZE_V2; 1261bf215546Sopenharmony_ci case 3: return LSC_VECT_SIZE_V3; 1262bf215546Sopenharmony_ci case 4: return LSC_VECT_SIZE_V4; 1263bf215546Sopenharmony_ci case 8: return LSC_VECT_SIZE_V8; 1264bf215546Sopenharmony_ci case 16: return LSC_VECT_SIZE_V16; 1265bf215546Sopenharmony_ci case 32: return LSC_VECT_SIZE_V32; 1266bf215546Sopenharmony_ci case 64: return LSC_VECT_SIZE_V64; 1267bf215546Sopenharmony_ci default: 1268bf215546Sopenharmony_ci unreachable("Unsupported vector size for dataport"); 1269bf215546Sopenharmony_ci } 1270bf215546Sopenharmony_ci} 1271bf215546Sopenharmony_ci 1272bf215546Sopenharmony_cistatic inline uint32_t 1273bf215546Sopenharmony_cilsc_msg_desc(UNUSED const struct intel_device_info *devinfo, 1274bf215546Sopenharmony_ci enum lsc_opcode opcode, unsigned simd_size, 1275bf215546Sopenharmony_ci enum lsc_addr_surface_type addr_type, 1276bf215546Sopenharmony_ci enum lsc_addr_size addr_sz, unsigned num_coordinates, 1277bf215546Sopenharmony_ci enum lsc_data_size data_sz, unsigned num_channels, 1278bf215546Sopenharmony_ci bool transpose, unsigned cache_ctrl, bool has_dest) 1279bf215546Sopenharmony_ci{ 1280bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1281bf215546Sopenharmony_ci 1282bf215546Sopenharmony_ci unsigned dest_length = !has_dest ? 0 : 1283bf215546Sopenharmony_ci DIV_ROUND_UP(lsc_data_size_bytes(data_sz) * num_channels * simd_size, 1284bf215546Sopenharmony_ci REG_SIZE); 1285bf215546Sopenharmony_ci 1286bf215546Sopenharmony_ci unsigned src0_length = 1287bf215546Sopenharmony_ci DIV_ROUND_UP(lsc_addr_size_bytes(addr_sz) * num_coordinates * simd_size, 1288bf215546Sopenharmony_ci REG_SIZE); 1289bf215546Sopenharmony_ci 1290bf215546Sopenharmony_ci assert(!transpose || lsc_opcode_has_transpose(opcode)); 1291bf215546Sopenharmony_ci 1292bf215546Sopenharmony_ci unsigned msg_desc = 1293bf215546Sopenharmony_ci SET_BITS(opcode, 5, 0) | 1294bf215546Sopenharmony_ci SET_BITS(addr_sz, 8, 7) | 1295bf215546Sopenharmony_ci SET_BITS(data_sz, 11, 9) | 1296bf215546Sopenharmony_ci SET_BITS(transpose, 15, 15) | 1297bf215546Sopenharmony_ci SET_BITS(cache_ctrl, 19, 17) | 1298bf215546Sopenharmony_ci SET_BITS(dest_length, 24, 20) | 1299bf215546Sopenharmony_ci SET_BITS(src0_length, 28, 25) | 1300bf215546Sopenharmony_ci SET_BITS(addr_type, 30, 29); 1301bf215546Sopenharmony_ci 1302bf215546Sopenharmony_ci if (lsc_opcode_has_cmask(opcode)) 1303bf215546Sopenharmony_ci msg_desc |= SET_BITS(lsc_cmask(num_channels), 15, 12); 1304bf215546Sopenharmony_ci else 1305bf215546Sopenharmony_ci msg_desc |= SET_BITS(lsc_vect_size(num_channels), 14, 12); 1306bf215546Sopenharmony_ci 1307bf215546Sopenharmony_ci return msg_desc; 1308bf215546Sopenharmony_ci} 1309bf215546Sopenharmony_ci 1310bf215546Sopenharmony_cistatic inline enum lsc_opcode 1311bf215546Sopenharmony_cilsc_msg_desc_opcode(UNUSED const struct intel_device_info *devinfo, 1312bf215546Sopenharmony_ci uint32_t desc) 1313bf215546Sopenharmony_ci{ 1314bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1315bf215546Sopenharmony_ci return (enum lsc_opcode) GET_BITS(desc, 5, 0); 1316bf215546Sopenharmony_ci} 1317bf215546Sopenharmony_ci 1318bf215546Sopenharmony_cistatic inline enum lsc_addr_size 1319bf215546Sopenharmony_cilsc_msg_desc_addr_size(UNUSED const struct intel_device_info *devinfo, 1320bf215546Sopenharmony_ci uint32_t desc) 1321bf215546Sopenharmony_ci{ 1322bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1323bf215546Sopenharmony_ci return (enum lsc_addr_size) GET_BITS(desc, 8, 7); 1324bf215546Sopenharmony_ci} 1325bf215546Sopenharmony_ci 1326bf215546Sopenharmony_cistatic inline enum lsc_data_size 1327bf215546Sopenharmony_cilsc_msg_desc_data_size(UNUSED const struct intel_device_info *devinfo, 1328bf215546Sopenharmony_ci uint32_t desc) 1329bf215546Sopenharmony_ci{ 1330bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1331bf215546Sopenharmony_ci return (enum lsc_data_size) GET_BITS(desc, 11, 9); 1332bf215546Sopenharmony_ci} 1333bf215546Sopenharmony_ci 1334bf215546Sopenharmony_cistatic inline enum lsc_vect_size 1335bf215546Sopenharmony_cilsc_msg_desc_vect_size(UNUSED const struct intel_device_info *devinfo, 1336bf215546Sopenharmony_ci uint32_t desc) 1337bf215546Sopenharmony_ci{ 1338bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1339bf215546Sopenharmony_ci assert(!lsc_opcode_has_cmask(lsc_msg_desc_opcode(devinfo, desc))); 1340bf215546Sopenharmony_ci return (enum lsc_vect_size) GET_BITS(desc, 14, 12); 1341bf215546Sopenharmony_ci} 1342bf215546Sopenharmony_ci 1343bf215546Sopenharmony_cistatic inline enum lsc_cmask 1344bf215546Sopenharmony_cilsc_msg_desc_cmask(UNUSED const struct intel_device_info *devinfo, 1345bf215546Sopenharmony_ci uint32_t desc) 1346bf215546Sopenharmony_ci{ 1347bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1348bf215546Sopenharmony_ci assert(lsc_opcode_has_cmask(lsc_msg_desc_opcode(devinfo, desc))); 1349bf215546Sopenharmony_ci return (enum lsc_cmask) GET_BITS(desc, 15, 12); 1350bf215546Sopenharmony_ci} 1351bf215546Sopenharmony_ci 1352bf215546Sopenharmony_cistatic inline bool 1353bf215546Sopenharmony_cilsc_msg_desc_transpose(UNUSED const struct intel_device_info *devinfo, 1354bf215546Sopenharmony_ci uint32_t desc) 1355bf215546Sopenharmony_ci{ 1356bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1357bf215546Sopenharmony_ci return GET_BITS(desc, 15, 15); 1358bf215546Sopenharmony_ci} 1359bf215546Sopenharmony_ci 1360bf215546Sopenharmony_cistatic inline unsigned 1361bf215546Sopenharmony_cilsc_msg_desc_cache_ctrl(UNUSED const struct intel_device_info *devinfo, 1362bf215546Sopenharmony_ci uint32_t desc) 1363bf215546Sopenharmony_ci{ 1364bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1365bf215546Sopenharmony_ci return GET_BITS(desc, 19, 17); 1366bf215546Sopenharmony_ci} 1367bf215546Sopenharmony_ci 1368bf215546Sopenharmony_cistatic inline unsigned 1369bf215546Sopenharmony_cilsc_msg_desc_dest_len(const struct intel_device_info *devinfo, 1370bf215546Sopenharmony_ci uint32_t desc) 1371bf215546Sopenharmony_ci{ 1372bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1373bf215546Sopenharmony_ci return GET_BITS(desc, 24, 20); 1374bf215546Sopenharmony_ci} 1375bf215546Sopenharmony_ci 1376bf215546Sopenharmony_cistatic inline unsigned 1377bf215546Sopenharmony_cilsc_msg_desc_src0_len(const struct intel_device_info *devinfo, 1378bf215546Sopenharmony_ci uint32_t desc) 1379bf215546Sopenharmony_ci{ 1380bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1381bf215546Sopenharmony_ci return GET_BITS(desc, 28, 25); 1382bf215546Sopenharmony_ci} 1383bf215546Sopenharmony_ci 1384bf215546Sopenharmony_cistatic inline enum lsc_addr_surface_type 1385bf215546Sopenharmony_cilsc_msg_desc_addr_type(UNUSED const struct intel_device_info *devinfo, 1386bf215546Sopenharmony_ci uint32_t desc) 1387bf215546Sopenharmony_ci{ 1388bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1389bf215546Sopenharmony_ci return (enum lsc_addr_surface_type) GET_BITS(desc, 30, 29); 1390bf215546Sopenharmony_ci} 1391bf215546Sopenharmony_ci 1392bf215546Sopenharmony_cistatic inline uint32_t 1393bf215546Sopenharmony_cilsc_fence_msg_desc(UNUSED const struct intel_device_info *devinfo, 1394bf215546Sopenharmony_ci enum lsc_fence_scope scope, 1395bf215546Sopenharmony_ci enum lsc_flush_type flush_type, 1396bf215546Sopenharmony_ci bool route_to_lsc) 1397bf215546Sopenharmony_ci{ 1398bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1399bf215546Sopenharmony_ci return SET_BITS(LSC_OP_FENCE, 5, 0) | 1400bf215546Sopenharmony_ci SET_BITS(LSC_ADDR_SIZE_A32, 8, 7) | 1401bf215546Sopenharmony_ci SET_BITS(scope, 11, 9) | 1402bf215546Sopenharmony_ci SET_BITS(flush_type, 14, 12) | 1403bf215546Sopenharmony_ci SET_BITS(route_to_lsc, 18, 18) | 1404bf215546Sopenharmony_ci SET_BITS(LSC_ADDR_SURFTYPE_FLAT, 30, 29); 1405bf215546Sopenharmony_ci} 1406bf215546Sopenharmony_ci 1407bf215546Sopenharmony_cistatic inline enum lsc_fence_scope 1408bf215546Sopenharmony_cilsc_fence_msg_desc_scope(UNUSED const struct intel_device_info *devinfo, 1409bf215546Sopenharmony_ci uint32_t desc) 1410bf215546Sopenharmony_ci{ 1411bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1412bf215546Sopenharmony_ci return (enum lsc_fence_scope) GET_BITS(desc, 11, 9); 1413bf215546Sopenharmony_ci} 1414bf215546Sopenharmony_ci 1415bf215546Sopenharmony_cistatic inline enum lsc_flush_type 1416bf215546Sopenharmony_cilsc_fence_msg_desc_flush_type(UNUSED const struct intel_device_info *devinfo, 1417bf215546Sopenharmony_ci uint32_t desc) 1418bf215546Sopenharmony_ci{ 1419bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1420bf215546Sopenharmony_ci return (enum lsc_flush_type) GET_BITS(desc, 14, 12); 1421bf215546Sopenharmony_ci} 1422bf215546Sopenharmony_ci 1423bf215546Sopenharmony_cistatic inline enum lsc_backup_fence_routing 1424bf215546Sopenharmony_cilsc_fence_msg_desc_backup_routing(UNUSED const struct intel_device_info *devinfo, 1425bf215546Sopenharmony_ci uint32_t desc) 1426bf215546Sopenharmony_ci{ 1427bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1428bf215546Sopenharmony_ci return (enum lsc_backup_fence_routing) GET_BITS(desc, 18, 18); 1429bf215546Sopenharmony_ci} 1430bf215546Sopenharmony_ci 1431bf215546Sopenharmony_cistatic inline uint32_t 1432bf215546Sopenharmony_cilsc_bti_ex_desc(const struct intel_device_info *devinfo, unsigned bti) 1433bf215546Sopenharmony_ci{ 1434bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1435bf215546Sopenharmony_ci return SET_BITS(bti, 31, 24) | 1436bf215546Sopenharmony_ci SET_BITS(0, 23, 12); /* base offset */ 1437bf215546Sopenharmony_ci} 1438bf215546Sopenharmony_ci 1439bf215546Sopenharmony_cistatic inline unsigned 1440bf215546Sopenharmony_cilsc_bti_ex_desc_base_offset(const struct intel_device_info *devinfo, 1441bf215546Sopenharmony_ci uint32_t ex_desc) 1442bf215546Sopenharmony_ci{ 1443bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1444bf215546Sopenharmony_ci return GET_BITS(ex_desc, 23, 12); 1445bf215546Sopenharmony_ci} 1446bf215546Sopenharmony_ci 1447bf215546Sopenharmony_cistatic inline unsigned 1448bf215546Sopenharmony_cilsc_bti_ex_desc_index(const struct intel_device_info *devinfo, 1449bf215546Sopenharmony_ci uint32_t ex_desc) 1450bf215546Sopenharmony_ci{ 1451bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1452bf215546Sopenharmony_ci return GET_BITS(ex_desc, 31, 24); 1453bf215546Sopenharmony_ci} 1454bf215546Sopenharmony_ci 1455bf215546Sopenharmony_cistatic inline unsigned 1456bf215546Sopenharmony_cilsc_flat_ex_desc_base_offset(const struct intel_device_info *devinfo, 1457bf215546Sopenharmony_ci uint32_t ex_desc) 1458bf215546Sopenharmony_ci{ 1459bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1460bf215546Sopenharmony_ci return GET_BITS(ex_desc, 31, 12); 1461bf215546Sopenharmony_ci} 1462bf215546Sopenharmony_ci 1463bf215546Sopenharmony_cistatic inline uint32_t 1464bf215546Sopenharmony_cilsc_bss_ex_desc(const struct intel_device_info *devinfo, 1465bf215546Sopenharmony_ci unsigned surface_state_index) 1466bf215546Sopenharmony_ci{ 1467bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1468bf215546Sopenharmony_ci return SET_BITS(surface_state_index, 31, 6); 1469bf215546Sopenharmony_ci} 1470bf215546Sopenharmony_ci 1471bf215546Sopenharmony_cistatic inline unsigned 1472bf215546Sopenharmony_cilsc_bss_ex_desc_index(const struct intel_device_info *devinfo, 1473bf215546Sopenharmony_ci uint32_t ex_desc) 1474bf215546Sopenharmony_ci{ 1475bf215546Sopenharmony_ci assert(devinfo->has_lsc); 1476bf215546Sopenharmony_ci return GET_BITS(ex_desc, 31, 6); 1477bf215546Sopenharmony_ci} 1478bf215546Sopenharmony_ci 1479bf215546Sopenharmony_cistatic inline uint32_t 1480bf215546Sopenharmony_cibrw_mdc_sm2(unsigned exec_size) 1481bf215546Sopenharmony_ci{ 1482bf215546Sopenharmony_ci assert(exec_size == 8 || exec_size == 16); 1483bf215546Sopenharmony_ci return exec_size > 8; 1484bf215546Sopenharmony_ci} 1485bf215546Sopenharmony_ci 1486bf215546Sopenharmony_cistatic inline uint32_t 1487bf215546Sopenharmony_cibrw_mdc_sm2_exec_size(uint32_t sm2) 1488bf215546Sopenharmony_ci{ 1489bf215546Sopenharmony_ci assert(sm2 <= 1); 1490bf215546Sopenharmony_ci return 8 << sm2; 1491bf215546Sopenharmony_ci} 1492bf215546Sopenharmony_ci 1493bf215546Sopenharmony_cistatic inline uint32_t 1494bf215546Sopenharmony_cibrw_btd_spawn_desc(ASSERTED const struct intel_device_info *devinfo, 1495bf215546Sopenharmony_ci unsigned exec_size, unsigned msg_type) 1496bf215546Sopenharmony_ci{ 1497bf215546Sopenharmony_ci assert(devinfo->has_ray_tracing); 1498bf215546Sopenharmony_ci 1499bf215546Sopenharmony_ci return SET_BITS(0, 19, 19) | /* No header */ 1500bf215546Sopenharmony_ci SET_BITS(msg_type, 17, 14) | 1501bf215546Sopenharmony_ci SET_BITS(brw_mdc_sm2(exec_size), 8, 8); 1502bf215546Sopenharmony_ci} 1503bf215546Sopenharmony_ci 1504bf215546Sopenharmony_cistatic inline uint32_t 1505bf215546Sopenharmony_cibrw_btd_spawn_msg_type(UNUSED const struct intel_device_info *devinfo, 1506bf215546Sopenharmony_ci uint32_t desc) 1507bf215546Sopenharmony_ci{ 1508bf215546Sopenharmony_ci return GET_BITS(desc, 17, 14); 1509bf215546Sopenharmony_ci} 1510bf215546Sopenharmony_ci 1511bf215546Sopenharmony_cistatic inline uint32_t 1512bf215546Sopenharmony_cibrw_btd_spawn_exec_size(UNUSED const struct intel_device_info *devinfo, 1513bf215546Sopenharmony_ci uint32_t desc) 1514bf215546Sopenharmony_ci{ 1515bf215546Sopenharmony_ci return brw_mdc_sm2_exec_size(GET_BITS(desc, 8, 8)); 1516bf215546Sopenharmony_ci} 1517bf215546Sopenharmony_ci 1518bf215546Sopenharmony_cistatic inline uint32_t 1519bf215546Sopenharmony_cibrw_rt_trace_ray_desc(ASSERTED const struct intel_device_info *devinfo, 1520bf215546Sopenharmony_ci unsigned exec_size) 1521bf215546Sopenharmony_ci{ 1522bf215546Sopenharmony_ci assert(devinfo->has_ray_tracing); 1523bf215546Sopenharmony_ci 1524bf215546Sopenharmony_ci return SET_BITS(0, 19, 19) | /* No header */ 1525bf215546Sopenharmony_ci SET_BITS(0, 17, 14) | /* Message type */ 1526bf215546Sopenharmony_ci SET_BITS(brw_mdc_sm2(exec_size), 8, 8); 1527bf215546Sopenharmony_ci} 1528bf215546Sopenharmony_ci 1529bf215546Sopenharmony_cistatic inline uint32_t 1530bf215546Sopenharmony_cibrw_rt_trace_ray_desc_exec_size(UNUSED const struct intel_device_info *devinfo, 1531bf215546Sopenharmony_ci uint32_t desc) 1532bf215546Sopenharmony_ci{ 1533bf215546Sopenharmony_ci return brw_mdc_sm2_exec_size(GET_BITS(desc, 8, 8)); 1534bf215546Sopenharmony_ci} 1535bf215546Sopenharmony_ci 1536bf215546Sopenharmony_ci/** 1537bf215546Sopenharmony_ci * Construct a message descriptor immediate with the specified pixel 1538bf215546Sopenharmony_ci * interpolator function controls. 1539bf215546Sopenharmony_ci */ 1540bf215546Sopenharmony_cistatic inline uint32_t 1541bf215546Sopenharmony_cibrw_pixel_interp_desc(UNUSED const struct intel_device_info *devinfo, 1542bf215546Sopenharmony_ci unsigned msg_type, 1543bf215546Sopenharmony_ci bool noperspective, 1544bf215546Sopenharmony_ci bool coarse_pixel_rate, 1545bf215546Sopenharmony_ci unsigned simd_mode, 1546bf215546Sopenharmony_ci unsigned slot_group) 1547bf215546Sopenharmony_ci{ 1548bf215546Sopenharmony_ci assert(devinfo->ver >= 10 || !coarse_pixel_rate); 1549bf215546Sopenharmony_ci return (SET_BITS(slot_group, 11, 11) | 1550bf215546Sopenharmony_ci SET_BITS(msg_type, 13, 12) | 1551bf215546Sopenharmony_ci SET_BITS(!!noperspective, 14, 14) | 1552bf215546Sopenharmony_ci SET_BITS(coarse_pixel_rate, 15, 15) | 1553bf215546Sopenharmony_ci SET_BITS(simd_mode, 16, 16)); 1554bf215546Sopenharmony_ci} 1555bf215546Sopenharmony_ci 1556bf215546Sopenharmony_civoid brw_urb_WRITE(struct brw_codegen *p, 1557bf215546Sopenharmony_ci struct brw_reg dest, 1558bf215546Sopenharmony_ci unsigned msg_reg_nr, 1559bf215546Sopenharmony_ci struct brw_reg src0, 1560bf215546Sopenharmony_ci enum brw_urb_write_flags flags, 1561bf215546Sopenharmony_ci unsigned msg_length, 1562bf215546Sopenharmony_ci unsigned response_length, 1563bf215546Sopenharmony_ci unsigned offset, 1564bf215546Sopenharmony_ci unsigned swizzle); 1565bf215546Sopenharmony_ci 1566bf215546Sopenharmony_ci/** 1567bf215546Sopenharmony_ci * Send message to shared unit \p sfid with a possibly indirect descriptor \p 1568bf215546Sopenharmony_ci * desc. If \p desc is not an immediate it will be transparently loaded to an 1569bf215546Sopenharmony_ci * address register using an OR instruction. 1570bf215546Sopenharmony_ci */ 1571bf215546Sopenharmony_civoid 1572bf215546Sopenharmony_cibrw_send_indirect_message(struct brw_codegen *p, 1573bf215546Sopenharmony_ci unsigned sfid, 1574bf215546Sopenharmony_ci struct brw_reg dst, 1575bf215546Sopenharmony_ci struct brw_reg payload, 1576bf215546Sopenharmony_ci struct brw_reg desc, 1577bf215546Sopenharmony_ci unsigned desc_imm, 1578bf215546Sopenharmony_ci bool eot); 1579bf215546Sopenharmony_ci 1580bf215546Sopenharmony_civoid 1581bf215546Sopenharmony_cibrw_send_indirect_split_message(struct brw_codegen *p, 1582bf215546Sopenharmony_ci unsigned sfid, 1583bf215546Sopenharmony_ci struct brw_reg dst, 1584bf215546Sopenharmony_ci struct brw_reg payload0, 1585bf215546Sopenharmony_ci struct brw_reg payload1, 1586bf215546Sopenharmony_ci struct brw_reg desc, 1587bf215546Sopenharmony_ci unsigned desc_imm, 1588bf215546Sopenharmony_ci struct brw_reg ex_desc, 1589bf215546Sopenharmony_ci unsigned ex_desc_imm, 1590bf215546Sopenharmony_ci bool eot); 1591bf215546Sopenharmony_ci 1592bf215546Sopenharmony_civoid brw_ff_sync(struct brw_codegen *p, 1593bf215546Sopenharmony_ci struct brw_reg dest, 1594bf215546Sopenharmony_ci unsigned msg_reg_nr, 1595bf215546Sopenharmony_ci struct brw_reg src0, 1596bf215546Sopenharmony_ci bool allocate, 1597bf215546Sopenharmony_ci unsigned response_length, 1598bf215546Sopenharmony_ci bool eot); 1599bf215546Sopenharmony_ci 1600bf215546Sopenharmony_civoid brw_svb_write(struct brw_codegen *p, 1601bf215546Sopenharmony_ci struct brw_reg dest, 1602bf215546Sopenharmony_ci unsigned msg_reg_nr, 1603bf215546Sopenharmony_ci struct brw_reg src0, 1604bf215546Sopenharmony_ci unsigned binding_table_index, 1605bf215546Sopenharmony_ci bool send_commit_msg); 1606bf215546Sopenharmony_ci 1607bf215546Sopenharmony_cibrw_inst *brw_fb_WRITE(struct brw_codegen *p, 1608bf215546Sopenharmony_ci struct brw_reg payload, 1609bf215546Sopenharmony_ci struct brw_reg implied_header, 1610bf215546Sopenharmony_ci unsigned msg_control, 1611bf215546Sopenharmony_ci unsigned binding_table_index, 1612bf215546Sopenharmony_ci unsigned msg_length, 1613bf215546Sopenharmony_ci unsigned response_length, 1614bf215546Sopenharmony_ci bool eot, 1615bf215546Sopenharmony_ci bool last_render_target, 1616bf215546Sopenharmony_ci bool header_present); 1617bf215546Sopenharmony_ci 1618bf215546Sopenharmony_cibrw_inst *gfx9_fb_READ(struct brw_codegen *p, 1619bf215546Sopenharmony_ci struct brw_reg dst, 1620bf215546Sopenharmony_ci struct brw_reg payload, 1621bf215546Sopenharmony_ci unsigned binding_table_index, 1622bf215546Sopenharmony_ci unsigned msg_length, 1623bf215546Sopenharmony_ci unsigned response_length, 1624bf215546Sopenharmony_ci bool per_sample); 1625bf215546Sopenharmony_ci 1626bf215546Sopenharmony_civoid brw_SAMPLE(struct brw_codegen *p, 1627bf215546Sopenharmony_ci struct brw_reg dest, 1628bf215546Sopenharmony_ci unsigned msg_reg_nr, 1629bf215546Sopenharmony_ci struct brw_reg src0, 1630bf215546Sopenharmony_ci unsigned binding_table_index, 1631bf215546Sopenharmony_ci unsigned sampler, 1632bf215546Sopenharmony_ci unsigned msg_type, 1633bf215546Sopenharmony_ci unsigned response_length, 1634bf215546Sopenharmony_ci unsigned msg_length, 1635bf215546Sopenharmony_ci unsigned header_present, 1636bf215546Sopenharmony_ci unsigned simd_mode, 1637bf215546Sopenharmony_ci unsigned return_format); 1638bf215546Sopenharmony_ci 1639bf215546Sopenharmony_civoid brw_adjust_sampler_state_pointer(struct brw_codegen *p, 1640bf215546Sopenharmony_ci struct brw_reg header, 1641bf215546Sopenharmony_ci struct brw_reg sampler_index); 1642bf215546Sopenharmony_ci 1643bf215546Sopenharmony_civoid gfx4_math(struct brw_codegen *p, 1644bf215546Sopenharmony_ci struct brw_reg dest, 1645bf215546Sopenharmony_ci unsigned function, 1646bf215546Sopenharmony_ci unsigned msg_reg_nr, 1647bf215546Sopenharmony_ci struct brw_reg src, 1648bf215546Sopenharmony_ci unsigned precision ); 1649bf215546Sopenharmony_ci 1650bf215546Sopenharmony_civoid gfx6_math(struct brw_codegen *p, 1651bf215546Sopenharmony_ci struct brw_reg dest, 1652bf215546Sopenharmony_ci unsigned function, 1653bf215546Sopenharmony_ci struct brw_reg src0, 1654bf215546Sopenharmony_ci struct brw_reg src1); 1655bf215546Sopenharmony_ci 1656bf215546Sopenharmony_civoid brw_oword_block_read(struct brw_codegen *p, 1657bf215546Sopenharmony_ci struct brw_reg dest, 1658bf215546Sopenharmony_ci struct brw_reg mrf, 1659bf215546Sopenharmony_ci uint32_t offset, 1660bf215546Sopenharmony_ci uint32_t bind_table_index); 1661bf215546Sopenharmony_ci 1662bf215546Sopenharmony_ciunsigned brw_scratch_surface_idx(const struct brw_codegen *p); 1663bf215546Sopenharmony_ci 1664bf215546Sopenharmony_civoid brw_oword_block_read_scratch(struct brw_codegen *p, 1665bf215546Sopenharmony_ci struct brw_reg dest, 1666bf215546Sopenharmony_ci struct brw_reg mrf, 1667bf215546Sopenharmony_ci int num_regs, 1668bf215546Sopenharmony_ci unsigned offset); 1669bf215546Sopenharmony_ci 1670bf215546Sopenharmony_civoid brw_oword_block_write_scratch(struct brw_codegen *p, 1671bf215546Sopenharmony_ci struct brw_reg mrf, 1672bf215546Sopenharmony_ci int num_regs, 1673bf215546Sopenharmony_ci unsigned offset); 1674bf215546Sopenharmony_ci 1675bf215546Sopenharmony_civoid gfx7_block_read_scratch(struct brw_codegen *p, 1676bf215546Sopenharmony_ci struct brw_reg dest, 1677bf215546Sopenharmony_ci int num_regs, 1678bf215546Sopenharmony_ci unsigned offset); 1679bf215546Sopenharmony_ci 1680bf215546Sopenharmony_ci/** 1681bf215546Sopenharmony_ci * Return the generation-specific jump distance scaling factor. 1682bf215546Sopenharmony_ci * 1683bf215546Sopenharmony_ci * Given the number of instructions to jump, we need to scale by 1684bf215546Sopenharmony_ci * some number to obtain the actual jump distance to program in an 1685bf215546Sopenharmony_ci * instruction. 1686bf215546Sopenharmony_ci */ 1687bf215546Sopenharmony_cistatic inline unsigned 1688bf215546Sopenharmony_cibrw_jump_scale(const struct intel_device_info *devinfo) 1689bf215546Sopenharmony_ci{ 1690bf215546Sopenharmony_ci /* Broadwell measures jump targets in bytes. */ 1691bf215546Sopenharmony_ci if (devinfo->ver >= 8) 1692bf215546Sopenharmony_ci return 16; 1693bf215546Sopenharmony_ci 1694bf215546Sopenharmony_ci /* Ironlake and later measure jump targets in 64-bit data chunks (in order 1695bf215546Sopenharmony_ci * (to support compaction), so each 128-bit instruction requires 2 chunks. 1696bf215546Sopenharmony_ci */ 1697bf215546Sopenharmony_ci if (devinfo->ver >= 5) 1698bf215546Sopenharmony_ci return 2; 1699bf215546Sopenharmony_ci 1700bf215546Sopenharmony_ci /* Gfx4 simply uses the number of 128-bit instructions. */ 1701bf215546Sopenharmony_ci return 1; 1702bf215546Sopenharmony_ci} 1703bf215546Sopenharmony_ci 1704bf215546Sopenharmony_civoid brw_barrier(struct brw_codegen *p, struct brw_reg src); 1705bf215546Sopenharmony_ci 1706bf215546Sopenharmony_ci/* If/else/endif. Works by manipulating the execution flags on each 1707bf215546Sopenharmony_ci * channel. 1708bf215546Sopenharmony_ci */ 1709bf215546Sopenharmony_cibrw_inst *brw_IF(struct brw_codegen *p, unsigned execute_size); 1710bf215546Sopenharmony_cibrw_inst *gfx6_IF(struct brw_codegen *p, enum brw_conditional_mod conditional, 1711bf215546Sopenharmony_ci struct brw_reg src0, struct brw_reg src1); 1712bf215546Sopenharmony_ci 1713bf215546Sopenharmony_civoid brw_ELSE(struct brw_codegen *p); 1714bf215546Sopenharmony_civoid brw_ENDIF(struct brw_codegen *p); 1715bf215546Sopenharmony_ci 1716bf215546Sopenharmony_ci/* DO/WHILE loops: 1717bf215546Sopenharmony_ci */ 1718bf215546Sopenharmony_cibrw_inst *brw_DO(struct brw_codegen *p, unsigned execute_size); 1719bf215546Sopenharmony_ci 1720bf215546Sopenharmony_cibrw_inst *brw_WHILE(struct brw_codegen *p); 1721bf215546Sopenharmony_ci 1722bf215546Sopenharmony_cibrw_inst *brw_BREAK(struct brw_codegen *p); 1723bf215546Sopenharmony_cibrw_inst *brw_CONT(struct brw_codegen *p); 1724bf215546Sopenharmony_cibrw_inst *brw_HALT(struct brw_codegen *p); 1725bf215546Sopenharmony_ci 1726bf215546Sopenharmony_ci/* Forward jumps: 1727bf215546Sopenharmony_ci */ 1728bf215546Sopenharmony_civoid brw_land_fwd_jump(struct brw_codegen *p, int jmp_insn_idx); 1729bf215546Sopenharmony_ci 1730bf215546Sopenharmony_cibrw_inst *brw_JMPI(struct brw_codegen *p, struct brw_reg index, 1731bf215546Sopenharmony_ci unsigned predicate_control); 1732bf215546Sopenharmony_ci 1733bf215546Sopenharmony_civoid brw_NOP(struct brw_codegen *p); 1734bf215546Sopenharmony_ci 1735bf215546Sopenharmony_civoid brw_WAIT(struct brw_codegen *p); 1736bf215546Sopenharmony_ci 1737bf215546Sopenharmony_civoid brw_SYNC(struct brw_codegen *p, enum tgl_sync_function func); 1738bf215546Sopenharmony_ci 1739bf215546Sopenharmony_ci/* Special case: there is never a destination, execution size will be 1740bf215546Sopenharmony_ci * taken from src0: 1741bf215546Sopenharmony_ci */ 1742bf215546Sopenharmony_civoid brw_CMP(struct brw_codegen *p, 1743bf215546Sopenharmony_ci struct brw_reg dest, 1744bf215546Sopenharmony_ci unsigned conditional, 1745bf215546Sopenharmony_ci struct brw_reg src0, 1746bf215546Sopenharmony_ci struct brw_reg src1); 1747bf215546Sopenharmony_ci 1748bf215546Sopenharmony_civoid brw_CMPN(struct brw_codegen *p, 1749bf215546Sopenharmony_ci struct brw_reg dest, 1750bf215546Sopenharmony_ci unsigned conditional, 1751bf215546Sopenharmony_ci struct brw_reg src0, 1752bf215546Sopenharmony_ci struct brw_reg src1); 1753bf215546Sopenharmony_ci 1754bf215546Sopenharmony_civoid 1755bf215546Sopenharmony_cibrw_untyped_atomic(struct brw_codegen *p, 1756bf215546Sopenharmony_ci struct brw_reg dst, 1757bf215546Sopenharmony_ci struct brw_reg payload, 1758bf215546Sopenharmony_ci struct brw_reg surface, 1759bf215546Sopenharmony_ci unsigned atomic_op, 1760bf215546Sopenharmony_ci unsigned msg_length, 1761bf215546Sopenharmony_ci bool response_expected, 1762bf215546Sopenharmony_ci bool header_present); 1763bf215546Sopenharmony_ci 1764bf215546Sopenharmony_civoid 1765bf215546Sopenharmony_cibrw_untyped_surface_read(struct brw_codegen *p, 1766bf215546Sopenharmony_ci struct brw_reg dst, 1767bf215546Sopenharmony_ci struct brw_reg payload, 1768bf215546Sopenharmony_ci struct brw_reg surface, 1769bf215546Sopenharmony_ci unsigned msg_length, 1770bf215546Sopenharmony_ci unsigned num_channels); 1771bf215546Sopenharmony_ci 1772bf215546Sopenharmony_civoid 1773bf215546Sopenharmony_cibrw_untyped_surface_write(struct brw_codegen *p, 1774bf215546Sopenharmony_ci struct brw_reg payload, 1775bf215546Sopenharmony_ci struct brw_reg surface, 1776bf215546Sopenharmony_ci unsigned msg_length, 1777bf215546Sopenharmony_ci unsigned num_channels, 1778bf215546Sopenharmony_ci bool header_present); 1779bf215546Sopenharmony_ci 1780bf215546Sopenharmony_civoid 1781bf215546Sopenharmony_cibrw_memory_fence(struct brw_codegen *p, 1782bf215546Sopenharmony_ci struct brw_reg dst, 1783bf215546Sopenharmony_ci struct brw_reg src, 1784bf215546Sopenharmony_ci enum opcode send_op, 1785bf215546Sopenharmony_ci enum brw_message_target sfid, 1786bf215546Sopenharmony_ci uint32_t desc, 1787bf215546Sopenharmony_ci bool commit_enable, 1788bf215546Sopenharmony_ci unsigned bti); 1789bf215546Sopenharmony_ci 1790bf215546Sopenharmony_civoid 1791bf215546Sopenharmony_cibrw_pixel_interpolator_query(struct brw_codegen *p, 1792bf215546Sopenharmony_ci struct brw_reg dest, 1793bf215546Sopenharmony_ci struct brw_reg mrf, 1794bf215546Sopenharmony_ci bool noperspective, 1795bf215546Sopenharmony_ci bool coarse_pixel_rate, 1796bf215546Sopenharmony_ci unsigned mode, 1797bf215546Sopenharmony_ci struct brw_reg data, 1798bf215546Sopenharmony_ci unsigned msg_length, 1799bf215546Sopenharmony_ci unsigned response_length); 1800bf215546Sopenharmony_ci 1801bf215546Sopenharmony_civoid 1802bf215546Sopenharmony_cibrw_find_live_channel(struct brw_codegen *p, 1803bf215546Sopenharmony_ci struct brw_reg dst, 1804bf215546Sopenharmony_ci bool last); 1805bf215546Sopenharmony_ci 1806bf215546Sopenharmony_civoid 1807bf215546Sopenharmony_cibrw_broadcast(struct brw_codegen *p, 1808bf215546Sopenharmony_ci struct brw_reg dst, 1809bf215546Sopenharmony_ci struct brw_reg src, 1810bf215546Sopenharmony_ci struct brw_reg idx); 1811bf215546Sopenharmony_ci 1812bf215546Sopenharmony_civoid 1813bf215546Sopenharmony_cibrw_float_controls_mode(struct brw_codegen *p, 1814bf215546Sopenharmony_ci unsigned mode, unsigned mask); 1815bf215546Sopenharmony_ci 1816bf215546Sopenharmony_civoid 1817bf215546Sopenharmony_cibrw_update_reloc_imm(const struct brw_isa_info *isa, 1818bf215546Sopenharmony_ci brw_inst *inst, 1819bf215546Sopenharmony_ci uint32_t value); 1820bf215546Sopenharmony_ci 1821bf215546Sopenharmony_civoid 1822bf215546Sopenharmony_cibrw_MOV_reloc_imm(struct brw_codegen *p, 1823bf215546Sopenharmony_ci struct brw_reg dst, 1824bf215546Sopenharmony_ci enum brw_reg_type src_type, 1825bf215546Sopenharmony_ci uint32_t id); 1826bf215546Sopenharmony_ci 1827bf215546Sopenharmony_ci/*********************************************************************** 1828bf215546Sopenharmony_ci * brw_eu_util.c: 1829bf215546Sopenharmony_ci */ 1830bf215546Sopenharmony_ci 1831bf215546Sopenharmony_civoid brw_copy_indirect_to_indirect(struct brw_codegen *p, 1832bf215546Sopenharmony_ci struct brw_indirect dst_ptr, 1833bf215546Sopenharmony_ci struct brw_indirect src_ptr, 1834bf215546Sopenharmony_ci unsigned count); 1835bf215546Sopenharmony_ci 1836bf215546Sopenharmony_civoid brw_copy_from_indirect(struct brw_codegen *p, 1837bf215546Sopenharmony_ci struct brw_reg dst, 1838bf215546Sopenharmony_ci struct brw_indirect ptr, 1839bf215546Sopenharmony_ci unsigned count); 1840bf215546Sopenharmony_ci 1841bf215546Sopenharmony_civoid brw_copy4(struct brw_codegen *p, 1842bf215546Sopenharmony_ci struct brw_reg dst, 1843bf215546Sopenharmony_ci struct brw_reg src, 1844bf215546Sopenharmony_ci unsigned count); 1845bf215546Sopenharmony_ci 1846bf215546Sopenharmony_civoid brw_copy8(struct brw_codegen *p, 1847bf215546Sopenharmony_ci struct brw_reg dst, 1848bf215546Sopenharmony_ci struct brw_reg src, 1849bf215546Sopenharmony_ci unsigned count); 1850bf215546Sopenharmony_ci 1851bf215546Sopenharmony_civoid brw_math_invert( struct brw_codegen *p, 1852bf215546Sopenharmony_ci struct brw_reg dst, 1853bf215546Sopenharmony_ci struct brw_reg src); 1854bf215546Sopenharmony_ci 1855bf215546Sopenharmony_civoid brw_set_src1(struct brw_codegen *p, brw_inst *insn, struct brw_reg reg); 1856bf215546Sopenharmony_ci 1857bf215546Sopenharmony_civoid brw_set_desc_ex(struct brw_codegen *p, brw_inst *insn, 1858bf215546Sopenharmony_ci unsigned desc, unsigned ex_desc); 1859bf215546Sopenharmony_ci 1860bf215546Sopenharmony_cistatic inline void 1861bf215546Sopenharmony_cibrw_set_desc(struct brw_codegen *p, brw_inst *insn, unsigned desc) 1862bf215546Sopenharmony_ci{ 1863bf215546Sopenharmony_ci brw_set_desc_ex(p, insn, desc, 0); 1864bf215546Sopenharmony_ci} 1865bf215546Sopenharmony_ci 1866bf215546Sopenharmony_civoid brw_set_uip_jip(struct brw_codegen *p, int start_offset); 1867bf215546Sopenharmony_ci 1868bf215546Sopenharmony_cienum brw_conditional_mod brw_negate_cmod(enum brw_conditional_mod cmod); 1869bf215546Sopenharmony_cienum brw_conditional_mod brw_swap_cmod(enum brw_conditional_mod cmod); 1870bf215546Sopenharmony_ci 1871bf215546Sopenharmony_ci/* brw_eu_compact.c */ 1872bf215546Sopenharmony_civoid brw_compact_instructions(struct brw_codegen *p, int start_offset, 1873bf215546Sopenharmony_ci struct disasm_info *disasm); 1874bf215546Sopenharmony_civoid brw_uncompact_instruction(const struct brw_isa_info *isa, 1875bf215546Sopenharmony_ci brw_inst *dst, brw_compact_inst *src); 1876bf215546Sopenharmony_cibool brw_try_compact_instruction(const struct brw_isa_info *isa, 1877bf215546Sopenharmony_ci brw_compact_inst *dst, const brw_inst *src); 1878bf215546Sopenharmony_ci 1879bf215546Sopenharmony_civoid brw_debug_compact_uncompact(const struct brw_isa_info *isa, 1880bf215546Sopenharmony_ci brw_inst *orig, brw_inst *uncompacted); 1881bf215546Sopenharmony_ci 1882bf215546Sopenharmony_ci/* brw_eu_validate.c */ 1883bf215546Sopenharmony_cibool brw_validate_instruction(const struct brw_isa_info *isa, 1884bf215546Sopenharmony_ci const brw_inst *inst, int offset, 1885bf215546Sopenharmony_ci unsigned inst_size, 1886bf215546Sopenharmony_ci struct disasm_info *disasm); 1887bf215546Sopenharmony_cibool brw_validate_instructions(const struct brw_isa_info *isa, 1888bf215546Sopenharmony_ci const void *assembly, int start_offset, int end_offset, 1889bf215546Sopenharmony_ci struct disasm_info *disasm); 1890bf215546Sopenharmony_ci 1891bf215546Sopenharmony_cistatic inline int 1892bf215546Sopenharmony_cinext_offset(const struct intel_device_info *devinfo, void *store, int offset) 1893bf215546Sopenharmony_ci{ 1894bf215546Sopenharmony_ci brw_inst *insn = (brw_inst *)((char *)store + offset); 1895bf215546Sopenharmony_ci 1896bf215546Sopenharmony_ci if (brw_inst_cmpt_control(devinfo, insn)) 1897bf215546Sopenharmony_ci return offset + 8; 1898bf215546Sopenharmony_ci else 1899bf215546Sopenharmony_ci return offset + 16; 1900bf215546Sopenharmony_ci} 1901bf215546Sopenharmony_ci 1902bf215546Sopenharmony_ci/** Maximum SEND message length */ 1903bf215546Sopenharmony_ci#define BRW_MAX_MSG_LENGTH 15 1904bf215546Sopenharmony_ci 1905bf215546Sopenharmony_ci/** First MRF register used by pull loads */ 1906bf215546Sopenharmony_ci#define FIRST_SPILL_MRF(gen) ((gen) == 6 ? 21 : 13) 1907bf215546Sopenharmony_ci 1908bf215546Sopenharmony_ci/** First MRF register used by spills */ 1909bf215546Sopenharmony_ci#define FIRST_PULL_LOAD_MRF(gen) ((gen) == 6 ? 16 : 13) 1910bf215546Sopenharmony_ci 1911bf215546Sopenharmony_ci#ifdef __cplusplus 1912bf215546Sopenharmony_ci} 1913bf215546Sopenharmony_ci#endif 1914bf215546Sopenharmony_ci 1915bf215546Sopenharmony_ci#endif 1916