static boolean iter_instruction( struct tgsi_iterate_context *iter, struct tgsi_full_instruction *inst ) { struct dump_ctx *ctx = (struct dump_ctx *) iter; uint instno = ctx->instno++; const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode ); uint i; boolean first_reg = TRUE; INSTID( instno ); TXT( ": " ); ctx->indent -= info->pre_dedent; for(i = 0; (int)i < ctx->indent; ++i) TXT( " " ); ctx->indent += info->post_indent; if (inst->Instruction.Predicate) { CHR( '(' ); if (inst->Predicate.Negate) CHR( '!' ); TXT( "PRED[" ); SID( inst->Predicate.Index ); CHR( ']' ); if (inst->Predicate.SwizzleX != TGSI_SWIZZLE_X || inst->Predicate.SwizzleY != TGSI_SWIZZLE_Y || inst->Predicate.SwizzleZ != TGSI_SWIZZLE_Z || inst->Predicate.SwizzleW != TGSI_SWIZZLE_W) { CHR( '.' ); ENM( inst->Predicate.SwizzleX, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleY, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleZ, tgsi_swizzle_names ); ENM( inst->Predicate.SwizzleW, tgsi_swizzle_names ); } TXT( ") " ); } TXT( info->mnemonic ); switch (inst->Instruction.Saturate) { case TGSI_SAT_NONE: break; case TGSI_SAT_ZERO_ONE: TXT( "_SAT" ); break; case TGSI_SAT_MINUS_PLUS_ONE: TXT( "_SATNV" ); break; default: assert( 0 ); } for (i = 0; i < inst->Instruction.NumDstRegs; i++) { const struct tgsi_full_dst_register *dst = &inst->Dst[i]; if (!first_reg) CHR( ',' ); CHR( ' ' ); _dump_register_dst( ctx, dst ); _dump_writemask( ctx, dst->Register.WriteMask ); first_reg = FALSE; } for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { const struct tgsi_full_src_register *src = &inst->Src[i]; if (!first_reg) CHR( ',' ); CHR( ' ' ); if (src->Register.Negate) CHR( '-' ); if (src->Register.Absolute) CHR( '|' ); _dump_register_src(ctx, src); if (src->Register.SwizzleX != TGSI_SWIZZLE_X || src->Register.SwizzleY != TGSI_SWIZZLE_Y || src->Register.SwizzleZ != TGSI_SWIZZLE_Z || src->Register.SwizzleW != TGSI_SWIZZLE_W) { CHR( '.' ); ENM( src->Register.SwizzleX, tgsi_swizzle_names ); ENM( src->Register.SwizzleY, tgsi_swizzle_names ); ENM( src->Register.SwizzleZ, tgsi_swizzle_names ); ENM( src->Register.SwizzleW, tgsi_swizzle_names ); } if (src->Register.Absolute) CHR( '|' ); first_reg = FALSE; } if (inst->Instruction.Texture) { TXT( ", " ); ENM( inst->Texture.Texture, tgsi_texture_names ); for (i = 0; i < inst->Texture.NumOffsets; i++) { TXT( ", " ); ENM( inst->TexOffsets[i].File, tgsi_file_names); CHR( '[' ); SID( inst->TexOffsets[i].Index ); CHR( ']' ); CHR( '.' ); ENM( inst->TexOffsets[i].SwizzleX, tgsi_swizzle_names); ENM( inst->TexOffsets[i].SwizzleY, tgsi_swizzle_names); ENM( inst->TexOffsets[i].SwizzleZ, tgsi_swizzle_names); } } switch (inst->Instruction.Opcode) { case TGSI_OPCODE_IF: case TGSI_OPCODE_UIF: case TGSI_OPCODE_ELSE: case TGSI_OPCODE_BGNLOOP: case TGSI_OPCODE_ENDLOOP: case TGSI_OPCODE_CAL: TXT( " :" ); UID( inst->Label.Label ); break; } /* update indentation */ if (inst->Instruction.Opcode == TGSI_OPCODE_IF || inst->Instruction.Opcode == TGSI_OPCODE_UIF || inst->Instruction.Opcode == TGSI_OPCODE_ELSE || inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) { ctx->indentation += indent_spaces; } EOL(); return TRUE; }
void tgsi_dump_c( const struct tgsi_token *tokens, uint flags ) { struct tgsi_parse_context parse; struct tgsi_full_instruction fi; struct tgsi_full_declaration fd; uint ignored = flags & TGSI_DUMP_C_IGNORED; uint deflt = flags & TGSI_DUMP_C_DEFAULT; uint instno = 0; tgsi_parse_init( &parse, tokens ); TXT( "tgsi-dump begin -----------------" ); TXT( "\nMajorVersion: " ); UID( parse.FullVersion.Version.MajorVersion ); TXT( "\nMinorVersion: " ); UID( parse.FullVersion.Version.MinorVersion ); EOL(); TXT( "\nHeaderSize: " ); UID( parse.FullHeader.Header.HeaderSize ); TXT( "\nBodySize : " ); UID( parse.FullHeader.Header.BodySize ); TXT( "\nProcessor : " ); ENM( parse.FullHeader.Processor.Processor, TGSI_PROCESSOR_TYPES ); EOL(); fi = tgsi_default_full_instruction(); fd = tgsi_default_full_declaration(); while( !tgsi_parse_end_of_tokens( &parse ) ) { tgsi_parse_token( &parse ); TXT( "\nType : " ); ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES ); if( ignored ) { TXT( "\nSize : " ); UID( parse.FullToken.Token.Size ); if( deflt || parse.FullToken.Token.Extended ) { TXT( "\nExtended : " ); UID( parse.FullToken.Token.Extended ); } } switch( parse.FullToken.Token.Type ) { case TGSI_TOKEN_TYPE_DECLARATION: dump_declaration_verbose( &parse.FullToken.FullDeclaration, ignored, deflt, &fd ); break; case TGSI_TOKEN_TYPE_IMMEDIATE: dump_immediate_verbose( &parse.FullToken.FullImmediate, ignored ); break; case TGSI_TOKEN_TYPE_INSTRUCTION: dump_instruction_verbose( &parse.FullToken.FullInstruction, ignored, deflt, &fi ); break; default: assert( 0 ); } EOL(); } TXT( "\ntgsi-dump end -------------------\n" ); tgsi_parse_free( &parse ); }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; TXT( "DCL " ); ENM(decl->Declaration.File, tgsi_file_names); /* all geometry shader inputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Array) { TXT( ", ARRAY(" ); SID(decl->Array.ArrayID); CHR(')'); } if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_RESOURCE) { TXT(", "); ENM(decl->Resource.Resource, tgsi_texture_names); if (decl->Resource.Writable) TXT(", WR"); if (decl->Resource.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Centroid) { TXT( ", CENTROID" ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } EOL(); return TRUE; }
bool operator!=( const T &t ) const { const std::string &self = *this; return self != (std::string)UID(t); }
static void dump_instruction_verbose( struct tgsi_full_instruction *inst, unsigned ignored, unsigned deflt, struct tgsi_full_instruction *fi ) { unsigned i; TXT( "\nOpcode : OPCODE_" ); TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic ); if( deflt || fi->Instruction.Saturate != inst->Instruction.Saturate ) { TXT( "\nSaturate : " ); ENM( inst->Instruction.Saturate, TGSI_SATS ); } if( deflt || fi->Instruction.NumDstRegs != inst->Instruction.NumDstRegs ) { TXT( "\nNumDstRegs : " ); UID( inst->Instruction.NumDstRegs ); } if( deflt || fi->Instruction.NumSrcRegs != inst->Instruction.NumSrcRegs ) { TXT( "\nNumSrcRegs : " ); UID( inst->Instruction.NumSrcRegs ); } if( ignored ) { TXT( "\nPadding : " ); UIX( inst->Instruction.Padding ); } if( deflt || tgsi_compare_instruction_ext_nv( inst->InstructionExtNv, fi->InstructionExtNv ) ) { EOL(); TXT( "\nType : " ); ENM( inst->InstructionExtNv.Type, TGSI_INSTRUCTION_EXTS ); if( deflt || fi->InstructionExtNv.Precision != inst->InstructionExtNv.Precision ) { TXT( "\nPrecision : " ); ENM( inst->InstructionExtNv.Precision, TGSI_PRECISIONS ); } if( deflt || fi->InstructionExtNv.CondDstIndex != inst->InstructionExtNv.CondDstIndex ) { TXT( "\nCondDstIndex : " ); UID( inst->InstructionExtNv.CondDstIndex ); } if( deflt || fi->InstructionExtNv.CondFlowIndex != inst->InstructionExtNv.CondFlowIndex ) { TXT( "\nCondFlowIndex : " ); UID( inst->InstructionExtNv.CondFlowIndex ); } if( deflt || fi->InstructionExtNv.CondMask != inst->InstructionExtNv.CondMask ) { TXT( "\nCondMask : " ); ENM( inst->InstructionExtNv.CondMask, TGSI_CCS ); } if( deflt || fi->InstructionExtNv.CondSwizzleX != inst->InstructionExtNv.CondSwizzleX ) { TXT( "\nCondSwizzleX : " ); ENM( inst->InstructionExtNv.CondSwizzleX, TGSI_SWIZZLES ); } if( deflt || fi->InstructionExtNv.CondSwizzleY != inst->InstructionExtNv.CondSwizzleY ) { TXT( "\nCondSwizzleY : " ); ENM( inst->InstructionExtNv.CondSwizzleY, TGSI_SWIZZLES ); } if( deflt || fi->InstructionExtNv.CondSwizzleZ != inst->InstructionExtNv.CondSwizzleZ ) { TXT( "\nCondSwizzleZ : " ); ENM( inst->InstructionExtNv.CondSwizzleZ, TGSI_SWIZZLES ); } if( deflt || fi->InstructionExtNv.CondSwizzleW != inst->InstructionExtNv.CondSwizzleW ) { TXT( "\nCondSwizzleW : " ); ENM( inst->InstructionExtNv.CondSwizzleW, TGSI_SWIZZLES ); } if( deflt || fi->InstructionExtNv.CondDstUpdate != inst->InstructionExtNv.CondDstUpdate ) { TXT( "\nCondDstUpdate : " ); UID( inst->InstructionExtNv.CondDstUpdate ); } if( deflt || fi->InstructionExtNv.CondFlowEnable != inst->InstructionExtNv.CondFlowEnable ) { TXT( "\nCondFlowEnable: " ); UID( inst->InstructionExtNv.CondFlowEnable ); } if( ignored ) { TXT( "\nPadding : " ); UIX( inst->InstructionExtNv.Padding ); if( deflt || fi->InstructionExtNv.Extended != inst->InstructionExtNv.Extended ) { TXT( "\nExtended : " ); UID( inst->InstructionExtNv.Extended ); } } } if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi->InstructionExtLabel ) ) { EOL(); TXT( "\nType : " ); ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS ); if( deflt || fi->InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) { TXT( "\nLabel : " ); UID( inst->InstructionExtLabel.Label ); } if( ignored ) { TXT( "\nPadding : " ); UIX( inst->InstructionExtLabel.Padding ); if( deflt || fi->InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) { TXT( "\nExtended: " ); UID( inst->InstructionExtLabel.Extended ); } } } if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi->InstructionExtTexture ) ) { EOL(); TXT( "\nType : " ); ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS ); if( deflt || fi->InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) { TXT( "\nTexture : " ); ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES ); } if( ignored ) { TXT( "\nPadding : " ); UIX( inst->InstructionExtTexture.Padding ); if( deflt || fi->InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) { TXT( "\nExtended: " ); UID( inst->InstructionExtTexture.Extended ); } } } for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) { struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i]; struct tgsi_full_dst_register *fd = &fi->FullDstRegisters[i]; EOL(); TXT( "\nFile : " ); ENM( dst->DstRegister.File, TGSI_FILES ); if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) { TXT( "\nWriteMask: " ); ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS ); } if( ignored ) { if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) { TXT( "\nIndirect : " ); UID( dst->DstRegister.Indirect ); } if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) { TXT( "\nDimension: " ); UID( dst->DstRegister.Dimension ); } } if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) { TXT( "\nIndex : " ); SID( dst->DstRegister.Index ); } if( ignored ) { TXT( "\nPadding : " ); UIX( dst->DstRegister.Padding ); if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) { TXT( "\nExtended : " ); UID( dst->DstRegister.Extended ); } } if( deflt || tgsi_compare_dst_register_ext_concode( dst->DstRegisterExtConcode, fd->DstRegisterExtConcode ) ) { EOL(); TXT( "\nType : " ); ENM( dst->DstRegisterExtConcode.Type, TGSI_DST_REGISTER_EXTS ); if( deflt || fd->DstRegisterExtConcode.CondMask != dst->DstRegisterExtConcode.CondMask ) { TXT( "\nCondMask : " ); ENM( dst->DstRegisterExtConcode.CondMask, TGSI_CCS ); } if( deflt || fd->DstRegisterExtConcode.CondSwizzleX != dst->DstRegisterExtConcode.CondSwizzleX ) { TXT( "\nCondSwizzleX: " ); ENM( dst->DstRegisterExtConcode.CondSwizzleX, TGSI_SWIZZLES ); } if( deflt || fd->DstRegisterExtConcode.CondSwizzleY != dst->DstRegisterExtConcode.CondSwizzleY ) { TXT( "\nCondSwizzleY: " ); ENM( dst->DstRegisterExtConcode.CondSwizzleY, TGSI_SWIZZLES ); } if( deflt || fd->DstRegisterExtConcode.CondSwizzleZ != dst->DstRegisterExtConcode.CondSwizzleZ ) { TXT( "\nCondSwizzleZ: " ); ENM( dst->DstRegisterExtConcode.CondSwizzleZ, TGSI_SWIZZLES ); } if( deflt || fd->DstRegisterExtConcode.CondSwizzleW != dst->DstRegisterExtConcode.CondSwizzleW ) { TXT( "\nCondSwizzleW: " ); ENM( dst->DstRegisterExtConcode.CondSwizzleW, TGSI_SWIZZLES ); } if( deflt || fd->DstRegisterExtConcode.CondSrcIndex != dst->DstRegisterExtConcode.CondSrcIndex ) { TXT( "\nCondSrcIndex: " ); UID( dst->DstRegisterExtConcode.CondSrcIndex ); } if( ignored ) { TXT( "\nPadding : " ); UIX( dst->DstRegisterExtConcode.Padding ); if( deflt || fd->DstRegisterExtConcode.Extended != dst->DstRegisterExtConcode.Extended ) { TXT( "\nExtended : " ); UID( dst->DstRegisterExtConcode.Extended ); } } } if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) { EOL(); TXT( "\nType : " ); ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS ); if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) { TXT( "\nModulate: " ); ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES ); } if( ignored ) { TXT( "\nPadding : " ); UIX( dst->DstRegisterExtModulate.Padding ); if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) { TXT( "\nExtended: " ); UID( dst->DstRegisterExtModulate.Extended ); } } } } for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) { struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i]; struct tgsi_full_src_register *fs = &fi->FullSrcRegisters[i]; EOL(); TXT( "\nFile : "); ENM( src->SrcRegister.File, TGSI_FILES ); if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) { TXT( "\nSwizzleX : " ); ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES ); } if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) { TXT( "\nSwizzleY : " ); ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES ); } if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) { TXT( "\nSwizzleZ : " ); ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES ); } if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) { TXT( "\nSwizzleW : " ); ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES ); } if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) { TXT( "\nNegate : " ); UID( src->SrcRegister.Negate ); } if( ignored ) { if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) { TXT( "\nIndirect : " ); UID( src->SrcRegister.Indirect ); } if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) { TXT( "\nDimension: " ); UID( src->SrcRegister.Dimension ); } } if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) { TXT( "\nIndex : " ); SID( src->SrcRegister.Index ); } if( ignored ) { if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) { TXT( "\nExtended : " ); UID( src->SrcRegister.Extended ); } } if( deflt || tgsi_compare_src_register_ext_swz( src->SrcRegisterExtSwz, fs->SrcRegisterExtSwz ) ) { EOL(); TXT( "\nType : " ); ENM( src->SrcRegisterExtSwz.Type, TGSI_SRC_REGISTER_EXTS ); if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleX != src->SrcRegisterExtSwz.ExtSwizzleX ) { TXT( "\nExtSwizzleX: " ); ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES ); } if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleY != src->SrcRegisterExtSwz.ExtSwizzleY ) { TXT( "\nExtSwizzleY: " ); ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES ); } if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleZ != src->SrcRegisterExtSwz.ExtSwizzleZ ) { TXT( "\nExtSwizzleZ: " ); ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES ); } if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleW != src->SrcRegisterExtSwz.ExtSwizzleW ) { TXT( "\nExtSwizzleW: " ); ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES ); } if( deflt || fs->SrcRegisterExtSwz.NegateX != src->SrcRegisterExtSwz.NegateX ) { TXT( "\nNegateX : " ); UID( src->SrcRegisterExtSwz.NegateX ); } if( deflt || fs->SrcRegisterExtSwz.NegateY != src->SrcRegisterExtSwz.NegateY ) { TXT( "\nNegateY : " ); UID( src->SrcRegisterExtSwz.NegateY ); } if( deflt || fs->SrcRegisterExtSwz.NegateZ != src->SrcRegisterExtSwz.NegateZ ) { TXT( "\nNegateZ : " ); UID( src->SrcRegisterExtSwz.NegateZ ); } if( deflt || fs->SrcRegisterExtSwz.NegateW != src->SrcRegisterExtSwz.NegateW ) { TXT( "\nNegateW : " ); UID( src->SrcRegisterExtSwz.NegateW ); } if( ignored ) { TXT( "\nPadding : " ); UIX( src->SrcRegisterExtSwz.Padding ); if( deflt || fs->SrcRegisterExtSwz.Extended != src->SrcRegisterExtSwz.Extended ) { TXT( "\nExtended : " ); UID( src->SrcRegisterExtSwz.Extended ); } } } if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) { EOL(); TXT( "\nType : " ); ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS ); if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) { TXT( "\nComplement: " ); UID( src->SrcRegisterExtMod.Complement ); } if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) { TXT( "\nBias : " ); UID( src->SrcRegisterExtMod.Bias ); } if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) { TXT( "\nScale2X : " ); UID( src->SrcRegisterExtMod.Scale2X ); } if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) { TXT( "\nAbsolute : " ); UID( src->SrcRegisterExtMod.Absolute ); } if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) { TXT( "\nNegate : " ); UID( src->SrcRegisterExtMod.Negate ); } if( ignored ) { TXT( "\nPadding : " ); UIX( src->SrcRegisterExtMod.Padding ); if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) { TXT( "\nExtended : " ); UID( src->SrcRegisterExtMod.Extended ); } } } } }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; TXT( "DCL " ); ENM(decl->Declaration.File, tgsi_file_names); /* all geometry shader inputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_RESOURCE) { TXT(", "); ENM(decl->Resource.Resource, tgsi_texture_names); if (decl->Resource.Writable) TXT(", WR"); if (decl->Resource.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Centroid) { TXT( ", CENTROID" ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } if (decl->Declaration.File == TGSI_FILE_IMMEDIATE_ARRAY) { unsigned i; char range_indent[4]; TXT(" {"); if (decl->Range.Last < 10) range_indent[0] = '\0'; else if (decl->Range.Last < 100) { range_indent[0] = ' '; range_indent[1] = '\0'; } else if (decl->Range.Last < 1000) { range_indent[0] = ' '; range_indent[1] = ' '; range_indent[2] = '\0'; } else { range_indent[0] = ' '; range_indent[1] = ' '; range_indent[2] = ' '; range_indent[3] = '\0'; } dump_imm_data(iter, decl->ImmediateData.u, 4, TGSI_IMM_FLOAT32); for(i = 1; i <= decl->Range.Last; ++i) { /* indent by strlen of: * "DCL IMMX[0..1] {" */ CHR('\n'); TXT( " " ); TXT( range_indent ); dump_imm_data(iter, decl->ImmediateData.u + i, 4, TGSI_IMM_FLOAT32); } TXT(" }"); } EOL(); return TRUE; }
void ServiceCore::Net_CM_Login(uint32_t nChannID, uint8_t, const uint8_t *pData, size_t) { CMLogin stCML; std::memcpy(&stCML, pData, sizeof(stCML)); auto fnOnLoginFail = [nChannID, stCML]() { g_MonoServer->AddLog(LOGTYPE_INFO, "Login failed for (%s:%s)", stCML.ID, "******"); g_NetDriver->Post(nChannID, SM_LOGINFAIL); g_NetDriver->Shutdown(nChannID, false); }; g_MonoServer->AddLog(LOGTYPE_INFO, "Login requested: (%s:%s)", stCML.ID, "******"); auto pDBHDR = g_DBPodN->CreateDBHDR(); if(!pDBHDR->QueryResult("select fld_id from tbl_account where fld_account = '%s' and fld_password = '******'", stCML.ID, stCML.Password)){ g_MonoServer->AddLog(LOGTYPE_INFO, "can't find account: (%s:%s)", stCML.ID, "******"); fnOnLoginFail(); return; } auto nID = pDBHDR->Get<int64_t>("fld_id"); if(!pDBHDR->QueryResult("select * from tbl_dbid where fld_id = %d", (int)(nID))){ g_MonoServer->AddLog(LOGTYPE_INFO, "no dbid created for this account: (%s:%s)", stCML.ID, "******"); fnOnLoginFail(); return; } AMLoginQueryDB stAMLQDBOK; std::memset(&stAMLQDBOK, 0, sizeof(stAMLQDBOK)); auto nDBID = pDBHDR->Get<int64_t>("fld_dbid"); auto nMapID = DBCOM_MAPID(pDBHDR->Get<std::string>("fld_mapname").c_str()); auto nMapX = pDBHDR->Get<int64_t>("fld_mapx"); auto nMapY = pDBHDR->Get<int64_t>("fld_mapy"); auto nDirection = pDBHDR->Get<int64_t>("fld_direction"); auto pMap = RetrieveMap(nMapID); if(false || !pMap || !pMap->In(nMapID, nMapX, nMapY)){ g_MonoServer->AddLog(LOGTYPE_WARNING, "Invalid db record found: (map, x, y) = (%d, %d, %d)", nMapID, nMapX, nMapY); fnOnLoginFail(); return; } AMAddCharObject stAMACO; std::memset(&stAMACO, 0, sizeof(stAMACO)); stAMACO.Type = TYPE_PLAYER; stAMACO.Common.MapID = nMapID; stAMACO.Common.X = nMapX; stAMACO.Common.Y = nMapY; stAMACO.Common.Random = true; stAMACO.Player.DBID = nDBID; stAMACO.Player.Direction = nDirection; stAMACO.Player.ChannID = nChannID; m_ActorPod->Forward(pMap->UID(), {MPK_ADDCHAROBJECT, stAMACO}, [this, fnOnLoginFail](const MessagePack &rstRMPK) { switch(rstRMPK.Type()){ case MPK_OK: { break; } default: { fnOnLoginFail(); break; } } }); }
static boolean iter_declaration( struct tgsi_iterate_context *iter, struct tgsi_full_declaration *decl ) { struct dump_ctx *ctx = (struct dump_ctx *)iter; boolean patch = decl->Semantic.Name == TGSI_SEMANTIC_PATCH || decl->Semantic.Name == TGSI_SEMANTIC_TESSINNER || decl->Semantic.Name == TGSI_SEMANTIC_TESSOUTER || decl->Semantic.Name == TGSI_SEMANTIC_PRIMID; TXT( "DCL " ); TXT(tgsi_file_name(decl->Declaration.File)); /* all geometry shader inputs and non-patch tessellation shader inputs are * two dimensional */ if (decl->Declaration.File == TGSI_FILE_INPUT && (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || (!patch && (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL || iter->processor.Processor == TGSI_PROCESSOR_TESS_EVAL)))) { TXT("[]"); } /* all non-patch tess ctrl shader outputs are two dimensional */ if (decl->Declaration.File == TGSI_FILE_OUTPUT && !patch && iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) { TXT("[]"); } if (decl->Declaration.Dimension) { CHR('['); SID(decl->Dim.Index2D); CHR(']'); } CHR('['); SID(decl->Range.First); if (decl->Range.First != decl->Range.Last) { TXT(".."); SID(decl->Range.Last); } CHR(']'); _dump_writemask( ctx, decl->Declaration.UsageMask ); if (decl->Declaration.Array) { TXT( ", ARRAY(" ); SID(decl->Array.ArrayID); CHR(')'); } if (decl->Declaration.Local) TXT( ", LOCAL" ); if (decl->Declaration.Semantic) { TXT( ", " ); ENM( decl->Semantic.Name, tgsi_semantic_names ); if (decl->Semantic.Index != 0 || decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD || decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) { CHR( '[' ); UID( decl->Semantic.Index ); CHR( ']' ); } } if (decl->Declaration.File == TGSI_FILE_IMAGE) { TXT(", "); ENM(decl->Image.Resource, tgsi_texture_names); TXT(", "); TXT(util_format_name(decl->Image.Format)); if (decl->Image.Writable) TXT(", WR"); if (decl->Image.Raw) TXT(", RAW"); } if (decl->Declaration.File == TGSI_FILE_BUFFER) { if (decl->Declaration.Atomic) TXT(", ATOMIC"); } if (decl->Declaration.File == TGSI_FILE_MEMORY) { if (decl->Declaration.Shared) TXT(", SHARED"); } if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) { TXT(", "); ENM(decl->SamplerView.Resource, tgsi_texture_names); TXT(", "); if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) && (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) { ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names); } else { ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeY, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeZ, tgsi_return_type_names); TXT(", "); ENM(decl->SamplerView.ReturnTypeW, tgsi_return_type_names); } } if (decl->Declaration.Interpolate) { if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && decl->Declaration.File == TGSI_FILE_INPUT) { TXT( ", " ); ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); } if (decl->Interp.Location != TGSI_INTERPOLATE_LOC_CENTER) { TXT( ", " ); ENM( decl->Interp.Location, tgsi_interpolate_locations ); } if (decl->Interp.CylindricalWrap) { TXT(", CYLWRAP_"); if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) { CHR('X'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) { CHR('Y'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) { CHR('Z'); } if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) { CHR('W'); } } } if (decl->Declaration.Invariant) { TXT( ", INVARIANT" ); } EOL(); return TRUE; }
/* * Handle a DUB response (inc. timeouts). * @param data the raw response, excluding the start code * @param length the length of the response, 0 if no response was received. */ void DiscoveryAgent::BranchComplete(const uint8_t *data, unsigned int length) { OLA_INFO << "BranchComplete, got " << length; if (length == 0) { // timeout if (!m_uid_ranges.empty()) { FreeCurrentRange(); } SendDiscovery(); return; } // Must at least have the separator, the EUID and the checksum if (length < 1 + EUID_SIZE + CHECKSUM_SIZE) { HandleCollision(); return; } unsigned int offset = 0; while (data[offset] != PREAMBLE_SEPARATOR && offset < PREAMBLE_SIZE - 1) { if (data[offset] != PREAMBLE) { OLA_INFO << "Preamble " << offset << " " << strings::ToHex(data[offset]); HandleCollision(); return; } offset++; } if (data[offset] != PREAMBLE_SEPARATOR) { OLA_INFO << "Preamble separator" << offset << " " << strings::ToHex(data[offset]); HandleCollision(); return; } offset++; unsigned int remaining = length - offset; if (remaining < EUID_SIZE + CHECKSUM_SIZE) { OLA_INFO << "Insufficient data remaining, was " << remaining; HandleCollision(); return; } typedef struct { uint8_t euid11; uint8_t euid10; uint8_t euid9; uint8_t euid8; uint8_t euid7; uint8_t euid6; uint8_t euid5; uint8_t euid4; uint8_t euid3; uint8_t euid2; uint8_t euid1; uint8_t euid0; uint8_t ecs3; uint8_t ecs2; uint8_t ecs1; uint8_t ecs0; } dub_response_structure; const dub_response_structure *response = reinterpret_cast<const dub_response_structure*>(data + offset); uint16_t calculated_checksum = 0; for (unsigned int i = offset; i < offset + EUID_SIZE; i++) { calculated_checksum += data[i]; } uint16_t recovered_checksum = JoinUInt8((response->ecs3 & response->ecs2), (response->ecs1 & response->ecs0)); if (recovered_checksum != calculated_checksum) { OLA_INFO << "Recovered checksum: " << recovered_checksum << " != " << "calculated checksum: " << calculated_checksum; HandleCollision(); return; } // ok this is a valid response uint16_t manufacturer_id = JoinUInt8((response->euid11 & response->euid10), (response->euid9 & response->euid8)); uint32_t device_id = JoinUInt8((response->euid7 & response->euid6), (response->euid5 & response->euid4), (response->euid3 & response->euid2), (response->euid1 & response->euid0)); UIDRange *range = m_uid_ranges.top(); // we store this as an instance variable so we don't have to create a new // callback each time. UID located_uid = UID(manufacturer_id, device_id); if (m_uids.Contains(located_uid)) { OLA_WARN << "Previous muted responder " << located_uid << " continues to respond"; range->failures++; // ignore this and continue on to the next branch. SendDiscovery(); } else if (m_bad_uids.Contains(located_uid)) { // we've already tried this one range->failures++; SendDiscovery(); } else { m_muting_uid = located_uid; m_mute_attempts = 0; OLA_INFO << "Muting " << m_muting_uid; m_target->MuteDevice(m_muting_uid, m_branch_mute_callback.get()); } }
/** * Called when we get a response (or timeout) to a branch request. * @param data the raw response, excluding the start code * @param length the length of the response, 0 if no response was received. */ void DiscoveryAgent::BranchComplete(const uint8_t *data, unsigned int length) { if (length == 0) { // timeout FreeCurrentRange(); SendDiscovery(); return; } if (length < MIN_DUB_RESPONSE_SIZE || length > MAX_DUB_RESPONSE_SIZE) { HandleCollision(); return; } unsigned int preamble_size = length - MIN_DUB_RESPONSE_SIZE; for (unsigned int i = 0; i < preamble_size; i++) { if (data[i] != 0xfe) { OLA_INFO << "preamble " << i << " " << std::hex << static_cast<int>(data[i]); HandleCollision(); return; } } unsigned int offset = preamble_size; if (data[offset++] != 0xaa) { OLA_INFO << "preamble separator is " << std::hex << static_cast<int>(data[offset]); HandleCollision(); return; } typedef struct { uint8_t euid11; uint8_t euid10; uint8_t euid9; uint8_t euid8; uint8_t euid7; uint8_t euid6; uint8_t euid5; uint8_t euid4; uint8_t euid3; uint8_t euid2; uint8_t euid1; uint8_t euid0; uint8_t ecs3; uint8_t ecs2; uint8_t ecs1; uint8_t ecs0; } dub_response_structure; const dub_response_structure *response = reinterpret_cast<const dub_response_structure*>(data + offset); uint16_t calculated_checksum = 0; for (unsigned int i = offset; i < offset + 12; i++) calculated_checksum += data[i]; uint16_t recovered_checksum = ((response->ecs3 & response->ecs2) << 8) + (response->ecs1 & response->ecs0); if (recovered_checksum != calculated_checksum) { OLA_INFO << "recovered checksum: " << recovered_checksum << " != " << "calculated checksum: " << calculated_checksum; HandleCollision(); return; } // ok this is a valid response uint16_t manufacturer_id = ((response->euid11 & response->euid10) << 8) + (response->euid9 & response->euid8); uint32_t device_id = ((response->euid7 & response->euid6) << 24) + ((response->euid5 & response->euid4) << 16) + ((response->euid3 & response->euid2) << 8) + (response->euid1 & response->euid0); UIDRange *range = m_uid_ranges.top(); // we store this as an instance variable so we don't have to create a new // callback each time. UID located_uid = UID(manufacturer_id, device_id); if (m_uids.Contains(located_uid)) { OLA_WARN << "Previous muted responder " << located_uid << " continues to respond"; range->failures++; // ignore this and continue on to the next branch. SendDiscovery(); } else if (m_bad_uids.Contains(located_uid)) { // we've already tried this one range->failures++; SendDiscovery(); } else { m_muting_uid = located_uid; m_mute_attempts = 0; OLA_INFO << "muting " << m_muting_uid; m_target->MuteDevice(m_muting_uid, m_branch_mute_callback); } }