From fb4e071beda6e3b9e68a21bbc7649b6c4733c485 Mon Sep 17 00:00:00 2001 From: Tommy Schultz Lassen Date: Wed, 18 Jul 2007 00:37:43 +0000 Subject: r300: Corrected texcoord start when BFC1 is enabled. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 0fb6110494..4f36e818ff 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1073,7 +1073,7 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; - cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; + cur_reg = vp->outputs[VERT_RESULT_BFC1] + 2; } #if 0 if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { -- cgit v1.2.3 From 86ece0a920d8afa870608a25745be8d03b7cccb6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 18 Jul 2007 02:49:26 +0000 Subject: r300: Cleaned up vertprog construction. Construct the vertprog instruction in the 4 DWORD parts... DWORD 0: Opcode and Output. DWORD 1: First Argument. DWORD 2: Second Argument. DWORD 3: Third Argument. Allow the opcode translation functions to generate more than one instruction; useful for when an instruction must be emulated. FLR, XPD, etc. --- src/mesa/drivers/dri/r300/r300_context.h | 2 +- src/mesa/drivers/dri/r300/r300_state.c | 29 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 716 +++++++++++++++--------------- src/mesa/drivers/dri/r300/r300_vertprog.h | 5 - 4 files changed, 383 insertions(+), 369 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 0349bac9a2..be6909724a 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -568,7 +568,7 @@ struct r300_vertex_shader_fragment { union { GLuint d[VSF_MAX_FRAGMENT_LENGTH]; float f[VSF_MAX_FRAGMENT_LENGTH]; - struct r300_vertprog_instruction i[VSF_MAX_FRAGMENT_LENGTH / 4]; + GLuint i[VSF_MAX_FRAGMENT_LENGTH]; } body; }; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 6789efd428..a790acacfe 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1566,30 +1566,31 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa) for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) { if (rmesa->state.sw_tcl_inputs[i] != -1) { - prog->program.body.i[program_end].opcode = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); - prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); - prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); - prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); - program_end++; + prog->program.body.i[program_end + 0] = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); + prog->program.body.i[program_end + 1] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end + 2] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end + 3] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); + program_end += 4; } } - prog->program.length = program_end * 4; + prog->program.length = program_end; - r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program)); + r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, + &(prog->program)); inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | - (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | + (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | - (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } static void r300SetupRealVertexProgram(r300ContextPtr rmesa) diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 4f36e818ff..c6b4fc6024 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -31,6 +31,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * \author Aapo Tahkola * * \author Oliver McFadden + * + * For a description of the vertex program instruction set see r300_reg.h. */ #include "glheader.h" @@ -366,20 +368,19 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, * component. */ -static void t_opcode_abs(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_abs(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //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->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = 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)), @@ -389,13 +390,14 @@ static void t_opcode_abs(struct r300_vertex_program *vp, (!src[0]. NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[2] = 0; + inst[3] = 0; + + return inst; } -static void t_opcode_add(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_add(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -405,53 +407,55 @@ static void t_opcode_add(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = ONE_SRC_0; - o_inst->src[1] = t_src(vp, &src[0]); - o_inst->src[2] = t_src(vp, &src[1]); + inst[1] = ONE_SRC_0; + inst[2] = t_src(vp, &src[0]); + inst[3] = t_src(vp, &src[1]); #else - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; #endif + + return inst; } -static void t_opcode_arl(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_arl(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_dp3(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dp3(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} - o_inst->opcode = + inst[0] = 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->src[0] = + inst[1] = 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)), @@ -461,7 +465,7 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = + inst[2] = 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)), @@ -471,36 +475,38 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - o_inst->src[2] = ZERO_SRC_1; + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dp4(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dp4(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dph(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dph(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} - o_inst->opcode = + inst[0] = 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->src[0] = + inst[1] = 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)), @@ -509,81 +515,84 @@ static void t_opcode_dph(struct r300_vertex_program *vp, src[0]. NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dst(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dst(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_ex2(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_ex2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_exp(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_exp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], - int *u_temp_i) +static GLuint *t_opcode_flr(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3], int *u_temp_i) { /* 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->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - o_inst++; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + inst += 4; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, @@ -592,40 +601,40 @@ static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE /*VSF_FLAG_ALL */ ); - o_inst->src[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; (*u_temp_i)--; - return o_inst; + return inst; } -static void t_opcode_frc(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_frc(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_lg2(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_lg2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} - o_inst->opcode = + inst[0] = 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->src[0] = + inst[1] = 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)), @@ -635,70 +644,70 @@ static void t_opcode_lg2(struct r300_vertex_program *vp, src[0]. NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_lit(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_lit(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //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->opcode = + inst[0] = 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. */ - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[1] = 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, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[2] = 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, 0)), // x - VSF_IN_COMPONENT_ZERO, // z - 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); + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + inst[2] = 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, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + inst[3] = 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, 0)), // x + VSF_IN_COMPONENT_ZERO, // z + 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); + + return inst; } -static void t_opcode_log(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_log(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_mad(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mad(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -708,80 +717,84 @@ static void t_opcode_mad(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = t_src(vp, &src[2]); + + return inst; } -static void t_opcode_max(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_max(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_min(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_min(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_mov(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mov(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} #if 1 - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; #else hw_op = (src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = ZERO_SRC_0; #endif + + return inst; } -static void t_opcode_mul(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mul(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -792,94 +805,100 @@ static void t_opcode_mul(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + + inst[3] = ZERO_SRC_1; - o_inst->src[2] = ZERO_SRC_1; + return inst; } -static void t_opcode_pow(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_pow(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = t_src_scalar(vp, &src[1]); + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = t_src_scalar(vp, &src[1]); + + return inst; } -static void t_opcode_rcp(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_rcp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_rsq(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_rsq(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_sge(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_sge(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_slt(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_slt(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_sub(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_sub(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -891,13 +910,13 @@ static void t_opcode_sub(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = 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)), @@ -908,13 +927,13 @@ static void t_opcode_sub(struct r300_vertex_program *vp, NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); #else - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = 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)), @@ -924,113 +943,110 @@ static void t_opcode_sub(struct r300_vertex_program *vp, (!src[1]. NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - o_inst->src[2] = 0; + inst[3] = 0; #endif + + return inst; } -static void t_opcode_swz(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_swz(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} #if 1 - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; #else hw_op = (src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = 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->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = ZERO_SRC_0; #endif + + return inst; } -static struct r300_vertprog_instruction *t_opcode_xpd(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], - int *u_temp_i) +static GLuint *t_opcode_xpd(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3], int *u_temp_i) { /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 NOTE: might need MAD_2 */ - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - o_inst->src[0] = 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 - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - 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->src[1] = 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 - t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y - 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->src[2] = ZERO_SRC_1; - o_inst++; + inst[1] = 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 + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + 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); + + inst[2] = 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 + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y + 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); + + inst[3] = ZERO_SRC_1; + inst += 4; (*u_temp_i)--; - o_inst->opcode = + inst[0] = 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->src[0] = 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 - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x - 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->src[1] = 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 - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - 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->src[2] = + inst[1] = 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 + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x + 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); + + inst[2] = 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 + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + 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); + + inst[3] = MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, VSF_FLAG_NONE); - return o_inst; + return inst; } static void t_inputs_outputs(struct r300_vertex_program *vp) @@ -1092,7 +1108,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct prog_instruction *vpi) { int i; - struct r300_vertprog_instruction *o_inst; + GLuint *inst; unsigned long num_operands; /* Initial value should be last tmp reg that hw supports. Strangely enough r300 doesnt mind even though these would be out of range. @@ -1108,8 +1124,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_inputs_outputs(vp); - for (o_inst = vp->program.body.i; vpi->Opcode != OPCODE_END; - vpi++, o_inst++) { + for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END; + vpi++, inst += 4) { FREE_TEMPS(); @@ -1129,12 +1145,12 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (num_operands == 3) { /* TODO: scalars */ if (CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2])) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index (vp, &src[2]), SWIZZLE_X, SWIZZLE_Y, @@ -1144,9 +1160,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, VSF_FLAG_NONE) | (src[2].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_2; - o_inst->src[2] = ZERO_SRC_2; - o_inst++; + inst[2] = ZERO_SRC_2; + inst[3] = ZERO_SRC_2; + inst += 4; src[2].File = PROGRAM_TEMPORARY; src[2].Index = u_temp_i; @@ -1157,12 +1173,12 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (num_operands >= 2) { if (CMP_SRCS(src[1], src[0])) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index (vp, &src[0]), SWIZZLE_X, SWIZZLE_Y, @@ -1172,9 +1188,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - o_inst++; + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + inst += 4; src[0].File = PROGRAM_TEMPORARY; src[0].Index = u_temp_i; @@ -1185,87 +1201,89 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, switch (vpi->Opcode) { case OPCODE_ABS: - t_opcode_abs(vp, vpi, o_inst, src); + inst = t_opcode_abs(vp, vpi, inst, src); break; case OPCODE_ADD: - t_opcode_add(vp, vpi, o_inst, src); + inst = t_opcode_add(vp, vpi, inst, src); break; case OPCODE_ARL: - t_opcode_arl(vp, vpi, o_inst, src); + inst = t_opcode_arl(vp, vpi, inst, src); break; case OPCODE_DP3: - t_opcode_dp3(vp, vpi, o_inst, src); + inst = t_opcode_dp3(vp, vpi, inst, src); break; case OPCODE_DP4: - t_opcode_dp4(vp, vpi, o_inst, src); + inst = t_opcode_dp4(vp, vpi, inst, src); break; case OPCODE_DPH: - t_opcode_dph(vp, vpi, o_inst, src); + inst = t_opcode_dph(vp, vpi, inst, src); break; case OPCODE_DST: - t_opcode_dst(vp, vpi, o_inst, src); + inst = t_opcode_dst(vp, vpi, inst, src); break; case OPCODE_EX2: - t_opcode_ex2(vp, vpi, o_inst, src); + inst = t_opcode_ex2(vp, vpi, inst, src); break; case OPCODE_EXP: - t_opcode_exp(vp, vpi, o_inst, src); + inst = t_opcode_exp(vp, vpi, inst, src); break; case OPCODE_FLR: - /* FIXME */ - o_inst = t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); + inst = + t_opcode_flr(vp, vpi, inst, src, /* FIXME */ + &u_temp_i); break; case OPCODE_FRC: - t_opcode_frc(vp, vpi, o_inst, src); + inst = t_opcode_frc(vp, vpi, inst, src); break; case OPCODE_LG2: - t_opcode_lg2(vp, vpi, o_inst, src); + inst = t_opcode_lg2(vp, vpi, inst, src); break; case OPCODE_LIT: - t_opcode_lit(vp, vpi, o_inst, src); + inst = t_opcode_lit(vp, vpi, inst, src); break; case OPCODE_LOG: - t_opcode_log(vp, vpi, o_inst, src); + inst = t_opcode_log(vp, vpi, inst, src); break; case OPCODE_MAD: - t_opcode_mad(vp, vpi, o_inst, src); + inst = t_opcode_mad(vp, vpi, inst, src); break; case OPCODE_MAX: - t_opcode_max(vp, vpi, o_inst, src); + inst = t_opcode_max(vp, vpi, inst, src); break; case OPCODE_MIN: - t_opcode_min(vp, vpi, o_inst, src); + inst = t_opcode_min(vp, vpi, inst, src); break; case OPCODE_MOV: - t_opcode_mov(vp, vpi, o_inst, src); + inst = t_opcode_mov(vp, vpi, inst, src); break; case OPCODE_MUL: - t_opcode_mul(vp, vpi, o_inst, src); + inst = t_opcode_mul(vp, vpi, inst, src); break; case OPCODE_POW: - t_opcode_pow(vp, vpi, o_inst, src); + inst = t_opcode_pow(vp, vpi, inst, src); break; case OPCODE_RCP: - t_opcode_rcp(vp, vpi, o_inst, src); + inst = t_opcode_rcp(vp, vpi, inst, src); break; case OPCODE_RSQ: - t_opcode_rsq(vp, vpi, o_inst, src); + inst = t_opcode_rsq(vp, vpi, inst, src); break; case OPCODE_SGE: - t_opcode_sge(vp, vpi, o_inst, src); + inst = t_opcode_sge(vp, vpi, inst, src); break; case OPCODE_SLT: - t_opcode_slt(vp, vpi, o_inst, src); + inst = t_opcode_slt(vp, vpi, inst, src); break; case OPCODE_SUB: - t_opcode_sub(vp, vpi, o_inst, src); + inst = t_opcode_sub(vp, vpi, inst, src); break; case OPCODE_SWZ: - t_opcode_swz(vp, vpi, o_inst, src); + inst = t_opcode_swz(vp, vpi, inst, src); break; case OPCODE_XPD: - /* FIXME */ - o_inst = t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); + inst = + t_opcode_xpd(vp, vpi, inst, src, /* FIXME */ + &u_temp_i); break; default: assert(0); @@ -1273,7 +1291,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } } - vp->program.length = (o_inst - vp->program.body.i) * 4; + vp->program.length = (inst - vp->program.body.i); if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) { vp->program.length = 0; vp->native = GL_FALSE; diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h index 2d399e243a..3df0eee799 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.h +++ b/src/mesa/drivers/dri/r300/r300_vertprog.h @@ -3,11 +3,6 @@ #include "r300_reg.h" -struct r300_vertprog_instruction { - GLuint opcode; - GLuint src[3]; -}; - #define VSF_FLAG_X 1 #define VSF_FLAG_Y 2 #define VSF_FLAG_Z 4 -- cgit v1.2.3 From 0b48ce450eef91a9fcf6681260beb1090e0ef9d1 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 18 Jul 2007 02:59:08 +0000 Subject: r300: Oops, made a mistake on commit fb4e071beda6e3b9e68a21bbc7649b6c4733c485. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index c6b4fc6024..7d4e8c9511 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1083,13 +1083,13 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { vp->outputs[VERT_RESULT_BFC0] = vp->outputs[VERT_RESULT_COL0] + 2; - cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1; + cur_reg = vp->outputs[VERT_RESULT_BFC0] + 2; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; - cur_reg = vp->outputs[VERT_RESULT_BFC1] + 2; + cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; } #if 0 if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { -- cgit v1.2.3 From b9f2cf9a4e0a5ec89b27371210846942c93cb412 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 12:56:30 +0200 Subject: increase MAX_RELOCS so never run out before batch buffer is full (fixes xdemos/shape) --- src/mesa/drivers/dri/i915tex/intel_batchbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h index 59261f7274..212f130101 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h @@ -9,7 +9,7 @@ struct intel_context; #define BATCH_SZ 16384 #define BATCH_RESERVED 16 -#define MAX_RELOCS 400 +#define MAX_RELOCS 4096 #define INTEL_BATCH_NO_CLIPRECTS 0x1 #define INTEL_BATCH_CLIPRECTS 0x2 -- cgit v1.2.3 From dbfb375805d94cb80262b8816c67a8adc778bec5 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 17:29:55 +0200 Subject: fix mesa fb binding Make sure that we bind the right buffer (draw or read) when rebinding the window framebuffer (the api doesn't allow binding different draw and read buffers at the same time, but the default window framebuffer is basically 2 fb objects, one for read, one for write, which can be different). Pass both of these two down the driver api (no driver uses this right now). --- src/mesa/drivers/dri/i915tex/intel_fbo.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 7 +++++-- src/mesa/main/dd.h | 2 +- src/mesa/main/fbobject.c | 8 +++++--- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 349912ffec..6f99f401c7 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -488,7 +488,7 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name) */ static void intel_bind_framebuffer(GLcontext * ctx, GLenum target, - struct gl_framebuffer *fb) + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index f98d666563..d498f616c9 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -390,9 +390,12 @@ nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) } static void -nouveauBindFramebuffer(GLcontext *ctx, GLenum target, struct gl_framebuffer *fb) +nouveauBindFramebuffer(GLcontext *ctx, GLenum target, + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { - nouveau_build_framebuffer(ctx, fb); + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } } static void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 88f33943b3..caa50dd682 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -782,7 +782,7 @@ struct dd_function_table { struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name); struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name); void (*BindFramebuffer)(GLcontext *ctx, GLenum target, - struct gl_framebuffer *fb); + struct gl_framebuffer *fb, struct gl_framebuffer *fbread); void (*FramebufferRenderbuffer)(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e3bada5ae8..5345310ca1 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -924,7 +924,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { - struct gl_framebuffer *newFb; + struct gl_framebuffer *newFb, *newFbread; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); @@ -984,12 +984,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } + newFbread = newFb; } else { /* Binding the window system framebuffer (which was originally set * with MakeCurrent). */ newFb = ctx->WinSysDrawBuffer; + newFbread = ctx->WinSysReadBuffer; } ASSERT(newFb); @@ -1000,7 +1002,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); } if (bindDrawBuf) { @@ -1015,7 +1017,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } if (ctx->Driver.BindFramebuffer) { - ctx->Driver.BindFramebuffer(ctx, target, newFb); + ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread); } } -- cgit v1.2.3 From f9ac01eac511aa9ea0b8b48774022a08d0fc2f3b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 19 Jul 2007 17:58:21 +0200 Subject: fix up mesa's probably bogus framebuffer updates with different read/write fbs Conflicts: src/mesa/main/framebuffer.c --- src/mesa/main/framebuffer.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index dc10d9ffbc..2ff067164b 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -654,6 +654,27 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } +static void +update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) +{ + /* Completeness only matters for user-created framebuffers */ + if (fb->Name != 0) { + /* XXX: EXT_framebuffer_blit: + framebuffer must still be complete wrt read/draw? */ + _mesa_test_framebuffer_completeness(ctx, fb); + _mesa_update_framebuffer_visual(fb); + } + + /* update_color_draw/read_buffers not needed for + read/draw only fb, but shouldn't hurt ??? */ + update_color_draw_buffers(ctx, fb); + update_color_read_buffer(ctx, fb); + _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); + _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + + compute_depth_max(fb); +} + /** * Update state related to the current draw/read framebuffers. * Specifically, update these framebuffer fields: @@ -671,19 +692,12 @@ void _mesa_update_framebuffer(GLcontext *ctx) { struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_framebuffer *fbread = ctx->ReadBuffer; - /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) { - _mesa_test_framebuffer_completeness(ctx, fb); - _mesa_update_framebuffer_visual(fb); - } - - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); - - compute_depth_max(fb); + update_framebuffer(ctx, fb); + if (fbread != fb && fbread != NULL /* can happen at make_current - + core/driver circular dependencies, should be fixed up */) + update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From 6075df53b5435ddada989d776d989132def363a6 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 18:07:12 +0200 Subject: more fixes for mesa's fbo handling (fixes tests/fbotest1/2) --- src/mesa/main/buffers.c | 5 ++--- src/mesa/main/context.c | 5 +++++ src/mesa/main/fbobject.c | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index c280f89e1d..68a0575d93 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -557,9 +557,8 @@ _mesa_ReadBuffer(GLenum buffer) } } - if (fb->Name == 0) { - ctx->Pixel.ReadBuffer = buffer; - } + ctx->Pixel.ReadBuffer = buffer; + fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2ad1badac7..4e6732dc7a 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1499,6 +1499,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if the DRIdrawable changes, and someone may rely on them. */ /* What a mess!?! */ + /* XXX this is still not quite correct. Imagine a user-created fbo + bound on a context. Now rebind with a completely new drawable. + Upon rebinding to the window-framebuffer, we have no idea what + the read and write buffers should be (front, back, ...) - that + information was only available in the previously used drawable... */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 5345310ca1..f300e481ce 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1003,13 +1003,20 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); + /* set context value */ + ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; } if (bindDrawBuf) { + GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); + /* set context value */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + } if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); -- cgit v1.2.3 From a1bc0d0f51c2aa248a349283c3b86ae2c72af4aa Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 20:17:14 +0200 Subject: fix mesa's handling of fbo's / window fb (again) Make sure the relevant fields in window fbs get updated at appropriate time (those are NOT the same as fbos!!!), and fix up related code accordingly. This is a bit ugly, but there's a reason the issues section in EXT_fbo is a couple hundred pages long... Hopefully correct now. --- src/mesa/main/attrib.c | 4 +++ src/mesa/main/buffers.c | 72 ++++++++++++++++++++++++++++++--------------- src/mesa/main/buffers.h | 3 ++ src/mesa/main/context.c | 12 ++------ src/mesa/main/fbobject.c | 24 ++++++++++----- src/mesa/main/framebuffer.c | 3 +- 6 files changed, 77 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 1aa0a02fc7..b422198f92 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -98,9 +98,13 @@ _mesa_PushAttrib(GLbitfield mask) } if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; struct gl_colorbuffer_attrib *attr; attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) + attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); newnode->data = attr; newnode->next = head; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 68a0575d93..7764a5d3b2 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -370,6 +370,14 @@ _mesa_DrawBuffer(GLenum buffer) /* if we get here, there's no error so set new state */ _mesa_drawbuffers(ctx, 1, &buffer, &destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, 1, &buffer); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffer); } @@ -435,6 +443,14 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) /* OK, if we get here, there were no errors so set the new state */ _mesa_drawbuffers(ctx, n, buffers, destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, n, buffers); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffers[0]); } @@ -463,14 +479,15 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, /* not really needed, will be set later */ fb->_NumColorDrawBuffers[output] = 0; + if (fb->Name == 0) /* Set traditional state var */ - ctx->Color.DrawBuffer[output] = buffer; + ctx->Color.DrawBuffer[output] = buffer; } /** * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and - * _mesa_PopAttrib to set drawbuffer state. + * other places (window fbo fixup) to set fbo (and the old ctx) fields. * All error checking will have been done prior to calling this function * so nothing should go wrong at this point. * \param ctx current context @@ -479,6 +496,7 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). + * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -509,30 +527,15 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, } ctx->NewState |= _NEW_COLOR; - - /* - * Call device driver function. - */ - if (ctx->Driver.DrawBuffers) - ctx->Driver.DrawBuffers(ctx, n, buffers); - else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffers[0]); } - -/** - * Called by glReadBuffer to set the source renderbuffer for reading pixels. - * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - */ -void GLAPIENTRY -_mesa_ReadBuffer(GLenum buffer) +GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) { struct gl_framebuffer *fb; GLbitfield supportedMask; GLint srcBuffer; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); fb = ctx->ReadBuffer; @@ -548,20 +551,43 @@ _mesa_ReadBuffer(GLenum buffer) srcBuffer = read_buffer_enum_to_index(buffer); if (srcBuffer == -1) { _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } supportedMask = supported_buffer_bitmask(ctx, fb); if (((1 << srcBuffer) & supportedMask) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } } - ctx->Pixel.ReadBuffer = buffer; - + if (fb->Name == 0) { + ctx->Pixel.ReadBuffer = buffer; + } fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; + return GL_TRUE; +} + + + +/** + * Called by glReadBuffer to set the source renderbuffer for reading pixels. + * \param mode color buffer such as GL_FRONT, GL_BACK, etc. + * \param callDriver call driver or not (bad idea sometimes this is called) + */ +void GLAPIENTRY +_mesa_ReadBuffer(GLenum buffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + if (!_mesa_readbuffer_update_fields(ctx, buffer)) + return; + ctx->NewState |= _NEW_PIXEL; /* diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index fcc2152342..208e7af2b9 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -56,6 +56,9 @@ extern void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask); +extern GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer); + extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 4e6732dc7a..00e4c8328e 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1496,14 +1496,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); /* fix up the fb fields - these will end up wrong otherwise - if the DRIdrawable changes, and someone may rely on them. - */ - /* What a mess!?! */ - /* XXX this is still not quite correct. Imagine a user-created fbo - bound on a context. Now rebind with a completely new drawable. - Upon rebinding to the window-framebuffer, we have no idea what - the read and write buffers should be (front, back, ...) - that - information was only available in the previously used drawable... */ + if the DRIdrawable changes, and everything relies on them. + This is a bit messy (same as needed in _mesa_BindFramebufferEXT) */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { @@ -1513,7 +1507,7 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); - _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer); + _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer); } newCtx->NewState |= _NEW_BUFFERS; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f300e481ce..6f7effcce7 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -29,6 +29,7 @@ */ +#include "buffers.h" #include "context.h" #include "fbobject.h" #include "framebuffer.h" @@ -1001,23 +1002,32 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) * XXX check if re-binding same buffer and skip some of this code. */ + /* for window-framebuffers, re-initialize the fbo values, as they + could be wrong (makecurrent with a new drawable while still a fbo + was bound will lead to default init fbo values). + note that therefore the context ReadBuffer/DrawBuffer values are not + valid while fbo's are bound!!! */ if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); - /* set context value */ - ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; + if (!newFbread->Name) { + _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer); + } } if (bindDrawBuf) { - GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); - /* set context value */ - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + if (!newFb->Name) { + GLuint i; + GLenum buffers[MAX_DRAW_BUFFERS]; + for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + buffers[i] = ctx->Color.DrawBuffer[i]; + } + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL); } - if (newFb->Name != 0) { + else { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 2ff067164b..c9b30d3252 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -695,8 +695,7 @@ _mesa_update_framebuffer(GLcontext *ctx) struct gl_framebuffer *fbread = ctx->ReadBuffer; update_framebuffer(ctx, fb); - if (fbread != fb && fbread != NULL /* can happen at make_current - - core/driver circular dependencies, should be fixed up */) + if (fbread != fb) update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From 82fceba231a03b3b7284d5356d7bc1d10c366026 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 20 Jul 2007 11:34:26 +0200 Subject: fix bogus recently introduced function param comments --- src/mesa/main/buffers.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 7764a5d3b2..0e6ca8ea1c 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -496,7 +496,6 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -574,7 +573,6 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) /** * Called by glReadBuffer to set the source renderbuffer for reading pixels. * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - * \param callDriver call driver or not (bad idea sometimes this is called) */ void GLAPIENTRY _mesa_ReadBuffer(GLenum buffer) -- cgit v1.2.3 From af2aa8e9cf88a9ee3ec338eddc9a47bf2f142cb7 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 21 Jul 2007 10:06:18 -0600 Subject: Remove ctx->Point._Size and ctx->Line._Width. The clamping for these values depends on whether we're drawing AA or non-AA points, lines. Defer clamping until drawing time. Drivers could compute and keep clamped AA and clamped non-AA values if desired. --- src/mesa/drivers/dri/i810/i810state.c | 10 ++++++++-- src/mesa/drivers/dri/i810/i810tris.c | 4 +++- src/mesa/drivers/dri/i965/brw_sf_state.c | 6 ++++-- src/mesa/drivers/dri/mach64/mach64_native_vb.c | 2 +- src/mesa/drivers/dri/mach64/mach64_tris.c | 13 ++++++++----- src/mesa/drivers/dri/mga/mgatris.c | 10 +++++++--- src/mesa/drivers/dri/r200/r200_state.c | 4 +++- src/mesa/drivers/dri/r300/r300_state.c | 9 +++++---- src/mesa/drivers/dri/savage/savagetris.c | 16 ++++++++++++---- src/mesa/drivers/dri/tdfx/tdfx_tris.c | 2 +- src/mesa/main/lines.c | 8 ++------ src/mesa/main/mtypes.h | 2 -- src/mesa/main/points.c | 5 ----- src/mesa/main/state.c | 4 ++-- src/mesa/swrast/s_aalinetemp.h | 4 +++- src/mesa/swrast/s_lines.c | 16 +++++++++------- src/mesa/swrast/s_points.c | 8 ++++---- src/mesa/tnl/t_vertex.c | 2 +- src/mesa/tnl_dd/t_dd_vb.c | 2 +- 19 files changed, 74 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c index 3ad25282d9..e0d5b2b487 100644 --- a/src/mesa/drivers/dri/i810/i810state.c +++ b/src/mesa/drivers/dri/i810/i810state.c @@ -380,7 +380,10 @@ static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused) static void i810LineWidth( GLcontext *ctx, GLfloat widthf ) { i810ContextPtr imesa = I810_CONTEXT( ctx ); - int width = (int)ctx->Line._Width; + /* AA, non-AA limits are same */ + const int width = (int) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); imesa->LcsLineWidth = 0; if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0; @@ -396,7 +399,10 @@ static void i810LineWidth( GLcontext *ctx, GLfloat widthf ) static void i810PointSize( GLcontext *ctx, GLfloat sz ) { i810ContextPtr imesa = I810_CONTEXT( ctx ); - int size = (int)ctx->Point._Size; + /* AA, non-AA limits are same */ + const int size = (int) CLAMP(ctx->Point.Size, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize); imesa->LcsPointSize = 0; if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0; diff --git a/src/mesa/drivers/dri/i810/i810tris.c b/src/mesa/drivers/dri/i810/i810tris.c index 3e09427bb9..2c4ee06633 100644 --- a/src/mesa/drivers/dri/i810/i810tris.c +++ b/src/mesa/drivers/dri/i810/i810tris.c @@ -112,7 +112,9 @@ static __inline__ void i810_draw_quad( i810ContextPtr imesa, static __inline__ void i810_draw_point( i810ContextPtr imesa, i810VertexPtr tmp ) { - GLfloat sz = imesa->glCtx->Point._Size * .5; + GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); int vertsize = imesa->vertex_size; GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize ); int j; diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index bfac52d765..9a6e5f5f19 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -173,7 +173,8 @@ static void upload_sf_unit( struct brw_context *brw ) /* _NEW_LINE */ - sf.sf6.line_width = brw->attribs.Line->_Width * (1<<1); + /* XXX use ctx->Const.Min/MaxLineWidth here */ + sf.sf6.line_width = CLAMP(brw->attribs.Line->Width, 1.0, 5.0) * (1<<1); sf.sf6.line_endcap_aa_region_width = 1; if (brw->attribs.Line->SmoothFlag) @@ -183,7 +184,8 @@ static void upload_sf_unit( struct brw_context *brw ) /* _NEW_POINT */ sf.sf6.point_rast_rule = 1; /* opengl conventions */ - sf.sf7.point_size = brw->attribs.Point->_Size * (1<<3); + /* XXX clamp max depends on AA vs. non-AA */ + sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 3.0) * (1<<3); sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated; /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons: diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/src/mesa/drivers/dri/mach64/mach64_native_vb.c index 75cf0e2ed2..248fa2a9a2 100644 --- a/src/mesa/drivers/dri/mach64/mach64_native_vb.c +++ b/src/mesa/drivers/dri/mach64/mach64_native_vb.c @@ -103,7 +103,7 @@ void TAG(translate_vertex)(GLcontext *ctx, assert( p + 1 - (CARD32 *)src == 10 ); - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } diff --git a/src/mesa/drivers/dri/mach64/mach64_tris.c b/src/mesa/drivers/dri/mach64/mach64_tris.c index 08cc1849a1..369f610442 100644 --- a/src/mesa/drivers/dri/mach64/mach64_tris.c +++ b/src/mesa/drivers/dri/mach64/mach64_tris.c @@ -673,7 +673,10 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa, #if MACH64_NATIVE_VTXFMT GLcontext *ctx = mmesa->glCtx; const GLuint vertsize = mmesa->vertex_size; - GLint width = (GLint)(mmesa->glCtx->Line._Width * 2.0); /* 2 fractional bits for hardware */ + /* 2 fractional bits for hardware: */ + const int width = (int) (2.0 * CLAMP(mmesa->glCtx->Line.Width, + mmesa->glCtx->Const.MinLineWidth, + mmesa->glCtx->Const.MaxLineWidth)); GLfloat ooa; GLuint *pxy0, *pxy1; GLuint xy0old, xy0, xy1old, xy1; @@ -691,9 +694,6 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa, mach64_print_vertex( ctx, v1 ); } - if( !width ) - width = 1; /* round to the nearest supported width */ - pxy0 = &v0->ui[xyoffset]; xy0old = *pxy0; xy0 = LE32_IN( &xy0old ); @@ -961,7 +961,10 @@ static __inline void mach64_draw_point( mach64ContextPtr mmesa, #if MACH64_NATIVE_VTXFMT GLcontext *ctx = mmesa->glCtx; const GLuint vertsize = mmesa->vertex_size; - GLint sz = (GLint)(mmesa->glCtx->Point._Size * 2.0); /* 2 fractional bits for hardware */ + /* 2 fractional bits for hardware: */ + GLint sz = (GLint) (2.0 * CLAMP(mmesa->glCtx->Point.Size, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize)); GLfloat ooa; GLuint *pxy; GLuint xyold, xy; diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c index 2b7ea05b14..91b413ae76 100644 --- a/src/mesa/drivers/dri/mga/mgatris.c +++ b/src/mesa/drivers/dri/mga/mgatris.c @@ -104,8 +104,10 @@ static void __inline__ mga_draw_quad( mgaContextPtr mmesa, static __inline__ void mga_draw_point( mgaContextPtr mmesa, mgaVertexPtr tmp ) { - GLfloat sz = mmesa->glCtx->Point._Size * .5; - int vertex_size = mmesa->vertex_size; + const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size, + mmesa->glCtx->Const.MinPointSize, + mmesa->glCtx->Const.MaxPointSize); + const int vertex_size = mmesa->vertex_size; GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size ); int j; @@ -165,7 +167,9 @@ static __inline__ void mga_draw_line( mgaContextPtr mmesa, GLuint vertex_size = mmesa->vertex_size; GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size ); GLfloat dx, dy, ix, iy; - GLfloat width = mmesa->glCtx->Line._Width; + const GLfloat width = CLAMP(mmesa->glCtx->Line.Width, + mmesa->glCtx->Const.MinLineWidth, + mmesa->glCtx->Const.MaxLineWidth); GLint j; #if 0 diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 2115799b9b..1d975ecd57 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -772,9 +772,11 @@ static void r200LineWidth( GLcontext *ctx, GLfloat widthf ) R200_STATECHANGE( rmesa, set ); /* Line width is stored in U6.4 format. + * Same min/max limits for AA, non-AA lines. */ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] &= ~0xffff; - rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)(ctx->Line._Width * 16.0); + rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint) + (CLAMP(widthf, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth) * 16.0); if ( widthf > 1.0 ) { rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_WIDELINE_ENABLE; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index a790acacfe..088216c76e 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -733,8 +733,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param) static void r300PointSize(GLcontext * ctx, GLfloat size) { r300ContextPtr r300 = R300_CONTEXT(ctx); - - size = ctx->Point._Size; + /* same size limits for AA, non-AA points */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); R300_STATECHANGE(r300, ps); r300->hw.ps.cmd[R300_PS_POINTSIZE] = @@ -749,8 +749,9 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf) { r300ContextPtr r300 = R300_CONTEXT(ctx); - widthf = ctx->Line._Width; - + widthf = CLAMP(widthf, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize); R300_STATECHANGE(r300, lcntl); r300->hw.lcntl.cmd[1] = R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0); diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c index 3dd821a4d3..4ce2f60b4f 100644 --- a/src/mesa/drivers/dri/savage/savagetris.c +++ b/src/mesa/drivers/dri/savage/savagetris.c @@ -131,7 +131,9 @@ static __inline__ void savage_draw_point (savageContextPtr imesa, u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); const GLfloat x = tmp->v.x; const GLfloat y = tmp->v.y; - const GLfloat sz = imesa->glCtx->Point._Size * .5; + const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); GLuint j; *(float *)&vb[0] = x - sz; @@ -164,7 +166,9 @@ static __inline__ void savage_draw_line (savageContextPtr imesa, savageVertexPtr v1 ) { GLuint vertsize = imesa->HwVertexSize; u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - GLfloat width = imesa->glCtx->Line._Width; + const GLfloat width = CLAMP(imesa->glCtx->Line.Width, + imesa->glCtx->Const.MinLineWidth, + imesa->glCtx->Const.MaxLineWidth); GLfloat dx, dy, ix, iy; GLuint j; @@ -234,7 +238,9 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa, savageVertexPtr v1 ) { GLuint vertsize = imesa->HwVertexSize; u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - GLfloat width = imesa->glCtx->Line._Width; + const GLfloat width = CLAMP(imesa->glCtx->Line.Width, + imesa->glCtx->Const.MinLineWidth, + imesa->glCtx->Const.MaxLineWidth); GLfloat dx, dy, ix, iy; savageVertex tmp0, tmp1; GLuint j; @@ -281,7 +287,9 @@ static __inline__ void savage_ptex_point (savageContextPtr imesa, u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); const GLfloat x = v0->v.x; const GLfloat y = v0->v.y; - const GLfloat sz = imesa->glCtx->Point._Size * .5; + const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); savageVertex tmp; GLuint j; diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c index 96f9ae27fc..7252a7e7dc 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_tris.c @@ -184,7 +184,7 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst) } } - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c index dc7195d4eb..0c2dbf915a 100644 --- a/src/mesa/main/lines.c +++ b/src/mesa/main/lines.c @@ -55,9 +55,6 @@ _mesa_LineWidth( GLfloat width ) FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.Width = width; - ctx->Line._Width = CLAMP(width, - ctx->Const.MinLineWidth, - ctx->Const.MaxLineWidth); if (ctx->Driver.LineWidth) ctx->Driver.LineWidth(ctx, width); @@ -105,13 +102,12 @@ _mesa_LineStipple( GLint factor, GLushort pattern ) * Initializes __GLcontextRec::Line and line related constants in * __GLcontextRec::Const. */ -void GLAPIENTRY _mesa_init_line( GLcontext * ctx ) +void GLAPIENTRY +_mesa_init_line( GLcontext * ctx ) { - /* Line group */ ctx->Line.SmoothFlag = GL_FALSE; ctx->Line.StippleFlag = GL_FALSE; ctx->Line.Width = 1.0; - ctx->Line._Width = 1.0; ctx->Line.StipplePattern = 0xffff; ctx->Line.StippleFactor = 1; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 709b88d2ef..a5fdd88262 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -917,7 +917,6 @@ struct gl_line_attrib GLushort StipplePattern; /**< Stipple pattern */ GLint StippleFactor; /**< Stipple repeat factor */ GLfloat Width; /**< Line width */ - GLfloat _Width; /**< Clamped Line width */ }; @@ -1063,7 +1062,6 @@ struct gl_point_attrib { GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ GLfloat Size; /**< User-specified point size */ - GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */ GLfloat Params[3]; /**< GL_EXT_point_parameters */ GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ GLfloat Threshold; /**< GL_EXT_point_parameters */ diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 0f562420b0..e83db5de78 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -57,10 +57,6 @@ _mesa_PointSize( GLfloat size ) FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.Size = size; - /* XXX correct clamp limits? */ - ctx->Point._Size = CLAMP(ctx->Point.Size, - ctx->Point.MinSize, - ctx->Point.MaxSize); if (ctx->Driver.PointSize) ctx->Driver.PointSize(ctx, size); @@ -253,7 +249,6 @@ _mesa_init_point(GLcontext *ctx) ctx->Point.SmoothFlag = GL_FALSE; ctx->Point.Size = 1.0; - ctx->Point._Size = 1.0; ctx->Point.Params[0] = 1.0; ctx->Point.Params[1] = 0.0; ctx->Point.Params[2] = 0.0; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 66f8ac6408..444f227760 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1068,7 +1068,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state) if (1/*new_state & _NEW_POINT*/) { if (ctx->Point.SmoothFlag) ctx->_TriangleCaps |= DD_POINT_SMOOTH; - if (ctx->Point._Size != 1.0F) + if (ctx->Point.Size != 1.0F) ctx->_TriangleCaps |= DD_POINT_SIZE; if (ctx->Point._Attenuated) ctx->_TriangleCaps |= DD_POINT_ATTEN; @@ -1082,7 +1082,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state) ctx->_TriangleCaps |= DD_LINE_SMOOTH; if (ctx->Line.StippleFlag) ctx->_TriangleCaps |= DD_LINE_STIPPLE; - if (ctx->Line._Width != 1.0) + if (ctx->Line.Width != 1.0) ctx->_TriangleCaps |= DD_LINE_WIDTH; } diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 69a1f0cd39..e7911fec3b 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -132,7 +132,9 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) line.dx = line.x1 - line.x0; line.dy = line.y1 - line.y0; line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); - line.halfWidth = 0.5F * ctx->Line._Width; + line.halfWidth = 0.5F * CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidthAA, + ctx->Const.MaxLineWidthAA); if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 781146e67f..15ef6233ed 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -63,12 +63,13 @@ compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] ) static void draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) { - GLint width, start; + const GLint width = (GLint) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + GLint start; ASSERT(span->end < MAX_WIDTH); - width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH ); - if (width & 1) start = width / 2; else @@ -143,7 +144,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -161,7 +162,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -180,7 +181,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -274,7 +275,7 @@ _swrast_choose_line( GLcontext *ctx ) USE(general_line); } else if (ctx->Depth.Test - || ctx->Line._Width != 1.0 + || ctx->Line.Width != 1.0 || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ if (rgbmode) @@ -284,6 +285,7 @@ _swrast_choose_line( GLcontext *ctx ) } else { ASSERT(!ctx->Depth.Test); + ASSERT(ctx->Line.Width == 1.0); /* simple lines */ if (rgbmode) USE(simple_no_z_rgba_line); diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 8eba53c807..4768fbea97 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -76,7 +76,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* already clamped to user range */ + size = ctx->Point.Size; } /* clamp to non-AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); @@ -227,7 +227,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* this is already clamped */ + size = ctx->Point.Size; } /* clamp to AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); @@ -361,7 +361,7 @@ large_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* already clamped to user range */ + size = ctx->Point.Size; } /* clamp to non-AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); @@ -550,7 +550,7 @@ _swrast_choose_point(GLcontext *ctx) else if (ctx->Point.SmoothFlag) { swrast->Point = smooth_point; } - else if (ctx->Point._Size > 1.0 || + else if (ctx->Point.Size > 1.0 || ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { swrast->Point = large_point; diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index 6aae602037..a6728c318f 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -233,7 +233,7 @@ void _tnl_get_attr( GLcontext *ctx, const void *vin, /* If the hardware vertex doesn't have point size then use size from * GLcontext. XXX this will be wrong if drawing attenuated points! */ - dest[0] = ctx->Point._Size; + dest[0] = ctx->Point.Size; } else { _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); diff --git a/src/mesa/tnl_dd/t_dd_vb.c b/src/mesa/tnl_dd/t_dd_vb.c index ab3bb37631..3cedd90119 100644 --- a/src/mesa/tnl_dd/t_dd_vb.c +++ b/src/mesa/tnl_dd/t_dd_vb.c @@ -184,7 +184,7 @@ void TAG(translate_vertex)(GLcontext *ctx, } } - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } -- cgit v1.2.3 From 76fb8089103e9dba9aaa7232c86d864d5874a08f Mon Sep 17 00:00:00 2001 From: Zhang Date: Sat, 21 Jul 2007 11:28:06 -0600 Subject: Fix a number of MINGW32 issues --- src/glu/sgi/Makefile.mgw | 229 +++++++++++++++++++++++++++ src/glu/sgi/libnurbs/interface/glcurveval.h | 2 +- src/glu/sgi/libnurbs/interface/glsurfeval.cc | 7 +- src/glu/sgi/libnurbs/interface/glsurfeval.h | 2 +- src/glut/glx/Makefile.mgw | 198 +++++++++++++++++++++++ src/glut/glx/glut_fbc.c | 4 +- src/glut/glx/glutint.h | 3 + src/glut/glx/win32_winproc.c | 3 + src/mesa/Makefile.mgw | 51 ++++-- src/mesa/drivers/windows/gdi/wgl.c | 57 ++++--- src/mesa/drivers/windows/gdi/wmesa.c | 7 +- src/mesa/drivers/windows/gdi/wmesadef.h | 4 +- src/mesa/main/glheader.h | 2 +- src/mesa/main/imports.c | 4 + src/mesa/main/imports.h | 4 + src/mesa/main/shaders.c | 8 +- src/mesa/main/texcompress_fxt1.c | 5 + 17 files changed, 544 insertions(+), 46 deletions(-) create mode 100644 src/glu/sgi/Makefile.mgw create mode 100644 src/glut/glx/Makefile.mgw (limited to 'src') diff --git a/src/glu/sgi/Makefile.mgw b/src/glu/sgi/Makefile.mgw new file mode 100644 index 0000000000..43b421e737 --- /dev/null +++ b/src/glu/sgi/Makefile.mgw @@ -0,0 +1,229 @@ +# Mesa 3-D graphics library +# Version: 5.1 +# +# Copyright (C) 1999-2003 Brian Paul All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# MinGW core makefile v1.4 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + +# MinGW core-glu makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + +# +# Available options: +# +# Environment variables: +# CFLAGS +# +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most WMesa code and requires fxMesa. +# As a consequence, you'll need the Win32 Glide3 +# library to build any application. +# default = no +# ICD=1 build the installable client driver interface +# (windows opengl driver interface) +# default = no +# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow). +# default = no +# +# Targets: +# all: build GL +# clean: remove object files +# + + + +.PHONY: all clean +.INTERMEDIATE: x86/gen_matypes.exe +.SUFFIXES: .rc .res + +# Set this to the prefix of your build tools, i.e. mingw32- +TOOLS_PREFIX = mingw32- + +TOP = ../../.. + +LIBDIR = $(TOP)/lib + +GLU_DLL = glu32.dll +GLU_IMP = libglu32.a +GLU_DEF = glu.def + +include $(TOP)/configs/config.mgw +GL_USING_STDCALL ?= 1 + +LDLIBS = -L$(LIBDIR) -lopengl32 +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLU_IMP) -Wl,--output-def=$(LIBDIR)/$(GLU_DEF) + +CFLAGS += -DBUILD_GLU32 -D_DLL + +ifeq ($(GL_USING_STDCALL),1) + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGL_NO_STDCALL +endif + +CC = gcc +CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude +CXX = g++ +CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess + +AR = ar +ARFLAGS = crus + +UNLINK = del $(subst /,\,$(1)) +ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif +ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif + +C_SOURCES = \ + libutil/error.c \ + libutil/glue.c \ + libutil/mipmap.c \ + libutil/project.c \ + libutil/quad.c \ + libutil/registry.c \ + libtess/dict.c \ + libtess/geom.c \ + libtess/memalloc.c \ + libtess/mesh.c \ + libtess/normal.c \ + libtess/priorityq.c \ + libtess/render.c \ + libtess/sweep.c \ + libtess/tess.c \ + libtess/tessmono.c + +CC_SOURCES = \ + libnurbs/interface/bezierEval.cc \ + libnurbs/interface/bezierPatch.cc \ + libnurbs/interface/bezierPatchMesh.cc \ + libnurbs/interface/glcurveval.cc \ + libnurbs/interface/glinterface.cc \ + libnurbs/interface/glrenderer.cc \ + libnurbs/interface/glsurfeval.cc \ + libnurbs/interface/incurveeval.cc \ + libnurbs/interface/insurfeval.cc \ + libnurbs/internals/arc.cc \ + libnurbs/internals/arcsorter.cc \ + libnurbs/internals/arctess.cc \ + libnurbs/internals/backend.cc \ + libnurbs/internals/basiccrveval.cc \ + libnurbs/internals/basicsurfeval.cc \ + libnurbs/internals/bin.cc \ + libnurbs/internals/bufpool.cc \ + libnurbs/internals/cachingeval.cc \ + libnurbs/internals/ccw.cc \ + libnurbs/internals/coveandtiler.cc \ + libnurbs/internals/curve.cc \ + libnurbs/internals/curvelist.cc \ + libnurbs/internals/curvesub.cc \ + libnurbs/internals/dataTransform.cc \ + libnurbs/internals/displaylist.cc \ + libnurbs/internals/flist.cc \ + libnurbs/internals/flistsorter.cc \ + libnurbs/internals/hull.cc \ + libnurbs/internals/intersect.cc \ + libnurbs/internals/knotvector.cc \ + libnurbs/internals/mapdesc.cc \ + libnurbs/internals/mapdescv.cc \ + libnurbs/internals/maplist.cc \ + libnurbs/internals/mesher.cc \ + libnurbs/internals/monoTriangulationBackend.cc \ + libnurbs/internals/monotonizer.cc \ + libnurbs/internals/mycode.cc \ + libnurbs/internals/nurbsinterfac.cc \ + libnurbs/internals/nurbstess.cc \ + libnurbs/internals/patch.cc \ + libnurbs/internals/patchlist.cc \ + libnurbs/internals/quilt.cc \ + libnurbs/internals/reader.cc \ + libnurbs/internals/renderhints.cc \ + libnurbs/internals/slicer.cc \ + libnurbs/internals/sorter.cc \ + libnurbs/internals/splitarcs.cc \ + libnurbs/internals/subdivider.cc \ + libnurbs/internals/tobezier.cc \ + libnurbs/internals/trimline.cc \ + libnurbs/internals/trimregion.cc \ + libnurbs/internals/trimvertpool.cc \ + libnurbs/internals/uarray.cc \ + libnurbs/internals/varray.cc \ + libnurbs/nurbtess/directedLine.cc \ + libnurbs/nurbtess/gridWrap.cc \ + libnurbs/nurbtess/monoChain.cc \ + libnurbs/nurbtess/monoPolyPart.cc \ + libnurbs/nurbtess/monoTriangulation.cc \ + libnurbs/nurbtess/partitionX.cc \ + libnurbs/nurbtess/partitionY.cc \ + libnurbs/nurbtess/polyDBG.cc \ + libnurbs/nurbtess/polyUtil.cc \ + libnurbs/nurbtess/primitiveStream.cc \ + libnurbs/nurbtess/quicksort.cc \ + libnurbs/nurbtess/rectBlock.cc \ + libnurbs/nurbtess/sampleComp.cc \ + libnurbs/nurbtess/sampleCompBot.cc \ + libnurbs/nurbtess/sampleCompRight.cc \ + libnurbs/nurbtess/sampleCompTop.cc \ + libnurbs/nurbtess/sampleMonoPoly.cc \ + libnurbs/nurbtess/sampledLine.cc \ + libnurbs/nurbtess/searchTree.cc + +SOURCES = $(C_SOURCES) $(CC_SOURCES) + +OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.cc.o: + $(CXX) -o $@ $(CXXFLAGS) -c $< + + +all: $(LIBDIR) $(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP) + +$(LIBDIR): + mkdir -p $(LIBDIR) + +$(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP): $(OBJECTS) + g++ -shared -fPIC -o $(LIBDIR)/$(GLU_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) + + + +clean: + -$(call UNLINK,libutil/*.o) + -$(call UNLINK,libtess/*.o) + -$(call UNLINK,libnurbs/interface/*.o) + -$(call UNLINK,libnurbs/internals/*.o) + -$(call UNLINK,libnurbs/nurbtess/*.o) diff --git a/src/glu/sgi/libnurbs/interface/glcurveval.h b/src/glu/sgi/libnurbs/interface/glcurveval.h index 4b44f6e847..a09a74d04c 100644 --- a/src/glu/sgi/libnurbs/interface/glcurveval.h +++ b/src/glu/sgi/libnurbs/interface/glcurveval.h @@ -93,7 +93,7 @@ public: output_triangles = flag; } #ifdef _WIN32 - void putCallBack(GLenum which, void (APIENTRY *fn)() ); + void putCallBack(GLenum which, void (GLAPIENTRY *fn)() ); #else void putCallBack(GLenum which, _GLUfuncptr fn ); #endif diff --git a/src/glu/sgi/libnurbs/interface/glsurfeval.cc b/src/glu/sgi/libnurbs/interface/glsurfeval.cc index a36b304508..b5bfab1e28 100644 --- a/src/glu/sgi/libnurbs/interface/glsurfeval.cc +++ b/src/glu/sgi/libnurbs/interface/glsurfeval.cc @@ -1184,8 +1184,11 @@ return; } -void -OpenGLSurfaceEvaluator::putCallBack(GLenum which, _GLUfuncptr fn ) +#ifdef _WIN32 +void OpenGLSurfaceEvaluator::putCallBack(GLenum which, void (GLAPIENTRY *fn)() ) +#else +void OpenGLSurfaceEvaluator::putCallBack(GLenum which, _GLUfuncptr fn ) +#endif { switch(which) { diff --git a/src/glu/sgi/libnurbs/interface/glsurfeval.h b/src/glu/sgi/libnurbs/interface/glsurfeval.h index c34a58cb9b..b7a88069f5 100644 --- a/src/glu/sgi/libnurbs/interface/glsurfeval.h +++ b/src/glu/sgi/libnurbs/interface/glsurfeval.h @@ -145,7 +145,7 @@ public: void newtmeshvert( long, long ); #ifdef _WIN32 - void putCallBack(GLenum which, void (APIENTRY *fn)() ); + void putCallBack(GLenum which, void (GLAPIENTRY *fn)() ); #else void putCallBack(GLenum which, _GLUfuncptr fn ); #endif diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw new file mode 100644 index 0000000000..ae4eb6addc --- /dev/null +++ b/src/glut/glx/Makefile.mgw @@ -0,0 +1,198 @@ +# Mesa 3-D graphics library +# Version: 5.1 +# +# Copyright (C) 1999-2003 Brian Paul All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# MinGW core makefile v1.4 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + +# MinGW core-glut makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + + +# +# Available options: +# +# Environment variables: +# CFLAGS +# +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most WMesa code and requires fxMesa. +# As a consequence, you'll need the Win32 Glide3 +# library to build any application. +# default = no +# ICD=1 build the installable client driver interface +# (windows opengl driver interface) +# default = no +# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow). +# default = no +# +# Targets: +# all: build GL +# clean: remove object files +# + + + +.PHONY: all clean +.INTERMEDIATE: x86/gen_matypes.exe +.SUFFIXES: .rc .res + +# Set this to the prefix of your build tools, i.e. mingw32- +TOOLS_PREFIX = mingw32- + +TOP = ../../.. + +LIBDIR = $(TOP)/lib + +GLUT_DLL = glut32.dll +GLUT_IMP = libglut32.a +GLUT_DEF = glut.def + +include $(TOP)/configs/config.mgw +GLUT_USING_STDCALL ?= 1 + + + +LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLUT_IMP) -Wl,--output-def=$(LIBDIR)/$(GLUT_DEF) + +CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL + +ifeq ($(GL_USING_STDCALL),0) + CFLAGS += -DGL_NO_STDCALL +endif + +ifeq ($(GLUT_USING_STDCALL),1) + CFLAGS += -D_STDCALL_SUPPORTED + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGLUT_NO_STDCALL +endif + +CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include + +CC = gcc +CXX = g++ +CXXFLAGS = $(CFLAGS) + +AR = ar +ARFLAGS = crus + +UNLINK = del $(subst /,\,$(1)) +ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif +ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif + +HDRS = glutint.h glutstroke.h glutbitmap.h glutwin32.h stroke.h win32_glx.h win32_x11.h + +SRCS = \ + glut_bitmap.c \ + glut_bwidth.c \ + glut_cindex.c \ + glut_cmap.c \ + glut_cursor.c \ + glut_dials.c \ + glut_dstr.c \ + glut_event.c \ + glut_ext.c \ + glut_fbc.c \ + glut_fullscrn.c \ + glut_gamemode.c \ + glut_get.c \ + glut_init.c \ + glut_input.c \ + glut_joy.c \ + glut_key.c \ + glut_keyctrl.c \ + glut_keyup.c \ + glut_mesa.c \ + glut_modifier.c \ + glut_overlay.c \ + glut_shapes.c \ + glut_space.c \ + glut_stroke.c \ + glut_swap.c \ + glut_swidth.c \ + glut_tablet.c \ + glut_teapot.c \ + glut_util.c \ + glut_vidresize.c \ + glut_warp.c \ + glut_win.c \ + glut_winmisc.c \ + win32_glx.c \ + win32_menu.c \ + win32_util.c \ + win32_winproc.c \ + win32_x11.c + + +SRCSSEMIGENS = \ + glut_8x13.c \ + glut_9x15.c \ + glut_hel10.c \ + glut_hel12.c \ + glut_hel18.c \ + glut_mroman.c \ + glut_roman.c \ + glut_tr10.c \ + glut_tr24.c + + + +SOURCES = $(SRCS) $(SRCSSEMIGENS) + +OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.cc.o: + $(CXX) -o $@ $(CXXFLAGS) -c $< + + +all: $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP) + +$(LIBDIR): + mkdir -p $(LIBDIR) + +$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS) + $(CXX) -shared -fPIC -o $(LIBDIR)/$(GLUT_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) + + + +clean: + -$(call UNLINK,*.o) \ No newline at end of file diff --git a/src/glut/glx/glut_fbc.c b/src/glut/glx/glut_fbc.c index deb46c3d8d..e93188b862 100644 --- a/src/glut/glx/glut_fbc.c +++ b/src/glut/glx/glut_fbc.c @@ -18,7 +18,7 @@ /* Set a Fortran callback function. */ -void GLUTAPIENTRY +void APIENTRY __glutSetFCB(int which, void *func) { #ifdef SUPPORT_FORTRAN @@ -100,7 +100,7 @@ __glutSetFCB(int which, void *func) /* Get a Fortran callback function. */ -void* GLUTAPIENTRY +void* APIENTRY __glutGetFCB(int which) { #ifdef SUPPORT_FORTRAN diff --git a/src/glut/glx/glutint.h b/src/glut/glx/glutint.h index 6fe09ffe7e..a962c78023 100644 --- a/src/glut/glx/glutint.h +++ b/src/glut/glx/glutint.h @@ -26,7 +26,10 @@ #include #endif +#ifndef GLUT_BUILDING_LIB #define GLUT_BUILDING_LIB /* Building the GLUT library itself. */ +#endif + #include #if defined(MESA) && defined(_WIN32) && !defined(__CYGWIN32__) diff --git a/src/glut/glx/win32_winproc.c b/src/glut/glx/win32_winproc.c index a54bac75fa..e1fc785ebb 100644 --- a/src/glut/glx/win32_winproc.c +++ b/src/glut/glx/win32_winproc.c @@ -9,6 +9,9 @@ #include "glutint.h" #include +#ifdef __MINGW32__ +#include +#endif #if defined(_WIN32) && !defined(__CYGWIN32__) #include /* Win32 Multimedia API header. */ diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index ebec5c055a..3b52834bd1 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -1,5 +1,5 @@ # Mesa 3-D graphics library -# Version: 5.1 +# Version: 7.0 # # Copyright (C) 1999-2003 Brian Paul All Rights Reserved. # @@ -26,6 +26,16 @@ # Email : dborca@users.sourceforge.net # Web : http://www.geocities.com/dborca +# MinGW core-gl makefile updated for Mesa 7.0 +# +# updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + # # Available options: @@ -52,7 +62,6 @@ # - .PHONY: all clean .INTERMEDIATE: x86/gen_matypes.exe .SUFFIXES: .rc .res @@ -60,6 +69,8 @@ # Set this to the prefix of your build tools, i.e. mingw32- TOOLS_PREFIX = mingw32- + + TOP = ../.. GLIDE ?= $(TOP)/glide3 LIBDIR = $(TOP)/lib @@ -71,11 +82,25 @@ else GL_IMP = libopengl32.a endif -LDLIBS = -lgdi32 +GL_DEF = gl.def + +include $(TOP)/configs/config.mgw +GL_USING_STDCALL ?= 1 + +MESA_LIB = libmesa.a + +LDLIBS = -lgdi32 -luser32 -liberty +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def CC = $(TOOLS_PREFIX)gcc -CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -CFLAGS += $(INCLUDE_DIRS) +CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS + +ifeq ($(GL_USING_STDCALL),1) + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGL_NO_STDCALL +endif + CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1 ifeq ($(FX),1) CFLAGS += -I$(GLIDE)/include -DFX @@ -104,6 +129,8 @@ endif include sources +CFLAGS += $(INCLUDE_DIRS) + ifeq ($(X86),1) CFLAGS += -DUSE_X86_ASM CFLAGS += -DUSE_MMX_ASM @@ -140,10 +167,9 @@ RESOURCE = $(GL_RES:.rc=.res) .c.o: $(CC) -o $@ $(CFLAGS) -c $< -.S.o: - $(CC) -o $@ $(CFLAGS) -c $< .s.o: $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $< + .rc.res: windres -o $@ -Irc -Ocoff $< @@ -153,9 +179,8 @@ $(LIBDIR): mkdir -p $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE) - $(TOOLS_PREFIX)dllwrap -o $(LIBDIR)/$(GL_DLL) --output-lib $(LIBDIR)/$(GL_IMP) \ - --target i386-mingw32 --def $(GL_DEF) -Wl,-enable-stdcall-fixup \ - $^ $(LDLIBS) + $(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) $(X86_OBJECTS): x86/matypes.h @@ -187,17 +212,21 @@ tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $< clean: - -$(call UNLINK,array_cache/*.o) -$(call UNLINK,glapi/*.o) -$(call UNLINK,main/*.o) -$(call UNLINK,math/*.o) + -$(call UNLINK,vbo/*.o) -$(call UNLINK,shader/*.o) + -$(call UNLINK,shader/slang/*.o) + -$(call UNLINK,shader/grammar/*.o) -$(call UNLINK,sparc/*.o) -$(call UNLINK,ppc/*.o) -$(call UNLINK,swrast/*.o) -$(call UNLINK,swrast_setup/*.o) -$(call UNLINK,tnl/*.o) -$(call UNLINK,x86/*.o) + -$(call UNLINK,x86/rtasm/*.o) + -$(call UNLINK,x86-64/*.o) -$(call UNLINK,drivers/common/*.o) -$(call UNLINK,drivers/glide/*.o) -$(call UNLINK,drivers/windows/fx/*.o) diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index fb23d210db..dad3dc1160 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -33,15 +33,30 @@ /* We're essentially building part of GDI here, so define this so that * we get the right export linkage. */ #ifdef __MINGW32__ -#include + +#include +#include +#include +#include + +# if defined(BUILD_GL32) +# define WINGDIAPI __declspec(dllexport) +# else +# define __W32API_USE_DLLIMPORT__ +# endif + +#include +#include "GL/mesa_wgl.h" #include + #else + #define _GDI32_ -#endif #include -#include "glapi.h" +#endif +#include "glapi.h" #include "GL/wmesa.h" /* protos for wmesa* functions */ /* @@ -339,7 +354,7 @@ WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) } WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - const PIXELFORMATDESCRIPTOR *ppfd) + const PIXELFORMATDESCRIPTOR *ppfd) { (void) hdc; @@ -392,12 +407,12 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, bitDevice = CreateCompatibleDC(fontDevice); - // Swap fore and back colors so the bitmap has the right polarity + /* Swap fore and back colors so the bitmap has the right polarity */ tempColor = GetBkColor(bitDevice); SetBkColor(bitDevice, GetTextColor(bitDevice)); SetTextColor(bitDevice, tempColor); - // Place chars based on base line + /* Place chars based on base line */ VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0); for(i = 0; i < (int)numChars; i++) { @@ -410,36 +425,36 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, curChar = (char)(i + firstChar); - // Find how high/wide this character is + /* Find how high/wide this character is */ VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size)); - // Create the output bitmap + /* Create the output bitmap */ charWidth = size.cx; charHeight = size.cy; - // Round up to the next multiple of 32 bits + /* Round up to the next multiple of 32 bits */ bmapWidth = ((charWidth + 31) / 32) * 32; bmapHeight = charHeight; bitObject = CreateCompatibleBitmap(bitDevice, bmapWidth, bmapHeight); - //VERIFY(bitObject); + /* VERIFY(bitObject); */ - // Assign the output bitmap to the device + /* Assign the output bitmap to the device */ origBmap = SelectObject(bitDevice, bitObject); (void) VERIFY(origBmap); VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) ); - // Use our source font on the device + /* Use our source font on the device */ VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT))); - // Draw the character + /* Draw the character */ VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1)); - // Unselect our bmap object + /* Unselect our bmap object */ VERIFY(SelectObject(bitDevice, origBmap)); - // Convert the display dependant representation to a 1 bit deep DIB + /* Convert the display dependant representation to a 1 bit deep DIB */ numBytes = (bmapWidth * bmapHeight) / 8; bmap = malloc(numBytes); dibInfo->bmiHeader.biWidth = bmapWidth; @@ -447,24 +462,24 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, dibInfo, DIB_RGB_COLORS); - //VERIFY(res); + /* VERIFY(res); */ - // Create the GL object + /* Create the GL object */ glNewList(i + listBase, GL_COMPILE); glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent, (GLfloat)charWidth, 0.0, bmap); glEndList(); - // CheckGL(); + /* CheckGL(); */ - // Destroy the bmap object + /* Destroy the bmap object */ DeleteObject(bitObject); - // Deallocate the bitmap data + /* Deallocate the bitmap data */ free(bmap); } - // Destroy the DC + /* Destroy the DC */ VERIFY(DeleteDC(bitDevice)); free(dibInfo); diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 2eec188912..5b67439f0f 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -6,6 +6,7 @@ #include "wmesadef.h" #include "colors.h" #include +#include #include "context.h" #include "extensions.h" #include "framebuffer.h" @@ -114,7 +115,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) { pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); - // Only 16 and 32 bit targets are supported now + /* Only 16 and 32 bit targets are supported now */ assert(pwfb->cColorBits == 0 || pwfb->cColorBits == 16 || pwfb->cColorBits == 32); @@ -1171,7 +1172,7 @@ WMesaContext WMesaCreateContext(HDC hDC, /* I do not understand this contributed code */ /* Support memory and device contexts */ if(WindowFromDC(hDC) != NULL) { - c->hDC = GetDC(WindowFromDC(hDC)); // huh ???? + c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */ } else { c->hDC = hDC; @@ -1404,6 +1405,7 @@ void WMesaSwapBuffers( HDC hdc ) * table entries. Hopefully, I'll find a better solution. The * dispatch table generation scripts ought to be making these dummy * stubs as well. */ +#if !defined(__MINGW32__) || !defined(GL_NO_STDCALL) void gl_dispatch_stub_543(void){} void gl_dispatch_stub_544(void){} void gl_dispatch_stub_545(void){} @@ -1471,3 +1473,4 @@ void gl_dispatch_stub_769(void){} void gl_dispatch_stub_770(void){} void gl_dispatch_stub_771(void){} +#endif diff --git a/src/mesa/drivers/windows/gdi/wmesadef.h b/src/mesa/drivers/windows/gdi/wmesadef.h index 97b063a8ba..83a42e6082 100644 --- a/src/mesa/drivers/windows/gdi/wmesadef.h +++ b/src/mesa/drivers/windows/gdi/wmesadef.h @@ -1,6 +1,8 @@ #ifndef WMESADEF_H #define WMESADEF_H - +#ifdef __MINGW32__ +#include +#endif #include "context.h" diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 63dd002a41..fd4127558a 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -92,7 +92,7 @@ #endif #ifdef WGLAPI -#undef WGLAPI +# undef WGLAPI #endif #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 8a5dfdb4b8..3ae56c8b0b 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -575,7 +575,11 @@ _mesa_ffs(int i) * if no bits set. */ int +#ifdef __MINGW32__ +_mesa_ffsll(long val) +#else _mesa_ffsll(long long val) +#endif { #ifdef ffsll return ffsll(val); diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 9be8014a13..ebdfc452a7 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -700,7 +700,11 @@ extern int _mesa_ffs(int i); extern int +#ifdef __MINGW32__ +_mesa_ffsll(long i); +#else _mesa_ffsll(long long i); +#endif extern unsigned int _mesa_bitcount(unsigned int n); diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index 58be1f46e5..7bf8808767 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -83,7 +83,7 @@ _mesa_CreateShader(GLenum type) } -GLhandleARB APIENTRY +GLhandleARB GLAPIENTRY _mesa_CreateShaderObjectARB(GLenum type) { GET_CURRENT_CONTEXT(ctx); @@ -99,7 +99,7 @@ _mesa_CreateProgram(void) } -GLhandleARB APIENTRY +GLhandleARB GLAPIENTRY _mesa_CreateProgramObjectARB(void) { GET_CURRENT_CONTEXT(ctx); @@ -319,7 +319,7 @@ _mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint * params) #if 0 -GLint APIENTRY +GLint GLAPIENTRY _mesa_GetUniformLocation(GLuint program, const GLcharARB *name) { GET_CURRENT_CONTEXT(ctx); @@ -336,7 +336,7 @@ _mesa_GetHandleARB(GLenum pname) } -GLint APIENTRY +GLint GLAPIENTRY _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) { GET_CURRENT_CONTEXT(ctx); diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 411d51cfcc..b6991f45ed 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -302,7 +302,12 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { #define FX64_NATIVE 1 +#ifdef __MINGW32__ +typedef unsigned long Fx64; +#else typedef unsigned long long Fx64; +#endif + #define FX64_MOV32(a, b) a = b #define FX64_OR32(a, b) a |= b -- cgit v1.2.3 From da2f1e88bc63403a95b89706905c070b7c894863 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 23 Jul 2007 16:51:57 -0600 Subject: fix GLX_STEREO handling (bug 11705) --- src/mesa/drivers/x11/fakeglx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 1587df66bc..7a170b4d3d 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -296,6 +296,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, } } + if (stereoFlag) { + /* stereo not supported */ + return NULL; + } + /* Comparing IDs uses less memory but sometimes fails. */ /* XXX revisit this after 3.0 is finished. */ if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) @@ -1079,7 +1084,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) else { stereo_flag = GL_TRUE; } - return NULL; /* stereo not supported */ + break; case GLX_AUX_BUFFERS: parselist++; numAux = *parselist++; -- cgit v1.2.3 From 5b6858c023fca9d8eefce78121aabd9aad108e09 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 24 Jul 2007 09:56:44 -0600 Subject: call ctx->Driver.NewProgram() instead of _mesa_new_program() --- src/mesa/shader/program.c | 2 +- src/mesa/shader/slang/slang_compile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 4205919828..1f227390af 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -333,7 +333,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog) { struct gl_program *clone; - clone = _mesa_new_program(ctx, prog->Target, prog->Id); + clone = ctx->Driver.NewProgram(ctx, prog->Target, prog->Id); if (!clone) return NULL; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 70f5aac16d..4e29e8dcc9 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2135,7 +2135,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader) progTarget = GL_FRAGMENT_PROGRAM_ARB; shader->Programs = (struct gl_program **) malloc(sizeof(struct gl_program*)); - shader->Programs[0] = _mesa_new_program(ctx, progTarget, 1); + shader->Programs[0] = ctx->Driver.NewProgram(ctx, progTarget, 1); shader->NumPrograms = 1; shader->Programs[0]->Parameters = _mesa_new_parameter_list(); -- cgit v1.2.3 From 03ec41ddc51e539c989a546f33d22daa2af69095 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 24 Jul 2007 17:45:14 -0600 Subject: remove unused MAX_3D_TEXTURE_SIZE, reformattting --- src/mesa/main/mtypes.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5fdd88262..3e4c49249a 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1131,13 +1131,13 @@ struct gl_stencil_attrib * An index for each type of texture object */ /*@{*/ -#define TEXTURE_1D_INDEX 0 -#define TEXTURE_2D_INDEX 1 -#define TEXTURE_3D_INDEX 2 -#define TEXTURE_CUBE_INDEX 3 -#define TEXTURE_RECT_INDEX 4 -#define TEXTURE_1D_ARRAY_INDEX 5 -#define TEXTURE_2D_ARRAY_INDEX 6 +#define TEXTURE_1D_INDEX 0 +#define TEXTURE_2D_INDEX 1 +#define TEXTURE_3D_INDEX 2 +#define TEXTURE_CUBE_INDEX 3 +#define TEXTURE_RECT_INDEX 4 +#define TEXTURE_1D_ARRAY_INDEX 5 +#define TEXTURE_2D_ARRAY_INDEX 6 /*@}*/ /** @@ -1145,13 +1145,13 @@ struct gl_stencil_attrib * Used for Texture.Unit[]._ReallyEnabled flags. */ /*@{*/ -#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) -#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) -#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) -#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) -#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) -#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) -#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) +#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) +#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) +#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) +#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) +#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) +#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) /*@}*/ @@ -1325,8 +1325,6 @@ struct gl_texture_format }; -#define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1)) - /** * Texture image state. Describes the dimensions of a texture image, * the texel format and pointers to Texel Fetch functions. @@ -1391,7 +1389,7 @@ struct gl_texture_image #define FACE_NEG_Y 3 #define FACE_POS_Z 4 #define FACE_NEG_Z 5 -#define MAX_FACES 6 +#define MAX_FACES 6 /*@}*/ @@ -2191,12 +2189,11 @@ struct gl_shared_state * \todo Improve the granularity of locking. */ /*@{*/ - _glthread_Mutex TexMutex; /**< texobj thread safety */ - GLuint TextureStateStamp; /**< state notification for shared tex */ + _glthread_Mutex TexMutex; /**< texobj thread safety */ + GLuint TextureStateStamp; /**< state notification for shared tex */ /*@}*/ - /** * \name Vertex/fragment programs */ -- cgit v1.2.3 From efda5cb6263631175aa2efe46df9322b3c5775ee Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 08:22:09 -0600 Subject: don't use rgba_line() if CHAN_BITS==32 --- src/mesa/swrast/s_lines.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 15ef6233ed..3de438760b 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -279,7 +279,11 @@ _swrast_choose_line( GLcontext *ctx ) || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ if (rgbmode) +#if CHAN_BITS == 32 + USE(general_line); +#else USE(rgba_line); +#endif else USE(ci_line); } -- cgit v1.2.3 From 51b728cf9aff383142a2a1e220a7d8963d1ca189 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 08:22:28 -0600 Subject: fix color interpolation for CHAN_BITS==32 --- src/mesa/swrast/s_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index f23272c2be..cfc65bee87 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1358,7 +1358,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) #if CHAN_BITS == 32 if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) { - interpolate_int_colors(ctx, span); + interpolate_active_attribs(ctx, span, FRAG_BIT_COL0); } #else if ((span->arrayMask & SPAN_RGBA) == 0) { -- cgit v1.2.3 From 9ed040c3c9afe06a8f6b28bc223751e3b2d65fe3 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 11:39:11 -0600 Subject: generate error upon writing to varying var in fragment program (bug 11733) --- src/mesa/shader/slang/slang_codegen.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 35e80e0452..c1664a5ccb 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2236,7 +2236,9 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) } if (var->type.qualifier == SLANG_QUAL_CONST || var->type.qualifier == SLANG_QUAL_ATTRIBUTE || - var->type.qualifier == SLANG_QUAL_UNIFORM) { + var->type.qualifier == SLANG_QUAL_UNIFORM || + (var->type.qualifier == SLANG_QUAL_VARYING && + A->program->Target == GL_FRAGMENT_PROGRAM_ARB)) { slang_info_log_error(A->log, "illegal assignment to read-only variable '%s'", (char *) oper->children[0].a_id); @@ -2264,10 +2266,11 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) lhs = _slang_gen_operation(A, &oper->children[0]); if (lhs) { - if (lhs->Store->File != PROGRAM_OUTPUT && - lhs->Store->File != PROGRAM_TEMPORARY && - lhs->Store->File != PROGRAM_VARYING && - lhs->Store->File != PROGRAM_UNDEFINED) { + if (!(lhs->Store->File == PROGRAM_OUTPUT || + lhs->Store->File == PROGRAM_TEMPORARY || + (lhs->Store->File == PROGRAM_VARYING && + A->program->Target == GL_VERTEX_PROGRAM_ARB) || + lhs->Store->File == PROGRAM_UNDEFINED)) { slang_info_log_error(A->log, "illegal assignment to read-only l-value"); return NULL; -- cgit v1.2.3 From e3cef5887540016a6d198598cb50bebe09e3f4cf Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 15:32:02 -0600 Subject: Fix function call bug 11731. Also, fix up IR_CALL/IR_FUNC confusion. --- src/mesa/shader/slang/slang_codegen.c | 27 +++++++++++++++++++-------- src/mesa/shader/slang/slang_emit.c | 16 +++++++++------- src/mesa/shader/slang/slang_ir.c | 2 +- src/mesa/shader/slang/slang_ir.h | 2 -- 4 files changed, 29 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index c1664a5ccb..8b2bdd74b5 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -536,7 +536,7 @@ new_not(slang_ir_node *n) static slang_ir_node * new_inlined_function_call(slang_ir_node *code, slang_label *name) { - slang_ir_node *n = new_node1(IR_FUNC, code); + slang_ir_node *n = new_node1(IR_CALL, code); assert(name); if (n) n->Label = name; @@ -1202,17 +1202,29 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, /* non-assembly function */ inlined = slang_inline_function_call(A, fun, oper, dest); if (inlined && _slang_find_node_type(inlined, SLANG_OPER_RETURN)) { - /* This inlined function has one or more 'return' statements. + slang_operation *callOper; + /* The function we're calling has one or more 'return' statements. * So, we can't truly inline this function because we need to * implement 'return' with RET (and CAL). + * Nevertheless, we performed "inlining" to make a new instance + * of the function body to deal with static register allocation. + * * XXX check if there's one 'return' and if it's the very last * statement in the function - we can optimize that case. */ assert(inlined->type == SLANG_OPER_BLOCK_NEW_SCOPE || inlined->type == SLANG_OPER_SEQUENCE); - inlined->type = SLANG_OPER_INLINED_CALL; - inlined->fun = fun; - inlined->label = _slang_label_new_unique((char*) fun->header.a_name); + if (_slang_function_has_return_value(fun) && !dest) { + assert(inlined->children[0].type == SLANG_OPER_VARIABLE_DECL); + assert(inlined->children[2].type == SLANG_OPER_IDENTIFIER); + callOper = &inlined->children[1]; + } + else { + callOper = inlined; + } + callOper->type = SLANG_OPER_INLINED_CALL; + callOper->fun = fun; + callOper->label = _slang_label_new_unique((char*) fun->header.a_name); } } @@ -1949,8 +1961,7 @@ static slang_ir_node * _slang_gen_return(slang_assemble_ctx * A, slang_operation *oper) { const GLboolean haveReturnValue - = (oper->num_children == 1 && - oper->children[0].type != SLANG_OPER_VOID); + = (oper->num_children == 1 && oper->children[0].type != SLANG_OPER_VOID); /* error checking */ assert(A->CurFunction); @@ -1960,7 +1971,7 @@ _slang_gen_return(slang_assemble_ctx * A, slang_operation *oper) return NULL; } else if (!haveReturnValue && - A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) { + A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) { slang_info_log_error(A->log, "return statement requires an expression"); return NULL; } diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 02c74095a9..fe13f2865c 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -780,16 +780,18 @@ emit_label(slang_emit_info *emitInfo, const slang_ir_node *n) /** - * Emit code for an inlined function call (subroutine). + * Emit code for a function call. + * Note that for each time a function is called, we emit the function's + * body code again because the set of available registers may be different. */ static struct prog_instruction * -emit_func(slang_emit_info *emitInfo, slang_ir_node *n) +emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n) { struct gl_program *progSave; struct prog_instruction *inst; GLuint subroutineId; - assert(n->Opcode == IR_FUNC); + assert(n->Opcode == IR_CALL); assert(n->Label); /* save/push cur program */ @@ -1687,10 +1689,10 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n) case IR_KILL: return emit_kill(emitInfo); - case IR_FUNC: - /* new variable scope for subroutines/function calls*/ + case IR_CALL: + /* new variable scope for subroutines/function calls */ _slang_push_var_table(emitInfo->vt); - inst = emit_func(emitInfo, n); + inst = emit_fcall(emitInfo, n); _slang_pop_var_table(emitInfo->vt); return inst; @@ -1782,7 +1784,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) emitInfo->NumSubroutines = 0; /* Examine CAL instructions. - * At this point, the BranchTarget field of the CAL instructions is + * At this point, the BranchTarget field of the CAL instruction is * the number/id of the subroutine to call (an index into the * emitInfo->Subroutines list). * Translate that into an actual instruction location now. diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index a29f302687..92e8d0345e 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -311,7 +311,7 @@ _slang_print_ir_tree(const slang_ir_node *n, int indent) printf("RETURN\n"); break; case IR_CALL: - printf("CALL\n"); + printf("CALL %s\n", n->Label->Name); break; case IR_LOOP: diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index 69db4b5451..c7c0ddbf9a 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -62,8 +62,6 @@ typedef enum IR_RETURN, /* return from subroutine */ IR_CALL, /* call subroutine */ - IR_FUNC, /* inlined function code */ - IR_LOOP, /* high-level loop-begin / loop-end */ /* Children[0] = loop body */ /* Children[1] = loop tail code, or NULL */ -- cgit v1.2.3