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

📄 brw_eu_emit.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
/* Copyright (C) Intel Corp.  2006.  All Rights Reserved. Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to develop this 3D driver.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  **********************************************************************/ /*  * Authors:  *   Keith Whitwell <keith@tungstengraphics.com>  */     #include "brw_context.h"#include "brw_defines.h"#include "brw_eu.h"/*********************************************************************** * Internal helper for constructing instructions */static void guess_execution_size( struct brw_instruction *insn,				  struct brw_reg reg ){   if (reg.width == BRW_WIDTH_8 &&        insn->header.compression_control == BRW_COMPRESSION_COMPRESSED)       insn->header.execution_size = BRW_EXECUTE_16;   else      insn->header.execution_size = reg.width;	/* note - definitions are compatible */}static void brw_set_dest( struct brw_instruction *insn,			  struct brw_reg dest ){   insn->bits1.da1.dest_reg_file = dest.file;   insn->bits1.da1.dest_reg_type = dest.type;   insn->bits1.da1.dest_address_mode = dest.address_mode;   if (dest.address_mode == BRW_ADDRESS_DIRECT) {         insn->bits1.da1.dest_reg_nr = dest.nr;      if (insn->header.access_mode == BRW_ALIGN_1) {	 insn->bits1.da1.dest_subreg_nr = dest.subnr;	 insn->bits1.da1.dest_horiz_stride = BRW_HORIZONTAL_STRIDE_1;      }      else {	 insn->bits1.da16.dest_subreg_nr = dest.subnr / 16;	 insn->bits1.da16.dest_writemask = dest.dw1.bits.writemask;      }   }   else {      insn->bits1.ia1.dest_subreg_nr = dest.subnr;      /* These are different sizes in align1 vs align16:       */      if (insn->header.access_mode == BRW_ALIGN_1) {	 insn->bits1.ia1.dest_indirect_offset = dest.dw1.bits.indirect_offset;	 insn->bits1.ia1.dest_horiz_stride = BRW_HORIZONTAL_STRIDE_1;      }      else {	 insn->bits1.ia16.dest_indirect_offset = dest.dw1.bits.indirect_offset;      }   }   /* NEW: Set the execution size based on dest.width and    * insn->compression_control:    */   guess_execution_size(insn, dest);}static void brw_set_src0( struct brw_instruction *insn,		      struct brw_reg reg ){   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);   insn->bits1.da1.src0_reg_file = reg.file;   insn->bits1.da1.src0_reg_type = reg.type;   insn->bits2.da1.src0_abs = reg.abs;   insn->bits2.da1.src0_negate = reg.negate;   insn->bits2.da1.src0_address_mode = reg.address_mode;   if (reg.file == BRW_IMMEDIATE_VALUE) {      insn->bits3.ud = reg.dw1.ud;         /* Required to set some fields in src1 as well:       */      insn->bits1.da1.src1_reg_file = 0; /* arf */      insn->bits1.da1.src1_reg_type = reg.type;   }   else    {      if (reg.address_mode == BRW_ADDRESS_DIRECT) {	 if (insn->header.access_mode == BRW_ALIGN_1) {	    insn->bits2.da1.src0_subreg_nr = reg.subnr;	    insn->bits2.da1.src0_reg_nr = reg.nr;	 }	 else {	    insn->bits2.da16.src0_subreg_nr = reg.subnr / 16;	    insn->bits2.da16.src0_reg_nr = reg.nr;	 }      }      else {	 insn->bits2.ia1.src0_subreg_nr = reg.subnr;	 if (insn->header.access_mode == BRW_ALIGN_1) {	    insn->bits2.ia1.src0_indirect_offset = reg.dw1.bits.indirect_offset; 	 }	 else {	    insn->bits2.ia16.src0_subreg_nr = reg.dw1.bits.indirect_offset;	 }      }      if (insn->header.access_mode == BRW_ALIGN_1) {	 if (reg.width == BRW_WIDTH_1 && 	     insn->header.execution_size == BRW_EXECUTE_1) {	    insn->bits2.da1.src0_horiz_stride = BRW_HORIZONTAL_STRIDE_0;	    insn->bits2.da1.src0_width = BRW_WIDTH_1;	    insn->bits2.da1.src0_vert_stride = BRW_VERTICAL_STRIDE_0;	 }	 else {	    insn->bits2.da1.src0_horiz_stride = reg.hstride;	    insn->bits2.da1.src0_width = reg.width;	    insn->bits2.da1.src0_vert_stride = reg.vstride;	 }      }      else {	 insn->bits2.da16.src0_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);	 insn->bits2.da16.src0_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);	 insn->bits2.da16.src0_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);	 insn->bits2.da16.src0_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);	 /* This is an oddity of the fact we're using the same	  * descriptions for registers in align_16 as align_1:	  */	 if (reg.vstride == BRW_VERTICAL_STRIDE_8)	    insn->bits2.da16.src0_vert_stride = BRW_VERTICAL_STRIDE_4;	 else	    insn->bits2.da16.src0_vert_stride = reg.vstride;      }   }}void brw_set_src1( struct brw_instruction *insn,			  struct brw_reg reg ){   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);   insn->bits1.da1.src1_reg_file = reg.file;   insn->bits1.da1.src1_reg_type = reg.type;   insn->bits3.da1.src1_abs = reg.abs;   insn->bits3.da1.src1_negate = reg.negate;   /* Only src1 can be immediate in two-argument instructions.    */   assert(insn->bits1.da1.src0_reg_file != BRW_IMMEDIATE_VALUE);   if (reg.file == BRW_IMMEDIATE_VALUE) {      insn->bits3.ud = reg.dw1.ud;   }   else {      /* This is a hardware restriction, which may or may not be lifted       * in the future:       */      assert (reg.address_mode == BRW_ADDRESS_DIRECT);      //assert (reg.file == BRW_GENERAL_REGISTER_FILE);      if (insn->header.access_mode == BRW_ALIGN_1) {	 insn->bits3.da1.src1_subreg_nr = reg.subnr;	 insn->bits3.da1.src1_reg_nr = reg.nr;      }      else {	 insn->bits3.da16.src1_subreg_nr = reg.subnr / 16;	 insn->bits3.da16.src1_reg_nr = reg.nr;      }      if (insn->header.access_mode == BRW_ALIGN_1) {	 if (reg.width == BRW_WIDTH_1 && 	     insn->header.execution_size == BRW_EXECUTE_1) {	    insn->bits3.da1.src1_horiz_stride = BRW_HORIZONTAL_STRIDE_0;	    insn->bits3.da1.src1_width = BRW_WIDTH_1;	    insn->bits3.da1.src1_vert_stride = BRW_VERTICAL_STRIDE_0;	 }	 else {	    insn->bits3.da1.src1_horiz_stride = reg.hstride;	    insn->bits3.da1.src1_width = reg.width;	    insn->bits3.da1.src1_vert_stride = reg.vstride;	 }      }      else {	 insn->bits3.da16.src1_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);	 insn->bits3.da16.src1_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);	 insn->bits3.da16.src1_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);	 insn->bits3.da16.src1_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);	 /* This is an oddity of the fact we're using the same	  * descriptions for registers in align_16 as align_1:	  */	 if (reg.vstride == BRW_VERTICAL_STRIDE_8)	    insn->bits3.da16.src1_vert_stride = BRW_VERTICAL_STRIDE_4;	 else	    insn->bits3.da16.src1_vert_stride = reg.vstride;      }   }}static void brw_set_math_message( struct brw_instruction *insn,				  GLuint msg_length,				  GLuint response_length,				  GLuint function,				  GLuint integer_type,				  GLboolean low_precision,				  GLboolean saturate,				  GLuint dataType ){   brw_set_src1(insn, brw_imm_d(0));   insn->bits3.math.function = function;   insn->bits3.math.int_type = integer_type;   insn->bits3.math.precision = low_precision;   insn->bits3.math.saturate = saturate;   insn->bits3.math.data_type = dataType;   insn->bits3.math.response_length = response_length;   insn->bits3.math.msg_length = msg_length;   insn->bits3.math.msg_target = BRW_MESSAGE_TARGET_MATH;   insn->bits3.math.end_of_thread = 0;}static void brw_set_urb_message( struct brw_instruction *insn,				 GLboolean allocate,				 GLboolean used,				 GLuint msg_length,				 GLuint response_length,				 GLboolean end_of_thread,				 GLboolean complete,				 GLuint offset,				 GLuint swizzle_control ){   brw_set_src1(insn, brw_imm_d(0));   insn->bits3.urb.opcode = 0;	/* ? */   insn->bits3.urb.offset = offset;   insn->bits3.urb.swizzle_control = swizzle_control;   insn->bits3.urb.allocate = allocate;   insn->bits3.urb.used = used;	/* ? */   insn->bits3.urb.complete = complete;   insn->bits3.urb.response_length = response_length;   insn->bits3.urb.msg_length = msg_length;   insn->bits3.urb.msg_target = BRW_MESSAGE_TARGET_URB;   insn->bits3.urb.end_of_thread = end_of_thread;}static void brw_set_dp_write_message( struct brw_instruction *insn,				      GLuint binding_table_index,				      GLuint msg_control,				      GLuint msg_type,				      GLuint msg_length,				      GLuint pixel_scoreboard_clear,				      GLuint response_length,				      GLuint end_of_thread ){   brw_set_src1(insn, brw_imm_d(0));   insn->bits3.dp_write.binding_table_index = binding_table_index;   insn->bits3.dp_write.msg_control = msg_control;   insn->bits3.dp_write.pixel_scoreboard_clear = pixel_scoreboard_clear;   insn->bits3.dp_write.msg_type = msg_type;   insn->bits3.dp_write.send_commit_msg = 0;   insn->bits3.dp_write.response_length = response_length;   insn->bits3.dp_write.msg_length = msg_length;   insn->bits3.dp_write.msg_target = BRW_MESSAGE_TARGET_DATAPORT_WRITE;   insn->bits3.urb.end_of_thread = end_of_thread;}static void brw_set_dp_read_message( struct brw_instruction *insn,				      GLuint binding_table_index,				      GLuint msg_control,				      GLuint msg_type,				      GLuint target_cache,				      GLuint msg_length,				      GLuint response_length,				      GLuint end_of_thread ){   brw_set_src1(insn, brw_imm_d(0));   insn->bits3.dp_read.binding_table_index = binding_table_index;   insn->bits3.dp_read.msg_control = msg_control;   insn->bits3.dp_read.msg_type = msg_type;   insn->bits3.dp_read.target_cache = target_cache;   insn->bits3.dp_read.response_length = response_length;   insn->bits3.dp_read.msg_length = msg_length;   insn->bits3.dp_read.msg_target = BRW_MESSAGE_TARGET_DATAPORT_READ;   insn->bits3.dp_read.end_of_thread = end_of_thread;}static void brw_set_sampler_message(struct brw_context *brw,                 struct brw_instruction *insn,				     GLuint binding_table_index,				     GLuint sampler,				     GLuint msg_type,				     GLuint response_length,				     GLuint msg_length,				     GLboolean eot){   brw_set_src1(insn, brw_imm_d(0));   if (BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) {      insn->bits3.sampler_gm45_g4x.binding_table_index = binding_table_index;      insn->bits3.sampler_gm45_g4x.sampler = sampler;      insn->bits3.sampler_gm45_g4x.msg_type = msg_type;      insn->bits3.sampler_gm45_g4x.response_length = response_length;      insn->bits3.sampler_gm45_g4x.msg_length = msg_length;      insn->bits3.sampler_gm45_g4x.end_of_thread = eot;      insn->bits3.sampler_gm45_g4x.msg_target = BRW_MESSAGE_TARGET_SAMPLER;   } else {      insn->bits3.sampler.binding_table_index = binding_table_index;      insn->bits3.sampler.sampler = sampler;      insn->bits3.sampler.msg_type = msg_type;      insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;      insn->bits3.sampler.response_length = response_length;      insn->bits3.sampler.msg_length = msg_length;      insn->bits3.sampler.end_of_thread = eot;      insn->bits3.sampler.msg_target = BRW_MESSAGE_TARGET_SAMPLER;   }}static struct brw_instruction *next_insn( struct brw_compile *p, 					  GLuint opcode ){   struct brw_instruction *insn;   assert(p->nr_insn + 1 < BRW_EU_MAX_INSN);   insn = &p->store[p->nr_insn++];   memcpy(insn, p->current, sizeof(*insn));   /* Reset this one-shot flag:     */

⌨️ 快捷键说明

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