brw_vs.h File Reference

Include dependency graph for brw_vs.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  brw_vs_prog_key
struct  brw_vs_compile

Functions

void brw_vs_emit (struct brw_vs_compile *c)


Function Documentation

void brw_vs_emit ( struct brw_vs_compile c  ) 

Definition at line 1243 of file brw_vs_emit.c.

References brw_address(), BRW_ALIGN_1, BRW_ALIGN_16, BRW_COMPRESSION_NONE, brw_indirect(), brw_MOV(), brw_set_access_mode(), brw_set_compression_control(), brw_vs_alloc_regs(), emit_vertex_write(), tgsi_src_register::File, tgsi_immediate_float32::Float, tgsi_full_token::FullDeclaration, tgsi_full_token::FullImmediate, tgsi_full_token::FullInstruction, tgsi_full_instruction::FullSrcRegisters, tgsi_parse_context::FullToken, brw_vs_compile::func, get_addr_reg(), brw_vs_prog_data::imm_buf, tgsi_full_immediate::ImmediateFloat32, tgsi_src_register::Index, brw_vs_prog_data::max_const, brw_compile::nr_insn, brw_prog_info::num_consts, brw_vs_prog_data::num_consts, brw_vs_prog_data::num_imm, brw_vs_compile::output_regs, post_vs_emit(), process_declaration(), process_instruction(), brw_vs_compile::prog_data, brw_vertex_program::program, tgsi_full_src_register::SrcRegister, brw_vs_compile::stack, brw_compile::store, TGSI_FILE_OUTPUT, tgsi_parse_end_of_tokens(), tgsi_parse_free(), tgsi_parse_init(), tgsi_parse_token(), TGSI_TOKEN_TYPE_DECLARATION, TGSI_TOKEN_TYPE_IMMEDIATE, TGSI_TOKEN_TYPE_INSTRUCTION, tgsi_full_token::Token, pipe_shader_state::tokens, TRUE, tgsi_token::Type, tgsi_full_immediate::u, brw_vs_compile::used_in_src, and brw_vs_compile::vp.

01244 {
01245 #define MAX_IFSN 32
01246    struct brw_compile *p = &c->func;
01247    struct brw_instruction *end_inst;
01248    struct tgsi_parse_context parse;
01249    struct brw_indirect stack_index = brw_indirect(0, 0);
01250    const struct tgsi_token *tokens = c->vp->program.tokens;
01251    struct brw_prog_info prog_info;
01252    unsigned allocated_registers = 0;
01253    memset(&prog_info, 0, sizeof(struct brw_prog_info));
01254 
01255    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
01256    brw_set_access_mode(p, BRW_ALIGN_16);
01257 
01258    tgsi_parse_init(&parse, tokens);
01259    /* Message registers can't be read, so copy the output into GRF register
01260       if they are used in source registers */
01261    while (!tgsi_parse_end_of_tokens(&parse)) {
01262       tgsi_parse_token(&parse);
01263       unsigned i;
01264       switch (parse.FullToken.Token.Type) {
01265       case TGSI_TOKEN_TYPE_INSTRUCTION: {
01266          const struct tgsi_full_instruction *inst = &parse.FullToken.FullInstruction;
01267          for (i = 0; i < 3; ++i) {
01268             const struct tgsi_src_register *src = &inst->FullSrcRegisters[i].SrcRegister;
01269             unsigned index = src->Index;
01270             unsigned file = src->File;
01271             if (file == TGSI_FILE_OUTPUT)
01272                c->output_regs[index].used_in_src = TRUE;
01273          }
01274       }
01275          break;
01276       default:
01277          /* nothing */
01278          break;
01279       }
01280    }
01281    tgsi_parse_free(&parse);
01282 
01283    tgsi_parse_init(&parse, tokens);
01284 
01285    while (!tgsi_parse_end_of_tokens(&parse)) {
01286       tgsi_parse_token(&parse);
01287 
01288       switch (parse.FullToken.Token.Type) {
01289       case TGSI_TOKEN_TYPE_DECLARATION: {
01290          struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
01291          process_declaration(decl, &prog_info);
01292       }
01293          break;
01294       case TGSI_TOKEN_TYPE_IMMEDIATE: {
01295          struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
01296          /*assert(imm->Immediate.Size == 4);*/
01297          c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
01298          c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
01299          c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;
01300          c->prog_data.imm_buf[c->prog_data.num_imm][3] = imm->u.ImmediateFloat32[3].Float;
01301          c->prog_data.num_imm++;
01302       }
01303          break;
01304       case TGSI_TOKEN_TYPE_INSTRUCTION: {
01305          struct tgsi_full_instruction *inst = &parse.FullToken.FullInstruction;
01306          if (!allocated_registers) {
01307             /* first instruction (declerations finished).
01308              * now that we know what vars are being used allocate
01309              * registers for them.*/
01310             c->prog_data.num_consts = prog_info.num_consts;
01311             c->prog_data.max_const = prog_info.num_consts + c->prog_data.num_imm;
01312             brw_vs_alloc_regs(c, &prog_info);
01313 
01314             brw_set_access_mode(p, BRW_ALIGN_1);
01315             brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
01316             brw_set_access_mode(p, BRW_ALIGN_16);
01317             allocated_registers = 1;
01318          }
01319          process_instruction(c, inst, &prog_info);
01320       }
01321          break;
01322       }
01323    }
01324 
01325    end_inst = &p->store[p->nr_insn];
01326    emit_vertex_write(c, &prog_info);
01327    post_vs_emit(c, end_inst);
01328    tgsi_parse_free(&parse);
01329 
01330 }


Generated on Tue Sep 29 06:25:39 2009 for Gallium3D by  doxygen 1.5.4