⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brw_eu_emit.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_CMP);   insn->header.destreg__conditonalmod = conditional;   brw_set_dest(insn, dest);   brw_set_src0(insn, src0);   brw_set_src1(insn, src1);/*    guess_execution_size(insn, src0); */   /* Make it so that future instructions will use the computed flag    * value until brw_set_predicate_control_flag_value() is called    * again.      */   if (dest.file == BRW_ARCHITECTURE_REGISTER_FILE &&       dest.nr == 0) {      p->current->header.predicate_control = BRW_PREDICATE_NORMAL;      p->flag_value = 0xff;   }}/*********************************************************************** * Helpers for the various SEND message types: *//* Invert 8 values */void brw_math( struct brw_compile *p,	       struct brw_reg dest,	       GLuint function,	       GLuint saturate,	       GLuint msg_reg_nr,	       struct brw_reg src,	       GLuint data_type,	       GLuint precision ){   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);   GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1;    GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1;    /* Example code doesn't set predicate_control for send    * instructions.    */   insn->header.predicate_control = 0;    insn->header.destreg__conditonalmod = msg_reg_nr;   brw_set_dest(insn, dest);   brw_set_src0(insn, src);   brw_set_math_message(insn, 			msg_length, response_length, 			function,			BRW_MATH_INTEGER_UNSIGNED,			precision,			saturate,			data_type);}/* Use 2 send instructions to invert 16 elements */void brw_math_16( struct brw_compile *p,		  struct brw_reg dest,		  GLuint function,		  GLuint saturate,		  GLuint msg_reg_nr,		  struct brw_reg src,		  GLuint precision ){   struct brw_instruction *insn;   GLuint msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1;    GLuint response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1;    /* First instruction:    */   brw_push_insn_state(p);   brw_set_predicate_control_flag_value(p, 0xff);   brw_set_compression_control(p, BRW_COMPRESSION_NONE);   insn = next_insn(p, BRW_OPCODE_SEND);   insn->header.destreg__conditonalmod = msg_reg_nr;   brw_set_dest(insn, dest);   brw_set_src0(insn, src);   brw_set_math_message(insn, 			msg_length, response_length, 			function,			BRW_MATH_INTEGER_UNSIGNED,			precision,			saturate,			BRW_MATH_DATA_VECTOR);   /* Second instruction:    */   insn = next_insn(p, BRW_OPCODE_SEND);   insn->header.compression_control = BRW_COMPRESSION_2NDHALF;   insn->header.destreg__conditonalmod = msg_reg_nr+1;   brw_set_dest(insn, offset(dest,1));   brw_set_src0(insn, src);   brw_set_math_message(insn, 			msg_length, response_length, 			function,			BRW_MATH_INTEGER_UNSIGNED,			precision,			saturate,			BRW_MATH_DATA_VECTOR);   brw_pop_insn_state(p);}void brw_dp_WRITE_16( struct brw_compile *p,		      struct brw_reg src,		      GLuint msg_reg_nr,		      GLuint scratch_offset ){   {      brw_push_insn_state(p);      brw_set_mask_control(p, BRW_MASK_DISABLE);      brw_set_compression_control(p, BRW_COMPRESSION_NONE);      brw_MOV(p,	      retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),	      brw_imm_d(scratch_offset));			         brw_pop_insn_state(p);   }   {      GLuint msg_length = 3;      struct brw_reg dest = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW);      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);         insn->header.predicate_control = 0; /* XXX */      insn->header.compression_control = BRW_COMPRESSION_NONE;       insn->header.destreg__conditonalmod = msg_reg_nr;        brw_set_dest(insn, dest);      brw_set_src0(insn, src);      brw_set_dp_write_message(insn,			       255, /* bti */			       BRW_DATAPORT_OWORD_BLOCK_4_OWORDS, /* msg_control */			       BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE, /* msg_type */			       msg_length,			       0, /* pixel scoreboard */			       0, /* response_length */			       0); /* eot */   }}void brw_dp_READ_16( struct brw_compile *p,		      struct brw_reg dest,		      GLuint msg_reg_nr,		      GLuint scratch_offset ){   {      brw_push_insn_state(p);      brw_set_compression_control(p, BRW_COMPRESSION_NONE);      brw_set_mask_control(p, BRW_MASK_DISABLE);      brw_MOV(p,	      retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),	      brw_imm_d(scratch_offset));			         brw_pop_insn_state(p);   }   {      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);         insn->header.predicate_control = 0; /* XXX */      insn->header.compression_control = BRW_COMPRESSION_NONE;       insn->header.destreg__conditonalmod = msg_reg_nr;        brw_set_dest(insn, dest);	/* UW? */      brw_set_src0(insn, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW));      brw_set_dp_read_message(insn,			      255, /* bti */			      3,  /* msg_control */			      BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */			      1, /* target cache */			      1, /* msg_length */			      2, /* response_length */			      0); /* eot */   }}void brw_fb_WRITE(struct brw_compile *p,		   struct brw_reg dest,		   GLuint msg_reg_nr,		   struct brw_reg src0,		   GLuint binding_table_index,		   GLuint msg_length,		   GLuint response_length,		   GLboolean eot){   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);      insn->header.predicate_control = 0; /* XXX */   insn->header.compression_control = BRW_COMPRESSION_NONE;    insn->header.destreg__conditonalmod = msg_reg_nr;     brw_set_dest(insn, dest);   brw_set_src0(insn, src0);   brw_set_dp_write_message(insn,			    binding_table_index,			    BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE, /* msg_control */			    BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE, /* msg_type */			    msg_length,			    1,	/* pixel scoreboard */			    response_length, 			    eot);}void brw_SAMPLE(struct brw_compile *p,		struct brw_reg dest,		GLuint msg_reg_nr,		struct brw_reg src0,		GLuint binding_table_index,		GLuint sampler,		GLuint writemask,		GLuint msg_type,		GLuint response_length,		GLuint msg_length,		GLboolean eot){   GLboolean need_stall = 0;      if(writemask == 0) {/*       _mesa_printf("%s: zero writemask??\n", __FUNCTION__); */      return;   }      /* Hardware doesn't do destination dependency checking on send    * instructions properly.  Add a workaround which generates the    * dependency by other means.  In practice it seems like this bug    * only crops up for texture samples, and only where registers are    * written by the send and then written again later without being    * read in between.  Luckily for us, we already track that    * information and use it to modify the writemask for the    * instruction, so that is a guide for whether a workaround is    * needed.    */   if (writemask != WRITEMASK_XYZW) {      GLuint dst_offset = 0;      GLuint i, newmask = 0, len = 0;      for (i = 0; i < 4; i++) {	 if (writemask & (1<<i))	    break;	 dst_offset += 2;      }      for (; i < 4; i++) {	 if (!(writemask & (1<<i)))	    break;	 newmask |= 1<<i;	 len++;      }      if (newmask != writemask) {	 need_stall = 1;/* 	 _mesa_printf("need stall %x %x\n", newmask , writemask); */      }      else {	 struct brw_reg m1 = brw_message_reg(msg_reg_nr);	 	 newmask = ~newmask & WRITEMASK_XYZW;	 brw_push_insn_state(p);	 brw_set_compression_control(p, BRW_COMPRESSION_NONE);	 brw_set_mask_control(p, BRW_MASK_DISABLE);	 brw_MOV(p, m1, brw_vec8_grf(0,0));	   	 brw_MOV(p, get_element_ud(m1, 2), brw_imm_ud(newmask << 12)); 	 brw_pop_insn_state(p);  	 src0 = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW); 	 dest = offset(dest, dst_offset);	 response_length = len * 2;      }   }   {      struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);         insn->header.predicate_control = 0; /* XXX */      insn->header.compression_control = BRW_COMPRESSION_NONE;      insn->header.destreg__conditonalmod = msg_reg_nr;      brw_set_dest(insn, dest);      brw_set_src0(insn, src0);      brw_set_sampler_message(p->brw, insn,			      binding_table_index,			      sampler,			      msg_type,			      response_length, 			      msg_length,			      eot);   }   if (need_stall)   {      struct brw_reg reg = vec8(offset(dest, response_length-1));      /*  mov (8) r9.0<1>:f    r9.0<8;8,1>:f    { Align1 }       */      brw_push_insn_state(p);      brw_set_compression_control(p, GL_FALSE);      brw_MOV(p, reg, reg);	            brw_pop_insn_state(p);   }}/* All these variables are pretty confusing - we might be better off * using bitmasks and macros for this, in the old style.  Or perhaps * just having the caller instantiate the fields in dword3 itself. */void brw_urb_WRITE(struct brw_compile *p,		   struct brw_reg dest,		   GLuint msg_reg_nr,		   struct brw_reg src0,		   GLboolean allocate,		   GLboolean used,		   GLuint msg_length,		   GLuint response_length,		   GLboolean eot,		   GLboolean writes_complete,		   GLuint offset,		   GLuint swizzle){   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);   assert(msg_length < 16);   brw_set_dest(insn, dest);   brw_set_src0(insn, src0);   brw_set_src1(insn, brw_imm_d(0));   insn->header.destreg__conditonalmod = msg_reg_nr;   brw_set_urb_message(insn,		       allocate,		       used,		       msg_length,		       response_length, 		       eot, 		       writes_complete, 		       offset,		       swizzle);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -