X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Ftgsi%2Ftgsi_build.c;h=3db117ac3db94e4a9e47b2e5f946632cef9a0db7;hb=c9af7701d1be791752fafcbe19169851bcdf1336;hp=83f50628b407bc58ad4a9b4c209615bcc5f56bbf;hpb=3281ae96c8e38ecb0d92155ff46142d3cb4d57b7;p=mesa.git diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c index 83f50628b40..3db117ac3db 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.c +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c @@ -111,6 +111,7 @@ tgsi_default_declaration( void ) declaration.Local = 0; declaration.Array = 0; declaration.Atomic = 0; + declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL; declaration.Padding = 0; return declaration; @@ -126,6 +127,8 @@ tgsi_build_declaration( unsigned invariant, unsigned local, unsigned array, + unsigned atomic, + unsigned mem_type, struct tgsi_header *header ) { struct tgsi_declaration declaration; @@ -142,6 +145,8 @@ tgsi_build_declaration( declaration.Invariant = invariant; declaration.Local = local; declaration.Array = array; + declaration.Atomic = atomic; + declaration.MemType = mem_type; header_bodysize_grow( header ); return declaration; @@ -158,6 +163,16 @@ tgsi_default_declaration_range( void ) return dr; } +static struct tgsi_declaration_dimension +tgsi_default_declaration_dimension() +{ + struct tgsi_declaration_dimension dim; + + dim.Index2D = 0; + + return dim; +} + static struct tgsi_declaration_range tgsi_build_declaration_range( unsigned first, @@ -234,7 +249,10 @@ tgsi_default_declaration_semantic( void ) ds.Name = TGSI_SEMANTIC_POSITION; ds.Index = 0; - ds.Padding = 0; + ds.StreamX = 0; + ds.StreamY = 0; + ds.StreamZ = 0; + ds.StreamW = 0; return ds; } @@ -243,6 +261,10 @@ static struct tgsi_declaration_semantic tgsi_build_declaration_semantic( unsigned semantic_name, unsigned semantic_index, + unsigned streamx, + unsigned streamy, + unsigned streamz, + unsigned streamw, struct tgsi_declaration *declaration, struct tgsi_header *header ) { @@ -253,7 +275,10 @@ tgsi_build_declaration_semantic( ds.Name = semantic_name; ds.Index = semantic_index; - ds.Padding = 0; + ds.StreamX = streamx; + ds.StreamY = streamy; + ds.StreamZ = streamz; + ds.StreamW = streamw; declaration_grow( declaration, header ); @@ -366,6 +391,7 @@ tgsi_default_full_declaration( void ) full_declaration.Declaration = tgsi_default_declaration(); full_declaration.Range = tgsi_default_declaration_range(); + full_declaration.Dim = tgsi_default_declaration_dimension(); full_declaration.Semantic = tgsi_default_declaration_semantic(); full_declaration.Interp = tgsi_default_declaration_interp(); full_declaration.Image = tgsi_default_declaration_image(); @@ -400,6 +426,8 @@ tgsi_build_full_declaration( full_decl->Declaration.Invariant, full_decl->Declaration.Local, full_decl->Declaration.Array, + full_decl->Declaration.Atomic, + full_decl->Declaration.MemType, header ); if (maxsize <= size) @@ -454,6 +482,10 @@ tgsi_build_full_declaration( *ds = tgsi_build_declaration_semantic( full_decl->Semantic.Name, full_decl->Semantic.Index, + full_decl->Semantic.StreamX, + full_decl->Semantic.StreamY, + full_decl->Semantic.StreamZ, + full_decl->Semantic.StreamW, declaration, header ); } @@ -575,7 +607,8 @@ tgsi_build_full_immediate( struct tgsi_header *header, unsigned maxsize ) { - unsigned size = 0, i; + unsigned size = 0; + int i; struct tgsi_immediate *immediate; if( maxsize <= size ) @@ -616,21 +649,21 @@ tgsi_default_instruction( void ) instruction.NrTokens = 0; instruction.Opcode = TGSI_OPCODE_MOV; instruction.Saturate = 0; - instruction.Predicate = 0; instruction.NumDstRegs = 1; instruction.NumSrcRegs = 1; instruction.Label = 0; instruction.Texture = 0; instruction.Memory = 0; + instruction.Precise = 0; instruction.Padding = 0; return instruction; } static struct tgsi_instruction -tgsi_build_instruction(unsigned opcode, +tgsi_build_instruction(enum tgsi_opcode opcode, unsigned saturate, - unsigned predicate, + unsigned precise, unsigned num_dst_regs, unsigned num_src_regs, struct tgsi_header *header) @@ -645,7 +678,7 @@ tgsi_build_instruction(unsigned opcode, instruction = tgsi_default_instruction(); instruction.Opcode = opcode; instruction.Saturate = saturate; - instruction.Predicate = predicate; + instruction.Precise = precise; instruction.NumDstRegs = num_dst_regs; instruction.NumSrcRegs = num_src_regs; @@ -666,47 +699,6 @@ instruction_grow( header_bodysize_grow( header ); } -struct tgsi_instruction_predicate -tgsi_default_instruction_predicate(void) -{ - struct tgsi_instruction_predicate instruction_predicate; - - instruction_predicate.SwizzleX = TGSI_SWIZZLE_X; - instruction_predicate.SwizzleY = TGSI_SWIZZLE_Y; - instruction_predicate.SwizzleZ = TGSI_SWIZZLE_Z; - instruction_predicate.SwizzleW = TGSI_SWIZZLE_W; - instruction_predicate.Negate = 0; - instruction_predicate.Index = 0; - instruction_predicate.Padding = 0; - - return instruction_predicate; -} - -static struct tgsi_instruction_predicate -tgsi_build_instruction_predicate(int index, - unsigned negate, - unsigned swizzleX, - unsigned swizzleY, - unsigned swizzleZ, - unsigned swizzleW, - struct tgsi_instruction *instruction, - struct tgsi_header *header) -{ - struct tgsi_instruction_predicate instruction_predicate; - - instruction_predicate = tgsi_default_instruction_predicate(); - instruction_predicate.SwizzleX = swizzleX; - instruction_predicate.SwizzleY = swizzleY; - instruction_predicate.SwizzleZ = swizzleZ; - instruction_predicate.SwizzleW = swizzleW; - instruction_predicate.Negate = negate; - instruction_predicate.Index = index; - - instruction_grow(instruction, header); - - return instruction_predicate; -} - static struct tgsi_instruction_label tgsi_default_instruction_label( void ) { @@ -721,7 +713,6 @@ tgsi_default_instruction_label( void ) static struct tgsi_instruction_label tgsi_build_instruction_label( unsigned label, - struct tgsi_token *prev_token, struct tgsi_instruction *instruction, struct tgsi_header *header ) { @@ -743,6 +734,7 @@ tgsi_default_instruction_texture( void ) instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN; instruction_texture.NumOffsets = 0; + instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN; instruction_texture.Padding = 0; return instruction_texture; @@ -752,7 +744,7 @@ static struct tgsi_instruction_texture tgsi_build_instruction_texture( unsigned texture, unsigned num_offsets, - struct tgsi_token *prev_token, + unsigned return_type, struct tgsi_instruction *instruction, struct tgsi_header *header ) { @@ -760,6 +752,7 @@ tgsi_build_instruction_texture( instruction_texture.Texture = texture; instruction_texture.NumOffsets = num_offsets; + instruction_texture.ReturnType = return_type; instruction_texture.Padding = 0; instruction->Texture = 1; @@ -774,6 +767,8 @@ tgsi_default_instruction_memory( void ) struct tgsi_instruction_memory instruction_memory; instruction_memory.Qualifier = 0; + instruction_memory.Texture = 0; + instruction_memory.Format = 0; instruction_memory.Padding = 0; return instruction_memory; @@ -782,13 +777,16 @@ tgsi_default_instruction_memory( void ) static struct tgsi_instruction_memory tgsi_build_instruction_memory( unsigned qualifier, - struct tgsi_token *prev_token, + unsigned texture, + unsigned format, struct tgsi_instruction *instruction, struct tgsi_header *header ) { struct tgsi_instruction_memory instruction_memory; instruction_memory.Qualifier = qualifier; + instruction_memory.Texture = texture; + instruction_memory.Format = format; instruction_memory.Padding = 0; instruction->Memory = 1; @@ -815,7 +813,6 @@ tgsi_default_texture_offset( void ) static struct tgsi_texture_offset tgsi_build_texture_offset( int index, int file, int swizzle_x, int swizzle_y, int swizzle_z, - struct tgsi_token *prev_token, struct tgsi_instruction *instruction, struct tgsi_header *header ) { @@ -1039,7 +1036,6 @@ tgsi_default_full_instruction( void ) unsigned i; full_instruction.Instruction = tgsi_default_instruction(); - full_instruction.Predicate = tgsi_default_instruction_predicate(); full_instruction.Label = tgsi_default_instruction_label(); full_instruction.Texture = tgsi_default_instruction_texture(); full_instruction.Memory = tgsi_default_instruction_memory(); @@ -1066,7 +1062,6 @@ tgsi_build_full_instruction( unsigned size = 0; unsigned i; struct tgsi_instruction *instruction; - struct tgsi_token *prev_token; if( maxsize <= size ) return 0; @@ -1075,31 +1070,10 @@ tgsi_build_full_instruction( *instruction = tgsi_build_instruction(full_inst->Instruction.Opcode, full_inst->Instruction.Saturate, - full_inst->Instruction.Predicate, + full_inst->Instruction.Precise, full_inst->Instruction.NumDstRegs, full_inst->Instruction.NumSrcRegs, header); - prev_token = (struct tgsi_token *) instruction; - - if (full_inst->Instruction.Predicate) { - struct tgsi_instruction_predicate *instruction_predicate; - - if (maxsize <= size) { - return 0; - } - instruction_predicate = (struct tgsi_instruction_predicate *)&tokens[size]; - size++; - - *instruction_predicate = - tgsi_build_instruction_predicate(full_inst->Predicate.Index, - full_inst->Predicate.Negate, - full_inst->Predicate.SwizzleX, - full_inst->Predicate.SwizzleY, - full_inst->Predicate.SwizzleZ, - full_inst->Predicate.SwizzleW, - instruction, - header); - } if (full_inst->Instruction.Label) { struct tgsi_instruction_label *instruction_label; @@ -1112,10 +1086,8 @@ tgsi_build_full_instruction( *instruction_label = tgsi_build_instruction_label( full_inst->Label.Label, - prev_token, instruction, - header ); - prev_token = (struct tgsi_token *) instruction_label; + header ); } if (full_inst->Instruction.Texture) { @@ -1129,11 +1101,10 @@ tgsi_build_full_instruction( *instruction_texture = tgsi_build_instruction_texture( full_inst->Texture.Texture, - full_inst->Texture.NumOffsets, - prev_token, + full_inst->Texture.NumOffsets, + full_inst->Texture.ReturnType, instruction, header ); - prev_token = (struct tgsi_token *) instruction_texture; for (i = 0; i < full_inst->Texture.NumOffsets; i++) { struct tgsi_texture_offset *texture_offset; @@ -1148,10 +1119,8 @@ tgsi_build_full_instruction( full_inst->TexOffsets[i].SwizzleX, full_inst->TexOffsets[i].SwizzleY, full_inst->TexOffsets[i].SwizzleZ, - prev_token, instruction, header); - prev_token = (struct tgsi_token *) texture_offset; } } @@ -1166,10 +1135,10 @@ tgsi_build_full_instruction( *instruction_memory = tgsi_build_instruction_memory( full_inst->Memory.Qualifier, - prev_token, + full_inst->Memory.Texture, + full_inst->Memory.Format, instruction, header ); - prev_token = (struct tgsi_token *) instruction_memory; } for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) { @@ -1394,7 +1363,8 @@ tgsi_build_full_property( struct tgsi_header *header, unsigned maxsize ) { - unsigned size = 0, i; + unsigned size = 0; + int i; struct tgsi_property *property; if( maxsize <= size ) @@ -1424,3 +1394,18 @@ tgsi_build_full_property( return size; } + +struct tgsi_full_src_register +tgsi_full_src_register_from_dst(const struct tgsi_full_dst_register *dst) +{ + struct tgsi_full_src_register src; + src.Register = tgsi_default_src_register(); + src.Register.File = dst->Register.File; + src.Register.Indirect = dst->Register.Indirect; + src.Register.Dimension = dst->Register.Dimension; + src.Register.Index = dst->Register.Index; + src.Indirect = dst->Indirect; + src.Dimension = dst->Dimension; + src.DimIndirect = dst->DimIndirect; + return src; +}