diff options
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_vertprog.c | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index aa2f20127b..b453e315a8 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -53,7 +53,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. WRITEMASK_W != VSF_FLAG_W #error Cannot change these! #endif - + #define SCALAR_FLAG (1<<31) #define FLAG_MASK (1<<31) #define OP_MASK (0xf) /* we are unlikely to have more than 15 */ @@ -96,17 +96,17 @@ static struct{ OPN(END, 0), }; #undef OPN - + int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont *vp, float *dst) { int pi; struct gl_vertex_program *mesa_vp = &vp->mesa_program; float *dst_o=dst; struct gl_program_parameter_list *paramList; - + if (mesa_vp->IsNVProgram) { _mesa_load_tracked_matrices(ctx); - + for (pi=0; pi < MAX_NV_VERTEX_PROGRAM_PARAMS; pi++) { *dst++=ctx->VertexProgram.Parameters[pi][0]; *dst++=ctx->VertexProgram.Parameters[pi][1]; @@ -115,19 +115,19 @@ int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont * } return dst - dst_o; } - + assert(mesa_vp->Base.Parameters); _mesa_load_state_parameters(ctx, mesa_vp->Base.Parameters); - + if(mesa_vp->Base.Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){ fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__); exit(-1); } - + paramList = mesa_vp->Base.Parameters; for(pi=0; pi < paramList->NumParameters; pi++){ switch(paramList->Parameters[pi].Type){ - + case PROGRAM_STATE_VAR: case PROGRAM_NAMED_PARAM: //fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name); @@ -137,15 +137,15 @@ int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont * *dst++=paramList->ParameterValues[pi][2]; *dst++=paramList->ParameterValues[pi][3]; break; - + default: _mesa_problem(NULL, "Bad param type in %s", __FUNCTION__); } - + } - + return dst - dst_o; } - + static unsigned long t_dst_mask(GLuint mask) { /* WRITEMASK_* is equivalent to VSF_FLAG_* */ @@ -154,7 +154,7 @@ static unsigned long t_dst_mask(GLuint mask) static unsigned long t_dst_class(enum register_file file) { - + switch(file){ case PROGRAM_TEMPORARY: return VSF_OUT_CLASS_TMP; @@ -162,7 +162,7 @@ static unsigned long t_dst_class(enum register_file file) return VSF_OUT_CLASS_RESULT; case PROGRAM_ADDRESS: return VSF_OUT_CLASS_ADDR; - /* + /* case PROGRAM_INPUT: case PROGRAM_LOCAL_PARAM: case PROGRAM_ENV_PARAM: @@ -187,20 +187,20 @@ static unsigned long t_dst_index(struct r300_vertex_program *vp, struct prog_dst static unsigned long t_src_class(enum register_file file) { - + switch(file){ case PROGRAM_TEMPORARY: return VSF_IN_CLASS_TMP; - + case PROGRAM_INPUT: return VSF_IN_CLASS_ATTR; - + case PROGRAM_LOCAL_PARAM: case PROGRAM_ENV_PARAM: case PROGRAM_NAMED_PARAM: case PROGRAM_STATE_VAR: return VSF_IN_CLASS_PARAM; - /* + /* case PROGRAM_OUTPUT: case PROGRAM_WRITE_ONLY: case PROGRAM_ADDRESS: @@ -221,17 +221,17 @@ static __inline unsigned long t_swizzle(GLubyte swizzle) static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller) { int i; - + if(vp == NULL){ fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, caller); return ; } - + fprintf(stderr, "%s:<", caller); for(i=0; i < VERT_ATTRIB_MAX; i++) fprintf(stderr, "%d ", vp->inputs[i]); fprintf(stderr, ">\n"); - + } #endif @@ -239,19 +239,19 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, struct prog_src { int i; int max_reg=-1; - + if(src->File == PROGRAM_INPUT){ if(vp->inputs[src->Index] != -1) return vp->inputs[src->Index]; - + for(i=0; i < VERT_ATTRIB_MAX; i++) if(vp->inputs[i] > max_reg) max_reg=vp->inputs[i]; - + vp->inputs[src->Index]=max_reg+1; - - //vp_dump_inputs(vp, __FUNCTION__); - + + //vp_dump_inputs(vp, __FUNCTION__); + return vp->inputs[src->Index]; }else{ if (src->Index < 0) { @@ -278,7 +278,7 @@ static unsigned long t_src(struct r300_vertex_program *vp, struct prog_src_regis static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct prog_src_register *src) { - + return MAKE_VSF_SOURCE(t_src_index(vp, src), t_swizzle(GET_SWZ(src->Swizzle, 0)), t_swizzle(GET_SWZ(src->Swizzle, 0)), @@ -307,8 +307,8 @@ static unsigned long t_opcode(enum prog_opcode opcode) case OPCODE_SGE: return R300_VPI_OUT_OP_SGE; case OPCODE_SLT: return R300_VPI_OUT_OP_SLT; case OPCODE_DP4: return R300_VPI_OUT_OP_DOT; - - default: + + default: fprintf(stderr, "%s: Should not be called with opcode %d!", __FUNCTION__, opcode); } exit(-1); @@ -318,12 +318,12 @@ static unsigned long t_opcode(enum prog_opcode opcode) static unsigned long op_operands(enum prog_opcode opcode) { int i; - + /* Can we trust mesas opcodes to be in order ? */ for(i=0; i < sizeof(op_names) / sizeof(*op_names); i++) if(op_names[i].opcode == opcode) return op_names[i].ip; - + fprintf(stderr, "op %d not found in op_names\n", opcode); exit(-1); return 0; @@ -337,7 +337,7 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_regis }else if(dst->File == PROGRAM_ADDRESS) { assert(dst->Index == 0); } - + return GL_TRUE; } @@ -347,12 +347,12 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_regis t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \ (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \ t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \ - + #define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ SWIZZLE_ZERO, SWIZZLE_ZERO, \ SWIZZLE_ZERO, SWIZZLE_ZERO, \ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) - + #define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ SWIZZLE_ZERO, SWIZZLE_ZERO, \ SWIZZLE_ZERO, SWIZZLE_ZERO, \ @@ -362,12 +362,12 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_regis SWIZZLE_ZERO, SWIZZLE_ZERO, \ SWIZZLE_ZERO, SWIZZLE_ZERO, \ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) - + #define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ SWIZZLE_ONE, SWIZZLE_ONE, \ SWIZZLE_ONE, SWIZZLE_ONE, \ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) - + #define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ SWIZZLE_ONE, SWIZZLE_ONE, \ SWIZZLE_ONE, SWIZZLE_ONE, \ @@ -377,7 +377,7 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_regis SWIZZLE_ONE, SWIZZLE_ONE, \ SWIZZLE_ONE, SWIZZLE_ONE, \ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) - + /* DP4 version seems to trigger some hw peculiarity */ //#define PREFER_DP4 @@ -406,46 +406,46 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct vp->pos_end=0; /* Not supported yet */ vp->program.length=0; /*vp->num_temporaries=mesa_vp->Base.NumTemporaries;*/ - + for(i=0; i < VERT_ATTRIB_MAX; i++) vp->inputs[i] = -1; for(i=0; i < VERT_RESULT_MAX; i++) vp->outputs[i] = -1; - + assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)); - + /* Assign outputs */ if(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) vp->outputs[VERT_RESULT_HPOS] = cur_reg++; - + if(vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; - + if(vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) vp->outputs[VERT_RESULT_COL0] = cur_reg++; - + if(vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) vp->outputs[VERT_RESULT_COL1] = cur_reg++; - + #if 0 /* Not supported yet */ if(vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) vp->outputs[VERT_RESULT_BFC0] = cur_reg++; - + if(vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) vp->outputs[VERT_RESULT_BFC1] = cur_reg++; - + if(vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) vp->outputs[VERT_RESULT_FOGC] = cur_reg++; #endif - + for(i=VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) if(vp->key.OutputsWritten & (1 << i)) vp->outputs[i] = cur_reg++; - + vp->translated = GL_TRUE; vp->native = GL_TRUE; - + o_inst=vp->program.body.i; for(; vpi->Opcode != OPCODE_END; vpi++, o_inst++){ FREE_TEMPS(); @@ -456,19 +456,19 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct vpi->DstReg.File = PROGRAM_TEMPORARY; vpi->DstReg.Index = u_temp_i; } - + operands=op_operands(vpi->Opcode); are_srcs_scalar=operands & SCALAR_FLAG; operands &= OP_MASK; - + for(i=0; i < operands; i++) src[i]=vpi->SrcReg[i]; - + if(operands == 3){ /* TODO: scalars */ if( CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2]) ){ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, @@ -477,20 +477,20 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_2; o_inst->src3=ZERO_SRC_2; o_inst++; - + src[2].File=PROGRAM_TEMPORARY; src[2].Index=u_temp_i; src[2].RelAddr=0; u_temp_i--; } - + } - + if(operands >= 2){ if( CMP_SRCS(src[1], src[0]) ){ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, @@ -499,14 +499,14 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_0; o_inst->src3=ZERO_SRC_0; o_inst++; - + src[0].File=PROGRAM_TEMPORARY; src[0].Index=u_temp_i; src[0].RelAddr=0; u_temp_i--; } } - + /* These ops need special handling. */ switch(vpi->Opcode){ case OPCODE_POW: @@ -516,8 +516,8 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_0; o_inst->src3=t_src_scalar(vp, &src[1]); goto next; - - case OPCODE_MOV://ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} + + case OPCODE_MOV://ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} case OPCODE_SWZ: #if 1 o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), @@ -527,21 +527,21 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src3=ZERO_SRC_0; #else hw_op=(src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); o_inst->src1=t_src(vp, &src[0]); o_inst->src2=ONE_SRC_0; o_inst->src3=ZERO_SRC_0; -#endif +#endif goto next; - + case OPCODE_ADD: #if 1 hw_op=(src[0].File == PROGRAM_TEMPORARY && src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); o_inst->src1=ONE_SRC_0; @@ -553,26 +553,26 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src1=t_src(vp, &src[0]); o_inst->src2=t_src(vp, &src[1]); o_inst->src3=ZERO_SRC_1; - + #endif goto next; - + case OPCODE_MAD: hw_op=(src[0].File == PROGRAM_TEMPORARY && src[1].File == PROGRAM_TEMPORARY && src[2].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); o_inst->src1=t_src(vp, &src[0]); o_inst->src2=t_src(vp, &src[1]); o_inst->src3=t_src(vp, &src[2]); goto next; - + case OPCODE_MUL: /* HW mul can take third arg but appears to have some other limitations. */ hw_op=(src[0].File == PROGRAM_TEMPORARY && src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); o_inst->src1=t_src(vp, &src[0]); @@ -580,11 +580,11 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src3=ZERO_SRC_1; goto next; - - case OPCODE_DP3://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} + + case OPCODE_DP3://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), @@ -592,7 +592,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct SWIZZLE_ZERO, t_src_class(src[0].File), src[0].NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - + o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 0)), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), @@ -608,7 +608,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct #if 1 hw_op=(src[0].File == PROGRAM_TEMPORARY && src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); o_inst->src1=t_src(vp, &src[0]); @@ -623,7 +623,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct #else o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=t_src(vp, &src[0]); o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 0)), @@ -635,11 +635,11 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src3=0; #endif goto next; - + case OPCODE_ABS://MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=t_src(vp, &src[0]); o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), @@ -650,22 +650,22 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct (!src[0].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); o_inst->src3=0; goto next; - + case OPCODE_FLR: - /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} + /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - + o_inst->src1=t_src(vp, &src[0]); o_inst->src2=ZERO_SRC_0; o_inst->src3=ZERO_SRC_0; o_inst++; - + o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=t_src(vp, &src[0]); o_inst->src2=MAKE_VSF_SOURCE(u_temp_i, VSF_IN_COMPONENT_X, @@ -679,11 +679,11 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src3=ZERO_SRC_0; u_temp_i--; goto next; - + case OPCODE_LG2:// LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), @@ -694,8 +694,8 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_0; o_inst->src3=ZERO_SRC_0; goto next; - - case OPCODE_LIT://LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} + + case OPCODE_LIT://LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); /* NOTE: Users swizzling might not work. */ @@ -721,11 +721,11 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct t_src_class(src[0].File), src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); goto next; - - case OPCODE_DPH://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} + + case OPCODE_DPH://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), @@ -736,16 +736,16 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=t_src(vp, &src[1]); o_inst->src3=ZERO_SRC_1; goto next; - + case OPCODE_XPD: /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 NOTE: might need MAD_2 */ - + o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z @@ -753,7 +753,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w t_src_class(src[0].File), src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - + o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x @@ -761,14 +761,14 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w t_src_class(src[1].File), src[1].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - + o_inst->src3=ZERO_SRC_1; o_inst++; u_temp_i--; - + o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z @@ -776,7 +776,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w t_src_class(src[1].File), (!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - + o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x @@ -784,7 +784,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w t_src_class(src[0].File), src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - + o_inst->src3=MAKE_VSF_SOURCE(u_temp_i+1, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, @@ -792,7 +792,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, VSF_FLAG_NONE); - + goto next; case OPCODE_RCC: @@ -804,10 +804,10 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct default: break; } - + o_inst->op=MAKE_VSF_OP(t_opcode(vpi->Opcode), t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - + if(are_srcs_scalar){ switch(operands){ case 1: @@ -815,19 +815,19 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_0; o_inst->src3=ZERO_SRC_0; break; - + case 2: o_inst->src1=t_src_scalar(vp, &src[0]); o_inst->src2=t_src_scalar(vp, &src[1]); o_inst->src3=ZERO_SRC_1; break; - + case 3: o_inst->src1=t_src_scalar(vp, &src[0]); o_inst->src2=t_src_scalar(vp, &src[1]); o_inst->src3=t_src_scalar(vp, &src[2]); break; - + default: fprintf(stderr, "scalars and op RCC not handled yet"); exit(-1); @@ -840,19 +840,19 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct o_inst->src2=ZERO_SRC_0; o_inst->src3=ZERO_SRC_0; break; - + case 2: o_inst->src1=t_src(vp, &src[0]); o_inst->src2=t_src(vp, &src[1]); o_inst->src3=ZERO_SRC_1; break; - + case 3: o_inst->src1=t_src(vp, &src[0]); o_inst->src2=t_src(vp, &src[1]); o_inst->src3=t_src(vp, &src[2]); break; - + default: fprintf(stderr, "scalars and op RCC not handled yet"); exit(-1); @@ -861,7 +861,7 @@ static void r300_translate_vertex_shader(struct r300_vertex_program *vp, struct } next: ; } - + /* Will most likely segfault before we get here... fix later. */ if(o_inst - vp->program.body.i >= VSF_MAX_FRAGMENT_LENGTH/4) { vp->program.length = 0; @@ -945,7 +945,7 @@ static void position_invariant(struct gl_program *prog) vpi[i].SrcReg[2].Index = 0; vpi[i].SrcReg[2].Swizzle = SWIZZLE_XYZW; } -#endif +#endif } _mesa_copy_instructions (&vpi[i], prog->Instructions, prog->NumInstructions); @@ -967,7 +967,7 @@ static void insert_wpos(struct r300_vertex_program *vp, struct prog_instruction *vpi; struct prog_instruction *vpi_insert; int i = 0; - + vpi = _mesa_alloc_instructions (prog->NumInstructions + 2); _mesa_init_instructions (vpi, prog->NumInstructions + 2); /* all but END */ @@ -1054,7 +1054,7 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key r300_translate_vertex_shader(vp, mesa_vp->Base.Instructions); - return vp; + return vp; } void r300_select_vertex_shader(r300ContextPtr r300) @@ -1077,7 +1077,7 @@ void r300_select_vertex_shader(r300ContextPtr r300) for (i = 0; i < ctx->Const.MaxTextureUnits; i++) if (!(InputsRead & (FRAG_BIT_TEX0 << i))) break; - + if(i == ctx->Const.MaxTextureUnits){ fprintf(stderr, "\tno free texcoord found\n"); exit(0); @@ -1093,7 +1093,7 @@ void r300_select_vertex_shader(r300ContextPtr r300) if ((InputsRead & FRAG_BIT_COL1) /*|| (InputsRead & FRAG_BIT_FOGC)*/) wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1; - + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) if (InputsRead & (FRAG_BIT_TEX0 << i)) wanted_key.OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i); |