+struct tgsi_full_instruction
+tgsi_default_full_instruction( void )
+{
+ struct tgsi_full_instruction full_instruction;
+ unsigned i;
+
+ full_instruction.Instruction = tgsi_default_instruction();
+ full_instruction.Label = tgsi_default_instruction_label();
+ full_instruction.Texture = tgsi_default_instruction_texture();
+ full_instruction.Memory = tgsi_default_instruction_memory();
+ for( i = 0; i < TGSI_FULL_MAX_TEX_OFFSETS; i++ ) {
+ full_instruction.TexOffsets[i] = tgsi_default_texture_offset();
+ }
+ for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
+ full_instruction.Dst[i] = tgsi_default_full_dst_register();
+ }
+ for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) {
+ full_instruction.Src[i] = tgsi_default_full_src_register();
+ }
+
+ return full_instruction;
+}
+
+unsigned
+tgsi_build_full_instruction(
+ const struct tgsi_full_instruction *full_inst,
+ struct tgsi_token *tokens,
+ struct tgsi_header *header,
+ unsigned maxsize )
+{
+ unsigned size = 0;
+ unsigned i;
+ struct tgsi_instruction *instruction;
+
+ if( maxsize <= size )
+ return 0;
+ instruction = (struct tgsi_instruction *) &tokens[size];
+ size++;
+
+ *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode,
+ full_inst->Instruction.Saturate,
+ full_inst->Instruction.Precise,
+ full_inst->Instruction.NumDstRegs,
+ full_inst->Instruction.NumSrcRegs,
+ header);
+
+ if (full_inst->Instruction.Label) {
+ struct tgsi_instruction_label *instruction_label;
+
+ if( maxsize <= size )
+ return 0;
+ instruction_label =
+ (struct tgsi_instruction_label *) &tokens[size];
+ size++;
+
+ *instruction_label = tgsi_build_instruction_label(
+ full_inst->Label.Label,
+ instruction,
+ header );
+ }
+
+ if (full_inst->Instruction.Texture) {
+ struct tgsi_instruction_texture *instruction_texture;
+
+ if( maxsize <= size )
+ return 0;
+ instruction_texture =
+ (struct tgsi_instruction_texture *) &tokens[size];
+ size++;
+
+ *instruction_texture = tgsi_build_instruction_texture(
+ full_inst->Texture.Texture,
+ full_inst->Texture.NumOffsets,
+ full_inst->Texture.ReturnType,
+ instruction,
+ header );
+
+ for (i = 0; i < full_inst->Texture.NumOffsets; i++) {
+ struct tgsi_texture_offset *texture_offset;
+
+ if ( maxsize <= size )
+ return 0;
+ texture_offset = (struct tgsi_texture_offset *)&tokens[size];
+ size++;
+ *texture_offset = tgsi_build_texture_offset(
+ full_inst->TexOffsets[i].Index,
+ full_inst->TexOffsets[i].File,
+ full_inst->TexOffsets[i].SwizzleX,
+ full_inst->TexOffsets[i].SwizzleY,
+ full_inst->TexOffsets[i].SwizzleZ,
+ instruction,
+ header);
+ }
+ }
+
+ if (full_inst->Instruction.Memory) {
+ struct tgsi_instruction_memory *instruction_memory;
+
+ if( maxsize <= size )
+ return 0;
+ instruction_memory =
+ (struct tgsi_instruction_memory *) &tokens[size];
+ size++;
+
+ *instruction_memory = tgsi_build_instruction_memory(
+ full_inst->Memory.Qualifier,
+ full_inst->Memory.Texture,
+ full_inst->Memory.Format,
+ instruction,
+ header );
+ }
+
+ for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) {
+ const struct tgsi_full_dst_register *reg = &full_inst->Dst[i];
+ struct tgsi_dst_register *dst_register;
+
+ if( maxsize <= size )
+ return 0;
+ dst_register = (struct tgsi_dst_register *) &tokens[size];
+ size++;
+
+ *dst_register = tgsi_build_dst_register(
+ reg->Register.File,
+ reg->Register.WriteMask,
+ reg->Register.Indirect,
+ reg->Register.Dimension,
+ reg->Register.Index,
+ instruction,
+ header );
+
+ if( reg->Register.Indirect ) {
+ struct tgsi_ind_register *ind;
+
+ if( maxsize <= size )
+ return 0;
+ ind = (struct tgsi_ind_register *) &tokens[size];
+ size++;
+
+ *ind = tgsi_build_ind_register(
+ reg->Indirect.File,
+ reg->Indirect.Swizzle,
+ reg->Indirect.Index,
+ reg->Indirect.ArrayID,
+ instruction,
+ header );
+ }
+
+ if( reg->Register.Dimension ) {
+ struct tgsi_dimension *dim;
+
+ assert( !reg->Dimension.Dimension );
+
+ if( maxsize <= size )
+ return 0;
+ dim = (struct tgsi_dimension *) &tokens[size];
+ size++;
+
+ *dim = tgsi_build_dimension(
+ reg->Dimension.Indirect,
+ reg->Dimension.Index,
+ instruction,
+ header );
+
+ if( reg->Dimension.Indirect ) {
+ struct tgsi_ind_register *ind;
+
+ if( maxsize <= size )
+ return 0;
+ ind = (struct tgsi_ind_register *) &tokens[size];
+ size++;
+
+ *ind = tgsi_build_ind_register(
+ reg->DimIndirect.File,
+ reg->DimIndirect.Swizzle,
+ reg->DimIndirect.Index,
+ reg->DimIndirect.ArrayID,
+ instruction,
+ header );
+ }
+ }
+ }
+
+ for( i = 0; i < full_inst->Instruction.NumSrcRegs; i++ ) {
+ const struct tgsi_full_src_register *reg = &full_inst->Src[i];
+ struct tgsi_src_register *src_register;
+
+ if( maxsize <= size )
+ return 0;
+ src_register = (struct tgsi_src_register *) &tokens[size];
+ size++;
+
+ *src_register = tgsi_build_src_register(
+ reg->Register.File,
+ reg->Register.SwizzleX,
+ reg->Register.SwizzleY,
+ reg->Register.SwizzleZ,
+ reg->Register.SwizzleW,
+ reg->Register.Negate,
+ reg->Register.Absolute,
+ reg->Register.Indirect,
+ reg->Register.Dimension,
+ reg->Register.Index,
+ instruction,
+ header );
+
+ if( reg->Register.Indirect ) {
+ struct tgsi_ind_register *ind;
+
+ if( maxsize <= size )
+ return 0;
+ ind = (struct tgsi_ind_register *) &tokens[size];
+ size++;
+
+ *ind = tgsi_build_ind_register(
+ reg->Indirect.File,
+ reg->Indirect.Swizzle,
+ reg->Indirect.Index,
+ reg->Indirect.ArrayID,
+ instruction,
+ header );
+ }
+
+ if( reg->Register.Dimension ) {
+ struct tgsi_dimension *dim;
+
+ assert( !reg->Dimension.Dimension );
+
+ if( maxsize <= size )
+ return 0;
+ dim = (struct tgsi_dimension *) &tokens[size];
+ size++;
+
+ *dim = tgsi_build_dimension(
+ reg->Dimension.Indirect,
+ reg->Dimension.Index,
+ instruction,
+ header );
+
+ if( reg->Dimension.Indirect ) {
+ struct tgsi_ind_register *ind;
+
+ if( maxsize <= size )
+ return 0;
+ ind = (struct tgsi_ind_register *) &tokens[size];
+ size++;
+
+ *ind = tgsi_build_ind_register(
+ reg->DimIndirect.File,
+ reg->DimIndirect.Swizzle,
+ reg->DimIndirect.Index,
+ reg->DimIndirect.ArrayID,
+ instruction,
+ header );
+ }
+ }
+ }
+
+ return size;
+}
+
+static struct tgsi_property