From 9f952cceb453d6273188a2c71d4e92dbdd454be0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 18 Feb 2010 11:26:18 +0100 Subject: [PATCH 001/483] tgsi: Rewrite exec implementations of NRM and NRM4. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 131 +++++++++++++------------ 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 262422364bf..14035d4b2d3 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -461,6 +461,10 @@ enum tgsi_exec_datatype { static const union tgsi_exec_channel ZeroVec = { { 0.0, 0.0, 0.0, 0.0 } }; +static const union tgsi_exec_channel OneVec = { + {1.0f, 1.0f, 1.0f, 1.0f} +}; + /** * Assert that none of the float values in 'chan' are infinite or NaN. @@ -2029,6 +2033,70 @@ exec_dp2(struct tgsi_exec_machine *mach, } } +static void +exec_nrm4(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + unsigned int chan; + union tgsi_exec_channel arg[4]; + union tgsi_exec_channel scale; + + fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_mul(&scale, &arg[0], &arg[0]); + + for (chan = CHAN_Y; chan <= CHAN_W; chan++) { + union tgsi_exec_channel product; + + fetch_source(mach, &arg[chan], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT); + micro_mul(&product, &arg[chan], &arg[chan]); + micro_add(&scale, &scale, &product); + } + + micro_rsq(&scale, &scale); + + for (chan = CHAN_X; chan <= CHAN_W; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + micro_mul(&arg[chan], &arg[chan], &scale); + store_dest(mach, &arg[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT); + } + } +} + +static void +exec_nrm3(struct tgsi_exec_machine *mach, + const struct tgsi_full_instruction *inst) +{ + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XYZ) { + unsigned int chan; + union tgsi_exec_channel arg[3]; + union tgsi_exec_channel scale; + + fetch_source(mach, &arg[0], &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_FLOAT); + micro_mul(&scale, &arg[0], &arg[0]); + + for (chan = CHAN_Y; chan <= CHAN_Z; chan++) { + union tgsi_exec_channel product; + + fetch_source(mach, &arg[chan], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT); + micro_mul(&product, &arg[chan], &arg[chan]); + micro_add(&scale, &scale, &product); + } + + micro_rsq(&scale, &scale); + + for (chan = CHAN_X; chan <= CHAN_Z; chan++) { + if (inst->Dst[0].Register.WriteMask & (1 << chan)) { + micro_mul(&arg[chan], &arg[chan], &scale); + store_dest(mach, &arg[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT); + } + } + } + + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { + store_dest(mach, &OneVec, &inst->Dst[0], inst, CHAN_W, TGSI_EXEC_DATA_FLOAT); + } +} + static void exec_break(struct tgsi_exec_machine *mach) { @@ -3052,70 +3120,11 @@ exec_instruction( break; case TGSI_OPCODE_NRM: - /* 3-component vector normalize */ - if(IS_CHANNEL_ENABLED(*inst, CHAN_X) || - IS_CHANNEL_ENABLED(*inst, CHAN_Y) || - IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - /* r3 = sqrt(dp3(src0, src0)) */ - FETCH(&r[0], 0, CHAN_X); - micro_mul(&r[3], &r[0], &r[0]); - FETCH(&r[1], 0, CHAN_Y); - micro_mul(&r[4], &r[1], &r[1]); - micro_add(&r[3], &r[3], &r[4]); - FETCH(&r[2], 0, CHAN_Z); - micro_mul(&r[4], &r[2], &r[2]); - micro_add(&r[3], &r[3], &r[4]); - micro_sqrt(&r[3], &r[3]); - - if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) { - micro_div(&r[0], &r[0], &r[3]); - STORE(&r[0], 0, CHAN_X); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) { - micro_div(&r[1], &r[1], &r[3]); - STORE(&r[1], 0, CHAN_Y); - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) { - micro_div(&r[2], &r[2], &r[3]); - STORE(&r[2], 0, CHAN_Z); - } - } - if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) { - STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W); - } + exec_nrm3(mach, inst); break; case TGSI_OPCODE_NRM4: - /* 4-component vector normalize */ - { - union tgsi_exec_channel tmp, dot; - - /* tmp = dp4(src0, src0): */ - FETCH( &r[0], 0, CHAN_X ); - micro_mul( &tmp, &r[0], &r[0] ); - - FETCH( &r[1], 0, CHAN_Y ); - micro_mul( &dot, &r[1], &r[1] ); - micro_add( &tmp, &tmp, &dot ); - - FETCH( &r[2], 0, CHAN_Z ); - micro_mul( &dot, &r[2], &r[2] ); - micro_add( &tmp, &tmp, &dot ); - - FETCH( &r[3], 0, CHAN_W ); - micro_mul( &dot, &r[3], &r[3] ); - micro_add( &tmp, &tmp, &dot ); - - /* tmp = 1 / sqrt(tmp) */ - micro_sqrt( &tmp, &tmp ); - micro_div( &tmp, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &tmp ); - - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - /* chan = chan * tmp */ - micro_mul( &r[chan_index], &tmp, &r[chan_index] ); - STORE( &r[chan_index], 0, chan_index ); - } - } + exec_nrm4(mach, inst); break; case TGSI_OPCODE_DIV: From 348d236afcde3beede16a2de58b8c423b98d0676 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 18 Feb 2010 11:56:14 +0100 Subject: [PATCH 002/483] tgsi: Change prototypes of micro opcodes to explicitly indicates number of args. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 370 ++++++++++++++----------- 1 file changed, 206 insertions(+), 164 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 14035d4b2d3..76ce3a8bf51 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -232,22 +232,26 @@ micro_lg2(union tgsi_exec_channel *dst, static void micro_lrp(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) { - dst->f[0] = src[0].f[0] * (src[1].f[0] - src[2].f[0]) + src[2].f[0]; - dst->f[1] = src[0].f[1] * (src[1].f[1] - src[2].f[1]) + src[2].f[1]; - dst->f[2] = src[0].f[2] * (src[1].f[2] - src[2].f[2]) + src[2].f[2]; - dst->f[3] = src[0].f[3] * (src[1].f[3] - src[2].f[3]) + src[2].f[3]; + dst->f[0] = src0->f[0] * (src1->f[0] - src2->f[0]) + src2->f[0]; + dst->f[1] = src0->f[1] * (src1->f[1] - src2->f[1]) + src2->f[1]; + dst->f[2] = src0->f[2] * (src1->f[2] - src2->f[2]) + src2->f[2]; + dst->f[3] = src0->f[3] * (src1->f[3] - src2->f[3]) + src2->f[3]; } static void micro_mad(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) { - dst->f[0] = src[0].f[0] * src[1].f[0] + src[2].f[0]; - dst->f[1] = src[0].f[1] * src[1].f[1] + src[2].f[1]; - dst->f[2] = src[0].f[2] * src[1].f[2] + src[2].f[2]; - dst->f[3] = src[0].f[3] * src[1].f[3] + src[2].f[3]; + dst->f[0] = src0->f[0] * src1->f[0] + src2->f[0]; + dst->f[1] = src0->f[1] * src1->f[1] + src2->f[1]; + dst->f[2] = src0->f[2] * src1->f[2] + src2->f[2]; + dst->f[3] = src0->f[3] * src1->f[3] + src2->f[3]; } static void @@ -304,22 +308,24 @@ micro_rsq(union tgsi_exec_channel *dst, static void micro_seq(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] == src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] == src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] == src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] == src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] == src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] == src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] == src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] == src1->f[3] ? 1.0f : 0.0f; } static void micro_sge(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] >= src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] >= src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] >= src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] >= src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] >= src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] >= src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] >= src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] >= src1->f[3] ? 1.0f : 0.0f; } static void @@ -334,12 +340,13 @@ micro_sgn(union tgsi_exec_channel *dst, static void micro_sgt(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] > src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] > src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] > src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] > src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] > src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] > src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] > src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] > src1->f[3] ? 1.0f : 0.0f; } static void @@ -354,32 +361,35 @@ micro_sin(union tgsi_exec_channel *dst, static void micro_sle(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] <= src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] <= src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] <= src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] <= src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] <= src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] <= src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] <= src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] <= src1->f[3] ? 1.0f : 0.0f; } static void micro_slt(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] < src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] < src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] < src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] < src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] < src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] < src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] < src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] < src1->f[3] ? 1.0f : 0.0f; } static void micro_sne(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->f[0] = src[0].f[0] != src[1].f[0] ? 1.0f : 0.0f; - dst->f[1] = src[0].f[1] != src[1].f[1] ? 1.0f : 0.0f; - dst->f[2] = src[0].f[2] != src[1].f[2] ? 1.0f : 0.0f; - dst->f[3] = src[0].f[3] != src[1].f[3] ? 1.0f : 0.0f; + dst->f[0] = src0->f[0] != src1->f[0] ? 1.0f : 0.0f; + dst->f[1] = src0->f[1] != src1->f[1] ? 1.0f : 0.0f; + dst->f[2] = src0->f[2] != src1->f[2] ? 1.0f : 0.0f; + dst->f[3] = src0->f[3] != src1->f[3] ? 1.0f : 0.0f; } static void @@ -1808,13 +1818,13 @@ exec_declaration(struct tgsi_exec_machine *mach, } } -typedef void (* micro_op)(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src); +typedef void (* micro_unary_op)(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src); static void exec_scalar_unary(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst, - micro_op op, + micro_unary_op op, enum tgsi_exec_datatype dst_datatype, enum tgsi_exec_datatype src_datatype) { @@ -1834,7 +1844,7 @@ exec_scalar_unary(struct tgsi_exec_machine *mach, static void exec_vector_unary(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst, - micro_op op, + micro_unary_op op, enum tgsi_exec_datatype dst_datatype, enum tgsi_exec_datatype src_datatype) { @@ -1856,10 +1866,14 @@ exec_vector_unary(struct tgsi_exec_machine *mach, } } +typedef void (* micro_binary_op)(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1); + static void exec_vector_binary(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst, - micro_op op, + micro_binary_op op, enum tgsi_exec_datatype dst_datatype, enum tgsi_exec_datatype src_datatype) { @@ -1872,7 +1886,7 @@ exec_vector_binary(struct tgsi_exec_machine *mach, fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype); fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype); - op(&dst.xyzw[chan], src); + op(&dst.xyzw[chan], &src[0], &src[1]); } } for (chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1882,10 +1896,15 @@ exec_vector_binary(struct tgsi_exec_machine *mach, } } +typedef void (* micro_trinary_op)(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2); + static void exec_vector_trinary(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst, - micro_op op, + micro_trinary_op op, enum tgsi_exec_datatype dst_datatype, enum tgsi_exec_datatype src_datatype) { @@ -1899,7 +1918,7 @@ exec_vector_trinary(struct tgsi_exec_machine *mach, fetch_source(mach, &src[0], &inst->Src[0], chan, src_datatype); fetch_source(mach, &src[1], &inst->Src[1], chan, src_datatype); fetch_source(mach, &src[2], &inst->Src[2], chan, src_datatype); - op(&dst.xyzw[chan], src); + op(&dst.xyzw[chan], &src[0], &src[1], &src[2]); } } for (chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1923,7 +1942,7 @@ exec_dp3(struct tgsi_exec_machine *mach, for (chan = CHAN_Y; chan <= CHAN_Z; chan++) { fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[2], arg); + micro_mad(&arg[2], &arg[0], &arg[1], &arg[2]); } for (chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1947,7 +1966,7 @@ exec_dp4(struct tgsi_exec_machine *mach, for (chan = CHAN_Y; chan <= CHAN_W; chan++) { fetch_source(mach, &arg[0], &inst->Src[0], chan, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], chan, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[2], arg); + micro_mad(&arg[2], &arg[0], &arg[1], &arg[2]); } for (chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1970,7 +1989,7 @@ exec_dp2a(struct tgsi_exec_machine *mach, fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[0], arg); + micro_mad(&arg[0], &arg[0], &arg[1], &arg[2]); fetch_source(mach, &arg[1], &inst->Src[2], CHAN_X, TGSI_EXEC_DATA_FLOAT); micro_add(&arg[0], &arg[0], &arg[1]); @@ -1995,11 +2014,11 @@ exec_dph(struct tgsi_exec_machine *mach, fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[2], arg); + micro_mad(&arg[2], &arg[0], &arg[1], &arg[2]); fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Z, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[0], arg); + micro_mad(&arg[0], &arg[0], &arg[1], &arg[2]); fetch_source(mach, &arg[1], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT); micro_add(&arg[0], &arg[0], &arg[1]); @@ -2024,7 +2043,7 @@ exec_dp2(struct tgsi_exec_machine *mach, fetch_source(mach, &arg[0], &inst->Src[0], CHAN_Y, TGSI_EXEC_DATA_FLOAT); fetch_source(mach, &arg[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT); - micro_mad(&arg[2], arg); + micro_mad(&arg[2], &arg[0], &arg[1], &arg[2]); for (chan = 0; chan < NUM_CHANNELS; chan++) { if (inst->Dst[0].Register.WriteMask & (1 << chan)) { @@ -2203,42 +2222,46 @@ micro_not(union tgsi_exec_channel *dst, static void micro_shl(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] << src[1].u[0]; - dst->u[1] = src[0].u[1] << src[1].u[1]; - dst->u[2] = src[0].u[2] << src[1].u[2]; - dst->u[3] = src[0].u[3] << src[1].u[3]; + dst->u[0] = src0->u[0] << src1->u[0]; + dst->u[1] = src0->u[1] << src1->u[1]; + dst->u[2] = src0->u[2] << src1->u[2]; + dst->u[3] = src0->u[3] << src1->u[3]; } static void micro_and(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] & src[1].u[0]; - dst->u[1] = src[0].u[1] & src[1].u[1]; - dst->u[2] = src[0].u[2] & src[1].u[2]; - dst->u[3] = src[0].u[3] & src[1].u[3]; + dst->u[0] = src0->u[0] & src1->u[0]; + dst->u[1] = src0->u[1] & src1->u[1]; + dst->u[2] = src0->u[2] & src1->u[2]; + dst->u[3] = src0->u[3] & src1->u[3]; } static void micro_or(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] | src[1].u[0]; - dst->u[1] = src[0].u[1] | src[1].u[1]; - dst->u[2] = src[0].u[2] | src[1].u[2]; - dst->u[3] = src[0].u[3] | src[1].u[3]; + dst->u[0] = src0->u[0] | src1->u[0]; + dst->u[1] = src0->u[1] | src1->u[1]; + dst->u[2] = src0->u[2] | src1->u[2]; + dst->u[3] = src0->u[3] | src1->u[3]; } static void micro_xor(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] ^ src[1].u[0]; - dst->u[1] = src[0].u[1] ^ src[1].u[1]; - dst->u[2] = src[0].u[2] ^ src[1].u[2]; - dst->u[3] = src[0].u[3] ^ src[1].u[3]; + dst->u[0] = src0->u[0] ^ src1->u[0]; + dst->u[1] = src0->u[1] ^ src1->u[1]; + dst->u[2] = src0->u[2] ^ src1->u[2]; + dst->u[3] = src0->u[3] ^ src1->u[3]; } static void @@ -2253,62 +2276,68 @@ micro_f2i(union tgsi_exec_channel *dst, static void micro_idiv(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] / src[1].i[0]; - dst->i[1] = src[0].i[1] / src[1].i[1]; - dst->i[2] = src[0].i[2] / src[1].i[2]; - dst->i[3] = src[0].i[3] / src[1].i[3]; + dst->i[0] = src0->i[0] / src1->i[0]; + dst->i[1] = src0->i[1] / src1->i[1]; + dst->i[2] = src0->i[2] / src1->i[2]; + dst->i[3] = src0->i[3] / src1->i[3]; } static void micro_imax(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] > src[1].i[0] ? src[0].i[0] : src[1].i[0]; - dst->i[1] = src[0].i[1] > src[1].i[1] ? src[0].i[1] : src[1].i[1]; - dst->i[2] = src[0].i[2] > src[1].i[2] ? src[0].i[2] : src[1].i[2]; - dst->i[3] = src[0].i[3] > src[1].i[3] ? src[0].i[3] : src[1].i[3]; + dst->i[0] = src0->i[0] > src1->i[0] ? src0->i[0] : src1->i[0]; + dst->i[1] = src0->i[1] > src1->i[1] ? src0->i[1] : src1->i[1]; + dst->i[2] = src0->i[2] > src1->i[2] ? src0->i[2] : src1->i[2]; + dst->i[3] = src0->i[3] > src1->i[3] ? src0->i[3] : src1->i[3]; } static void micro_imin(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] < src[1].i[0] ? src[0].i[0] : src[1].i[0]; - dst->i[1] = src[0].i[1] < src[1].i[1] ? src[0].i[1] : src[1].i[1]; - dst->i[2] = src[0].i[2] < src[1].i[2] ? src[0].i[2] : src[1].i[2]; - dst->i[3] = src[0].i[3] < src[1].i[3] ? src[0].i[3] : src[1].i[3]; + dst->i[0] = src0->i[0] < src1->i[0] ? src0->i[0] : src1->i[0]; + dst->i[1] = src0->i[1] < src1->i[1] ? src0->i[1] : src1->i[1]; + dst->i[2] = src0->i[2] < src1->i[2] ? src0->i[2] : src1->i[2]; + dst->i[3] = src0->i[3] < src1->i[3] ? src0->i[3] : src1->i[3]; } static void micro_isge(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] >= src[1].i[0] ? -1 : 0; - dst->i[1] = src[0].i[1] >= src[1].i[1] ? -1 : 0; - dst->i[2] = src[0].i[2] >= src[1].i[2] ? -1 : 0; - dst->i[3] = src[0].i[3] >= src[1].i[3] ? -1 : 0; + dst->i[0] = src0->i[0] >= src1->i[0] ? -1 : 0; + dst->i[1] = src0->i[1] >= src1->i[1] ? -1 : 0; + dst->i[2] = src0->i[2] >= src1->i[2] ? -1 : 0; + dst->i[3] = src0->i[3] >= src1->i[3] ? -1 : 0; } static void micro_ishr(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] >> src[1].i[0]; - dst->i[1] = src[0].i[1] >> src[1].i[1]; - dst->i[2] = src[0].i[2] >> src[1].i[2]; - dst->i[3] = src[0].i[3] >> src[1].i[3]; + dst->i[0] = src0->i[0] >> src1->i[0]; + dst->i[1] = src0->i[1] >> src1->i[1]; + dst->i[2] = src0->i[2] >> src1->i[2]; + dst->i[3] = src0->i[3] >> src1->i[3]; } static void micro_islt(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->i[0] = src[0].i[0] < src[1].i[0] ? -1 : 0; - dst->i[1] = src[0].i[1] < src[1].i[1] ? -1 : 0; - dst->i[2] = src[0].i[2] < src[1].i[2] ? -1 : 0; - dst->i[3] = src[0].i[3] < src[1].i[3] ? -1 : 0; + dst->i[0] = src0->i[0] < src1->i[0] ? -1 : 0; + dst->i[1] = src0->i[1] < src1->i[1] ? -1 : 0; + dst->i[2] = src0->i[2] < src1->i[2] ? -1 : 0; + dst->i[3] = src0->i[3] < src1->i[3] ? -1 : 0; } static void @@ -2333,122 +2362,135 @@ micro_u2f(union tgsi_exec_channel *dst, static void micro_uadd(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] + src[1].u[0]; - dst->u[1] = src[0].u[1] + src[1].u[1]; - dst->u[2] = src[0].u[2] + src[1].u[2]; - dst->u[3] = src[0].u[3] + src[1].u[3]; + dst->u[0] = src0->u[0] + src1->u[0]; + dst->u[1] = src0->u[1] + src1->u[1]; + dst->u[2] = src0->u[2] + src1->u[2]; + dst->u[3] = src0->u[3] + src1->u[3]; } static void micro_udiv(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] / src[1].u[0]; - dst->u[1] = src[0].u[1] / src[1].u[1]; - dst->u[2] = src[0].u[2] / src[1].u[2]; - dst->u[3] = src[0].u[3] / src[1].u[3]; + dst->u[0] = src0->u[0] / src1->u[0]; + dst->u[1] = src0->u[1] / src1->u[1]; + dst->u[2] = src0->u[2] / src1->u[2]; + dst->u[3] = src0->u[3] / src1->u[3]; } static void micro_umad(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) { - dst->u[0] = src[0].u[0] * src[1].u[0] + src[2].u[0]; - dst->u[1] = src[0].u[1] * src[1].u[1] + src[2].u[1]; - dst->u[2] = src[0].u[2] * src[1].u[2] + src[2].u[2]; - dst->u[3] = src[0].u[3] * src[1].u[3] + src[2].u[3]; + dst->u[0] = src0->u[0] * src1->u[0] + src2->u[0]; + dst->u[1] = src0->u[1] * src1->u[1] + src2->u[1]; + dst->u[2] = src0->u[2] * src1->u[2] + src2->u[2]; + dst->u[3] = src0->u[3] * src1->u[3] + src2->u[3]; } static void micro_umax(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] > src[1].u[0] ? src[0].u[0] : src[1].u[0]; - dst->u[1] = src[0].u[1] > src[1].u[1] ? src[0].u[1] : src[1].u[1]; - dst->u[2] = src[0].u[2] > src[1].u[2] ? src[0].u[2] : src[1].u[2]; - dst->u[3] = src[0].u[3] > src[1].u[3] ? src[0].u[3] : src[1].u[3]; + dst->u[0] = src0->u[0] > src1->u[0] ? src0->u[0] : src1->u[0]; + dst->u[1] = src0->u[1] > src1->u[1] ? src0->u[1] : src1->u[1]; + dst->u[2] = src0->u[2] > src1->u[2] ? src0->u[2] : src1->u[2]; + dst->u[3] = src0->u[3] > src1->u[3] ? src0->u[3] : src1->u[3]; } static void micro_umin(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] < src[1].u[0] ? src[0].u[0] : src[1].u[0]; - dst->u[1] = src[0].u[1] < src[1].u[1] ? src[0].u[1] : src[1].u[1]; - dst->u[2] = src[0].u[2] < src[1].u[2] ? src[0].u[2] : src[1].u[2]; - dst->u[3] = src[0].u[3] < src[1].u[3] ? src[0].u[3] : src[1].u[3]; + dst->u[0] = src0->u[0] < src1->u[0] ? src0->u[0] : src1->u[0]; + dst->u[1] = src0->u[1] < src1->u[1] ? src0->u[1] : src1->u[1]; + dst->u[2] = src0->u[2] < src1->u[2] ? src0->u[2] : src1->u[2]; + dst->u[3] = src0->u[3] < src1->u[3] ? src0->u[3] : src1->u[3]; } static void micro_umod(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] % src[1].u[0]; - dst->u[1] = src[0].u[1] % src[1].u[1]; - dst->u[2] = src[0].u[2] % src[1].u[2]; - dst->u[3] = src[0].u[3] % src[1].u[3]; + dst->u[0] = src0->u[0] % src1->u[0]; + dst->u[1] = src0->u[1] % src1->u[1]; + dst->u[2] = src0->u[2] % src1->u[2]; + dst->u[3] = src0->u[3] % src1->u[3]; } static void micro_umul(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] * src[1].u[0]; - dst->u[1] = src[0].u[1] * src[1].u[1]; - dst->u[2] = src[0].u[2] * src[1].u[2]; - dst->u[3] = src[0].u[3] * src[1].u[3]; + dst->u[0] = src0->u[0] * src1->u[0]; + dst->u[1] = src0->u[1] * src1->u[1]; + dst->u[2] = src0->u[2] * src1->u[2]; + dst->u[3] = src0->u[3] * src1->u[3]; } static void micro_useq(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] == src[1].u[0] ? ~0 : 0; - dst->u[1] = src[0].u[1] == src[1].u[1] ? ~0 : 0; - dst->u[2] = src[0].u[2] == src[1].u[2] ? ~0 : 0; - dst->u[3] = src[0].u[3] == src[1].u[3] ? ~0 : 0; + dst->u[0] = src0->u[0] == src1->u[0] ? ~0 : 0; + dst->u[1] = src0->u[1] == src1->u[1] ? ~0 : 0; + dst->u[2] = src0->u[2] == src1->u[2] ? ~0 : 0; + dst->u[3] = src0->u[3] == src1->u[3] ? ~0 : 0; } static void micro_usge(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] >= src[1].u[0] ? ~0 : 0; - dst->u[1] = src[0].u[1] >= src[1].u[1] ? ~0 : 0; - dst->u[2] = src[0].u[2] >= src[1].u[2] ? ~0 : 0; - dst->u[3] = src[0].u[3] >= src[1].u[3] ? ~0 : 0; + dst->u[0] = src0->u[0] >= src1->u[0] ? ~0 : 0; + dst->u[1] = src0->u[1] >= src1->u[1] ? ~0 : 0; + dst->u[2] = src0->u[2] >= src1->u[2] ? ~0 : 0; + dst->u[3] = src0->u[3] >= src1->u[3] ? ~0 : 0; } static void micro_ushr(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] >> src[1].u[0]; - dst->u[1] = src[0].u[1] >> src[1].u[1]; - dst->u[2] = src[0].u[2] >> src[1].u[2]; - dst->u[3] = src[0].u[3] >> src[1].u[3]; + dst->u[0] = src0->u[0] >> src1->u[0]; + dst->u[1] = src0->u[1] >> src1->u[1]; + dst->u[2] = src0->u[2] >> src1->u[2]; + dst->u[3] = src0->u[3] >> src1->u[3]; } static void micro_uslt(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] < src[1].u[0] ? ~0 : 0; - dst->u[1] = src[0].u[1] < src[1].u[1] ? ~0 : 0; - dst->u[2] = src[0].u[2] < src[1].u[2] ? ~0 : 0; - dst->u[3] = src[0].u[3] < src[1].u[3] ? ~0 : 0; + dst->u[0] = src0->u[0] < src1->u[0] ? ~0 : 0; + dst->u[1] = src0->u[1] < src1->u[1] ? ~0 : 0; + dst->u[2] = src0->u[2] < src1->u[2] ? ~0 : 0; + dst->u[3] = src0->u[3] < src1->u[3] ? ~0 : 0; } static void micro_usne(union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src) + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { - dst->u[0] = src[0].u[0] != src[1].u[0] ? ~0 : 0; - dst->u[1] = src[0].u[1] != src[1].u[1] ? ~0 : 0; - dst->u[2] = src[0].u[2] != src[1].u[2] ? ~0 : 0; - dst->u[3] = src[0].u[3] != src[1].u[3] ? ~0 : 0; + dst->u[0] = src0->u[0] != src1->u[0] ? ~0 : 0; + dst->u[1] = src0->u[1] != src1->u[1] ? ~0 : 0; + dst->u[2] = src0->u[2] != src1->u[2] ? ~0 : 0; + dst->u[3] = src0->u[3] != src1->u[3] ? ~0 : 0; } static void From 3d0bfc6a4be73d43928493641bf819f77075bbc1 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 18 Feb 2010 12:05:08 +0100 Subject: [PATCH 003/483] tgsi: Make more exec opcodes look pretty. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 84 ++++++-------------------- 1 file changed, 20 insertions(+), 64 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 76ce3a8bf51..fdbf2b436e4 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -773,10 +773,9 @@ tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach) } static void -micro_add( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) +micro_add(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { dst->f[0] = src0->f[0] + src1->f[0]; dst->f[1] = src0->f[1] + src1->f[1]; @@ -845,10 +844,9 @@ micro_lt( } static void -micro_max( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) +micro_max(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { dst->f[0] = src0->f[0] > src1->f[0] ? src0->f[0] : src1->f[0]; dst->f[1] = src0->f[1] > src1->f[1] ? src0->f[1] : src1->f[1]; @@ -857,10 +855,9 @@ micro_max( } static void -micro_min( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) +micro_min(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { dst->f[0] = src0->f[0] < src1->f[0] ? src0->f[0] : src1->f[0]; dst->f[1] = src0->f[1] < src1->f[1] ? src0->f[1] : src1->f[1]; @@ -869,10 +866,9 @@ micro_min( } static void -micro_mul( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) +micro_mul(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { dst->f[0] = src0->f[0] * src1->f[0]; dst->f[1] = src0->f[1] * src1->f[1]; @@ -975,10 +971,9 @@ micro_sqrt( union tgsi_exec_channel *dst, } static void -micro_sub( - union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src0, - const union tgsi_exec_channel *src1 ) +micro_sub(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1) { dst->f[0] = src0->f[0] - src1->f[0]; dst->f[1] = src0->f[1] - src1->f[1]; @@ -2597,25 +2592,11 @@ exec_instruction( break; case TGSI_OPCODE_MUL: - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - micro_mul(&d[chan_index], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_binary(mach, inst, micro_mul, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_ADD: - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH( &r[0], 0, chan_index ); - FETCH( &r[1], 1, chan_index ); - micro_add(&d[chan_index], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_binary(mach, inst, micro_add, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_DP3: @@ -2654,29 +2635,11 @@ exec_instruction( break; case TGSI_OPCODE_MIN: - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - - /* XXX use micro_min()?? */ - micro_lt(&d[chan_index], &r[0], &r[1], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_binary(mach, inst, micro_min, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_MAX: - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - - /* XXX use micro_max()?? */ - micro_lt(&d[chan_index], &r[0], &r[1], &r[1], &r[0] ); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_binary(mach, inst, micro_max, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_SLT: @@ -2692,14 +2655,7 @@ exec_instruction( break; case TGSI_OPCODE_SUB: - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - micro_sub(&d[chan_index], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_binary(mach, inst, micro_sub, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_LRP: From f6106566081978f663cf08e54bb8908cb58a5316 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 19 Feb 2010 19:00:26 +0100 Subject: [PATCH 004/483] gallium: WIP: Introduce sampler views. --- src/gallium/auxiliary/Makefile | 13 +-- src/gallium/auxiliary/SConscript | 12 ++- src/gallium/auxiliary/cso_cache/cso_context.c | 86 +++++++++++++--- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 58 +++++++---- .../auxiliary/draw/draw_pipe_pstipple.c | 58 +++++++---- src/gallium/auxiliary/util/u_blitter.c | 36 +++++-- src/gallium/auxiliary/util/u_blitter.h | 24 ++--- src/gallium/auxiliary/util/u_inlines.h | 10 ++ src/gallium/auxiliary/util/u_sampler.c | 97 +++++++++++++++++++ src/gallium/auxiliary/util/u_sampler.h | 57 +++++++++++ src/gallium/drivers/failover/fo_context.h | 8 +- src/gallium/drivers/failover/fo_state.c | 60 ++++++------ src/gallium/drivers/failover/fo_state_emit.c | 10 +- src/gallium/drivers/identity/id_context.c | 52 +++++----- src/gallium/drivers/identity/id_objects.h | 26 +++++ src/gallium/drivers/softpipe/sp_context.c | 8 +- src/gallium/drivers/softpipe/sp_context.h | 8 +- src/gallium/drivers/softpipe/sp_flush.c | 4 +- src/gallium/drivers/softpipe/sp_state.h | 12 +-- .../drivers/softpipe/sp_state_sampler.c | 63 +++++++----- src/gallium/drivers/svga/svga_context.h | 4 +- src/gallium/drivers/svga/svga_pipe_sampler.c | 30 +++--- .../drivers/svga/svga_state_constants.c | 2 +- src/gallium/drivers/svga/svga_state_fs.c | 9 +- src/gallium/drivers/svga/svga_state_tss.c | 22 +++-- src/gallium/drivers/trace/tr_context.c | 76 +++++++-------- src/gallium/drivers/trace/tr_context.h | 10 +- src/gallium/drivers/trace/tr_rbug.c | 8 +- src/gallium/drivers/trace/tr_texture.h | 19 ++++ src/gallium/include/pipe/p_context.h | 22 +++-- src/gallium/include/pipe/p_defines.h | 11 +++ src/gallium/include/pipe/p_state.h | 18 ++++ src/mesa/state_tracker/st_cb_drawpixels.c | 4 +- 33 files changed, 660 insertions(+), 277 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_sampler.c create mode 100644 src/gallium/auxiliary/util/u_sampler.h diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index ff7695150e2..ec986355140 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -125,12 +125,13 @@ C_SOURCES = \ util/u_tile.c \ util/u_timed_winsys.c \ util/u_upload_mgr.c \ - util/u_simple_screen.c \ - vl/vl_bitstream_parser.c \ - vl/vl_mpeg12_mc_renderer.c \ - vl/vl_compositor.c \ - vl/vl_csc.c \ - vl/vl_shader_build.c + util/u_simple_screen.c + # Disabling until pipe-video branch gets merged in + #vl/vl_bitstream_parser.c \ + #vl/vl_mpeg12_mc_renderer.c \ + #vl/vl_compositor.c \ + #vl/vl_csc.c \ + #vl/vl_shader_build.c GALLIVM_SOURCES = \ gallivm/lp_bld_alpha.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index b531ad2dbd9..acb03e62829 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -153,6 +153,7 @@ source = [ 'util/u_mm.c', 'util/u_rect.c', 'util/u_ringbuffer.c', + 'util/u_sampler.c', 'util/u_simple_shaders.c', 'util/u_snprintf.c', 'util/u_surface.c', @@ -161,11 +162,12 @@ source = [ 'util/u_timed_winsys.c', 'util/u_upload_mgr.c', 'util/u_simple_screen.c', - 'vl/vl_bitstream_parser.c', - 'vl/vl_mpeg12_mc_renderer.c', - 'vl/vl_compositor.c', - 'vl/vl_csc.c', - 'vl/vl_shader_build.c', + # Disabling until pipe-video branch gets merged in + #'vl/vl_bitstream_parser.c', + #'vl/vl_mpeg12_mc_renderer.c', + #'vl/vl_compositor.c', + #'vl/vl_csc.c', + #'vl/vl_shader_build.c', ] if drawllvm: diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index b5241fa64c6..6ae765c8991 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -38,6 +38,7 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "tgsi/tgsi_parse.h" #include "cso_cache/cso_context.h" @@ -70,16 +71,20 @@ struct cso_context { void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; uint nr_textures; struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; uint nr_vertex_textures; uint nr_textures_saved; struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views_saved[PIPE_MAX_SAMPLERS]; uint nr_vertex_textures_saved; - struct pipe_texture *vertex_textures_saved[PIPE_MAX_SAMPLERS]; + struct pipe_texture *vertex_textures_saved[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views_saved[PIPE_MAX_VERTEX_SAMPLERS]; /** Current and saved state. * The saved state is used as a 1-deep stack. @@ -273,11 +278,15 @@ void cso_release_all( struct cso_context *ctx ) for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_texture_reference(&ctx->textures[i], NULL); pipe_texture_reference(&ctx->textures_saved[i], NULL); + pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + pipe_sampler_view_reference(&ctx->sampler_views_saved[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { pipe_texture_reference(&ctx->vertex_textures[i], NULL); pipe_texture_reference(&ctx->vertex_textures_saved[i], NULL); + pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); + pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], NULL); } free_framebuffer_state(&ctx->fb); @@ -602,12 +611,27 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, ctx->nr_textures = count; - for (i = 0; i < count; i++) - pipe_texture_reference(&ctx->textures[i], textures[i]); - for ( ; i < PIPE_MAX_SAMPLERS; i++) - pipe_texture_reference(&ctx->textures[i], NULL); + for (i = 0; i < count; i++) { + struct pipe_sampler_view templ, *view; - ctx->pipe->set_fragment_sampler_textures(ctx->pipe, count, textures); + u_sampler_view_default_template(&templ, + textures[i], + textures[i]->format); + view = ctx->pipe->create_sampler_view(ctx->pipe, + textures[i], + &templ); + + pipe_texture_reference(&ctx->textures[i], textures[i]); + pipe_sampler_view_reference(&ctx->sampler_views[i], view); + } + for ( ; i < PIPE_MAX_SAMPLERS; i++) { + pipe_texture_reference(&ctx->textures[i], NULL); + pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + } + + ctx->pipe->set_fragment_sampler_views(ctx->pipe, + count, + ctx->sampler_views); return PIPE_OK; } @@ -619,7 +643,11 @@ void cso_save_sampler_textures( struct cso_context *ctx ) ctx->nr_textures_saved = ctx->nr_textures; for (i = 0; i < ctx->nr_textures; i++) { assert(!ctx->textures_saved[i]); + assert(!ctx->sampler_views_saved[i]); + pipe_texture_reference(&ctx->textures_saved[i], ctx->textures[i]); + pipe_sampler_view_reference(&ctx->sampler_views_saved[i], + ctx->sampler_views[i]); } } @@ -633,11 +661,19 @@ void cso_restore_sampler_textures( struct cso_context *ctx ) pipe_texture_reference(&ctx->textures[i], NULL); ctx->textures[i] = ctx->textures_saved[i]; ctx->textures_saved[i] = NULL; - } - for ( ; i < PIPE_MAX_SAMPLERS; i++) - pipe_texture_reference(&ctx->textures[i], NULL); - ctx->pipe->set_fragment_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures); + pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + ctx->sampler_views[i] = ctx->sampler_views_saved[i]; + ctx->sampler_views_saved[i] = NULL; + } + for ( ; i < PIPE_MAX_SAMPLERS; i++) { + pipe_texture_reference(&ctx->textures[i], NULL); + pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + } + + ctx->pipe->set_fragment_sampler_views(ctx->pipe, + ctx->nr_textures, + ctx->sampler_views); ctx->nr_textures_saved = 0; } @@ -654,13 +690,26 @@ cso_set_vertex_sampler_textures(struct cso_context *ctx, ctx->nr_vertex_textures = count; for (i = 0; i < count; i++) { + struct pipe_sampler_view templ, *view; + + u_sampler_view_default_template(&templ, + textures[i], + textures[i]->format); + view = ctx->pipe->create_sampler_view(ctx->pipe, + textures[i], + &templ); + pipe_texture_reference(&ctx->vertex_textures[i], textures[i]); + pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], view); } for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { pipe_texture_reference(&ctx->vertex_textures[i], NULL); + pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); } - ctx->pipe->set_vertex_sampler_textures(ctx->pipe, count, textures); + ctx->pipe->set_vertex_sampler_views(ctx->pipe, + count, + ctx->vertex_sampler_views); return PIPE_OK; } @@ -673,7 +722,11 @@ cso_save_vertex_sampler_textures(struct cso_context *ctx) ctx->nr_vertex_textures_saved = ctx->nr_vertex_textures; for (i = 0; i < ctx->nr_vertex_textures; i++) { assert(!ctx->vertex_textures_saved[i]); + assert(!ctx->vertex_sampler_views_saved[i]); + pipe_texture_reference(&ctx->vertex_textures_saved[i], ctx->vertex_textures[i]); + pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], + ctx->vertex_sampler_views[i]); } } @@ -688,14 +741,19 @@ cso_restore_vertex_sampler_textures(struct cso_context *ctx) pipe_texture_reference(&ctx->vertex_textures[i], NULL); ctx->vertex_textures[i] = ctx->vertex_textures_saved[i]; ctx->vertex_textures_saved[i] = NULL; + + pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); + ctx->vertex_sampler_views[i] = ctx->vertex_sampler_views_saved[i]; + ctx->vertex_sampler_views_saved[i] = NULL; } for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { pipe_texture_reference(&ctx->vertex_textures[i], NULL); + pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); } - ctx->pipe->set_vertex_sampler_textures(ctx->pipe, - ctx->nr_vertex_textures, - ctx->vertex_textures); + ctx->pipe->set_vertex_sampler_views(ctx->pipe, + ctx->nr_vertex_textures, + ctx->vertex_sampler_views); ctx->nr_vertex_textures_saved = 0; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 8f6ca15dfa2..70d7dbdfc75 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -40,6 +40,7 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "tgsi/tgsi_transform.h" #include "tgsi/tgsi_dump.h" @@ -88,8 +89,9 @@ struct aaline_stage void *sampler_cso; struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; uint num_samplers; - uint num_textures; + uint num_sampler_views; /* @@ -98,7 +100,7 @@ struct aaline_stage struct aaline_fragment_shader *fs; struct { void *sampler[PIPE_MAX_SAMPLERS]; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; } state; /* @@ -111,8 +113,9 @@ struct aaline_stage void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, void **); - void (*driver_set_sampler_textures)(struct pipe_context *, unsigned, - struct pipe_texture **); + void (*driver_set_sampler_views)(struct pipe_context *, + unsigned, + struct pipe_sampler_view **); struct pipe_context *pipe; }; @@ -394,6 +397,7 @@ aaline_create_texture(struct aaline_stage *aaline) struct pipe_context *pipe = aaline->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_texture texTemp; + struct pipe_sampler_view viewTempl; uint level; memset(&texTemp, 0, sizeof(texTemp)); @@ -408,6 +412,16 @@ aaline_create_texture(struct aaline_stage *aaline) if (!aaline->texture) return FALSE; + u_sampler_view_default_template(&viewTempl, + aaline->texture, + aaline->texture->format); + aaline->sampler_view = pipe->create_sampler_view(pipe, + aaline->texture, + &viewTempl); + if (!aaline->sampler_view) { + return FALSE; + } + /* Fill in mipmap images. * Basically each level is solid opaque, except for the outermost * texels which are zero. Special case the 1x1 and 2x2 levels. @@ -669,16 +683,16 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header) /* how many samplers? */ /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */ - num_samplers = MAX2(aaline->num_textures, aaline->num_samplers); + num_samplers = MAX2(aaline->num_sampler_views, aaline->num_samplers); num_samplers = MAX2(num_samplers, aaline->fs->sampler_unit + 1); aaline->state.sampler[aaline->fs->sampler_unit] = aaline->sampler_cso; - pipe_texture_reference(&aaline->state.texture[aaline->fs->sampler_unit], - aaline->texture); + pipe_sampler_view_reference(&aaline->state.sampler_views[aaline->fs->sampler_unit], + aaline->sampler_view); draw->suspend_flushing = TRUE; aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler); - aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture); + aaline->driver_set_sampler_views(pipe, num_samplers, aaline->state.sampler_views); draw->suspend_flushing = FALSE; /* now really draw first line */ @@ -702,8 +716,9 @@ aaline_flush(struct draw_stage *stage, unsigned flags) aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs); aaline->driver_bind_sampler_states(pipe, aaline->num_samplers, aaline->state.sampler); - aaline->driver_set_sampler_textures(pipe, aaline->num_textures, - aaline->state.texture); + aaline->driver_set_sampler_views(pipe, + aaline->num_sampler_views, + aaline->state.sampler_views); draw->suspend_flushing = FALSE; draw->extra_shader_outputs.slot = 0; @@ -724,7 +739,7 @@ aaline_destroy(struct draw_stage *stage) uint i; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&aaline->state.texture[i], NULL); + pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL); } if (aaline->sampler_cso) @@ -733,6 +748,10 @@ aaline_destroy(struct draw_stage *stage) if (aaline->texture) pipe_texture_reference(&aaline->texture, NULL); + if (aaline->sampler_view) { + pipe_sampler_view_reference(&aaline->sampler_view, NULL); + } + draw_free_temp_verts( stage ); FREE( stage ); @@ -844,23 +863,24 @@ aaline_bind_sampler_states(struct pipe_context *pipe, static void -aaline_set_sampler_textures(struct pipe_context *pipe, - unsigned num, struct pipe_texture **texture) +aaline_set_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); uint i; /* save current */ for (i = 0; i < num; i++) { - pipe_texture_reference(&aaline->state.texture[i], texture[i]); + pipe_sampler_view_reference(&aaline->state.sampler_views[i], views[i]); } for ( ; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&aaline->state.texture[i], NULL); + pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL); } - aaline->num_textures = num; + aaline->num_sampler_views = num; /* pass-through */ - aaline->driver_set_sampler_textures(aaline->pipe, num, texture); + aaline->driver_set_sampler_views(aaline->pipe, num, views); } @@ -898,7 +918,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe) aaline->driver_delete_fs_state = pipe->delete_fs_state; aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states; - aaline->driver_set_sampler_textures = pipe->set_fragment_sampler_textures; + aaline->driver_set_sampler_views = pipe->set_fragment_sampler_views; /* override the driver's functions */ pipe->create_fs_state = aaline_create_fs_state; @@ -906,7 +926,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe) pipe->delete_fs_state = aaline_delete_fs_state; pipe->bind_fragment_sampler_states = aaline_bind_sampler_states; - pipe->set_fragment_sampler_textures = aaline_set_sampler_textures; + pipe->set_fragment_sampler_views = aaline_set_sampler_views; /* Install once everything is known to be OK: */ diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index d0d99aa331a..e03081d65c5 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -42,6 +42,7 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "tgsi/tgsi_transform.h" #include "tgsi/tgsi_dump.h" @@ -75,8 +76,9 @@ struct pstip_stage void *sampler_cso; struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; uint num_samplers; - uint num_textures; + uint num_sampler_views; /* * Currently bound state @@ -84,7 +86,7 @@ struct pstip_stage struct pstip_fragment_shader *fs; struct { void *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; const struct pipe_poly_stipple *stipple; } state; @@ -98,8 +100,9 @@ struct pstip_stage void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, void **); - void (*driver_set_sampler_textures)(struct pipe_context *, unsigned, - struct pipe_texture **); + void (*driver_set_sampler_views)(struct pipe_context *, + unsigned, + struct pipe_sampler_view **); void (*driver_set_polygon_stipple)(struct pipe_context *, const struct pipe_poly_stipple *); @@ -422,6 +425,7 @@ pstip_create_texture(struct pstip_stage *pstip) struct pipe_context *pipe = pstip->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_texture texTemp; + struct pipe_sampler_view viewTempl; memset(&texTemp, 0, sizeof(texTemp)); texTemp.target = PIPE_TEXTURE_2D; @@ -435,6 +439,16 @@ pstip_create_texture(struct pstip_stage *pstip) if (pstip->texture == NULL) return FALSE; + u_sampler_view_default_template(&viewTempl, + pstip->texture, + pstip->texture->format); + pstip->sampler_view = pipe->create_sampler_view(pipe, + pstip->texture, + &viewTempl); + if (!pstip->sampler_view) { + return FALSE; + } + return TRUE; } @@ -513,19 +527,19 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header) /* how many samplers? */ /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */ - num_samplers = MAX2(pstip->num_textures, pstip->num_samplers); + num_samplers = MAX2(pstip->num_sampler_views, pstip->num_samplers); num_samplers = MAX2(num_samplers, pstip->fs->sampler_unit + 1); /* plug in our sampler, texture */ pstip->state.samplers[pstip->fs->sampler_unit] = pstip->sampler_cso; - pipe_texture_reference(&pstip->state.textures[pstip->fs->sampler_unit], - pstip->texture); + pipe_sampler_view_reference(&pstip->state.sampler_views[pstip->fs->sampler_unit], + pstip->sampler_view); assert(num_samplers <= PIPE_MAX_SAMPLERS); draw->suspend_flushing = TRUE; pstip->driver_bind_sampler_states(pipe, num_samplers, pstip->state.samplers); - pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures); + pstip->driver_set_sampler_views(pipe, num_samplers, pstip->state.sampler_views); draw->suspend_flushing = FALSE; /* now really draw first triangle */ @@ -549,8 +563,9 @@ pstip_flush(struct draw_stage *stage, unsigned flags) pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs); pstip->driver_bind_sampler_states(pipe, pstip->num_samplers, pstip->state.samplers); - pstip->driver_set_sampler_textures(pipe, pstip->num_textures, - pstip->state.textures); + pstip->driver_set_sampler_views(pipe, + pstip->num_sampler_views, + pstip->state.sampler_views); draw->suspend_flushing = FALSE; } @@ -569,13 +584,17 @@ pstip_destroy(struct draw_stage *stage) uint i; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&pstip->state.textures[i], NULL); + pipe_sampler_view_reference(&pstip->state.sampler_views[i], NULL); } pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso); pipe_texture_reference(&pstip->texture, NULL); + if (pstip->sampler_view) { + pipe_sampler_view_reference(&pstip->sampler_view, NULL); + } + draw_free_temp_verts( stage ); FREE( stage ); } @@ -680,24 +699,25 @@ pstip_bind_sampler_states(struct pipe_context *pipe, static void -pstip_set_sampler_textures(struct pipe_context *pipe, - unsigned num, struct pipe_texture **texture) +pstip_set_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct pstip_stage *pstip = pstip_stage_from_pipe(pipe); uint i; /* save current */ for (i = 0; i < num; i++) { - pipe_texture_reference(&pstip->state.textures[i], texture[i]); + pipe_sampler_view_reference(&pstip->state.sampler_views[i], views[i]); } for (; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&pstip->state.textures[i], NULL); + pipe_sampler_view_reference(&pstip->state.sampler_views[i], NULL); } - pstip->num_textures = num; + pstip->num_sampler_views = num; /* pass-through */ - pstip->driver_set_sampler_textures(pstip->pipe, num, texture); + pstip->driver_set_sampler_views(pstip->pipe, num, views); } @@ -754,7 +774,7 @@ draw_install_pstipple_stage(struct draw_context *draw, pstip->driver_delete_fs_state = pipe->delete_fs_state; pstip->driver_bind_sampler_states = pipe->bind_fragment_sampler_states; - pstip->driver_set_sampler_textures = pipe->set_fragment_sampler_textures; + pstip->driver_set_sampler_views = pipe->set_fragment_sampler_views; pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple; /* override the driver's functions */ @@ -763,7 +783,7 @@ draw_install_pstipple_stage(struct draw_context *draw, pipe->delete_fs_state = pstip_delete_fs_state; pipe->bind_fragment_sampler_states = pstip_bind_sampler_states; - pipe->set_fragment_sampler_textures = pstip_set_sampler_textures; + pipe->set_fragment_sampler_views = pstip_set_sampler_views; pipe->set_polygon_stipple = pstip_set_polygon_stipple; return TRUE; diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 18f86068183..29060a1effe 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -45,6 +45,7 @@ #include "util/u_draw_quad.h" #include "util/u_pack_color.h" #include "util/u_rect.h" +#include "util/u_sampler.h" #include "util/u_simple_shaders.h" #include "util/u_texture.h" @@ -93,6 +94,8 @@ struct blitter_context_priv /* Rasterizer state. */ void *rs_state; + + struct pipe_sampler_view *sampler_view; }; struct blitter_context *util_blitter_create(struct pipe_context *pipe) @@ -117,7 +120,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->blitter.saved_fs = INVALID_PTR; ctx->blitter.saved_vs = INVALID_PTR; ctx->blitter.saved_fb_state.nr_cbufs = ~0; - ctx->blitter.saved_num_textures = ~0; + ctx->blitter.saved_num_sampler_views = ~0; ctx->blitter.saved_num_sampler_states = ~0; /* blend state objects */ @@ -230,6 +233,10 @@ void util_blitter_destroy(struct blitter_context *blitter) if (ctx->sampler_state[i]) pipe->delete_sampler_state(pipe, ctx->sampler_state[i]); + if (ctx->sampler_view) { + pipe_sampler_view_reference(&ctx->sampler_view, NULL); + } + pipe_buffer_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -277,11 +284,11 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) ctx->blitter.saved_num_sampler_states = ~0; } - if (ctx->blitter.saved_num_textures != ~0) { - pipe->set_fragment_sampler_textures(pipe, - ctx->blitter.saved_num_textures, - ctx->blitter.saved_textures); - ctx->blitter.saved_num_textures = ~0; + if (ctx->blitter.saved_num_sampler_views != ~0) { + pipe->set_fragment_sampler_views(pipe, + ctx->blitter.saved_num_sampler_views, + ctx->blitter.saved_sampler_views); + ctx->blitter.saved_num_sampler_views = ~0; } } @@ -577,9 +584,10 @@ static void util_blitter_do_copy(struct blitter_context *blitter, struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->pipe; struct pipe_framebuffer_state fb_state; + struct pipe_sampler_view viewTempl, *view; assert(blitter->saved_fb_state.nr_cbufs != ~0); - assert(blitter->saved_num_textures != ~0); + assert(blitter->saved_num_sampler_views != ~0); assert(blitter->saved_num_sampler_states != ~0); assert(src->texture->target < PIPE_MAX_TEXTURE_TYPES); @@ -607,11 +615,23 @@ static void util_blitter_do_copy(struct blitter_context *blitter, fb_state.zsbuf = 0; } + u_sampler_view_default_template(&viewTempl, + src->texture, + src->texture->format); + view = pipe->create_sampler_view(pipe, + src->texture, + &viewTempl); + + if (ctx->sampler_view) { + pipe_sampler_view_reference(&ctx->sampler_view, NULL); + } + ctx->sampler_view = view; + pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_vs_state(pipe, ctx->vs_tex); pipe->bind_fragment_sampler_states(pipe, 1, blitter_get_sampler_state(ctx, src->level)); - pipe->set_fragment_sampler_textures(pipe, 1, &src->texture); + pipe->set_fragment_sampler_views(pipe, 1, &view); pipe->set_framebuffer_state(pipe, &fb_state); /* set texture coordinates */ diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index a2f17073ac6..99119485603 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -50,10 +50,10 @@ struct blitter_context struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ int saved_num_sampler_states; - void *saved_sampler_states[32]; + void *saved_sampler_states[PIPE_MAX_SAMPLERS]; - int saved_num_textures; - struct pipe_texture *saved_textures[32]; /* is 32 enough? */ + int saved_num_sampler_views; + struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS]; }; /** @@ -218,17 +218,17 @@ void util_blitter_save_fragment_sampler_states( num_sampler_states * sizeof(void *)); } -static INLINE -void util_blitter_save_fragment_sampler_textures( - struct blitter_context *blitter, - int num_textures, - struct pipe_texture **textures) +static INLINE void +util_blitter_save_fragment_sampler_views(struct blitter_context *blitter, + int num_views, + struct pipe_sampler_view **views) { - assert(num_textures <= Elements(blitter->saved_textures)); + assert(num_views <= Elements(blitter->saved_sampler_views)); - blitter->saved_num_textures = num_textures; - memcpy(blitter->saved_textures, textures, - num_textures * sizeof(struct pipe_texture *)); + blitter->saved_num_sampler_views = num_views; + memcpy(blitter->saved_sampler_views, + views, + num_views * sizeof(struct pipe_sampler_view *)); } #ifdef __cplusplus diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index e95d58ea863..f8dfea4e51a 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -117,6 +117,16 @@ pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex) *ptr = tex; } +static INLINE void +pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view) +{ + struct pipe_sampler_view *old_view = *ptr; + + if (pipe_reference(&(*ptr)->reference, &view->reference)) + old_view->context->sampler_view_destroy(old_view->context, old_view); + *ptr = view; +} + /* * Convenience wrappers for screen buffer functions. diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c new file mode 100644 index 00000000000..3e45a2fa70d --- /dev/null +++ b/src/gallium/auxiliary/util/u_sampler.c @@ -0,0 +1,97 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#include "u_format.h" +#include "u_sampler.h" + + +static void +default_template(struct pipe_sampler_view *view, + const struct pipe_texture *texture, + enum pipe_format format, + unsigned expand_green_blue) +{ + /* XXX: Check if format is compatible with texture->format. + */ + + view->format = format; + view->first_level = 0; + view->num_levels = texture->last_level + 1; + view->swizzle_r = PIPE_SWIZZLE_RED; + view->swizzle_g = PIPE_SWIZZLE_GREEN; + view->swizzle_b = PIPE_SWIZZLE_BLUE; + view->swizzle_a = PIPE_SWIZZLE_ALPHA; + + /* Override default green and blue component expansion to the requested one. + * + * Gallium expands nonexistent components to (0,0,0,1), DX9 expands to (1,1,1,1). + * Since alpha is always expanded to 1, and red is always present, we only really + * care about green and blue components. + * + * To make it look less hackish, one would have to add UTIL_FORMAT_SWIZZLE_EXPAND + * to indicate components for expansion and then override without exceptions or + * favoring one component over another. + */ + if (format != PIPE_FORMAT_A8_UNORM) { + const struct util_format_description *desc = util_format_description(format); + + assert(desc); + if (desc) { + if (desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0) { + view->swizzle_g = expand_green_blue; + } + if (desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0) { + view->swizzle_b = expand_green_blue; + } + } + } +} + +void +u_sampler_view_default_template(struct pipe_sampler_view *view, + const struct pipe_texture *texture, + enum pipe_format format) +{ + /* Expand to (0, 0, 0, 1) */ + default_template(view, + texture, + format, + PIPE_SWIZZLE_ZERO); +} + +void +u_sampler_view_default_dx9_template(struct pipe_sampler_view *view, + const struct pipe_texture *texture, + enum pipe_format format) +{ + /* Expand to (1, 1, 1, 1) */ + default_template(view, + texture, + format, + PIPE_SWIZZLE_ONE); +} diff --git a/src/gallium/auxiliary/util/u_sampler.h b/src/gallium/auxiliary/util/u_sampler.h new file mode 100644 index 00000000000..bdd061c851c --- /dev/null +++ b/src/gallium/auxiliary/util/u_sampler.h @@ -0,0 +1,57 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#ifndef U_SAMPLER_H +#define U_SAMPLER_H + + +#include "pipe/p_defines.h" +#include "pipe/p_format.h" +#include "pipe/p_state.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +void +u_sampler_view_default_template(struct pipe_sampler_view *view, + const struct pipe_texture *texture, + enum pipe_format format); + +void +u_sampler_view_default_dx9_template(struct pipe_sampler_view *view, + const struct pipe_texture *texture, + enum pipe_format format); + + +#ifdef __cplusplus +} /* extern "C" { */ +#endif + +#endif /* U_SAMPLER_H */ diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index bb1a168ea7a..ae3b0b0c189 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -85,8 +85,8 @@ struct failover_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; - struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; @@ -103,8 +103,8 @@ struct failover_context { unsigned num_samplers; unsigned num_vertex_samplers; - unsigned num_textures; - unsigned num_vertex_textures; + unsigned num_sampler_views; + unsigned num_vertex_sampler_views; unsigned mode; struct pipe_context *hw; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index 970606a3f50..b16f2197f11 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -405,9 +405,9 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler) static void -failover_set_fragment_sampler_textures(struct pipe_context *pipe, - unsigned num, - struct pipe_texture **texture) +failover_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); uint i; @@ -415,49 +415,49 @@ failover_set_fragment_sampler_textures(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == failover->num_textures && - !memcmp(failover->texture, texture, num * sizeof(struct pipe_texture *))) + if (num == failover->num_sampler_views && + !memcmp(failover->sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; for (i = 0; i < num; i++) - pipe_texture_reference((struct pipe_texture **) &failover->texture[i], - texture[i]); - for (i = num; i < failover->num_textures; i++) - pipe_texture_reference((struct pipe_texture **) &failover->texture[i], - NULL); + pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], + views[i]); + for (i = num; i < failover->num_sampler_views; i++) + pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], + NULL); failover->dirty |= FO_NEW_TEXTURE; - failover->num_textures = num; - failover->sw->set_fragment_sampler_textures( failover->sw, num, texture ); - failover->hw->set_fragment_sampler_textures( failover->hw, num, texture ); + failover->num_sampler_views = num; + failover->sw->set_fragment_sampler_views( failover->sw, num, views ); + failover->hw->set_fragment_sampler_views( failover->hw, num, views ); } static void -failover_set_vertex_sampler_textures(struct pipe_context *pipe, - unsigned num_textures, - struct pipe_texture **textures) +failover_set_vertex_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); uint i; - assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS); + assert(num <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ - if (num_textures == failover->num_vertex_textures && - !memcmp(failover->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) { + if (num == failover->num_vertex_sampler_views && + !memcmp(failover->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { return; } - for (i = 0; i < num_textures; i++) { - pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i], - textures[i]); + for (i = 0; i < num; i++) { + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], + views[i]); } - for (i = num_textures; i < failover->num_vertex_textures; i++) { - pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i], - NULL); + for (i = num; i < failover->num_vertex_sampler_views; i++) { + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], + NULL); } failover->dirty |= FO_NEW_TEXTURE; - failover->num_vertex_textures = num_textures; - failover->sw->set_vertex_sampler_textures(failover->sw, num_textures, textures); - failover->hw->set_vertex_sampler_textures(failover->hw, num_textures, textures); + failover->num_vertex_sampler_views = num; + failover->sw->set_vertex_sampler_views(failover->sw, num, views); + failover->hw->set_vertex_sampler_views(failover->hw, num, views); } @@ -550,8 +550,8 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_scissor_state = failover_set_scissor_state; - failover->pipe.set_fragment_sampler_textures = failover_set_fragment_sampler_textures; - failover->pipe.set_vertex_sampler_textures = failover_set_vertex_sampler_textures; + failover->pipe.set_fragment_sampler_views = failover_set_fragment_sampler_views; + failover->pipe.set_vertex_sampler_views = failover_set_vertex_sampler_views; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffers = failover_set_vertex_buffers; failover->pipe.set_vertex_elements = failover_set_vertex_elements; diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index 5c000808425..1c37668027f 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -103,11 +103,11 @@ failover_state_emit( struct failover_context *failover ) } if (failover->dirty & FO_NEW_TEXTURE) { - failover->sw->set_fragment_sampler_textures( failover->sw, failover->num_textures, - failover->texture ); - failover->sw->set_vertex_sampler_textures(failover->sw, - failover->num_vertex_textures, - failover->vertex_textures); + failover->sw->set_fragment_sampler_views( failover->sw, failover->num_sampler_views, + failover->sampler_views ); + failover->sw->set_vertex_sampler_views(failover->sw, + failover->num_vertex_sampler_views, + failover->vertex_sampler_views); } if (failover->dirty & FO_NEW_VERTEX_BUFFER) { diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 8248b2a4132..2272f4a126a 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -492,53 +492,49 @@ identity_set_viewport_state(struct pipe_context *_pipe, } static void -identity_set_fragment_sampler_textures(struct pipe_context *_pipe, - unsigned num_textures, - struct pipe_texture **_textures) +identity_set_fragment_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **_views) { struct identity_context *id_pipe = identity_context(_pipe); struct pipe_context *pipe = id_pipe->pipe; - struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS]; - struct pipe_texture **textures = NULL; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view **views = NULL; unsigned i; - if (_textures) { - for (i = 0; i < num_textures; i++) - unwrapped_textures[i] = identity_texture_unwrap(_textures[i]); + if (_views) { + for (i = 0; i < num; i++) + unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]); for (; i < PIPE_MAX_SAMPLERS; i++) - unwrapped_textures[i] = NULL; + unwrapped_views[i] = NULL; - textures = unwrapped_textures; + views = unwrapped_views; } - pipe->set_fragment_sampler_textures(pipe, - num_textures, - textures); + pipe->set_fragment_sampler_views(pipe, num, views); } static void -identity_set_vertex_sampler_textures(struct pipe_context *_pipe, - unsigned num_textures, - struct pipe_texture **_textures) +identity_set_vertex_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **_views) { struct identity_context *id_pipe = identity_context(_pipe); struct pipe_context *pipe = id_pipe->pipe; - struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS]; - struct pipe_texture **textures = NULL; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view **views = NULL; unsigned i; - if (_textures) { - for (i = 0; i < num_textures; i++) - unwrapped_textures[i] = identity_texture_unwrap(_textures[i]); + if (_views) { + for (i = 0; i < num; i++) + unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]); for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++) - unwrapped_textures[i] = NULL; + unwrapped_views[i] = NULL; - textures = unwrapped_textures; + views = unwrapped_views; } - pipe->set_vertex_sampler_textures(pipe, - num_textures, - textures); + pipe->set_vertex_sampler_views(pipe, num, views); } static void @@ -741,8 +737,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple; id_pipe->base.set_scissor_state = identity_set_scissor_state; id_pipe->base.set_viewport_state = identity_set_viewport_state; - id_pipe->base.set_fragment_sampler_textures = identity_set_fragment_sampler_textures; - id_pipe->base.set_vertex_sampler_textures = identity_set_vertex_sampler_textures; + id_pipe->base.set_fragment_sampler_views = identity_set_fragment_sampler_views; + id_pipe->base.set_vertex_sampler_views = identity_set_vertex_sampler_views; id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers; id_pipe->base.set_vertex_elements = identity_set_vertex_elements; id_pipe->base.surface_copy = identity_surface_copy; diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 77cc7190798..b48df83b3ed 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -52,6 +52,14 @@ struct identity_texture }; +struct identity_sampler_view +{ + struct pipe_sampler_view base; + + struct pipe_sampler_view *sampler_view; +}; + + struct identity_surface { struct pipe_surface base; @@ -94,6 +102,15 @@ identity_texture(struct pipe_texture *_texture) return (struct identity_texture *)_texture; } +static INLINE struct identity_sampler_view * +identity_sampler_view(struct pipe_sampler_view *_sampler_view) +{ + if (!_sampler_view) { + return NULL; + } + return (struct identity_sampler_view *)_sampler_view; +} + static INLINE struct identity_surface * identity_surface(struct pipe_surface *_surface) { @@ -138,6 +155,15 @@ identity_texture_unwrap(struct pipe_texture *_texture) return identity_texture(_texture)->texture; } +static INLINE struct pipe_sampler_view * +identity_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) +{ + if (!_sampler_view) { + return NULL; + } + return identity_sampler_view(_sampler_view)->sampler_view; +} + static INLINE struct pipe_surface * identity_surface_unwrap(struct pipe_surface *_surface) { diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index ddc35bcd629..858e118bc66 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -103,12 +103,12 @@ softpipe_destroy( struct pipe_context *pipe ) for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { sp_destroy_tex_tile_cache(softpipe->tex_cache[i]); - pipe_texture_reference(&softpipe->texture[i], NULL); + pipe_sampler_view_reference(&softpipe->sampler_views[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { sp_destroy_tex_tile_cache(softpipe->vertex_tex_cache[i]); - pipe_texture_reference(&softpipe->vertex_textures[i], NULL); + pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], NULL); } for (i = 0; i < PIPE_SHADER_TYPES; i++) { @@ -252,8 +252,8 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; - softpipe->pipe.set_fragment_sampler_textures = softpipe_set_sampler_textures; - softpipe->pipe.set_vertex_sampler_textures = softpipe_set_vertex_sampler_textures; + softpipe->pipe.set_fragment_sampler_views = softpipe_set_sampler_views; + softpipe->pipe.set_vertex_sampler_views = softpipe_set_vertex_sampler_views; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers; diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 95def72c541..2f0f51de2c4 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -68,16 +68,16 @@ struct softpipe_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; - struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned num_samplers; - unsigned num_textures; + unsigned num_sampler_views; unsigned num_vertex_samplers; - unsigned num_vertex_textures; + unsigned num_vertex_sampler_views; unsigned num_vertex_elements; unsigned num_vertex_buffers; diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index e8952bf4fb8..38dea13c66b 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -50,10 +50,10 @@ softpipe_flush( struct pipe_context *pipe, draw_flush(softpipe->draw); if (flags & PIPE_FLUSH_TEXTURE_CACHE) { - for (i = 0; i < softpipe->num_textures; i++) { + for (i = 0; i < softpipe->num_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->tex_cache[i]); } - for (i = 0; i < softpipe->num_vertex_textures; i++) { + for (i = 0; i < softpipe->num_vertex_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]); } } diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 4370bbeaee2..ba9bbfe68a4 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -166,14 +166,14 @@ void softpipe_set_polygon_stipple( struct pipe_context *, void softpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); -void softpipe_set_sampler_textures( struct pipe_context *, - unsigned num, - struct pipe_texture ** ); +void softpipe_set_sampler_views( struct pipe_context *, + unsigned num, + struct pipe_sampler_view ** ); void -softpipe_set_vertex_sampler_textures(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); +softpipe_set_vertex_sampler_views(struct pipe_context *, + unsigned num, + struct pipe_sampler_view **); void softpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index ceb4e338f1a..c985b5c3e08 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -122,8 +122,9 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe, void -softpipe_set_sampler_textures(struct pipe_context *pipe, - unsigned num, struct pipe_texture **texture) +softpipe_set_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; @@ -131,51 +132,53 @@ softpipe_set_sampler_textures(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == softpipe->num_textures && - !memcmp(softpipe->texture, texture, num * sizeof(struct pipe_texture *))) + if (num == softpipe->num_sampler_views && + !memcmp(softpipe->sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; draw_flush(softpipe->draw); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - struct pipe_texture *tex = i < num ? texture[i] : NULL; + struct pipe_sampler_view *view = i < num ? views[i] : NULL; + struct pipe_texture *texture = view ? view->texture : NULL; - pipe_texture_reference(&softpipe->texture[i], tex); - sp_tex_tile_cache_set_texture(softpipe->tex_cache[i], tex); + pipe_sampler_view_reference(&softpipe->sampler_views[i], view); + sp_tex_tile_cache_set_texture(softpipe->tex_cache[i], texture); } - softpipe->num_textures = num; + softpipe->num_sampler_views = num; softpipe->dirty |= SP_NEW_TEXTURE; } void -softpipe_set_vertex_sampler_textures(struct pipe_context *pipe, - unsigned num_textures, - struct pipe_texture **textures) +softpipe_set_vertex_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; - assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS); + assert(num <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ - if (num_textures == softpipe->num_vertex_textures && - !memcmp(softpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) { + if (num == softpipe->num_vertex_sampler_views && + !memcmp(softpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { return; } draw_flush(softpipe->draw); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - struct pipe_texture *tex = i < num_textures ? textures[i] : NULL; + struct pipe_sampler_view *view = i < num ? views[i] : NULL; + struct pipe_texture *texture = view ? view->texture : NULL; - pipe_texture_reference(&softpipe->vertex_textures[i], tex); - sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], tex); + pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], view); + sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], texture); } - softpipe->num_vertex_textures = num_textures; + softpipe->num_vertex_sampler_views = num; softpipe->dirty |= SP_NEW_TEXTURE; } @@ -245,29 +248,41 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe) */ for (i = 0; i <= softpipe->vs->max_sampler; i++) { if (softpipe->vertex_samplers[i]) { + struct pipe_texture *texture = NULL; + + if (softpipe->vertex_sampler_views[i]) { + texture = softpipe->vertex_sampler_views[i]->texture; + } + softpipe->tgsi.vert_samplers_list[i] = get_sampler_varient( i, - sp_sampler(softpipe->vertex_samplers[i]), - softpipe->vertex_textures[i], + sp_sampler(softpipe->vertex_samplers[i]), + texture, TGSI_PROCESSOR_VERTEX ); sp_sampler_varient_bind_texture( softpipe->tgsi.vert_samplers_list[i], - softpipe->vertex_tex_cache[i], - softpipe->vertex_textures[i] ); + softpipe->vertex_tex_cache[i], + texture ); } } for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) { if (softpipe->sampler[i]) { + struct pipe_texture *texture = NULL; + + if (softpipe->sampler_views[i]) { + texture = softpipe->sampler_views[i]->texture; + } + softpipe->tgsi.frag_samplers_list[i] = get_sampler_varient( i, sp_sampler(softpipe->sampler[i]), - softpipe->texture[i], + texture, TGSI_PROCESSOR_FRAGMENT ); sp_sampler_varient_bind_texture( softpipe->tgsi.frag_samplers_list[i], softpipe->tex_cache[i], - softpipe->texture[i] ); + texture ); } } } diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 03302e2a6ec..b1022c3c996 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -179,7 +179,7 @@ struct svga_state const struct svga_rasterizer_state *rast; const struct svga_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; /* or texture ID's? */ + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; /* or texture ID's? */ struct svga_fragment_shader *fs; struct svga_vertex_shader *vs; @@ -203,7 +203,7 @@ struct svga_state struct pipe_viewport_state viewport; unsigned num_samplers; - unsigned num_textures; + unsigned num_sampler_views; unsigned num_vertex_elements; unsigned num_vertex_buffers; unsigned reduced_prim; diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 224c4f4c183..a2dfa4557df 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -176,9 +176,9 @@ static void svga_delete_sampler_state(struct pipe_context *pipe, } -static void svga_set_sampler_textures(struct pipe_context *pipe, - unsigned num, - struct pipe_texture **texture) +static void svga_set_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct svga_context *svga = svga_context(pipe); unsigned flag_1d = 0; @@ -188,31 +188,31 @@ static void svga_set_sampler_textures(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == svga->curr.num_textures && - !memcmp(svga->curr.texture, texture, num * sizeof(struct pipe_texture *))) { + if (num == svga->curr.num_sampler_views && + !memcmp(svga->curr.sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { if (0) debug_printf("texture noop\n"); return; } for (i = 0; i < num; i++) { - pipe_texture_reference(&svga->curr.texture[i], - texture[i]); + pipe_sampler_view_reference(&svga->curr.sampler_views[i], + views[i]); - if (!texture[i]) + if (!views[i]) continue; - if (texture[i]->format == PIPE_FORMAT_A8R8G8B8_SRGB) + if (views[i]->texture->format == PIPE_FORMAT_A8R8G8B8_SRGB) flag_srgb |= 1 << i; - if (texture[i]->target == PIPE_TEXTURE_1D) + if (views[i]->texture->target == PIPE_TEXTURE_1D) flag_1d |= 1 << i; } - for (i = num; i < svga->curr.num_textures; i++) - pipe_texture_reference(&svga->curr.texture[i], - NULL); + for (i = num; i < svga->curr.num_sampler_views; i++) + pipe_sampler_view_reference(&svga->curr.sampler_views[i], + NULL); - svga->curr.num_textures = num; + svga->curr.num_sampler_views = num; svga->dirty |= SVGA_NEW_TEXTURE_BINDING; if (flag_srgb != svga->curr.tex_flags.flag_srgb || @@ -231,7 +231,7 @@ void svga_init_sampler_functions( struct svga_context *svga ) svga->pipe.create_sampler_state = svga_create_sampler_state; svga->pipe.bind_fragment_sampler_states = svga_bind_sampler_states; svga->pipe.delete_sampler_state = svga_delete_sampler_state; - svga->pipe.set_fragment_sampler_textures = svga_set_sampler_textures; + svga->pipe.set_fragment_sampler_views = svga_set_sampler_views; } diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index bb92f818eae..493f78a9908 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -137,7 +137,7 @@ static int emit_fs_consts( struct svga_context *svga, for (i = 0; i < key->num_textures; i++) { if (key->tex[i].unnormalized) { - struct pipe_texture *tex = svga->curr.texture[i]; + struct pipe_texture *tex = svga->curr.sampler_views[i]->texture; float data[4]; data[0] = 1.0 / (float)tex->width0; diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 2973444d0ab..1310fd9825f 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -158,10 +158,11 @@ static int make_fs_key( const struct svga_context *svga, * * SVGA_NEW_TEXTURE_BINDING | SVGA_NEW_SAMPLER */ - for (i = 0; i < svga->curr.num_textures; i++) { - if (svga->curr.texture[i]) { + for (i = 0; i < svga->curr.num_sampler_views; i++) { + if (svga->curr.sampler_views[i]) { assert(svga->curr.sampler[i]); - key->tex[i].texture_target = svga->curr.texture[i]->target; + assert(svga->curr.sampler_views[i]->texture); + key->tex[i].texture_target = svga->curr.sampler_views[i]->texture->target; if (!svga->curr.sampler[i]->normalized_coords) { key->tex[i].width_height_idx = idx++; key->tex[i].unnormalized = TRUE; @@ -169,7 +170,7 @@ static int make_fs_key( const struct svga_context *svga, } } } - key->num_textures = svga->curr.num_textures; + key->num_textures = svga->curr.num_sampler_views; idx = 0; for (i = 0; i < svga->curr.num_samplers; ++i) { diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c index 17b47859781..c08ec7c2e8c 100644 --- a/src/gallium/drivers/svga/svga_state_tss.c +++ b/src/gallium/drivers/svga/svga_state_tss.c @@ -37,14 +37,14 @@ void svga_cleanup_tss_binding(struct svga_context *svga) { int i; - unsigned count = MAX2( svga->curr.num_textures, + unsigned count = MAX2( svga->curr.num_sampler_views, svga->state.hw_draw.num_views ); for (i = 0; i < count; i++) { struct svga_hw_view_state *view = &svga->state.hw_draw.views[i]; svga_sampler_view_reference(&view->v, NULL); - pipe_texture_reference( &svga->curr.texture[i], NULL ); + pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL ); pipe_texture_reference( &view->texture, NULL ); view->dirty = 1; @@ -57,7 +57,7 @@ update_tss_binding(struct svga_context *svga, unsigned dirty ) { unsigned i; - unsigned count = MAX2( svga->curr.num_textures, + unsigned count = MAX2( svga->curr.num_sampler_views, svga->state.hw_draw.num_views ); unsigned min_lod; unsigned max_lod; @@ -77,30 +77,32 @@ update_tss_binding(struct svga_context *svga, for (i = 0; i < count; i++) { const struct svga_sampler_state *s = svga->curr.sampler[i]; struct svga_hw_view_state *view = &svga->state.hw_draw.views[i]; + struct pipe_texture *texture = NULL; /* get min max lod */ - if (svga->curr.texture[i]) { + if (svga->curr.sampler_views[i]) { min_lod = MAX2(s->view_min_lod, 0); - max_lod = MIN2(s->view_max_lod, svga->curr.texture[i]->last_level); + max_lod = MIN2(s->view_max_lod, svga->curr.sampler_views[i]->texture->last_level); + texture = svga->curr.sampler_views[i]->texture; } else { min_lod = 0; max_lod = 0; } - if (view->texture != svga->curr.texture[i] || + if (view->texture != texture || view->min_lod != min_lod || view->max_lod != max_lod) { svga_sampler_view_reference(&view->v, NULL); - pipe_texture_reference( &view->texture, svga->curr.texture[i] ); + pipe_texture_reference( &view->texture, texture ); view->dirty = TRUE; view->min_lod = min_lod; view->max_lod = max_lod; - if (svga->curr.texture[i]) + if (texture) view->v = svga_get_tex_sampler_view(&svga->pipe, - svga->curr.texture[i], + texture, min_lod, max_lod); } @@ -115,7 +117,7 @@ update_tss_binding(struct svga_context *svga, } } - svga->state.hw_draw.num_views = svga->curr.num_textures; + svga->state.hw_draw.num_views = svga->curr.num_sampler_views; if (queue.bind_count) { SVGA3dTextureState *ts; diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index df40fbade6c..6293dd79acf 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -112,7 +112,7 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag) (void *) tr_ctx->draw_rule.fs, (void *) tr_ctx->curr.fs, (void *) tr_ctx->draw_rule.vs, (void *) tr_ctx->curr.vs, (void *) tr_ctx->draw_rule.surf, 0, - (void *) tr_ctx->draw_rule.tex, 0); + (void *) tr_ctx->draw_rule.sampler_view, 0); if (tr_ctx->draw_rule.fs && tr_ctx->draw_rule.fs == tr_ctx->curr.fs) block = TRUE; @@ -126,12 +126,12 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag) for (k = 0; k < tr_ctx->curr.nr_cbufs; k++) if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k]) block = TRUE; - if (tr_ctx->draw_rule.tex) { - for (k = 0; k < tr_ctx->curr.num_texs; k++) - if (tr_ctx->draw_rule.tex == tr_ctx->curr.tex[k]) + if (tr_ctx->draw_rule.sampler_view) { + for (k = 0; k < tr_ctx->curr.num_sampler_views; k++) + if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.sampler_views[k]) block = TRUE; - for (k = 0; k < tr_ctx->curr.num_vert_texs; k++) { - if (tr_ctx->draw_rule.tex == tr_ctx->curr.vert_tex[k]) { + for (k = 0; k < tr_ctx->curr.num_vert_sampler_views; k++) { + if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.vert_sampler_views[k]) { block = TRUE; } } @@ -950,62 +950,62 @@ trace_context_set_viewport_state(struct pipe_context *_pipe, static INLINE void -trace_context_set_fragment_sampler_textures(struct pipe_context *_pipe, - unsigned num_textures, - struct pipe_texture **textures) +trace_context_set_fragment_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **views) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_texture *tr_tex; + struct trace_sampler_view *tr_view; struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_texs = num_textures; - for(i = 0; i < num_textures; ++i) { - tr_tex = trace_texture(textures[i]); - tr_ctx->curr.tex[i] = tr_tex; - unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL; + tr_ctx->curr.num_sampler_views = num; + for(i = 0; i < num; ++i) { + tr_view = trace_sampler_view(views[i]); + tr_ctx->curr.sampler_views[i] = tr_view; + unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } - textures = unwrapped_textures; + views = unwrapped_views; - trace_dump_call_begin("pipe_context", "set_fragment_sampler_textures"); + trace_dump_call_begin("pipe_context", "set_fragment_sampler_views"); trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, num_textures); - trace_dump_arg_array(ptr, textures, num_textures); + trace_dump_arg(uint, num); + trace_dump_arg_array(ptr, views, num); - pipe->set_fragment_sampler_textures(pipe, num_textures, textures); + pipe->set_fragment_sampler_views(pipe, num, views); trace_dump_call_end(); } static INLINE void -trace_context_set_vertex_sampler_textures(struct pipe_context *_pipe, - unsigned num_textures, - struct pipe_texture **textures) +trace_context_set_vertex_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **views) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_texture *tr_tex; + struct trace_sampler_view *tr_view; struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_vert_texs = num_textures; - for(i = 0; i < num_textures; ++i) { - tr_tex = trace_texture(textures[i]); - tr_ctx->curr.vert_tex[i] = tr_tex; - unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL; + tr_ctx->curr.num_vert_sampler_views = num; + for(i = 0; i < num; ++i) { + tr_view = trace_sampler_view(views[i]); + tr_ctx->curr.vert_sampler_views[i] = tr_view; + unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } - textures = unwrapped_textures; + views = unwrapped_views; - trace_dump_call_begin("pipe_context", "set_vertex_sampler_textures"); + trace_dump_call_begin("pipe_context", "set_vertex_sampler_views"); trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, num_textures); - trace_dump_arg_array(ptr, textures, num_textures); + trace_dump_arg(uint, num); + trace_dump_arg_array(ptr, views, num); - pipe->set_vertex_sampler_textures(pipe, num_textures, textures); + pipe->set_vertex_sampler_views(pipe, num, views); trace_dump_call_end(); } @@ -1311,8 +1311,8 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple; tr_ctx->base.set_scissor_state = trace_context_set_scissor_state; tr_ctx->base.set_viewport_state = trace_context_set_viewport_state; - tr_ctx->base.set_fragment_sampler_textures = trace_context_set_fragment_sampler_textures; - tr_ctx->base.set_vertex_sampler_textures = trace_context_set_vertex_sampler_textures; + tr_ctx->base.set_fragment_sampler_views = trace_context_set_fragment_sampler_views; + tr_ctx->base.set_vertex_sampler_views = trace_context_set_vertex_sampler_views; tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers; tr_ctx->base.set_vertex_elements = trace_context_set_vertex_elements; if (pipe->surface_copy) diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 14284232485..feec9b6bbf3 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -53,11 +53,11 @@ struct trace_context struct trace_shader *fs; struct trace_shader *vs; - struct trace_texture *tex[PIPE_MAX_SAMPLERS]; - unsigned num_texs; + struct trace_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; + unsigned num_sampler_views; - struct trace_texture *vert_tex[PIPE_MAX_VERTEX_SAMPLERS]; - unsigned num_vert_texs; + struct trace_sampler_view *vert_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; + unsigned num_vert_sampler_views; unsigned nr_cbufs; struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS]; @@ -68,7 +68,7 @@ struct trace_context struct trace_shader *fs; struct trace_shader *vs; - struct trace_texture *tex; + struct trace_sampler_view *sampler_view; struct trace_texture *surf; int blocker; diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c index a43adac6940..07f9de253ec 100644 --- a/src/gallium/drivers/trace/tr_rbug.c +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -313,12 +313,12 @@ trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header, for (i = 0; i < tr_ctx->curr.nr_cbufs; i++) cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]); - for (i = 0; i < tr_ctx->curr.num_texs; i++) - texs[i] = VOID2U64(tr_ctx->curr.tex[i]); + for (i = 0; i < tr_ctx->curr.num_sampler_views; i++) + texs[i] = VOID2U64(tr_ctx->curr.sampler_views[i]); rbug_send_context_info_reply(tr_rbug->con, serial, VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs), - texs, tr_ctx->curr.num_texs, + texs, tr_ctx->curr.num_sampler_views, cbufs, tr_ctx->curr.nr_cbufs, VOID2U64(tr_ctx->curr.zsbuf), tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL); @@ -444,7 +444,7 @@ trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *hea pipe_mutex_lock(tr_ctx->draw_mutex); tr_ctx->draw_rule.vs = U642VOID(rule->vertex); tr_ctx->draw_rule.fs = U642VOID(rule->fragment); - tr_ctx->draw_rule.tex = U642VOID(rule->texture); + tr_ctx->draw_rule.sampler_view = U642VOID(rule->texture); tr_ctx->draw_rule.surf = U642VOID(rule->surface); tr_ctx->draw_rule.blocker = rule->block; tr_ctx->draw_blocker |= RBUG_BLOCK_RULE; diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index 395e523e73a..a2ca3c21dbf 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -55,6 +55,16 @@ struct trace_surface }; +struct trace_sampler_view +{ + struct pipe_sampler_view base; + + struct pipe_sampler_view *sampler_view; + + struct tr_list list; +}; + + struct trace_transfer { struct pipe_transfer base; @@ -87,6 +97,15 @@ trace_surface(struct pipe_surface *surface) } +static INLINE struct trace_sampler_view * +trace_sampler_view(struct pipe_sampler_view *sampler_view) +{ + if (!sampler_view) + return NULL; + return (struct trace_sampler_view *)sampler_view; +} + + static INLINE struct trace_transfer * trace_transfer(struct pipe_transfer *transfer) { diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f82b77903e9..0c265484e9a 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -208,13 +208,13 @@ struct pipe_context { void (*set_viewport_state)( struct pipe_context *, const struct pipe_viewport_state * ); - void (*set_fragment_sampler_textures)(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); + void (*set_fragment_sampler_views)(struct pipe_context *, + unsigned num_views, + struct pipe_sampler_view **); - void (*set_vertex_sampler_textures)(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); + void (*set_vertex_sampler_views)(struct pipe_context *, + unsigned num_views, + struct pipe_sampler_view **); void (*set_vertex_buffers)( struct pipe_context *, unsigned num_buffers, @@ -303,6 +303,16 @@ struct pipe_context { */ unsigned int (*is_buffer_referenced)(struct pipe_context *pipe, struct pipe_buffer *buf); + + /** + * Create a view on a texture to be used by a shader stage. + */ + struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx, + struct pipe_texture *texture, + const struct pipe_sampler_view *templat); + + void (*sampler_view_destroy)(struct pipe_context *ctx, + struct pipe_sampler_view *view); }; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 5cebd43ace2..73c70b2fe40 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -368,6 +368,17 @@ enum pipe_transfer_usage { #define PIPE_SPRITE_COORD_LOWER_LEFT 1 +/** + * Texture swizzles + */ +#define PIPE_SWIZZLE_RED 0 +#define PIPE_SWIZZLE_GREEN 1 +#define PIPE_SWIZZLE_BLUE 2 +#define PIPE_SWIZZLE_ALPHA 3 +#define PIPE_SWIZZLE_ZERO 4 +#define PIPE_SWIZZLE_ONE 5 + + /** * Implementation capabilities/limits which are queried through * pipe_screen::get_param() and pipe_screen::get_paramf(). diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 5ac5c878135..603848b11f4 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -309,6 +309,24 @@ struct pipe_surface }; +/** + * A view into a texture that can be bound to a shader stage. + */ +struct pipe_sampler_view +{ + struct pipe_reference reference; + enum pipe_format format; /**< typed PIPE_FORMAT_x */ + struct pipe_texture *texture; /**< texture into which this is a view */ + struct pipe_context *context; /**< context this view belongs to */ + unsigned first_level:8; /**< first mipmap level */ + unsigned num_levels:8; /**< number of mipamp levels */ + unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ + unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ + unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ + unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */ +}; + + /** * Transfer object. For data transfer to/from a texture. */ diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 36c0a2b0e1e..4c02e01e5b1 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -586,10 +586,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_texture *textures[2]; textures[0] = pt; textures[1] = st->pixel_xfer.pixelmap_texture; - pipe->set_fragment_sampler_textures(pipe, 2, textures); + cso_set_sampler_textures(cso, 2, textures); } else { - pipe->set_fragment_sampler_textures(pipe, 1, &pt); + cso_set_sampler_textures(cso, 1, &pt); } /* Compute window coords (y=0=bottom) with pixel zoom. From 9187b25a15145933ca014556e109b17ecf38ece4 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Feb 2010 16:09:10 +0100 Subject: [PATCH 005/483] failover: Fix after sampler view changes. --- src/gallium/drivers/failover/fo_context.h | 18 +++-- src/gallium/drivers/failover/fo_state.c | 80 +++++++++++++++----- src/gallium/drivers/failover/fo_state_emit.c | 22 ++++-- 3 files changed, 89 insertions(+), 31 deletions(-) diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index ae3b0b0c189..53e1a02bcba 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -47,7 +47,7 @@ #define FO_NEW_ALPHA_TEST 0x100 #define FO_NEW_DEPTH_STENCIL 0x200 #define FO_NEW_SAMPLER 0x400 -#define FO_NEW_TEXTURE 0x800 +#define FO_NEW_SAMPLER_VIEW 0x800 #define FO_NEW_VERTEX 0x2000 #define FO_NEW_VERTEX_SHADER 0x4000 #define FO_NEW_BLEND_COLOR 0x8000 @@ -65,6 +65,13 @@ struct fo_state { void *sw_state; void *hw_state; }; + +struct fo_sampler_view { + struct pipe_sampler_view base; + struct pipe_sampler_view *sw; + struct pipe_sampler_view *hw; +}; + struct failover_context { struct pipe_context pipe; /**< base class */ @@ -85,8 +92,6 @@ struct failover_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; @@ -99,12 +104,15 @@ struct failover_context { void *sw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS]; void *hw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS]; + struct fo_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; + struct fo_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; + unsigned num_fragment_sampler_views; + unsigned num_vertex_sampler_views; + unsigned dirty; unsigned num_samplers; unsigned num_vertex_samplers; - unsigned num_sampler_views; - unsigned num_vertex_sampler_views; unsigned mode; struct pipe_context *hw; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index b16f2197f11..d0c2f1474ae 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -404,30 +404,66 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler) } +static struct pipe_sampler_view * +failover_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view)); + struct failover_context *failover = failover_context(pipe); + + view->sw = failover->sw->create_sampler_view(failover->sw, texture, templ); + view->hw = failover->hw->create_sampler_view(failover->hw, texture, templ); + + view->base = *templ; + view->base.reference.count = 1; + view->base.texture = NULL; + pipe_texture_reference(&view->base.texture, texture); + view->base.context = pipe; + + return &view->base; +} + +static void +failover_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)view; + struct failover_context *failover = failover_context(pipe); + + failover->sw->sampler_view_destroy(failover->sw, fo_view->sw); + failover->hw->sampler_view_destroy(failover->hw, fo_view->hw); + + pipe_texture_reference(&fo_view->base.texture, NULL); + free(fo_view); +} + static void failover_set_fragment_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); + struct pipe_sampler_view *hw_views[PIPE_MAX_SAMPLERS]; uint i; assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == failover->num_sampler_views && - !memcmp(failover->sampler_views, views, num * sizeof(struct pipe_sampler_view *))) + if (num == failover->num_fragment_sampler_views && + !memcmp(failover->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; - for (i = 0; i < num; i++) - pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], - views[i]); - for (i = num; i < failover->num_sampler_views; i++) - pipe_sampler_view_reference((struct pipe_sampler_view **) &failover->sampler_views[i], - NULL); - failover->dirty |= FO_NEW_TEXTURE; - failover->num_sampler_views = num; - failover->sw->set_fragment_sampler_views( failover->sw, num, views ); - failover->hw->set_fragment_sampler_views( failover->hw, num, views ); + for (i = 0; i < num; i++) { + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i]; + + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], views[i]); + hw_views[i] = fo_view->hw; + } + for (i = num; i < failover->num_fragment_sampler_views; i++) + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], NULL); + failover->dirty |= FO_NEW_SAMPLER_VIEW; + failover->num_fragment_sampler_views = num; + failover->hw->set_fragment_sampler_views(failover->hw, num, hw_views); } @@ -437,6 +473,7 @@ failover_set_vertex_sampler_views(struct pipe_context *pipe, struct pipe_sampler_view **views) { struct failover_context *failover = failover_context(pipe); + struct pipe_sampler_view *hw_views[PIPE_MAX_VERTEX_SAMPLERS]; uint i; assert(num <= PIPE_MAX_VERTEX_SAMPLERS); @@ -447,17 +484,16 @@ failover_set_vertex_sampler_views(struct pipe_context *pipe, return; } for (i = 0; i < num; i++) { - pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], - views[i]); + struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i]; + + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], views[i]); + hw_views[i] = fo_view->hw; } - for (i = num; i < failover->num_vertex_sampler_views; i++) { - pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], - NULL); - } - failover->dirty |= FO_NEW_TEXTURE; + for (i = num; i < failover->num_vertex_sampler_views; i++) + pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], NULL); + failover->dirty |= FO_NEW_SAMPLER_VIEW; failover->num_vertex_sampler_views = num; - failover->sw->set_vertex_sampler_views(failover->sw, num, views); - failover->hw->set_vertex_sampler_views(failover->hw, num, views); + failover->hw->set_vertex_sampler_views(failover->hw, num, hw_views); } @@ -556,4 +592,6 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_vertex_buffers = failover_set_vertex_buffers; failover->pipe.set_vertex_elements = failover_set_vertex_elements; failover->pipe.set_constant_buffer = failover_set_constant_buffer; + failover->pipe.create_sampler_view = failover_create_sampler_view; + failover->pipe.sampler_view_destroy = failover_sampler_view_destroy; } diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index 1c37668027f..171151e1ee2 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -102,12 +102,24 @@ failover_state_emit( struct failover_context *failover ) failover->sw_vertex_sampler_state); } - if (failover->dirty & FO_NEW_TEXTURE) { - failover->sw->set_fragment_sampler_views( failover->sw, failover->num_sampler_views, - failover->sampler_views ); + if (failover->dirty & FO_NEW_SAMPLER_VIEW) { + struct pipe_sampler_view *fragment_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_views[PIPE_MAX_VERTEX_SAMPLERS]; + uint i; + + for (i = 0; i < failover->num_fragment_sampler_views; i++) { + fragment_views[i] = failover->fragment_sampler_views[i]->sw; + } + failover->sw->set_fragment_sampler_views(failover->sw, + failover->num_fragment_sampler_views, + fragment_views); + + for (i = 0; i < failover->num_vertex_sampler_views; i++) { + vertex_views[i] = failover->vertex_sampler_views[i]->sw; + } failover->sw->set_vertex_sampler_views(failover->sw, - failover->num_vertex_sampler_views, - failover->vertex_sampler_views); + failover->num_vertex_sampler_views, + vertex_views); } if (failover->dirty & FO_NEW_VERTEX_BUFFER) { From 14a146c4995da5074eb1192a818b7a3dfc3bb438 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Feb 2010 16:09:40 +0100 Subject: [PATCH 006/483] identity: Fix after sampler view changes. --- src/gallium/drivers/identity/id_context.c | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 2272f4a126a..442d851c135 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -685,6 +685,46 @@ identity_is_buffer_referenced(struct pipe_context *_pipe, buffer); } +static struct pipe_sampler_view * +identity_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct identity_context *id_pipe = identity_context(pipe); + struct identity_texture *id_texture = identity_texture(texture); + struct pipe_context *pipe_unwrapped = id_pipe->pipe; + struct pipe_texture *texture_unwrapped = id_texture->texture; + struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view)); + + view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped, + texture_unwrapped, + templ); + + view->base = *templ; + view->base.reference.count = 1; + view->base.texture = NULL; + pipe_texture_reference(&view->base.texture, texture); + view->base.context = pipe; + + return &view->base; +} + +static void +identity_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + struct identity_context *id_pipe = identity_context(pipe); + struct identity_sampler_view *id_view = identity_sampler_view(view); + struct pipe_context *pipe_unwrapped = id_pipe->pipe; + struct pipe_sampler_view *view_unwrapped = id_view->sampler_view; + + pipe_unwrapped->sampler_view_destroy(pipe_unwrapped, + view_unwrapped); + + pipe_texture_reference(&view->texture, NULL); + free(view); +} + struct pipe_context * identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { @@ -747,6 +787,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.flush = identity_flush; id_pipe->base.is_texture_referenced = identity_is_texture_referenced; id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced; + id_pipe->base.create_sampler_view = identity_create_sampler_view; + id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy; id_pipe->pipe = pipe; From eb9c9efedf9e0b1fdb000a3d175285764759af2a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Feb 2010 16:37:42 +0100 Subject: [PATCH 007/483] softpipe: Fix after sampler view changes. --- src/gallium/drivers/softpipe/sp_context.c | 2 ++ src/gallium/drivers/softpipe/sp_state.h | 9 ++++++ .../drivers/softpipe/sp_state_sampler.c | 29 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 858e118bc66..0c74b490fea 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -254,6 +254,8 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; softpipe->pipe.set_fragment_sampler_views = softpipe_set_sampler_views; softpipe->pipe.set_vertex_sampler_views = softpipe_set_vertex_sampler_views; + softpipe->pipe.create_sampler_view = softpipe_create_sampler_view; + softpipe->pipe.sampler_view_destroy = softpipe_sampler_view_destroy; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers; diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index ba9bbfe68a4..b37bb951520 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -175,6 +175,15 @@ softpipe_set_vertex_sampler_views(struct pipe_context *, unsigned num, struct pipe_sampler_view **); +struct pipe_sampler_view * +softpipe_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ); + +void +softpipe_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view); + void softpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index c985b5c3e08..5a92e2223ef 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -121,6 +121,35 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe, } +struct pipe_sampler_view * +softpipe_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +void +softpipe_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + + void softpipe_set_sampler_views(struct pipe_context *pipe, unsigned num, From ad230a1fb12640ac515096d892b58e2bfdb995e7 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Feb 2010 17:03:56 +0100 Subject: [PATCH 008/483] svga: Fix after sampler view changes. --- src/gallium/drivers/svga/svga_pipe_sampler.c | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index a2dfa4557df..26878177308 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -176,6 +176,34 @@ static void svga_delete_sampler_state(struct pipe_context *pipe, } +static struct pipe_sampler_view * +svga_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct svga_context *softpipe = svga_context(pipe); + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +svga_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + struct svga_context *svga = svga_context(pipe); + + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + static void svga_set_sampler_views(struct pipe_context *pipe, unsigned num, struct pipe_sampler_view **views) @@ -232,6 +260,8 @@ void svga_init_sampler_functions( struct svga_context *svga ) svga->pipe.bind_fragment_sampler_states = svga_bind_sampler_states; svga->pipe.delete_sampler_state = svga_delete_sampler_state; svga->pipe.set_fragment_sampler_views = svga_set_sampler_views; + svga->pipe.create_sampler_view = svga_create_sampler_view; + svga->pipe.sampler_view_destroy = svga_sampler_view_destroy; } From 92b781c2dda9ae5aeec7e32cfc9902057edd0a9d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Feb 2010 19:18:27 +0100 Subject: [PATCH 009/483] trace: Fix after sampler view changes. --- src/gallium/drivers/trace/tr_context.c | 59 ++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_texture.h | 2 - 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 6293dd79acf..c84cbd0e521 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_simple_list.h" @@ -949,6 +950,62 @@ trace_context_set_viewport_state(struct pipe_context *_pipe, } +static struct pipe_sampler_view * +trace_create_sampler_view(struct pipe_context *_pipe, + struct pipe_texture *_texture, + const struct pipe_sampler_view *templ) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_texture *tr_tex = trace_texture(_texture); + struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_texture *texture = tr_tex->texture; + struct trace_sampler_view *result = CALLOC_STRUCT(trace_sampler_view); + + trace_dump_call_begin("pipe_context", "create_sampler_view"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, texture); + trace_dump_arg(ptr, templ); + + result->sampler_view = pipe->create_sampler_view(pipe, texture, templ); + + result->base = *templ; + result->base.reference.count = 1; + result->base.texture = NULL; + pipe_texture_reference(&result->base.texture, _texture); + result->base.context = _pipe; + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + return &result->base; +} + + +static void +trace_sampler_view_destroy(struct pipe_context *_pipe, + struct pipe_sampler_view *_view) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_sampler_view *tr_view = trace_sampler_view(_view); + struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_sampler_view *view = tr_view->sampler_view; + + trace_dump_call_begin("pipe_context", "sampler_view_destroy"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, view); + + pipe->sampler_view_destroy(pipe, view); + + trace_dump_call_end(); + + pipe_texture_reference(&_view->texture, NULL); + FREE(_view); +} + + static INLINE void trace_context_set_fragment_sampler_views(struct pipe_context *_pipe, unsigned num, @@ -1313,6 +1370,8 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.set_viewport_state = trace_context_set_viewport_state; tr_ctx->base.set_fragment_sampler_views = trace_context_set_fragment_sampler_views; tr_ctx->base.set_vertex_sampler_views = trace_context_set_vertex_sampler_views; + tr_ctx->base.create_sampler_view = trace_create_sampler_view; + tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy; tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers; tr_ctx->base.set_vertex_elements = trace_context_set_vertex_elements; if (pipe->surface_copy) diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index a2ca3c21dbf..3a99dcdaece 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -60,8 +60,6 @@ struct trace_sampler_view struct pipe_sampler_view base; struct pipe_sampler_view *sampler_view; - - struct tr_list list; }; From 1f5285f99771243b636deb9ae0a17c54f818fac6 Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 10 Dec 2009 07:52:45 +0100 Subject: [PATCH 010/483] i915: Fix for sampler view changes. --- src/gallium/drivers/i915/i915_context.h | 6 +-- src/gallium/drivers/i915/i915_state.c | 54 ++++++++++++++----- src/gallium/drivers/i915/i915_state_derived.c | 4 +- src/gallium/drivers/i915/i915_state_emit.c | 3 +- src/gallium/drivers/i915/i915_state_sampler.c | 18 ++++--- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index da769e7b290..cd6dcd59a9f 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -239,14 +239,14 @@ struct i915_context struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct i915_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; unsigned dirty; unsigned num_samplers; - unsigned num_textures; + unsigned num_fragment_sampler_views; unsigned num_vertex_elements; unsigned num_vertex_buffers; @@ -276,7 +276,7 @@ struct i915_context #define I915_NEW_ALPHA_TEST 0x100 #define I915_NEW_DEPTH_STENCIL 0x200 #define I915_NEW_SAMPLER 0x400 -#define I915_NEW_TEXTURE 0x800 +#define I915_NEW_SAMPLER_VIEW 0x800 #define I915_NEW_CONSTANTS 0x1000 #define I915_NEW_VBO 0x2000 #define I915_NEW_VS 0x4000 diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 62169918e2b..b38d1b2404a 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -560,9 +560,9 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, } -static void i915_set_sampler_textures(struct pipe_context *pipe, - unsigned num, - struct pipe_texture **texture) +static void i915_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct i915_context *i915 = i915_context(pipe); uint i; @@ -570,27 +570,53 @@ static void i915_set_sampler_textures(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == i915->num_textures && - !memcmp(i915->texture, texture, num * sizeof(struct pipe_texture *))) + if (num == i915->num_fragment_sampler_views && + !memcmp(i915->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; /* Fixes wrong texture in texobj with VBUF */ draw_flush(i915->draw); for (i = 0; i < num; i++) - pipe_texture_reference((struct pipe_texture **) &i915->texture[i], - texture[i]); + pipe_sampler_view_reference(&i915->fragment_sampler_views[i], + views[i]); - for (i = num; i < i915->num_textures; i++) - pipe_texture_reference((struct pipe_texture **) &i915->texture[i], - NULL); + for (i = num; i < i915->num_fragment_sampler_views; i++) + pipe_sampler_view_reference(&i915->fragment_sampler_views[i], + NULL); - i915->num_textures = num; + i915->num_fragment_sampler_views = num; - i915->dirty |= I915_NEW_TEXTURE; + i915->dirty |= I915_NEW_SAMPLER_VIEW; } +static struct pipe_sampler_view * +i915_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct i915_context *i915 = i915_context(pipe); + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +i915_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + static void i915_set_framebuffer_state(struct pipe_context *pipe, const struct pipe_framebuffer_state *fb) @@ -791,7 +817,9 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.set_polygon_stipple = i915_set_polygon_stipple; i915->base.set_scissor_state = i915_set_scissor_state; - i915->base.set_fragment_sampler_textures = i915_set_sampler_textures; + i915->base.set_fragment_sampler_views = i915_set_fragment_sampler_views; + i915->base.create_sampler_view = i915_create_sampler_view; + i915->base.sampler_view_destroy = i915_sampler_view_destroy; i915->base.set_viewport_state = i915_set_viewport_state; i915->base.set_vertex_buffers = i915_set_vertex_buffers; i915->base.set_vertex_elements = i915_set_vertex_elements; diff --git a/src/gallium/drivers/i915/i915_state_derived.c b/src/gallium/drivers/i915/i915_state_derived.c index f5b0e9f011e..0eb1e3f91a4 100644 --- a/src/gallium/drivers/i915/i915_state_derived.c +++ b/src/gallium/drivers/i915/i915_state_derived.c @@ -157,10 +157,10 @@ void i915_update_derived( struct i915_context *i915 ) if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS | I915_NEW_VS)) calculate_vertex_layout( i915 ); - if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE)) + if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_SAMPLER_VIEW)) i915_update_samplers(i915); - if (i915->dirty & I915_NEW_TEXTURE) + if (i915->dirty & I915_NEW_SAMPLER_VIEW) i915_update_textures(i915); if (i915->dirty) diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index a3d4e3b04e5..202607a6563 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -289,7 +289,8 @@ i915_emit_hardware_state(struct i915_context *i915 ) OUT_BATCH(enabled); for (unit = 0; unit < I915_TEX_UNITS; unit++) { if (enabled & (1 << unit)) { - struct intel_buffer *buf = i915->texture[unit]->buffer; + struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture; + struct intel_buffer *buf = texture->buffer; uint offset = 0; assert(buf); diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index e5c6d87215b..483947ece7f 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -144,20 +144,22 @@ void i915_update_samplers( struct i915_context *i915 ) i915->current.sampler_enable_nr = 0; i915->current.sampler_enable_flags = 0x0; - for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers; + for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers; unit++) { /* determine unit enable/disable by looking for a bound texture */ /* could also examine the fragment program? */ - if (i915->texture[unit]) { + if (i915->fragment_sampler_views[unit]) { + struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture; + update_sampler( i915, unit, i915->sampler[unit], /* sampler state */ - i915->texture[unit], /* texture */ + texture, /* texture */ i915->current.sampler[unit] /* the result */ ); i915_update_texture( i915, unit, - i915->texture[unit], /* texture */ + texture, /* texture */ i915->sampler[unit], /* sampler state */ i915->current.texbuffer[unit] ); @@ -281,14 +283,16 @@ i915_update_textures(struct i915_context *i915) { uint unit; - for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers; + for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers; unit++) { /* determine unit enable/disable by looking for a bound texture */ /* could also examine the fragment program? */ - if (i915->texture[unit]) { + if (i915->fragment_sampler_views[unit]) { + struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture; + i915_update_texture( i915, unit, - i915->texture[unit], /* texture */ + texture, /* texture */ i915->sampler[unit], /* sampler state */ i915->current.texbuffer[unit] ); } From 875f6d20b1180a4cafc747bd295b24ae1799a964 Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 10 Dec 2009 08:05:45 +0100 Subject: [PATCH 011/483] i965: Fix after sampler view changes. --- src/gallium/drivers/i965/brw_context.h | 4 +- src/gallium/drivers/i965/brw_pipe_sampler.c | 53 ++++++++++++++----- src/gallium/drivers/i965/brw_wm.c | 4 +- .../drivers/i965/brw_wm_sampler_state.c | 8 +-- .../drivers/i965/brw_wm_surface_state.c | 6 +-- 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h index 12cfa7b049c..8816714a7aa 100644 --- a/src/gallium/drivers/i965/brw_context.h +++ b/src/gallium/drivers/i965/brw_context.h @@ -550,11 +550,11 @@ struct brw_context const struct brw_sampler *sampler[PIPE_MAX_SAMPLERS]; unsigned num_samplers; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned num_vertex_elements; - unsigned num_textures; + unsigned num_fragment_sampler_views; unsigned num_vertex_buffers; struct pipe_scissor_state scissor; diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c index c7c0e2ae95e..fe1d18ae773 100644 --- a/src/gallium/drivers/i965/brw_pipe_sampler.c +++ b/src/gallium/drivers/i965/brw_pipe_sampler.c @@ -183,26 +183,26 @@ static void brw_delete_sampler_state(struct pipe_context *pipe, FREE(cso); } -static void brw_set_sampler_textures(struct pipe_context *pipe, - unsigned num, - struct pipe_texture **texture) +static void brw_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct brw_context *brw = brw_context(pipe); int i; for (i = 0; i < num; i++) - pipe_texture_reference(&brw->curr.texture[i], texture[i]); + pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], views[i]); - for (i = num; i < brw->curr.num_textures; i++) - pipe_texture_reference(&brw->curr.texture[i], NULL); + for (i = num; i < brw->curr.num_fragment_sampler_views; i++) + pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], NULL); - brw->curr.num_textures = num; + brw->curr.num_fragment_sampler_views = num; brw->state.dirty.mesa |= PIPE_NEW_BOUND_TEXTURES; } -static void brw_set_vertex_sampler_textures(struct pipe_context *pipe, - unsigned num, - struct pipe_texture **texture) +static void brw_set_vertex_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { } @@ -212,17 +212,46 @@ static void brw_bind_vertex_sampler_state(struct pipe_context *pipe, } +static struct pipe_sampler_view * +brw_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct brw_context *brw = brw_context(pipe); + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +brw_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + + void brw_pipe_sampler_init( struct brw_context *brw ) { brw->base.create_sampler_state = brw_create_sampler_state; brw->base.delete_sampler_state = brw_delete_sampler_state; - brw->base.set_fragment_sampler_textures = brw_set_sampler_textures; + brw->base.set_fragment_sampler_views = brw_set_fragment_sampler_views; brw->base.bind_fragment_sampler_states = brw_bind_sampler_state; - brw->base.set_vertex_sampler_textures = brw_set_vertex_sampler_textures; + brw->base.set_vertex_sampler_views = brw_set_vertex_sampler_views; brw->base.bind_vertex_sampler_states = brw_bind_vertex_sampler_state; + brw->base.create_sampler_view = brw_create_sampler_view; + brw->base.sampler_view_destroy = brw_sampler_view_destroy; } void brw_pipe_sampler_cleanup( struct brw_context *brw ) { diff --git a/src/gallium/drivers/i965/brw_wm.c b/src/gallium/drivers/i965/brw_wm.c index 5164c90ed60..3724adc040e 100644 --- a/src/gallium/drivers/i965/brw_wm.c +++ b/src/gallium/drivers/i965/brw_wm.c @@ -251,8 +251,8 @@ static void brw_wm_populate_key( struct brw_context *brw, /* PIPE_NEW_BOUND_TEXTURES */ - for (i = 0; i < brw->curr.num_textures; i++) { - const struct brw_texture *tex = brw_texture(brw->curr.texture[i]); + for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) { + const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture); if (tex->base.format == PIPE_FORMAT_YCBCR) key->yuvtex_mask |= 1 << i; diff --git a/src/gallium/drivers/i965/brw_wm_sampler_state.c b/src/gallium/drivers/i965/brw_wm_sampler_state.c index a8bc31c9cef..a4bfa61ab30 100644 --- a/src/gallium/drivers/i965/brw_wm_sampler_state.c +++ b/src/gallium/drivers/i965/brw_wm_sampler_state.c @@ -78,11 +78,11 @@ brw_wm_sampler_populate_key(struct brw_context *brw, memset(key, 0, sizeof(*key)); - key->sampler_count = MIN2(brw->curr.num_textures, + key->sampler_count = MIN2(brw->curr.num_fragment_sampler_views, brw->curr.num_samplers); for (i = 0; i < key->sampler_count; i++) { - const struct brw_texture *tex = brw_texture(brw->curr.texture[i]); + const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture); const struct brw_sampler *sampler = brw->curr.sampler[i]; struct brw_sampler_state *entry = &key->sampler[i]; @@ -122,12 +122,12 @@ static enum pipe_error brw_wm_sampler_update_default_colors(struct brw_context *brw) { enum pipe_error ret; - int nr = MIN2(brw->curr.num_textures, + int nr = MIN2(brw->curr.num_fragment_sampler_views, brw->curr.num_samplers); int i; for (i = 0; i < nr; i++) { - const struct brw_texture *tex = brw_texture(brw->curr.texture[i]); + const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture); const struct brw_sampler *sampler = brw->curr.sampler[i]; const float *bc; diff --git a/src/gallium/drivers/i965/brw_wm_surface_state.c b/src/gallium/drivers/i965/brw_wm_surface_state.c index b01a7f194b7..2368ae3f808 100644 --- a/src/gallium/drivers/i965/brw_wm_surface_state.c +++ b/src/gallium/drivers/i965/brw_wm_surface_state.c @@ -242,9 +242,9 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw ) /* PIPE_NEW_TEXTURE */ - for (i = 0; i < brw->curr.num_textures; i++) { + for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) { ret = brw_update_texture_surface(brw, - brw_texture(brw->curr.texture[i]), + brw_texture(brw->curr.fragment_sampler_views[i]->texture), &brw->wm.surf_bo[BTI_TEXTURE(i)]); if (ret) return ret; @@ -261,7 +261,7 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw ) bo_reference(&brw->wm.surf_bo[BTI_FRAGMENT_CONSTANTS], NULL); /* XXX: no pipe_max_textures define?? */ - for (i = brw->curr.num_textures; i < PIPE_MAX_SAMPLERS; i++) + for (i = brw->curr.num_fragment_sampler_views; i < PIPE_MAX_SAMPLERS; i++) bo_reference(&brw->wm.surf_bo[BTI_TEXTURE(i)], NULL); if (brw->wm.nr_surfaces != nr_surfaces) { From 3710a6f6cc84f46b6e1fb6a6a9f9eb6e7047c4e0 Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 10 Dec 2009 08:46:19 +0100 Subject: [PATCH 012/483] r300: Fix after sampler view changes. --- src/gallium/drivers/r300/r300_blit.c | 6 +-- src/gallium/drivers/r300/r300_context.h | 6 +-- src/gallium/drivers/r300/r300_emit.c | 20 ++++----- src/gallium/drivers/r300/r300_state.c | 54 ++++++++++++++++++++----- 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index eb9b0beeb5a..c48684fe51f 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -108,9 +108,9 @@ static void r300_hw_copy(struct pipe_context* pipe, util_blitter_save_fragment_sampler_states( r300->blitter, r300->sampler_count, (void**)r300->sampler_states); - util_blitter_save_fragment_sampler_textures( - r300->blitter, r300->texture_count, - (struct pipe_texture**)r300->textures); + util_blitter_save_fragment_sampler_views( + r300->blitter, r300->fragment_sampler_view_count, + r300->fragment_sampler_views); /* Do a copy */ util_blitter_copy(r300->blitter, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 1eba8a8ed12..2edf65797a2 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -300,9 +300,9 @@ struct r300_context { int sampler_count; /* Scissor state. */ struct r300_atom scissor_state; - /* Texture states. */ - struct r300_texture* textures[8]; - int texture_count; + /* Sampler view states. */ + struct pipe_sampler_view* fragment_sampler_views[8]; + int fragment_sampler_view_count; /* Vertex shader. */ struct r300_vertex_shader* vs; /* Viewport state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 88fe166359b..4310ff1411d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -159,7 +159,7 @@ static const float * get_shader_constant( /* Factor for converting rectangle coords to * normalized coords. Should only show up on non-r500. */ case RC_STATE_R300_TEXRECT_FACTOR: - tex = &r300->textures[constant->u.State[1]]->tex; + tex = r300->fragment_sampler_views[constant->u.State[1]]->texture; vec[0] = 1.0 / tex->width0; vec[1] = 1.0 / tex->height0; break; @@ -967,11 +967,11 @@ void r300_emit_texture_count(struct r300_context* r300) int i; CS_LOCALS(r300); - /* Notice that texture_count and sampler_count are just sizes + /* Notice that fragment_sampler_view_count and sampler_count are just sizes * of the respective arrays. We still have to check for the individual * elements. */ - for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) { - if (r300->textures[i]) { + for (i = 0; i < MIN2(r300->sampler_count, r300->fragment_sampler_view_count); i++) { + if (r300->fragment_sampler_views[i]) { tx_enable |= 1 << i; } } @@ -1043,10 +1043,10 @@ validate: } } /* ...textures... */ - for (i = 0; i < r300->texture_count; i++) { - tex = r300->textures[i]; - if (!tex) + for (i = 0; i < r300->fragment_sampler_view_count; i++) { + if (!r300->fragment_sampler_views[i]) continue; + tex = (struct r300_texture *)r300->fragment_sampler_views[i]->texture; if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { r300->context.flush(&r300->context, 0, NULL); @@ -1145,13 +1145,13 @@ void r300_emit_dirty_state(struct r300_context* r300) (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { r300_emit_texture_count(r300); - for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) { + for (i = 0; i < MIN2(r300->sampler_count, r300->fragment_sampler_view_count); i++) { if (r300->dirty_state & ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) { - if (r300->textures[i]) { + if (r300->fragment_sampler_views[i]) { r300_emit_texture(r300, r300->sampler_states[i], - r300->textures[i], + (struct r300_texture *)r300->fragment_sampler_views[i]->texture, i); dirty_tex |= r300->dirty_state & (R300_NEW_TEXTURE << i); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 34bf81c1930..e5ec2701c81 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -932,9 +932,9 @@ static void r300_delete_sampler_state(struct pipe_context* pipe, void* state) FREE(state); } -static void r300_set_sampler_textures(struct pipe_context* pipe, - unsigned count, - struct pipe_texture** texture) +static void r300_set_fragment_sampler_views(struct pipe_context* pipe, + unsigned count, + struct pipe_sampler_view** views) { struct r300_context* r300 = r300_context(pipe); boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; @@ -946,13 +946,17 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } for (i = 0; i < count; i++) { - if (r300->textures[i] != (struct r300_texture*)texture[i]) { - pipe_texture_reference((struct pipe_texture**)&r300->textures[i], - texture[i]); + if (r300->fragment_sampler_views[i] != views[i]) { + struct r300_texture *texture; + + pipe_sampler_view_reference(&r300->fragment_sampler_views[i], + views[i]); r300->dirty_state |= (R300_NEW_TEXTURE << i); + texture = (struct r300_texture *)views[i]->texture; + /* R300-specific - set the texrect factor in a fragment shader */ - if (!is_r500 && r300->textures[i]->is_npot) { + if (!is_r500 && texture->is_npot) { /* XXX It would be nice to re-emit just 1 constant, * XXX not all of them */ r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; @@ -961,14 +965,40 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } for (i = count; i < 8; i++) { - if (r300->textures[i]) { - pipe_texture_reference((struct pipe_texture**)&r300->textures[i], + if (r300->fragment_sampler_views[i]) { + pipe_sampler_view_reference(&r300->fragment_sampler_views[i], NULL); r300->dirty_state |= (R300_NEW_TEXTURE << i); } } - r300->texture_count = count; + r300->fragment_sampler_view_count = count; +} + +static struct pipe_sampler_view * +r300_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct r300_context *r300 = r300_context(pipe); + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +r300_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); } static void r300_set_scissor_state(struct pipe_context* pipe, @@ -1234,7 +1264,9 @@ void r300_init_state_functions(struct r300_context* r300) r300->context.bind_vertex_sampler_states = r300_lacks_vertex_textures; r300->context.delete_sampler_state = r300_delete_sampler_state; - r300->context.set_fragment_sampler_textures = r300_set_sampler_textures; + r300->context.set_fragment_sampler_views = r300_set_fragment_sampler_views; + r300->context.create_sampler_view = r300_create_sampler_view; + r300->context.sampler_view_destroy = r300_sampler_view_destroy; r300->context.set_scissor_state = r300_set_scissor_state; From 1fb440beb9cccbe6f4bbd309792a89f6e1b4ee3f Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 10 Dec 2009 09:23:15 +0100 Subject: [PATCH 013/483] llvmpipe: Fix after sampler view changes. --- src/gallium/drivers/llvmpipe/lp_context.c | 10 +-- src/gallium/drivers/llvmpipe/lp_context.h | 8 +-- src/gallium/drivers/llvmpipe/lp_setup.c | 12 ++-- src/gallium/drivers/llvmpipe/lp_setup.h | 5 +- src/gallium/drivers/llvmpipe/lp_state.h | 23 ++++--- .../drivers/llvmpipe/lp_state_derived.c | 12 ++-- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 +- .../drivers/llvmpipe/lp_state_sampler.c | 63 +++++++++++++------ 8 files changed, 88 insertions(+), 47 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 9120226de0c..0e385f843d1 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -68,11 +68,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&llvmpipe->texture[i], NULL); + pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - pipe_texture_reference(&llvmpipe->vertex_textures[i], NULL); + pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], NULL); } for (i = 0; i < Elements(llvmpipe->constants); i++) { @@ -152,8 +152,10 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state; llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple; llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state; - llvmpipe->pipe.set_fragment_sampler_textures = llvmpipe_set_sampler_textures; - llvmpipe->pipe.set_vertex_sampler_textures = llvmpipe_set_vertex_sampler_textures; + llvmpipe->pipe.set_fragment_sampler_views = llvmpipe_set_fragment_sampler_views; + llvmpipe->pipe.set_vertex_sampler_views = llvmpipe_set_vertex_sampler_views; + llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view; + llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy; llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state; llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers; diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 955c7eb8e0e..1b98e3033db 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -67,16 +67,16 @@ struct llvmpipe_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; - struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned num_samplers; - unsigned num_textures; + unsigned num_fragment_sampler_views; unsigned num_vertex_samplers; - unsigned num_vertex_textures; + unsigned num_vertex_sampler_views; unsigned num_vertex_elements; unsigned num_vertex_buffers; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index cb873667a20..7d52765970c 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -453,11 +453,12 @@ lp_setup_set_vertex_info( struct setup_context *setup, /** - * Called during state validation when LP_NEW_TEXTURE is set. + * Called during state validation when LP_NEW_SAMPLER_VIEW is set. */ void -lp_setup_set_sampler_textures( struct setup_context *setup, - unsigned num, struct pipe_texture **texture) +lp_setup_set_fragment_sampler_views(struct setup_context *setup, + unsigned num, + struct pipe_sampler_view **views) { unsigned i; @@ -466,9 +467,10 @@ lp_setup_set_sampler_textures( struct setup_context *setup, assert(num <= PIPE_MAX_SAMPLERS); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - struct pipe_texture *tex = i < num ? texture[i] : NULL; + struct pipe_sampler_view *view = i < num ? views[i] : NULL; - if(tex) { + if(view) { + struct pipe_texture *tex = view->texture; struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex); struct lp_jit_texture *jit_tex; jit_tex = &setup->fs.current.jit_context.textures[i]; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 0e155a7dc31..5a5d3531f95 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -120,8 +120,9 @@ lp_setup_set_scissor( struct setup_context *setup, const struct pipe_scissor_state *scissor ); void -lp_setup_set_sampler_textures( struct setup_context *setup, - unsigned num, struct pipe_texture **texture); +lp_setup_set_fragment_sampler_views(struct setup_context *setup, + unsigned num, + struct pipe_sampler_view **views); unsigned lp_setup_is_texture_referenced( const struct setup_context *setup, diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 9beba32271f..8a2a08b0759 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -50,7 +50,7 @@ #define LP_NEW_DEPTH_STENCIL_ALPHA 0x100 #define LP_NEW_CONSTANTS 0x200 #define LP_NEW_SAMPLER 0x400 -#define LP_NEW_TEXTURE 0x800 +#define LP_NEW_SAMPLER_VIEW 0x800 #define LP_NEW_VERTEX 0x1000 #define LP_NEW_VS 0x2000 #define LP_NEW_QUERY 0x4000 @@ -182,14 +182,23 @@ void llvmpipe_set_polygon_stipple( struct pipe_context *, void llvmpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); -void llvmpipe_set_sampler_textures( struct pipe_context *, - unsigned num, - struct pipe_texture ** ); +void llvmpipe_set_fragment_sampler_views(struct pipe_context *, + unsigned num, + struct pipe_sampler_view **); void -llvmpipe_set_vertex_sampler_textures(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); +llvmpipe_set_vertex_sampler_views(struct pipe_context *, + unsigned num, + struct pipe_sampler_view **); + +struct pipe_sampler_view * +llvmpipe_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ); + +void +llvmpipe_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view); void llvmpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index bdd906e1a73..9c91ce9238f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -150,7 +150,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) */ if (llvmpipe->tex_timestamp != lp_screen->timestamp) { llvmpipe->tex_timestamp = lp_screen->timestamp; - llvmpipe->dirty |= LP_NEW_TEXTURE; + llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; } if (llvmpipe->dirty & (LP_NEW_RASTERIZER | @@ -164,7 +164,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) LP_NEW_DEPTH_STENCIL_ALPHA | LP_NEW_RASTERIZER | LP_NEW_SAMPLER | - LP_NEW_TEXTURE)) + LP_NEW_SAMPLER_VIEW)) llvmpipe_update_fs( llvmpipe ); if (llvmpipe->dirty & LP_NEW_BLEND_COLOR) @@ -182,10 +182,10 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) lp_setup_set_fs_constants(llvmpipe->setup, llvmpipe->constants[PIPE_SHADER_FRAGMENT]); - if (llvmpipe->dirty & LP_NEW_TEXTURE) - lp_setup_set_sampler_textures(llvmpipe->setup, - llvmpipe->num_textures, - llvmpipe->texture); + if (llvmpipe->dirty & LP_NEW_SAMPLER_VIEW) + lp_setup_set_fragment_sampler_views(llvmpipe->setup, + llvmpipe->num_fragment_sampler_views, + llvmpipe->fragment_sampler_views); llvmpipe->dirty = 0; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 90dae3f9101..2e018df05c0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1084,7 +1084,7 @@ make_variant_key(struct llvmpipe_context *lp, for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) - lp_sampler_static_state(&key->sampler[i], lp->texture[i], lp->sampler[i]); + lp_sampler_static_state(&key->sampler[i], lp->fragment_sampler_views[i]->texture, lp->sampler[i]); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index b30a0757768..2df86a08148 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -105,8 +105,9 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe, void -llvmpipe_set_sampler_textures(struct pipe_context *pipe, - unsigned num, struct pipe_texture **texture) +llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; @@ -114,51 +115,77 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe, assert(num <= PIPE_MAX_SAMPLERS); /* Check for no-op */ - if (num == llvmpipe->num_textures && - !memcmp(llvmpipe->texture, texture, num * sizeof(struct pipe_texture *))) + if (num == llvmpipe->num_fragment_sampler_views && + !memcmp(llvmpipe->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) return; draw_flush(llvmpipe->draw); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - struct pipe_texture *tex = i < num ? texture[i] : NULL; + struct pipe_sampler_view *view = i < num ? views[i] : NULL; - pipe_texture_reference(&llvmpipe->texture[i], tex); + pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], view); } - llvmpipe->num_textures = num; + llvmpipe->num_fragment_sampler_views = num; - llvmpipe->dirty |= LP_NEW_TEXTURE; + llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; } void -llvmpipe_set_vertex_sampler_textures(struct pipe_context *pipe, - unsigned num_textures, - struct pipe_texture **textures) +llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); uint i; - assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS); + assert(num <= PIPE_MAX_VERTEX_SAMPLERS); /* Check for no-op */ - if (num_textures == llvmpipe->num_vertex_textures && - !memcmp(llvmpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) { + if (num == llvmpipe->num_vertex_sampler_views && + !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) { return; } draw_flush(llvmpipe->draw); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - struct pipe_texture *tex = i < num_textures ? textures[i] : NULL; + struct pipe_sampler_view *view = i < num ? views[i] : NULL; - pipe_texture_reference(&llvmpipe->vertex_textures[i], tex); + pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view); } - llvmpipe->num_vertex_textures = num_textures; + llvmpipe->num_vertex_sampler_views = num; - llvmpipe->dirty |= LP_NEW_TEXTURE; + llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW; +} + + +struct pipe_sampler_view * +llvmpipe_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +void +llvmpipe_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); } From 3a7314a78d2d239aef4032445c41e530ec13d3e0 Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 10 Dec 2009 09:29:15 +0100 Subject: [PATCH 014/483] gallium: Silence compiler warnings. --- src/gallium/drivers/i915/i915_state.c | 1 - src/gallium/drivers/i965/brw_pipe_sampler.c | 1 - src/gallium/drivers/softpipe/sp_state_sampler.c | 3 --- src/gallium/drivers/svga/svga_pipe_sampler.c | 3 --- 4 files changed, 8 deletions(-) diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index b38d1b2404a..46703dce350 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -596,7 +596,6 @@ i915_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct i915_context *i915 = i915_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); *view = *templ; diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c index fe1d18ae773..fbc3a07d61e 100644 --- a/src/gallium/drivers/i965/brw_pipe_sampler.c +++ b/src/gallium/drivers/i965/brw_pipe_sampler.c @@ -217,7 +217,6 @@ brw_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct brw_context *brw = brw_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); *view = *templ; diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index 5a92e2223ef..8922941994a 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -126,7 +126,6 @@ softpipe_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct softpipe_context *softpipe = softpipe_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); *view = *templ; @@ -143,8 +142,6 @@ void softpipe_sampler_view_destroy(struct pipe_context *pipe, struct pipe_sampler_view *view) { - struct softpipe_context *softpipe = softpipe_context(pipe); - pipe_texture_reference(&view->texture, NULL); FREE(view); } diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 26878177308..50fe962b28d 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -181,7 +181,6 @@ svga_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct svga_context *softpipe = svga_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); *view = *templ; @@ -198,8 +197,6 @@ static void svga_sampler_view_destroy(struct pipe_context *pipe, struct pipe_sampler_view *view) { - struct svga_context *svga = svga_context(pipe); - pipe_texture_reference(&view->texture, NULL); FREE(view); } From 92a8c42baa64fbf8e1a986a0b820fe1744c1b3b3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:19:54 +0100 Subject: [PATCH 015/483] python: Fix after sampler view changes. --- src/gallium/state_trackers/python/gallium.i | 1 + src/gallium/state_trackers/python/p_context.i | 33 ++++++++++++++----- src/gallium/state_trackers/python/st_device.c | 32 +++++++++++++----- src/gallium/state_trackers/python/st_device.h | 4 +-- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index ffb084e358b..632d71ccbee 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -49,6 +49,7 @@ #include "util/u_format.h" #include "util/u_dump.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "cso_cache/cso_context.h" #include "tgsi/tgsi_text.h" #include "tgsi/tgsi_dump.h" diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 3f36ccb6217..85c9598d069 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -169,22 +169,39 @@ struct st_context { void set_fragment_sampler_texture(unsigned index, struct pipe_texture *texture) { + struct pipe_sampler_view templ; + if(!texture) texture = $self->default_texture; - pipe_texture_reference(&$self->fragment_sampler_textures[index], texture); - $self->pipe->set_fragment_sampler_textures($self->pipe, - PIPE_MAX_SAMPLERS, - $self->fragment_sampler_textures); + pipe_sampler_view_reference(&$self->fragment_sampler_views[index], NULL); + u_sampler_view_default_template(&templ, + texture, + texture->format); + $self->fragment_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe, + texture, + &templ); + $self->pipe->set_fragment_sampler_views($self->pipe, + PIPE_MAX_SAMPLERS, + $self->fragment_sampler_views); } void set_vertex_sampler_texture(unsigned index, struct pipe_texture *texture) { + struct pipe_sampler_view templ; + if(!texture) texture = $self->default_texture; - pipe_texture_reference(&$self->vertex_sampler_textures[index], texture); - $self->pipe->set_vertex_sampler_textures($self->pipe, - PIPE_MAX_VERTEX_SAMPLERS, - $self->vertex_sampler_textures); + pipe_sampler_view_reference(&$self->vertex_sampler_views[index], NULL); + u_sampler_view_default_template(&templ, + texture, + texture->format); + $self->vertex_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe, + texture, + &templ); + + $self->pipe->set_vertex_sampler_views($self->pipe, + PIPE_MAX_VERTEX_SAMPLERS, + $self->vertex_sampler_views); } void set_vertex_buffer(unsigned index, diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index a3798a55212..d5a14fd795d 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -33,6 +33,7 @@ #include "cso_cache/cso_context.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "util/u_simple_shaders.h" #include "trace/tr_screen.h" #include "trace/tr_context.h" @@ -134,9 +135,9 @@ st_context_destroy(struct st_context *st_ctx) st_ctx->pipe->destroy(st_ctx->pipe); for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) - pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], NULL); + pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], NULL); for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i) - pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL); + pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], NULL); pipe_texture_reference(&st_ctx->default_texture, NULL); FREE(st_ctx); @@ -240,6 +241,8 @@ st_context_create(struct st_device *st_dev) struct pipe_screen *screen = st_dev->screen; struct pipe_texture templat; struct pipe_transfer *transfer; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; unsigned i; memset( &templat, 0, sizeof( templat ) ); @@ -269,14 +272,27 @@ st_context_create(struct st_device *st_dev) screen->tex_transfer_destroy(transfer); } } - + + u_sampler_view_default_template(&view_templ, + st_ctx->default_texture, + st_ctx->default_texture->format); + view = st_ctx->pipe->create_sampler_view(st_ctx->pipe, + st_ctx->default_texture, + &view_templ); + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) - pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture); + pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], view); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) - pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], st_ctx->default_texture); - - cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->fragment_sampler_textures); - cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures); + pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], view); + + st_ctx->pipe->set_fragment_sampler_views(st_ctx->pipe, + PIPE_MAX_SAMPLERS, + st_ctx->fragment_sampler_views); + st_ctx->pipe->set_vertex_sampler_views(st_ctx->pipe, + PIPE_MAX_VERTEX_SAMPLERS, + st_ctx->vertex_sampler_views); + + pipe_sampler_view_reference(&view, NULL); } /* vertex shader */ diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h index de9e0215d8e..dee9a8ca7b5 100644 --- a/src/gallium/state_trackers/python/st_device.h +++ b/src/gallium/state_trackers/python/st_device.h @@ -59,8 +59,8 @@ struct st_context { void *gs; struct pipe_texture *default_texture; - struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS]; - struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; unsigned num_vertex_buffers; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; From 3e0181f47334534be081caa912a20d278fd07149 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:21:50 +0100 Subject: [PATCH 016/483] python: Fix typo. --- src/gallium/state_trackers/python/p_state.i | 2 +- .../tests/regress/fragment-shader/frag-abs.png | Bin 0 -> 8750 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i index 5afe4d49082..eda77b56f8e 100644 --- a/src/gallium/state_trackers/python/p_state.i +++ b/src/gallium/state_trackers/python/p_state.i @@ -69,7 +69,7 @@ pipe_blend_state(const char *STRING, unsigned LENGTH) { struct pipe_blend_state *state; - state = CALLOC_STRUCT(pipe_framebuffer_state); + state = CALLOC_STRUCT(pipe_blend_state); if (state) { LENGTH = MIN2(sizeof *state, LENGTH); memcpy(state, STRING, LENGTH); diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png new file mode 100644 index 0000000000000000000000000000000000000000..c947a7b8813dda47928649392cdc69672f7aed54 GIT binary patch literal 8750 zcmeI2`(G1h+J`3z6EKDV7Bxfxm99l7b~uU_Arv=;%A#0HMQn}AIw_!FWtFvBlF$XU zsKi=JT`eeRt%8jerL|fUvD8z|K|}!$18PMm3Myi0W%hn12{ZdIyzknNKREaEz3$U< znn^d#NuKF0l8G=3b5B&xn2TXNIr{4+geSk0?mLKKCK^MG9WGL$#c@MaSdQKGMO29{T64!j{lV z)yI6+$UjlI$n3YIc0iG?tyGO;4LTmSp~?T`$mcyK`Rke9C34opKcVwCKfIIOz4X$Ks?v50KTZNrE5A)$qZ|-D73j`dIOkiU~eOZF;=PAS`PUJhaYs`n|-q>Upad9&K zV@7l}SkS#Og(%^QG*irz->T`0Y7vdaYyV5cyTFL<%@TBfkwPSKLZ)DD z%}IuJ9vh@;jGv4aw!BrTl5&9ub)(IfuT&pnRE=l{a#kWp&{>C6Pwop_R#mFXkSnL{ zpq4aWww?UUu5#g6g7__rucM@}* zwaHXTzVhH!5L3ZSt|bT?V0?Z0im>Gh_~P0&84JmuU8^G*U)#C9M7$SF3450cx_?h0 z&T>llt?3jw)Ai)YD9f|0x;^fkAVfwZA4U=z}LXRz9=j_L`27AG)p&&NBRv<1L=dRe`U^ zZlHST(;=7P30z-$jh~S}6eo3M9{6sRw>XBQngG5YZdidoycKEDMv98KDjj7zx;x?U z+mVeoUKa_ub(#RaI+dWh5o*y!iHZ==+2oVdnWNna$0H->-JCA!aBgR4yWp#+^i>&k z{JI>-YYbjEmZRE5-8fp4@Z-qH#+z{>^>B_Q22?A(LA3(%8jBY)bHlL#Ra2La{!+ic zFJj@Jp`rsG9MxD*<;=^%SKNxQXs3#VlQ=eUZfA4D;%k|*6@xx_BX?TA3aaJva_|*5 z2#a=_NI0IO^3H8<9$4JEKz4XghTrAx84*NJP2|pF{A=GpUcPuCw_nlG&$7D>Ie&3q zLvQBWIJlQV6tT08f9)`&<%bt?3onE}MFHm2tz}JCW$*pKaa>}c^m&ud%>~*+@3`lw zw(8=!3!*5&oVw+^RIBpIqd=pCFI8a!}f9J5YL++0kB8#J6xw%yHW3N`3?CU{4 zoD)Po#CL?3g->1-Wzoiogq*Ug43C;^UbjWE2ZR0(SdtnP25kfV`DC9Cr4$!%U~>%j zo7=5T9^NHI_2)QCXFf>2G3n^n-ixs4Lq$T4L~iJ6K4VSwkV)OQ>W8sjlpr~5DxzOo zNLch?B4$=PQXvd?n*X#mNhE}9asX#CM1!Qpw23yCPqFC3MID@Kjx%&O->{}ic!VrA zfHUg?K~innLYsGoTl5j44o+a6hI`GwS)1JTs)$_*PK~7?IkZPdo4<^-=p#iPoUIfy zJZQdTO?BU>ia4p@tRpv&9Nbexn|Fm;^iiS?l%+iv$tpuz^HXb+_zP9UjiNaA`G+9+ zde0_$c6pRVKSiWwbCE1HJZx^Xri%Ziiuki=3Mpv=-Io&Ec$4Xn$1P>mf_dt zyVj=RpBdHBl0~c}9VB11>FC*CLSLqe)NC%21Vd-@S!?R>&rIrk$!u0K3ncs7is;$9 zpfA%zYGiTb5^iWuqt#jeQm7&p7W=c$UkAy)woP<@zkA-@E&L#MO-TX_zok7=2mh-< z6|t^(G%E=PNmbhxy8oFt@8zxhAa?RgUNYQG>sNPuoD6*_X1gyL1CmO;j$X6IJud?! z?0T073>|6r)rUU541FnPcPhznknGhL(Q8(V^Qu6C{5x`4X`s^nP-kUmjOy<^*0az5 z36eefO>|uyzpM9~2e(Ep**+aoz+e?u{%CCn?1J zv?uDWrKK8czVrn9JPjn}DdOdL)D-u;B~moOVpd>ErCJAiJU*JIbdN6kStM@AnIZO~B=K|W*t zWS_6Ki>esW)U|8QsW|OkV(G8`u(of?S(ExV_Z6%t(=MuJMAO%9?NPC7S2EY~qH?5mGODvB$?Wqt?Xn#Wr#XIEnA-Pe&D-|{qj0Lh?Zeq-6^ zBD-udBO55uCg)XZv|4tB5bFG>RZx>ROzLV6j=N~73(TmbYp9gbtD5Am{OHA5*W=Xd zgy%8Z^}27RiZZH$b5$&HoGJtU8{3h3Inb}P$zKoglwjuG4(BFnbeogOGTt zKZ+{meLv_AuN-o0l3-@KmUC`NJT=D#Rr$vBn98z;HF46xIPxL(RfC>AC?uGAebiQ7 z`l&d$-^XLe#ABD^635Fu+}9+SJm&?x0=ataUxnuQt|j`{ukEf8*TTM>~?M&mKT?PM*ilDSkM<~z6;B(9jTnj>W6u@4!~_)g89A7bnm>4 z_vSv%*=plGjZJTmC!a!kg{GF#zryNyr7cKr^YZwXi9h>yP1RLByNqnor*Y{fdE$Dc z7ivy2dUk2rq@|318_&bW=$G8Xs;=uf_47)Kvp)jo%n3{#Og93MW5&s zm&9vpL)W=DSs~ch;{9>0M)}2owY4LoU9iofCP=2wkqk1cucBhk<#||}{KbFXHt4mX z#`5DkhF-j3jN7u<*0b`hYY}1tZ}af$fcOWCa8uu85SrrrE)U^gPRk`@$NgFU7Zs>w zXwCt`Wm#P78M%4jpMY@VO&2u-;%ye;(!oTrO<>1%_ zOdRc|`jdUG0(wpNGF9FxUo|OC8ya)o<&*O6#nOoHHH#sTaViZH$c3SLoOdbQhi1rG z-ApADNApEvM|+IrvUD5Ez-ELe1cE)I6tV0Dsc6;9vT?&sONQU$XY*o(-sBwbI!WZ(_mnzw!C1Szl zzDuM}?U1(svi85Lnuryi>YK7RT^qm@#KU))s`e-qacA+;^$;13TkwV5~+Ab}4Mc5}+b` z7a&G8MIX5%E=k=X=q`zO9snWOFioF1nGiQK&8-qiT|!PkbDb9~WZwg8->b$5i{-r@ z`fQ?5G5iUHQQ_QuLa<)VW^;0=_;)+PO|08-LmgbYdMMRi&7NBWW11L53Ppc?MO?CM zKZ?S60EA#GHNTiI6XJg}h?j?pb)yjC_z+^Hrp-1mW(R{vr06e>ic2OoAcXU{4Z)6R zYRs2I#Xr~)!yt-QKs*~l9MQBj4U9=;5NQ2tu5nl?@9wm$fUQ6dRd5_EYrc ze~U|Gosb95xjk8N%0$*l73+Y|R%48}j6esV^Ev}oCDfsl(NCu6npSa1=0T))*5L?F zwUKM2id8&*$+=W&oLcKHjM=uzv0;E!-Q_XT;~)b#Owqf45SIj9Kmg}5)#H?v>_>o! z(i9ZHV_8yu)vwNJ3uYj^?&pmr#BGg+?td6g1Wl6EhIcsMMpxogFX@2@D~JgTw1pKv zMM`^>mqt2j0A?V>`B_j5IdT*2>fs|DdDpeYC(l`g6r4IwZbgK}M0Gk4_C=QUDlhsv z2w;Yp6df~;iJ=0c{iiQeZT}QD3XAjh8H!U6$k~X{tC|ltp!nfgfs}sxEC&J1K!`}X z#>6m33$L1C#08}XWZ|5XUO3fEni1iFYW^`GT+9q?({D?65WozCn556`1oYw^PP~~2 zbx=F&@C>JZCtpK^-&ON#f$&LYV7tCF%RvA$5Wxq$SU+{NV?KZx2q(%8+6jF6_Q}7iyuJK@;Jl^nz^SX`BZgoq%>=@ZE4gRtBd0hB zUgN;#N%G*#R2EE zjl!vJauFiDFjg>iuqlo8lRkG4zzl>R%c|@IExqW+Fye78iorP_M&Z;=@-{;-RWNn1 zD$msarOrVBGt6cc0ZRtfg~5eBy`EIvZAW!*_Tn*4y&&U&U@~gst)j6mA$#>3iW3f_ zr3-f-Fe5_fEqe@wblgW_#0Lh5Ac}xiAKn1mD=NLx}U`L2{y0Yf9*YH9553})H#M24ruz(ytz^Nys zSX}wNs)v7qSrVl8()K-N!45UpLG8IzAuOV6FRLq67QS*s#jKIaNXL|)i&GcLBtiGb zDRP&J_ea68yE~<1O!%Px0(_j^1&m-2RY~%rsZ^l!DHZopxZuv|(}HgCUWc17oa!PI z8oq`XK?U04&iMTFaqpaiha67A_FZ5QuYRHFtTCn#8ODN9sltZ1)38U)KnRq|2%Ksq zvzbVQ6`63+tj$)0_U0dGbY9+I07HrSLX(LocZ~&6tA!1V;(+4f2;?bF{XvdpAiRn< z5k##BeUKm6_^!hX3}7G=!gxP1p_mFJ$-)Nz+W^UTKpJuCXL2C}!R09klA#FwJ>PI` zu>%4F7|4h)UNaMksbKO7VMER$fJ8eWwK#R3jA0;um8T+zN)dW5pSbpS2LuK%kgzb` zc?8Ke7Wlm$fWQC-A`0VK5#%>xLF`Au zhS~lAaem^>!>N9f&p;C7^AKb{KzdcxtquqbU?4#md>s>ssel(RZ18vlkU+= zmOaZSt~&4VFo1!`GWaEEu7y&kHv|gq{QDZrHS`tTx%+tI)NOJJ0udOt4}m6DmVK0O zX#A%m8W>;)E#t$N6z`Jgo<&K!w7pj^YF7&#+d~h(hYsJUU414{D(@-RE;gnIROYLC zR0sZWFnaia2LV Date: Thu, 25 Feb 2010 14:27:34 +0100 Subject: [PATCH 017/483] docs: Update after sampler view changes. --- src/gallium/docs/source/context.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9080addba44..827db8398ce 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -39,8 +39,10 @@ buffers, surfaces) are bound to the driver. are mostly restricted to the first one right now). * ``set_framebuffer_state`` -* ``set_fragment_sampler_textures`` -* ``set_vertex_sampler_textures`` +* ``set_fragment_sampler_views`` +* ``set_vertex_sampler_views`` +* ``create_sampler_view`` +* ``sampler_view_destroy`` * ``set_vertex_buffers`` From e3c2a053cf4ac761d672ec64cb18c099b4ac3bc2 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:40:56 +0100 Subject: [PATCH 018/483] nv30: Fix after sampler view changes. Did not test build. --- src/gallium/drivers/nv30/nv30_context.h | 1 + src/gallium/drivers/nv30/nv30_state.c | 38 ++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index ca3d6aca7fa..04813526f40 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -138,6 +138,7 @@ struct nv30_context { unsigned idxbuf_format; struct nv30_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS]; struct nv30_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; unsigned nr_samplers; unsigned nr_textures; unsigned dirty_samplers; diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index d911c807074..1d484ecb77f 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -272,19 +272,22 @@ nv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso) } static void -nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr, - struct pipe_texture **miptree) +nv30_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned nr, + struct pipe_sampler_view **views) { struct nv30_context *nv30 = nv30_context(pipe); unsigned unit; for (unit = 0; unit < nr; unit++) { + pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], views[unit]); pipe_texture_reference((struct pipe_texture **) - &nv30->tex_miptree[unit], miptree[unit]); + &nv30->tex_miptree[unit], views[unit]->texture); nv30->dirty_samplers |= (1 << unit); } for (unit = nr; unit < nv30->nr_textures; unit++) { + pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], NULL); pipe_texture_reference((struct pipe_texture **) &nv30->tex_miptree[unit], NULL); nv30->dirty_samplers |= (1 << unit); @@ -294,6 +297,31 @@ nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr, nv30->dirty |= NV30_NEW_SAMPLER; } +static struct pipe_sampler_view * +nv30_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +nv30_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + static void * nv30_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) @@ -692,7 +720,9 @@ nv30_init_state_functions(struct nv30_context *nv30) nv30->pipe.create_sampler_state = nv30_sampler_state_create; nv30->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind; nv30->pipe.delete_sampler_state = nv30_sampler_state_delete; - nv30->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture; + nv30->pipe.set_fragment_sampler_views = nv30_set_fragment_sampler_view; + nv30->pipe.create_sampler_view = nv30_create_sampler_view; + nv30->pipe.sampler_view_destroy = nv30_sampler_view_destroy; nv30->pipe.create_rasterizer_state = nv30_rasterizer_state_create; nv30->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind; From 512d3e691e43b663932fcf22a8c333c79033cb8b Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:46:31 +0100 Subject: [PATCH 019/483] nv40: Fix after sampler view changes. Did not test build. --- src/gallium/drivers/nv40/nv40_context.h | 1 + src/gallium/drivers/nv40/nv40_state.c | 38 ++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 4861924dac7..3d41042a771 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -153,6 +153,7 @@ struct nv40_context { unsigned idxbuf_format; struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS]; struct nv40_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; unsigned nr_samplers; unsigned nr_textures; unsigned dirty_samplers; diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index 4f28675e64c..dbb52bf5bc9 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -282,19 +282,22 @@ nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso) } static void -nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr, - struct pipe_texture **miptree) +nv40_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned nr, + struct pipe_sampler_view **views) { struct nv40_context *nv40 = nv40_context(pipe); unsigned unit; for (unit = 0; unit < nr; unit++) { + pipe_sampler_view_reference(&nv40->fragment_sampler_views[unit], views[unit]); pipe_texture_reference((struct pipe_texture **) - &nv40->tex_miptree[unit], miptree[unit]); + &nv40->tex_miptree[unit], views[unit]->texture); nv40->dirty_samplers |= (1 << unit); } for (unit = nr; unit < nv40->nr_textures; unit++) { + pipe_sampler_view_reference(&nv40->fragment_sampler_views[unit], NULL); pipe_texture_reference((struct pipe_texture **) &nv40->tex_miptree[unit], NULL); nv40->dirty_samplers |= (1 << unit); @@ -304,6 +307,31 @@ nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr, nv40->dirty |= NV40_NEW_SAMPLER; } +static struct pipe_sampler_view * +nv40_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +nv40_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + static void * nv40_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) @@ -707,7 +735,9 @@ nv40_init_state_functions(struct nv40_context *nv40) nv40->pipe.create_sampler_state = nv40_sampler_state_create; nv40->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind; nv40->pipe.delete_sampler_state = nv40_sampler_state_delete; - nv40->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture; + nv40->pipe.set_fragment_sampler_views = nv40_set_fragment_sampler_views; + nv40->pipe.create_sampler_view = nv40_create_sampler_view; + nv40->pipe.sampler_view_destroy = nv40_sampler_view_destroy; nv40->pipe.create_rasterizer_state = nv40_rasterizer_state_create; nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind; From 6a8961a2479288df4ec736f94b8bf990c1fe0d72 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:56:19 +0100 Subject: [PATCH 020/483] nv50: Fix after sampler view changes. Did not test build. --- src/gallium/drivers/nv50/nv50_context.h | 1 + src/gallium/drivers/nv50/nv50_state.c | 61 +++++++++++++++++++------ 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index b4de3e2ba57..7b879851b0e 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -173,6 +173,7 @@ struct nv50_context { struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; unsigned sampler_nr[PIPE_SHADER_TYPES]; struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; unsigned miptree_nr[PIPE_SHADER_TYPES]; uint16_t vbo_fifo; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 7d304907b65..8e5f1662eac 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -269,33 +269,66 @@ nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso) } static INLINE void -nv50_set_sampler_texture(struct pipe_context *pipe, unsigned type, - unsigned nr, struct pipe_texture **pt) +nv50_set_sampler_views(struct pipe_context *pipe, + unsigned type, + unsigned nr, + struct pipe_sampler_view **views) { struct nv50_context *nv50 = nv50_context(pipe); unsigned i; - for (i = 0; i < nr; i++) - pipe_texture_reference((void *)&nv50->miptree[type][i], pt[i]); - for (i = nr; i < nv50->miptree_nr[type]; i++) + for (i = 0; i < nr; i++) { + pipe_sampler_view_reference(&nv50->sampler_views[type][i], views[i]); + pipe_texture_reference((void *)&nv50->miptree[type][i], views[i]->texture); + } + for (i = nr; i < nv50->miptree_nr[type]; i++) { + pipe_sampler_view_reference(&nv50->sampler_views[type][i], NULL); pipe_texture_reference((void *)&nv50->miptree[type][i], NULL); + } nv50->miptree_nr[type] = nr; nv50->dirty |= NV50_NEW_TEXTURE; } static void -nv50_set_vp_sampler_textures(struct pipe_context *pipe, - unsigned nr, struct pipe_texture **pt) +nv50_set_vp_sampler_views(struct pipe_context *pipe, + unsigned nr, + struct pipe_sampler_view **views) { - nv50_set_sampler_texture(pipe, PIPE_SHADER_VERTEX, nr, pt); + nv50_set_sampler_views(pipe, PIPE_SHADER_VERTEX, nr, views); } static void -nv50_set_fp_sampler_textures(struct pipe_context *pipe, - unsigned nr, struct pipe_texture **pt) +nv50_set_fp_sampler_views(struct pipe_context *pipe, + unsigned nr, + struct pipe_sampler_view **views) { - nv50_set_sampler_texture(pipe, PIPE_SHADER_FRAGMENT, nr, pt); + nv50_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, nr, views); +} + +static struct pipe_sampler_view * +nv50_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +nv50_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); } static void * @@ -743,8 +776,10 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.delete_sampler_state = nv50_sampler_state_delete; nv50->pipe.bind_fragment_sampler_states = nv50_fp_sampler_state_bind; nv50->pipe.bind_vertex_sampler_states = nv50_vp_sampler_state_bind; - nv50->pipe.set_fragment_sampler_textures = nv50_set_fp_sampler_textures; - nv50->pipe.set_vertex_sampler_textures = nv50_set_vp_sampler_textures; + nv50->pipe.set_fragment_sampler_views = nv50_set_fp_sampler_views; + nv50->pipe.set_vertex_sampler_views = nv50_set_vp_sampler_views; + nv50->pipe.create_sampler_view = nv50_create_sampler_view; + nv50->pipe.sampler_view_destroy = nv50_sampler_view_destroy; nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create; nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind; From 9aeb206e17181dfba4a40a41dbfc11560269e942 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 15:16:18 +0100 Subject: [PATCH 021/483] cell: Fix after sampler view changes. Did not test build. --- src/gallium/drivers/cell/ppu/cell_context.h | 1 + .../drivers/cell/ppu/cell_pipe_state.c | 45 ++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index a77cc5b9067..0724da9a7aa 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -121,6 +121,7 @@ struct cell_context struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct cell_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; uint num_textures; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index 3d8b4409c75..e1cf9dbbee8 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -257,8 +257,9 @@ cell_delete_sampler_state(struct pipe_context *pipe, static void -cell_set_sampler_textures(struct pipe_context *pipe, - unsigned num, struct pipe_texture **texture) +cell_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct cell_context *cell = cell_context(pipe); uint i, changed = 0x0; @@ -266,10 +267,14 @@ cell_set_sampler_textures(struct pipe_context *pipe, assert(num <= CELL_MAX_SAMPLERS); for (i = 0; i < CELL_MAX_SAMPLERS; i++) { - struct cell_texture *new_tex = cell_texture(i < num ? texture[i] : NULL); - struct cell_texture *old_tex = cell->texture[i]; - if (old_tex != new_tex) { + struct pipe_sampler_view *new_view = i < num ? views[i] : NULL; + struct pipe_sampler_view *old_view = cell->fragment_sampler_views[i]; + if (old_view != new_view) { + struct pipe_texture *new_tex = new_view ? new_view->texture : NULL; + + pipe_sampler_view_reference(&cell->fragment_sampler_views[i], + views[i]); pipe_texture_reference((struct pipe_texture **) &cell->texture[i], (struct pipe_texture *) new_tex); @@ -286,6 +291,32 @@ cell_set_sampler_textures(struct pipe_context *pipe, } +static struct pipe_sampler_view * +cell_create_sampler_view(struct pipe_context *pipe, + struct pipe_texture *texture, + const struct pipe_sampler_view *templ) +{ + struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + + return view; +} + + +static void +cell_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(view); +} + + /** * Map color and z/stencil framebuffer surfaces. */ @@ -399,7 +430,9 @@ cell_init_state_functions(struct cell_context *cell) cell->pipe.bind_fragment_sampler_states = cell_bind_sampler_states; cell->pipe.delete_sampler_state = cell_delete_sampler_state; - cell->pipe.set_fragment_sampler_textures = cell_set_sampler_textures; + cell->pipe.set_fragment_sampler_views = cell_set_fragment_sampler_views; + cell->pipe.create_sampler_view = cell_create_sampler_view; + cell->pipe.sampler_view_destroy = cell_sampler_view_destroy; cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state; cell->pipe.bind_depth_stencil_alpha_state = cell_bind_depth_stencil_alpha_state; From e81caade02a51da65eb28eba6816503305a97920 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 15:33:15 +0100 Subject: [PATCH 022/483] docs: Document sampler view entry points. --- src/gallium/docs/source/context.rst | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 827db8398ce..2d495f5d0e7 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -39,10 +39,24 @@ buffers, surfaces) are bound to the driver. are mostly restricted to the first one right now). * ``set_framebuffer_state`` -* ``set_fragment_sampler_views`` -* ``set_vertex_sampler_views`` -* ``create_sampler_view`` -* ``sampler_view_destroy`` + +* ``set_fragment_sampler_views`` binds an array of sampler views to + fragment shader stage. Every binding point acquires a reference + to a respective sampler view and releases a reference to the previous + sampler view. + +* ``set_vertex_sampler_views`` binds an array of sampler views to vertex + shader stage. Every binding point acquires a reference to a respective + sampler view and releases a reference to the previous sampler view. + +* ``create_sampler_view`` creates a new sampler view. texture is associated + with the sampler view which results in sampler view holding a reference + to the texture. Format specified in template must be compatible + with texture format. + +* ``sampler_view_destroy`` destroys a sampler view and releases its reference + to associated texture. + * ``set_vertex_buffers`` From 9960b3ed4b9a7b6eb92245820bdffdf5f70470a6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Feb 2010 08:04:29 -0700 Subject: [PATCH 023/483] gallium: added util/u_sampler.c to Makefile --- src/gallium/auxiliary/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index ec986355140..75dfd965afa 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -118,6 +118,7 @@ C_SOURCES = \ util/u_mm.c \ util/u_rect.c \ util/u_ringbuffer.c \ + util/u_sampler.c \ util/u_simple_shaders.c \ util/u_snprintf.c \ util/u_surface.c \ From 013dd29cca9b90555b7481a81ea1727fb7cea28b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Feb 2010 08:05:53 -0700 Subject: [PATCH 024/483] gallium/util: rewrap comment to fit in 80 columns --- src/gallium/auxiliary/util/u_sampler.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c index 3e45a2fa70d..08cf1fcf223 100644 --- a/src/gallium/auxiliary/util/u_sampler.c +++ b/src/gallium/auxiliary/util/u_sampler.c @@ -47,15 +47,18 @@ default_template(struct pipe_sampler_view *view, view->swizzle_b = PIPE_SWIZZLE_BLUE; view->swizzle_a = PIPE_SWIZZLE_ALPHA; - /* Override default green and blue component expansion to the requested one. + /* Override default green and blue component expansion to the requested + * one. * - * Gallium expands nonexistent components to (0,0,0,1), DX9 expands to (1,1,1,1). - * Since alpha is always expanded to 1, and red is always present, we only really - * care about green and blue components. + * Gallium expands nonexistent components to (0,0,0,1), DX9 expands + * to (1,1,1,1). Since alpha is always expanded to 1, and red is + * always present, we only really care about green and blue + * components. * - * To make it look less hackish, one would have to add UTIL_FORMAT_SWIZZLE_EXPAND - * to indicate components for expansion and then override without exceptions or - * favoring one component over another. + * To make it look less hackish, one would have to add + * UTIL_FORMAT_SWIZZLE_EXPAND to indicate components for expansion + * and then override without exceptions or favoring one component + * over another. */ if (format != PIPE_FORMAT_A8_UNORM) { const struct util_format_description *desc = util_format_description(format); From 44570063bf8a4f45807bc1598c8de291cdc64506 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 25 Feb 2010 16:39:58 +0100 Subject: [PATCH 025/483] nv50: update to handle new sampler view state --- src/gallium/drivers/nv50/nv50_context.h | 23 ++- src/gallium/drivers/nv50/nv50_screen.c | 6 +- src/gallium/drivers/nv50/nv50_state.c | 64 +++--- .../drivers/nv50/nv50_state_validate.c | 4 +- src/gallium/drivers/nv50/nv50_tex.c | 187 ++++++++++-------- src/gallium/drivers/nv50/nv50_texture.h | 32 ++- 6 files changed, 187 insertions(+), 129 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 7b879851b0e..42405c1a890 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -72,6 +72,17 @@ struct nv50_sampler_stateobj { unsigned tsc[8]; }; +struct nv50_sampler_view { + struct pipe_sampler_view pipe; + uint32_t tic[8]; +}; + +static INLINE struct nv50_sampler_view * +nv50_sampler_view(struct pipe_sampler_view *view) +{ + return (struct nv50_sampler_view *)view; +} + static INLINE unsigned get_tile_height(uint32_t tile_mode) { @@ -130,7 +141,7 @@ struct nv50_state { unsigned viewport_bypass; struct nouveau_stateobj *tsc_upload; struct nouveau_stateobj *tic_upload; - unsigned miptree_nr[PIPE_SHADER_TYPES]; + unsigned sampler_view_nr[3]; struct nouveau_stateobj *vertprog; struct nouveau_stateobj *fragprog; struct nouveau_stateobj *geomprog; @@ -170,11 +181,10 @@ struct nv50_context { unsigned vtxbuf_nr; struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; unsigned vtxelt_nr; - struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - unsigned sampler_nr[PIPE_SHADER_TYPES]; - struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - unsigned miptree_nr[PIPE_SHADER_TYPES]; + struct nv50_sampler_stateobj *sampler[3][PIPE_MAX_SAMPLERS]; + unsigned sampler_nr[3]; + struct pipe_sampler_view *sampler_views[3][PIPE_MAX_SAMPLERS]; + unsigned sampler_view_nr[3]; uint16_t vbo_fifo; }; @@ -244,6 +254,7 @@ extern void nv50_so_init_sifc(struct nv50_context *nv50, /* nv50_tex.c */ extern void nv50_tex_validate(struct nv50_context *); +extern boolean nv50_tex_construct(struct nv50_sampler_view *view); /* nv50_transfer.c */ extern void diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 2232461b9b6..ee54749443c 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -464,7 +464,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); so_data (so, 0x00000131 | (NV50_CB_PFP << 12)); - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4), &screen->tic); if (ret) { nv50_screen_destroy(pscreen); @@ -476,9 +476,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, PIPE_SHADER_TYPES * 32 - 1); + so_data (so, 3 * 32 - 1); - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4), &screen->tsc); if (ret) { nv50_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 8e5f1662eac..dd457c0f00f 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -238,6 +238,9 @@ nv50_sampler_state_create(struct pipe_context *pipe, return (void *)sso; } +/* type == 0 for VPs, 1 for GPs, 2 for FPs, which is how the + * relevant tesla methods are indexed (NV50TCL_BIND_TSC etc.) + */ static INLINE void nv50_sampler_state_bind(struct pipe_context *pipe, unsigned type, unsigned nr, void **sampler) @@ -253,13 +256,13 @@ nv50_sampler_state_bind(struct pipe_context *pipe, unsigned type, static void nv50_vp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s) { - nv50_sampler_state_bind(pipe, PIPE_SHADER_VERTEX, nr, s); + nv50_sampler_state_bind(pipe, 0, nr, s); } static void nv50_fp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s) { - nv50_sampler_state_bind(pipe, PIPE_SHADER_FRAGMENT, nr, s); + nv50_sampler_state_bind(pipe, 2, nr, s); } static void @@ -269,24 +272,21 @@ nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso) } static INLINE void -nv50_set_sampler_views(struct pipe_context *pipe, - unsigned type, +nv50_set_sampler_views(struct pipe_context *pipe, unsigned p, unsigned nr, struct pipe_sampler_view **views) { struct nv50_context *nv50 = nv50_context(pipe); unsigned i; - for (i = 0; i < nr; i++) { - pipe_sampler_view_reference(&nv50->sampler_views[type][i], views[i]); - pipe_texture_reference((void *)&nv50->miptree[type][i], views[i]->texture); - } - for (i = nr; i < nv50->miptree_nr[type]; i++) { - pipe_sampler_view_reference(&nv50->sampler_views[type][i], NULL); - pipe_texture_reference((void *)&nv50->miptree[type][i], NULL); - } + for (i = 0; i < nr; i++) + pipe_sampler_view_reference(&nv50->sampler_views[p][i], + views[i]); - nv50->miptree_nr[type] = nr; + for (i = nr; i < nv50->sampler_view_nr[p]; i++) + pipe_sampler_view_reference(&nv50->sampler_views[p][i], NULL); + + nv50->sampler_view_nr[p] = nr; nv50->dirty |= NV50_NEW_TEXTURE; } @@ -295,7 +295,7 @@ nv50_set_vp_sampler_views(struct pipe_context *pipe, unsigned nr, struct pipe_sampler_view **views) { - nv50_set_sampler_views(pipe, PIPE_SHADER_VERTEX, nr, views); + nv50_set_sampler_views(pipe, 0, nr, views); } static void @@ -303,7 +303,15 @@ nv50_set_fp_sampler_views(struct pipe_context *pipe, unsigned nr, struct pipe_sampler_view **views) { - nv50_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, nr, views); + nv50_set_sampler_views(pipe, 2, nr, views); +} + +static void +nv50_sampler_view_destroy(struct pipe_context *pipe, + struct pipe_sampler_view *view) +{ + pipe_texture_reference(&view->texture, NULL); + FREE(nv50_sampler_view(view)); } static struct pipe_sampler_view * @@ -311,26 +319,22 @@ nv50_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); + struct nv50_sampler_view *view = CALLOC_STRUCT(nv50_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + view->pipe = *templ; + view->pipe.reference.count = 1; + view->pipe.texture = NULL; + pipe_texture_reference(&view->pipe.texture, texture); + view->pipe.context = pipe; - return view; + if (!nv50_tex_construct(view)) { + nv50_sampler_view_destroy(pipe, &view->pipe); + return NULL; + } + return &view->pipe; } -static void -nv50_sampler_view_destroy(struct pipe_context *pipe, - struct pipe_sampler_view *view) -{ - pipe_texture_reference(&view->texture, NULL); - FREE(view); -} - static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index efab94cab74..741f8e8f59d 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -436,8 +436,8 @@ viewport_uptodate: 1 + 19 * PIPE_SHADER_TYPES + nr * 8, PIPE_SHADER_TYPES * 2); - nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); - nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT); + nv50_validate_samplers(nv50, so, 0); /* VP samplers */ + nv50_validate_samplers(nv50, so, 2); /* FP samplers */ so_method(so, tesla, 0x1334, 1); /* flush TSC */ so_data (so, 0); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 9f1a1713032..2f2ebc8ec43 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -28,26 +28,16 @@ #include "util/u_format.h" #define _MIXED(pf, t0, t1, t2, t3, cr, cg, cb, ca, f) \ -{ \ - PIPE_FORMAT_##pf, \ +[PIPE_FORMAT_##pf] = ( \ NV50TIC_0_0_MAPR_##cr | NV50TIC_0_0_TYPER_##t0 | \ NV50TIC_0_0_MAPG_##cg | NV50TIC_0_0_TYPEG_##t1 | \ NV50TIC_0_0_MAPB_##cb | NV50TIC_0_0_TYPEB_##t2 | \ NV50TIC_0_0_MAPA_##ca | NV50TIC_0_0_TYPEA_##t3 | \ - NV50TIC_0_0_FMT_##f \ -} + NV50TIC_0_0_FMT_##f) #define _(pf, t, cr, cg, cb, ca, f) _MIXED(pf, t, t, t, t, cr, cg, cb, ca, f) -struct nv50_texture_format { - enum pipe_format pf; - uint32_t hw; -}; - -#define NV50_TEX_FORMAT_LIST_SIZE \ - (sizeof(nv50_tex_format_list) / sizeof(struct nv50_texture_format)) - -static const struct nv50_texture_format nv50_tex_format_list[] = +static const uint32_t nv50_texture_formats[PIPE_FORMAT_COUNT] = { _(A8R8G8B8_UNORM, UNORM, C2, C1, C0, C3, 8_8_8_8), _(A8R8G8B8_SRGB, UNORM, C2, C1, C0, C3, 8_8_8_8), @@ -59,10 +49,12 @@ static const struct nv50_texture_format nv50_tex_format_list[] = _(R5G6B5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5), _(L8_UNORM, UNORM, C0, C0, C0, ONE, 8), + _(L8_SRGB, UNORM, C0, C0, C0, ONE, 8), _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8), _(I8_UNORM, UNORM, C0, C0, C0, C0, 8), _(A8L8_UNORM, UNORM, C0, C0, C0, C1, 8_8), + _(A8L8_SRGB, UNORM, C0, C0, C0, C1, 8_8), _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1), _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1), @@ -80,117 +72,144 @@ static const struct nv50_texture_format nv50_tex_format_list[] = _(R16G16_UNORM, UNORM, C0, C1, ZERO, ONE, 16_16), _MIXED(Z32_FLOAT, FLOAT, UINT, UINT, UINT, C0, C0, C0, ONE, 32_DEPTH) - }; #undef _ #undef _MIXED -static int -nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, - struct nv50_miptree *mt, int unit, unsigned p) +static INLINE uint32_t +nv50_tic_swizzle(uint32_t tc, unsigned swz) { - unsigned i; - uint32_t mode; - const struct util_format_description *desc; - - for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++) - if (nv50_tex_format_list[i].pf == mt->base.base.format) - break; - if (i == NV50_TEX_FORMAT_LIST_SIZE) - return 1; - - if (nv50->sampler[p][unit]->normalized) - mode = 0x50001000 | (1 << 31); - else { - mode = 0x50001000 | (7 << 14); - assert(mt->base.base.target == PIPE_TEXTURE_2D); + switch (swz) { + case PIPE_SWIZZLE_RED: + return (tc & NV50TIC_0_0_MAPR_MASK) >> NV50TIC_0_0_MAPR_SHIFT; + case PIPE_SWIZZLE_GREEN: + return (tc & NV50TIC_0_0_MAPG_MASK) >> NV50TIC_0_0_MAPG_SHIFT; + case PIPE_SWIZZLE_BLUE: + return (tc & NV50TIC_0_0_MAPB_MASK) >> NV50TIC_0_0_MAPB_SHIFT; + case PIPE_SWIZZLE_ALPHA: + return (tc & NV50TIC_0_0_MAPA_MASK) >> NV50TIC_0_0_MAPA_SHIFT; + case PIPE_SWIZZLE_ONE: + return 7; + case PIPE_SWIZZLE_ZERO: + default: + return 0; } +} - mode |= ((mt->base.bo->tile_mode & 0x0f) << 22) | - ((mt->base.bo->tile_mode & 0xf0) << 21); +boolean +nv50_tex_construct(struct nv50_sampler_view *view) +{ + const struct util_format_description *desc; + struct nv50_miptree *mt = nv50_miptree(view->pipe.texture); + uint32_t swz[4], *tic = view->tic; + + tic[0] = nv50_texture_formats[mt->base.base.format]; + + swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r); + swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g); + swz[2] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_b); + swz[3] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_a); + view->tic[0] = (tic[0] & ~NV50TIC_0_0_SWIZZLE_MASK) | + (swz[0] << NV50TIC_0_0_MAPR_SHIFT) | + (swz[1] << NV50TIC_0_0_MAPG_SHIFT) | + (swz[2] << NV50TIC_0_0_MAPB_SHIFT) | + (swz[3] << NV50TIC_0_0_MAPA_SHIFT); + + tic[2] = 0x50001000; + tic[2] |= ((mt->base.bo->tile_mode & 0x0f) << 22) | + ((mt->base.bo->tile_mode & 0xf0) << 21); desc = util_format_description(mt->base.base.format); - assert(desc); - if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) - mode |= 0x0400; + tic[2] |= NV50TIC_0_2_COLORSPACE_SRGB; switch (mt->base.base.target) { case PIPE_TEXTURE_1D: + tic[2] |= NV50TIC_0_2_TARGET_1D; break; case PIPE_TEXTURE_2D: - mode |= (1 << 14); + tic[2] |= NV50TIC_0_2_TARGET_2D; break; case PIPE_TEXTURE_3D: - mode |= (2 << 14); + tic[2] |= NV50TIC_0_2_TARGET_3D; break; case PIPE_TEXTURE_CUBE: - mode |= (3 << 14); + tic[2] |= NV50TIC_0_2_TARGET_CUBE; break; default: - assert(!"unsupported texture target"); - break; + NOUVEAU_ERR("invalid texture target: %d\n", + mt->base.base.target); + return FALSE; } - so_data (so, nv50_tex_format_list[i].hw); - so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | - NOUVEAU_BO_RD, 0, 0); - so_data (so, mode); - so_data (so, 0x00300000); - so_data (so, mt->base.base.width0 | (1 << 31)); - so_data (so, (mt->base.base.last_level << 28) | - (mt->base.base.depth0 << 16) | mt->base.base.height0); - so_data (so, 0x03000000); - so_data (so, mt->base.base.last_level << 4); + tic[3] = 0x00300000; - return 0; + tic[4] = (1 << 31) | mt->base.base.width0; + tic[5] = (mt->base.base.last_level << 28) | + (mt->base.base.depth0 << 16) | mt->base.base.height0; + + tic[6] = 0x03000000; + + tic[7] = (view->pipe.num_levels - view->pipe.first_level - 1) << 4; + tic[7] |= view->pipe.first_level; + + return TRUE; } -#ifndef NV50TCL_BIND_TIC -#define NV50TCL_BIND_TIC(n) (0x1448 + 8 * n) -#endif - -static boolean +static int nv50_validate_textures(struct nv50_context *nv50, struct nouveau_stateobj *so, unsigned p) { - static const unsigned p_remap[PIPE_SHADER_TYPES] = { 0, 2, 1 }; - struct nouveau_grobj *eng2d = nv50->screen->eng2d; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned unit, j, p_hw = p_remap[p]; + unsigned unit, j; + + const unsigned rll = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW; + const unsigned rlh = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH + | NOUVEAU_BO_OR; nv50_so_init_sifc(nv50, so, nv50->screen->tic, NOUVEAU_BO_VRAM, - p * (32 * 8 * 4), nv50->miptree_nr[p] * 8 * 4); + p * (32 * 8 * 4), nv50->sampler_view_nr[p] * 8 * 4); - for (unit = 0; unit < nv50->miptree_nr[p]; ++unit) { - struct nv50_miptree *mt = nv50->miptree[p][unit]; + for (unit = 0; unit < nv50->sampler_view_nr[p]; ++unit) { + struct nv50_sampler_view *view = + nv50_sampler_view(nv50->sampler_views[p][unit]); so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8); - if (mt) { - if (nv50_tex_construct(nv50, so, mt, unit, p)) - return FALSE; + if (view) { + uint32_t tic2 = view->tic[2]; + struct nv50_miptree *mt = + nv50_miptree(view->pipe.texture); + + if (nv50->sampler[p][unit]->normalized) + tic2 |= NV50TIC_0_2_NORMALIZED_COORDS; + + so_data (so, view->tic[0]); + so_reloc (so, mt->base.bo, 0, rll, 0, 0); + so_reloc (so, mt->base.bo, 0, rlh, tic2, tic2); + so_datap (so, &view->tic[3], 5); + /* Set TEX insn $t src binding $unit in program type p * to TIC, TSC entry (32 * p + unit), mark valid (1). */ - so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1); + so_method(so, tesla, NV50TCL_BIND_TIC(p), 1); so_data (so, ((32 * p + unit) << 9) | (unit << 1) | 1); } else { for (j = 0; j < 8; ++j) so_data(so, 0); - so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1); + so_method(so, tesla, NV50TCL_BIND_TIC(p), 1); so_data (so, (unit << 1) | 0); } } - for (; unit < nv50->state.miptree_nr[p]; unit++) { + for (; unit < nv50->state.sampler_view_nr[p]; unit++) { /* Make other bindings invalid. */ - so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1); + so_method(so, tesla, NV50TCL_BIND_TIC(p), 1); so_data (so, (unit << 1) | 0); } - nv50->state.miptree_nr[p] = nv50->miptree_nr[p]; + nv50->state.sampler_view_nr[p] = nv50->sampler_view_nr[p]; return TRUE; } @@ -199,21 +218,23 @@ nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_stateobj *so; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned p, start, push, nrlc; + unsigned p, m = 0, d = 0, r = 0; - for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { - start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); - push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); - nrlc += nv50->miptree_nr[p]; + for (p = 0; p < 3; ++p) { + unsigned nr = MAX2(nv50->sampler_view_nr[p], + nv50->state.sampler_view_nr[p]); + m += nr; + d += nr; + r += nv50->sampler_view_nr[p]; } - start = start * 2 + 4 * PIPE_SHADER_TYPES + 2; - push = push * 9 + 19 * PIPE_SHADER_TYPES + 2; - nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES; + m = m * 2 + 3 * 4 + 1; + d = d * 9 + 3 * 19 + 1; + r = r * 2 + 3 * 2; - so = so_new(start, push, nrlc); + so = so_new(m, d, r); - if (nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX) == FALSE || - nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT) == FALSE) { + if (nv50_validate_textures(nv50, so, 0) == FALSE || + nv50_validate_textures(nv50, so, 2) == FALSE) { so_ref(NULL, &so); NOUVEAU_ERR("failed tex validate\n"); diff --git a/src/gallium/drivers/nv50/nv50_texture.h b/src/gallium/drivers/nv50/nv50_texture.h index b870302019a..3475d3e4326 100644 --- a/src/gallium/drivers/nv50/nv50_texture.h +++ b/src/gallium/drivers/nv50/nv50_texture.h @@ -7,7 +7,9 @@ */ /* Texture image control block */ +#define NV50TIC_0_0_SWIZZLE_MASK 0x3ffc0000 #define NV50TIC_0_0_MAPA_MASK 0x38000000 +#define NV50TIC_0_0_MAPA_SHIFT 27 #define NV50TIC_0_0_MAPA_ZERO 0x00000000 #define NV50TIC_0_0_MAPA_C0 0x10000000 #define NV50TIC_0_0_MAPA_C1 0x18000000 @@ -15,6 +17,7 @@ #define NV50TIC_0_0_MAPA_C3 0x28000000 #define NV50TIC_0_0_MAPA_ONE 0x38000000 #define NV50TIC_0_0_MAPB_MASK 0x07000000 +#define NV50TIC_0_0_MAPB_SHIFT 24 #define NV50TIC_0_0_MAPB_ZERO 0x00000000 #define NV50TIC_0_0_MAPB_C0 0x02000000 #define NV50TIC_0_0_MAPB_C1 0x03000000 @@ -22,6 +25,7 @@ #define NV50TIC_0_0_MAPB_C3 0x05000000 #define NV50TIC_0_0_MAPB_ONE 0x07000000 #define NV50TIC_0_0_MAPG_MASK 0x00e00000 +#define NV50TIC_0_0_MAPG_SHIFT 21 #define NV50TIC_0_0_MAPG_ZERO 0x00000000 #define NV50TIC_0_0_MAPG_C0 0x00400000 #define NV50TIC_0_0_MAPG_C1 0x00600000 @@ -29,6 +33,7 @@ #define NV50TIC_0_0_MAPG_C3 0x00a00000 #define NV50TIC_0_0_MAPG_ONE 0x00e00000 #define NV50TIC_0_0_MAPR_MASK 0x001c0000 +#define NV50TIC_0_0_MAPR_SHIFT 18 #define NV50TIC_0_0_MAPR_ZERO 0x00000000 #define NV50TIC_0_0_MAPR_C0 0x00080000 #define NV50TIC_0_0_MAPR_C1 0x000c0000 @@ -89,22 +94,39 @@ #define NV50TIC_0_1_OFFSET_LOW_MASK 0xffffffff #define NV50TIC_0_1_OFFSET_LOW_SHIFT 0 -#define NV50TIC_0_2_UNKNOWN_MASK 0xffffffff +#define NV50TIC_0_2_COLORSPACE_SRGB 0x00000400 +#define NV50TIC_0_2_TARGET_1D 0x00000000 +#define NV50TIC_0_2_TARGET_2D 0x00004000 +#define NV50TIC_0_2_TARGET_3D 0x00008000 +#define NV50TIC_0_2_TARGET_CUBE 0x0000c000 +#define NV50TIC_0_2_TARGET_1D_ARRAY 0x00010000 +#define NV50TIC_0_2_TARGET_2D_ARRAY 0x00014000 +#define NV50TIC_0_2_TARGET_BUFFER 0x00018000 +#define NV50TIC_0_2_TARGET_RECT 0x0001c000 +/* #define NV50TIC_0_0_TILE_MODE_LINEAR 0x00040000 */ +#define NV50TIC_0_2_TILE_MODE_Y_MASK 0x01c00000 +#define NV50TIC_0_2_TILE_MODE_Y_SHIFT 22 +#define NV50TIC_0_2_TILE_MODE_Z_MASK 0x0e000000 +#define NV50TIC_0_2_TILE_MODE_Z_SHIFT 25 +#define NV50TIC_0_2_NORMALIZED_COORDS 0x80000000 #define NV50TIC_0_3_UNKNOWN_MASK 0xffffffff #define NV50TIC_0_4_WIDTH_MASK 0x0000ffff #define NV50TIC_0_4_WIDTH_SHIFT 0 -#define NV50TIC_0_5_DEPTH_MASK 0xffff0000 +#define NV50TIC_0_5_LAST_LEVEL_MASK 0xf0000000 +#define NV50TIC_0_5_LAST_LEVEL_SHIFT 28 +#define NV50TIC_0_5_DEPTH_MASK 0x0fff0000 #define NV50TIC_0_5_DEPTH_SHIFT 16 #define NV50TIC_0_5_HEIGHT_MASK 0x0000ffff #define NV50TIC_0_5_HEIGHT_SHIFT 0 - #define NV50TIC_0_6_UNKNOWN_MASK 0xffffffff -#define NV50TIC_0_7_OFFSET_HIGH_MASK 0xffffffff -#define NV50TIC_0_7_OFFSET_HIGH_SHIFT 0 +#define NV50TIC_0_7_BASE_LEVEL_MASK 0x0000000f +#define NV50TIC_0_7_BASE_LEVEL_SHIFT 0 +#define NV50TIC_0_7_MAX_LEVEL_MASK 0x000000f0 +#define NV50TIC_0_7_MAX_LEVEL_SHIFT 4 /* Texture sampler control block */ #define NV50TSC_1_0_WRAPS_MASK 0x00000007 From a69fdb84df17dd91cbfd41fc90a54558cb334297 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 25 Feb 2010 16:43:01 +0100 Subject: [PATCH 026/483] nv30: function is called nv30_set_fragment_sampler_views, plural --- src/gallium/drivers/nv30/nv30_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 1d484ecb77f..fdfb51a9b34 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -720,7 +720,7 @@ nv30_init_state_functions(struct nv30_context *nv30) nv30->pipe.create_sampler_state = nv30_sampler_state_create; nv30->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind; nv30->pipe.delete_sampler_state = nv30_sampler_state_delete; - nv30->pipe.set_fragment_sampler_views = nv30_set_fragment_sampler_view; + nv30->pipe.set_fragment_sampler_views = nv30_set_fragment_sampler_views; nv30->pipe.create_sampler_view = nv30_create_sampler_view; nv30->pipe.sampler_view_destroy = nv30_sampler_view_destroy; From 5587097b53afbce52f7e26568d2dde11de96e1ec Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 2 Mar 2010 12:02:31 +0100 Subject: [PATCH 027/483] util: Add pipe_get_tile_swizzle(). --- src/gallium/auxiliary/util/u_tile.c | 42 +++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_tile.h | 12 +++++++++ 2 files changed, 54 insertions(+) diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 0051258e22a..813ce4eb7dc 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1273,6 +1273,48 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, } +void +pipe_get_tile_swizzle(struct pipe_transfer *pt, + uint x, + uint y, + uint w, + uint h, + uint swizzle_r, + uint swizzle_g, + uint swizzle_b, + uint swizzle_a, + float *p) +{ + uint i; + float rgba01[6]; + + pipe_get_tile_rgba(pt, x, y, w, h, p); + + if (swizzle_r == PIPE_SWIZZLE_RED && + swizzle_g == PIPE_SWIZZLE_GREEN && + swizzle_b == PIPE_SWIZZLE_BLUE && + swizzle_a == PIPE_SWIZZLE_ALPHA) { + /* no-op, skip */ + return; + } + + rgba01[PIPE_SWIZZLE_ZERO] = 0.0f; + rgba01[PIPE_SWIZZLE_ONE] = 1.0f; + + for (i = 0; i < w * h; i++) { + rgba01[PIPE_SWIZZLE_RED] = p[0]; + rgba01[PIPE_SWIZZLE_GREEN] = p[1]; + rgba01[PIPE_SWIZZLE_BLUE] = p[2]; + rgba01[PIPE_SWIZZLE_ALPHA] = p[3]; + + *p++ = rgba01[swizzle_r]; + *p++ = rgba01[swizzle_g]; + *p++ = rgba01[swizzle_b]; + *p++ = rgba01[swizzle_a]; + } +} + + void pipe_put_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index 1453af38b8a..b4706179a55 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -71,6 +71,18 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, float *p); +void +pipe_get_tile_swizzle(struct pipe_transfer *pt, + uint x, + uint y, + uint w, + uint h, + uint swizzle_r, + uint swizzle_g, + uint swizzle_b, + uint swizzle_a, + float *p); + void pipe_put_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, From f59f28093ea827bd234d8e1a36bdd56a9fce5f09 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 2 Mar 2010 12:03:24 +0100 Subject: [PATCH 028/483] softpipe: Implement sampler view swizzling. --- .../drivers/softpipe/sp_state_sampler.c | 6 ++-- .../drivers/softpipe/sp_tex_tile_cache.c | 29 ++++++++++++++----- .../drivers/softpipe/sp_tex_tile_cache.h | 9 ++++-- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index 8922941994a..68ea13f8d51 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -166,10 +166,9 @@ softpipe_set_sampler_views(struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; - struct pipe_texture *texture = view ? view->texture : NULL; pipe_sampler_view_reference(&softpipe->sampler_views[i], view); - sp_tex_tile_cache_set_texture(softpipe->tex_cache[i], texture); + sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[i], view); } softpipe->num_sampler_views = num; @@ -198,10 +197,9 @@ softpipe_set_vertex_sampler_views(struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; - struct pipe_texture *texture = view ? view->texture : NULL; pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], view); - sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], texture); + sp_tex_tile_cache_set_sampler_view(softpipe->vertex_tex_cache[i], view); } softpipe->num_vertex_sampler_views = num; diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index a0b95c88846..b9635bee78b 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -119,12 +119,13 @@ sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc) } /** - * Specify the texture to cache. + * Specify the sampler view to cache. */ void -sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc, - struct pipe_texture *texture) +sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc, + struct pipe_sampler_view *view) { + struct pipe_texture *texture = view ? view->texture : NULL; uint i; assert(!tc->transfer); @@ -144,6 +145,13 @@ sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc, tc->tex_trans = NULL; } + if (view) { + tc->swizzle_r = view->swizzle_r; + tc->swizzle_g = view->swizzle_g; + tc->swizzle_b = view->swizzle_b; + tc->swizzle_a = view->swizzle_a; + } + /* mark as entries as invalid/empty */ /* XXX we should try to avoid this when the teximage hasn't changed */ for (i = 0; i < NUM_ENTRIES; i++) { @@ -257,11 +265,16 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, } /* get tile from the transfer (view into texture) */ - pipe_get_tile_rgba(tc->tex_trans, - addr.bits.x * TILE_SIZE, - addr.bits.y * TILE_SIZE, - TILE_SIZE, TILE_SIZE, - (float *) tile->data.color); + pipe_get_tile_swizzle(tc->tex_trans, + addr.bits.x * TILE_SIZE, + addr.bits.y * TILE_SIZE, + TILE_SIZE, + TILE_SIZE, + tc->swizzle_r, + tc->swizzle_g, + tc->swizzle_b, + tc->swizzle_a, + (float *) tile->data.color); tile->addr = addr; } diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h index ac6886a3df1..c562f721be7 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h @@ -83,6 +83,11 @@ struct softpipe_tex_tile_cache void *tex_trans_map; int tex_face, tex_level, tex_z; + unsigned swizzle_r; + unsigned swizzle_g; + unsigned swizzle_b; + unsigned swizzle_a; + struct softpipe_tex_cached_tile *last_tile; /**< most recently retrieved tile */ }; @@ -101,8 +106,8 @@ extern void sp_tex_tile_cache_unmap_transfers(struct softpipe_tex_tile_cache *tc); extern void -sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc, - struct pipe_texture *texture); +sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc, + struct pipe_sampler_view *view); void sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc); From 5d4360d10cd39e28ee3b563e95959f3dd22c5242 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 10 Mar 2010 16:32:34 +0100 Subject: [PATCH 029/483] gallium: pipe_get_tile_swizzle() accepts format parameter. Enables casting of texture data. --- src/gallium/auxiliary/util/u_tile.c | 22 ++++++++++++++++++- src/gallium/auxiliary/util/u_tile.h | 1 + .../drivers/softpipe/sp_tex_tile_cache.c | 2 ++ .../drivers/softpipe/sp_tex_tile_cache.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 024d9577bc9..8a36d4d9d18 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1283,12 +1283,32 @@ pipe_get_tile_swizzle(struct pipe_transfer *pt, uint swizzle_g, uint swizzle_b, uint swizzle_a, + enum pipe_format format, float *p) { + unsigned dst_stride = w * 4; + void *packed; uint i; float rgba01[6]; - pipe_get_tile_rgba(pt, x, y, w, h, p); + if (pipe_clip_tile(x, y, &w, &h, pt)) { + return; + } + + packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format)); + if (!packed) { + return; + } + + if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) { + assert((x & 1) == 0); + } + + pipe_get_tile_raw(pt, x, y, w, h, packed, 0); + + pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride); + + FREE(packed); if (swizzle_r == PIPE_SWIZZLE_RED && swizzle_g == PIPE_SWIZZLE_GREEN && diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index b4706179a55..d665fdb1bb1 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -81,6 +81,7 @@ pipe_get_tile_swizzle(struct pipe_transfer *pt, uint swizzle_g, uint swizzle_b, uint swizzle_a, + enum pipe_format format, float *p); void diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index b9635bee78b..dfa002a79b4 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -150,6 +150,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc, tc->swizzle_g = view->swizzle_g; tc->swizzle_b = view->swizzle_b; tc->swizzle_a = view->swizzle_a; + tc->format = view->format; } /* mark as entries as invalid/empty */ @@ -274,6 +275,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, tc->swizzle_g, tc->swizzle_b, tc->swizzle_a, + tc->format, (float *) tile->data.color); tile->addr = addr; } diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h index c562f721be7..f8770409d87 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h @@ -87,6 +87,7 @@ struct softpipe_tex_tile_cache unsigned swizzle_g; unsigned swizzle_b; unsigned swizzle_a; + unsigned format; struct softpipe_tex_cached_tile *last_tile; /**< most recently retrieved tile */ }; From 252dc5f897f9d124459e3afebf6686d1fe271511 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 11 Mar 2010 15:25:52 +0100 Subject: [PATCH 030/483] gallium: Use last_level for pipe_sampler_view instead of num_levels. It's more consistent with the rest of the interfaces. --- src/gallium/auxiliary/util/u_sampler.c | 2 +- src/gallium/drivers/nv50/nv50_tex.c | 2 +- src/gallium/include/pipe/p_state.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c index 08cf1fcf223..4d8f861ce49 100644 --- a/src/gallium/auxiliary/util/u_sampler.c +++ b/src/gallium/auxiliary/util/u_sampler.c @@ -41,7 +41,7 @@ default_template(struct pipe_sampler_view *view, view->format = format; view->first_level = 0; - view->num_levels = texture->last_level + 1; + view->last_level = texture->last_level; view->swizzle_r = PIPE_SWIZZLE_RED; view->swizzle_g = PIPE_SWIZZLE_GREEN; view->swizzle_b = PIPE_SWIZZLE_BLUE; diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index c5029bad2d8..7ed73eac50f 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -152,7 +152,7 @@ nv50_tex_construct(struct nv50_sampler_view *view) tic[6] = 0x03000000; - tic[7] = (view->pipe.num_levels - view->pipe.first_level - 1) << 4; + tic[7] = (view->pipe.last_level - view->pipe.first_level) << 4; tic[7] |= view->pipe.first_level; return TRUE; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 3c7c0a5261c..11072407d93 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -309,7 +309,7 @@ struct pipe_sampler_view struct pipe_texture *texture; /**< texture into which this is a view */ struct pipe_context *context; /**< context this view belongs to */ unsigned first_level:8; /**< first mipmap level */ - unsigned num_levels:8; /**< number of mipamp levels */ + unsigned last_level:8; /**< last mipmap level */ unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ From 530b9910c2fd25344e6d28b6d9aa0eaad31618e7 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 11 Mar 2010 15:30:21 +0100 Subject: [PATCH 031/483] gallium: Check for OOM condition when creating a sampler view. --- src/gallium/drivers/cell/ppu/cell_pipe_state.c | 12 +++++++----- src/gallium/drivers/i915/i915_state.c | 12 +++++++----- src/gallium/drivers/i965/brw_pipe_sampler.c | 12 +++++++----- src/gallium/drivers/llvmpipe/lp_state_sampler.c | 12 +++++++----- src/gallium/drivers/nv30/nv30_state.c | 12 +++++++----- src/gallium/drivers/nv40/nv40_state.c | 12 +++++++----- src/gallium/drivers/r300/r300_state.c | 12 +++++++----- src/gallium/drivers/softpipe/sp_state_sampler.c | 12 +++++++----- src/gallium/drivers/svga/svga_pipe_sampler.c | 12 +++++++----- 9 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index 2fc82933e4d..059ce8597bc 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -298,11 +298,13 @@ cell_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 884abe622b3..e54997736f9 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -598,11 +598,13 @@ i915_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c index fbc3a07d61e..d2aa2bc9f35 100644 --- a/src/gallium/drivers/i965/brw_pipe_sampler.c +++ b/src/gallium/drivers/i965/brw_pipe_sampler.c @@ -219,11 +219,13 @@ brw_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 2df86a08148..2645441b58c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -170,11 +170,13 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 321575da0a9..fb3075f4c81 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -304,11 +304,13 @@ nv30_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index 120dc42f7b1..28a48a63f1c 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -314,11 +314,13 @@ nv40_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 09bbf6c60e2..d73ec78fda8 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -980,11 +980,13 @@ r300_create_sampler_view(struct pipe_context *pipe, struct r300_context *r300 = r300_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index 68ea13f8d51..d501952bba9 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -128,11 +128,13 @@ softpipe_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index ebd1b949972..82d525ca33f 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -183,11 +183,13 @@ svga_create_sampler_view(struct pipe_context *pipe, { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); - *view = *templ; - view->reference.count = 1; - view->texture = NULL; - pipe_texture_reference(&view->texture, texture); - view->context = pipe; + if (view) { + *view = *templ; + view->reference.count = 1; + view->texture = NULL; + pipe_texture_reference(&view->texture, texture); + view->context = pipe; + } return view; } From 4da5d369fb6a724a03a3c2e79ed6623980fc72ac Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 11 Mar 2010 17:27:12 +0100 Subject: [PATCH 032/483] nv50: fix damage from merging master into sampler-view Fixed the state array sizes at 3 (instead of PIPE_SHADER_TYPES) because we'll never have domain and hull shaders on nv50; also the numbering doesn't correspond to the hw numbering. --- src/gallium/drivers/nv50/nv50_context.h | 8 +++----- src/gallium/drivers/nv50/nv50_state_validate.c | 10 ++++------ src/gallium/drivers/nv50/nv50_tex.c | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 8a5f7cb2519..f35bc411feb 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -137,7 +137,7 @@ struct nv50_state { struct nouveau_stateobj *hw[64]; uint64_t hw_dirty; - unsigned miptree_nr[PIPE_SHADER_TYPES]; + unsigned sampler_view_nr[3]; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; unsigned vtxelt_nr; @@ -169,12 +169,10 @@ struct nv50_context { struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned vtxbuf_nr; struct nv50_vtxelt_stateobj *vtxelt; - struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - unsigned sampler_nr[PIPE_SHADER_TYPES]; + struct nv50_sampler_stateobj *sampler[3][PIPE_MAX_SAMPLERS]; + unsigned sampler_nr[3]; struct pipe_sampler_view *sampler_views[3][PIPE_MAX_SAMPLERS]; unsigned sampler_view_nr[3]; - struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; - unsigned miptree_nr[PIPE_SHADER_TYPES]; unsigned vbo_fifo; }; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 2c8e7ca7982..63d73b5ce83 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -310,15 +310,13 @@ validate_sampler(struct nv50_context *nv50) struct nouveau_stateobj *so; unsigned nr = 0, i; - for (i = 0; i < PIPE_SHADER_TYPES; ++i) + for (i = 0; i < 3; ++i) nr += nv50->sampler_nr[i]; - so = so_new(1 + 5 * PIPE_SHADER_TYPES, - 1 + 19 * PIPE_SHADER_TYPES + nr * 8, - PIPE_SHADER_TYPES * 2); + so = so_new(1 + 5 * 3, 1 + 19 * 3 + nr * 8, 3 * 2); - nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); - nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT); + nv50_validate_samplers(nv50, so, 0); /* VP */ + nv50_validate_samplers(nv50, so, 2); /* FP */ so_method(so, tesla, 0x1334, 1); /* flush TSC */ so_data (so, 0); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 7ed73eac50f..aa885e71688 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -54,8 +54,8 @@ static const uint32_t nv50_texture_formats[PIPE_FORMAT_COUNT] = _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8), _(I8_UNORM, UNORM, C0, C0, C0, C0, 8), - _(A8L8_UNORM, UNORM, C0, C0, C0, C1, 8_8), - _(A8L8_SRGB, UNORM, C0, C0, C0, C1, 8_8), + _(L8A8_UNORM, UNORM, C0, C0, C0, C1, 8_8), + _(L8A8_SRGB, UNORM, C0, C0, C0, C1, 8_8), _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1), _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1), @@ -221,23 +221,25 @@ nv50_tex_relocs(struct nv50_context *nv50) int p, unit; p = PIPE_SHADER_FRAGMENT; - for (unit = 0; unit < nv50->miptree_nr[p]; unit++) { - if (!nv50->miptree[p][unit]) + for (unit = 0; unit < nv50->sampler_view_nr[p]; unit++) { + struct pipe_sampler_view *view = nv50->sampler_views[p][unit]; + if (!view) continue; nouveau_reloc_emit(chan, nv50->screen->tic, ((p * 32) + unit) * 32, NULL, - nv50->miptree[p][unit]->base.bo, 0, 0, + nv50_miptree(view->texture)->base.bo, 0, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); } p = PIPE_SHADER_VERTEX; - for (unit = 0; unit < nv50->miptree_nr[p]; unit++) { - if (!nv50->miptree[p][unit]) + for (unit = 0; unit < nv50->sampler_view_nr[p]; unit++) { + struct pipe_sampler_view *view = nv50->sampler_views[p][unit]; + if (!view) continue; nouveau_reloc_emit(chan, nv50->screen->tic, ((p * 32) + unit) * 32, NULL, - nv50->miptree[p][unit]->base.bo, 0, 0, + nv50_miptree(view->texture)->base.bo, 0, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); } From 9e9839bd04b5d4e554a1a9ede22ccf44fc1306b6 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 11 Mar 2010 17:12:10 +0100 Subject: [PATCH 033/483] nv50: put correct value into the TIC MAX_LEVEL field --- src/gallium/drivers/nv50/nv50_tex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index aa885e71688..79639e81eb3 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -152,8 +152,7 @@ nv50_tex_construct(struct nv50_sampler_view *view) tic[6] = 0x03000000; - tic[7] = (view->pipe.last_level - view->pipe.first_level) << 4; - tic[7] |= view->pipe.first_level; + tic[7] = (view->pipe.last_level << 4) | view->pipe.first_level; return TRUE; } From a671a9eed08e63e97ec4257adea2c09dd7d2b4e2 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 11 Mar 2010 17:14:14 +0100 Subject: [PATCH 034/483] nv50: take format from sampler view, not the referenced texture --- src/gallium/drivers/nv50/nv50_tex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 79639e81eb3..85ab947c006 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -105,7 +105,7 @@ nv50_tex_construct(struct nv50_sampler_view *view) struct nv50_miptree *mt = nv50_miptree(view->pipe.texture); uint32_t swz[4], *tic = view->tic; - tic[0] = nv50_texture_formats[mt->base.base.format]; + tic[0] = nv50_texture_formats[view->pipe.format]; swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r); swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g); From d2083056d56990a9bfba774d5bda272b74d27a6f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 7 Feb 2010 00:52:02 +0800 Subject: [PATCH 035/483] gallium: Add st_api.h. This is a new interface to be implemented by st/mesa, st/vesa, and the window system APIs such as EGL or GLX. --- src/gallium/include/state_tracker/st_api.h | 407 +++++++++++++++++++++ 1 file changed, 407 insertions(+) create mode 100644 src/gallium/include/state_tracker/st_api.h diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h new file mode 100644 index 00000000000..70ad215bfce --- /dev/null +++ b/src/gallium/include/state_tracker/st_api.h @@ -0,0 +1,407 @@ +/********************************************************** + * Copyright 2010 VMware, Inc. 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 THE AUTHORS OR COPYRIGHT HOLDERS + * 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. + * + **********************************************************/ + + +#ifndef _ST_API_H_ +#define _ST_API_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" + +/** + * \file API for communication between state trackers and state tracker + * managers. + * + * While both are state tackers, we use the term state tracker for rendering + * APIs such as OpenGL or OpenVG, and state tracker manager for window system + * APIs such as EGL or GLX in this file. + * + * This file defines an API to be implemented by both state trackers and state + * tracker managers. + */ + +/** + * The entry points of the state trackers. + */ +#define ST_MODULE_OPENGL_SYMBOL "st_module_OpenGL" +#define ST_MODULE_OPENGL_ES1_SYMBOL "st_module_OpenGL_ES1" +#define ST_MODULE_OPENGL_ES2_SYMBOL "st_module_OpenGL_ES2" +#define ST_MODULE_OPENVG_SYMBOL "st_module_OpenVG" + +/** + * The supported rendering API of a state tracker. + */ +enum st_api_type { + ST_API_OPENGL, + ST_API_OPENGL_ES1, + ST_API_OPENGL_ES2, + ST_API_OPENVG, + + ST_API_COUNT +}; + +/** + * Used in st_context_iface->teximage. + */ +enum st_texture_type { + ST_TEXTURE_1D, + ST_TEXTURE_2D, + ST_TEXTURE_3D, + ST_TEXTURE_RECT, +}; + +/** + * Available attachments of framebuffer. + */ +enum st_attachment_type { + ST_ATTACHMENT_FRONT_LEFT, + ST_ATTACHMENT_BACK_LEFT, + ST_ATTACHMENT_FRONT_RIGHT, + ST_ATTACHMENT_BACK_RIGHT, + ST_ATTACHMENT_DEPTH_STENCIL, + ST_ATTACHMENT_ACCUM, + ST_ATTACHMENT_SAMPLE, + + ST_ATTACHMENT_COUNT, + ST_ATTACHMENT_INVALID = -1 +}; + +/* for buffer_mask in st_visual */ +#define ST_ATTACHMENT_FRONT_LEFT_MASK (1 << ST_ATTACHMENT_FRONT_LEFT) +#define ST_ATTACHMENT_BACK_LEFT_MASK (1 << ST_ATTACHMENT_BACK_LEFT) +#define ST_ATTACHMENT_FRONT_RIGHT_MASK (1 << ST_ATTACHMENT_FRONT_RIGHT) +#define ST_ATTACHMENT_BACK_RIGHT_MASK (1 << ST_ATTACHMENT_BACK_RIGHT) +#define ST_ATTACHMENT_DEPTH_STENCIL_MASK (1 << ST_ATTACHMENT_DEPTH_STENCIL) +#define ST_ATTACHMENT_ACCUM_MASK (1 << ST_ATTACHMENT_ACCUM) +#define ST_ATTACHMENT_SAMPLE_MASK (1 << ST_ATTACHMENT_SAMPLE) + +/** + * Enumerations of state tracker context resources. + */ +enum st_context_resource_type { + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_2D, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_3D, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_X, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_X, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Y, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Z, + ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Z, + ST_CONTEXT_RESOURCE_OPENGL_RENDERBUFFER, + ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE, +}; + +/** + * The return type of st_api->get_proc_address. + */ +typedef void (*st_proc_t)(void); + +struct pipe_context; +struct pipe_texture; +struct pipe_fence_handle; + +/** + * Used in st_context_iface->get_resource_for_egl_image. + */ +struct st_context_resource +{ + /* these fields are filled by the caller */ + enum st_context_resource_type type; + void *resource; + + /* this is owned by the caller */ + struct pipe_texture *texture; +}; + +/** + * Used in st_manager_iface->get_egl_image. + */ +struct st_egl_image +{ + /* these fields are filled by the caller */ + struct st_context_iface *stctxi; + void *egl_image; + + /* this is owned by the caller */ + struct pipe_texture *texture; + + unsigned face; + unsigned level; + unsigned zslice; +}; + +/** + * Represent the visual of a framebuffer. + */ +struct st_visual +{ + /** + * Available buffers. Tested with ST_FRAMEBUFFER_*_MASK. + */ + unsigned buffer_mask; + + /** + * Buffer formats. The formats are always set even when the buffer is + * not available. + */ + enum pipe_format color_format; + enum pipe_format depth_stencil_format; + enum pipe_format accum_format; + int samples; + + /** + * Desired render buffer. + */ + enum st_attachment_type render_buffer; +}; + +/** + * Represent a windowing system drawable. + * + * The framebuffer is implemented by the state tracker manager and + * used by the state trackers. + * + * Instead of the winsys pokeing into the API context to figure + * out what buffers that might be needed in the future by the API + * context, it calls into the framebuffer to get the textures. + * + * This structure along with the notify_invalid_framebuffer + * allows framebuffers to be shared between different threads + * but at the same make the API context free from thread + * syncronisation primitves, with the exception of a small + * atomic flag used for notification of framebuffer dirty status. + * + * The thread syncronisation is put inside the framebuffer + * and only called once the framebuffer has become dirty. + */ +struct st_framebuffer_iface +{ + /** + * Available for the state tracker manager to use. + */ + void *st_manager_private; + + /** + * The visual of a framebuffer. + */ + const struct st_visual *visual; + + /** + * Flush the front buffer. + * + * On some window systems, changes to the front buffers are not immediately + * visible. They need to be flushed. + * + * @att is one of the front buffer attachments. + */ + boolean (*flush_front)(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt); + + /** + * The state tracker asks for the textures it needs. + * + * It should try to only ask for attachments that it currently renders + * to, thus allowing the winsys to delay the allocation of textures not + * needed. For example front buffer attachments are not needed if you + * only do back buffer rendering. + * + * The implementor of this function needs to also ensure + * thread safty as this call might be done from multiple threads. + * + * The returned textures are owned by the caller. They should be + * unreferenced when no longer used. If this function is called multiple + * times with different sets of attachments, those buffers not included in + * the last call might be destroyed. This behavior might change in the + * future. + */ + boolean (*validate)(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_texture **out); +}; + +/** + * Represent a rendering context. + * + * This entity is created from st_api and used by the state tracker manager. + */ +struct st_context_iface +{ + /** + * Available for the state tracker and the manager to use. + */ + void *st_context_private; + void *st_manager_private; + + /** + * Destroy the context. + */ + void (*destroy)(struct st_context_iface *stctxi); + + /** + * Invalidate the current textures that was taken from a framebuffer. + * + * The state tracker manager calls this function to let the rendering + * context know that it should update the textures it got from + * st_framebuffer_iface::validate. It should do so at the latest time possible. + * Possible right before sending triangles to the pipe context. + * + * For certain platforms this function might be called from a thread other + * than the thread that the context is currently bound in, and must + * therefore be thread safe. But it is the state tracker manager's + * responsibility to make sure that the framebuffer is bound to the context + * and the API context is current for the duration of this call. + * + * Thus reducing the sync primitive needed to a single atomic flag. + */ + void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stfbi); + + /** + * Flush all drawing from context to the pipe also flushes the pipe. + */ + void (*flush)(struct st_context_iface *stctxi, unsigned flags, + struct pipe_fence_handle **fence); + + /** + * Replace the texture image of a texture object at the specified level. + * + * This function is optional. + */ + boolean (*teximage)(struct st_context_iface *stctxi, enum st_texture_type target, + int level, enum pipe_format internal_format, + struct pipe_texture *tex, boolean mipmap); + + /** + * Used to implement glXCopyContext. + */ + void (*copy)(struct st_context_iface *stctxi, + struct st_context_iface *stsrci, unsigned mask); + + /** + * Look up and return the info of a resource for EGLImage. + * + * This function is optional. + */ + boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi, + struct st_context_resource *stres); +}; + + +/** + * Represent a state tracker manager. + * + * This interface is implemented by the state tracker manager. It corresponds + * to a "display" in the window system. + */ +struct st_manager +{ + struct pipe_screen *screen; + + /** + * Look up and return the info of an EGLImage. + * + * This function is optional. + */ + boolean (*get_egl_image)(struct st_manager *smapi, + struct st_egl_image *stimg); +}; + +/** + * Represent a rendering API such as OpenGL or OpenVG. + * + * Implemented by the state tracker and used by the state tracker manager. + */ +struct st_api +{ + /** + * Destroy the API. + */ + void (*destroy)(struct st_api *stapi); + + /** + * Return an API entry point. + * + * For GL this is the same as _glapi_get_proc_address. + */ + st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname); + + /** + * Return true if the visual is supported by the state tracker. + */ + boolean (*is_visual_supported)(struct st_api *stapi, + const struct st_visual *visual); + + /** + * Create a rendering context. + */ + struct st_context_iface *(*create_context)(struct st_api *stapi, + struct st_manager *smapi, + const struct st_visual *visual, + struct st_context_iface *stsharei); + + /** + * Bind the context to the calling thread with draw and read as drawables. + * + * The framebuffers might have different visuals than the context does. + */ + boolean (*make_current)(struct st_api *stapi, + struct st_context_iface *stctxi, + struct st_framebuffer_iface *stdrawi, + struct st_framebuffer_iface *streadi); + + /** + * Get the currently bound context in the calling thread. + */ + struct st_context_iface *(*get_current)(struct st_api *stapi); +}; + +/** + * Represent a state tracker. + * + * This is the entry point of a state tracker. + */ +struct st_module +{ + enum st_api_type api; + struct st_api *(*create_api)(void); +}; + +/** + * Return true if the visual has the specified buffers. + */ +static INLINE boolean +st_visual_have_buffers(const struct st_visual *visual, unsigned mask) +{ + return ((visual->buffer_mask & mask) == mask); +} + +/* these symbols may need to be dynamically lookup up */ +extern PUBLIC const struct st_module st_module_OpenGL; +extern PUBLIC const struct st_module st_module_OpenGL_ES1; +extern PUBLIC const struct st_module st_module_OpenGL_ES2; +extern PUBLIC const struct st_module st_module_OpenVG; + +#endif /* _ST_API_H_ */ From 8bcd616a3ffd040ef28b61b38b22da2dad9e2242 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 14 Jan 2010 12:19:32 +0800 Subject: [PATCH 036/483] st/vega: Implement st_api.h. There is currently no user of this new interface. As the inteface can coexist with st_public.h, everthing should work as before. --- src/gallium/state_trackers/vega/Makefile | 1 + src/gallium/state_trackers/vega/api_context.c | 3 + src/gallium/state_trackers/vega/api_masks.c | 4 - src/gallium/state_trackers/vega/vg_context.c | 3 + src/gallium/state_trackers/vega/vg_context.h | 7 + src/gallium/state_trackers/vega/vg_manager.c | 373 ++++++++++++++++++ src/gallium/state_trackers/vega/vg_manager.h | 40 ++ 7 files changed, 427 insertions(+), 4 deletions(-) create mode 100644 src/gallium/state_trackers/vega/vg_manager.c create mode 100644 src/gallium/state_trackers/vega/vg_manager.h diff --git a/src/gallium/state_trackers/vega/Makefile b/src/gallium/state_trackers/vega/Makefile index 7f04b2aa832..7c315de8271 100644 --- a/src/gallium/state_trackers/vega/Makefile +++ b/src/gallium/state_trackers/vega/Makefile @@ -25,6 +25,7 @@ VG_SOURCES = \ api_transform.c \ vgu.c \ vg_context.c \ + vg_manager.c \ vg_state.c \ vg_tracker.c \ vg_translate.c \ diff --git a/src/gallium/state_trackers/vega/api_context.c b/src/gallium/state_trackers/vega/api_context.c index 47db102dd2d..eb2fbe26e7f 100644 --- a/src/gallium/state_trackers/vega/api_context.c +++ b/src/gallium/state_trackers/vega/api_context.c @@ -26,6 +26,7 @@ #include "VG/openvg.h" +#include "vg_manager.h" #include "vg_context.h" #include "pipe/p_context.h" @@ -55,6 +56,8 @@ void vgFlush(void) pipe = ctx->pipe; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + + vg_manager_flush_frontbuffer(ctx); } void vgFinish(void) diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 7eb5ea1f078..2f2d925252d 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -117,10 +117,6 @@ clear_with_quad(struct vg_context *st, float x0, float y0, x1, y1); */ - if (st->pipe->screen && st->pipe->screen->update_buffer) - st->pipe->screen->update_buffer( st->pipe->screen, - st->pipe->priv ); - cso_save_blend(st->cso_context); cso_save_rasterizer(st->cso_context); cso_save_fragment_shader(st->cso_context); diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 170391ec031..7769112a31e 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -32,6 +32,7 @@ #include "shader.h" #include "asm_util.h" #include "st_inlines.h" +#include "vg_manager.h" #include "pipe/p_context.h" #include "util/u_inlines.h" @@ -305,6 +306,8 @@ static void update_clip_state(struct vg_context *ctx) void vg_validate_state(struct vg_context *ctx) { + vg_manager_validate_framebuffer(ctx); + if ((ctx->state.dirty & BLEND_DIRTY)) { struct pipe_blend_state *blend = &ctx->state.g3d.blend; memset(blend, 0, sizeof(struct pipe_blend_state)); diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index 804e9e76d77..17c7d2ad1c5 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -33,6 +33,7 @@ #include "pipe/p_state.h" #include "util/u_pointer.h" #include "util/u_math.h" +#include "state_tracker/st_api.h" #include "cso_cache/cso_hash.h" #include "cso_cache/cso_context.h" @@ -58,6 +59,9 @@ struct st_framebuffer { struct pipe_texture *blend_texture; + struct st_framebuffer_iface *iface; + enum st_attachment_type strb_att; + void *privateData; }; @@ -84,6 +88,8 @@ enum dirty_state { struct vg_context { + struct st_context_iface iface; + struct pipe_context *pipe; struct { @@ -101,6 +107,7 @@ struct vg_context VGErrorCode _error; struct st_framebuffer *draw_buffer; + int32_t draw_buffer_invalid; struct cso_hash *owned_objects[VG_OBJECT_LAST]; diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c new file mode 100644 index 00000000000..25c2e853f2a --- /dev/null +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -0,0 +1,373 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "state_tracker/st_api.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "util/u_memory.h" +#include "util/u_inlines.h" + +#include "vg_manager.h" +#include "vg_context.h" +#include "vg_tracker.h" /* for st_resize_framebuffer */ +#include "image.h" + +/** + * Flush the front buffer if the current context renders to the front buffer. + */ +void +vg_manager_flush_frontbuffer(struct vg_context *ctx) +{ + struct st_framebuffer *stfb = ctx->draw_buffer; + + if (!stfb) + return; + + /* st_public.h is used */ + if (!stfb->iface) { + struct pipe_screen *screen = ctx->pipe->screen; + if (screen->flush_frontbuffer) { + screen->flush_frontbuffer(screen, + stfb->strb->surface, ctx->pipe->priv); + } + return; + } + + switch (stfb->strb_att) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + stfb->iface->flush_front(stfb->iface, stfb->strb_att); + break; + default: + break; + } +} + +/** + * Re-validate the framebuffer. + */ +void +vg_manager_validate_framebuffer(struct vg_context *ctx) +{ + struct pipe_screen *screen = ctx->pipe->screen; + struct st_framebuffer *stfb = ctx->draw_buffer; + struct st_renderbuffer *rb; + struct pipe_texture *pt; + + /* no binding surface */ + if (!stfb) + return; + + /* st_public.h is used */ + if (!stfb->iface) { + struct pipe_screen *screen = ctx->pipe->screen; + if (screen->update_buffer) + screen->update_buffer(screen, ctx->pipe->priv); + return; + } + + if (!p_atomic_read(&ctx->draw_buffer_invalid)) + return; + + /* validate the fb */ + if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt) + return; + + rb = stfb->strb; + if (rb->texture == pt) { + pipe_texture_reference(&pt, NULL); + return; + } + + /* unreference existing ones */ + pipe_surface_reference(&rb->surface, NULL); + pipe_texture_reference(&rb->texture, NULL); + + rb->texture = pt; + rb->surface = screen->get_tex_surface(screen, rb->texture, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); + + rb->width = rb->surface->width; + rb->height = rb->surface->height; + + st_resize_framebuffer(stfb, rb->width, rb->height); + + p_atomic_set(&ctx->draw_buffer_invalid, FALSE); +} + + +static void +vg_context_notify_invalid_framebuffer(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stfbi) +{ + struct vg_context *ctx = (struct vg_context *) stctxi; + p_atomic_set(&ctx->draw_buffer_invalid, TRUE); +} + +static void +vg_context_flush(struct st_context_iface *stctxi, unsigned flags, + struct pipe_fence_handle **fence) +{ + struct vg_context *ctx = (struct vg_context *) stctxi; + ctx->pipe->flush(ctx->pipe, flags, fence); + if (flags & PIPE_FLUSH_RENDER_CACHE) + vg_manager_flush_frontbuffer(ctx); +} + +static void +vg_context_destroy(struct st_context_iface *stctxi) +{ + struct vg_context *ctx = (struct vg_context *) stctxi; + vg_destroy_context(ctx); +} + +static struct st_context_iface * +vg_api_create_context(struct st_api *stapi, struct st_manager *smapi, + const struct st_visual *visual, + struct st_context_iface *shared_stctxi) +{ + struct vg_context *shared_ctx = (struct vg_context *) shared_stctxi; + struct vg_context *ctx; + struct pipe_context *pipe; + + pipe = smapi->screen->context_create(smapi->screen, NULL); + if (!pipe) + return NULL; + ctx = vg_create_context(pipe, NULL, shared_ctx); + if (!ctx) { + pipe->destroy(pipe); + return NULL; + } + + ctx->iface.destroy = vg_context_destroy; + + ctx->iface.notify_invalid_framebuffer = + vg_context_notify_invalid_framebuffer; + ctx->iface.flush = vg_context_flush; + + ctx->iface.teximage = NULL; + ctx->iface.copy = NULL; + + ctx->iface.st_context_private = (void *) smapi; + + return &ctx->iface; +} + +static struct st_renderbuffer * +create_renderbuffer(enum pipe_format format) +{ + struct st_renderbuffer *strb; + + strb = CALLOC_STRUCT(st_renderbuffer); + if (strb) + strb->format = format; + + return strb; +} + +static void +destroy_renderbuffer(struct st_renderbuffer *strb) +{ + pipe_surface_reference(&strb->surface, NULL); + pipe_texture_reference(&strb->texture, NULL); + free(strb); +} + +/** + * Decide the buffer to render to. + */ +static enum st_attachment_type +choose_attachment(struct st_framebuffer_iface *stfbi) +{ + enum st_attachment_type statt; + + statt = stfbi->visual->render_buffer; + if (statt != ST_ATTACHMENT_INVALID) { + /* use the buffer given by the visual, unless it is unavailable */ + if (!st_visual_have_buffers(stfbi->visual, 1 << statt)) { + switch (statt) { + case ST_ATTACHMENT_BACK_LEFT: + statt = ST_ATTACHMENT_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + statt = ST_ATTACHMENT_FRONT_RIGHT; + break; + default: + break; + } + + if (!st_visual_have_buffers(stfbi->visual, 1 << statt)) + statt = ST_ATTACHMENT_INVALID; + } + } + + return statt; +} + +/** + * Bind the context to the given framebuffers. + */ +static boolean +vg_context_bind_framebuffers(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stdrawi, + struct st_framebuffer_iface *streadi) +{ + struct vg_context *ctx = (struct vg_context *) stctxi; + struct st_framebuffer *stfb; + enum st_attachment_type strb_att; + + /* the draw and read framebuffers must be the same */ + if (stdrawi != streadi) + return FALSE; + + p_atomic_set(&ctx->draw_buffer_invalid, TRUE); + + strb_att = (stdrawi) ? choose_attachment(stdrawi) : ST_ATTACHMENT_INVALID; + + if (ctx->draw_buffer) { + stfb = ctx->draw_buffer; + + /* free the existing fb */ + if (!stdrawi || + stfb->strb_att != strb_att || + stfb->strb->format != stdrawi->visual->color_format || + stfb->dsrb->format != stdrawi->visual->depth_stencil_format) { + destroy_renderbuffer(stfb->strb); + destroy_renderbuffer(stfb->dsrb); + free(stfb); + + ctx->draw_buffer = NULL; + } + } + + if (!stdrawi) + return TRUE; + + if (strb_att == ST_ATTACHMENT_INVALID) + return FALSE; + + /* create a new fb */ + if (!ctx->draw_buffer) { + stfb = CALLOC_STRUCT(st_framebuffer); + if (!stfb) + return FALSE; + + stfb->strb = create_renderbuffer(stdrawi->visual->color_format); + if (!stfb->strb) { + free(stfb); + return FALSE; + } + + stfb->dsrb = create_renderbuffer(stdrawi->visual->depth_stencil_format); + if (!stfb->dsrb) { + free(stfb->strb); + free(stfb); + return FALSE; + } + + stfb->width = 0; + stfb->height = 0; + stfb->strb_att = strb_att; + + ctx->draw_buffer = stfb; + } + + ctx->draw_buffer->iface = stdrawi; + + return TRUE; +} + +static boolean +vg_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, + struct st_framebuffer_iface *stdrawi, + struct st_framebuffer_iface *streadi) +{ + struct vg_context *ctx = (struct vg_context *) stctxi; + + if (stctxi) + vg_context_bind_framebuffers(stctxi, stdrawi, streadi); + vg_set_current_context(ctx); + + return TRUE; +} + +static struct st_context_iface * +vg_api_get_current(struct st_api *stapi) +{ + struct vg_context *ctx = vg_current_context(); + + return (ctx) ? &ctx->iface : NULL; +} + +static boolean +vg_api_is_visual_supported(struct st_api *stapi, + const struct st_visual *visual) +{ + /* the impl requires a depth/stencil buffer */ + if (visual->depth_stencil_format == PIPE_FORMAT_NONE) + return FALSE; + + return TRUE; +} + +static st_proc_t +vg_api_get_proc_address(struct st_api *stapi, const char *procname) +{ + /* TODO */ + return (st_proc_t) NULL; +} + +static void +vg_api_destroy(struct st_api *stapi) +{ + free(stapi); +} + +static struct st_api * +vg_module_create_api(void) +{ + struct st_api *stapi; + + stapi = CALLOC_STRUCT(st_api); + if (stapi) { + stapi->destroy = vg_api_destroy; + stapi->get_proc_address = vg_api_get_proc_address; + stapi->is_visual_supported = vg_api_is_visual_supported; + + stapi->create_context = vg_api_create_context; + stapi->make_current = vg_api_make_current; + stapi->get_current = vg_api_get_current; + } + + return stapi; +} + +PUBLIC const struct st_module st_module_OpenVG = { + .api = ST_API_OPENVG, + .create_api = vg_module_create_api, +}; diff --git a/src/gallium/state_trackers/vega/vg_manager.h b/src/gallium/state_trackers/vega/vg_manager.h new file mode 100644 index 00000000000..1a276c0f35e --- /dev/null +++ b/src/gallium/state_trackers/vega/vg_manager.h @@ -0,0 +1,40 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef VG_MANAGER_H +#define VG_MANAGER_H + +#include "state_tracker/st_api.h" +#include "vg_context.h" + +void +vg_manager_flush_frontbuffer(struct vg_context *ctx); + +void +vg_manager_validate_framebuffer(struct vg_context *ctx); + +#endif /* VG_MANAGER_H */ From de8a879f5c77dbf5c31251e07b2f1b8d2635716c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 7 Feb 2010 19:20:52 +0800 Subject: [PATCH 037/483] st/mesa: Implement st_api.h. There is currently no user of this new interface. As the inteface can coexist with st_public.h, everthing should work as before. ST_TEXTURE_2D is both defined by st_public.h and st_api.h. Reorder the headers in st/dri to avoid conflicts. --- src/gallium/state_trackers/dri/dri_context.c | 1 - src/gallium/state_trackers/dri/dri_drawable.c | 2 +- src/mesa/SConscript | 1 + src/mesa/sources.mak | 1 + src/mesa/state_tracker/st_atom.c | 5 +- src/mesa/state_tracker/st_cb_fbo.c | 18 +- src/mesa/state_tracker/st_cb_flush.c | 6 +- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_context.h | 8 + src/mesa/state_tracker/st_manager.c | 781 ++++++++++++++++++ src/mesa/state_tracker/st_manager.h | 47 ++ 11 files changed, 861 insertions(+), 11 deletions(-) create mode 100644 src/mesa/state_tracker/st_manager.c create mode 100644 src/mesa/state_tracker/st_manager.h diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 2f991c39e33..75ac2e8adae 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -35,7 +35,6 @@ #include "state_tracker/drm_api.h" #include "state_tracker/dri1_api.h" #include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" #include "pipe/p_context.h" #include "dri_context.h" diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 458473853cf..c400725c7f2 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -39,8 +39,8 @@ #include "main/renderbuffer.h" #include "state_tracker/drm_api.h" #include "state_tracker/dri1_api.h" -#include "state_tracker/st_public.h" #include "state_tracker/st_context.h" +#include "state_tracker/st_public.h" #include "state_tracker/st_cb_fbo.h" #include "util/u_format.h" diff --git a/src/mesa/SConscript b/src/mesa/SConscript index e80ec5ee880..4db2c215d0a 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -182,6 +182,7 @@ if env['platform'] != 'winddk': 'state_tracker/st_format.c', 'state_tracker/st_framebuffer.c', 'state_tracker/st_gen_mipmap.c', + 'state_tracker/st_manager.c', 'state_tracker/st_mesa_to_tgsi.c', 'state_tracker/st_program.c', 'state_tracker/st_texture.c', diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 74885548e5a..0c16fcb444c 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -213,6 +213,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_format.c \ state_tracker/st_framebuffer.c \ state_tracker/st_gen_mipmap.c \ + state_tracker/st_manager.c \ state_tracker/st_mesa_to_tgsi.c \ state_tracker/st_program.c \ state_tracker/st_texture.c diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 7806df4a531..9fa4dae5ca9 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -34,6 +34,7 @@ #include "st_atom.h" #include "st_cb_bitmap.h" #include "st_program.h" +#include "st_manager.h" #include "pipe/p_context.h" @@ -136,9 +137,7 @@ void st_validate_state( struct st_context *st ) check_program_state( st ); - if (st->pipe->screen->update_buffer) - st->pipe->screen->update_buffer(st->pipe->screen, - st->pipe->priv); + st_manager_validate_framebuffers(st); if (state->st == 0) return; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index abf0c8d6cb1..114a8596adf 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -48,6 +48,7 @@ #include "st_format.h" #include "st_public.h" #include "st_texture.h" +#include "st_manager.h" #include "util/u_format.h" #include "util/u_rect.h" @@ -614,8 +615,18 @@ check_create_front_buffers(GLcontext *ctx, struct gl_framebuffer *fb) static void st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) { + GLframebuffer *fb = ctx->DrawBuffer; + GLuint i; + (void) count; (void) buffers; + + /* add the renderbuffers on demand */ + for (i = 0; i < fb->_NumColorDrawBuffers; i++) { + gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i]; + st_manager_add_color_renderbuffer(ctx->st, fb, idx); + } + check_create_front_buffers(ctx, ctx->DrawBuffer); } @@ -626,8 +637,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) static void st_ReadBuffer(GLcontext *ctx, GLenum buffer) { + GLframebuffer *fb = ctx->ReadBuffer; + (void) buffer; - check_create_front_buffers(ctx, ctx->ReadBuffer); + + /* add the renderbuffer on demand */ + st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex); + check_create_front_buffers(ctx, fb); } diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 28a384ba49b..30e7afcf2a3 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -40,6 +40,7 @@ #include "st_cb_clear.h" #include "st_cb_fbo.h" #include "st_public.h" +#include "st_manager.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" @@ -74,12 +75,9 @@ display_front_buffer(struct st_context *st) = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); if (strb) { - struct pipe_surface *front_surf = strb->surface; - /* Hook for copying "fake" frontbuffer if necessary: */ - st->pipe->screen->flush_frontbuffer( st->pipe->screen, front_surf, - st->winsys_drawable_handle ); + st_manager_flush_frontbuffer(st); /* st->frontbuffer_status = FRONT_STATUS_UNDEFINED; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index ca6d4dfb069..7c1a0b8bc54 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -30,9 +30,9 @@ #include "vbo/vbo.h" #include "shader/shader_api.h" #include "glapi/glapi.h" +#include "st_context.h" #include "st_public.h" #include "st_debug.h" -#include "st_context.h" #include "st_cb_accum.h" #include "st_cb_bitmap.h" #include "st_cb_blit.h" diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index e2d34fb3d10..2d81c4ca631 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -31,6 +31,7 @@ #include "main/mtypes.h" #include "shader/prog_cache.h" #include "pipe/p_state.h" +#include "state_tracker/st_api.h" struct st_context; @@ -73,6 +74,8 @@ struct st_tracked_state { struct st_context { + struct st_context_iface iface; + GLcontext *ctx; struct pipe_context *pipe; @@ -206,6 +209,11 @@ struct st_framebuffer GLframebuffer Base; void *Private; GLuint InitWidth, InitHeight; + + struct st_framebuffer_iface *iface; + enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; + unsigned num_statts; + int32_t revalidate; }; diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c new file mode 100644 index 00000000000..6c3cde09683 --- /dev/null +++ b/src/mesa/state_tracker/st_manager.c @@ -0,0 +1,781 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "state_tracker/st_api.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "util/u_format.h" +#include "util/u_pointer.h" +#include "util/u_inlines.h" +#include "util/u_atomic.h" + +#include "main/mtypes.h" +#include "main/context.h" +#include "main/texobj.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "main/texfetch.h" +#include "main/fbobject.h" +#include "main/framebuffer.h" +#include "main/renderbuffer.h" +#include "st_texture.h" + +#include "st_context.h" +#include "st_format.h" +#include "st_cb_fbo.h" +#include "st_manager.h" + +/* these functions are defined in st_context.c */ +struct st_context * +st_create_context(struct pipe_context *pipe, + const __GLcontextModes *visual, + struct st_context *share); +void st_destroy_context(struct st_context *st); +void st_flush(struct st_context *st, uint pipeFlushFlags, + struct pipe_fence_handle **fence); + +/** + * Map an attachment to a buffer index. + */ +static INLINE gl_buffer_index +attachment_to_buffer_index(enum st_attachment_type statt) +{ + gl_buffer_index index; + + switch (statt) { + case ST_ATTACHMENT_FRONT_LEFT: + index = BUFFER_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + index = BUFFER_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + index = BUFFER_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + index = BUFFER_BACK_RIGHT; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + index = BUFFER_DEPTH; + break; + case ST_ATTACHMENT_ACCUM: + index = BUFFER_ACCUM; + break; + case ST_ATTACHMENT_SAMPLE: + default: + index = BUFFER_COUNT; + break; + } + + return index; +} + +/** + * Map a buffer index to an attachment. + */ +static INLINE enum st_attachment_type +buffer_index_to_attachment(gl_buffer_index index) +{ + enum st_attachment_type statt; + + switch (index) { + case BUFFER_FRONT_LEFT: + statt = ST_ATTACHMENT_FRONT_LEFT; + break; + case BUFFER_BACK_LEFT: + statt = ST_ATTACHMENT_BACK_LEFT; + break; + case BUFFER_FRONT_RIGHT: + statt = ST_ATTACHMENT_FRONT_RIGHT; + break; + case BUFFER_BACK_RIGHT: + statt = ST_ATTACHMENT_BACK_RIGHT; + break; + case BUFFER_DEPTH: + statt = ST_ATTACHMENT_DEPTH_STENCIL; + break; + case BUFFER_ACCUM: + statt = ST_ATTACHMENT_ACCUM; + break; + default: + statt = ST_ATTACHMENT_INVALID; + break; + } + + return statt; +} + +/** + * Validate a framebuffer and update the states of the context. + */ +static void +st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) +{ + struct pipe_screen *screen = st->pipe->screen; + struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; + uint width, height; + unsigned i; + boolean changed = FALSE; + + if (!p_atomic_read(&stfb->revalidate)) + return; + + /* validate the fb */ + if (!stfb->iface->validate(stfb->iface, stfb->statts, stfb->num_statts, textures)) + return; + + width = stfb->Base.Width; + height = stfb->Base.Height; + + for (i = 0; i < stfb->num_statts; i++) { + struct st_renderbuffer *strb; + struct pipe_surface *ps; + gl_buffer_index idx; + + if (!textures[i]) + continue; + + idx = attachment_to_buffer_index(stfb->statts[i]); + if (idx >= BUFFER_COUNT) { + pipe_texture_reference(&textures[i], NULL); + continue; + } + + strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer); + assert(strb); + if (strb->texture == textures[i]) { + pipe_texture_reference(&textures[i], NULL); + continue; + } + + ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); + if (ps) { + pipe_surface_reference(&strb->surface, ps); + pipe_texture_reference(&strb->texture, ps->texture); + /* ownership transfered */ + pipe_surface_reference(&ps, NULL); + + changed = TRUE; + + strb->Base.Width = strb->surface->width; + strb->Base.Height = strb->surface->height; + + width = strb->Base.Width; + height = strb->Base.Height; + } + + pipe_texture_reference(&textures[i], NULL); + } + + if (changed) { + st->dirty.st |= ST_NEW_FRAMEBUFFER; + _mesa_resize_framebuffer(st->ctx, &stfb->Base, width, height); + + assert(stfb->Base.Width == width); + assert(stfb->Base.Height == height); + } + + p_atomic_set(&stfb->revalidate, FALSE); +} + +/** + * Update the attachments to validate. + */ +static void +st_framebuffer_update_attachments(struct st_framebuffer *stfb) +{ + gl_buffer_index idx; + + stfb->num_statts = 0; + for (idx = 0; idx < BUFFER_COUNT; idx++) { + struct st_renderbuffer *strb; + enum st_attachment_type statt; + + strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer); + if (!strb || strb->software) + continue; + + statt = buffer_index_to_attachment(idx); + if (statt != ST_ATTACHMENT_INVALID && + st_visual_have_buffers(stfb->iface->visual, 1 << statt)) + stfb->statts[stfb->num_statts++] = statt; + } +} + +/** + * Add a renderbuffer to the framebuffer. + */ +static boolean +st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb, + gl_buffer_index idx) +{ + struct gl_renderbuffer *rb; + enum pipe_format format; + int samples; + boolean sw; + + /* do not distinguish depth/stencil buffers */ + if (idx == BUFFER_STENCIL) + idx = BUFFER_DEPTH; + + switch (idx) { + case BUFFER_DEPTH: + format = stfb->iface->visual->depth_stencil_format; + sw = FALSE; + break; + case BUFFER_ACCUM: + format = stfb->iface->visual->accum_format; + sw = TRUE; + break; + default: + format = stfb->iface->visual->color_format; + sw = FALSE; + break; + } + + if (format == PIPE_FORMAT_NONE) + return FALSE; + + samples = stfb->iface->visual->samples; + if (!samples) + samples = st_get_msaa(); + + rb = st_new_renderbuffer_fb(format, samples, sw); + if (!rb) + return FALSE; + + _mesa_add_renderbuffer(&stfb->Base, idx, rb); + if (idx == BUFFER_DEPTH) + _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb); + + return TRUE; +} + +/** + * Intialize a __GLcontextModes from a visual. + */ +static void +st_visual_to_context_mode(const struct st_visual *visual, + __GLcontextModes *mode) +{ + memset(mode, 0, sizeof(*mode)); + + if (st_visual_have_buffers(visual, ST_ATTACHMENT_BACK_LEFT_MASK)) + mode->doubleBufferMode = GL_TRUE; + if (st_visual_have_buffers(visual, + ST_ATTACHMENT_FRONT_RIGHT_MASK | ST_ATTACHMENT_BACK_RIGHT_MASK)) + mode->stereoMode = GL_TRUE; + + if (visual->color_format != PIPE_FORMAT_NONE) { + mode->rgbMode = GL_TRUE; + + mode->redBits = + util_format_get_component_bits(visual->color_format, + UTIL_FORMAT_COLORSPACE_RGB, 0); + mode->greenBits = + util_format_get_component_bits(visual->color_format, + UTIL_FORMAT_COLORSPACE_RGB, 1); + mode->blueBits = + util_format_get_component_bits(visual->color_format, + UTIL_FORMAT_COLORSPACE_RGB, 2); + mode->alphaBits = + util_format_get_component_bits(visual->color_format, + UTIL_FORMAT_COLORSPACE_RGB, 3); + + mode->rgbBits = mode->redBits + + mode->greenBits + mode->blueBits + mode->alphaBits; + } + + if (visual->depth_stencil_format != PIPE_FORMAT_NONE) { + mode->haveDepthBuffer = GL_TRUE; + mode->haveStencilBuffer = GL_TRUE; + + mode->depthBits = + util_format_get_component_bits(visual->depth_stencil_format, + UTIL_FORMAT_COLORSPACE_ZS, 0); + mode->stencilBits = + util_format_get_component_bits(visual->depth_stencil_format, + UTIL_FORMAT_COLORSPACE_ZS, 1); + } + + if (visual->accum_format != PIPE_FORMAT_NONE) { + mode->haveAccumBuffer = GL_TRUE; + + mode->accumRedBits = + util_format_get_component_bits(visual->accum_format, + UTIL_FORMAT_COLORSPACE_RGB, 0); + mode->accumGreenBits = + util_format_get_component_bits(visual->accum_format, + UTIL_FORMAT_COLORSPACE_RGB, 1); + mode->accumBlueBits = + util_format_get_component_bits(visual->accum_format, + UTIL_FORMAT_COLORSPACE_RGB, 2); + mode->accumAlphaBits = + util_format_get_component_bits(visual->accum_format, + UTIL_FORMAT_COLORSPACE_RGB, 3); + } + + if (visual->samples) { + mode->sampleBuffers = 1; + mode->samples = visual->samples; + } +} + +/** + * Determine the default draw or read buffer from a visual. + */ +static void +st_visual_to_default_buffer(const struct st_visual *visual, + GLenum *buffer, GLint *index) +{ + enum st_attachment_type statt; + GLenum buf; + gl_buffer_index idx; + + statt = visual->render_buffer; + /* do nothing if an invalid render buffer is specified */ + if (statt == ST_ATTACHMENT_INVALID || + !st_visual_have_buffers(visual, 1 << statt)) + return; + + switch (statt) { + case ST_ATTACHMENT_FRONT_LEFT: + buf = GL_FRONT_LEFT; + idx = BUFFER_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + buf = GL_BACK_LEFT; + idx = BUFFER_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + buf = GL_FRONT_RIGHT; + idx = BUFFER_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + buf = GL_BACK_RIGHT; + idx = BUFFER_BACK_RIGHT; + break; + default: + buf = GL_NONE; + idx = BUFFER_COUNT; + break; + } + + if (buf != GL_NONE) { + if (buffer) + *buffer = buf; + if (index) + *index = idx; + } +} + +/** + * Create a framebuffer from a manager interface. + */ +static struct st_framebuffer * +st_framebuffer_create(struct st_framebuffer_iface *stfbi) +{ + struct st_framebuffer *stfb; + __GLcontextModes mode; + gl_buffer_index idx; + + stfb = CALLOC_STRUCT(st_framebuffer); + if (!stfb) + return NULL; + + st_visual_to_context_mode(stfbi->visual, &mode); + _mesa_initialize_window_framebuffer(&stfb->Base, &mode); + + /* modify the draw/read buffers of the fb */ + st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorDrawBuffer[0], + &stfb->Base._ColorDrawBufferIndexes[0]); + st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorReadBuffer, + &stfb->Base._ColorReadBufferIndex); + + stfb->iface = stfbi; + + /* add the color buffer */ + idx = stfb->Base._ColorDrawBufferIndexes[0]; + if (!st_framebuffer_add_renderbuffer(stfb, idx)) { + FREE(stfb); + return NULL; + } + + st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH); + st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM); + + st_framebuffer_update_attachments(stfb); + + p_atomic_set(&stfb->revalidate, TRUE); + stfb->Base.Initialized = GL_TRUE; + + return stfb; +} + +/** + * Reference a framebuffer. + */ +static void +st_framebuffer_reference(struct st_framebuffer **ptr, + struct st_framebuffer *stfb) +{ + GLframebuffer *fb = &stfb->Base; + _mesa_reference_framebuffer((GLframebuffer **) ptr, fb); +} + +static void +st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stfbi) +{ + struct st_context *st = (struct st_context *) stctxi; + struct st_framebuffer *stfb; + + /* either draw or read winsys fb */ + stfb = (struct st_framebuffer *) st->ctx->WinSysDrawBuffer; + if (!stfb || stfb->iface != stfbi) + stfb = (struct st_framebuffer *) st->ctx->WinSysReadBuffer; + assert(stfb && stfb->iface == stfbi); + + p_atomic_set(&stfb->revalidate, TRUE); +} + +static void +st_context_flush(struct st_context_iface *stctxi, unsigned flags, + struct pipe_fence_handle **fence) +{ + struct st_context *st = (struct st_context *) stctxi; + st_flush(st, flags, fence); + if (flags & PIPE_FLUSH_RENDER_CACHE) + st_manager_flush_frontbuffer(st); +} + +static boolean +st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target, + int level, enum pipe_format internal_format, + struct pipe_texture *tex, boolean mipmap) +{ + struct st_context *st = (struct st_context *) stctxi; + GLcontext *ctx = st->ctx; + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + struct st_texture_object *stObj; + struct st_texture_image *stImage; + GLenum internalFormat; + + switch (target) { + case ST_TEXTURE_1D: + target = GL_TEXTURE_1D; + break; + case ST_TEXTURE_2D: + target = GL_TEXTURE_2D; + break; + case ST_TEXTURE_3D: + target = GL_TEXTURE_3D; + break; + case ST_TEXTURE_RECT: + target = GL_TEXTURE_RECTANGLE_ARB; + break; + default: + return FALSE; + break; + } + + if (util_format_get_component_bits(internal_format, + UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) + internalFormat = GL_RGBA; + else + internalFormat = GL_RGB; + + texObj = _mesa_select_tex_object(ctx, texUnit, target); + _mesa_lock_texture(ctx, texObj); + + stObj = st_texture_object(texObj); + /* switch to surface based */ + if (!stObj->surface_based) { + _mesa_clear_texture_object(ctx, texObj); + stObj->surface_based = GL_TRUE; + } + + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + stImage = st_texture_image(texImage); + if (tex) { + _mesa_init_teximage_fields(ctx, target, texImage, + tex->width0, tex->height0, 1, 0, internalFormat); + texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, + GL_RGBA, GL_UNSIGNED_BYTE); + _mesa_set_fetch_functions(texImage, 2); + } + else { + _mesa_clear_texture_image(ctx, texImage); + } + + pipe_texture_reference(&stImage->pt, tex); + + _mesa_dirty_texobj(ctx, texObj, GL_TRUE); + _mesa_unlock_texture(ctx, texObj); + + return TRUE; +} + +static void +st_context_destroy(struct st_context_iface *stctxi) +{ + struct st_context *st = (struct st_context *) stctxi; + st_destroy_context(st); +} + +static struct st_context_iface * +st_api_create_context(struct st_api *stapi, struct st_manager *smapi, + const struct st_visual *visual, + struct st_context_iface *shared_stctxi) +{ + struct st_context *shared_ctx = (struct st_context *) shared_stctxi; + struct st_context *st; + struct pipe_context *pipe; + __GLcontextModes mode; + + pipe = smapi->screen->context_create(smapi->screen, NULL); + if (!pipe) + return NULL; + + st_visual_to_context_mode(visual, &mode); + st = st_create_context(pipe, &mode, shared_ctx); + if (!st) { + pipe->destroy(pipe); + return NULL; + } + + st->iface.destroy = st_context_destroy; + + st->iface.notify_invalid_framebuffer = + st_context_notify_invalid_framebuffer; + st->iface.flush = st_context_flush; + + st->iface.teximage = st_context_teximage; + st->iface.copy = NULL; + + st->iface.st_context_private = (void *) smapi; + + return &st->iface; +} + +static boolean +st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, + struct st_framebuffer_iface *stdrawi, + struct st_framebuffer_iface *streadi) +{ + struct st_context *st = (struct st_context *) stctxi; + struct st_framebuffer *stdraw, *stread, *stfb; + boolean ret; + + _glapi_check_multithread(); + + if (st) { + /* reuse/create the draw fb */ + stfb = (struct st_framebuffer * ) st->ctx->DrawBuffer; + if (stfb && stfb->iface == stdrawi) { + stdraw = NULL; + st_framebuffer_reference(&stdraw, stfb); + } + else { + stdraw = st_framebuffer_create(stdrawi); + } + + /* reuse/create the read fb */ + stfb = (struct st_framebuffer * ) st->ctx->ReadBuffer; + if (!stfb || stfb->iface != streadi) + stfb = stdraw; + if (stfb && stfb->iface == streadi) { + stread = NULL; + st_framebuffer_reference(&stread, stfb); + } + else { + stread = st_framebuffer_create(streadi); + } + + if (stdraw && stread) { + st_framebuffer_validate(stdraw, st); + if (stread != stdraw) + st_framebuffer_validate(stread, st); + + /* modify the draw/read buffers of the context */ + st_visual_to_default_buffer(stdraw->iface->visual, + &st->ctx->Color.DrawBuffer[0], NULL); + st_visual_to_default_buffer(stread->iface->visual, + &st->ctx->Pixel.ReadBuffer, NULL); + + ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base); + } + else { + ret = FALSE; + } + + st_framebuffer_reference(&stdraw, NULL); + st_framebuffer_reference(&stread, NULL); + } + else { + ret = _mesa_make_current(NULL, NULL, NULL); + } + + return ret; +} + +static struct st_context_iface * +st_api_get_current(struct st_api *stapi) +{ + GET_CURRENT_CONTEXT(ctx); + struct st_context *st = (ctx) ? ctx->st : NULL; + + return (st) ? &st->iface : NULL; +} + +static boolean +st_api_is_visual_supported(struct st_api *stapi, + const struct st_visual *visual) +{ + return TRUE; +} + +static st_proc_t +st_api_get_proc_address(struct st_api *stapi, const char *procname) +{ + return (st_proc_t) _glapi_get_proc_address(procname); +} + +static void +st_api_destroy(struct st_api *stapi) +{ + FREE(stapi); +} + +/** + * Flush the front buffer if the current context renders to the front buffer. + */ +void +st_manager_flush_frontbuffer(struct st_context *st) +{ + struct st_framebuffer *stfb = (struct st_framebuffer *) st->ctx->DrawBuffer; + struct st_renderbuffer *strb = NULL; + + if (stfb) + strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + if (!strb) + return; + + /* st_public.h or FBO */ + if (!stfb->iface) { + struct pipe_surface *front_surf = strb->surface; + st->pipe->screen->flush_frontbuffer(st->pipe->screen, + front_surf, st->winsys_drawable_handle); + return; + } + + stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT); +} + +/** + * Re-validate the framebuffer. + */ +void +st_manager_validate_framebuffers(struct st_context *st) +{ + struct st_framebuffer *stdraw, *stread; + + stdraw = (struct st_framebuffer *) st->ctx->DrawBuffer; + stread = (struct st_framebuffer *) st->ctx->ReadBuffer; + + /* st_public.h or FBO */ + if ((stdraw && !stdraw->iface) || (stread && !stread->iface)) { + struct pipe_screen *screen = st->pipe->screen; + if (screen->update_buffer) + screen->update_buffer(screen, st->pipe->priv); + return; + } + + if (stdraw) + st_framebuffer_validate(stdraw, st); + if (stread && stread != stdraw) + st_framebuffer_validate(stread, st); +} + +/** + * Add a color buffer on demand. + */ +boolean +st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, + gl_buffer_index idx) +{ + struct st_framebuffer *stfb = (struct st_framebuffer *) fb; + + if (stfb->Base.Attachment[idx].Renderbuffer) + return TRUE; + + /* st_public.h or FBO */ + if (!stfb->iface) + return FALSE; + + switch (idx) { + case BUFFER_FRONT_LEFT: + case BUFFER_BACK_LEFT: + case BUFFER_FRONT_RIGHT: + case BUFFER_BACK_RIGHT: + break; + default: + return FALSE; + break; + } + + if (!st_framebuffer_add_renderbuffer(stfb, idx)) + return FALSE; + + st_framebuffer_update_attachments(stfb); + st_invalidate_state(st->ctx, _NEW_BUFFERS); + + return TRUE; +} + +struct st_api * +st_manager_create_api(void) +{ + struct st_api *stapi; + + stapi = CALLOC_STRUCT(st_api); + if (stapi) { + stapi->destroy = st_api_destroy; + stapi->get_proc_address = st_api_get_proc_address; + stapi->is_visual_supported = st_api_is_visual_supported; + + stapi->create_context = st_api_create_context; + stapi->make_current = st_api_make_current; + stapi->get_current = st_api_get_current; + } + + return stapi; +} diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h new file mode 100644 index 00000000000..a3f51992237 --- /dev/null +++ b/src/mesa/state_tracker/st_manager.h @@ -0,0 +1,47 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef ST_MANAGER_H +#define ST_MANAGER_H + +#include "state_tracker/st_api.h" +#include "st_context.h" + +void +st_manager_flush_frontbuffer(struct st_context *st); + +void +st_manager_validate_framebuffers(struct st_context *st); + +boolean +st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, + gl_buffer_index idx); + +struct st_api * +st_manager_create_api(void); + +#endif /* ST_MANAGER_H */ From 3a3a31bf88c42890fbc2e4211981f97bd43dff4a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 7 Feb 2010 20:17:48 +0800 Subject: [PATCH 038/483] winsys/xlib, st/es: Advertise st_api.h support. This is done by defining one of st_module_OpenGL_ES1, st_module_OpenGL_ES2, and st_module_OpenGL. --- src/gallium/state_trackers/es/Makefile | 1 + src/gallium/state_trackers/es/st_es1.c | 7 ++++++- src/gallium/state_trackers/es/st_es2.c | 7 ++++++- src/gallium/targets/libgl-xlib/xlib.c | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile index b0365512719..e33685d2471 100644 --- a/src/gallium/state_trackers/es/Makefile +++ b/src/gallium/state_trackers/es/Makefile @@ -38,6 +38,7 @@ SYS_LIBS = -lm -pthread INCLUDE_DIRS = \ + -I$(TOP)/src/mesa \ -I$(TOP)/src/gallium/include .c.o: diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/state_trackers/es/st_es1.c index 25bc53b21eb..4e89e06b34c 100644 --- a/src/gallium/state_trackers/es/st_es1.c +++ b/src/gallium/state_trackers/es/st_es1.c @@ -1,3 +1,8 @@ -#include "pipe/p_compiler.h" +#include "state_tracker/st_manager.h" PUBLIC const int st_api_OpenGL_ES1 = 1; + +PUBLIC const struct st_module st_module_OpenGL_ES1 = { + .api = ST_API_OPENGL_ES1, + .create_api = st_manager_create_api +}; diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/state_trackers/es/st_es2.c index 171ea62b97f..82e88b176ac 100644 --- a/src/gallium/state_trackers/es/st_es2.c +++ b/src/gallium/state_trackers/es/st_es2.c @@ -1,3 +1,8 @@ -#include "pipe/p_compiler.h" +#include "state_tracker/st_manager.h" PUBLIC const int st_api_OpenGL_ES2 = 1; + +PUBLIC const struct st_module st_module_OpenGL_ES2 = { + .api = ST_API_OPENGL_ES2, + .create_api = st_manager_create_api +}; diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 05dc8db57d9..50dd99ffce1 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -39,9 +39,15 @@ #include "target-helpers/wrap_screen.h" #include "xm_public.h" +#include "state_tracker/st_manager.h" + /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; +PUBLIC const struct st_module st_module_OpenGL = { + .api = ST_API_OPENGL, + .create_api = st_manager_create_api +}; /* Helper function to build a subset of a driver stack consisting of * one of the software rasterizers (cell, llvmpipe, softpipe) and the From a924dd18c32bbc0056a799cf621dc2835644c16e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 14 Jan 2010 16:05:36 +0800 Subject: [PATCH 039/483] st/egl: Use st_api.h instead of st_public.h. Switch from st_public.h to st_api.h. The latter has intrinsic multiple APIs support and allows various EGLImage extensions to be supported. --- .../state_trackers/egl/common/egl_g3d.c | 562 ++++++------------ .../state_trackers/egl/common/egl_g3d.h | 24 +- .../state_trackers/egl/common/egl_g3d_st.c | 227 +++++++ .../egl/common/{egl_st.h => egl_g3d_st.h} | 86 +-- .../state_trackers/egl/common/egl_st.c | 131 ---- .../state_trackers/egl/common/st_public_tmp.h | 20 - 6 files changed, 474 insertions(+), 576 deletions(-) create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d_st.c rename src/gallium/state_trackers/egl/common/{egl_st.h => egl_g3d_st.h} (51%) delete mode 100644 src/gallium/state_trackers/egl/common/egl_st.c delete mode 100644 src/gallium/state_trackers/egl/common/st_public_tmp.h diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index e4972d493d6..783b8e56b38 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -36,234 +36,27 @@ #include "native.h" #include "egl_g3d.h" +#include "egl_g3d_st.h" #include "egl_g3d_image.h" -#include "egl_st.h" - -/** - * Validate the draw/read surfaces of the context. - */ -static void -egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct pipe_screen *screen = gdpy->native->screen; - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { - ST_SURFACE_FRONT_LEFT, - ST_SURFACE_BACK_LEFT, - ST_SURFACE_FRONT_RIGHT, - ST_SURFACE_BACK_RIGHT, - }; - EGLint num_surfaces, s; - - /* validate draw and/or read buffers */ - num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; - for (s = 0; s < num_surfaces; s++) { - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - EGLint att; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - if (!gctx->force_validate) { - unsigned int seq_num; - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &seq_num, NULL, NULL, NULL); - /* skip validation */ - if (gsurf->sequence_number == seq_num) - continue; - } - - pipe_surface_reference(&gsurf->render_surface, NULL); - memset(textures, 0, sizeof(textures)); - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &gsurf->sequence_number, textures, - &gsurf->base.Width, &gsurf->base.Height); - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct pipe_texture *pt = textures[att]; - struct pipe_surface *ps; - - if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { - ps = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, - st_att_map[att], ps); - - if (gsurf->render_att == att) - pipe_surface_reference(&gsurf->render_surface, ps); - - pipe_surface_reference(&ps, NULL); - pipe_texture_reference(&pt, NULL); - } - } - - gctx->stapi->st_resize_framebuffer(gbuf->st_fb, - gsurf->base.Width, gsurf->base.Height); - } - - gctx->force_validate = EGL_FALSE; - -} - -/** - * Create a st_framebuffer. - */ -static struct st_framebuffer * -create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - return gctx->stapi->st_create_framebuffer(&gconf->native->mode, - gconf->native->color_format, gconf->native->depth_format, - gconf->native->stencil_format, - gsurf->base.Width, gsurf->base.Height, &gsurf->base); -} - -/** - * Update the attachments of draw/read surfaces. - */ -static void -egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - EGLint s; - - /* route draw and read buffers' attachments */ - for (s = 0; s < 2; s++) { - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - gbuf->attachment_mask = (1 << gsurf->render_att); - - /* FIXME OpenGL defaults to draw the front or back buffer when the - * context is single-buffered or double-buffered respectively. In EGL, - * however, the buffer to be drawn is determined by the surface, instead - * of the context. As a result, rendering to a pixmap surface with a - * double-buffered context does not work as expected. - * - * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == - * NATIVE_ATTACHMENT_FRONT_LEFT); - */ - - /* - * FIXME If the back buffer is asked for here, and the front buffer is - * later needed by the client API (e.g. glDrawBuffer is called to draw - * the front buffer), it will create a new pipe texture and draw there. - * One fix is to ask for both buffers here, but it would be a waste if - * the front buffer is never used. A better fix is to add a callback to - * the pipe screen with context private (just like flush_frontbuffer). - */ - } -} - -/** - * Reallocate the context's framebuffers after draw/read surfaces change. - */ -static EGLBoolean -egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); - struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); - - /* unreference the old framebuffers */ - if (gctx->draw.st_fb) { - EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); - void *priv; - - priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); - if (!gdraw || priv != (void *) &gdraw->base) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - - if (is_equal) { - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - else { - priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); - if (!gread || priv != (void *) &gread->base) { - gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - } - } - - if (!gdraw) - return EGL_TRUE; - - /* create the draw fb */ - if (!gctx->draw.st_fb) { - gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); - if (!gctx->draw.st_fb) - return EGL_FALSE; - } - - /* create the read fb */ - if (!gctx->read.st_fb) { - if (gread != gdraw) { - gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); - if (!gctx->read.st_fb) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - return EGL_FALSE; - } - } - else { - /* there is no st_reference_framebuffer... */ - gctx->read.st_fb = gctx->draw.st_fb; - } - } - - egl_g3d_route_context(dpy, &gctx->base); - gctx->force_validate = EGL_TRUE; - - return EGL_TRUE; -} /** * Return the state tracker for the given context. */ -static const struct egl_g3d_st * +static struct st_api * egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) { struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - const struct egl_g3d_st *stapi; + struct st_api *stapi; EGLint idx = -1; switch (ctx->ClientAPI) { case EGL_OPENGL_ES_API: switch (ctx->ClientVersion) { case 1: - idx = EGL_G3D_ST_OPENGL_ES; + idx = ST_API_OPENGL_ES1; break; case 2: - idx = EGL_G3D_ST_OPENGL_ES2; + idx = ST_API_OPENGL_ES2; break; default: _eglLog(_EGL_WARNING, "unknown client version %d", @@ -272,10 +65,10 @@ egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) } break; case EGL_OPENVG_API: - idx = EGL_G3D_ST_OPENVG; + idx = ST_API_OPENVG; break; case EGL_OPENGL_API: - idx = EGL_G3D_ST_OPENGL; + idx = ST_API_OPENGL; break; default: _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); @@ -299,10 +92,10 @@ egl_g3d_init_st(_EGLDriver *drv) if (gdrv->api_mask) return; - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - gdrv->stapis[i] = egl_g3d_get_st(i); + for (i = 0; i < ST_API_COUNT; i++) { + gdrv->stapis[i] = egl_g3d_create_st_api(i); if (gdrv->stapis[i]) - gdrv->api_mask |= gdrv->stapis[i]->api_bit; + gdrv->api_mask |= egl_g3d_st_api_bit(i); } if (gdrv->api_mask) @@ -351,35 +144,6 @@ egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) } } -/** - * Return an API mask that consists of the state trackers that supports the - * given mode. - * - * FIXME add st_is_mode_supported()? - */ -static EGLint -get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) -{ - EGLint check; - - /* OpenGL ES 1.x and 2.x are checked together */ - check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; - if (api_mask & check) { - /* this is required by EGL, not by OpenGL ES */ - if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) - api_mask &= ~check; - } - - check = EGL_OPENVG_BIT; - if (api_mask & check) { - /* vega st needs the depth/stencil rb */ - if (!mode->depthBits && !mode->stencilBits) - api_mask &= ~check; - } - - return api_mask; -} - #ifdef EGL_MESA_screen_surface static void @@ -443,19 +207,89 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) #endif /* EGL_MESA_screen_surface */ +/** + * Initialize an EGL config from the native config. + */ +static EGLBoolean +egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const struct native_config *nconf) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + const __GLcontextModes *mode = &nconf->mode; + EGLint buffer_mask, api_mask; + EGLBoolean valid; + EGLint i; + + buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK; + if (mode->doubleBufferMode) + buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; + if (mode->stereoMode) { + buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; + if (mode->doubleBufferMode) + buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; + } + + gconf->stvis.buffer_mask = buffer_mask; + gconf->stvis.color_format = nconf->color_format; + gconf->stvis.depth_stencil_format = nconf->depth_format; + gconf->stvis.accum_format = PIPE_FORMAT_NONE; + gconf->stvis.samples = 0; + + gconf->stvis.render_buffer = (buffer_mask & ST_ATTACHMENT_BACK_LEFT) ? + ST_ATTACHMENT_BACK_LEFT : ST_ATTACHMENT_FRONT_LEFT; + + api_mask = 0; + for (i = 0; i < ST_API_COUNT; i++) { + struct st_api *stapi = gdrv->stapis[i]; + if (stapi) { + if (stapi->is_visual_supported(stapi, &gconf->stvis)) + api_mask |= egl_g3d_st_api_bit(i); + } + } + /* this is required by EGL, not by OpenGL ES */ + if ((mode->drawableType & GLX_WINDOW_BIT) && !mode->doubleBufferMode) + api_mask &= ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT); + + if (!api_mask) { + _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", + mode->visualID); + } + + valid = _eglConfigFromContextModesRec(&gconf->base, + mode, api_mask, api_mask); + if (valid) { +#ifdef EGL_MESA_screen_surface + /* check if scanout surface bit is set */ + if (nconf->scanout_bit) { + EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); + val |= EGL_SCREEN_BIT_MESA; + SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); + } +#endif + valid = _eglValidateConfig(&gconf->base, EGL_FALSE); + } + if (!valid) { + _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", mode->visualID); + return EGL_FALSE; + } + + gconf->native = nconf; + + return EGL_TRUE; +} + /** * Add configs to display and return the next config ID. */ static EGLint egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) { - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); struct egl_g3d_display *gdpy = egl_g3d_display(dpy); const struct native_config **native_configs; int num_configs, i; - native_configs = gdpy->native->get_configs(gdpy->native, - &num_configs); + native_configs = gdpy->native->get_configs(gdpy->native, &num_configs); if (!num_configs) { if (native_configs) free(native_configs); @@ -463,61 +297,25 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) } for (i = 0; i < num_configs; i++) { - EGLint api_mask; struct egl_g3d_config *gconf; - EGLBoolean valid; gconf = CALLOC_STRUCT(egl_g3d_config); - if (!gconf) - continue; - - _eglInitConfig(&gconf->base, dpy, id); - - api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); - if (!api_mask) { - _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", - native_configs[i]->mode.visualID); - } - - valid = _eglConfigFromContextModesRec(&gconf->base, - &native_configs[i]->mode, api_mask, api_mask); - if (valid) { -#ifdef EGL_MESA_screen_surface - /* check if scanout surface bit is set */ - if (native_configs[i]->scanout_bit) { - EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); - val |= EGL_SCREEN_BIT_MESA; - SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); + if (gconf) { + _eglInitConfig(&gconf->base, dpy, id); + if (!egl_g3d_init_config(drv, dpy, &gconf->base, native_configs[i])) { + free(gconf); + continue; } -#endif - valid = _eglValidateConfig(&gconf->base, EGL_FALSE); - } - if (!valid) { - _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", - native_configs[i]->mode.visualID); - free(gconf); - continue; - } - gconf->native = native_configs[i]; - _eglAddConfig(dpy, &gconf->base); - id++; + _eglAddConfig(dpy, &gconf->base); + id++; + } } free(native_configs); return id; } -/** - * Re-validate the context. - */ -static void -egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base); -} - static void egl_g3d_invalid_surface(struct native_display *ndpy, struct native_surface *nsurf, @@ -527,9 +325,8 @@ egl_g3d_invalid_surface(struct native_display *ndpy, struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data); struct egl_g3d_context *gctx = egl_g3d_context(gsurf->base.CurrentContext); - /* set force_validate to skip an unnecessary check */ if (gctx) - gctx->force_validate = TRUE; + gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gsurf->stfbi); } static struct native_event_handler egl_g3d_native_event_handler = { @@ -554,6 +351,9 @@ egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) free(dpy->Screens); } + if (gdpy->smapi) + egl_g3d_destroy_st_manager(gdpy->smapi); + if (gdpy->native) gdpy->native->destroy(gdpy->native); @@ -588,11 +388,17 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, } gdpy->native->user_data = (void *) dpy; - gdpy->native->screen->update_buffer = egl_g3d_update_buffer; egl_g3d_init_st(&gdrv->base); dpy->ClientAPIsMask = gdrv->api_mask; + gdpy->smapi = egl_g3d_create_st_manager(dpy); + if (!gdpy->smapi) { + _eglError(EGL_NOT_INITIALIZED, + "eglInitialize(failed to create st manager)"); + goto fail; + } + #ifdef EGL_MESA_screen_surface /* enable MESA_screen_surface before adding (and validating) configs */ if (gdpy->native->modeset) { @@ -629,7 +435,6 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, struct egl_g3d_context *gshare = egl_g3d_context(share); struct egl_g3d_config *gconf = egl_g3d_config(conf); struct egl_g3d_context *gctx; - const __GLcontextModes *mode; gctx = CALLOC_STRUCT(egl_g3d_context); if (!gctx) { @@ -648,24 +453,14 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, return NULL; } - mode = &gconf->native->mode; - - gctx->pipe = gdpy->native->screen->context_create( - gdpy->native->screen, - (void *) &gctx->base); - - if (!gctx->pipe) { + gctx->stctxi = gctx->stapi->create_context(gctx->stapi, gdpy->smapi, + &gconf->stvis, (gshare) ? gshare->stctxi : NULL); + if (!gctx->stctxi) { free(gctx); return NULL; } - gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, - (gshare) ? gshare->st_ctx : NULL); - if (!gctx->st_ctx) { - gctx->pipe->destroy(gctx->pipe); - free(gctx); - return NULL; - } + gctx->stctxi->st_manager_private = (void *) &gctx->base; return &gctx->base; } @@ -682,9 +477,7 @@ destroy_context(_EGLDisplay *dpy, _EGLContext *ctx) if (!dpy->Initialized) _eglLog(_EGL_FATAL, "destroy a context with an unitialized display"); - egl_g3d_realloc_context(dpy, &gctx->base); - /* it will destroy the associated pipe context */ - gctx->stapi->st_destroy_context(gctx->st_ctx); + gctx->stctxi->destroy(gctx->stctxi); free(gctx); } @@ -786,14 +579,20 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, return NULL; } + gsurf->stvis = gconf->stvis; + if (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) + gsurf->stvis.render_buffer = ST_ATTACHMENT_FRONT_LEFT; + + gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base); + if (!gsurf->stfbi) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + nsurf->user_data = &gsurf->base; gsurf->native = nsurf; - gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - if (!gconf->native->mode.doubleBufferMode) - gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; - return &gsurf->base; } @@ -849,7 +648,8 @@ destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf) if (!dpy->Initialized) _eglLog(_EGL_FATAL, "destroy a surface with an unitialized display"); - pipe_surface_reference(&gsurf->render_surface, NULL); + pipe_texture_reference(&gsurf->render_texture, NULL); + egl_g3d_destroy_st_framebuffer(gsurf->stfbi); gsurf->native->destroy(gsurf->native); free(gsurf); } @@ -868,6 +668,7 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, { struct egl_g3d_context *gctx = egl_g3d_context(ctx); struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); + struct egl_g3d_surface *gread = egl_g3d_surface(read); struct egl_g3d_context *old_gctx; EGLBoolean ok = EGL_TRUE; @@ -878,39 +679,29 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, if (old_gctx) { /* flush old context */ - old_gctx->stapi->st_flush(old_gctx->st_ctx, + old_gctx->stctxi->flush(old_gctx->stctxi, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - - /* - * The old context is no longer current, and egl_g3d_realloc_context() - * should be called to destroy the framebuffers. However, it is possible - * that it will be made current again with the same draw/read surfaces. - * It might be better to keep it around. - */ } if (gctx) { - ok = egl_g3d_realloc_context(dpy, &gctx->base); + ok = gctx->stapi->make_current(gctx->stapi, gctx->stctxi, + (gdraw) ? gdraw->stfbi : NULL, (gread) ? gread->stfbi : NULL); if (ok) { - /* XXX: need to pass the winsys argument for - * flush_frontbuffer in the fourth parameter here: - */ - ok = gctx->stapi->st_make_current(gctx->st_ctx, - gctx->draw.st_fb, - gctx->read.st_fb, - NULL); - if (ok) { - egl_g3d_validate_context(dpy, &gctx->base); - if (gdraw->base.Type == EGL_WINDOW_BIT) { - gctx->base.WindowRenderBuffer = - (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? - EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; - } + gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gdraw->stfbi); + if (gread != gdraw) { + gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, + gread->stfbi); + } + + if (gdraw->base.Type == EGL_WINDOW_BIT) { + gctx->base.WindowRenderBuffer = + (gdraw->stvis.render_buffer == ST_ATTACHMENT_FRONT_LEFT) ? + EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; } } } else if (old_gctx) { - ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL, NULL); + ok = old_gctx->stapi->make_current(old_gctx->stapi, NULL, NULL, NULL); old_gctx->base.WindowRenderBuffer = EGL_NONE; } @@ -937,15 +728,17 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) return EGL_TRUE; /* or when the surface is single-buffered */ - if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) + if (gsurf->stvis.render_buffer == ST_ATTACHMENT_FRONT_LEFT) return EGL_TRUE; if (ctx && ctx->DrawSurface == surf) gctx = egl_g3d_context(ctx); /* flush if the surface is current */ - if (gctx) - gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); + if (gctx) { + gctx->stctxi->flush(gctx->stctxi, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } return gsurf->native->swap_buffers(gsurf->native); } @@ -1003,7 +796,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, struct pipe_screen *screen = gdpy->native->screen; struct pipe_surface *psurf; - if (!gsurf->render_surface) + if (!gsurf->render_texture) return EGL_TRUE; gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, target)); @@ -1018,26 +811,33 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, /* flush if the surface is current */ if (ctx && ctx->DrawSurface == &gsurf->base) { struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_flush(gctx->st_ctx, + gctx->stctxi->flush(gctx->stctxi, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); if (psurf) { struct pipe_context pipe; + struct pipe_surface *psrc; /** - * XXX This is hacky. If we might allow the EGLDisplay to create a pipe - * context of its own and use the blitter context for this. + * XXX This is hacky. We should probably create a pipe context for + * EGLDisplay and use a blitter context for this. */ memset(&pipe, 0, sizeof(pipe)); pipe.screen = screen; - util_surface_copy(&pipe, FALSE, psurf, 0, 0, - gsurf->render_surface, 0, 0, psurf->width, psurf->height); + psrc = screen->get_tex_surface(screen, gsurf->render_texture, + 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); + if (psrc) { + util_surface_copy(&pipe, FALSE, psurf, 0, 0, + psrc, 0, 0, psurf->width, psurf->height); + pipe_surface_reference(&psrc, NULL); + + nsurf->flush_frontbuffer(nsurf); + } pipe_surface_reference(&psurf, NULL); - nsurf->flush_frontbuffer(nsurf); } nsurf->destroy(nsurf); @@ -1048,8 +848,16 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, static EGLBoolean egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_finish(gctx->st_ctx); + struct pipe_screen *screen = gdpy->native->screen; + struct pipe_fence_handle *fence = NULL; + + gctx->stctxi->flush(gctx->stctxi, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence); + screen->fence_finish(screen, fence, 0); + screen->fence_reference(screen, &fence, NULL); + return EGL_TRUE; } @@ -1079,10 +887,10 @@ egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) /* in case this is called before a display is initialized */ egl_g3d_init_st(&gdrv->base); - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - const struct egl_g3d_st *stapi = gdrv->stapis[i]; + for (i = 0; i < ST_API_COUNT; i++) { + struct st_api *stapi = gdrv->stapis[i]; if (stapi) { - proc = (_EGLProc) stapi->st_get_proc_address(procname); + proc = (_EGLProc) stapi->get_proc_address(stapi, procname); if (proc) return proc; } @@ -1098,8 +906,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); _EGLContext *es1 = _eglGetAPIContext(EGL_OPENGL_ES_API); struct egl_g3d_context *gctx; - enum pipe_format target_format; - int target; + enum pipe_format internal_format; + enum st_texture_type target; if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); @@ -1110,10 +918,10 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, switch (gsurf->base.TextureFormat) { case EGL_TEXTURE_RGB: - target_format = PIPE_FORMAT_R8G8B8_UNORM; + internal_format = PIPE_FORMAT_R8G8B8_UNORM; break; case EGL_TEXTURE_RGBA: - target_format = PIPE_FORMAT_B8G8R8A8_UNORM; + internal_format = PIPE_FORMAT_B8G8R8A8_UNORM; break; default: return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); @@ -1129,21 +937,24 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, if (!es1) return EGL_TRUE; - if (!gsurf->render_surface) + if (!gsurf->render_texture) return EGL_FALSE; /* flush properly if the surface is bound */ if (gsurf->base.CurrentContext) { gctx = egl_g3d_context(gsurf->base.CurrentContext); - gctx->stapi->st_flush(gctx->st_ctx, + gctx->stctxi->flush(gctx->stctxi, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } gctx = egl_g3d_context(es1); - gctx->stapi->st_bind_texture_surface(gsurf->render_surface, - target, gsurf->base.MipmapLevel, target_format); - - gsurf->base.BoundToTexture = EGL_TRUE; + if (gctx->stctxi->teximage) { + if (!gctx->stctxi->teximage(gctx->stctxi, target, + gsurf->base.MipmapLevel, internal_format, + gsurf->render_texture, gsurf->base.MipmapTexture)) + return EGL_FALSE; + gsurf->base.BoundToTexture = EGL_TRUE; + } return EGL_TRUE; } @@ -1160,14 +971,15 @@ egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, if (buffer != EGL_BACK_BUFFER) return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - if (gsurf->render_surface) { + if (gsurf->render_texture) { _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API); struct egl_g3d_context *gctx = egl_g3d_context(ctx); /* what if the context the surface binds to is no longer current? */ - if (gctx) - gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, - ST_TEXTURE_2D, gsurf->base.MipmapLevel); + if (gctx) { + gctx->stctxi->teximage(gctx->stctxi, ST_TEXTURE_2D, + gsurf->base.MipmapLevel, PIPE_FORMAT_NONE, NULL, FALSE); + } } gsurf->base.BoundToTexture = EGL_FALSE; @@ -1279,6 +1091,12 @@ static void egl_g3d_unload(_EGLDriver *drv) { struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + EGLint i; + + for (i = 0; i < ST_API_COUNT; i++) { + if (gdrv->stapis[i]) + gdrv->stapis[i]->destroy(gdrv->stapis[i]); + } egl_g3d_destroy_probe(drv, NULL); free(gdrv); diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h index e3e55e46d3b..07a87f8bc73 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -39,11 +39,11 @@ #include "eglmode.h" #include "native.h" -#include "egl_st.h" +#include "egl_g3d_st.h" struct egl_g3d_driver { _EGLDriver base; - const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; + struct st_api *stapis[ST_API_COUNT]; EGLint api_mask; EGLint probe_key; @@ -51,35 +51,33 @@ struct egl_g3d_driver { struct egl_g3d_display { struct native_display *native; -}; -struct egl_g3d_buffer { - struct st_framebuffer *st_fb; - uint attachment_mask; + struct st_manager *smapi; }; struct egl_g3d_context { _EGLContext base; - const struct egl_g3d_st *stapi; - struct pipe_context *pipe; + struct st_api *stapi; - struct st_context *st_ctx; - EGLBoolean force_validate; - struct egl_g3d_buffer draw, read; + struct st_context_iface *stctxi; }; struct egl_g3d_surface { _EGLSurface base; + + struct st_visual stvis; + struct st_framebuffer_iface *stfbi; + struct native_surface *native; - enum native_attachment render_att; - struct pipe_surface *render_surface; + struct pipe_texture *render_texture; unsigned int sequence_number; }; struct egl_g3d_config { _EGLConfig base; const struct native_config *native; + struct st_visual stvis; }; struct egl_g3d_image { diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c new file mode 100644 index 00000000000..36094096d36 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -0,0 +1,227 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_dl.h" +#include "eglimage.h" +#include "eglmutex.h" + +#include "egl_g3d.h" +#include "egl_g3d_st.h" + +struct egl_g3d_st_manager { + struct st_manager base; + _EGLDisplay *display; +}; + +static INLINE struct egl_g3d_st_manager * +egl_g3d_st_manager(struct st_manager *smapi) +{ + return (struct egl_g3d_st_manager *) smapi; +} + +struct st_api * +egl_g3d_create_st_api(enum st_api_type api) +{ + const char *stmod_name; + struct util_dl_library *lib; + const struct st_module *mod; + + switch (api) { + case ST_API_OPENGL: + stmod_name = ST_MODULE_OPENGL_SYMBOL; + break; + case ST_API_OPENGL_ES1: + stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL; + break; + case ST_API_OPENGL_ES2: + stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL; + break; + case ST_API_OPENVG: + stmod_name = ST_MODULE_OPENVG_SYMBOL; + break; + default: + stmod_name = NULL; + break; + } + if (!stmod_name) + return NULL; + + mod = NULL; + lib = util_dl_open(NULL); + if (lib) { + mod = (const struct st_module *) + util_dl_get_proc_address(lib, stmod_name); + util_dl_close(lib); + } + if (!mod || mod->api != api) + return NULL; + + return mod->create_api(); +} + +struct st_manager * +egl_g3d_create_st_manager(_EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_st_manager *gsmapi; + + gsmapi = CALLOC_STRUCT(egl_g3d_st_manager); + if (gsmapi) { + gsmapi->display = dpy; + + gsmapi->base.screen = gdpy->native->screen; + } + + return &gsmapi->base;; +} + +void +egl_g3d_destroy_st_manager(struct st_manager *smapi) +{ + struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi); + free(gsmapi); +} + +static boolean +egl_g3d_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private; + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + return gsurf->native->flush_frontbuffer(gsurf->native); +} + +static boolean +egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_texture **out) +{ + _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private; + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + uint attachment_mask = 0; + unsigned i; + + for (i = 0; i < count; i++) { + int natt; + + switch (statts[i]) { + case ST_ATTACHMENT_FRONT_LEFT: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + natt = NATIVE_ATTACHMENT_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + natt = NATIVE_ATTACHMENT_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + natt = NATIVE_ATTACHMENT_BACK_RIGHT; + default: + natt = -1; + break; + } + + if (natt >= 0) + attachment_mask |= 1 << natt; + } + + if (!gsurf->native->validate(gsurf->native, attachment_mask, + &gsurf->sequence_number, textures, &gsurf->base.Width, + &gsurf->base.Height)) + return FALSE; + + for (i = 0; i < count; i++) { + struct pipe_texture *tex; + int natt; + + switch (statts[i]) { + case ST_ATTACHMENT_FRONT_LEFT: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + natt = NATIVE_ATTACHMENT_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + natt = NATIVE_ATTACHMENT_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + natt = NATIVE_ATTACHMENT_BACK_RIGHT; + break; + default: + natt = -1; + break; + } + + if (natt >= 0) { + tex = textures[natt]; + + if (statts[i] == stfbi->visual->render_buffer) + pipe_texture_reference(&gsurf->render_texture, tex); + + if (attachment_mask & (1 << natt)) { + /* transfer the ownership to the caller */ + out[i] = tex; + attachment_mask &= ~(1 << natt); + } + else { + /* the attachment is listed more than once */ + pipe_texture_reference(&out[i], tex); + } + } + } + + return TRUE; +} + +struct st_framebuffer_iface * +egl_g3d_create_st_framebuffer(_EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct st_framebuffer_iface *stfbi; + + stfbi = CALLOC_STRUCT(st_framebuffer_iface); + if (!stfbi) + return NULL; + + stfbi->visual = &gsurf->stvis; + stfbi->flush_front = egl_g3d_st_framebuffer_flush_front; + stfbi->validate = egl_g3d_st_framebuffer_validate; + stfbi->st_manager_private = (void *) &gsurf->base; + + return stfbi; +} + +void +egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + free(stfbi); +} diff --git a/src/gallium/state_trackers/egl/common/egl_st.h b/src/gallium/state_trackers/egl/common/egl_g3d_st.h similarity index 51% rename from src/gallium/state_trackers/egl/common/egl_st.h rename to src/gallium/state_trackers/egl/common/egl_g3d_st.h index 8fb464bd3d7..ea8b4068cd8 100644 --- a/src/gallium/state_trackers/egl/common/egl_st.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.8 + * Version: 7.9 * - * Copyright (C) 2009-2010 Chia-I Wu + * Copyright (C) 2010 LunarG Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,54 +20,60 @@ * 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. + * + * Authors: + * Chia-I Wu */ -#ifndef _EGL_ST_H_ -#define _EGL_ST_H_ - -#include "GL/gl.h" /* for GL types */ -#include "GL/internal/glcore.h" /* for __GLcontextModes */ +#ifndef _EGL_G3D_ST_H_ +#define _EGL_G3D_ST_H_ #include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" +#include "state_tracker/st_api.h" +#include "egltypedefs.h" -/* avoid calling st functions directly */ -#if 1 +struct st_api * +egl_g3d_create_st_api(enum st_api_type api); -#define ST_SURFACE_FRONT_LEFT 0 -#define ST_SURFACE_BACK_LEFT 1 -#define ST_SURFACE_FRONT_RIGHT 2 -#define ST_SURFACE_BACK_RIGHT 3 +struct st_manager * +egl_g3d_create_st_manager(_EGLDisplay *dpy); -#define ST_TEXTURE_2D 0x2 +void +egl_g3d_destroy_st_manager(struct st_manager *smapi); -struct st_context; -struct st_framebuffer; -typedef void (*st_proc)(); +struct st_framebuffer_iface * +egl_g3d_create_st_framebuffer(_EGLSurface *surf); -#else -#include "state_tracker/st_public.h" -#endif +void +egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); -/* remember to update egl_g3d_get_st() when update the enums */ -enum egl_g3d_st_api { - EGL_G3D_ST_OPENGL_ES = 0, - EGL_G3D_ST_OPENVG, - EGL_G3D_ST_OPENGL_ES2, - EGL_G3D_ST_OPENGL, +/** + * Return the EGL__BIT of the st api. + */ +static INLINE int +egl_g3d_st_api_bit(enum st_api_type api) +{ + int bit; - NUM_EGL_G3D_STS -}; + switch (api) { + case ST_API_OPENGL: + bit = EGL_OPENGL_BIT; + break; + case ST_API_OPENGL_ES1: + bit = EGL_OPENGL_ES_BIT; + break; + case ST_API_OPENGL_ES2: + bit = EGL_OPENGL_ES2_BIT; + break; + case ST_API_OPENVG: + bit = EGL_OPENVG_BIT; + break; + default: + bit = 0; + break; + } -struct egl_g3d_st { -#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); -#include "st_public_tmp.h" - /* fields must be added here */ - EGLint api_bit; -}; + return bit; +} -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api); - -#endif /* _EGL_ST_H_ */ +#endif /* _EGL_G3D_ST_H_ */ diff --git a/src/gallium/state_trackers/egl/common/egl_st.c b/src/gallium/state_trackers/egl/common/egl_st.c deleted file mode 100644 index a88ff911cd5..00000000000 --- a/src/gallium/state_trackers/egl/common/egl_st.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * 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. - */ - -#include -#include "pipe/p_compiler.h" -#include "util/u_memory.h" -#include "egllog.h" -#include "EGL/egl.h" /* for EGL_api_BIT */ - -#include "egl_st.h" - -#ifndef HAVE_DLADDR -#define HAVE_DLADDR 1 -#endif - -#if HAVE_DLADDR - -static const char * -egl_g3d_st_names[] = { -#define ST_PUBLIC(name, ...) #name, -#include "st_public_tmp.h" - NULL -}; - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ - st_proc *procs = (st_proc *) stapi; - void *handle; - Dl_info info; - const char **name; - - if (!dladdr(sym, &info)) - return FALSE; - handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); - if (!handle) - return FALSE; - - for (name = egl_g3d_st_names; *name; name++) { - st_proc proc = (st_proc) dlsym(handle, *name); - if (!proc) { - _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); - memset(stapi, 0, sizeof(*stapi)); - dlclose(handle); - return FALSE; - } - *procs++ = proc; - } - - dlclose(handle); - return TRUE; -} - -#else /* HAVE_DLADDR */ - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ -#define ST_PUBLIC(name, ...) stapi->name = name; -#include "st_public_tmp.h" - return TRUE; -} - -#endif /* HAVE_DLADDR */ - -static boolean -egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) -{ - void *handle, *sym; - boolean res = FALSE; - - /* already initialized */ - if (stapi->st_notify_swapbuffers != NULL) - return TRUE; - - handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); - if (!handle) - return FALSE; - - sym = dlsym(handle, api); - if (sym && egl_g3d_fill_st(stapi, sym)) - res = TRUE; - - dlclose(handle); - return res; -} - -static struct { - const char *symbol; - EGLint api_bit; -} egl_g3d_st_info[NUM_EGL_G3D_STS] = { - { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, - { "st_api_OpenVG", EGL_OPENVG_BIT }, - { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, - { "st_api_OpenGL", EGL_OPENGL_BIT }, -}; - -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api) -{ - static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; - - if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { - all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; - return &all_trackers[api]; - } - else { - return NULL; - } -} diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h deleted file mode 100644 index 562dd68c150..00000000000 --- a/src/gallium/state_trackers/egl/common/st_public_tmp.h +++ /dev/null @@ -1,20 +0,0 @@ -ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) -ST_PUBLIC(st_destroy_context, void, struct st_context *st) -ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) -ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) -ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) -ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) -ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) -ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) -ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) -ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) -ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read, void *winsys_drawable_handle) -ST_PUBLIC(st_get_current, struct st_context *, void) -ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) -ST_PUBLIC(st_finish, void, struct st_context *st) -ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) -ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) -ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) -#undef ST_PUBLIC From 576d9af505bd19ccaac04a68c8744f36f887bd5c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 10 Mar 2010 17:22:56 +0800 Subject: [PATCH 040/483] st/glx: Use st_api.h instead of st_public.h. --- src/gallium/state_trackers/glx/xlib/Makefile | 3 +- src/gallium/state_trackers/glx/xlib/glx_api.c | 5 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 265 +++++++++-------- src/gallium/state_trackers/glx/xlib/xm_api.h | 39 +-- src/gallium/state_trackers/glx/xlib/xm_st.c | 269 ++++++++++++++++++ src/gallium/state_trackers/glx/xlib/xm_st.h | 54 ++++ 6 files changed, 470 insertions(+), 165 deletions(-) create mode 100644 src/gallium/state_trackers/glx/xlib/xm_st.c create mode 100644 src/gallium/state_trackers/glx/xlib/xm_st.h diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile index 7b2adc62c34..ddffdb162c7 100644 --- a/src/gallium/state_trackers/glx/xlib/Makefile +++ b/src/gallium/state_trackers/glx/xlib/Makefile @@ -11,6 +11,7 @@ C_SOURCES = \ glx_api.c \ glx_getproc.c \ glx_usefont.c \ - xm_api.c + xm_api.c \ + xm_st.c include ../../../Makefile.template diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 24545858500..4930cd6cd50 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -35,12 +35,9 @@ #include "xm_api.h" #include "main/context.h" -#include "main/config.h" #include "main/macros.h" #include "main/imports.h" #include "main/version.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_public.h" /* This indicates the client-side GLX API and GLX encoder version. */ @@ -1304,7 +1301,7 @@ glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, if (MakeCurrent_PrevContext == src) { _mesa_Flush(); } - st_copy_context_state( xm_src->st, xm_dst->st, (GLuint) mask ); + XMesaCopyContext(xm_src, xm_dst, mask); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index f4d7133d2ff..6a0f3146dbf 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -54,11 +54,9 @@ #endif #include "xm_api.h" -#include "main/context.h" -#include "main/framebuffer.h" +#include "xm_st.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" +#include "main/context.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" #include "pipe/p_context.h" @@ -84,6 +82,8 @@ void xmesa_set_driver( const struct xm_driver *templ ) pipe_mutex _xmesa_lock; static struct pipe_screen *screen = NULL; +static struct st_api *stapi = NULL; +static struct st_manager *smapi = NULL; /**********************************************************************/ @@ -273,49 +273,49 @@ choose_pixel_format(XMesaVisual v) return 0; } - - /** - * Query the default gallium screen for a Z/Stencil format that - * at least matches the given depthBits and stencilBits. + * Choose a depth/stencil format for the given depth and stencil sizes. */ -static void -xmesa_choose_z_stencil_format(int depthBits, int stencilBits, - enum pipe_format *depthFormat, - enum pipe_format *stencilFormat) +static enum pipe_format +choose_depth_stencil_format(int depth, int stencil) { const enum pipe_texture_target target = PIPE_TEXTURE_2D; const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); - static enum pipe_format formats[] = { - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_Z32_UNORM - }; - int i; + enum pipe_format formats[8], fmt; + int count, i; assert(screen); - *depthFormat = *stencilFormat = PIPE_FORMAT_NONE; + count = 0; + switch (depth) { + case 16: + if (!stencil) + formats[count++] = PIPE_FORMAT_Z16_UNORM; + break; + case 24: + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + break; + case 32: + if (!stencil) + formats[count++] = PIPE_FORMAT_Z32_UNORM; + break; + default: + break; + } - /* search for supported format */ - for (i = 0; i < Elements(formats); i++) { + fmt = PIPE_FORMAT_NONE; + for (i = 0; i < count; i++) { if (screen->is_format_supported(screen, formats[i], target, tex_usage, geom_flags)) { - *depthFormat = formats[i]; + fmt = formats[i]; break; } } - if (stencilBits) { - *stencilFormat = *depthFormat; - } - - /* XXX we should check that he chosen format has at least as many bits - * as what was requested. - */ + return fmt; } @@ -343,12 +343,14 @@ create_xmesa_buffer(Drawable d, BufferType type, XMesaVisual vis, Colormap cmap) { XMesaBuffer b; - GLframebuffer *fb; - enum pipe_format colorFormat, depthFormat, stencilFormat; uint width, height; ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); + xmesa_init(vis->display); + if (!screen) + return NULL; + b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer); if (!b) return NULL; @@ -361,24 +363,12 @@ create_xmesa_buffer(Drawable d, BufferType type, b->type = type; b->cmap = cmap; - /* determine PIPE_FORMATs for buffers */ - colorFormat = choose_pixel_format(vis); - - xmesa_choose_z_stencil_format(vis->mesa_visual.depthBits, - vis->mesa_visual.stencilBits, - &depthFormat, &stencilFormat); - - get_drawable_size(vis->display, d, &width, &height); /* * Create framebuffer, but we'll plug in our own renderbuffers below. */ - b->stfb = st_create_framebuffer(&vis->mesa_visual, - colorFormat, depthFormat, stencilFormat, - width, height, - (void *) b); - fb = &b->stfb->Base; + b->stfb = xmesa_create_st_framebuffer(screen, b); /* GLX_EXT_texture_from_pixmap */ b->TextureTarget = 0; @@ -422,24 +412,21 @@ xmesa_free_buffer(XMesaBuffer buffer) for (b = XMesaBufferList; b; b = b->Next) { if (b == buffer) { - struct gl_framebuffer *fb = &buffer->stfb->Base; - /* unlink buffer from list */ if (prev) prev->Next = buffer->Next; else XMesaBufferList = buffer->Next; - /* mark as delete pending */ - fb->DeletePending = GL_TRUE; - /* Since the X window for the XMesaBuffer is going away, we don't * want to dereference this pointer in the future. */ b->ws.drawable = 0; - /* Unreference. If count = zero we'll really delete the buffer */ - _mesa_reference_framebuffer(&fb, NULL); + /* XXX we should move the buffer to a delete-pending list and destroy + * the buffer until it is no longer current. + */ + xmesa_destroy_st_framebuffer(buffer->stfb); free(buffer); @@ -681,6 +668,26 @@ XMesaVisual XMesaCreateVisual( Display *display, accum_blue_size, accum_alpha_size, 0 ); + v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK; + if (db_flag) + v->stvis.buffer_mask = ST_ATTACHMENT_BACK_LEFT_MASK; + if (stereo_flag) { + v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_RIGHT_MASK; + if (db_flag) + v->stvis.buffer_mask = ST_ATTACHMENT_BACK_RIGHT_MASK; + } + + v->stvis.color_format = choose_pixel_format(v); + v->stvis.depth_stencil_format = + choose_depth_stencil_format(depth_size, stencil_size); + + v->stvis.accum_format = (accum_red_size + + accum_green_size + accum_blue_size + accum_alpha_size) ? + PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE; + + v->stvis.samples = num_samples; + v->stvis.render_buffer = ST_ATTACHMENT_INVALID; + /* XXX minor hack */ v->mesa_visual.level = level; return v; @@ -705,6 +712,26 @@ xmesa_init( Display *display ) if (firstTime) { pipe_mutex_init(_xmesa_lock); screen = driver.create_pipe_screen( display ); + stapi = xmesa_create_st_api(); + smapi = CALLOC_STRUCT(st_manager); + if (smapi) + smapi->screen = screen; + + if (!screen || !stapi || !smapi) { + if (screen) { + screen->destroy(screen); + screen = NULL; + } + if (stapi) { + stapi->destroy(stapi); + stapi = NULL; + } + if (smapi) { + FREE(smapi); + smapi = NULL; + } + } + firstTime = GL_FALSE; } } @@ -720,10 +747,7 @@ xmesa_init( Display *display ) PUBLIC XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) { - struct pipe_context *pipe = NULL; XMesaContext c; - GLcontext *mesaCtx; - uint pf; xmesa_init( v->display ); @@ -732,9 +756,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (!c) return NULL; - pf = choose_pixel_format(v); - assert(pf); - c->xm_visual = v; c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */ c->xm_read_buffer = NULL; @@ -742,29 +763,18 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (screen == NULL) goto fail; - /* Trace screen knows how to properly wrap context creation in the - * wrapped screen, so nothing special to do here: - */ - pipe = screen->context_create(screen, (void *) c); - if (pipe == NULL) - goto fail; - - c->st = st_create_context(pipe, - &v->mesa_visual, - share_list ? share_list->st : NULL); + c->st = stapi->create_context(stapi, smapi, + &v->stvis, (share_list) ? share_list->st : NULL); if (c->st == NULL) goto fail; - mesaCtx = c->st->ctx; - c->st->ctx->DriverCtx = c; + c->st->st_manager_private = (void *) c; return c; fail: if (c->st) - st_destroy_context(c->st); - else if (pipe) - pipe->destroy(pipe); + c->st->destroy(c->st); free(c); return NULL; @@ -775,7 +785,7 @@ fail: PUBLIC void XMesaDestroyContext( XMesaContext c ) { - st_destroy_context(c->st); + c->st->destroy(c->st); /* FIXME: We should destroy the screen here, but if we do so, surfaces may * outlive it, causing segfaults @@ -881,7 +891,6 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p, { GET_CURRENT_CONTEXT(ctx); XMesaBuffer b; - GLuint width, height; assert(v); @@ -889,19 +898,18 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p, if (!b) return NULL; - /* get pixmap size, update framebuffer/renderbuffer dims */ - xmesa_get_window_size(v->display, b, &width, &height); - _mesa_resize_framebuffer(NULL, &(b->stfb->Base), width, height); + /* get pixmap size */ + xmesa_get_window_size(v->display, b, &b->width, &b->height); if (target == 0) { /* examine dims */ if (ctx->Extensions.ARB_texture_non_power_of_two) { target = GLX_TEXTURE_2D_EXT; } - else if ( _mesa_bitcount(width) == 1 - && _mesa_bitcount(height) == 1) { + else if ( _mesa_bitcount(b->width) == 1 + && _mesa_bitcount(b->height) == 1) { /* power of two size */ - if (height == 1) { + if (b->height == 1) { target = GLX_TEXTURE_1D_EXT; } else { @@ -974,25 +982,22 @@ XMesaDestroyBuffer(XMesaBuffer b) /** - * Query the current window size and update the corresponding GLframebuffer - * and all attached renderbuffers. - * Called when: - * 1. the first time a buffer is bound to a context. - * 2. SwapBuffers. XXX probabaly from xm_flush_frontbuffer() too... - * Note: it's possible (and legal) for xmctx to be NULL. That can happen - * when resizing a buffer when no rendering context is bound. + * Query the current drawable size and notify the binding context. */ void -xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer) +xmesa_check_buffer_size(XMesaBuffer b) { - GLuint width, height; - xmesa_get_window_size(drawBuffer->xm_visual->display, drawBuffer, &width, &height); - st_resize_framebuffer(drawBuffer->stfb, width, height); + XMesaContext xmctx = XMesaGetCurrentContext(); + + if (b->type == PBUFFER) + return; + + xmesa_get_window_size(b->xm_visual->display, b, &b->width, &b->height); + if (xmctx && xmctx->xm_buffer == b) + xmctx->st->notify_invalid_framebuffer(xmctx->st, b->stfb); } - - /* * Bind buffer b to context c and make c the current rendering context. */ @@ -1017,22 +1022,21 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, c->xm_read_buffer == readBuffer) return GL_TRUE; + xmesa_check_buffer_size(drawBuffer); + if (readBuffer != drawBuffer) + xmesa_check_buffer_size(readBuffer); + c->xm_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb, - &drawBuffer->ws); - - xmesa_check_and_update_buffer_size(c, drawBuffer); - if (readBuffer != drawBuffer) - xmesa_check_and_update_buffer_size(c, readBuffer); + stapi->make_current(stapi, c->st, drawBuffer->stfb, readBuffer->stfb); /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ drawBuffer->wasCurrent = GL_TRUE; } else { /* Detach */ - st_make_current( NULL, NULL, NULL, NULL ); + stapi->make_current(stapi, NULL, NULL, NULL); } return GL_TRUE; @@ -1051,14 +1055,8 @@ GLboolean XMesaUnbindContext( XMesaContext c ) XMesaContext XMesaGetCurrentContext( void ) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) { - XMesaContext xmesa = xmesa_context(ctx); - return xmesa; - } - else { - return 0; - } + struct st_context_iface *st = stapi->get_current(stapi); + return (XMesaContext) (st) ? st->st_manager_private : NULL; } @@ -1070,17 +1068,17 @@ XMesaContext XMesaGetCurrentContext( void ) PUBLIC void XMesaSwapBuffers( XMesaBuffer b ) { - struct pipe_surface *frontLeftSurf; + XMesaContext xmctx = XMesaGetCurrentContext(); - st_swapbuffers(b->stfb, &frontLeftSurf, NULL); - - if (frontLeftSurf) { - screen->flush_frontbuffer( screen, - frontLeftSurf, - &b->ws ); + if (xmctx && xmctx->xm_buffer == b) { + xmctx->st->flush( xmctx->st, + PIPE_FLUSH_RENDER_CACHE | + PIPE_FLUSH_SWAPBUFFERS | + PIPE_FLUSH_FRAME, + NULL); } - xmesa_check_and_update_buffer_size(NULL, b); + xmesa_swap_st_framebuffer(b->stfb); } @@ -1090,21 +1088,9 @@ void XMesaSwapBuffers( XMesaBuffer b ) */ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) { - struct pipe_surface *surf_front; - struct pipe_surface *surf_back; - struct pipe_context *pipe = NULL; /* XXX fix */ - - st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT, &surf_front); - st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf_back); - - if (!surf_front || !surf_back) - return; - - assert(pipe); - pipe->surface_copy(pipe, - surf_front, x, y, /* dest */ - surf_back, x, y, /* src */ - width, height); + xmesa_copy_st_framebuffer(b->stfb, + ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT, + x, y, width, height); } @@ -1112,7 +1098,13 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) void XMesaFlush( XMesaContext c ) { if (c && c->xm_visual->display) { - st_finish(c->st); + struct pipe_fence_handle *fence = NULL; + + c->st->flush(c->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence); + if (fence) { + screen->fence_finish(screen, fence, 0); + screen->fence_reference(screen, &fence, NULL); + } XSync( c->xm_visual->display, False ); } } @@ -1186,3 +1178,10 @@ XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer) { } + +void +XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask) +{ + if (dst->st->copy) + dst->st->copy(dst->st, src->st, mask); +} diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index de47064b410..258abf92554 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -58,8 +58,7 @@ and create a window, you must do the following to use the X/Mesa interface: #include "main/mtypes.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_public.h" +#include "state_tracker/st_api.h" #include "os/os_thread.h" #include "state_tracker/xlib_sw_winsys.h" @@ -258,6 +257,8 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p, int format, int target, int mipmap); +extern void +XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask); /*********************************************************************** @@ -280,6 +281,8 @@ struct xmesa_visual { GLint BitsPerPixel; /* True bits per pixel for XImages */ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */ + + struct st_visual stvis; }; @@ -288,7 +291,7 @@ struct xmesa_visual { * Basically corresponds to a GLXContext. */ struct xmesa_context { - struct st_context *st; + struct st_context_iface *st; XMesaVisual xm_visual; /** pixel format info */ XMesaBuffer xm_buffer; /** current drawbuffer */ XMesaBuffer xm_read_buffer; /** current readbuffer */ @@ -311,7 +314,7 @@ typedef enum { * Basically corresponds to a GLXDrawable. */ struct xmesa_buffer { - struct st_framebuffer *stfb; + struct st_framebuffer_iface *stfb; struct xlib_drawable ws; GLboolean wasCurrent; /* was ever the current buffer? */ @@ -335,33 +338,15 @@ struct xmesa_buffer { GLint TextureMipmap; /** 0 or 1 */ struct xmesa_buffer *Next; /* Linked list pointer: */ + + unsigned width, height; }; -/** cast wrapper */ -static INLINE XMesaContext -xmesa_context(GLcontext *ctx) -{ - return (XMesaContext) ctx->DriverCtx; -} - - -/** cast wrapper */ -static INLINE XMesaBuffer -xmesa_buffer(GLframebuffer *fb) -{ - struct st_framebuffer *stfb = (struct st_framebuffer *) fb; - return (XMesaBuffer) st_framebuffer_private(stfb); -} - - extern void xmesa_init(Display *dpy); -extern void -xmesa_delete_framebuffer(struct gl_framebuffer *fb); - extern XMesaBuffer xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis); @@ -370,7 +355,7 @@ xmesa_get_window_size(Display *dpy, XMesaBuffer b, GLuint *width, GLuint *height); extern void -xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer); +xmesa_check_buffer_size(XMesaBuffer b); extern void xmesa_destroy_buffers_on_display(Display *dpy); @@ -378,13 +363,13 @@ xmesa_destroy_buffers_on_display(Display *dpy); static INLINE GLuint xmesa_buffer_width(XMesaBuffer b) { - return b->stfb->Base.Width; + return b->width; } static INLINE GLuint xmesa_buffer_height(XMesaBuffer b) { - return b->stfb->Base.Height; + return b->height; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c new file mode 100644 index 00000000000..c5ea5c1549b --- /dev/null +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -0,0 +1,269 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "util/u_memory.h" +#include "util/u_inlines.h" + +#include "xm_api.h" +#include "xm_st.h" + +/* support OpenGL by default */ +#ifndef XMESA_ST_MODULE +#define XMESA_ST_MODULE st_module_OpenGL +#endif + +struct xmesa_st_framebuffer { + struct pipe_screen *screen; + XMesaBuffer buffer; + + struct st_visual stvis; + + unsigned texture_width, texture_height; + struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; + + struct pipe_surface *display_surface; +}; + +static INLINE struct xmesa_st_framebuffer * +xmesa_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + return (struct xmesa_st_framebuffer *) stfbi->st_manager_private; +} + +/** + * Display an attachment to the xlib_drawable of the framebuffer. + */ +static boolean +xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + struct pipe_texture *ptex = xstfb->textures[statt]; + struct pipe_surface *psurf; + + if (!ptex) + return TRUE; + + psurf = xstfb->display_surface; + /* (re)allocate the surface for the texture to be displayed */ + if (!psurf || psurf->texture != ptex) { + pipe_surface_reference(&xstfb->display_surface, NULL); + + psurf = xstfb->screen->get_tex_surface(xstfb->screen, + ptex, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); + if (!psurf) + return FALSE; + + xstfb->display_surface = psurf; + } + + xstfb->screen->flush_frontbuffer(xstfb->screen, psurf, &xstfb->buffer->ws); + + return TRUE; +} + +/** + * Remove outdated textures and create the requested ones. + */ +static void +xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + struct pipe_texture templ; + unsigned request_mask, i; + + request_mask = 0; + for (i = 0; i < count; i++) + request_mask |= 1 << statts[i]; + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.width0 = xstfb->texture_width; + templ.height0 = xstfb->texture_height; + templ.depth0 = 1; + templ.last_level = 0; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + struct pipe_texture *ptex = xstfb->textures[i]; + enum pipe_format format; + unsigned tex_usage; + + /* remove outdated textures */ + if (ptex && (ptex->width0 != xstfb->texture_width || + ptex->height0 != xstfb->texture_height)) { + pipe_texture_reference(&xstfb->textures[i], NULL); + ptex = NULL; + } + + /* the texture already exists or not requested */ + if (ptex || !(request_mask & (1 << i))) + continue; + + switch (i) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + format = xstfb->stvis.color_format; + tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_RENDER_TARGET; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + format = xstfb->stvis.depth_stencil_format; + tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + break; + default: + format = PIPE_FORMAT_NONE; + break; + } + + if (format != PIPE_FORMAT_NONE) { + templ.format = format; + templ.tex_usage = tex_usage; + + xstfb->textures[i] = + xstfb->screen->texture_create(xstfb->screen, &templ); + } + } +} + +static boolean +xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_texture **out) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + unsigned i; + + /* revalidate textures */ + if (xstfb->buffer->width != xstfb->texture_width || + xstfb->buffer->height != xstfb->texture_height) { + xstfb->texture_width = xstfb->buffer->width; + xstfb->texture_height = xstfb->buffer->height; + + xmesa_st_framebuffer_validate_textures(stfbi, statts, count); + } + + for (i = 0; i < count; i++) { + out[i] = NULL; + pipe_texture_reference(&out[i], xstfb->textures[statts[i]]); + } + + return TRUE; +} + +static boolean +xmesa_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + boolean ret; + + ret = xmesa_st_framebuffer_flush_front(stfbi, statt); + if (ret) + xmesa_check_buffer_size(xstfb->buffer); + + return ret; +} + +struct st_framebuffer_iface * +xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b) +{ + struct st_framebuffer_iface *stfbi; + struct xmesa_st_framebuffer *xstfb; + + stfbi = CALLOC_STRUCT(st_framebuffer_iface); + xstfb = CALLOC_STRUCT(xmesa_st_framebuffer); + if (!stfbi || !xstfb) { + if (stfbi) + FREE(stfbi); + if (xstfb) + FREE(xstfb); + return NULL; + } + + xstfb->screen = screen; + xstfb->buffer = b; + xstfb->stvis = b->xm_visual->stvis; + + stfbi->visual = &xstfb->stvis; + stfbi->flush_front = xmesa_st_framebuffer_flush_front; + stfbi->validate = xmesa_st_framebuffer_validate; + stfbi->st_manager_private = (void *) xstfb; + + return stfbi; +} + +void +xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + + FREE(xstfb); + FREE(stfbi); +} + +void +xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + boolean ret; + + ret = xmesa_st_framebuffer_display(stfbi, ST_ATTACHMENT_BACK_LEFT); + if (ret) { + struct pipe_texture **front, **back, *tmp; + + front = &xstfb->textures[ST_ATTACHMENT_FRONT_LEFT]; + back = &xstfb->textures[ST_ATTACHMENT_BACK_LEFT]; + /* swap textures only if the front texture has been allocated */ + if (*front) { + tmp = *front; + *front = *back; + *back = tmp; + } + + xmesa_check_buffer_size(xstfb->buffer); + } +} + +void +xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi, + enum st_attachment_type src, + enum st_attachment_type dst, + int x, int y, int w, int h) +{ + /* TODO */ +} + +struct st_api * +xmesa_create_st_api(void) +{ + return XMESA_ST_MODULE.create_api(); +} diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.h b/src/gallium/state_trackers/glx/xlib/xm_st.h new file mode 100644 index 00000000000..7ca7afe2531 --- /dev/null +++ b/src/gallium/state_trackers/glx/xlib/xm_st.h @@ -0,0 +1,54 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _XM_ST_H_ +#define _XM_ST_H_ + +#include "pipe/p_compiler.h" +#include "state_tracker/st_api.h" + +#include "xm_api.h" + +struct st_api * +xmesa_create_st_api(void); + +struct st_framebuffer_iface * +xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b); + +void +xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); + +void +xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi); + +void +xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi, + enum st_attachment_type src, + enum st_attachment_type dst, + int x, int y, int w, int h); + +#endif /* _XM_ST_H_ */ From 72ed7eb15a12ad88647dddefde5999ddd308b9e4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 12 Mar 2010 10:04:47 +0800 Subject: [PATCH 041/483] st/glx: Fix an infinite recursion in flush_front. It was a stupid typo by me when I refactored the code. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index c5ea5c1549b..3b5f78e98ad 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -186,7 +186,7 @@ xmesa_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); boolean ret; - ret = xmesa_st_framebuffer_flush_front(stfbi, statt); + ret = xmesa_st_framebuffer_display(stfbi, statt); if (ret) xmesa_check_buffer_size(xstfb->buffer); From 3475e88442c16fb2b50b903fe246b3ebe49da226 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 12 Mar 2010 11:20:27 +0800 Subject: [PATCH 042/483] st/glx: Return a better format in choose_depth_stencil_format. Return a better format instead of an exact format in choose_depth_stencil_format. Also, prefer formats with stencil bits. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 6a0f3146dbf..3ea4d77805f 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -274,7 +274,8 @@ choose_pixel_format(XMesaVisual v) } /** - * Choose a depth/stencil format for the given depth and stencil sizes. + * Choose a depth/stencil format that is "better" than the given depth and + * stencil sizes. */ static enum pipe_format choose_depth_stencil_format(int depth, int stencil) @@ -289,21 +290,16 @@ choose_depth_stencil_format(int depth, int stencil) assert(screen); count = 0; - switch (depth) { - case 16: - if (!stencil) - formats[count++] = PIPE_FORMAT_Z16_UNORM; - break; - case 24: + if (depth <= 24 && stencil <= 8) { formats[count++] = PIPE_FORMAT_S8Z24_UNORM; formats[count++] = PIPE_FORMAT_Z24S8_UNORM; - break; - case 32: - if (!stencil) + } + + if (!stencil) { + if (depth <= 16) + formats[count++] = PIPE_FORMAT_Z16_UNORM; + if (depth <= 32) formats[count++] = PIPE_FORMAT_Z32_UNORM; - break; - default: - break; } fmt = PIPE_FORMAT_NONE; From 543a29f1a16cc46c6d019d2cf2bd13a96b5a3f2f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 12 Mar 2010 11:27:50 +0800 Subject: [PATCH 043/483] st/mesa: Check the format before adding depth/stencil buffers. The format might have depth bits, stencil bits, or both. Add the renderbuffers as needed. --- src/mesa/state_tracker/st_manager.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 6c3cde09683..f0dda4be6e9 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -270,9 +270,15 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb, if (!rb) return FALSE; - _mesa_add_renderbuffer(&stfb->Base, idx, rb); - if (idx == BUFFER_DEPTH) - _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb); + if (idx != BUFFER_DEPTH) { + _mesa_add_renderbuffer(&stfb->Base, idx, rb); + } + else { + if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) + _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, rb); + if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) + _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb); + } return TRUE; } From 9dae0e0ff88957d16db47130a2646179fb5fc267 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 12 Mar 2010 13:26:18 +0800 Subject: [PATCH 044/483] st/glx: Add xm_st.c to SConscript. --- src/gallium/state_trackers/glx/xlib/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index bb202351509..d6c16ad2f52 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -20,6 +20,7 @@ if env['platform'] == 'linux' \ 'glx_getproc.c', 'glx_usefont.c', 'xm_api.c', + 'xm_st.c', ] ) Export('st_xlib') From 08f89988c8738029c60e89c61c9da0522bd53087 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 12 Mar 2010 14:36:23 +0100 Subject: [PATCH 045/483] cso: Add entry points for vertex/fragment sampler views. --- src/gallium/auxiliary/cso_cache/cso_context.c | 154 ++++++++++++++++-- src/gallium/auxiliary/cso_cache/cso_context.h | 28 ++++ 2 files changed, 167 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 8568a0052d0..5c16e0959d6 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -37,6 +37,7 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" +#include "util/u_math.h" #include "util/u_memory.h" #include "util/u_sampler.h" #include "tgsi/tgsi_parse.h" @@ -71,19 +72,23 @@ struct cso_context { void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; + uint nr_fragment_sampler_views; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; uint nr_textures; struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; + uint nr_vertex_sampler_views; struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; uint nr_vertex_textures; uint nr_textures_saved; struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *sampler_views_saved[PIPE_MAX_SAMPLERS]; + uint nr_fragment_sampler_views_saved; + struct pipe_sampler_view *fragment_sampler_views_saved[PIPE_MAX_SAMPLERS]; uint nr_vertex_textures_saved; struct pipe_texture *vertex_textures_saved[PIPE_MAX_VERTEX_SAMPLERS]; + uint nr_vertex_sampler_views_saved; struct pipe_sampler_view *vertex_sampler_views_saved[PIPE_MAX_VERTEX_SAMPLERS]; /** Current and saved state. @@ -300,8 +305,8 @@ void cso_release_all( struct cso_context *ctx ) for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { pipe_texture_reference(&ctx->textures[i], NULL); pipe_texture_reference(&ctx->textures_saved[i], NULL); - pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); - pipe_sampler_view_reference(&ctx->sampler_views_saved[i], NULL); + pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); + pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { @@ -644,16 +649,16 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, &templ); pipe_texture_reference(&ctx->textures[i], textures[i]); - pipe_sampler_view_reference(&ctx->sampler_views[i], view); + pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], view); } for ( ; i < PIPE_MAX_SAMPLERS; i++) { pipe_texture_reference(&ctx->textures[i], NULL); - pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); } ctx->pipe->set_fragment_sampler_views(ctx->pipe, count, - ctx->sampler_views); + ctx->fragment_sampler_views); return PIPE_OK; } @@ -665,11 +670,11 @@ void cso_save_sampler_textures( struct cso_context *ctx ) ctx->nr_textures_saved = ctx->nr_textures; for (i = 0; i < ctx->nr_textures; i++) { assert(!ctx->textures_saved[i]); - assert(!ctx->sampler_views_saved[i]); + assert(!ctx->fragment_sampler_views_saved[i]); pipe_texture_reference(&ctx->textures_saved[i], ctx->textures[i]); - pipe_sampler_view_reference(&ctx->sampler_views_saved[i], - ctx->sampler_views[i]); + pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], + ctx->fragment_sampler_views[i]); } } @@ -684,18 +689,18 @@ void cso_restore_sampler_textures( struct cso_context *ctx ) ctx->textures[i] = ctx->textures_saved[i]; ctx->textures_saved[i] = NULL; - pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); - ctx->sampler_views[i] = ctx->sampler_views_saved[i]; - ctx->sampler_views_saved[i] = NULL; + pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); + ctx->fragment_sampler_views[i] = ctx->fragment_sampler_views_saved[i]; + ctx->fragment_sampler_views_saved[i] = NULL; } for ( ; i < PIPE_MAX_SAMPLERS; i++) { pipe_texture_reference(&ctx->textures[i], NULL); - pipe_sampler_view_reference(&ctx->sampler_views[i], NULL); + pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); } ctx->pipe->set_fragment_sampler_views(ctx->pipe, ctx->nr_textures, - ctx->sampler_views); + ctx->fragment_sampler_views); ctx->nr_textures_saved = 0; } @@ -1319,3 +1324,122 @@ void cso_restore_vertex_elements(struct cso_context *ctx) } ctx->velements_saved = NULL; } + +/* fragment sampler view state */ + +void +cso_set_fragment_sampler_views(struct cso_context *cso, + uint count, + struct pipe_sampler_view **views) +{ + uint i; + + for (i = 0; i < count; i++) { + pipe_sampler_view_reference(&cso->fragment_sampler_views[i], views[i]); + } + for (; i < cso->nr_fragment_sampler_views; i++) { + pipe_sampler_view_reference(&cso->fragment_sampler_views[i], NULL); + } + + cso->pipe->set_fragment_sampler_views(cso->pipe, + MAX2(count, cso->nr_fragment_sampler_views), + cso->fragment_sampler_views); + + cso->nr_fragment_sampler_views = count; +} + +void +cso_save_fragment_sampler_views(struct cso_context *cso) +{ + uint i; + + cso->nr_fragment_sampler_views_saved = cso->nr_fragment_sampler_views; + + for (i = 0; i < cso->nr_fragment_sampler_views; i++) { + assert(!cso->fragment_sampler_views_saved[i]); + + pipe_sampler_view_reference(&cso->fragment_sampler_views_saved[i], + cso->fragment_sampler_views[i]); + } +} + +void +cso_restore_fragment_sampler_views(struct cso_context *cso) +{ + uint i; + + for (i = 0; i < cso->nr_fragment_sampler_views_saved; i++) { + pipe_sampler_view_reference(&cso->fragment_sampler_views[i], cso->fragment_sampler_views_saved[i]); + pipe_sampler_view_reference(&cso->fragment_sampler_views_saved[i], NULL); + } + for (; i < cso->nr_fragment_sampler_views; i++) { + pipe_sampler_view_reference(&cso->fragment_sampler_views[i], NULL); + } + + cso->pipe->set_fragment_sampler_views(cso->pipe, + MAX2(cso->nr_fragment_sampler_views, cso->nr_fragment_sampler_views_saved), + cso->fragment_sampler_views); + + cso->nr_fragment_sampler_views = cso->nr_fragment_sampler_views_saved; + cso->nr_fragment_sampler_views_saved = 0; +} + + +/* vertex sampler view state */ + +void +cso_set_vertex_sampler_views(struct cso_context *cso, + uint count, + struct pipe_sampler_view **views) +{ + uint i; + + for (i = 0; i < count; i++) { + pipe_sampler_view_reference(&cso->vertex_sampler_views[i], views[i]); + } + for (; i < cso->nr_vertex_sampler_views; i++) { + pipe_sampler_view_reference(&cso->vertex_sampler_views[i], NULL); + } + + cso->pipe->set_vertex_sampler_views(cso->pipe, + MAX2(count, cso->nr_vertex_sampler_views), + cso->vertex_sampler_views); + + cso->nr_vertex_sampler_views = count; +} + +void +cso_save_vertex_sampler_views(struct cso_context *cso) +{ + uint i; + + cso->nr_vertex_sampler_views_saved = cso->nr_vertex_sampler_views; + + for (i = 0; i < cso->nr_vertex_sampler_views; i++) { + assert(!cso->vertex_sampler_views_saved[i]); + + pipe_sampler_view_reference(&cso->vertex_sampler_views_saved[i], + cso->vertex_sampler_views[i]); + } +} + +void +cso_restore_vertex_sampler_views(struct cso_context *cso) +{ + uint i; + + for (i = 0; i < cso->nr_vertex_sampler_views_saved; i++) { + pipe_sampler_view_reference(&cso->vertex_sampler_views[i], cso->vertex_sampler_views_saved[i]); + pipe_sampler_view_reference(&cso->vertex_sampler_views_saved[i], NULL); + } + for (; i < cso->nr_vertex_sampler_views; i++) { + pipe_sampler_view_reference(&cso->vertex_sampler_views[i], NULL); + } + + cso->pipe->set_vertex_sampler_views(cso->pipe, + MAX2(cso->nr_vertex_sampler_views, cso->nr_vertex_sampler_views_saved), + cso->vertex_sampler_views); + + cso->nr_vertex_sampler_views = cso->nr_vertex_sampler_views_saved; + cso->nr_vertex_sampler_views_saved = 0; +} diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 9c16abd28dd..e476cf4adef 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -198,6 +198,34 @@ void cso_restore_clip(struct cso_context *cso); +/* fragment sampler view state */ + +void +cso_set_fragment_sampler_views(struct cso_context *cso, + uint count, + struct pipe_sampler_view **views); + +void +cso_save_fragment_sampler_views(struct cso_context *cso); + +void +cso_restore_fragment_sampler_views(struct cso_context *cso); + + +/* vertex sampler view state */ + +void +cso_set_vertex_sampler_views(struct cso_context *cso, + uint count, + struct pipe_sampler_view **views); + +void +cso_save_vertex_sampler_views(struct cso_context *cso); + +void +cso_restore_vertex_sampler_views(struct cso_context *cso); + + #ifdef __cplusplus } #endif From b8030c6561e019e079b5be2fe64ec804df4bfa03 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 12 Mar 2010 14:37:36 +0100 Subject: [PATCH 046/483] st/mesa: Associate a sampler view with an st texture object. Lazily create a sampler view when the texture is being bound for the first time. --- .../state_tracker/st_atom_pixeltransfer.c | 2 + src/mesa/state_tracker/st_atom_texture.c | 20 ++++---- src/mesa/state_tracker/st_cb_bitmap.c | 48 ++++++++++++------- src/mesa/state_tracker/st_cb_drawpixels.c | 46 +++++++++++------- src/mesa/state_tracker/st_cb_texture.c | 4 ++ src/mesa/state_tracker/st_context.c | 4 +- src/mesa/state_tracker/st_context.h | 3 +- src/mesa/state_tracker/st_texture.h | 39 +++++++++++++++ 8 files changed, 119 insertions(+), 47 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 0b2e3f53812..e766b3a9038 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -257,6 +257,8 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key) /* create the colormap/texture now if not already done */ if (!st->pixel_xfer.pixelmap_texture) { st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx); + st->pixel_xfer.pixelmap_sampler_view = st_sampler_view_from_texture(ctx->st->pipe, + st->pixel_xfer.pixelmap_texture); } /* with a little effort, we can do four pixel map look-ups with diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 57b71c1e7b0..241c001f94f 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -56,7 +56,7 @@ update_textures(struct st_context *st) /* loop over sampler units (aka tex image units) */ for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) { - struct pipe_texture *pt = NULL; + struct pipe_sampler_view *sampler_view = NULL; if (samplersUsed & (1 << su)) { struct gl_texture_object *texObj; @@ -84,7 +84,7 @@ update_textures(struct st_context *st) st->state.num_textures = su + 1; - pt = st_get_stobj_texture(stObj); + sampler_view = st_get_stobj_sampler_view(stObj); } /* @@ -96,17 +96,17 @@ update_textures(struct st_context *st) } */ - pipe_texture_reference(&st->state.sampler_texture[su], pt); + pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view); } - cso_set_sampler_textures(st->cso_context, - st->state.num_textures, - st->state.sampler_texture); + cso_set_fragment_sampler_views(st->cso_context, + st->state.num_textures, + st->state.sampler_views); if (st->ctx->Const.MaxVertexTextureImageUnits > 0) { - cso_set_vertex_sampler_textures(st->cso_context, - MIN2(st->state.num_textures, - st->ctx->Const.MaxVertexTextureImageUnits), - st->state.sampler_texture); + cso_set_vertex_sampler_views(st->cso_context, + MIN2(st->state.num_textures, + st->ctx->Const.MaxVertexTextureImageUnits), + st->state.sampler_views); } } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index f326601c3be..25d33b933e3 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -398,7 +398,7 @@ setup_bitmap_vertex_data(struct st_context *st, static void draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, GLsizei width, GLsizei height, - struct pipe_texture *pt, + struct pipe_sampler_view *sv, const GLfloat *color) { struct st_context *st = ctx->st; @@ -436,7 +436,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_save_rasterizer(cso); cso_save_samplers(cso); - cso_save_sampler_textures(cso); + cso_save_fragment_sampler_views(cso); cso_save_viewport(cso); cso_save_fragment_shader(cso); cso_save_vertex_shader(cso); @@ -466,11 +466,11 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* user textures, plus the bitmap texture */ { - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; uint num = MAX2(stfp->bitmap_sampler + 1, st->state.num_textures); - memcpy(textures, st->state.sampler_texture, sizeof(textures)); - textures[stfp->bitmap_sampler] = pt; - cso_set_sampler_textures(cso, num, textures); + memcpy(sampler_views, st->state.sampler_views, sizeof(sampler_views)); + sampler_views[stfp->bitmap_sampler] = sv; + cso_set_fragment_sampler_views(cso, num, sampler_views); } /* viewport state: viewport matching window dims */ @@ -508,7 +508,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* restore state */ cso_restore_rasterizer(cso); cso_restore_samplers(cso); - cso_restore_sampler_textures(cso); + cso_restore_fragment_sampler_views(cso); cso_restore_viewport(cso); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); @@ -602,6 +602,7 @@ st_flush_bitmap_cache(struct st_context *st) if (st->ctx->DrawBuffer) { struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; + struct pipe_sampler_view *sv; assert(cache->xmin <= cache->xmax); @@ -624,13 +625,18 @@ st_flush_bitmap_cache(struct st_context *st) cache->trans = NULL; } - draw_bitmap_quad(st->ctx, - cache->xpos, - cache->ypos, - cache->zpos, - BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, - cache->texture, - cache->color); + sv = st_sampler_view_from_texture(st->pipe, cache->texture); + if (sv) { + draw_bitmap_quad(st->ctx, + cache->xpos, + cache->ypos, + cache->zpos, + BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, + sv, + cache->color); + + pipe_sampler_view_reference(&sv, NULL); + } } /* release/free the texture */ @@ -753,10 +759,18 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { + struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt); + assert(pt->target == PIPE_TEXTURE_2D); - draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, pt, - st->ctx->Current.RasterColor); + + if (sv) { + draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], + width, height, sv, + st->ctx->Current.RasterColor); + + pipe_sampler_view_reference(&sv, NULL); + } + /* release/free the texture */ pipe_texture_reference(&pt, NULL); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d542c996d07..236010c5b5d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -503,7 +503,7 @@ static void draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, GLsizei width, GLsizei height, GLfloat zoomX, GLfloat zoomY, - struct pipe_texture *pt, + struct pipe_sampler_view *sv, void *driver_vp, void *driver_fp, const GLfloat *color, @@ -526,7 +526,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_save_rasterizer(cso); cso_save_viewport(cso); cso_save_samplers(cso); - cso_save_sampler_textures(cso); + cso_save_fragment_sampler_views(cso); cso_save_fragment_shader(cso); cso_save_vertex_shader(cso); cso_save_vertex_elements(cso); @@ -586,13 +586,13 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* texture state: */ if (st->pixel_xfer.pixelmap_enabled) { - struct pipe_texture *textures[2]; - textures[0] = pt; - textures[1] = st->pixel_xfer.pixelmap_texture; - cso_set_sampler_textures(cso, 2, textures); + struct pipe_sampler_view *sampler_views[2]; + sampler_views[0] = sv; + sampler_views[1] = st->pixel_xfer.pixelmap_sampler_view; + cso_set_fragment_sampler_views(cso, 2, sampler_views); } else { - cso_set_sampler_textures(cso, 1, &pt); + cso_set_fragment_sampler_views(cso, 1, &sv); } /* Compute window coords (y=0=bottom) with pixel zoom. @@ -608,14 +608,14 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, z = z * 2.0 - 1.0; draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex, - (GLfloat) width / pt->width0, - (GLfloat) height / pt->height0); + (GLfloat) width / sv->texture->width0, + (GLfloat) height / sv->texture->height0); /* restore state */ cso_restore_rasterizer(cso); cso_restore_viewport(cso); cso_restore_samplers(cso); - cso_restore_sampler_textures(cso); + cso_restore_fragment_sampler_views(cso); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); cso_restore_vertex_elements(cso); @@ -809,12 +809,17 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, struct pipe_texture *pt = make_texture(st, width, height, format, type, unpack, pixels); if (pt) { - draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, - pt, - driver_vp, - driver_fp, - color, GL_FALSE); + struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt); + + if (sv) { + draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], + width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, + sv, + driver_vp, + driver_fp, + color, GL_FALSE); + pipe_sampler_view_reference(&sv, NULL); + } pipe_texture_reference(&pt, NULL); } } @@ -933,6 +938,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, struct st_renderbuffer *rbRead; void *driver_vp, *driver_fp; struct pipe_texture *pt; + struct pipe_sampler_view *sv; GLfloat *color; enum pipe_format srcFormat, texFormat; int ptw, pth; @@ -1050,6 +1056,11 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (!pt) return; + sv = st_sampler_view_from_texture(st->pipe, pt); + if (!sv) { + pipe_texture_reference(&pt, NULL); + return; + } if (srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ @@ -1118,12 +1129,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* draw textured quad */ draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2], width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, - pt, + sv, driver_vp, driver_fp, color, GL_TRUE); pipe_texture_reference(&pt, NULL); + pipe_sampler_view_reference(&sv, NULL); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index c849132e74c..76846560f9f 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -123,6 +123,8 @@ st_DeleteTextureObject(GLcontext *ctx, struct st_texture_object *stObj = st_texture_object(texObj); if (stObj->pt) pipe_texture_reference(&stObj->pt, NULL); + if (stObj->sampler_view) + pipe_sampler_view_reference(&stObj->sampler_view, NULL); _mesa_delete_texture_object(ctx, texObj); } @@ -312,6 +314,8 @@ guess_and_alloc_texture(struct st_context *st, depth, usage); + stObj->pipe = st->pipe; + DBG("%s - success\n", __FUNCTION__); } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 09f891d691a..e978415c200 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -215,8 +215,8 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_drawtex(st); #endif - for (i = 0; i < Elements(st->state.sampler_texture); i++) { - pipe_texture_reference(&st->state.sampler_texture[i], NULL); + for (i = 0; i < Elements(st->state.sampler_views); i++) { + pipe_sampler_view_reference(&st->state.sampler_views[i], NULL); } for (i = 0; i < Elements(st->state.constants); i++) { diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 6622361a7e3..ae73817c0e6 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -94,7 +94,7 @@ struct st_context struct pipe_clip_state clip; struct pipe_buffer *constants[2]; struct pipe_framebuffer_state framebuffer; - struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; @@ -141,6 +141,7 @@ struct st_context struct st_fragment_program *combined_prog; GLuint combined_prog_sn; struct pipe_texture *pixelmap_texture; + struct pipe_sampler_view *pixelmap_sampler_view; boolean pixelmap_enabled; /**< use the pixelmap texture? */ } pixel_xfer; diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 60868ce0673..c62f7f2cc0d 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -29,6 +29,9 @@ #define ST_TEXTURE_H +#include "pipe/p_context.h" +#include "util/u_sampler.h" + #include "main/mtypes.h" struct pipe_context; @@ -68,6 +71,13 @@ struct st_texture_object */ struct pipe_texture *pt; + /* Default sampler view attached to this texture object. Created lazily + * on first binding. + */ + struct pipe_sampler_view *sampler_view; + + struct pipe_context *pipe; + GLboolean teximage_realloc; /* True if there is/was a surface bound to this texture object. It helps @@ -105,6 +115,35 @@ st_get_stobj_texture(struct st_texture_object *stObj) } +static INLINE struct pipe_sampler_view * +st_sampler_view_from_texture(struct pipe_context *pipe, + struct pipe_texture *texture) +{ + struct pipe_sampler_view templ; + + u_sampler_view_default_template(&templ, + texture, + texture->format); + + return pipe->create_sampler_view(pipe, texture, &templ); +} + + +static INLINE struct pipe_sampler_view * +st_get_stobj_sampler_view(struct st_texture_object *stObj) +{ + if (!stObj || !stObj->pt) { + return NULL; + } + + if (!stObj->sampler_view) { + stObj->sampler_view = st_sampler_view_from_texture(stObj->pipe, stObj->pt); + } + + return stObj->sampler_view; +} + + extern struct pipe_texture * st_texture_create(struct st_context *st, enum pipe_texture_target target, From faa14818856e1e9a4ee624c2bc04d7aecabd07ab Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 12 Mar 2010 14:43:11 +0100 Subject: [PATCH 047/483] cso: Remove set/save/restore_vertex_sampler_textures(). --- src/gallium/auxiliary/cso_cache/cso_context.c | 87 ------------------- src/gallium/auxiliary/cso_cache/cso_context.h | 11 --- 2 files changed, 98 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 5c16e0959d6..648ba10a995 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -76,18 +76,14 @@ struct cso_context { struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; uint nr_textures; - struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; uint nr_vertex_sampler_views; struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; - uint nr_vertex_textures; uint nr_textures_saved; struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS]; uint nr_fragment_sampler_views_saved; struct pipe_sampler_view *fragment_sampler_views_saved[PIPE_MAX_SAMPLERS]; - uint nr_vertex_textures_saved; - struct pipe_texture *vertex_textures_saved[PIPE_MAX_VERTEX_SAMPLERS]; uint nr_vertex_sampler_views_saved; struct pipe_sampler_view *vertex_sampler_views_saved[PIPE_MAX_VERTEX_SAMPLERS]; @@ -310,8 +306,6 @@ void cso_release_all( struct cso_context *ctx ) } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->vertex_textures[i], NULL); - pipe_texture_reference(&ctx->vertex_textures_saved[i], NULL); pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], NULL); } @@ -706,87 +700,6 @@ void cso_restore_sampler_textures( struct cso_context *ctx ) } - -enum pipe_error -cso_set_vertex_sampler_textures(struct cso_context *ctx, - uint count, - struct pipe_texture **textures) -{ - uint i; - - ctx->nr_vertex_textures = count; - - for (i = 0; i < count; i++) { - struct pipe_sampler_view templ, *view; - - u_sampler_view_default_template(&templ, - textures[i], - textures[i]->format); - view = ctx->pipe->create_sampler_view(ctx->pipe, - textures[i], - &templ); - - pipe_texture_reference(&ctx->vertex_textures[i], textures[i]); - pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], view); - } - for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->vertex_textures[i], NULL); - pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); - } - - ctx->pipe->set_vertex_sampler_views(ctx->pipe, - count, - ctx->vertex_sampler_views); - - return PIPE_OK; -} - -void -cso_save_vertex_sampler_textures(struct cso_context *ctx) -{ - uint i; - - ctx->nr_vertex_textures_saved = ctx->nr_vertex_textures; - for (i = 0; i < ctx->nr_vertex_textures; i++) { - assert(!ctx->vertex_textures_saved[i]); - assert(!ctx->vertex_sampler_views_saved[i]); - - pipe_texture_reference(&ctx->vertex_textures_saved[i], ctx->vertex_textures[i]); - pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], - ctx->vertex_sampler_views[i]); - } -} - -void -cso_restore_vertex_sampler_textures(struct cso_context *ctx) -{ - uint i; - - ctx->nr_vertex_textures = ctx->nr_vertex_textures_saved; - - for (i = 0; i < ctx->nr_vertex_textures; i++) { - pipe_texture_reference(&ctx->vertex_textures[i], NULL); - ctx->vertex_textures[i] = ctx->vertex_textures_saved[i]; - ctx->vertex_textures_saved[i] = NULL; - - pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); - ctx->vertex_sampler_views[i] = ctx->vertex_sampler_views_saved[i]; - ctx->vertex_sampler_views_saved[i] = NULL; - } - for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->vertex_textures[i], NULL); - pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL); - } - - ctx->pipe->set_vertex_sampler_views(ctx->pipe, - ctx->nr_vertex_textures, - ctx->vertex_sampler_views); - - ctx->nr_vertex_textures_saved = 0; -} - - - enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx, const struct pipe_depth_stencil_alpha_state *templ) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index e476cf4adef..a24077e009c 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -111,17 +111,6 @@ void cso_save_sampler_textures( struct cso_context *cso ); void cso_restore_sampler_textures( struct cso_context *cso ); - -enum pipe_error -cso_set_vertex_sampler_textures(struct cso_context *cso, - uint count, - struct pipe_texture **textures); -void -cso_save_vertex_sampler_textures(struct cso_context *cso); -void -cso_restore_vertex_sampler_textures(struct cso_context *cso); - - enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, unsigned count, const struct pipe_vertex_element *states); From 495bfb0ad2e60638e7b2e94f36f0079e3f450091 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 00:52:47 +0800 Subject: [PATCH 048/483] st/glx: Fix leaks in xmesa_st_framebuffer. The textures and surface of a framebuffer should be unreferenced when the framebuffer is destroyed. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 3b5f78e98ad..d462776363c 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -225,6 +225,12 @@ void xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) { struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + int i; + + pipe_surface_reference(&xstfb->display_surface, NULL); + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&xstfb->textures[i], NULL); FREE(xstfb); FREE(stfbi); From fecb97aab42e1a099f12cc7a47ed7219cd041809 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 14:57:32 +0800 Subject: [PATCH 049/483] st/egl: Fix eglCopyBuffers. Use a (real) pipe context to copy between pipe surfaces. Fix a NULL dereference of the temporary native surface created for copying. --- .../state_trackers/egl/common/egl_g3d.c | 34 ++++++++++++------- .../state_trackers/egl/common/egl_g3d.h | 1 + 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 783b8e56b38..5eabe10558a 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -323,8 +323,13 @@ egl_g3d_invalid_surface(struct native_display *ndpy, { /* XXX not thread safe? */ struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data); - struct egl_g3d_context *gctx = egl_g3d_context(gsurf->base.CurrentContext); - + struct egl_g3d_context *gctx; + + /* + * Some functions such as egl_g3d_copy_buffers create a temporary native + * surface. There is no gsurf associated with it. + */ + gctx = (gsurf) ? egl_g3d_context(gsurf->base.CurrentContext) : NULL; if (gctx) gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gsurf->stfbi); } @@ -342,6 +347,9 @@ egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) _eglReleaseDisplayResources(drv, dpy); _eglCleanupDisplay(dpy); + if (gdpy->pipe) + gdpy->pipe->destroy(gdpy->pipe); + if (dpy->Screens) { for (i = 0; i < dpy->NumScreens; i++) { struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]); @@ -778,7 +786,7 @@ get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, return NULL; psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], - 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); + 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); pipe_texture_reference(&textures[natt], NULL); return psurf; @@ -815,22 +823,22 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } + /* create a pipe context to copy surfaces */ + if (!gdpy->pipe) { + gdpy->pipe = + gdpy->native->screen->context_create(gdpy->native->screen, NULL); + if (!gdpy->pipe) + return EGL_FALSE; + } + psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); if (psurf) { - struct pipe_context pipe; struct pipe_surface *psrc; - /** - * XXX This is hacky. We should probably create a pipe context for - * EGLDisplay and use a blitter context for this. - */ - memset(&pipe, 0, sizeof(pipe)); - pipe.screen = screen; - psrc = screen->get_tex_surface(screen, gsurf->render_texture, - 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); + 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); if (psrc) { - util_surface_copy(&pipe, FALSE, psurf, 0, 0, + gdpy->pipe->surface_copy(gdpy->pipe, psurf, 0, 0, psrc, 0, 0, psurf->width, psurf->height); pipe_surface_reference(&psrc, NULL); diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h index 07a87f8bc73..2788f1bf4ac 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -53,6 +53,7 @@ struct egl_g3d_display { struct native_display *native; struct st_manager *smapi; + struct pipe_context *pipe; }; struct egl_g3d_context { From 813c58d77e21cb59adb914b4b4ee26be758ff0ea Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 15:57:15 +0800 Subject: [PATCH 050/483] st/glx: Make xmesa_create_st_api a callback of xm_driver. Instead of guessing the API in st/glx, let the target decide how to create st_api. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_public.h | 12 ++++++++---- src/gallium/state_trackers/glx/xlib/xm_st.c | 11 ----------- src/gallium/state_trackers/glx/xlib/xm_st.h | 3 --- src/gallium/targets/libgl-xlib/xlib.c | 3 ++- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 3ea4d77805f..82384a4d284 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -708,7 +708,7 @@ xmesa_init( Display *display ) if (firstTime) { pipe_mutex_init(_xmesa_lock); screen = driver.create_pipe_screen( display ); - stapi = xmesa_create_st_api(); + stapi = driver.create_st_api(); smapi = CALLOC_STRUCT(st_manager); if (smapi) smapi->screen = screen; diff --git a/src/gallium/state_trackers/glx/xlib/xm_public.h b/src/gallium/state_trackers/glx/xlib/xm_public.h index ac6a8ffb27a..950eb21521f 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_public.h +++ b/src/gallium/state_trackers/glx/xlib/xm_public.h @@ -26,19 +26,23 @@ * **************************************************************************/ -#ifndef XM_WINSYS_H -#define XM_WINSYS_H +#ifndef XM_PUBLIC_H +#define XM_PUBLIC_H -struct xm_driver; +#include + +struct pipe_screen; +struct st_api; /* This is the driver interface required by the glx/xlib state tracker. */ struct xm_driver { struct pipe_screen *(*create_pipe_screen)( Display *display ); + struct st_api *(*create_st_api)( void ); }; extern void xmesa_set_driver( const struct xm_driver *driver ); -#endif +#endif /* XM_PUBLIC_H */ diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index d462776363c..abe3b5429bc 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -31,11 +31,6 @@ #include "xm_api.h" #include "xm_st.h" -/* support OpenGL by default */ -#ifndef XMESA_ST_MODULE -#define XMESA_ST_MODULE st_module_OpenGL -#endif - struct xmesa_st_framebuffer { struct pipe_screen *screen; XMesaBuffer buffer; @@ -267,9 +262,3 @@ xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi, { /* TODO */ } - -struct st_api * -xmesa_create_st_api(void) -{ - return XMESA_ST_MODULE.create_api(); -} diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.h b/src/gallium/state_trackers/glx/xlib/xm_st.h index 7ca7afe2531..b22a8373801 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.h +++ b/src/gallium/state_trackers/glx/xlib/xm_st.h @@ -33,9 +33,6 @@ #include "xm_api.h" -struct st_api * -xmesa_create_st_api(void); - struct st_framebuffer_iface * xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b); diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 50dd99ffce1..1e6769367f4 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -104,9 +104,10 @@ fail: return NULL; } -struct xm_driver xlib_driver = +static struct xm_driver xlib_driver = { .create_pipe_screen = swrast_xlib_create_screen, + .create_st_api = st_manager_create_api, }; From f91d8c6885c8944322991115b739cee3e2fdf6bd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 17:00:24 +0800 Subject: [PATCH 051/483] st/mesa: Set revalidate in st_framebuffer_update_attachments. There are two conditions that a validation is required. One is when the the framebuffer becomes invalid. The other is when we request for textures that we did not request before. --- src/mesa/state_tracker/st_manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index f0dda4be6e9..9475704121c 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -226,6 +226,8 @@ st_framebuffer_update_attachments(struct st_framebuffer *stfb) st_visual_have_buffers(stfb->iface->visual, 1 << statt)) stfb->statts[stfb->num_statts++] = statt; } + + p_atomic_set(&stfb->revalidate, TRUE); } /** @@ -438,7 +440,6 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi) st_framebuffer_update_attachments(stfb); - p_atomic_set(&stfb->revalidate, TRUE); stfb->Base.Initialized = GL_TRUE; return stfb; From 418b9ac2990fc6809de359a862ee809d3b86343c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 17:39:14 +0800 Subject: [PATCH 052/483] st/glx: Correctly set buffer_mask of a visual. Stupid typos again.. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 82384a4d284..94c0ad496d4 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -666,11 +666,11 @@ XMesaVisual XMesaCreateVisual( Display *display, v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK; if (db_flag) - v->stvis.buffer_mask = ST_ATTACHMENT_BACK_LEFT_MASK; + v->stvis.buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; if (stereo_flag) { - v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_RIGHT_MASK; + v->stvis.buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; if (db_flag) - v->stvis.buffer_mask = ST_ATTACHMENT_BACK_RIGHT_MASK; + v->stvis.buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; } v->stvis.color_format = choose_pixel_format(v); From 66cd38f465499863de106e1ae83b5de85072c29b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 17:40:24 +0800 Subject: [PATCH 053/483] st/glx: Fix framebuffer validation. When xmesa_st_framebuffer_validate was called twice with different sets of attachments, the second call was ignored. Add a texture_mask to remember which textures have been requested to make sure the missing ones get created. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 53 +++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index abe3b5429bc..8714da8b346 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -37,7 +37,7 @@ struct xmesa_st_framebuffer { struct st_visual stvis; - unsigned texture_width, texture_height; + unsigned texture_width, texture_height, texture_mask; struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; struct pipe_surface *display_surface; @@ -86,39 +86,37 @@ xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi, */ static void xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi, - const enum st_attachment_type *statts, - unsigned count) + unsigned width, unsigned height, + unsigned mask) { struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); struct pipe_texture templ; - unsigned request_mask, i; + unsigned i; - request_mask = 0; - for (i = 0; i < count; i++) - request_mask |= 1 << statts[i]; + /* remove outdated textures */ + if (xstfb->texture_width != width || xstfb->texture_height != height) { + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&xstfb->textures[i], NULL); + } memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_2D; - templ.width0 = xstfb->texture_width; - templ.height0 = xstfb->texture_height; + templ.width0 = width; + templ.height0 = height; templ.depth0 = 1; templ.last_level = 0; for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - struct pipe_texture *ptex = xstfb->textures[i]; enum pipe_format format; unsigned tex_usage; - /* remove outdated textures */ - if (ptex && (ptex->width0 != xstfb->texture_width || - ptex->height0 != xstfb->texture_height)) { - pipe_texture_reference(&xstfb->textures[i], NULL); - ptex = NULL; - } - /* the texture already exists or not requested */ - if (ptex || !(request_mask & (1 << i))) + if (xstfb->textures[i] || !(mask & (1 << i))) { + /* remember the texture */ + if (xstfb->textures[i]) + mask |= (1 << i); continue; + } switch (i) { case ST_ATTACHMENT_FRONT_LEFT: @@ -146,6 +144,10 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi, xstfb->screen->texture_create(xstfb->screen, &templ); } } + + xstfb->texture_width = width; + xstfb->texture_height = height; + xstfb->texture_mask = mask; } static boolean @@ -155,15 +157,18 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, struct pipe_texture **out) { struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); - unsigned i; + unsigned statt_mask, i; + + statt_mask = 0x0; + for (i = 0; i < count; i++) + statt_mask |= 1 << statts[i]; /* revalidate textures */ if (xstfb->buffer->width != xstfb->texture_width || - xstfb->buffer->height != xstfb->texture_height) { - xstfb->texture_width = xstfb->buffer->width; - xstfb->texture_height = xstfb->buffer->height; - - xmesa_st_framebuffer_validate_textures(stfbi, statts, count); + xstfb->buffer->height != xstfb->texture_height || + (xstfb->texture_mask & statt_mask) != statt_mask) { + xmesa_st_framebuffer_validate_textures(stfbi, + xstfb->buffer->width, xstfb->buffer->height, statt_mask); } for (i = 0; i < count; i++) { From 63af29bfbe265318bcf5be69e420de361b900321 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Mar 2010 18:32:10 +0000 Subject: [PATCH 054/483] mesa: Fix memory leak in decompress-with-blit. (cherry picked from commit f05a4ee6f2840590c90da4be2fe5c6295410a5af) --- src/mesa/state_tracker/st_cb_texture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index c849132e74c..92eefca2e79 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -880,6 +880,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, _mesa_unmap_pbo_dest(ctx, &ctx->Pack); + screen->tex_transfer_destroy(tex_xfer); + /* destroy the temp / dest surface */ util_destroy_rgba_surface(dst_texture, dst_surface); } From 8c210c1b3b5e63eebae2b73814d2000520576ce7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Mar 2010 20:30:03 +0800 Subject: [PATCH 055/483] st/mesa: Validate the state in st_readpixels. The front renderbuffer of a framebuffer is usually added as needed when glReadBuffer(GL_FRONT) is called. When the call is followed by glReadPixels, we should validate the state before reading from the renderbuffer. --- src/mesa/state_tracker/st_cb_readpixels.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 8cc9cfac76f..f0a02ab7664 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -45,6 +45,7 @@ #include "st_debug.h" #include "st_context.h" +#include "st_atom.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" #include "st_public.h" @@ -352,6 +353,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* XXX convolution not done yet */ assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0); + st_validate_state(ctx->st); + /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { /* The ReadPixels transfer is totally outside the window bounds */ From 4a30330b26b543dfa864a05a1e8072f764369a25 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 14 Mar 2010 00:10:09 +0800 Subject: [PATCH 056/483] st/mesa: Fix handling of FBO. FBOs are created by st_new_framebuffer and cannot be casted to st_framebuffer. --- src/mesa/state_tracker/st_manager.c | 40 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 9475704121c..d04d72d48aa 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -59,6 +59,16 @@ void st_destroy_context(struct st_context *st); void st_flush(struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence); +/** + * Note that this function may fail. + */ +static INLINE struct st_framebuffer * +st_framebuffer(GLframebuffer *fb) +{ + /* FBO cannot be casted. See st_new_framebuffer */ + return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL); +} + /** * Map an attachment to a buffer index. */ @@ -464,9 +474,9 @@ st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi, struct st_framebuffer *stfb; /* either draw or read winsys fb */ - stfb = (struct st_framebuffer *) st->ctx->WinSysDrawBuffer; + stfb = st_framebuffer(st->ctx->WinSysDrawBuffer); if (!stfb || stfb->iface != stfbi) - stfb = (struct st_framebuffer *) st->ctx->WinSysReadBuffer; + stfb = st_framebuffer(st->ctx->WinSysReadBuffer); assert(stfb && stfb->iface == stfbi); p_atomic_set(&stfb->revalidate, TRUE); @@ -606,7 +616,7 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, if (st) { /* reuse/create the draw fb */ - stfb = (struct st_framebuffer * ) st->ctx->DrawBuffer; + stfb = st_framebuffer(st->ctx->WinSysDrawBuffer); if (stfb && stfb->iface == stdrawi) { stdraw = NULL; st_framebuffer_reference(&stdraw, stfb); @@ -616,7 +626,7 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, } /* reuse/create the read fb */ - stfb = (struct st_framebuffer * ) st->ctx->ReadBuffer; + stfb = st_framebuffer(st->ctx->WinSysReadBuffer); if (!stfb || stfb->iface != streadi) stfb = stdraw; if (stfb && stfb->iface == streadi) { @@ -688,7 +698,7 @@ st_api_destroy(struct st_api *stapi) void st_manager_flush_frontbuffer(struct st_context *st) { - struct st_framebuffer *stfb = (struct st_framebuffer *) st->ctx->DrawBuffer; + struct st_framebuffer *stfb = st_framebuffer(st->ctx->DrawBuffer); struct st_renderbuffer *strb = NULL; if (stfb) @@ -696,7 +706,7 @@ st_manager_flush_frontbuffer(struct st_context *st) if (!strb) return; - /* st_public.h or FBO */ + /* st_public.h */ if (!stfb->iface) { struct pipe_surface *front_surf = strb->surface; st->pipe->screen->flush_frontbuffer(st->pipe->screen, @@ -713,12 +723,10 @@ st_manager_flush_frontbuffer(struct st_context *st) void st_manager_validate_framebuffers(struct st_context *st) { - struct st_framebuffer *stdraw, *stread; + struct st_framebuffer *stdraw = st_framebuffer(st->ctx->DrawBuffer); + struct st_framebuffer *stread = st_framebuffer(st->ctx->ReadBuffer); - stdraw = (struct st_framebuffer *) st->ctx->DrawBuffer; - stread = (struct st_framebuffer *) st->ctx->ReadBuffer; - - /* st_public.h or FBO */ + /* st_public.h */ if ((stdraw && !stdraw->iface) || (stread && !stread->iface)) { struct pipe_screen *screen = st->pipe->screen; if (screen->update_buffer) @@ -739,15 +747,15 @@ boolean st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, gl_buffer_index idx) { - struct st_framebuffer *stfb = (struct st_framebuffer *) fb; + struct st_framebuffer *stfb = st_framebuffer(fb); + + /* FBO or st_public.h */ + if (!stfb || !stfb->iface) + return FALSE; if (stfb->Base.Attachment[idx].Renderbuffer) return TRUE; - /* st_public.h or FBO */ - if (!stfb->iface) - return FALSE; - switch (idx) { case BUFFER_FRONT_LEFT: case BUFFER_BACK_LEFT: From 6632915e957149c153a3f793c400a532b4995b18 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 14 Mar 2010 11:20:58 +0800 Subject: [PATCH 057/483] st/glx: Add xmesa_display to hold per-display variables. This basically adds a static xmesa_display to collect per-display static variables in xm_api.c. Multiple display support is still missing, but this is a step forward. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 117 ++++++++++--------- src/gallium/state_trackers/glx/xlib/xm_api.h | 14 ++- 2 files changed, 73 insertions(+), 58 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 94c0ad496d4..e7c1979b424 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -70,21 +70,56 @@ * global. */ static struct xm_driver driver; +static struct st_api *stapi; void xmesa_set_driver( const struct xm_driver *templ ) { driver = *templ; + stapi = driver.create_st_api(); } -/** - * Global X driver lock - */ -pipe_mutex _xmesa_lock; +static XMesaDisplay +xmesa_init_display( Display *display ) +{ + pipe_static_mutex(init_mutex); + static struct xmesa_display xm_display; + XMesaDisplay xmdpy; + + pipe_mutex_lock(init_mutex); -static struct pipe_screen *screen = NULL; -static struct st_api *stapi = NULL; -static struct st_manager *smapi = NULL; + /* TODO support for multiple displays */ + xmdpy = &xm_display; + if (!xmdpy->display && display) { + xmdpy->display = display; + xmdpy->screen = driver.create_pipe_screen(display); + xmdpy->smapi = CALLOC_STRUCT(st_manager); + if (xmdpy->smapi) + xmdpy->smapi->screen = xmdpy->screen; + + if (xmdpy->screen && xmdpy->smapi) { + pipe_mutex_init(xmdpy->mutex); + } + else { + if (xmdpy->screen) { + xmdpy->screen->destroy(xmdpy->screen); + xmdpy->screen = NULL; + } + if (xmdpy->smapi) { + FREE(xmdpy->smapi); + xmdpy->smapi = NULL; + } + + xmdpy->display = NULL; + } + } + if (!xmdpy->display || xmdpy->display != display) + xmdpy = NULL; + + pipe_mutex_unlock(init_mutex); + + return xmdpy; +} /**********************************************************************/ /***** X Utility Functions *****/ @@ -194,12 +229,13 @@ void xmesa_get_window_size(Display *dpy, XMesaBuffer b, GLuint *width, GLuint *height) { + XMesaDisplay xmdpy = xmesa_init_display(dpy); Status stat; - pipe_mutex_lock(_xmesa_lock); + pipe_mutex_lock(xmdpy->mutex); XSync(b->xm_visual->display, 0); /* added for Chromium */ stat = get_drawable_size(dpy, b->ws.drawable, width, height); - pipe_mutex_unlock(_xmesa_lock); + pipe_mutex_unlock(xmdpy->mutex); if (!stat) { /* probably querying a window that's recently been destroyed */ @@ -278,7 +314,7 @@ choose_pixel_format(XMesaVisual v) * stencil sizes. */ static enum pipe_format -choose_depth_stencil_format(int depth, int stencil) +choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil) { const enum pipe_texture_target target = PIPE_TEXTURE_2D; const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; @@ -287,8 +323,6 @@ choose_depth_stencil_format(int depth, int stencil) enum pipe_format formats[8], fmt; int count, i; - assert(screen); - count = 0; if (depth <= 24 && stencil <= 8) { formats[count++] = PIPE_FORMAT_S8Z24_UNORM; @@ -304,7 +338,7 @@ choose_depth_stencil_format(int depth, int stencil) fmt = PIPE_FORMAT_NONE; for (i = 0; i < count; i++) { - if (screen->is_format_supported(screen, formats[i], + if (xmdpy->screen->is_format_supported(xmdpy->screen, formats[i], target, tex_usage, geom_flags)) { fmt = formats[i]; break; @@ -320,7 +354,7 @@ choose_depth_stencil_format(int depth, int stencil) /***** Linked list of XMesaBuffers *****/ /**********************************************************************/ -XMesaBuffer XMesaBufferList = NULL; +static XMesaBuffer XMesaBufferList = NULL; /** @@ -338,13 +372,13 @@ static XMesaBuffer create_xmesa_buffer(Drawable d, BufferType type, XMesaVisual vis, Colormap cmap) { + XMesaDisplay xmdpy = xmesa_init_display(vis->display); XMesaBuffer b; uint width, height; ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); - xmesa_init(vis->display); - if (!screen) + if (!xmdpy) return NULL; b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer); @@ -364,7 +398,7 @@ create_xmesa_buffer(Drawable d, BufferType type, /* * Create framebuffer, but we'll plug in our own renderbuffers below. */ - b->stfb = xmesa_create_st_framebuffer(screen, b); + b->stfb = xmesa_create_st_framebuffer(xmdpy->screen, b); /* GLX_EXT_texture_from_pixmap */ b->TextureTarget = 0; @@ -579,10 +613,12 @@ XMesaVisual XMesaCreateVisual( Display *display, GLint level, GLint visualCaveat ) { + XMesaDisplay xmdpy = xmesa_init_display(display); XMesaVisual v; GLint red_bits, green_bits, blue_bits, alpha_bits; - xmesa_init( display ); + if (!xmdpy) + return NULL; /* For debugging only */ if (_mesa_getenv("MESA_XSYNC")) { @@ -675,7 +711,7 @@ XMesaVisual XMesaCreateVisual( Display *display, v->stvis.color_format = choose_pixel_format(v); v->stvis.depth_stencil_format = - choose_depth_stencil_format(depth_size, stencil_size); + choose_depth_stencil_format(xmdpy, depth_size, stencil_size); v->stvis.accum_format = (accum_red_size + accum_green_size + accum_blue_size + accum_alpha_size) ? @@ -699,37 +735,12 @@ void XMesaDestroyVisual( XMesaVisual v ) /** - * Do one-time initializations. + * Do per-display initializations. */ void xmesa_init( Display *display ) { - static GLboolean firstTime = GL_TRUE; - if (firstTime) { - pipe_mutex_init(_xmesa_lock); - screen = driver.create_pipe_screen( display ); - stapi = driver.create_st_api(); - smapi = CALLOC_STRUCT(st_manager); - if (smapi) - smapi->screen = screen; - - if (!screen || !stapi || !smapi) { - if (screen) { - screen->destroy(screen); - screen = NULL; - } - if (stapi) { - stapi->destroy(stapi); - stapi = NULL; - } - if (smapi) { - FREE(smapi); - smapi = NULL; - } - } - - firstTime = GL_FALSE; - } + xmesa_init_display(display); } @@ -743,9 +754,11 @@ xmesa_init( Display *display ) PUBLIC XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) { + XMesaDisplay xmdpy = xmesa_init_display(v->display); XMesaContext c; - xmesa_init( v->display ); + if (!xmdpy) + return NULL; /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */ c = (XMesaContext) CALLOC_STRUCT(xmesa_context); @@ -756,10 +769,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */ c->xm_read_buffer = NULL; - if (screen == NULL) - goto fail; - - c->st = stapi->create_context(stapi, smapi, + c->st = stapi->create_context(stapi, xmdpy->smapi, &v->stvis, (share_list) ? share_list->st : NULL); if (c->st == NULL) goto fail; @@ -1094,12 +1104,13 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) void XMesaFlush( XMesaContext c ) { if (c && c->xm_visual->display) { + XMesaDisplay xmdpy = xmesa_init_display(c->xm_visual->display); struct pipe_fence_handle *fence = NULL; c->st->flush(c->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence); if (fence) { - screen->fence_finish(screen, fence, 0); - screen->fence_reference(screen, &fence, NULL); + xmdpy->screen->fence_finish(xmdpy->screen, fence, 0); + xmdpy->screen->fence_reference(xmdpy->screen, &fence, NULL); } XSync( c->xm_visual->display, False ); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 258abf92554..11a08962b74 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -67,11 +67,20 @@ and create a window, you must do the following to use the X/Mesa interface: # include # include +typedef struct xmesa_display *XMesaDisplay; typedef struct xmesa_buffer *XMesaBuffer; typedef struct xmesa_context *XMesaContext; typedef struct xmesa_visual *XMesaVisual; +struct xmesa_display { + pipe_mutex mutex; + + Display *display; + struct pipe_screen *screen; + struct st_manager *smapi; +}; + /* * Create a new X/Mesa visual. @@ -264,11 +273,6 @@ XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask); /*********************************************************************** */ -extern pipe_mutex _xmesa_lock; - -extern struct xmesa_buffer *XMesaBufferList; - - /** * Visual inforation, derived from GLvisual. * Basically corresponds to an XVisualInfo. From 48bc3cca89f7aecc40d1661e695796113df6e583 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 14 Mar 2010 11:34:16 +0800 Subject: [PATCH 058/483] st/glx: Add support for GLX_MESA_copy_sub_buffer. Create a per-display pipe_context as needed to copy the contents between framebuffer attachments. This allows us to support GLX_MESA_copy_sub_buffer. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.h | 2 + src/gallium/state_trackers/glx/xlib/xm_st.c | 53 ++++++++++++++++++-- src/gallium/state_trackers/glx/xlib/xm_st.h | 2 +- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index e7c1979b424..62a2bfcfa07 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -398,7 +398,7 @@ create_xmesa_buffer(Drawable d, BufferType type, /* * Create framebuffer, but we'll plug in our own renderbuffers below. */ - b->stfb = xmesa_create_st_framebuffer(xmdpy->screen, b); + b->stfb = xmesa_create_st_framebuffer(xmdpy, b); /* GLX_EXT_texture_from_pixmap */ b->TextureTarget = 0; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 11a08962b74..4f2c8a6e6a9 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -79,6 +79,8 @@ struct xmesa_display { Display *display; struct pipe_screen *screen; struct st_manager *smapi; + + struct pipe_context *pipe; }; diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 8714da8b346..de5a35edca4 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -32,8 +32,9 @@ #include "xm_st.h" struct xmesa_st_framebuffer { - struct pipe_screen *screen; + XMesaDisplay display; XMesaBuffer buffer; + struct pipe_screen *screen; struct st_visual stvis; @@ -81,6 +82,45 @@ xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi, return TRUE; } +/** + * Copy the contents between the attachments. + */ +static void +xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi, + enum st_attachment_type src_statt, + enum st_attachment_type dst_statt, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); + struct pipe_texture *src_ptex = xstfb->textures[src_statt]; + struct pipe_texture *dst_ptex = xstfb->textures[dst_statt]; + struct pipe_surface *src, *dst; + struct pipe_context *pipe; + + if (!src_ptex || !dst_ptex) + return; + + pipe = xstfb->display->pipe; + if (!pipe) { + pipe = xstfb->screen->context_create(xstfb->screen, NULL); + if (!pipe) + return; + xstfb->display->pipe = pipe; + } + + src = xstfb->screen->get_tex_surface(xstfb->screen, + src_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); + dst = xstfb->screen->get_tex_surface(xstfb->screen, + dst_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); + + if (src && dst) + pipe->surface_copy(pipe, dst, 0, 0, src, 0, 0, src->width, src->height); + + pipe_surface_reference(&src, NULL); + pipe_surface_reference(&dst, NULL); +} + /** * Remove outdated textures and create the requested ones. */ @@ -194,11 +234,13 @@ xmesa_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, } struct st_framebuffer_iface * -xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b) +xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b) { struct st_framebuffer_iface *stfbi; struct xmesa_st_framebuffer *xstfb; + assert(xmdpy->display == b->xm_visual->display); + stfbi = CALLOC_STRUCT(st_framebuffer_iface); xstfb = CALLOC_STRUCT(xmesa_st_framebuffer); if (!stfbi || !xstfb) { @@ -209,8 +251,9 @@ xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b) return NULL; } - xstfb->screen = screen; + xstfb->display = xmdpy; xstfb->buffer = b; + xstfb->screen = xmdpy->screen; xstfb->stvis = b->xm_visual->stvis; stfbi->visual = &xstfb->stvis; @@ -265,5 +308,7 @@ xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi, enum st_attachment_type dst, int x, int y, int w, int h) { - /* TODO */ + xmesa_st_framebuffer_copy_textures(stfbi, src, dst, x, y, w, h); + if (dst == ST_ATTACHMENT_FRONT_LEFT) + xmesa_st_framebuffer_display(stfbi, dst); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.h b/src/gallium/state_trackers/glx/xlib/xm_st.h index b22a8373801..396495c1893 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.h +++ b/src/gallium/state_trackers/glx/xlib/xm_st.h @@ -34,7 +34,7 @@ #include "xm_api.h" struct st_framebuffer_iface * -xmesa_create_st_framebuffer(struct pipe_screen *screen, XMesaBuffer b); +xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b); void xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); From d6262bdcfb64e1f88f6a890829f5c30c26bc372b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 14 Mar 2010 12:01:27 +0800 Subject: [PATCH 059/483] st/glx: Sync the back buffer to the front buffer. Consider this rendering sequence * render to the back buffer * swap buffers * read from the front buffer The front buffer is expected to have the contents of the back buffer. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 26 +++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index de5a35edca4..bcb8285d9f5 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -197,18 +197,36 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, struct pipe_texture **out) { struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); - unsigned statt_mask, i; + unsigned statt_mask, new_mask, i; + boolean resized; statt_mask = 0x0; for (i = 0; i < count; i++) statt_mask |= 1 << statts[i]; + /* record newly allocated textures */ + new_mask = statt_mask & ~xstfb->texture_mask; + + resized = (xstfb->buffer->width != xstfb->texture_width || + xstfb->buffer->height != xstfb->texture_height); /* revalidate textures */ - if (xstfb->buffer->width != xstfb->texture_width || - xstfb->buffer->height != xstfb->texture_height || - (xstfb->texture_mask & statt_mask) != statt_mask) { + if (resized || new_mask) { xmesa_st_framebuffer_validate_textures(stfbi, xstfb->buffer->width, xstfb->buffer->height, statt_mask); + + if (!resized) { + enum st_attachment_type back, front; + + back = ST_ATTACHMENT_BACK_LEFT; + front = ST_ATTACHMENT_FRONT_LEFT; + /* copy the contents if front is newly allocated and back is not */ + if ((statt_mask & (1 << back)) && + (new_mask & (1 << front)) && + !(new_mask & (1 << back))) { + xmesa_st_framebuffer_copy_textures(stfbi, back, front, + 0, 0, xstfb->texture_width, xstfb->texture_height); + } + } } for (i = 0; i < count; i++) { From 23e9a25e1ff01d9f3ef5cc99f59e0fda0ac2d421 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 14 Mar 2010 14:58:27 +0800 Subject: [PATCH 060/483] st/glx: Fix glXCopySubBufferMESA. Honor the (x, y) and (width, height) pairs. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index bcb8285d9f5..b6ed7e8e1e8 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -115,7 +115,7 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi, dst_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); if (src && dst) - pipe->surface_copy(pipe, dst, 0, 0, src, 0, 0, src->width, src->height); + pipe->surface_copy(pipe, dst, x, y, src, x, y, width, height); pipe_surface_reference(&src, NULL); pipe_surface_reference(&dst, NULL); From 506130fff5685742d280bde8800be036c8e8ebfa Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Mar 2010 10:24:55 +0000 Subject: [PATCH 061/483] r300g: fix up after merge --- src/gallium/drivers/r300/r300_blit.c | 4 ++-- src/gallium/drivers/r300/r300_context.h | 7 +++---- src/gallium/drivers/r300/r300_emit.c | 13 ++++++------ src/gallium/drivers/r300/r300_state.c | 21 ++++++++++--------- src/gallium/drivers/r300/r300_state_derived.c | 4 ++-- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index a60b12844d6..f99f9dffaa5 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -114,8 +114,8 @@ static void r300_hw_copy(struct pipe_context* pipe, r300->blitter, state->sampler_count, (void**)state->sampler_states); util_blitter_save_fragment_sampler_views( - r300->blitter, r300->fragment_sampler_view_count, - r300->fragment_sampler_views); + r300->blitter, state->texture_count, + state->fragment_sampler_views); /* Do a copy */ util_blitter_copy(r300->blitter, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2763103fda1..0c8fb6860eb 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -139,7 +139,7 @@ struct r300_texture_fb_state { struct r300_textures_state { /* Textures. */ - struct r300_texture *textures[8]; + struct pipe_sampler_view *fragment_sampler_views[8]; int texture_count; /* Sampler states. */ struct r300_sampler_state *sampler_states[8]; @@ -343,9 +343,8 @@ struct r300_context { struct r300_atom rs_block_state; /* Scissor state. */ struct r300_atom scissor_state; - /* Sampler view states. */ - struct pipe_sampler_view* fragment_sampler_views[8]; - int fragment_sampler_view_count; + /* Textures state. */ + struct r300_atom textures_state; /* Vertex stream formatting state. */ struct r300_atom vertex_stream_state; /* VAP (vertex shader) output mapping state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 0a3f0f45c03..3ad0e561bc1 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -165,7 +165,7 @@ static const float * get_shader_constant( /* Factor for converting rectangle coords to * normalized coords. Should only show up on non-r500. */ case RC_STATE_R300_TEXRECT_FACTOR: - tex = r300->fragment_sampler_views[constant->u.State[1]]->texture; + tex = texstate->fragment_sampler_views[constant->u.State[1]]->texture; vec[0] = 1.0 / tex->width0; vec[1] = 1.0 / tex->height0; break; @@ -749,8 +749,9 @@ void r300_emit_textures_state(struct r300_context *r300, OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]); OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1); - OUT_CS_TEX_RELOC(allstate->textures[i], texstate->tile_config, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0); + OUT_CS_TEX_RELOC((struct r300_texture *)allstate->fragment_sampler_views[i]->texture, + texstate->tile_config, + RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0); } } END_CS; @@ -1042,10 +1043,10 @@ validate: } } /* ...textures... */ - for (i = 0; i < r300->fragment_sampler_view_count; i++) { - if (!r300->fragment_sampler_views[i]) + for (i = 0; i < texstate->count; i++) { + tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture; + if (!tex || !texstate->sampler_states[i]) continue; - tex = (struct r300_texture *)r300->fragment_sampler_views[i]->texture; if (!r300_add_texture(r300->rws, tex, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { r300->context.flush(&r300->context, 0, NULL); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 71ac89715cc..d7d654dc315 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -938,6 +938,8 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, struct pipe_sampler_view** views) { struct r300_context* r300 = r300_context(pipe); + struct r300_textures_state* state = + (struct r300_textures_state*)r300->textures_state.state; unsigned i; boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; boolean dirty_tex = FALSE; @@ -948,16 +950,16 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, } for (i = 0; i < count; i++) { - if (r300->fragment_sampler_views[i] != views[i]) { + if (state->fragment_sampler_views[i] != views[i]) { struct r300_texture *texture; - - pipe_sampler_view_reference(&r300->fragment_sampler_views[i], - views[i]); + + pipe_sampler_view_reference(&state->fragment_sampler_views[i], + views[i]); dirty_tex = TRUE; texture = (struct r300_texture *)views[i]->texture; - /* R300-specific - set the texrect factor in a fragment shader */ + /* R300-specific - set the texrect factor in the fragment shader */ if (!is_r500 && texture->is_npot) { /* XXX It would be nice to re-emit just 1 constant, * XXX not all of them */ @@ -967,13 +969,13 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, } for (i = count; i < 8; i++) { - if (r300->fragment_sampler_views[i]) { - pipe_sampler_view_reference(&r300->fragment_sampler_views[i], - NULL); + if (state->fragment_sampler_views[i]) { + pipe_sampler_view_reference(&state->fragment_sampler_views[i], + NULL); } } - r300->fragment_sampler_view_count = count; + state->texture_count = count; r300->textures_state.dirty = TRUE; @@ -987,7 +989,6 @@ r300_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { - struct r300_context *r300 = r300_context(pipe); struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); if (view) { diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 6b9f61acd7b..7947ec6641d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -340,10 +340,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) size = 2; for (i = 0; i < count; i++) { - if (state->textures[i] && state->sampler_states[i]) { + if (state->fragment_sampler_views[i] && state->sampler_states[i]) { state->tx_enable |= 1 << i; - tex = state->textures[i]; + tex = (struct r300_texture *)state->fragment_sampler_views[i]->texture; sampler = state->sampler_states[i]; texstate = &state->regs[i]; From 08189e639195ecb619ed37250b6dbb63017584b8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Mar 2010 10:27:25 +0000 Subject: [PATCH 062/483] nvfx: fix up after merge --- src/gallium/drivers/nvfx/nvfx_state.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c index 32a81997528..ecaa0dcb16a 100644 --- a/src/gallium/drivers/nvfx/nvfx_state.c +++ b/src/gallium/drivers/nvfx/nvfx_state.c @@ -145,18 +145,14 @@ nvfx_set_fragment_sampler_views(struct pipe_context *pipe, unsigned unit; for (unit = 0; unit < nr; unit++) { - pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], + pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit], views[unit]); - pipe_texture_reference((struct pipe_texture **) - &nvfx->tex_miptree[unit], miptree[unit]); nvfx->dirty_samplers |= (1 << unit); } for (unit = nr; unit < nvfx->nr_textures; unit++) { - pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], + pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit], NULL); - pipe_texture_reference((struct pipe_texture **) - &nvfx->tex_miptree[unit], NULL); nvfx->dirty_samplers |= (1 << unit); } @@ -166,7 +162,7 @@ nvfx_set_fragment_sampler_views(struct pipe_context *pipe, static struct pipe_sampler_view * -nv30_create_sampler_view(struct pipe_context *pipe, +nvfx_create_sampler_view(struct pipe_context *pipe, struct pipe_texture *texture, const struct pipe_sampler_view *templ) { @@ -185,7 +181,7 @@ nv30_create_sampler_view(struct pipe_context *pipe, static void -nv30_sampler_view_destroy(struct pipe_context *pipe, +nvfx_sampler_view_destroy(struct pipe_context *pipe, struct pipe_sampler_view *view) { pipe_texture_reference(&view->texture, NULL); @@ -614,7 +610,9 @@ nvfx_init_state_functions(struct nvfx_context *nvfx) nvfx->pipe.create_sampler_state = nvfx_sampler_state_create; nvfx->pipe.bind_fragment_sampler_states = nvfx_sampler_state_bind; nvfx->pipe.delete_sampler_state = nvfx_sampler_state_delete; - nvfx->pipe.set_fragment_sampler_textures = nvfx_set_sampler_texture; + nvfx->pipe.set_fragment_sampler_views = nvfx_set_fragment_sampler_views; + nvfx->pipe.create_sampler_view = nvfx_create_sampler_view; + nvfx->pipe.sampler_view_destroy = nvfx_sampler_view_destroy; nvfx->pipe.create_rasterizer_state = nvfx_rasterizer_state_create; nvfx->pipe.bind_rasterizer_state = nvfx_rasterizer_state_bind; From a66d0081044bfcbfbe72ecbc27692387e4716e5c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 15 Mar 2010 19:15:29 +0800 Subject: [PATCH 063/483] st/mesa: Update the comments in st_manager.c. --- src/mesa/state_tracker/st_manager.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index d04d72d48aa..1b005c1ee17 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -141,7 +141,7 @@ buffer_index_to_attachment(gl_buffer_index index) } /** - * Validate a framebuffer and update the states of the context. + * Validate a framebuffer to make sure up-to-date pipe_textures are used. */ static void st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) @@ -215,7 +215,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) } /** - * Update the attachments to validate. + * Update the attachments to validate by looping the existing renderbuffers. */ static void st_framebuffer_update_attachments(struct st_framebuffer *stfb) @@ -718,7 +718,7 @@ st_manager_flush_frontbuffer(struct st_context *st) } /** - * Re-validate the framebuffer. + * Re-validate the framebuffers. */ void st_manager_validate_framebuffers(struct st_context *st) @@ -741,7 +741,7 @@ st_manager_validate_framebuffers(struct st_context *st) } /** - * Add a color buffer on demand. + * Add a color renderbuffer on demand. */ boolean st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, @@ -776,6 +776,9 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, return TRUE; } +/** + * Create an st_api to manage the state tracker. + */ struct st_api * st_manager_create_api(void) { From dbf20a1f0fa7965254aa8a0e2ea35a6b8576fd7d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Mar 2010 13:18:30 +0100 Subject: [PATCH 064/483] st/mesa: Cache FBO texture's sampler view object. --- src/mesa/state_tracker/st_cb_fbo.c | 15 +++++++++++++++ src/mesa/state_tracker/st_cb_fbo.h | 6 ++++++ src/mesa/state_tracker/st_framebuffer.c | 1 + src/mesa/state_tracker/st_texture.c | 9 +++++++++ 4 files changed, 31 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index abf0c8d6cb1..b219763beab 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -103,6 +103,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, */ pipe_surface_reference( &strb->surface, NULL ); pipe_texture_reference( &strb->texture, NULL ); + pipe_sampler_view_reference(&strb->sampler_view, NULL); /* Setup new texture template. */ @@ -162,6 +163,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) ASSERT(strb); pipe_surface_reference(&strb->surface, NULL); pipe_texture_reference(&strb->texture, NULL); + pipe_sampler_view_reference(&strb->sampler_view, NULL); free(strb->data); free(strb); } @@ -368,6 +370,8 @@ st_render_texture(GLcontext *ctx, pipe_surface_reference(&strb->surface, NULL); + pipe_sampler_view_reference(&strb->sampler_view, st_get_stobj_sampler_view(stObj)); + assert(strb->rtt_level <= strb->texture->last_level); /* new surface for rendering into the texture */ @@ -647,3 +651,14 @@ void st_init_fbo_functions(struct dd_function_table *functions) functions->DrawBuffers = st_DrawBuffers; functions->ReadBuffer = st_ReadBuffer; } + +struct pipe_sampler_view * +st_renderbuffer_get_sampler_view(struct st_renderbuffer *rb, + struct pipe_context *pipe) +{ + if (!rb->sampler_view) { + rb->sampler_view = st_sampler_view_from_texture(pipe, rb->texture); + } + + return rb->sampler_view; +} diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index bea6eb89c3e..7a45a608fe1 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -39,6 +39,7 @@ struct st_renderbuffer struct gl_renderbuffer Base; struct pipe_texture *texture; struct pipe_surface *surface; /* temporary view into texture */ + struct pipe_sampler_view *sampler_view; enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */ GLboolean defined; /**< defined contents? */ @@ -55,6 +56,7 @@ struct st_renderbuffer /** Render to texture state */ struct pipe_texture *texture_save; struct pipe_surface *surface_save; + struct pipe_sampler_view *sampler_view_save; }; @@ -71,5 +73,9 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw); extern void st_init_fbo_functions(struct dd_function_table *functions); +extern struct pipe_sampler_view * +st_renderbuffer_get_sampler_view(struct st_renderbuffer *rb, + struct pipe_context *pipe); + #endif /* ST_CB_FBO_H */ diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 0a91183f89d..d3c43bbc68a 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -197,6 +197,7 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb, /* replace the renderbuffer's surface/texture pointers */ pipe_surface_reference( &strb->surface, surf ); pipe_texture_reference( &strb->texture, surf->texture ); + pipe_sampler_view_reference(&strb->sampler_view, NULL); if (ctx) { /* If ctx isn't set, we've likely not made current yet. diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 10a38befb41..ef97d873e50 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -528,14 +528,21 @@ st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex, /* save the renderbuffer's surface/texture info */ pipe_texture_reference(&strb->texture_save, strb->texture); pipe_surface_reference(&strb->surface_save, strb->surface); + pipe_sampler_view_reference(&strb->sampler_view_save, strb->sampler_view); /* plug in new surface/texture info */ pipe_texture_reference(&strb->texture, stImage->pt); + + /* XXX: Shouldn't we release reference to old surface here? + */ + strb->surface = screen->get_tex_surface(screen, strb->texture, face, level, slice, (PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE)); + pipe_sampler_view_reference(&strb->sampler_view, NULL); + st->dirty.st |= ST_NEW_FRAMEBUFFER; return 1; @@ -565,9 +572,11 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex, /* free tex surface, restore original */ pipe_surface_reference(&strb->surface, strb->surface_save); pipe_texture_reference(&strb->texture, strb->texture_save); + pipe_sampler_view_reference(&strb->sampler_view, strb->sampler_view_save); pipe_surface_reference(&strb->surface_save, NULL); pipe_texture_reference(&strb->texture_save, NULL); + pipe_sampler_view_reference(&strb->sampler_view, NULL); st->dirty.st |= ST_NEW_FRAMEBUFFER; From f2bc089d148253d7a411e94257633ce40ec1c6a9 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Mar 2010 13:20:37 +0100 Subject: [PATCH 065/483] gallium: util_blit_pixels() takes source sampler view as argument. --- src/gallium/auxiliary/util/u_blit.c | 28 ++++++++++++++++++++------ src/gallium/auxiliary/util/u_blit.h | 2 ++ src/mesa/state_tracker/st_cb_blit.c | 15 +++++++++----- src/mesa/state_tracker/st_cb_texture.c | 2 ++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 4d0737ccd3d..803086b93e6 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -45,6 +45,7 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "util/u_simple_shaders.h" #include "util/u_surface.h" #include "util/u_rect.h" @@ -280,6 +281,7 @@ regions_overlap(int srcX0, int srcY0, void util_blit_pixels_writemask(struct blit_state *ctx, struct pipe_surface *src, + struct pipe_sampler_view *src_sampler_view, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, @@ -291,6 +293,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_texture *tex = NULL; + struct pipe_sampler_view *sampler_view = NULL; struct pipe_framebuffer_state fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); @@ -345,6 +348,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, src->texture->last_level != 0) { struct pipe_texture texTemp; + struct pipe_sampler_view sv_templ; struct pipe_surface *texSurf; const int srcLeft = MIN2(srcX0, srcX1); const int srcTop = MIN2(srcY0, srcY1); @@ -376,6 +380,14 @@ util_blit_pixels_writemask(struct blit_state *ctx, if (!tex) return; + u_sampler_view_default_template(&sv_templ, tex, tex->format); + + sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ); + if (!sampler_view) { + pipe_texture_reference(&tex, NULL); + return; + } + texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); @@ -399,22 +411,25 @@ util_blit_pixels_writemask(struct blit_state *ctx, s1 = 1.0f; t0 = 0.0f; t1 = 1.0f; + + pipe_texture_reference(&tex, NULL); } else { - pipe_texture_reference(&tex, src->texture); + pipe_sampler_view_reference(&sampler_view, src_sampler_view); s0 = srcX0 / (float)tex->width0; s1 = srcX1 / (float)tex->width0; t0 = srcY0 / (float)tex->height0; t1 = srcY1 / (float)tex->height0; } + /* save state (restored below) */ cso_save_blend(ctx->cso); cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); cso_save_samplers(ctx->cso); - cso_save_sampler_textures(ctx->cso); + cso_save_fragment_sampler_views(ctx->cso); cso_save_viewport(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); @@ -447,7 +462,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_set_viewport(ctx->cso, &ctx->viewport); /* texture */ - cso_set_sampler_textures(ctx->cso, 1, &tex); + cso_set_fragment_sampler_views(ctx->cso, 1, &sampler_view); if (ctx->fs[writemask] == NULL) ctx->fs[writemask] = @@ -486,7 +501,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); cso_restore_samplers(ctx->cso); - cso_restore_sampler_textures(ctx->cso); + cso_restore_fragment_sampler_views(ctx->cso); cso_restore_viewport(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); @@ -494,13 +509,14 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_clip(ctx->cso); cso_restore_vertex_elements(ctx->cso); - pipe_texture_reference(&tex, NULL); + pipe_sampler_view_reference(&sampler_view, NULL); } void util_blit_pixels(struct blit_state *ctx, struct pipe_surface *src, + struct pipe_sampler_view *src_sampler_view, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, @@ -508,7 +524,7 @@ util_blit_pixels(struct blit_state *ctx, int dstX1, int dstY1, float z, uint filter ) { - util_blit_pixels_writemask( ctx, src, + util_blit_pixels_writemask( ctx, src, src_sampler_view, srcX0, srcY0, srcX1, srcY1, dst, diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h index a102021529e..2d8cdd25fb9 100644 --- a/src/gallium/auxiliary/util/u_blit.h +++ b/src/gallium/auxiliary/util/u_blit.h @@ -53,6 +53,7 @@ util_destroy_blit(struct blit_state *ctx); extern void util_blit_pixels(struct blit_state *ctx, struct pipe_surface *src, + struct pipe_sampler_view *src_sampler_view, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, @@ -63,6 +64,7 @@ util_blit_pixels(struct blit_state *ctx, void util_blit_pixels_writemask(struct blit_state *ctx, struct pipe_surface *src, + struct pipe_sampler_view *src_sampler_view, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 36e03018d9f..abf0ac0fc82 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -69,6 +69,7 @@ st_BlitFramebuffer(GLcontext *ctx, const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; const uint pFilter = ((filter == GL_NEAREST) ? PIPE_TEX_MIPFILTER_NEAREST : PIPE_TEX_MIPFILTER_LINEAR); @@ -111,8 +112,8 @@ st_BlitFramebuffer(GLcontext *ctx, &readFB->Attachment[readFB->_ColorReadBufferIndex]; if(srcAtt->Type == GL_TEXTURE) { - struct pipe_screen *screen = ctx->st->pipe->screen; - const struct st_texture_object *srcObj = + struct pipe_screen *screen = pipe->screen; + struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture); struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); @@ -132,7 +133,8 @@ st_BlitFramebuffer(GLcontext *ctx, return; util_blit_pixels(st->blit, - srcSurf, srcX0, srcY0, srcX1, srcY1, + srcSurf, st_get_stobj_sampler_view(srcObj, pipe), + srcX0, srcY0, srcX1, srcY1, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); @@ -144,10 +146,11 @@ st_BlitFramebuffer(GLcontext *ctx, struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); struct pipe_surface *srcSurf = srcRb->surface; + struct pipe_sampler_view *srcView = st_renderbuffer_get_sampler_view(srcRb, pipe); struct pipe_surface *dstSurf = dstRb->surface; util_blit_pixels(st->blit, - srcSurf, srcX0, srcY0, srcX1, srcY1, + srcSurf, srcView, srcX0, srcY0, srcX1, srcY1, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } @@ -179,11 +182,13 @@ st_BlitFramebuffer(GLcontext *ctx, if ((mask & depthStencil) == depthStencil && srcDepthSurf == srcStencilSurf && dstDepthSurf == dstStencilSurf) { + struct pipe_sampler_view *srcView = st_renderbuffer_get_sampler_view(srcDepthRb, pipe); + /* Blitting depth and stencil values between combined * depth/stencil buffers. This is the ideal case for such buffers. */ util_blit_pixels(st->blit, - srcDepthSurf, srcX0, srcY0, srcX1, srcY1, + srcDepthSurf, srcView, srcX0, srcY0, srcX1, srcY1, dstDepthSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 04c0ef8c84c..7fcd1e9ca74 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1457,6 +1457,7 @@ st_copy_texsubimage(GLcontext *ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); + struct st_texture_object *stObj = st_texture_object(texObj); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); struct st_texture_image *stImage = st_texture_image(texImage); @@ -1597,6 +1598,7 @@ st_copy_texsubimage(GLcontext *ctx, } util_blit_pixels_writemask(ctx->st->blit, strb->surface, + st_get_stobj_sampler_view(stObj), srcX, srcY0, srcX + width, srcY1, dest_surface, From df65fc8100f267b3167012d4f8502cf9eed526df Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Mar 2010 14:42:44 +0100 Subject: [PATCH 066/483] util: Fix nil pointer reference. --- src/gallium/auxiliary/util/u_blit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 803086b93e6..4d9168face3 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -292,7 +292,6 @@ util_blit_pixels_writemask(struct blit_state *ctx, { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture *tex = NULL; struct pipe_sampler_view *sampler_view = NULL; struct pipe_framebuffer_state fb; const int srcW = abs(srcX1 - srcX0); @@ -348,6 +347,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, src->texture->last_level != 0) { struct pipe_texture texTemp; + struct pipe_texture *tex; struct pipe_sampler_view sv_templ; struct pipe_surface *texSurf; const int srcLeft = MIN2(srcX0, srcX1); @@ -416,10 +416,10 @@ util_blit_pixels_writemask(struct blit_state *ctx, } else { pipe_sampler_view_reference(&sampler_view, src_sampler_view); - s0 = srcX0 / (float)tex->width0; - s1 = srcX1 / (float)tex->width0; - t0 = srcY0 / (float)tex->height0; - t1 = srcY1 / (float)tex->height0; + s0 = srcX0 / (float)src->texture->width0; + s1 = srcX1 / (float)src->texture->width0; + t0 = srcY0 / (float)src->texture->height0; + t1 = srcY1 / (float)src->texture->height0; } From 6b60820fde8596966b1ffdb5d008e94773b2f321 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Mar 2010 15:03:44 +0100 Subject: [PATCH 067/483] st/mesa: Pass in correct sampler view object to blitter. --- src/mesa/state_tracker/st_cb_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 7fcd1e9ca74..0c518a7e031 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1598,7 +1598,7 @@ st_copy_texsubimage(GLcontext *ctx, } util_blit_pixels_writemask(ctx->st->blit, strb->surface, - st_get_stobj_sampler_view(stObj), + st_renderbuffer_get_sampler_view(strb, pipe), srcX, srcY0, srcX + width, srcY1, dest_surface, From 3949388ca34c4578455be6db65d140c8e8f2184a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Mar 2010 15:04:12 +0100 Subject: [PATCH 068/483] st/mesa: Fix a call to st_get_stobj_sampler_view(). --- src/mesa/state_tracker/st_cb_blit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index abf0ac0fc82..06b0a18fd22 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -133,7 +133,7 @@ st_BlitFramebuffer(GLcontext *ctx, return; util_blit_pixels(st->blit, - srcSurf, st_get_stobj_sampler_view(srcObj, pipe), + srcSurf, st_get_stobj_sampler_view(srcObj), srcX0, srcY0, srcX1, srcY1, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); From 346298c7658f2ec8b105e5e53101637af232724f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Baczy=C5=84ski?= Date: Sat, 13 Mar 2010 14:26:45 +0100 Subject: [PATCH 069/483] Replace _mesa_strtod with _mesa_strtof. Reviewed-by: Ian Romanick --- src/mesa/main/imports.c | 12 +++++++----- src/mesa/main/imports.h | 4 ++-- src/mesa/shader/lex.yy.c | 8 ++++---- src/mesa/shader/nvfragparse.c | 2 +- src/mesa/shader/program_lexer.l | 8 ++++---- src/mesa/shader/slang/slang_compile.c | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 56e8195810e..1ae08533648 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -795,18 +795,20 @@ _mesa_strdup( const char *s ) } } -/** Wrapper around strtod() */ -double -_mesa_strtod( const char *s, char **end ) +/** Wrapper around strtof() */ +float +_mesa_strtof( const char *s, char **end ) { #ifdef _GNU_SOURCE static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); } - return strtod_l(s, end, loc); + return strtof_l(s, end, loc); +#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) + return strtof(s, end); #else - return strtod(s, end); + return (float)strtod(s, end); #endif } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index fb4a00eca7b..d28f4ad125d 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -575,8 +575,8 @@ _mesa_getenv( const char *var ); extern char * _mesa_strdup( const char *s ); -extern double -_mesa_strtod( const char *s, char **end ); +extern float +_mesa_strtof( const char *s, char **end ); extern unsigned int _mesa_str_checksum(const char *str); diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index a08617ff8d4..4c5c644a6ed 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -2198,7 +2198,7 @@ case 142: YY_RULE_SETUP #line 326 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2210,7 +2210,7 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 330 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2218,7 +2218,7 @@ case 144: YY_RULE_SETUP #line 334 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2226,7 +2226,7 @@ case 145: YY_RULE_SETUP #line 338 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index d03cb4e493b..0de3c5804d2 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -456,7 +456,7 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) { char *end = NULL; - *number = (GLfloat) _mesa_strtod((const char *) parseState->pos, &end); + *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end); if (end && end > (char *) parseState->pos) { /* got a number */ diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index b00765793dc..fe18272cdba 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -324,19 +324,19 @@ ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require return INTEGER; } {num}?{frac}{exp}? { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."/[^.] { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index b95c15fea61..ad866761570 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -246,7 +246,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number) if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') { flt[strlen(flt) - 1] = '\0'; } - *number = (float)_mesa_strtod(flt, (char **)NULL); + *number = _mesa_strtof(flt, (char **)NULL); free(flt); return 1; @@ -312,7 +312,7 @@ parse_float(slang_parse_ctx * C, float *number) slang_string_concat(whole, "E"); slang_string_concat(whole, exponent); - *number = (float) (_mesa_strtod(whole, (char **) NULL)); + *number = _mesa_strtof(whole, (char **) NULL); _slang_free(whole); } From 6420aca08ba6910dce22ab9f813cc57d611b0aa8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Mar 2010 17:56:19 +0100 Subject: [PATCH 070/483] cso: Do not hold references to bound textures. Sampler views already hold references to those. --- src/gallium/auxiliary/cso_cache/cso_context.c | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 648ba10a995..4ed9e09c529 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -71,16 +71,12 @@ struct cso_context { unsigned nr_vertex_samplers_saved; void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; uint nr_fragment_sampler_views; struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; - uint nr_textures; uint nr_vertex_sampler_views; struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; - uint nr_textures_saved; - struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS]; uint nr_fragment_sampler_views_saved; struct pipe_sampler_view *fragment_sampler_views_saved[PIPE_MAX_SAMPLERS]; @@ -299,8 +295,6 @@ void cso_release_all( struct cso_context *ctx ) } for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->textures[i], NULL); - pipe_texture_reference(&ctx->textures_saved[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], NULL); } @@ -630,7 +624,7 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, { uint i; - ctx->nr_textures = count; + ctx->nr_fragment_sampler_views = count; for (i = 0; i < count; i++) { struct pipe_sampler_view templ, *view; @@ -638,15 +632,14 @@ enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, u_sampler_view_default_template(&templ, textures[i], textures[i]->format); + view = ctx->pipe->create_sampler_view(ctx->pipe, textures[i], &templ); - pipe_texture_reference(&ctx->textures[i], textures[i]); pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], view); } for ( ; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->textures[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); } @@ -661,12 +654,10 @@ void cso_save_sampler_textures( struct cso_context *ctx ) { uint i; - ctx->nr_textures_saved = ctx->nr_textures; - for (i = 0; i < ctx->nr_textures; i++) { - assert(!ctx->textures_saved[i]); + ctx->nr_fragment_sampler_views_saved = ctx->nr_fragment_sampler_views; + for (i = 0; i < ctx->nr_fragment_sampler_views; i++) { assert(!ctx->fragment_sampler_views_saved[i]); - pipe_texture_reference(&ctx->textures_saved[i], ctx->textures[i]); pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], ctx->fragment_sampler_views[i]); } @@ -676,27 +667,22 @@ void cso_restore_sampler_textures( struct cso_context *ctx ) { uint i; - ctx->nr_textures = ctx->nr_textures_saved; - - for (i = 0; i < ctx->nr_textures; i++) { - pipe_texture_reference(&ctx->textures[i], NULL); - ctx->textures[i] = ctx->textures_saved[i]; - ctx->textures_saved[i] = NULL; + ctx->nr_fragment_sampler_views = ctx->nr_fragment_sampler_views_saved; + for (i = 0; i < ctx->nr_fragment_sampler_views; i++) { pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); ctx->fragment_sampler_views[i] = ctx->fragment_sampler_views_saved[i]; ctx->fragment_sampler_views_saved[i] = NULL; } for ( ; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->textures[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); } ctx->pipe->set_fragment_sampler_views(ctx->pipe, - ctx->nr_textures, + ctx->nr_fragment_sampler_views, ctx->fragment_sampler_views); - ctx->nr_textures_saved = 0; + ctx->nr_fragment_sampler_views_saved = 0; } From 8e848d682e74f9ae3e105635fe55d19ed8c94547 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 16 Mar 2010 06:49:38 +1000 Subject: [PATCH 071/483] gallium: fix frontbuffer rendering with r300g No idea if this is the correct fix, but it makes it work again at least. Signed-off-by: Dave Airlie --- src/gallium/state_trackers/dri/dri_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 2f991c39e33..9811f8cf43c 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -167,7 +167,7 @@ dri_make_current(__DRIcontext * cPriv, * flush_frontbuffer directly (in front-buffer rendering), it * will have access to the drawable argument: */ - st_make_current(ctx->st, draw->stfb, read->stfb, NULL); + st_make_current(ctx->st, draw->stfb, read->stfb, ctx); if (__dri1_api_hooks) { dri1_update_drawables(ctx, draw, read); From 3eb4b7bbecc013f25a9d77b50c745514350f99f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 15 Mar 2010 21:03:59 +0000 Subject: [PATCH 072/483] libgl-xlib: Obey GALLIUM_SOFTPIPE define. --- src/gallium/targets/libgl-xlib/xlib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 05dc8db57d9..5bb6c5c38ce 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -81,8 +81,10 @@ swrast_xlib_create_screen( Display *display ) screen = llvmpipe_create_screen( winsys ); #endif +#if defined(GALLIUM_SOFTPIPE) if (screen == NULL) screen = softpipe_create_screen( winsys ); +#endif if (screen == NULL) goto fail; From 0d71ba46e613230c84165106c1fcc9027dec4cd3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Mar 2010 13:50:40 -0600 Subject: [PATCH 073/483] gallivm/llvmpipe: rename os_llvm.h to lp_bld.h The llvm wrapper wasn't really an OS thing. Use lp_bld.h for now but we eventually should rename/re-prefix all the files/functions in the gallivm/ directory. --- src/gallium/auxiliary/{os/os_llvm.h => gallivm/lp_bld.h} | 8 ++++---- src/gallium/auxiliary/gallivm/lp_bld_alpha.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_arit.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_blend.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_const.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_conv.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_debug.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_depth.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_flow.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_format.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_interp.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_intr.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_logic.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_pack.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_struct.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_swizzle.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_type.h | 2 +- src/gallium/drivers/llvmpipe/lp_screen.h | 2 +- src/gallium/drivers/llvmpipe/lp_state.h | 2 +- src/gallium/drivers/llvmpipe/lp_test.h | 2 +- src/gallium/drivers/llvmpipe/lp_test_format.c | 2 +- src/gallium/drivers/llvmpipe/lp_tex_sample.h | 2 +- 24 files changed, 27 insertions(+), 27 deletions(-) rename src/gallium/auxiliary/{os/os_llvm.h => gallivm/lp_bld.h} (94%) diff --git a/src/gallium/auxiliary/os/os_llvm.h b/src/gallium/auxiliary/gallivm/lp_bld.h similarity index 94% rename from src/gallium/auxiliary/os/os_llvm.h rename to src/gallium/auxiliary/gallivm/lp_bld.h index d5edfbfe923..70a4960f913 100644 --- a/src/gallium/auxiliary/os/os_llvm.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -31,8 +31,8 @@ */ -#ifndef OS_LLVM_H -#define OS_LLVM_H +#ifndef LP_BLD_H +#define LP_BLD_H #include @@ -40,8 +40,8 @@ /** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */ #ifndef HAVE_LLVM -#define HAVE_LLVM 0x0 +#define HAVE_LLVM 0x0207 #endif -#endif /* OS_LLVM_H */ +#endif /* LP_BLD_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_alpha.h b/src/gallium/auxiliary/gallivm/lp_bld_alpha.h index fe3cedcc48c..0f99fec65ed 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_alpha.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_alpha.h @@ -35,7 +35,7 @@ #define LP_BLD_ALPHA_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct pipe_alpha_state; struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 7a10fe12209..31efa9921ce 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -37,7 +37,7 @@ #define LP_BLD_ARIT_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_blend.h b/src/gallium/auxiliary/gallivm/lp_bld_blend.h index 5a9e1c1fb2f..ebbdb1a604c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_blend.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_blend.h @@ -40,7 +40,7 @@ * for a standalone example. */ -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "pipe/p_format.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h index 40786361031..5bd0db844d3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h @@ -37,7 +37,7 @@ #define LP_BLD_CONST_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.h b/src/gallium/auxiliary/gallivm/lp_bld_conv.h index 78e8155ff73..628831c3ada 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.h @@ -37,7 +37,7 @@ #define LP_BLD_CONV_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h index 441ad94786f..7b010cbdb09 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h @@ -30,7 +30,7 @@ #define LP_BLD_DEBUG_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "pipe/p_compiler.h" #include "util/u_string.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index 8be80024ae8..8375824cbf4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -36,7 +36,7 @@ #define LP_BLD_DEPTH_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct pipe_depth_state; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h index e1588365491..c2b50e1b602 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h @@ -35,7 +35,7 @@ #define LP_BLD_FLOW_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h index 8972c0dc178..73ab6de3f21 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h @@ -34,7 +34,7 @@ * Pixel format helpers. */ -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "pipe/p_format.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_interp.h b/src/gallium/auxiliary/gallivm/lp_bld_interp.h index 177b5e943ee..a4937bbb048 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_interp.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_interp.h @@ -41,7 +41,7 @@ #define LP_BLD_INTERP_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "tgsi/tgsi_exec.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.h b/src/gallium/auxiliary/gallivm/lp_bld_intr.h index 7d5506c7338..977f7673228 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.h @@ -37,7 +37,7 @@ #define LP_BLD_INTR_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" /** diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.h b/src/gallium/auxiliary/gallivm/lp_bld_logic.h index b54ec13b701..d849d29e95d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.h @@ -37,7 +37,7 @@ #define LP_BLD_LOGIC_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.h b/src/gallium/auxiliary/gallivm/lp_bld_pack.h index 346a17d5803..41adeed220c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.h @@ -37,7 +37,7 @@ #define LP_BLD_PACK_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 7f08bfaac1f..92f3c57435a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -36,7 +36,7 @@ #define LP_BLD_SAMPLE_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct pipe_texture; struct pipe_sampler_state; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_struct.h b/src/gallium/auxiliary/gallivm/lp_bld_struct.h index 34478c10f51..147336edb4b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_struct.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_struct.h @@ -37,7 +37,7 @@ #define LP_BLD_STRUCT_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include #include "util/u_debug.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h index 57b5cc079f2..138ca620e63 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h @@ -37,7 +37,7 @@ #define LP_BLD_SWIZZLE_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 0f2f8a65b10..63b938bfa98 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -35,7 +35,7 @@ #ifndef LP_BLD_TGSI_H #define LP_BLD_TGSI_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct tgsi_token; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 5b351476ac2..8a80e4f09aa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -37,7 +37,7 @@ #define LP_BLD_TYPE_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index d977f98cfaa..af25e043cc9 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -34,7 +34,7 @@ #ifndef LP_SCREEN_H #define LP_SCREEN_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include #include "pipe/p_screen.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index a5a1a720742..34dd5234ce3 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -31,7 +31,7 @@ #ifndef LP_STATE_H #define LP_STATE_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include "pipe/p_state.h" #include "tgsi/tgsi_scan.h" diff --git a/src/gallium/drivers/llvmpipe/lp_test.h b/src/gallium/drivers/llvmpipe/lp_test.h index 1df98978988..338a04a4878 100644 --- a/src/gallium/drivers/llvmpipe/lp_test.h +++ b/src/gallium/drivers/llvmpipe/lp_test.h @@ -41,7 +41,7 @@ #include #include -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include #include #include diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index 2c4d7fb6e14..fb595893bd0 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -29,7 +29,7 @@ #include #include -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" #include #include #include diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.h b/src/gallium/drivers/llvmpipe/lp_tex_sample.h index 799df182b6a..1228a831f3b 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.h +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.h @@ -29,7 +29,7 @@ #define LP_TEX_SAMPLE_H -#include "os/os_llvm.h" +#include "gallivm/lp_bld.h" struct lp_sampler_static_state; From c86a499769d56fc59fa41b9c2d73ac181ab33e36 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Mar 2010 13:54:43 -0600 Subject: [PATCH 074/483] gallivm: fix up some #includes --- src/gallium/auxiliary/gallivm/lp_bld_const.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_type.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h index 5bd0db844d3..0f426189003 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h @@ -37,9 +37,9 @@ #define LP_BLD_CONST_H +#include "pipe/p_compiler.h" #include "gallivm/lp_bld.h" -#include struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 8a80e4f09aa..cd59d2faa66 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -37,9 +37,9 @@ #define LP_BLD_TYPE_H +#include "pipe/p_compiler.h" #include "gallivm/lp_bld.h" -#include /** From 185be3a87a5b38e8821a560c073975c11dcbd3e9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Mar 2010 14:00:23 -0600 Subject: [PATCH 075/483] gallivm/llvmpipe: rename some constant building functions --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 60 +++++++++---------- src/gallium/auxiliary/gallivm/lp_bld_const.c | 8 +-- src/gallium/auxiliary/gallivm/lp_bld_const.h | 6 +- src/gallium/auxiliary/gallivm/lp_bld_conv.c | 34 +++++------ src/gallium/auxiliary/gallivm/lp_bld_depth.c | 4 +- .../auxiliary/gallivm/lp_bld_format_soa.c | 4 +- src/gallium/auxiliary/gallivm/lp_bld_interp.c | 6 +- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 4 +- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 6 +- .../auxiliary/gallivm/lp_bld_sample_soa.c | 38 ++++++------ .../auxiliary/gallivm/lp_bld_swizzle.c | 4 +- .../auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 +- 14 files changed, 92 insertions(+), 94 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 233a36669d4..8e8fcccf564 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -361,12 +361,12 @@ lp_build_mul_u8n(LLVMBuilderRef builder, LLVMValueRef c8; LLVMValueRef ab; - c8 = lp_build_int_const_scalar(i16_type, 8); + c8 = lp_build_const_int_vec(i16_type, 8); #if 0 /* a*b/255 ~= (a*(b + 1)) >> 256 */ - b = LLVMBuildAdd(builder, b, lp_build_int_const_scalar(i16_type, 1), ""); + b = LLVMBuildAdd(builder, b, lp_build_const_int_vec(i16_type, 1), ""); ab = LLVMBuildMul(builder, a, b, ""); #else @@ -374,7 +374,7 @@ lp_build_mul_u8n(LLVMBuilderRef builder, /* ab/255 ~= (ab + (ab >> 8) + 0x80) >> 8 */ ab = LLVMBuildMul(builder, a, b, ""); ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c8, ""), ""); - ab = LLVMBuildAdd(builder, ab, lp_build_int_const_scalar(i16_type, 0x80), ""); + ab = LLVMBuildAdd(builder, ab, lp_build_const_int_vec(i16_type, 0x80), ""); #endif @@ -429,7 +429,7 @@ lp_build_mul(struct lp_build_context *bld, } if(type.fixed) - shift = lp_build_int_const_scalar(type, type.width/2); + shift = lp_build_const_int_vec(type, type.width/2); else shift = NULL; @@ -491,7 +491,7 @@ lp_build_mul_imm(struct lp_build_context *bld, * for Inf and NaN. */ unsigned mantissa = lp_mantissa(bld->type); - factor = lp_build_int_const_scalar(bld->type, (unsigned long long)shift << mantissa); + factor = lp_build_const_int_vec(bld->type, (unsigned long long)shift << mantissa); a = LLVMBuildBitCast(bld->builder, a, lp_build_int_vec_type(bld->type), ""); a = LLVMBuildAdd(bld->builder, a, factor, ""); a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->type), ""); @@ -499,12 +499,12 @@ lp_build_mul_imm(struct lp_build_context *bld, #endif } else { - factor = lp_build_const_scalar(bld->type, shift); + factor = lp_build_const_vec(bld->type, shift); return LLVMBuildShl(bld->builder, a, factor, ""); } } - factor = lp_build_const_scalar(bld->type, (double)b); + factor = lp_build_const_vec(bld->type, (double)b); return lp_build_mul(bld, a, factor); } @@ -567,7 +567,7 @@ lp_build_lerp(struct lp_build_context *bld, * but it will be wrong for other uses. Basically we need a more * powerful lp_type, capable of further distinguishing the values * interpretation from the value storage. */ - res = LLVMBuildAnd(bld->builder, res, lp_build_int_const_scalar(bld->type, (1 << bld->type.width/2) - 1), ""); + res = LLVMBuildAnd(bld->builder, res, lp_build_const_int_vec(bld->type, (1 << bld->type.width/2) - 1), ""); return res; } @@ -689,7 +689,7 @@ lp_build_abs(struct lp_build_context *bld, /* vector of floats */ LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); unsigned long long absMask = ~(1ULL << (type.width - 1)); - LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask)); + LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask)); a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); a = LLVMBuildAnd(bld->builder, a, mask, ""); a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); @@ -751,7 +751,7 @@ lp_build_sgn(struct lp_build_context *bld, /* vector */ int_type = lp_build_int_vec_type(type); vec_type = lp_build_vec_type(type); - mask = lp_build_int_const_scalar(type, maskBit); + mask = lp_build_const_int_vec(type, maskBit); } /* Take the sign bit and add it to 1 constant */ @@ -763,7 +763,7 @@ lp_build_sgn(struct lp_build_context *bld, } else { - LLVMValueRef minus_one = lp_build_const_scalar(type, -1.0); + LLVMValueRef minus_one = lp_build_const_vec(type, -1.0); cond = lp_build_cmp(bld, PIPE_FUNC_GREATER, a, bld->zero); res = lp_build_select(bld, cond, bld->one, minus_one); } @@ -789,8 +789,8 @@ lp_build_set_sign(struct lp_build_context *bld, const struct lp_type type = bld->type; LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); LLVMTypeRef vec_type = lp_build_vec_type(type); - LLVMValueRef shift = lp_build_int_const_scalar(type, type.width - 1); - LLVMValueRef mask = lp_build_int_const_scalar(type, + LLVMValueRef shift = lp_build_const_int_vec(type, type.width - 1); + LLVMValueRef mask = lp_build_const_int_vec(type, ~((unsigned long long) 1 << (type.width - 1))); LLVMValueRef val, res; @@ -1034,7 +1034,7 @@ lp_build_iround(struct lp_build_context *bld, } else { LLVMTypeRef vec_type = lp_build_vec_type(type); - LLVMValueRef mask = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1)); + LLVMValueRef mask = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1)); LLVMValueRef sign; LLVMValueRef half; @@ -1043,7 +1043,7 @@ lp_build_iround(struct lp_build_context *bld, sign = LLVMBuildAnd(bld->builder, sign, mask, ""); /* sign * 0.5 */ - half = lp_build_const_scalar(type, 0.5); + half = lp_build_const_vec(type, 0.5); half = LLVMBuildBitCast(bld->builder, half, int_vec_type, ""); half = LLVMBuildOr(bld->builder, sign, half, ""); half = LLVMBuildBitCast(bld->builder, half, vec_type, ""); @@ -1086,18 +1086,18 @@ lp_build_ifloor(struct lp_build_context *bld, /* Take the sign bit and add it to 1 constant */ LLVMTypeRef vec_type = lp_build_vec_type(type); unsigned mantissa = lp_mantissa(type); - LLVMValueRef mask = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1)); + LLVMValueRef mask = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1)); LLVMValueRef sign; LLVMValueRef offset; /* sign = a < 0 ? ~0 : 0 */ sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); sign = LLVMBuildAnd(bld->builder, sign, mask, ""); - sign = LLVMBuildAShr(bld->builder, sign, lp_build_int_const_scalar(type, type.width - 1), ""); + sign = LLVMBuildAShr(bld->builder, sign, lp_build_const_int_vec(type, type.width - 1), ""); lp_build_name(sign, "floor.sign"); /* offset = -0.99999(9)f */ - offset = lp_build_const_scalar(type, -(double)(((unsigned long long)1 << mantissa) - 1)/((unsigned long long)1 << mantissa)); + offset = lp_build_const_vec(type, -(double)(((unsigned long long)1 << mantissa) - 1)/((unsigned long long)1 << mantissa)); offset = LLVMConstBitCast(offset, int_vec_type); /* offset = a < 0 ? -0.99999(9)f : 0.0f */ @@ -1268,7 +1268,7 @@ lp_build_exp(struct lp_build_context *bld, LLVMValueRef x) { /* log2(e) = 1/log(2) */ - LLVMValueRef log2e = lp_build_const_scalar(bld->type, 1.4426950408889634); + LLVMValueRef log2e = lp_build_const_vec(bld->type, 1.4426950408889634); return lp_build_mul(bld, log2e, lp_build_exp2(bld, x)); } @@ -1282,7 +1282,7 @@ lp_build_log(struct lp_build_context *bld, LLVMValueRef x) { /* log(2) */ - LLVMValueRef log2 = lp_build_const_scalar(bld->type, 0.69314718055994529); + LLVMValueRef log2 = lp_build_const_vec(bld->type, 0.69314718055994529); return lp_build_mul(bld, log2, lp_build_exp2(bld, x)); } @@ -1318,7 +1318,7 @@ lp_build_polynomial(struct lp_build_context *bld, if (type.length == 1) coeff = LLVMConstReal(float_type, coeffs[i]); else - coeff = lp_build_const_scalar(type, coeffs[i]); + coeff = lp_build_const_vec(type, coeffs[i]); if(res) res = lp_build_add(bld, coeff, lp_build_mul(bld, x, res)); @@ -1375,11 +1375,11 @@ lp_build_exp2_approx(struct lp_build_context *bld, assert(type.floating && type.width == 32); - x = lp_build_min(bld, x, lp_build_const_scalar(type, 129.0)); - x = lp_build_max(bld, x, lp_build_const_scalar(type, -126.99999)); + x = lp_build_min(bld, x, lp_build_const_vec(type, 129.0)); + x = lp_build_max(bld, x, lp_build_const_vec(type, -126.99999)); /* ipart = int(x - 0.5) */ - ipart = LLVMBuildSub(bld->builder, x, lp_build_const_scalar(type, 0.5f), ""); + ipart = LLVMBuildSub(bld->builder, x, lp_build_const_vec(type, 0.5f), ""); ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, ""); /* fpart = x - ipart */ @@ -1389,8 +1389,8 @@ lp_build_exp2_approx(struct lp_build_context *bld, if(p_exp2_int_part || p_exp2) { /* expipart = (float) (1 << ipart) */ - expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_int_const_scalar(type, 127), ""); - expipart = LLVMBuildShl(bld->builder, expipart, lp_build_int_const_scalar(type, 23), ""); + expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_const_int_vec(type, 127), ""); + expipart = LLVMBuildShl(bld->builder, expipart, lp_build_const_int_vec(type, 23), ""); expipart = LLVMBuildBitCast(bld->builder, expipart, vec_type, ""); } @@ -1456,8 +1456,8 @@ lp_build_log2_approx(struct lp_build_context *bld, LLVMTypeRef vec_type = lp_build_vec_type(type); LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - LLVMValueRef expmask = lp_build_int_const_scalar(type, 0x7f800000); - LLVMValueRef mantmask = lp_build_int_const_scalar(type, 0x007fffff); + LLVMValueRef expmask = lp_build_const_int_vec(type, 0x7f800000); + LLVMValueRef mantmask = lp_build_const_int_vec(type, 0x007fffff); LLVMValueRef one = LLVMConstBitCast(bld->one, int_vec_type); LLVMValueRef i = NULL; @@ -1482,8 +1482,8 @@ lp_build_log2_approx(struct lp_build_context *bld, } if(p_floor_log2 || p_log2) { - logexp = LLVMBuildLShr(bld->builder, exp, lp_build_int_const_scalar(type, 23), ""); - logexp = LLVMBuildSub(bld->builder, logexp, lp_build_int_const_scalar(type, 127), ""); + logexp = LLVMBuildLShr(bld->builder, exp, lp_build_const_int_vec(type, 23), ""); + logexp = LLVMBuildSub(bld->builder, logexp, lp_build_const_int_vec(type, 127), ""); logexp = LLVMBuildSIToFP(bld->builder, logexp, vec_type, ""); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c index 8a275fa72f3..57843e9a60c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c @@ -263,7 +263,7 @@ lp_build_one(struct lp_type type) if(type.sign) /* TODO: Unfortunately this caused "Tried to create a shift operation * on a non-integer type!" */ - vec = LLVMConstLShr(vec, lp_build_int_const_scalar(type, 1)); + vec = LLVMConstLShr(vec, lp_build_const_int_vec(type, 1)); #endif return vec; @@ -283,8 +283,8 @@ lp_build_one(struct lp_type type) * Build constant-valued vector from a scalar value. */ LLVMValueRef -lp_build_const_scalar(struct lp_type type, - double val) +lp_build_const_vec(struct lp_type type, + double val) { LLVMTypeRef elem_type = lp_build_elem_type(type); LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; @@ -309,7 +309,7 @@ lp_build_const_scalar(struct lp_type type, LLVMValueRef -lp_build_int_const_scalar(struct lp_type type, +lp_build_const_int_vec(struct lp_type type, long long val) { LLVMTypeRef elem_type = lp_build_int_elem_type(type); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h index 0f426189003..9ca2f0664eb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h @@ -85,13 +85,11 @@ lp_build_one(struct lp_type type); LLVMValueRef -lp_build_const_scalar(struct lp_type type, - double val); +lp_build_const_vec(struct lp_type type, double val); LLVMValueRef -lp_build_int_const_scalar(struct lp_type type, - long long val); +lp_build_const_int_vec(struct lp_type type, long long val); LLVMValueRef diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c index f77cf787213..3f7f2ebde9c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c @@ -114,13 +114,13 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder, scale = (double)mask/ubound; bias = (double)((unsigned long long)1 << (mantissa - n)); - res = LLVMBuildMul(builder, src, lp_build_const_scalar(src_type, scale), ""); - res = LLVMBuildAdd(builder, res, lp_build_const_scalar(src_type, bias), ""); + res = LLVMBuildMul(builder, src, lp_build_const_vec(src_type, scale), ""); + res = LLVMBuildAdd(builder, res, lp_build_const_vec(src_type, bias), ""); res = LLVMBuildBitCast(builder, res, int_vec_type, ""); if(dst_width > n) { int shift = dst_width - n; - res = LLVMBuildShl(builder, res, lp_build_int_const_scalar(src_type, shift), ""); + res = LLVMBuildShl(builder, res, lp_build_const_int_vec(src_type, shift), ""); /* TODO: Fill in the empty lower bits for additional precision? */ /* YES: this fixes progs/trivial/tri-z-eq.c. @@ -130,21 +130,21 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder, #if 0 { LLVMValueRef msb; - msb = LLVMBuildLShr(builder, res, lp_build_int_const_scalar(src_type, dst_width - 1), ""); - msb = LLVMBuildShl(builder, msb, lp_build_int_const_scalar(src_type, shift), ""); - msb = LLVMBuildSub(builder, msb, lp_build_int_const_scalar(src_type, 1), ""); + msb = LLVMBuildLShr(builder, res, lp_build_const_int_vec(src_type, dst_width - 1), ""); + msb = LLVMBuildShl(builder, msb, lp_build_const_int_vec(src_type, shift), ""); + msb = LLVMBuildSub(builder, msb, lp_build_const_int_vec(src_type, 1), ""); res = LLVMBuildOr(builder, res, msb, ""); } #elif 0 while(shift > 0) { - res = LLVMBuildOr(builder, res, LLVMBuildLShr(builder, res, lp_build_int_const_scalar(src_type, n), ""), ""); + res = LLVMBuildOr(builder, res, LLVMBuildLShr(builder, res, lp_build_const_int_vec(src_type, n), ""), ""); shift -= n; n *= 2; } #endif } else - res = LLVMBuildAnd(builder, res, lp_build_int_const_scalar(src_type, mask), ""); + res = LLVMBuildAnd(builder, res, lp_build_const_int_vec(src_type, mask), ""); return res; } @@ -183,10 +183,10 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder, if(src_width > mantissa) { int shift = src_width - mantissa; - res = LLVMBuildLShr(builder, res, lp_build_int_const_scalar(dst_type, shift), ""); + res = LLVMBuildLShr(builder, res, lp_build_const_int_vec(dst_type, shift), ""); } - bias_ = lp_build_const_scalar(dst_type, bias); + bias_ = lp_build_const_vec(dst_type, bias); res = LLVMBuildOr(builder, res, @@ -195,7 +195,7 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder, res = LLVMBuildBitCast(builder, res, vec_type, ""); res = LLVMBuildSub(builder, res, bias_, ""); - res = LLVMBuildMul(builder, res, lp_build_const_scalar(dst_type, scale), ""); + res = LLVMBuildMul(builder, res, lp_build_const_vec(dst_type, scale), ""); return res; } @@ -251,7 +251,7 @@ lp_build_conv(LLVMBuilderRef builder, if(dst_min == 0.0) thres = bld.zero; else - thres = lp_build_const_scalar(src_type, dst_min); + thres = lp_build_const_vec(src_type, dst_min); for(i = 0; i < num_tmps; ++i) tmp[i] = lp_build_max(&bld, tmp[i], thres); } @@ -260,7 +260,7 @@ lp_build_conv(LLVMBuilderRef builder, if(dst_max == 1.0) thres = bld.one; else - thres = lp_build_const_scalar(src_type, dst_max); + thres = lp_build_const_vec(src_type, dst_max); for(i = 0; i < num_tmps; ++i) tmp[i] = lp_build_min(&bld, tmp[i], thres); } @@ -288,7 +288,7 @@ lp_build_conv(LLVMBuilderRef builder, LLVMTypeRef tmp_vec_type; if (dst_scale != 1.0) { - LLVMValueRef scale = lp_build_const_scalar(tmp_type, dst_scale); + LLVMValueRef scale = lp_build_const_vec(tmp_type, dst_scale); for(i = 0; i < num_tmps; ++i) tmp[i] = LLVMBuildMul(builder, tmp[i], scale, ""); } @@ -315,7 +315,7 @@ lp_build_conv(LLVMBuilderRef builder, /* FIXME: compensate different offsets too */ if(src_shift > dst_shift) { - LLVMValueRef shift = lp_build_int_const_scalar(tmp_type, src_shift - dst_shift); + LLVMValueRef shift = lp_build_const_int_vec(tmp_type, src_shift - dst_shift); for(i = 0; i < num_tmps; ++i) if(src_type.sign) tmp[i] = LLVMBuildAShr(builder, tmp[i], shift, ""); @@ -388,7 +388,7 @@ lp_build_conv(LLVMBuilderRef builder, } if (src_scale != 1.0) { - LLVMValueRef scale = lp_build_const_scalar(tmp_type, 1.0/src_scale); + LLVMValueRef scale = lp_build_const_vec(tmp_type, 1.0/src_scale); for(i = 0; i < num_tmps; ++i) tmp[i] = LLVMBuildMul(builder, tmp[i], scale, ""); } @@ -400,7 +400,7 @@ lp_build_conv(LLVMBuilderRef builder, /* FIXME: compensate different offsets too */ if(src_shift < dst_shift) { - LLVMValueRef shift = lp_build_int_const_scalar(tmp_type, dst_shift - src_shift); + LLVMValueRef shift = lp_build_const_int_vec(tmp_type, dst_shift - src_shift); for(i = 0; i < num_tmps; ++i) tmp[i] = LLVMBuildShl(builder, tmp[i], shift, ""); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index f08f8eb6d8b..829cffea4c8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -185,11 +185,11 @@ lp_build_depth_test(LLVMBuilderRef builder, if(padding_left || padding_right) { const unsigned long long mask_left = ((unsigned long long)1 << (format_desc->block.bits - padding_left)) - 1; const unsigned long long mask_right = ((unsigned long long)1 << (padding_right)) - 1; - z_bitmask = lp_build_int_const_scalar(type, mask_left ^ mask_right); + z_bitmask = lp_build_const_int_vec(type, mask_left ^ mask_right); } if(padding_left) - src = LLVMBuildLShr(builder, src, lp_build_int_const_scalar(type, padding_left), ""); + src = LLVMBuildLShr(builder, src, lp_build_const_int_vec(type, padding_left), ""); if(padding_right) src = LLVMBuildAnd(builder, src, z_bitmask, ""); if(padding_left || padding_right) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index abb27e4c328..45ee4b12ced 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -114,10 +114,10 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, case UTIL_FORMAT_TYPE_UNSIGNED: if(type.floating) { if(start) - input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(type, start), ""); + input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(type, start), ""); if(stop < format_desc->block.bits) { unsigned mask = ((unsigned long long)1 << width) - 1; - input = LLVMBuildAnd(builder, input, lp_build_int_const_scalar(type, mask), ""); + input = LLVMBuildAnd(builder, input, lp_build_const_int_vec(type, mask), ""); } if(format_desc->channel[chan].normalized) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_interp.c b/src/gallium/auxiliary/gallivm/lp_bld_interp.c index 2fc894017d8..09efb161217 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_interp.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_interp.c @@ -289,17 +289,17 @@ pos_update(struct lp_build_interp_soa_context *bld, int quad_index) /* top-right or bottom-right quad in block */ /* build x += xstep */ x = lp_build_add(&bld->base, x, - lp_build_const_scalar(bld->base.type, xstep)); + lp_build_const_vec(bld->base.type, xstep)); } if (quad_index == 2) { /* bottom-left quad in block */ /* build y += ystep */ y = lp_build_add(&bld->base, y, - lp_build_const_scalar(bld->base.type, ystep)); + lp_build_const_vec(bld->base.type, ystep)); /* build x -= xstep */ x = lp_build_sub(&bld->base, x, - lp_build_const_scalar(bld->base.type, xstep)); + lp_build_const_vec(bld->base.type, xstep)); } lp_build_name(x, "pos.x"); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index f3df3dd1388..e2e533fa7ec 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -193,7 +193,7 @@ lp_build_compare(LLVMBuilderRef builder, if(table[func].gt && ((type.width == 8 && type.sign) || (type.width != 8 && !type.sign))) { - LLVMValueRef msb = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1)); + LLVMValueRef msb = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1)); a = LLVMBuildXor(builder, a, msb, ""); b = LLVMBuildXor(builder, b, msb, ""); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c index 23398f41f99..2daa8a3b582 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c @@ -164,7 +164,7 @@ lp_build_unpack2(LLVMBuilderRef builder, if(dst_type.sign && src_type.sign) { /* Replicate the sign bit in the most significant bits */ - msb = LLVMBuildAShr(builder, src, lp_build_int_const_scalar(src_type, src_type.width - 1), ""); + msb = LLVMBuildAShr(builder, src, lp_build_const_int_vec(src_type, src_type.width - 1), ""); } else /* Most significant bits always zero */ @@ -361,7 +361,7 @@ lp_build_packs2(LLVMBuilderRef builder, if(clamp) { struct lp_build_context bld; unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width; - LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1); + LLVMValueRef dst_max = lp_build_const_int_vec(src_type, ((unsigned long long)1 << dst_bits) - 1); lp_build_context_init(&bld, builder, src_type); lo = lp_build_min(&bld, lo, dst_max); hi = lp_build_min(&bld, hi, dst_max); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 2f74aa5e00a..bb76ad4c6bf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -173,7 +173,7 @@ lp_build_sample_offset(struct lp_build_context *bld, LLVMValueRef x_stride; LLVMValueRef offset; - x_stride = lp_build_const_scalar(bld->type, format_desc->block.bits/8); + x_stride = lp_build_const_vec(bld->type, format_desc->block.bits/8); if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { LLVMValueRef x_lo, x_hi; @@ -195,9 +195,9 @@ lp_build_sample_offset(struct lp_build_context *bld, y_hi = LLVMBuildLShr(bld->builder, y, bld->one, ""); x_stride_lo = x_stride; - y_stride_lo = lp_build_const_scalar(bld->type, 2*format_desc->block.bits/8); + y_stride_lo = lp_build_const_vec(bld->type, 2*format_desc->block.bits/8); - x_stride_hi = lp_build_const_scalar(bld->type, 4*format_desc->block.bits/8); + x_stride_hi = lp_build_const_vec(bld->type, 4*format_desc->block.bits/8); y_stride_hi = LLVMBuildShl(bld->builder, y_stride, bld->one, ""); x_offset_lo = lp_build_mul(bld, x_lo, x_stride_lo); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 9741dbb389c..995c016b9dd 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -292,7 +292,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, int chan; for (chan = 0; chan < 4; chan++) { LLVMValueRef border_chan = - lp_build_const_scalar(bld->texel_type, + lp_build_const_vec(bld->texel_type, bld->static_state->border_color[chan]); texel[chan] = lp_build_select(&bld->texel_bld, use_border, border_chan, texel[chan]); @@ -457,8 +457,8 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, struct lp_build_context *coord_bld = &bld->coord_bld; struct lp_build_context *int_coord_bld = &bld->int_coord_bld; struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; - LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0); - LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5); + LLVMValueRef two = lp_build_const_vec(coord_bld->type, 2.0); + LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5); LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length); LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); @@ -512,7 +512,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, else { LLVMValueRef min, max; /* clamp to [0.5, length - 0.5] */ - min = lp_build_const_scalar(coord_bld->type, 0.5F); + min = lp_build_const_vec(coord_bld->type, 0.5F); max = lp_build_sub(coord_bld, length_f, min); coord = lp_build_clamp(coord_bld, coord, min, max); } @@ -533,7 +533,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, if (bld->static_state->normalized_coords) { /* min = -1.0 / (2 * length) = -0.5 / length */ min = lp_build_mul(coord_bld, - lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_const_vec(coord_bld->type, -0.5F), lp_build_rcp(coord_bld, length_f)); /* max = 1.0 - min */ max = lp_build_sub(coord_bld, coord_bld->one, min); @@ -545,7 +545,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, } else { /* clamp to [-0.5, length + 0.5] */ - min = lp_build_const_scalar(coord_bld->type, -0.5F); + min = lp_build_const_vec(coord_bld->type, -0.5F); max = lp_build_sub(coord_bld, length_f, min); coord = lp_build_clamp(coord_bld, coord, min, max); coord = lp_build_sub(coord_bld, coord, half); @@ -620,7 +620,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, LLVMValueRef min, max; /* min = -1.0 / (2 * length) = -0.5 / length */ min = lp_build_mul(coord_bld, - lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_const_vec(coord_bld->type, -0.5F), lp_build_rcp(coord_bld, length_f)); /* max = 1.0 - min */ max = lp_build_sub(coord_bld, coord_bld->one, min); @@ -665,7 +665,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, struct lp_build_context *coord_bld = &bld->coord_bld; struct lp_build_context *int_coord_bld = &bld->int_coord_bld; struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; - LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0); + LLVMValueRef two = lp_build_const_vec(coord_bld->type, 2.0); LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length); LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); @@ -708,7 +708,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, } else { /* clamp to [0.5, length - 0.5] */ - min = lp_build_const_scalar(coord_bld->type, 0.5F); + min = lp_build_const_vec(coord_bld->type, 0.5F); max = lp_build_sub(coord_bld, length_f, min); } /* coord = clamp(coord, min, max) */ @@ -724,7 +724,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, if (bld->static_state->normalized_coords) { /* min = -1.0 / (2 * length) = -0.5 / length */ min = lp_build_mul(coord_bld, - lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_const_vec(coord_bld->type, -0.5F), lp_build_rcp(coord_bld, length_f)); /* max = length - min */ max = lp_build_sub(coord_bld, length_f, min); @@ -733,7 +733,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, } else { /* clamp to [-0.5, length + 0.5] */ - min = lp_build_const_scalar(coord_bld->type, -0.5F); + min = lp_build_const_vec(coord_bld->type, -0.5F); max = lp_build_sub(coord_bld, length_f, min); } /* coord = clamp(coord, min, max) */ @@ -1226,7 +1226,7 @@ static LLVMValueRef lp_build_cube_ima(struct lp_build_context *coord_bld, LLVMValueRef coord) { /* ima = -0.5 / abs(coord); */ - LLVMValueRef negHalf = lp_build_const_scalar(coord_bld->type, -0.5); + LLVMValueRef negHalf = lp_build_const_vec(coord_bld->type, -0.5); LLVMValueRef absCoord = lp_build_abs(coord_bld, coord); LLVMValueRef ima = lp_build_mul(coord_bld, negHalf, lp_build_rcp(coord_bld, absCoord)); @@ -1246,7 +1246,7 @@ lp_build_cube_coord(struct lp_build_context *coord_bld, LLVMValueRef coord, LLVMValueRef ima) { /* return negate(coord) * ima * sign + 0.5; */ - LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5); + LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5); LLVMValueRef res; assert(negate_coord == +1 || negate_coord == -1); @@ -1708,7 +1708,7 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, LLVMValueRef packed, LLVMValueRef *rgba) { - LLVMValueRef mask = lp_build_int_const_scalar(dst_type, 0xff); + LLVMValueRef mask = lp_build_const_int_vec(dst_type, 0xff); unsigned chan; /* Decode the input vector components */ @@ -1720,7 +1720,7 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, input = packed; if(start) - input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(dst_type, start), ""); + input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(dst_type, start), ""); if(stop < 32) input = LLVMBuildAnd(builder, input, mask, ""); @@ -1782,17 +1782,17 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, t = LLVMBuildFPToSI(builder, t, i32_vec_type, ""); /* subtract 0.5 (add -128) */ - i32_c128 = lp_build_int_const_scalar(i32.type, -128); + i32_c128 = lp_build_const_int_vec(i32.type, -128); s = LLVMBuildAdd(builder, s, i32_c128, ""); t = LLVMBuildAdd(builder, t, i32_c128, ""); /* compute floor (shift right 8) */ - i32_c8 = lp_build_int_const_scalar(i32.type, 8); + i32_c8 = lp_build_const_int_vec(i32.type, 8); s_ipart = LLVMBuildAShr(builder, s, i32_c8, ""); t_ipart = LLVMBuildAShr(builder, t, i32_c8, ""); /* compute fractional part (AND with 0xff) */ - i32_c255 = lp_build_int_const_scalar(i32.type, 255); + i32_c255 = lp_build_const_int_vec(i32.type, 255); s_fpart = LLVMBuildAnd(builder, s, i32_c255, ""); t_fpart = LLVMBuildAnd(builder, t, i32_c255, ""); @@ -1959,7 +1959,7 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, } assert(res); - res = lp_build_mul(texel_bld, res, lp_build_const_scalar(texel_bld->type, 0.25)); + res = lp_build_mul(texel_bld, res, lp_build_const_vec(texel_bld->type, 0.25)); /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */ for(chan = 0; chan < 3; ++chan) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c index 64e81f7b1fe..278c838eaca 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c @@ -144,9 +144,9 @@ lp_build_broadcast_aos(struct lp_build_context *bld, #endif if(shift > 0) - tmp = LLVMBuildLShr(bld->builder, a, lp_build_int_const_scalar(type4, shift*type.width), ""); + tmp = LLVMBuildLShr(bld->builder, a, lp_build_const_int_vec(type4, shift*type.width), ""); if(shift < 0) - tmp = LLVMBuildShl(bld->builder, a, lp_build_int_const_scalar(type4, -shift*type.width), ""); + tmp = LLVMBuildShl(bld->builder, a, lp_build_const_int_vec(type4, -shift*type.width), ""); assert(tmp); if(tmp) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 5ec59d636cb..f160be878f8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -475,7 +475,7 @@ emit_store( break; case TGSI_SAT_MINUS_PLUS_ONE: - value = lp_build_max(&bld->base, value, lp_build_const_scalar(bld->base.type, -1.0)); + value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.type, -1.0)); value = lp_build_min(&bld->base, value, bld->base.one); break; @@ -996,7 +996,7 @@ emit_instruction( src0 = emit_fetch( bld, inst, 0, chan_index ); src1 = emit_fetch( bld, inst, 1, chan_index ); src2 = emit_fetch( bld, inst, 2, chan_index ); - tmp1 = lp_build_const_scalar(bld->base.type, 0.5); + tmp1 = lp_build_const_vec(bld->base.type, 0.5); tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_GREATER, src2, tmp1); dst0[chan_index] = lp_build_select( &bld->base, tmp0, src0, src1 ); } @@ -1713,7 +1713,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, assert(num_immediates < LP_MAX_IMMEDIATES); for( i = 0; i < size; ++i ) bld.immediates[num_immediates][i] = - lp_build_const_scalar(type, parse.FullToken.FullImmediate.u[i].Float); + lp_build_const_vec(type, parse.FullToken.FullImmediate.u[i].Float); for( i = size; i < 4; ++i ) bld.immediates[num_immediates][i] = bld.base.undef; num_immediates++; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 9a8de0edfda..64f988d6d01 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -252,7 +252,7 @@ generate_tri_edge_mask(LLVMBuilderRef builder, LLVMConstInt(LLVMInt32Type(), INT_MIN, 0), ""); - in_out_mask = lp_build_int_const_scalar(i32_type, ~0); + in_out_mask = lp_build_const_int_vec(i32_type, ~0); lp_build_flow_scope_declare(flow, &in_out_mask); @@ -367,7 +367,7 @@ build_int32_vec_const(int value) i32_type.norm = FALSE; /* values are not normalized */ i32_type.width = 32; /* 32-bit int values */ i32_type.length = 4; /* 4 elements per vector */ - return lp_build_int_const_scalar(i32_type, value); + return lp_build_const_int_vec(i32_type, value); } From cb1b0b4bec9a1c05bbb762ed04a78dfdf584e3a6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Mar 2010 18:19:04 -0600 Subject: [PATCH 076/483] gallivm: checkpoint: stencil test code --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 106 ++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 829cffea4c8..cbc48f98651 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -61,11 +61,104 @@ #include "util/u_format.h" #include "lp_bld_type.h" +#include "lp_bld_arit.h" #include "lp_bld_const.h" #include "lp_bld_logic.h" #include "lp_bld_flow.h" #include "lp_bld_debug.h" #include "lp_bld_depth.h" +#include "lp_bld_swizzle.h" + + + +/** + * Do the stencil test comparison (compare fb Z values against ref value. + * \param stencilVals vector of stencil values from framebuffer + * \param stencilRef the stencil reference value, replicated as a vector + * \return mask of pass/fail values + */ +static LLVMValueRef +lp_build_stencil_test(struct lp_build_context *bld, + const struct pipe_stencil_state *stencil, + LLVMValueRef stencilVals, + LLVMValueRef stencilRef) +{ + const unsigned stencilMax = 255; /* XXX fix */ + struct lp_type type = bld->type; + LLVMValueRef res; + + assert(stencil->enabled); + + if (stencil->valuemask != stencilMax) { + /* compute stencilRef = stencilRef & valuemask */ + LLVMValueRef valuemask = lp_build_const_int_vec(type, stencil->valuemask); + stencilRef = LLVMBuildAnd(bld->builder, stencilRef, valuemask, ""); + /* compute stencilVals = stencilVals & valuemask */ + stencilVals = LLVMBuildAnd(bld->builder, stencilVals, valuemask, ""); + } + + res = lp_build_compare(bld->builder, bld->type, stencil->func, + stencilVals, stencilRef); + + return res; +} + + +/** + * Apply the stencil operator (add/sub/keep/etc) to the given vector + * of stencil values. + * \return new stencil values vector + */ +static LLVMValueRef +lp_build_stencil_op(struct lp_build_context *bld, + unsigned stencil_op, + LLVMValueRef stencilRef, + const struct pipe_stencil_state *stencil, + LLVMValueRef stencilVals) + +{ + const unsigned stencilMax = 255; /* XXX fix */ + struct lp_type type = bld->type; + LLVMValueRef res; + LLVMValueRef max = lp_build_const_int_vec(type, stencilMax); + + switch (stencil_op) { + case PIPE_STENCIL_OP_KEEP: + res = stencilVals; + case PIPE_STENCIL_OP_ZERO: + res = bld->zero; + case PIPE_STENCIL_OP_REPLACE: + res = lp_build_broadcast_scalar(bld, stencilRef); + case PIPE_STENCIL_OP_INCR: + res = lp_build_add(bld, stencilVals, bld->one); + res = lp_build_min(bld, res, max); + case PIPE_STENCIL_OP_DECR: + res = lp_build_sub(bld, stencilVals, bld->one); + res = lp_build_max(bld, res, bld->zero); + case PIPE_STENCIL_OP_INCR_WRAP: + res = lp_build_add(bld, stencilVals, bld->one); + res = LLVMBuildAnd(bld->builder, res, max, ""); + case PIPE_STENCIL_OP_DECR_WRAP: + res = lp_build_sub(bld, stencilVals, bld->one); + res = LLVMBuildAnd(bld->builder, res, max, ""); + case PIPE_STENCIL_OP_INVERT: + res = LLVMBuildNot(bld->builder, stencilVals, ""); + default: + assert(0 && "bad stencil op mode"); + res = NULL; + } + + if (stencil->writemask != stencilMax) { + /* compute res = (res & mask) | (stencilVals & ~mask) */ + LLVMValueRef mask = lp_build_const_int_vec(type, stencil->writemask); + LLVMValueRef cmask = LLVMBuildNot(bld->builder, mask, "notWritemask"); + LLVMValueRef t1 = LLVMBuildAnd(bld->builder, res, mask, "t1"); + LLVMValueRef t2 = LLVMBuildAnd(bld->builder, stencilVals, cmask, "t2"); + res = LLVMBuildOr(bld->builder, t1, t2, "t1_or_t2"); + } + + return res; +} /** @@ -109,7 +202,14 @@ lp_depth_type(const struct util_format_description *format_desc, /** - * Depth test. + * Generate code for performing depth and/or stencil tests. + * We operate on a vector of values (typically a 2x2 quad). + * + * \param type the data type of the fragment depth/stencil values + * \param format_desc description of the depth/stencil surface + * \param mask the alive/dead pixel mask for the quad + * \param src the incoming depth/stencil values (a 2x2 quad) + * \param dst_ptr the outgoing/updated depth/stencil values */ void lp_build_depth_test(LLVMBuilderRef builder, @@ -126,6 +226,9 @@ lp_build_depth_test(LLVMBuilderRef builder, LLVMValueRef z_bitmask = NULL; LLVMValueRef test; + (void) lp_build_stencil_test; + (void) lp_build_stencil_op; + if(!state->enabled) return; @@ -198,6 +301,7 @@ lp_build_depth_test(LLVMBuilderRef builder, lp_build_name(dst, "zsbuf.z"); + /* compare src Z to dst Z, returning 'pass' mask */ test = lp_build_cmp(&bld, state->func, src, dst); lp_build_mask_update(mask, test); From eaee22ac880e431028ac4c6854af1873d5765869 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Mar 2010 00:12:37 +0000 Subject: [PATCH 077/483] i965g: Fix after context transfers --- src/gallium/drivers/i965/brw_context.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c index 3dbe2b91308..4bcdcdd17eb 100644 --- a/src/gallium/drivers/i965/brw_context.c +++ b/src/gallium/drivers/i965/brw_context.c @@ -118,6 +118,7 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen, brw->sws = brw_screen(screen)->sws; brw->chipset = brw_screen(screen)->chipset; + brw_tex_init( brw ); brw_pipe_blend_init( brw ); brw_pipe_depth_stencil_init( brw ); brw_pipe_framebuffer_init( brw ); From 8b63f9b497c22cb59678588d921699189f8b712f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 11 Mar 2010 03:33:03 +0000 Subject: [PATCH 078/483] winsys/sw: Add a software winsys layered on a pipe --- src/gallium/drivers/cell/ppu/cell_screen.c | 6 +- src/gallium/drivers/cell/ppu/cell_texture.c | 1 + src/gallium/drivers/llvmpipe/lp_screen.c | 6 +- src/gallium/drivers/llvmpipe/lp_texture.c | 51 ++++ src/gallium/drivers/softpipe/sp_screen.c | 6 +- src/gallium/drivers/softpipe/sp_texture.c | 54 +++- src/gallium/include/state_tracker/sw_winsys.h | 20 ++ src/gallium/winsys/drm/Makefile | 2 +- src/gallium/winsys/drm/i965/dri/Makefile | 1 + .../winsys/drm/i965/gem/i965_drm_api.c | 12 +- src/gallium/winsys/drm/sw/Makefile | 14 + src/gallium/winsys/drm/sw/sw_drm_api.c | 97 ++++++ src/gallium/winsys/drm/sw/sw_drm_api.h | 34 +++ src/gallium/winsys/drm/sw/wrapper_sw_winsys.c | 282 ++++++++++++++++++ src/gallium/winsys/drm/sw/wrapper_sw_winsys.h | 35 +++ src/gallium/winsys/gdi/gdi_sw_winsys.c | 25 ++ src/gallium/winsys/null/null_sw_winsys.c | 24 ++ src/gallium/winsys/xlib/xlib_sw_winsys.c | 25 ++ 18 files changed, 685 insertions(+), 10 deletions(-) create mode 100644 src/gallium/winsys/drm/sw/Makefile create mode 100644 src/gallium/winsys/drm/sw/sw_drm_api.c create mode 100644 src/gallium/winsys/drm/sw/sw_drm_api.h create mode 100644 src/gallium/winsys/drm/sw/wrapper_sw_winsys.c create mode 100644 src/gallium/winsys/drm/sw/wrapper_sw_winsys.h diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 31fd963d19a..f5528a7ec6b 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -142,8 +142,10 @@ cell_is_format_supported( struct pipe_screen *screen, format == PIPE_FORMAT_A8B8G8R8_SRGB) return FALSE; - if (tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { - if (!winsys->is_displaytarget_format_supported(winsys, format)) + if (tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { + if (!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) return FALSE; } diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index c65c3b4f885..5b169afaf88 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -105,6 +105,7 @@ cell_displaytarget_layout(struct pipe_screen *screen, /* Round up the surface size to a multiple of the tile size? */ ct->dt = winsys->displaytarget_create(winsys, + ct->base->tex_usage, ct->base.format, ct->base.width0, ct->base.height0, diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 5093f58bb19..f1bbc2092c4 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -204,8 +204,10 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, return FALSE; } - if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { - if(!winsys->is_displaytarget_format_supported(winsys, format)) + if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { + if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) return FALSE; } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 9a85a42897d..10ede9bb045 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -103,6 +103,7 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, unsigned height = align(lpt->base.height0, TILE_SIZE); lpt->dt = winsys->displaytarget_create(winsys, + lpt->base.tex_usage, lpt->base.format, width, height, 16, @@ -250,6 +251,55 @@ llvmpipe_texture_unmap(struct pipe_texture *texture, } +static struct pipe_texture * +llvmpipe_texture_from_handle(struct pipe_screen *screen, + const struct pipe_texture *template, + struct winsys_handle *whandle) +{ + struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys; + struct llvmpipe_texture *lpt = CALLOC_STRUCT(llvmpipe_texture); + if (!lpt) + return NULL; + + lpt->base = *template; + pipe_reference_init(&lpt->base.reference, 1); + lpt->base.screen = screen; + + lpt->pot = (util_is_power_of_two(template->width0) && + util_is_power_of_two(template->height0) && + util_is_power_of_two(template->depth0)); + + lpt->dt = winsys->displaytarget_from_handle(winsys, + template, + whandle, + &lpt->stride[0]); + if (!lpt->dt) + goto fail; + + return &lpt->base; + + fail: + FREE(lpt); + return NULL; +} + + +static boolean +llvmpipe_texture_get_handle(struct pipe_screen *screen, + struct pipe_texture *pt, + struct winsys_handle *whandle) +{ + struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys; + struct llvmpipe_texture *lpt = llvmpipe_texture(pt); + + assert(lpt->dt); + if (!lpt->dt) + return FALSE; + + return winsys->displaytarget_get_handle(winsys, lpt->dt, whandle); +} + + static struct pipe_surface * llvmpipe_get_tex_surface(struct pipe_screen *screen, struct pipe_texture *pt, @@ -418,6 +468,7 @@ llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen) { screen->texture_create = llvmpipe_texture_create; screen->texture_destroy = llvmpipe_texture_destroy; + screen->texture_get_handle = llvmpipe_texture_get_handle; screen->get_tex_surface = llvmpipe_get_tex_surface; screen->tex_surface_destroy = llvmpipe_tex_surface_destroy; diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index d62bfa3d633..757dc861284 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -173,8 +173,10 @@ softpipe_is_format_supported( struct pipe_screen *screen, break; } - if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { - if(!winsys->is_displaytarget_format_supported(winsys, format)) + if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { + if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) return FALSE; } diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 2aff6118f41..f4983b7c8e8 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -91,6 +91,7 @@ softpipe_displaytarget_layout(struct pipe_screen *screen, /* Round up the surface size to a multiple of the tile size? */ spt->dt = winsys->displaytarget_create(winsys, + spt->base.tex_usage, spt->base.format, spt->base.width0, spt->base.height0, @@ -139,8 +140,6 @@ softpipe_texture_create(struct pipe_screen *screen, } - - static void softpipe_texture_destroy(struct pipe_texture *pt) { @@ -161,6 +160,55 @@ softpipe_texture_destroy(struct pipe_texture *pt) } +static struct pipe_texture * +softpipe_texture_from_handle(struct pipe_screen *screen, + const struct pipe_texture *template, + struct winsys_handle *whandle) +{ + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture); + if (!spt) + return NULL; + + spt->base = *template; + pipe_reference_init(&spt->base.reference, 1); + spt->base.screen = screen; + + spt->pot = (util_is_power_of_two(template->width0) && + util_is_power_of_two(template->height0) && + util_is_power_of_two(template->depth0)); + + spt->dt = winsys->displaytarget_from_handle(winsys, + template, + whandle, + &spt->stride[0]); + if (!spt->dt) + goto fail; + + return &spt->base; + + fail: + FREE(spt); + return NULL; +} + + +static boolean +softpipe_texture_get_handle(struct pipe_screen *screen, + struct pipe_texture *pt, + struct winsys_handle *whandle) +{ + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + struct softpipe_texture *spt = softpipe_texture(pt); + + assert(spt->dt); + if (!spt->dt) + return FALSE; + + return winsys->displaytarget_get_handle(winsys, spt->dt, whandle); +} + + /** * Get a pipe_surface "view" into a texture. */ @@ -461,6 +509,8 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) { screen->texture_create = softpipe_texture_create; screen->texture_destroy = softpipe_texture_destroy; + screen->texture_from_handle = softpipe_texture_from_handle; + screen->texture_get_handle = softpipe_texture_get_handle; screen->get_tex_surface = softpipe_get_tex_surface; screen->tex_surface_destroy = softpipe_tex_surface_destroy; diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h index 0de98bbc1c9..9d202e48bfd 100644 --- a/src/gallium/include/state_tracker/sw_winsys.h +++ b/src/gallium/include/state_tracker/sw_winsys.h @@ -44,6 +44,7 @@ extern "C" { #endif +struct winsys_handle; struct pipe_screen; struct pipe_context; @@ -68,6 +69,7 @@ struct sw_winsys boolean (*is_displaytarget_format_supported)( struct sw_winsys *ws, + unsigned tex_usage, enum pipe_format format ); /** @@ -83,11 +85,29 @@ struct sw_winsys */ struct sw_displaytarget * (*displaytarget_create)( struct sw_winsys *ws, + unsigned tex_usage, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, unsigned *stride ); + /** + * Used to implement texture_from_handle. + */ + struct sw_displaytarget * + (*displaytarget_from_handle)( struct sw_winsys *ws, + const struct pipe_texture *templat, + struct winsys_handle *whandle, + unsigned *stride ); + + /** + * Used to implement texture_get_handle. + */ + boolean + (*displaytarget_get_handle)( struct sw_winsys *ws, + struct sw_displaytarget *dt, + struct winsys_handle *whandle ); + /** * \param flags bitmask of PIPE_BUFFER_USAGE_x flags */ diff --git a/src/gallium/winsys/drm/Makefile b/src/gallium/winsys/drm/Makefile index fee01916432..a998aff931d 100644 --- a/src/gallium/winsys/drm/Makefile +++ b/src/gallium/winsys/drm/Makefile @@ -2,7 +2,7 @@ TOP = ../../../.. include $(TOP)/configs/current -SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS) +SUBDIRS = sw $(GALLIUM_WINSYS_DRM_DIRS) default install clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/gallium/winsys/drm/i965/dri/Makefile b/src/gallium/winsys/drm/i965/dri/Makefile index f7e81eed87b..56690769fc7 100644 --- a/src/gallium/winsys/drm/i965/dri/Makefile +++ b/src/gallium/winsys/drm/i965/dri/Makefile @@ -7,6 +7,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/winsys/drm/sw/libswdrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i965/libi965.a diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c index 21e82303f72..2ebc05f47e0 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c @@ -10,6 +10,8 @@ #include "trace/tr_drm.h" +#include "../../sw/sw_drm_api.h" + /* * Helper functions */ @@ -108,5 +110,13 @@ struct drm_api i965_libdrm_api = struct drm_api * drm_api_create() { - return trace_drm_create(&i965_libdrm_api); + struct drm_api *api; + + if (api == NULL && debug_get_bool_option("BRW_SOFTPIPE", FALSE)) + api = sw_drm_api_create(&i965_libdrm_api); + + if (api == NULL) + api = &i965_libdrm_api; + + return trace_drm_create(api); } diff --git a/src/gallium/winsys/drm/sw/Makefile b/src/gallium/winsys/drm/sw/Makefile new file mode 100644 index 00000000000..5f3c3ec325d --- /dev/null +++ b/src/gallium/winsys/drm/sw/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = swdrm + +C_SOURCES = \ + wrapper_sw_winsys.c \ + sw_drm_api.c + +LIBRARY_INCLUDES = + +LIBRARY_DEFINES = + +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c new file mode 100644 index 00000000000..0fd2163913e --- /dev/null +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -0,0 +1,97 @@ +/********************************************************** + * Copyright 2010 VMware, Inc. 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 THE AUTHORS OR COPYRIGHT HOLDERS + * 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. + * + **********************************************************/ + + +#include "util/u_memory.h" +#include "softpipe/sp_public.h" +#include "state_tracker/drm_api.h" +#include "wrapper_sw_winsys.h" +#include "sw_drm_api.h" + + +/* + * Defines + */ + + +struct sw_drm_api +{ + struct drm_api base; + struct drm_api *api; + struct sw_winsys *sw; +}; + +static INLINE struct sw_drm_api * +sw_drm_api(struct drm_api *api) +{ + return (struct sw_drm_api *)api; +} + + +/* + * Exported functions + */ + + +static struct pipe_screen * +sw_drm_create_screen(struct drm_api *_api, int drmFD, + struct drm_create_screen_arg *arg) +{ + struct sw_drm_api *swapi = sw_drm_api(_api); + struct drm_api *api = swapi->api; + struct sw_winsys *sww; + struct pipe_screen *screen; + + screen = api->create_screen(api, drmFD, arg); + + sww = wrapper_sw_winsys_warp_pipe_screen(screen); + + return softpipe_create_screen(sww); +} + +static void +sw_drm_destroy(struct drm_api *api) +{ + struct sw_drm_api *swapi = sw_drm_api(api); + if (swapi->api->destroy) + swapi->api->destroy(swapi->api); + + FREE(swapi); +} + +struct drm_api * +sw_drm_api_create(struct drm_api *api) +{ + struct sw_drm_api *swapi = CALLOC_STRUCT(sw_drm_api); + + swapi->base.name = "sw"; + swapi->base.driver_name = api->driver_name; + swapi->base.create_screen = sw_drm_create_screen; + swapi->base.destroy = sw_drm_destroy; + + swapi->api = api; + + return &swapi->base; +} diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.h b/src/gallium/winsys/drm/sw/sw_drm_api.h new file mode 100644 index 00000000000..ce90a04ae0c --- /dev/null +++ b/src/gallium/winsys/drm/sw/sw_drm_api.h @@ -0,0 +1,34 @@ +/********************************************************** + * Copyright 2010 VMware, Inc. 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 THE AUTHORS OR COPYRIGHT HOLDERS + * 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. + * + **********************************************************/ + + +#ifndef SW_DRM_API_H +#define SW_DRM_API_H + +struct drm_api; + +struct drm_api * sw_drm_api_create(struct drm_api *api); + +#endif diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c new file mode 100644 index 00000000000..459b1c1e2a3 --- /dev/null +++ b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c @@ -0,0 +1,282 @@ +/********************************************************** + * Copyright 2010 VMware, Inc. 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 THE AUTHORS OR COPYRIGHT HOLDERS + * 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. + * + **********************************************************/ + + +#include "wrapper_sw_winsys.h" + +#include "pipe/p_format.h" +#include "pipe/p_state.h" + +#include "state_tracker/sw_winsys.h" + +#include "util/u_memory.h" +#include "util/u_inlines.h" + +/* + * This code wraps a pipe_screen and exposes a sw_winsys interface for use + * with software resterizers. This code is used by the DRM based winsys to + * allow access to the drm driver. + * + * We must borrow the whole stack because only the pipe screen knows how + * to decode the content of a buffer. Or how to create a buffer that + * can still be used by drivers using real hardware (as the case is + * with software st/xorg but hw st/dri). + * + * We also need a pipe context for the transfers. + */ + +struct wrapper_sw_winsys +{ + struct sw_winsys base; + struct pipe_screen *screen; + struct pipe_context *pipe; +}; + +struct wrapper_sw_displaytarget +{ + struct wrapper_sw_winsys *winsys; + struct pipe_texture *tex; + struct pipe_transfer *transfer; + + unsigned width; + unsigned height; + unsigned map_count; + unsigned stride; /**< because we give stride at create */ + void *ptr; +}; + +static INLINE struct wrapper_sw_winsys * +wrapper_sw_winsys(struct sw_winsys *ws) +{ + return (struct wrapper_sw_winsys *)ws; +} + +static INLINE struct wrapper_sw_displaytarget * +wrapper_sw_displaytarget(struct sw_displaytarget *dt) +{ + return (struct wrapper_sw_displaytarget *)dt; +} + + +/* + * Functions + */ + + +static boolean +wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride) +{ + struct pipe_context *pipe = wdt->winsys->pipe; + struct pipe_texture *tex = wdt->tex; + struct pipe_transfer *tr; + + tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0, + PIPE_TRANSFER_READ_WRITE, + 0, 0, wdt->width, wdt->height); + if (!tr) + return FALSE; + + *stride = tr->stride; + wdt->stride = tr->stride; + + pipe->tex_transfer_destroy(pipe, tr); + + return TRUE; +} + +static struct sw_displaytarget * +wsw_dt_wrap_texture(struct wrapper_sw_winsys *wsw, + struct pipe_texture *tex, unsigned *stride) +{ + struct wrapper_sw_displaytarget *wdt = CALLOC_STRUCT(wrapper_sw_displaytarget); + if (!wdt) + goto err_unref; + + wdt->tex = tex; + wdt->winsys = wsw; + + if (!wsw_dt_get_stride(wdt, stride)) + goto err_free; + + return (struct sw_displaytarget *)wdt; + +err_free: + FREE(wdt); +err_unref: + pipe_texture_reference(&tex, NULL); + return NULL; +} + +static struct sw_displaytarget * +wsw_dt_create(struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws); + struct pipe_texture templ; + struct pipe_texture *tex; + + /* + * XXX Why don't we just get the template. + */ + memset(&templ, 0, sizeof(templ)); + templ.width0 = width; + templ.height0 = height; + templ.format = format; + templ.tex_usage = tex_usage; + + /* XXX alignment: we can't do anything about this */ + + tex = wsw->screen->texture_create(wsw->screen, &templ); + if (!tex) + return NULL; + + return wsw_dt_wrap_texture(wsw, tex, stride); +} + +static struct sw_displaytarget * +wsw_dt_from_handle(struct sw_winsys *ws, + const struct pipe_texture *templ, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws); + struct pipe_texture *tex; + + tex = wsw->screen->texture_from_handle(wsw->screen, templ, whandle); + if (!tex) + return NULL; + + return wsw_dt_wrap_texture(wsw, tex, stride); +} + +static void * +wsw_dt_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) +{ + struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt); + struct pipe_context *pipe = wdt->winsys->pipe; + struct pipe_texture *tex = wdt->tex; + struct pipe_transfer *tr; + void *ptr; + + if (!wdt->map_count) { + + assert(!wdt->transfer); + + tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0, + PIPE_TRANSFER_READ_WRITE, + 0, 0, wdt->width, wdt->height); + if (!tr) + return NULL; + + ptr = pipe->transfer_map(pipe, tr); + if (!ptr) + goto err; + + wdt->transfer = tr; + wdt->ptr = ptr; + + /* XXX Handle this case */ + assert(tr->stride == wdt->stride); + } + + wdt->map_count++; + + return wdt->ptr; + +err: + pipe->tex_transfer_destroy(pipe, tr); + return NULL; +} + +static void +wsw_dt_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt); + struct pipe_context *pipe = wdt->winsys->pipe; + + assert(wdt->transfer); + + wdt->map_count--; + + if (wdt->map_count) + return; + + pipe->transfer_unmap(pipe, wdt->transfer); + pipe->tex_transfer_destroy(pipe, wdt->transfer); + wdt->transfer = NULL; +} + +static void +wsw_dt_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt); + + pipe_texture_reference(&wdt->tex, NULL); + + FREE(wdt); +} + +static void +wsw_destroy(struct sw_winsys *ws) +{ + struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws); + + wsw->pipe->destroy(wsw->pipe); + wsw->screen->destroy(wsw->screen); + + FREE(wsw); +} + +struct sw_winsys * +wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen) +{ + struct wrapper_sw_winsys *wsw = CALLOC_STRUCT(wrapper_sw_winsys); + + wsw->base.displaytarget_create = wsw_dt_create; + wsw->base.displaytarget_from_handle = wsw_dt_from_handle; + wsw->base.displaytarget_map = wsw_dt_map; + wsw->base.displaytarget_unmap = wsw_dt_unmap; + wsw->base.displaytarget_destroy = wsw_dt_destroy; + wsw->base.destroy = wsw_destroy; + + wsw->screen = screen; + wsw->pipe = screen->context_create(screen, NULL); + if (!wsw->pipe) + goto err; + + return &wsw->base; + +err: + FREE(wsw); + return NULL; +} diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h new file mode 100644 index 00000000000..b5c25a3c50f --- /dev/null +++ b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h @@ -0,0 +1,35 @@ +/********************************************************** + * Copyright 2010 VMware, Inc. 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 THE AUTHORS OR COPYRIGHT HOLDERS + * 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. + * + **********************************************************/ + + +#ifndef WRAPPER_SW_WINSYS +#define WRAPPER_SW_WINSYS + +struct sw_winsys; +struct pipe_screen; + +struct sw_winsys *wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen); + +#endif diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c index f5c0b7d56ec..4dba4b577b8 100644 --- a/src/gallium/winsys/gdi/gdi_sw_winsys.c +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.c @@ -71,6 +71,7 @@ gdi_sw_displaytarget( struct sw_displaytarget *buf ) static boolean gdi_sw_is_displaytarget_format_supported( struct sw_winsys *ws, + unsigned tex_usage, enum pipe_format format ) { switch(format) { @@ -119,6 +120,7 @@ gdi_sw_displaytarget_destroy(struct sw_winsys *winsys, static struct sw_displaytarget * gdi_sw_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, @@ -168,6 +170,27 @@ no_gdt: } +static struct sw_displaytarget * +gdi_sw_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templet, + struct winsys_handle *whandle, + unsigned *stride) +{ + assert(0); + return NULL; +} + + +static boolean +gdi_sw_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + assert(0); + return FALSE; +} + + void gdi_sw_display( struct sw_winsys *winsys, struct sw_displaytarget *dt, @@ -212,6 +235,8 @@ gdi_create_sw_winsys(void) winsys->destroy = gdi_sw_destroy; winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported; winsys->displaytarget_create = gdi_sw_displaytarget_create; + winsys->displaytarget_from_handle = gdi_sw_displaytarget_from_handle; + winsys->displaytarget_get_handle = gdi_sw_displaytarget_get_handle; winsys->displaytarget_map = gdi_sw_displaytarget_map; winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap; winsys->displaytarget_display = gdi_sw_displaytarget_display; diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/null/null_sw_winsys.c index d961d34860e..5027e57b303 100644 --- a/src/gallium/winsys/null/null_sw_winsys.c +++ b/src/gallium/winsys/null/null_sw_winsys.c @@ -44,6 +44,7 @@ static boolean null_sw_is_displaytarget_format_supported(struct sw_winsys *ws, + unsigned tex_usage, enum pipe_format format ) { return FALSE; @@ -78,6 +79,7 @@ null_sw_displaytarget_destroy(struct sw_winsys *winsys, static struct sw_displaytarget * null_sw_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, @@ -87,6 +89,26 @@ null_sw_displaytarget_create(struct sw_winsys *winsys, } +static struct sw_displaytarget * +null_sw_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templet, + struct winsys_handle *whandle, + unsigned *stride) +{ + return NULL; +} + + +static boolean +null_sw_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + assert(0); + return FALSE; +} + + static void null_sw_displaytarget_display(struct sw_winsys *winsys, struct sw_displaytarget *dt, @@ -115,6 +137,8 @@ null_sw_create(void) winsys->destroy = null_sw_destroy; winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported; winsys->displaytarget_create = null_sw_displaytarget_create; + winsys->displaytarget_from_handle = null_sw_displaytarget_from_handle; + winsys->displaytarget_get_handle = null_sw_displaytarget_get_handle; winsys->displaytarget_map = null_sw_displaytarget_map; winsys->displaytarget_unmap = null_sw_displaytarget_unmap; winsys->displaytarget_display = null_sw_displaytarget_display; diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index cecfa4a53d4..54789d7a87c 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -208,6 +208,7 @@ alloc_ximage(struct xm_displaytarget *xm_dt, static boolean xm_is_displaytarget_format_supported( struct sw_winsys *ws, + unsigned tex_usage, enum pipe_format format ) { /* TODO: check visuals or other sensible thing here */ @@ -358,6 +359,7 @@ xm_displaytarget_display(struct sw_winsys *ws, static struct sw_displaytarget * xm_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, enum pipe_format format, unsigned width, unsigned height, unsigned alignment, @@ -406,6 +408,27 @@ no_xm_dt: } +static struct sw_displaytarget * +xm_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templet, + struct winsys_handle *whandle, + unsigned *stride) +{ + assert(0); + return NULL; +} + + +static boolean +xm_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + assert(0); + return FALSE; +} + + static void xm_destroy( struct sw_winsys *ws ) { @@ -428,6 +451,8 @@ xlib_create_sw_winsys( Display *display ) ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported; ws->base.displaytarget_create = xm_displaytarget_create; + ws->base.displaytarget_from_handle = xm_displaytarget_from_handle; + ws->base.displaytarget_get_handle = xm_displaytarget_get_handle; ws->base.displaytarget_map = xm_displaytarget_map; ws->base.displaytarget_unmap = xm_displaytarget_unmap; ws->base.displaytarget_destroy = xm_displaytarget_destroy; From b586774016e2f5dd1541cd3b0c93f8ea69fe9e9a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Mar 2010 01:17:33 +0000 Subject: [PATCH 079/483] llvmpipe: Fix rebase typo --- src/gallium/drivers/llvmpipe/lp_texture.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 10ede9bb045..93ad789c35d 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -265,10 +265,6 @@ llvmpipe_texture_from_handle(struct pipe_screen *screen, pipe_reference_init(&lpt->base.reference, 1); lpt->base.screen = screen; - lpt->pot = (util_is_power_of_two(template->width0) && - util_is_power_of_two(template->height0) && - util_is_power_of_two(template->depth0)); - lpt->dt = winsys->displaytarget_from_handle(winsys, template, whandle, From 95d43bccde9ba5c0727bb2b9e52d050dacfa0cfa Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 16 Mar 2010 13:18:39 +1000 Subject: [PATCH 080/483] nv50: fix texturing from >=4GiB mark --- src/gallium/drivers/nv50/nv50_tex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 4c48b12cd87..eb64f6cee48 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -137,7 +137,8 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, so_data (so, nv50_tex_format_list[i].hw); so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); - so_data (so, mode); + so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH | + NOUVEAU_BO_RD | NOUVEAU_BO_OR, mode, mode); so_data (so, 0x00300000); so_data (so, mt->base.base.width0 | (1 << 31)); so_data (so, (mt->base.base.last_level << 28) | From e0ce4a4a0994211ead8e5a77cccdd2a084e8a288 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Mar 2010 15:48:03 +0800 Subject: [PATCH 081/483] i965g: Fix use of an uninitialized variable. --- src/gallium/winsys/drm/i965/gem/i965_drm_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c index 2ebc05f47e0..c644eedcb31 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c @@ -110,7 +110,7 @@ struct drm_api i965_libdrm_api = struct drm_api * drm_api_create() { - struct drm_api *api; + struct drm_api *api = NULL; if (api == NULL && debug_get_bool_option("BRW_SOFTPIPE", FALSE)) api = sw_drm_api_create(&i965_libdrm_api); From e4b8a307b25146202b1fb64339b307bde5ec3b30 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 16 Mar 2010 10:58:33 +0100 Subject: [PATCH 082/483] gallium/docs: Create a separate section for Sampler Views. --- src/gallium/docs/source/context.rst | 52 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index ef3e4639314..1f022570dbb 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -41,23 +41,6 @@ buffers, surfaces) are bound to the driver. * ``set_framebuffer_state`` -* ``set_fragment_sampler_views`` binds an array of sampler views to - fragment shader stage. Every binding point acquires a reference - to a respective sampler view and releases a reference to the previous - sampler view. - -* ``set_vertex_sampler_views`` binds an array of sampler views to vertex - shader stage. Every binding point acquires a reference to a respective - sampler view and releases a reference to the previous sampler view. - -* ``create_sampler_view`` creates a new sampler view. texture is associated - with the sampler view which results in sampler view holding a reference - to the texture. Format specified in template must be compatible - with texture format. - -* ``sampler_view_destroy`` destroys a sampler view and releases its reference - to associated texture. - * ``set_vertex_buffers`` @@ -79,6 +62,41 @@ objects. They all follow simple, one-method binding calls, e.g. * ``set_viewport_state`` +Sampler Views +^^^^^^^^^^^^^ + +These are the means to bind textures to shader stages. To create one, specify +its format, swizzle and LOD range in sampler view template. + +If texture format is different than template format, it is said the texture +is being cast to another format. Casting can be done only between compatible +formats, that is formats that have matching component order and sizes. + +Swizzle fields specify they way in which fetched texel components are placed +in the result register. For example, swizzle_r specifies what is going to be +placed in destination register x (AKA r). + +first_level and last_level fields of sampler view template specify the LOD +range the texture is going to be constrained to. + +* ``set_fragment_sampler_views`` binds an array of sampler views to + fragment shader stage. Every binding point acquires a reference + to a respective sampler view and releases a reference to the previous + sampler view. + +* ``set_vertex_sampler_views`` binds an array of sampler views to vertex + shader stage. Every binding point acquires a reference to a respective + sampler view and releases a reference to the previous sampler view. + +* ``create_sampler_view`` creates a new sampler view. texture is associated + with the sampler view which results in sampler view holding a reference + to the texture. Format specified in template must be compatible + with texture format. + +* ``sampler_view_destroy`` destroys a sampler view and releases its reference + to associated texture. + + Clearing ^^^^^^^^ From 8f55a95178069d5e8b18647e6b675fc403d68073 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 15 Mar 2010 21:55:08 +0100 Subject: [PATCH 083/483] gallium: change remaining util functions to use cso sampler views changes arguments of util_blit_pixels_tex and util_gen_mipmap to struct pipe_sampler_view * instead of struct pipe_texture *. --- src/gallium/auxiliary/util/u_blit.c | 22 ++++++++++++---------- src/gallium/auxiliary/util/u_blit.h | 2 +- src/gallium/auxiliary/util/u_gen_mipmap.c | 13 +++++++------ src/gallium/auxiliary/util/u_gen_mipmap.h | 2 +- src/mesa/state_tracker/st_cb_texture.c | 18 +++++++++++++++--- src/mesa/state_tracker/st_gen_mipmap.c | 11 ++++++----- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 4d9168face3..cd95f85b63b 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -555,21 +555,23 @@ void util_blit_flush( struct blit_state *ctx ) */ void util_blit_pixels_tex(struct blit_state *ctx, - struct pipe_texture *tex, - int srcX0, int srcY0, - int srcX1, int srcY1, - struct pipe_surface *dst, - int dstX0, int dstY0, - int dstX1, int dstY1, - float z, uint filter) + struct pipe_sampler_view *src_sampler_view, + int srcX0, int srcY0, + int srcX1, int srcY1, + struct pipe_surface *dst, + int dstX0, int dstY0, + int dstX1, int dstY1, + float z, uint filter) { struct pipe_framebuffer_state fb; float s0, t0, s1, t1; unsigned offset; + struct pipe_texture *tex = src_sampler_view->texture; assert(filter == PIPE_TEX_MIPFILTER_NEAREST || filter == PIPE_TEX_MIPFILTER_LINEAR); + assert(tex); assert(tex->width0 != 0); assert(tex->height0 != 0); @@ -588,7 +590,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); cso_save_samplers(ctx->cso); - cso_save_sampler_textures(ctx->cso); + cso_save_fragment_sampler_views(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); @@ -620,7 +622,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_set_viewport(ctx->cso, &ctx->viewport); /* texture */ - cso_set_sampler_textures(ctx->cso, 1, &tex); + cso_set_fragment_sampler_views(ctx->cso, 1, &src_sampler_view); /* shaders */ cso_set_fragment_shader_handle(ctx->cso, ctx->fs[TGSI_WRITEMASK_XYZW]); @@ -654,7 +656,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); cso_restore_samplers(ctx->cso); - cso_restore_sampler_textures(ctx->cso); + cso_restore_fragment_sampler_views(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h index 2d8cdd25fb9..1ebe65b4558 100644 --- a/src/gallium/auxiliary/util/u_blit.h +++ b/src/gallium/auxiliary/util/u_blit.h @@ -75,7 +75,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, extern void util_blit_pixels_tex(struct blit_state *ctx, - struct pipe_texture *tex, + struct pipe_sampler_view *src_sampler_view, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 5c51b53d7bd..61d64cff6d4 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1460,7 +1460,7 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) * Generate mipmap images. It's assumed all needed texture memory is * already allocated. * - * \param pt the texture to generate mipmap levels for + * \param psv the sampler view to the texture to generate mipmap levels for * \param face which cube face to generate mipmaps for (0 for non-cube maps) * \param baseLevel the first mipmap level to use as a src * \param lastLevel the last mipmap level to generate @@ -1469,12 +1469,13 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) */ void util_gen_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_sampler_view *psv, uint face, uint baseLevel, uint lastLevel, uint filter) { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_framebuffer_state fb; + struct pipe_texture *pt = psv->texture; void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d; uint dstLevel; uint zslice = 0; @@ -1492,7 +1493,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, filter == PIPE_TEX_FILTER_NEAREST); /* check if we can render in the texture's format */ - if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D, + if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel); return; @@ -1503,7 +1504,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); cso_save_samplers(ctx->cso); - cso_save_sampler_textures(ctx->cso); + cso_save_fragment_sampler_views(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); @@ -1572,7 +1573,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_single_sampler(ctx->cso, 0, &ctx->sampler); cso_single_sampler_done(ctx->cso); - cso_set_sampler_textures(ctx->cso, 1, &pt); + cso_set_fragment_sampler_views(ctx->cso, 1, &psv); /* quad coords in clip coords */ offset = set_vertex_data(ctx, @@ -1597,7 +1598,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); cso_restore_samplers(ctx->cso); - cso_restore_sampler_textures(ctx->cso); + cso_restore_fragment_sampler_views(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.h b/src/gallium/auxiliary/util/u_gen_mipmap.h index 54608f9466d..35ac9daeaa2 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.h +++ b/src/gallium/auxiliary/util/u_gen_mipmap.h @@ -59,7 +59,7 @@ util_gen_mipmap_flush( struct gen_mipmap_state *ctx ); extern void util_gen_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_sampler_view *psv, uint face, uint baseLevel, uint lastLevel, uint filter); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0c518a7e031..6ed1c60a51e 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -63,6 +63,7 @@ #include "util/u_blit.h" #include "util/u_format.h" #include "util/u_surface.h" +#include "util/u_sampler.h" #include "util/u_math.h" @@ -380,6 +381,8 @@ compress_with_blit(GLcontext * ctx, gl_format mesa_format; struct pipe_texture templ; struct pipe_texture *src_tex; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *src_view; struct pipe_surface *dst_surface; struct pipe_transfer *tex_xfer; void *map; @@ -441,9 +444,16 @@ compress_with_blit(GLcontext * ctx, pipe->transfer_unmap(pipe, tex_xfer); pipe->tex_transfer_destroy(pipe, tex_xfer); + /* Create temporary sampler view */ + u_sampler_view_default_template(&view_templ, + src_tex, + src_tex->format); + src_view = pipe->create_sampler_view(pipe, src_tex, &view_templ); + + /* copy / compress image */ util_blit_pixels_tex(ctx->st->blit, - src_tex, /* pipe_texture (src) */ + src_view, /* sampler view (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ dst_surface, /* pipe_surface (dst) */ @@ -455,6 +465,7 @@ compress_with_blit(GLcontext * ctx, pipe_surface_reference(&dst_surface, NULL); pipe_texture_reference(&src_tex, NULL); + pipe_sampler_view_reference(&src_view, NULL); return GL_TRUE; } @@ -817,6 +828,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); + struct st_texture_object *stObj = st_texture_object(texObj); + struct pipe_sampler_view *src_view = st_get_stobj_sampler_view(stObj); const GLuint width = texImage->Width; const GLuint height = texImage->Height; struct pipe_surface *dst_surface; @@ -833,7 +846,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, /* blit/render/decompress */ util_blit_pixels_tex(ctx->st->blit, - stImage->pt, /* pipe_texture (src) */ + src_view, /* pipe_texture (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ dst_surface, /* pipe_surface (dst) */ @@ -1457,7 +1470,6 @@ st_copy_texsubimage(GLcontext *ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct st_texture_object *stObj = st_texture_object(texObj); struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); struct st_texture_image *stImage = st_texture_image(texImage); diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index b2521433c87..97f6903f9e2 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -79,22 +79,23 @@ st_destroy_generate_mipmap(struct st_context *st) static boolean st_render_mipmap(struct st_context *st, GLenum target, - struct pipe_texture *pt, + struct st_texture_object *stObj, uint baseLevel, uint lastLevel) { struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; + struct pipe_sampler_view *psv = st_get_stobj_sampler_view(stObj); const uint face = _mesa_tex_target_to_face(target); assert(target != GL_TEXTURE_3D); /* not done yet */ /* check if we can render in the texture's format */ - if (!screen->is_format_supported(screen, pt->format, pt->target, + if (!screen->is_format_supported(screen, psv->format, psv->texture->target, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { return FALSE; } - util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel, + util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel, PIPE_TEX_FILTER_LINEAR); return TRUE; @@ -211,6 +212,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { struct st_context *st = ctx->st; + struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_texture *pt = st_get_texobj_texture(texObj); const uint baseLevel = texObj->BaseLevel; uint lastLevel; @@ -229,7 +231,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, /* The current gallium texture doesn't have space for all the * mipmap levels we need to generate. So allocate a new texture. */ - struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_texture *oldTex = stObj->pt; GLboolean needFlush; @@ -264,7 +265,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, /* Recall that the Mesa BaseLevel image is stored in the gallium * texture's level[0] position. So pass baseLevel=0 here. */ - if (!st_render_mipmap(st, target, pt, 0, lastLevel)) { + if (!st_render_mipmap(st, target, stObj, 0, lastLevel)) { fallback_generate_mipmap(ctx, target, texObj); } From d731190ec3a0401376e877d5f2e6a988a2eb9eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 16 Mar 2010 13:46:10 +0000 Subject: [PATCH 084/483] gallium: Silence warning. --- src/gallium/include/state_tracker/sw_winsys.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h index 9d202e48bfd..a87650dc77d 100644 --- a/src/gallium/include/state_tracker/sw_winsys.h +++ b/src/gallium/include/state_tracker/sw_winsys.h @@ -47,6 +47,7 @@ extern "C" { struct winsys_handle; struct pipe_screen; struct pipe_context; +struct pipe_texture; /** From 759c1c287caddac2f9d398de8c626ca435ecb42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 16 Mar 2010 13:48:09 +0000 Subject: [PATCH 085/483] libgl-xlib: Use a simple GALLIUM_DRIVER env var to select the pipe driver. GALLIUM_DRIVER is being used in many other places, and it easier to memorizing and understand than all the GALLIUM_NO_XXX. --- src/gallium/targets/libgl-xlib/xlib.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index eff4b4778bf..48e79fe4f3b 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -63,6 +63,8 @@ PUBLIC const struct st_module st_module_OpenGL = { static struct pipe_screen * swrast_xlib_create_screen( Display *display ) { + const char *default_driver; + const char *driver; struct sw_winsys *winsys; struct pipe_screen *screen = NULL; @@ -73,17 +75,29 @@ swrast_xlib_create_screen( Display *display ) if (winsys == NULL) return NULL; +#if defined(GALLIUM_CELL) + default_driver = "cell"; +#elif defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + /* Create a software rasterizer on top of that winsys: */ #if defined(GALLIUM_CELL) if (screen == NULL && - !debug_get_bool_option("GALLIUM_NO_CELL", FALSE)) + strcmp(driver, "cell") == 0) screen = cell_create_screen( winsys ); #endif #if defined(GALLIUM_LLVMPIPE) if (screen == NULL && - !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) + strcmp(driver, "llvmpipe") == 0) screen = llvmpipe_create_screen( winsys ); #endif From e1a4bb23703462487f6267e3ffb7b9b24db841e7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 07:56:56 -0600 Subject: [PATCH 086/483] regenerate gl_mangle.h to get new EGLImage functions --- include/GL/gl_mangle.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/GL/gl_mangle.h b/include/GL/gl_mangle.h index b292840f917..43d2e896b0b 100644 --- a/include/GL/gl_mangle.h +++ b/include/GL/gl_mangle.h @@ -393,6 +393,8 @@ #define glEdgeFlagPointerListIBM MANGLE(EdgeFlagPointerListIBM) #define glEdgeFlagPointer MANGLE(EdgeFlagPointer) #define glEdgeFlagv MANGLE(EdgeFlagv) +#define glEGLImageTargetRenderbufferStorageOES MANGLE(EGLImageTargetRenderbufferStorageOES) +#define glEGLImageTargetTexture2DOES MANGLE(EGLImageTargetTexture2DOES) #define glElementPointerAPPLE MANGLE(ElementPointerAPPLE) #define glElementPointerATI MANGLE(ElementPointerATI) #define glEnableClientStateIndexedEXT MANGLE(EnableClientStateIndexedEXT) From e9c2c4a76466fc1ccfbf4d5de048414f7126b940 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 15 Mar 2010 10:30:18 +0200 Subject: [PATCH 087/483] radeon: Fix buffer object unmap to be called only once for dma buffers. If flush happens inside radeonRefillCurrentMaRegion the last dma buffer would be unmapped twice. Unmapping buffer when moving buffer to wait list fixes the mapping error. --- src/mesa/drivers/dri/radeon/radeon_dma.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c index 22499bc38d1..6b7690cf8b3 100644 --- a/src/mesa/drivers/dri/radeon/radeon_dma.c +++ b/src/mesa/drivers/dri/radeon/radeon_dma.c @@ -184,9 +184,6 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size) radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %d\n", __FUNCTION__, size, rmesa->dma.minimum_size); - if (!is_empty_list(&rmesa->dma.reserved)) - radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo); - if (is_empty_list(&rmesa->dma.free) || last_elem(&rmesa->dma.free)->bo->size < size) { dma_bo = CALLOC_STRUCT(radeon_dma_bo); @@ -336,9 +333,6 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa) legacy_track_pending(rmesa->radeonScreen->bom, 0); } - if (!is_empty_list(&rmesa->dma.reserved)) - radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo); - /* move waiting bos to free list. wait list provides gpu time to handle data before reuse */ foreach_s(dma_bo, temp, &rmesa->dma.wait) { @@ -368,6 +362,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa) /* move reserved to wait list */ foreach_s(dma_bo, temp, &rmesa->dma.reserved) { + radeon_bo_unmap(dma_bo->bo); /* free objects that are too small to be used because of large request */ if (dma_bo->bo->size < rmesa->dma.minimum_size) { radeon_bo_unref(dma_bo->bo); From ac8662c29dbf96b456d23308c1bc459eea63e36c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 16 Mar 2010 15:49:23 +0100 Subject: [PATCH 088/483] st/xorg: fix up xorg state tracker to use cso changes use cso_set_fragment_sampler_views instead of cso_set_sampler_textures --- .../state_trackers/xorg/xorg_composite.c | 29 +++++++++---- src/gallium/state_trackers/xorg/xorg_exa.c | 3 ++ src/gallium/state_trackers/xorg/xorg_exa.h | 2 +- .../state_trackers/xorg/xorg_renderer.c | 21 +++++++--- .../state_trackers/xorg/xorg_renderer.h | 4 +- src/gallium/state_trackers/xorg/xorg_xv.c | 42 ++++++++++++++++--- 6 files changed, 78 insertions(+), 23 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 715a5e7b943..4ff48026e50 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -4,6 +4,7 @@ #include "xorg_exa_tgsi.h" #include "cso_cache/cso_context.h" +#include "util/u_sampler.h" /*XXX also in Xrender.h but the including it here breaks compilition */ @@ -356,6 +357,9 @@ bind_samplers(struct exa_context *exa, int op, { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state src_sampler, mask_sampler; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *src_view; + struct pipe_context *pipe = exa->pipe; exa->num_bound_samplers = 0; @@ -366,7 +370,7 @@ bind_samplers(struct exa_context *exa, int op, if (exa->has_solid_color) { debug_assert(!"solid color with textures"); samplers[0] = NULL; - exa->bound_textures[0] = NULL; + pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); } else { unsigned src_wrap = render_repeat_to_gallium( pSrcPicture->repeatType); @@ -381,8 +385,13 @@ bind_samplers(struct exa_context *exa, int op, src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; src_sampler.normalized_coords = 1; samplers[0] = &src_sampler; - exa->bound_textures[0] = pSrc->tex; exa->num_bound_samplers = 1; + u_sampler_view_default_template(&view_templ, + pSrc->tex, + pSrc->tex->format); + src_view = pipe->create_sampler_view(pipe, pSrc->tex, &view_templ); + pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); + exa->bound_sampler_views[0] = src_view; } } @@ -400,14 +409,19 @@ bind_samplers(struct exa_context *exa, int op, src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; mask_sampler.normalized_coords = 1; samplers[1] = &mask_sampler; - exa->bound_textures[1] = pMask->tex; exa->num_bound_samplers = 2; + u_sampler_view_default_template(&view_templ, + pMask->tex, + pMask->tex->format); + src_view = pipe->create_sampler_view(pipe, pMask->tex, &view_templ); + pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); + exa->bound_sampler_views[1] = src_view; } cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers, (const struct pipe_sampler_state **)samplers); - cso_set_sampler_textures(exa->renderer->cso, exa->num_bound_samplers, - exa->bound_textures); + cso_set_fragment_sampler_views(exa->renderer->cso, exa->num_bound_samplers, + exa->bound_sampler_views); } @@ -476,7 +490,6 @@ boolean xorg_composite_bind_state(struct exa_context *exa, renderer_begin_solid(exa->renderer); } else { renderer_begin_textures(exa->renderer, - exa->bound_textures, exa->num_bound_samplers); } @@ -506,7 +519,7 @@ void xorg_composite(struct exa_context *exa, renderer_texture(exa->renderer, pos, width, height, - exa->bound_textures, + exa->bound_sampler_views, exa->num_bound_samplers, src_matrix, mask_matrix); } @@ -538,7 +551,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa, pixmap->width, pixmap->height); bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL); cso_set_samplers(exa->renderer->cso, 0, NULL); - cso_set_sampler_textures(exa->renderer->cso, 0, NULL); + cso_set_fragment_sampler_views(exa->renderer->cso, 0, NULL); shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index bdec0e254fa..76e6411bb8c 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -975,6 +975,9 @@ xorg_exa_close(ScrnInfoPtr pScrn) modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; + pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); + pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); + renderer_destroy(exa->renderer); if (exa->pipe) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index f2cefe23b99..41b19061599 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -18,7 +18,7 @@ struct exa_context struct pipe_screen *scrn; struct xorg_renderer *renderer; - struct pipe_texture *bound_textures[MAX_EXA_SAMPLERS]; + struct pipe_sampler_view *bound_sampler_views[MAX_EXA_SAMPLERS]; int num_bound_samplers; float solid_color[4]; diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 1eb926360b9..81b0dcf656f 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -8,6 +8,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_rect.h" +#include "util/u_sampler.h" #include "util/u_inlines.h" @@ -482,8 +483,17 @@ void renderer_copy_prepare(struct xorg_renderer *r, dst_surface->width, dst_surface->height); - /* texture */ - cso_set_sampler_textures(r->cso, 1, &src_texture); + /* texture/sampler view */ + { + struct pipe_sampler_view templ; + struct pipe_sampler_view *src_view; + u_sampler_view_default_template(&templ, + src_texture, + src_texture->format); + src_view = pipe->create_sampler_view(pipe, src_texture, &templ); + cso_set_fragment_sampler_views(r->cso, 1, &src_view); + pipe_sampler_view_reference(&src_view, NULL); + } /* shaders */ shader = xorg_shaders_get(r->shaders, @@ -655,7 +665,6 @@ void renderer_draw_flush(struct xorg_renderer *r) } void renderer_begin_textures(struct xorg_renderer *r, - struct pipe_texture **textures, int num_textures) { r->attrs_per_vertex = 1 + num_textures; @@ -665,7 +674,7 @@ void renderer_begin_textures(struct xorg_renderer *r, void renderer_texture(struct xorg_renderer *r, int *pos, int width, int height, - struct pipe_texture **textures, + struct pipe_sampler_view **sampler_view, int num_textures, float *src_matrix, float *mask_matrix) @@ -693,7 +702,7 @@ void renderer_texture(struct xorg_renderer *r, pos[0], pos[1], /* src */ pos[4], pos[5], /* dst */ width, height, - textures[0], src_matrix); + sampler_view[0]->texture, src_matrix); break; case 3: renderer_draw_conditional(r, 4 * 12); @@ -702,7 +711,7 @@ void renderer_texture(struct xorg_renderer *r, pos[2], pos[3], /* mask */ pos[4], pos[5], /* dst */ width, height, - textures[0], textures[1], + sampler_view[0]->texture, sampler_view[1]->texture, src_matrix, mask_matrix); break; default: diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h index 3d006287199..cc5802e79b2 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.h +++ b/src/gallium/state_trackers/xorg/xorg_renderer.h @@ -65,12 +65,12 @@ void renderer_solid(struct xorg_renderer *r, float *color); void renderer_begin_textures(struct xorg_renderer *r, - struct pipe_texture **textures, int num_textures); + void renderer_texture(struct xorg_renderer *r, int *pos, int width, int height, - struct pipe_texture **textures, + struct pipe_sampler_view **textures, int num_textures, float *src_matrix, float *mask_matrix); diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index 5a195cb482d..5efda6837de 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -9,6 +9,7 @@ #include "xorg_exa_tgsi.h" #include "cso_cache/cso_context.h" +#include "util/u_sampler.h" #include "pipe/p_screen.h" @@ -91,6 +92,7 @@ struct xorg_xv_port_priv { /* juggle two sets of seperate Y, U and V * textures */ struct pipe_texture *yuv[2][3]; + struct pipe_sampler_view *yuv_views[2][3]; }; @@ -180,32 +182,60 @@ static int check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height) { struct pipe_texture **dst = priv->yuv[priv->current_set]; + struct pipe_sampler_view **dst_view = priv->yuv_views[priv->current_set]; + struct pipe_sampler_view view_templ; + struct pipe_context *pipe = priv->r->pipe; + if (!dst[0] || dst[0]->width0 != width || dst[0]->height0 != height) { pipe_texture_reference(&dst[0], NULL); + pipe_sampler_view_reference(&dst_view[0], NULL); } if (!dst[1] || dst[1]->width0 != width || dst[1]->height0 != height) { pipe_texture_reference(&dst[1], NULL); + pipe_sampler_view_reference(&dst_view[1], NULL); } if (!dst[2] || dst[2]->width0 != width || dst[2]->height0 != height) { pipe_texture_reference(&dst[2], NULL); + pipe_sampler_view_reference(&dst_view[2], NULL); } - if (!dst[0]) + if (!dst[0]) { dst[0] = create_component_texture(priv->r->pipe, width, height); + if (dst[0]) { + u_sampler_view_default_template(&view_templ, + dst[0], + dst[0]->format); + dst_view[0] = pipe->create_sampler_view(pipe, dst[0], &view_templ); + } + } - if (!dst[1]) + if (!dst[1]) { dst[1] = create_component_texture(priv->r->pipe, width, height); + if (dst[1]) { + u_sampler_view_default_template(&view_templ, + dst[1], + dst[1]->format); + dst_view[1] = pipe->create_sampler_view(pipe, dst[1], &view_templ); + } + } - if (!dst[2]) + if (!dst[2]) { dst[2] = create_component_texture(priv->r->pipe, width, height); + if (dst[2]) { + u_sampler_view_default_template(&view_templ, + dst[2], + dst[2]->format); + dst_view[2] = pipe->create_sampler_view(pipe, dst[2], &view_templ); + } + } - if (!dst[0] || !dst[1] || !dst[2]) + if (!dst[0] || !dst[1] || !dst[2] || !dst_view[0] || !dst_view[1] || !dst_view[2] ) return BadAlloc; return Success; @@ -450,6 +480,7 @@ bind_samplers(struct xorg_xv_port_priv *port) struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state sampler; struct pipe_texture **dst = port->yuv[port->current_set]; + struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set]; memset(&sampler, 0, sizeof(struct pipe_sampler_state)); @@ -469,8 +500,7 @@ bind_samplers(struct xorg_xv_port_priv *port) cso_set_samplers(port->r->cso, 3, (const struct pipe_sampler_state **)samplers); - cso_set_sampler_textures(port->r->cso, 3, - dst); + cso_set_fragment_sampler_views(port->r->cso, 3, dst_views); } static int From d320152b4786e72f0fe76ec5e8cf58b0eea91b13 Mon Sep 17 00:00:00 2001 From: "Matthew W. S. Bell" Date: Mon, 15 Mar 2010 01:18:02 +0000 Subject: [PATCH 089/483] Correct GL_EQUIV code in r67/7xx. From 247e121106e8d3e389f2e5a6edf13ea70ac18df7 Mon Sep 17 00:00:00 2001 These seem to be documented in . --- src/mesa/drivers/dri/r600/r700_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 6f156b54096..12eaebbc16b 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -614,7 +614,7 @@ static GLuint translate_logicop(GLenum logicop) case GL_XOR: return 0x66; case GL_EQUIV: - return 0xaa; + return 0x99; case GL_AND_REVERSE: return 0x44; case GL_AND_INVERTED: From f0c32629276a0bf33eed5ba519e3536061e239ad Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 16 Mar 2010 07:38:51 -0700 Subject: [PATCH 090/483] mesa: set version string to 7.8-rc1 --- Makefile | 2 +- src/mesa/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c4ee9e583cf..37683e0f0dc 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-devel +VERSION=7.8-rc1 DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index d521569f8d3..7ed1e1a32a4 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -35,7 +35,7 @@ #define MESA_MAJOR 7 #define MESA_MINOR 8 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.8-devel" +#define MESA_VERSION_STRING "7.8-rc1" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) From c1c9fad293eed751668fe2b34ff611af8d268131 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 16 Mar 2010 07:48:14 -0700 Subject: [PATCH 091/483] Remove nonexistant files from tarballs rule of Makefile The Makefile should eventually be fixed to stop building tarballs if one of the individual calls to tar fails. --- Makefile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 37683e0f0dc..68b5adffbe9 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/shader/descrip.mms \ $(DIRECTORY)/src/mesa/shader/slang/*.[ch] \ $(DIRECTORY)/src/mesa/shader/slang/descrip.mms \ - $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch] \ $(DIRECTORY)/src/mesa/shader/slang/library/*.gc \ $(DIRECTORY)/src/mesa/shader/slang/library/Makefile \ $(DIRECTORY)/src/mesa/swrast/*.[ch] \ @@ -380,15 +379,6 @@ SGI_GLU_FILES = \ $(DIRECTORY)/src/glu/sgi/libtess/*.[ch] \ $(DIRECTORY)/src/glu/sgi/libutil/*.[ch] -MESA_GLU_FILES = \ - $(DIRECTORY)/src/glu/mesa/README[12] \ - $(DIRECTORY)/src/glu/mesa/Makefile* \ - $(DIRECTORY)/src/glu/mesa/descrip.mms \ - $(DIRECTORY)/src/glu/mesa/mms_depend \ - $(DIRECTORY)/src/glu/mesa/*.def \ - $(DIRECTORY)/src/glu/mesa/depend \ - $(DIRECTORY)/src/glu/mesa/*.[ch] - GLW_FILES = \ $(DIRECTORY)/src/glw/*.[ch] \ $(DIRECTORY)/src/glw/Makefile* \ @@ -451,11 +441,7 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/glx/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.cpp \ - $(DIRECTORY)/src/glut/beos/Makefile \ - $(DIRECTORY)/src/glut/fbdev/Makefile \ - $(DIRECTORY)/src/glut/fbdev/*[ch] \ - $(DIRECTORY)/src/glut/mini/*[ch] \ - $(DIRECTORY)/src/glut/mini/glut.pc.in \ + $(DIRECTORY)/src/glut/beos/Makefile DEPEND_FILES = \ $(TOP)/src/mesa/depend \ From 40c3861e1e98116c573027b054a6a05208c53b6a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 16 Mar 2010 19:39:09 +0100 Subject: [PATCH 092/483] st/mesa: Invalidate sampler view when texture object changes. --- src/mesa/state_tracker/st_cb_texture.c | 3 +++ src/mesa/state_tracker/st_gen_mipmap.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 6ed1c60a51e..3ef030f5a9b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -571,6 +571,7 @@ st_TexImage(GLcontext * ctx, DBG("release it\n"); pipe_texture_reference(&stObj->pt, NULL); assert(!stObj->pt); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); stObj->teximage_realloc = FALSE; } } @@ -1807,6 +1808,7 @@ st_finalize_texture(GLcontext *ctx, firstImage->pt != stObj->pt && firstImage->pt->last_level >= stObj->lastLevel) { pipe_texture_reference(&stObj->pt, firstImage->pt); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); } /* bytes per pixel block (blocks are usually 1x1) */ @@ -1826,6 +1828,7 @@ st_finalize_texture(GLcontext *ctx, stObj->pt->depth0 != firstImage->base.Depth2) { pipe_texture_reference(&stObj->pt, NULL); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; } } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 97f6903f9e2..030b0a0f065 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -256,6 +256,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, /* release the old tex (will likely be freed too) */ pipe_texture_reference(&oldTex, NULL); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); pt = stObj->pt; } From 7ee4db50b10ab2d8fdfc4781f26b84041cf568d7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2010 10:38:20 -0800 Subject: [PATCH 093/483] i965: Fix the response len of masked sampler messages for 8-wide dispatch. The bad response length would hang the GPU with a masked sample in a shader using control flow. For 8-wide, the response length is always 4, and masked slots are just not written to. brw_wm_glsl.c already allocates registers in the right locations. Fixes piglit glsl-fs-bug25902 (fd.o bug #25902). (cherry picked from commit f6d210c284751ac50a8d6358de7e75a1ff1e4ac7) (cherry picked from commit dc8c0359448cdae7b367552ba58783c04b199778) --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index f69d5296137..82f2fdab2fc 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1290,7 +1290,7 @@ void brw_SAMPLE(struct brw_compile *p, GLuint simd_mode) { GLboolean need_stall = 0; - + if (writemask == 0) { /*printf("%s: zero writemask??\n", __FUNCTION__); */ return; @@ -1327,8 +1327,14 @@ void brw_SAMPLE(struct brw_compile *p, /* printf("need stall %x %x\n", newmask , writemask); */ } else { + GLboolean dispatch_16 = GL_FALSE; + struct brw_reg m1 = brw_message_reg(msg_reg_nr); - + + guess_execution_size(p->current, dest); + if (p->current->header.execution_size == BRW_EXECUTE_16) + dispatch_16 = GL_TRUE; + newmask = ~newmask & WRITEMASK_XYZW; brw_push_insn_state(p); @@ -1343,7 +1349,13 @@ void brw_SAMPLE(struct brw_compile *p, src0 = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW); dest = offset(dest, dst_offset); - response_length = len * 2; + + /* For 16-wide dispatch, masked channels are skipped in the + * response. For 8-wide, masked channels still take up slots, + * and are just not written to. + */ + if (dispatch_16) + response_length = len * 2; } } From 837f003eeb1ce56c2d8285e82ee86b5ffbb19442 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2010 11:00:40 -0800 Subject: [PATCH 094/483] i965: Add support for the CMP opcode in the GLSL path. This would be triggered by use of sqrt() along with control flow. Fixes piglit-fs-sqrt-branch and a bug in Yo Frankie!. (cherry picked from commit 48dca99feb394febc3af44e14f23fb12a9cc9204) --- src/mesa/drivers/dri/i965/brw_wm.h | 6 ++++++ src/mesa/drivers/dri/i965/brw_wm_emit.c | 12 ++++++------ src/mesa/drivers/dri/i965/brw_wm_glsl.c | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 88d84ee82fe..47b764d24d1 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -328,6 +328,12 @@ void emit_cinterp(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, const struct brw_reg *arg0); +void emit_cmp(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1, + const struct brw_reg *arg2); void emit_ddxy(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 9315bca3156..c7d87b9d94c 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -566,12 +566,12 @@ static void emit_sne( struct brw_compile *p, emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1); } -static void emit_cmp( struct brw_compile *p, - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2 ) +void emit_cmp(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1, + const struct brw_reg *arg2) { GLuint i; diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 562608e2ecd..a42e6bf7a58 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -1960,6 +1960,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) case OPCODE_LG2: emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]); break; + case OPCODE_CMP: + emit_cmp(p, dst, dst_flags, args[0], args[1], args[2]); + break; case OPCODE_MIN: unalias2(c, emit_min, dst, dst_flags, args[0], args[1]); break; From 1254d3d315497636a2445533372dd3d1fa6f96dc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Mar 2010 12:12:31 -0800 Subject: [PATCH 095/483] i965: Fix up the handling of point sprite coordinate replacement. The code was walking over the regs of pairs of attributes and checking whether the attribute with a given reg index had point sprite enabled. So the point sprite setup code was rarely even getting executed. Instead, we need to determine which channels of a reg need point sprite coordinate replacement. In addition, it was multiplying the attribute by 1/w, when it's supposed to cover (0, 1) in each direction regardless of w, and it wasn't filling in the Z and W components of the texcoord as specified. Fixes piglit point-sprite and the spriteblast demo. Bug #24431, #22245. (cherry picked from commit bc632d04370566c1156cbd0345fe303834f0b910) --- src/mesa/drivers/dri/i965/brw_sf.c | 21 ++-- src/mesa/drivers/dri/i965/brw_sf.h | 6 +- src/mesa/drivers/dri/i965/brw_sf_emit.c | 135 +++++++++++++++--------- 3 files changed, 96 insertions(+), 66 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 8e6839b8120..57d1c29ade1 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -46,7 +46,6 @@ static void compile_sf_prog( struct brw_context *brw, struct brw_sf_prog_key *key ) { - GLcontext *ctx = &brw->intel.ctx; struct brw_sf_compile c; const GLuint *program; GLuint program_size; @@ -69,20 +68,14 @@ static void compile_sf_prog( struct brw_context *brw, /* Construct map from attribute number to position in the vertex. */ - for (i = idx = 0; i < VERT_RESULT_MAX; i++) + for (i = idx = 0; i < VERT_RESULT_MAX; i++) { if (c.key.attrs & BITFIELD64_BIT(i)) { c.attr_to_idx[i] = idx; c.idx_to_attr[idx] = i; - if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) { - c.point_attrs[i].CoordReplace = - ctx->Point.CoordReplace[i - VERT_RESULT_TEX0]; - } - else { - c.point_attrs[i].CoordReplace = GL_FALSE; - } idx++; } - + } + /* Which primitive? Or all three? */ switch (key->primitive) { @@ -162,6 +155,14 @@ static void upload_sf_prog(struct brw_context *brw) } key.do_point_sprite = ctx->Point.PointSprite; + if (key.do_point_sprite) { + int i; + + for (i = 0; i < 8; i++) { + if (ctx->Point.CoordReplace[i]) + key.point_sprite_coord_replace |= (1 << i); + } + } key.sprite_origin_lower_left = (ctx->Point.SpriteOrigin == GL_LOWER_LEFT); /* _NEW_LIGHT */ key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT); diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h index 0ba731fac99..a0680a56f2c 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.h +++ b/src/mesa/drivers/dri/i965/brw_sf.h @@ -46,6 +46,7 @@ struct brw_sf_prog_key { GLbitfield64 attrs; + uint8_t point_sprite_coord_replace; GLuint primitive:2; GLuint do_twoside_color:1; GLuint do_flat_shading:1; @@ -56,10 +57,6 @@ struct brw_sf_prog_key { GLuint pad:24; }; -struct brw_sf_point_tex { - GLboolean CoordReplace; -}; - struct brw_sf_compile { struct brw_compile func; struct brw_sf_prog_key key; @@ -100,7 +97,6 @@ struct brw_sf_compile { GLubyte attr_to_idx[VERT_RESULT_MAX]; GLubyte idx_to_attr[VERT_RESULT_MAX]; - struct brw_sf_point_tex point_attrs[VERT_RESULT_MAX]; }; diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c index bb08055e3bb..56f7c986e78 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c @@ -354,6 +354,33 @@ static GLboolean calculate_masks( struct brw_sf_compile *c, return is_last_attr; } +/* Calculates the predicate control for which channels of a reg + * (containing 2 attrs) to do point sprite coordinate replacement on. + */ +static uint16_t +calculate_point_sprite_mask(struct brw_sf_compile *c, GLuint reg) +{ + int attr1, attr2; + uint16_t pc = 0; + + attr1 = c->idx_to_attr[reg * 2]; + if (attr1 >= VERT_RESULT_TEX0 && attr1 <= VERT_RESULT_TEX7) { + if (c->key.point_sprite_coord_replace & (1 << (attr1 - VERT_RESULT_TEX0))) + pc |= 0x0f; + } + + if (reg * 2 + 1 < c->nr_setup_attrs) { + attr2 = c->idx_to_attr[reg * 2 + 1]; + if (attr2 >= VERT_RESULT_TEX0 && attr2 <= VERT_RESULT_TEX7) { + if (c->key.point_sprite_coord_replace & (1 << (attr2 - + VERT_RESULT_TEX0))) + pc |= 0xf0; + } + } + + return pc; +} + void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate) @@ -529,22 +556,27 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate) copy_z_inv_w(c); for (i = 0; i < c->nr_setup_regs; i++) { - struct brw_sf_point_tex *tex = &c->point_attrs[c->idx_to_attr[2*i]]; struct brw_reg a0 = offset(c->vert[0], i); - GLushort pc, pc_persp, pc_linear; + GLushort pc, pc_persp, pc_linear, pc_coord_replace; GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear); - - if (pc_persp) - { - if (!tex->CoordReplace) { - brw_set_predicate_control_flag_value(p, pc_persp); - brw_MUL(p, a0, a0, c->inv_w[0]); - } + + pc_coord_replace = calculate_point_sprite_mask(c, i); + pc_persp &= ~pc_coord_replace; + + if (pc_persp) { + brw_set_predicate_control_flag_value(p, pc_persp); + brw_MUL(p, a0, a0, c->inv_w[0]); } - if (tex->CoordReplace) { - /* Caculate 1.0/PointWidth */ - brw_math(&c->func, + /* Point sprite coordinate replacement: A texcoord with this + * enabled gets replaced with the value (x, y, 0, 1) where x and + * y vary from 0 to 1 across the horizontal and vertical of the + * point. + */ + if (pc_coord_replace) { + brw_set_predicate_control_flag_value(p, pc_coord_replace); + /* Caculate 1.0/PointWidth */ + brw_math(&c->func, c->tmp, BRW_MATH_FUNCTION_INV, BRW_MATH_SATURATE_NONE, @@ -553,50 +585,51 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate) BRW_MATH_DATA_SCALAR, BRW_MATH_PRECISION_FULL); - if (c->key.sprite_origin_lower_left) { - brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); - brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0])); - brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); - } else { - brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); - brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); - } - } else { - brw_MOV(p, c->m1Cx, brw_imm_ud(0)); - brw_MOV(p, c->m2Cy, brw_imm_ud(0)); - } + brw_set_access_mode(p, BRW_ALIGN_16); - { - brw_set_predicate_control_flag_value(p, pc); - if (tex->CoordReplace) { - if (c->key.sprite_origin_lower_left) { - brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0)); - brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0)); - } - else - brw_MOV(p, c->m3C0, brw_imm_f(0.0)); + /* dA/dx, dA/dy */ + brw_MOV(p, c->m1Cx, brw_imm_f(0.0)); + brw_MOV(p, c->m2Cy, brw_imm_f(0.0)); + brw_MOV(p, brw_writemask(c->m1Cx, WRITEMASK_X), c->tmp); + if (c->key.sprite_origin_lower_left) { + brw_MOV(p, brw_writemask(c->m2Cy, WRITEMASK_Y), negate(c->tmp)); } else { - brw_MOV(p, c->m3C0, a0); /* constant value */ + brw_MOV(p, brw_writemask(c->m2Cy, WRITEMASK_Y), c->tmp); } - /* Copy m0..m3 to URB. - */ - brw_urb_WRITE(p, - brw_null_reg(), - 0, - brw_vec8_grf(0, 0), - 0, /* allocate */ - 1, /* used */ - 4, /* msg len */ - 0, /* response len */ - last, /* eot */ - last, /* writes complete */ - i*4, /* urb destination offset */ - BRW_URB_SWIZZLE_TRANSPOSE); + /* attribute constant offset */ + brw_MOV(p, c->m3C0, brw_imm_f(0.0)); + if (c->key.sprite_origin_lower_left) { + brw_MOV(p, brw_writemask(c->m3C0, WRITEMASK_YW), brw_imm_f(1.0)); + } else { + brw_MOV(p, brw_writemask(c->m3C0, WRITEMASK_W), brw_imm_f(1.0)); + } + + brw_set_access_mode(p, BRW_ALIGN_1); } + + if (pc & ~pc_coord_replace) { + brw_set_predicate_control_flag_value(p, pc & ~pc_coord_replace); + brw_MOV(p, c->m1Cx, brw_imm_ud(0)); + brw_MOV(p, c->m2Cy, brw_imm_ud(0)); + brw_MOV(p, c->m3C0, a0); /* constant value */ + } + + + brw_set_predicate_control_flag_value(p, pc); + /* Copy m0..m3 to URB. */ + brw_urb_WRITE(p, + brw_null_reg(), + 0, + brw_vec8_grf(0, 0), + 0, /* allocate */ + 1, /* used */ + 4, /* msg len */ + 0, /* response len */ + last, /* eot */ + last, /* writes complete */ + i*4, /* urb destination offset */ + BRW_URB_SWIZZLE_TRANSPOSE); } } From 009392f50db7ae0f6ef1fcbff268d5b833852074 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Mar 2010 16:08:33 -0800 Subject: [PATCH 096/483] i965: Fix up VP constbuf leak on program delete. (cherry picked from commit 7f6d2754d586545ab6c970acffdd897294879039) --- src/mesa/drivers/dri/i965/brw_program.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index c78f7b38aee..1fd957b3ad6 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -95,9 +95,17 @@ static void brwDeleteProgram( GLcontext *ctx, struct gl_program *prog ) { if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - struct brw_fragment_program *brw_fprog = brw_fragment_program(fprog); - dri_bo_unreference(brw_fprog->const_buffer); + struct gl_fragment_program *fp = (struct gl_fragment_program *) prog; + struct brw_fragment_program *brw_fp = brw_fragment_program(fp); + + dri_bo_unreference(brw_fp->const_buffer); + } + + if (prog->Target == GL_VERTEX_PROGRAM_ARB) { + struct gl_vertex_program *vp = (struct gl_vertex_program *) prog; + struct brw_vertex_program *brw_vp = brw_vertex_program(vp); + + dri_bo_unreference(brw_vp->const_buffer); } _mesa_delete_program( ctx, prog ); From d24f59d0081074ae9c4532949e75147447c8a82a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 09:56:42 -0800 Subject: [PATCH 097/483] i965: Fix nested loops in the VS. We were patching up all the break and continues between the start of our loop and the end of our loop, even if they were breaks/continues for an inner loop. Avoiding patching already patched breaks/continues fixes piglit glsl-vs-loop-nested. (cherry picked from commit f6f547d87ea68f44c50a0b0231b7360ca94b2975) --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index a7c4b589727..a48804a660f 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1717,11 +1717,13 @@ void brw_vs_emit(struct brw_vs_compile *c ) /* patch all the BREAK/CONT instructions from last BEGINLOOP */ while (inst0 > loop_inst[loop_depth]) { inst0--; - if (inst0->header.opcode == BRW_OPCODE_BREAK) { + if (inst0->header.opcode == BRW_OPCODE_BREAK && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1); inst0->bits3.if_else.pop_count = 0; } - else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) { + else if (inst0->header.opcode == BRW_OPCODE_CONTINUE && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0); inst0->bits3.if_else.pop_count = 0; } From 42e0e8686688ff91e92fa4ac46c6dacb2d5f2140 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 11:56:14 -0800 Subject: [PATCH 098/483] i965: Unalias all GLSL source regs from the destination regs used. We were doing it ad-hoc before, as instructions with potential aliasing problems were identified. But thanks to swizzling basically anything can have aliasing, so just do it generally at source reg setup time. This is somewhat inefficient, because sometimes an operation doesn't need unaliasing protection if the swizzling is safe, but the unaliasing before didn't cover those cases either. Fixes piglit glsl-fs-loop. (cherry picked from commit 6b194dab6b4d9f12cdd54c699b23c0d3420a49c2) --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 138 +++++------------------- 1 file changed, 25 insertions(+), 113 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index a42e6bf7a58..e3e6f663390 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -614,112 +614,6 @@ static void invoke_subroutine( struct brw_wm_compile *c, } } -/* Workaround for using brw_wm_emit.c's emit functions, which expect - * destination regs to be uniquely written. Moves arguments out to - * temporaries as necessary for instructions which use their destination as - * a temporary. - */ -static void -unalias3(struct brw_wm_compile *c, - void (*func)(struct brw_compile *c, - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2), - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2) -{ - struct brw_compile *p = &c->func; - struct brw_reg tmp_arg0[4], tmp_arg1[4], tmp_arg2[4]; - int i, j; - int mark = mark_tmps(c); - - for (j = 0; j < 4; j++) { - tmp_arg0[j] = arg0[j]; - tmp_arg1[j] = arg1[j]; - tmp_arg2[j] = arg2[j]; - } - - for (i = 0; i < 4; i++) { - if (mask & (1<func; - struct brw_reg tmp_arg0[4], tmp_arg1[4]; - int i, j; - int mark = mark_tmps(c); - - for (j = 0; j < 4; j++) { - tmp_arg0[j] = arg0[j]; - tmp_arg1[j] = arg1[j]; - } - - for (i = 0; i < 4; i++) { - if (mask & (1<func; + int i, j; for (i = 0; i < 4; i++) { - if (mask & (1 << i)) + if (mask & (1 << i)) { regs[i] = get_src_reg(c, inst, index, i); + + /* Unalias destination registers from our sources. */ + if (regs[i].file == BRW_GENERAL_REGISTER_FILE) { + for (j = 0; j < 4; j++) { + if (memcmp(®s[i], &dst[j], sizeof(regs[0])) == 0) { + struct brw_reg tmp = alloc_tmp(c); + brw_MOV(p, tmp, regs[i]); + regs[i] = tmp; + break; + } + } + } + } } } @@ -1845,6 +1754,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) int dst_flags; struct brw_reg args[3][4], dst[4]; int j; + int mark = mark_tmps( c ); c->cur_inst = i; @@ -1866,7 +1776,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) } } for (j = 0; j < brw_wm_nr_args(inst->Opcode); j++) - get_argument_regs(c, inst, j, args[j], WRITEMASK_XYZW); + get_argument_regs(c, inst, j, dst, args[j], WRITEMASK_XYZW); dst_flags = inst->DstReg.WriteMask; if (inst->SaturateMode == SATURATE_ZERO_ONE) @@ -1920,8 +1830,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) emit_alu1(p, brw_RNDD, dst, dst_flags, args[0]); break; case OPCODE_LRP: - unalias3(c, emit_lrp, - dst, dst_flags, args[0], args[1], args[2]); + emit_lrp(p, dst, dst_flags, args[0], args[1], args[2]); break; case OPCODE_TRUNC: emit_alu1(p, brw_RNDZ, dst, dst_flags, args[0]); @@ -1964,10 +1873,10 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) emit_cmp(p, dst, dst_flags, args[0], args[1], args[2]); break; case OPCODE_MIN: - unalias2(c, emit_min, dst, dst_flags, args[0], args[1]); + emit_min(p, dst, dst_flags, args[0], args[1]); break; case OPCODE_MAX: - unalias2(c, emit_max, dst, dst_flags, args[0], args[1]); + emit_max(p, dst, dst_flags, args[0], args[1]); break; case OPCODE_DDX: case OPCODE_DDY: @@ -2122,6 +2031,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) inst->Opcode); } + /* Release temporaries containing any unaliased source regs. */ + release_tmps( c, mark ); + if (inst->CondUpdate) brw_set_predicate_control(p, BRW_PREDICATE_NORMAL); else From a29c7948d965ad274ae7ac98fe01f2f877b19d94 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 14:22:51 -0800 Subject: [PATCH 099/483] i965: Fix ENDLOOP to only patch up this loop's BREAK and CONT. Corresponds to d225a25e21a24508aea3b877c78beb35502e942d and fixes piglit glsl-fs-loop-nested. Bug #25173. (cherry picked from commit a81836ee2fe5092d695b717addf8cec91f569777) --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index e3e6f663390..315b030484f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2015,11 +2015,13 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) /* patch all the BREAK/CONT instructions from last BGNLOOP */ while (inst0 > loop_inst[loop_depth]) { inst0--; - if (inst0->header.opcode == BRW_OPCODE_BREAK) { + if (inst0->header.opcode == BRW_OPCODE_BREAK && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1); inst0->bits3.if_else.pop_count = 0; } - else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) { + else if (inst0->header.opcode == BRW_OPCODE_CONTINUE && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0); inst0->bits3.if_else.pop_count = 0; } From 7c457108596ba6b95a17b8353a117fccbac486fc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 13:31:42 -0600 Subject: [PATCH 100/483] gallium: add target-helpers/wrap_screen.c to C_SOURCES Was commented out before. --- src/gallium/auxiliary/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index e2796d5bd38..e1c3bc43a24 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -127,14 +127,15 @@ C_SOURCES = \ util/u_tile.c \ util/u_timed_winsys.c \ util/u_upload_mgr.c \ - util/u_simple_screen.c + util/u_simple_screen.c \ + target-helpers/wrap_screen.c + # Disabling until pipe-video branch gets merged in #vl/vl_bitstream_parser.c \ #vl/vl_mpeg12_mc_renderer.c \ #vl/vl_compositor.c \ #vl/vl_csc.c \ #vl/vl_shader_build.c \ - target-helpers/wrap_screen.c GALLIVM_SOURCES = \ gallivm/lp_bld_alpha.c \ From 541c9c08e575ea93768c2e2cb889d9b236caf40f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 12 Mar 2010 17:09:51 -0800 Subject: [PATCH 101/483] meta: Properly refcount our saved programs and texobjs. Found while debugging bug #24119. --- src/mesa/drivers/common/meta.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index b97b760f181..b29f58db729 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -429,13 +429,15 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) if (state & META_SHADER) { if (ctx->Extensions.ARB_vertex_program) { save->VertexProgramEnabled = ctx->VertexProgram.Enabled; - save->VertexProgram = ctx->VertexProgram.Current; + _mesa_reference_vertprog(ctx, &save->VertexProgram, + ctx->VertexProgram.Current); _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); } if (ctx->Extensions.ARB_fragment_program) { save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; - save->FragmentProgram = ctx->FragmentProgram.Current; + _mesa_reference_fragprog(ctx, &save->FragmentProgram, + ctx->FragmentProgram.Current); _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE); } @@ -663,6 +665,7 @@ _mesa_meta_end(GLcontext *ctx) save->VertexProgramEnabled); _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, save->VertexProgram); + _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); } if (ctx->Extensions.ARB_fragment_program) { @@ -670,6 +673,7 @@ _mesa_meta_end(GLcontext *ctx) save->FragmentProgramEnabled); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, save->FragmentProgram); + _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); } if (ctx->Extensions.ARB_shader_objects) { @@ -720,6 +724,7 @@ _mesa_meta_end(GLcontext *ctx) for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt], save->CurrentTexture[tgt]); + _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); } /* Re-enable textures, texgen */ From 7cbb7051f42c0220b35ce1e834853dac8706a69a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 12 Mar 2010 17:12:14 -0800 Subject: [PATCH 102/483] meta: Fix up restoration of state if _mesa_map_pbo_source() fails. --- src/mesa/drivers/common/meta.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index b29f58db729..84a2a5fcb3a 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2067,8 +2067,10 @@ _mesa_meta_Bitmap(GLcontext *ctx, } bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1); - if (!bitmap1) + if (!bitmap1) { + _mesa_meta_end(ctx); return; + } bitmap8 = (GLubyte *) calloc(1, width * height); if (bitmap8) { From ba208604ea8bc069be583732a4c59a47e4a7b280 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 11:22:29 -0700 Subject: [PATCH 103/483] Revert "i965: Do FS SLT, SGT, and friends using CMP, SEL instead of CMP, MOV, MOV." This reverts commit 46450c1f3f93bf4dc96696fc7e0f0eb808d9c08a. I was wrong about null reg behavior -- it reads undefined, not 0. And they're not kidding. --- src/mesa/drivers/dri/i965/brw_wm_emit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 05e464d4b61..1869fd06d5a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -545,8 +545,11 @@ void emit_sop(struct brw_compile *p, for (i = 0; i < 4; i++) { if (mask & (1< Date: Tue, 16 Mar 2010 11:23:08 -0700 Subject: [PATCH 104/483] Revert "i965: Do VS SGT, SLT, and friends using CMP, SEL instead of CMP, MOV, MOV." This reverts commit 8ef3b1834a896927bdd4f2aea552cdb732849da9. Fixes piglit glsl-vs-if. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index d16e916832e..14c3b936b7e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -384,8 +384,9 @@ static void emit_sop( struct brw_vs_compile *c, { struct brw_compile *p = &c->func; - brw_CMP(p, brw_null_reg(), cond, arg1, arg0); - brw_SEL(p, dst, brw_null_reg(), brw_imm_f(1.0f)); + brw_MOV(p, dst, brw_imm_f(0.0f)); + brw_CMP(p, brw_null_reg(), cond, arg0, arg1); + brw_MOV(p, dst, brw_imm_f(1.0f)); brw_set_predicate_control_flag_value(p, 0xff); } From 800a4b202f8b23540dbb128e780ca8b7e90d1f46 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 12:59:59 -0700 Subject: [PATCH 105/483] intel: Remove more code for x8z24 visuals, since we only do s8z24. --- src/mesa/drivers/dri/intel/intel_screen.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 6e4bb643651..5e3f40836d0 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -312,18 +312,13 @@ intelCreateBuffer(__DRIscreen * driScrnPriv, } if (mesaVis->depthBits == 24) { - if (mesaVis->stencilBits == 8) { - /* combined depth/stencil buffer */ - struct intel_renderbuffer *depthStencilRb - = intel_create_renderbuffer(MESA_FORMAT_S8_Z24); - /* note: bind RB to two attachment points */ - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base); - } else { - struct intel_renderbuffer *depthRb - = intel_create_renderbuffer(MESA_FORMAT_X8_Z24); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } + assert(mesaVis->stencilBits == 8); + /* combined depth/stencil buffer */ + struct intel_renderbuffer *depthStencilRb + = intel_create_renderbuffer(MESA_FORMAT_S8_Z24); + /* note: bind RB to two attachment points */ + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base); } else if (mesaVis->depthBits == 16) { /* just 16-bit depth buffer, no hw stencil */ From a589da14dee0c2a32e6e529f1a390b01a3ee4001 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 13:14:38 -0700 Subject: [PATCH 106/483] i965: Fix inversion for glCopyPixels to/from FBOs. fixes piglit fbo-copypix. --- .../drivers/dri/intel/intel_mipmap_tree.c | 3 ++- src/mesa/drivers/dri/intel/intel_pixel_copy.c | 21 +++++++++---------- src/mesa/drivers/dri/intel/intel_regions.c | 8 ++++++- src/mesa/drivers/dri/intel/intel_regions.h | 1 + 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 4f14946ec72..da17809f16c 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -525,7 +525,8 @@ intel_miptree_image_copy(struct intel_context *intel, intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); success = intel_region_copy(intel, dst->region, 0, dst_x, dst_y, - src->region, 0, src_x, src_y, width, height, + src->region, 0, src_x, src_y, + width, height, GL_FALSE, GL_COPY); if (!success) { GLubyte *src_ptr, *dst_ptr; diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index f4f3fd6d889..8efb7a60c26 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -116,6 +116,7 @@ do_blit_copypixels(GLcontext * ctx, GLint orig_dsty; GLint orig_srcx; GLint orig_srcy; + GLboolean flip = GL_FALSE; if (type == GL_DEPTH || type == GL_STENCIL) { if (INTEL_DEBUG & DEBUG_FALLBACKS) @@ -140,8 +141,6 @@ do_blit_copypixels(GLcontext * ctx, intel_prepare_render(intel); - /* XXX: We fail to handle different inversion between read and draw framebuffer. */ - /* Clip to destination buffer. */ orig_dstx = dstx; orig_dsty = dsty; @@ -164,23 +163,23 @@ do_blit_copypixels(GLcontext * ctx, dstx += srcx - orig_srcx; dsty += srcy - orig_srcy; - /* Convert from GL to hardware coordinates: */ + /* Flip dest Y if it's a window system framebuffer. */ if (fb->Name == 0) { - /* copypixels to a system framebuffer */ + /* copypixels to a window system framebuffer */ dsty = fb->Height - dsty - height; - } else { - /* copypixels to a user framebuffer object */ - dsty = dsty; + flip = !flip; } - /* Flip source Y if it's a system framebuffer. */ - if (read_fb->Name == 0) - srcy = fb->Height - srcy - height; + /* Flip source Y if it's a window system framebuffer. */ + if (read_fb->Name == 0) { + srcy = read_fb->Height - srcy - height; + flip = !flip; + } if (!intel_region_copy(intel, dst, 0, dstx, dsty, src, 0, srcx, srcy, - width, height, + width, height, flip, ctx->Color.ColorLogicOpEnabled ? ctx->Color.LogicOp : GL_COPY)) { DBG("%s: blit failure\n", __FUNCTION__); diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index f042bcbc28c..f8107bd0615 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -380,8 +380,11 @@ intel_region_copy(struct intel_context *intel, struct intel_region *src, GLuint src_offset, GLuint srcx, GLuint srcy, GLuint width, GLuint height, + GLboolean flip, GLenum logicop) { + uint32_t src_pitch = src->pitch; + _DBG("%s\n", __FUNCTION__); if (intel == NULL) @@ -397,9 +400,12 @@ intel_region_copy(struct intel_context *intel, assert(src->cpp == dst->cpp); + if (flip) + src_pitch = -src_pitch; + return intelEmitCopyBlit(intel, dst->cpp, - src->pitch, src->buffer, src_offset, src->tiling, + src_pitch, src->buffer, src_offset, src->tiling, dst->pitch, dst->buffer, dst_offset, dst->tiling, srcx, srcy, dstx, dsty, width, height, logicop); diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index 7ee6a988eae..8f32449f345 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -122,6 +122,7 @@ intel_region_copy(struct intel_context *intel, struct intel_region *src, GLuint src_offset, GLuint srcx, GLuint srcy, GLuint width, GLuint height, + GLboolean flip, GLenum logicop); /* Helpers for zerocopy uploads, particularly texture image uploads: From 5782b2a968bb979b651e49bb5fc4162faa842050 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 13:23:23 -0700 Subject: [PATCH 107/483] i965: Fix readpixels from ReadBuffer != DrawBuffer. Fixes piglit fbo-readdrawpix. --- src/mesa/drivers/dri/intel/intel_span.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index fb5c01bc4dc..377f3a8627e 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -48,11 +48,11 @@ intel_set_span_functions(struct intel_context *intel, #define LOCAL_VARS \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ - const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ - const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ + const GLint yScale = rb->Name ? 1 : -1; \ + const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ int minx = 0, miny = 0; \ - int maxx = ctx->DrawBuffer->Width; \ - int maxy = ctx->DrawBuffer->Height; \ + int maxx = rb->Width; \ + int maxy = rb->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ GLuint p; \ @@ -108,11 +108,11 @@ intel_set_span_functions(struct intel_context *intel, #define LOCAL_DEPTH_VARS \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ - const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ - const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ + const GLint yScale = rb->Name ? 1 : -1; \ + const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ int minx = 0, miny = 0; \ - int maxx = ctx->DrawBuffer->Width; \ - int maxy = ctx->DrawBuffer->Height; \ + int maxx = rb->Width; \ + int maxy = rb->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ (void)buf; (void)pitch; /* unused for non-gttmap. */ \ From e548babb1fc9230054674deb5e332f55319e5b91 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 16 Mar 2010 22:32:42 +0100 Subject: [PATCH 108/483] nv50: support more formats in surface_copy,fill Fixes corrupted fonts in bzFlag, where we've been silently failing to copy I8 mipmaps to a new miptree. Print an error message on unsupported format now, since we can't return failure. --- src/gallium/drivers/nv50/nv50_surface.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index cabd148bc5b..6467c48a32a 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_tile.h" +#include "util/u_format.h" static INLINE int nv50_format(enum pipe_format format) @@ -37,10 +38,35 @@ nv50_format(enum pipe_format format) return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; case PIPE_FORMAT_B8G8R8X8_UNORM: return NV50_2D_DST_FORMAT_X8R8G8B8_UNORM; + case PIPE_FORMAT_B8G8R8A8_SRGB: + return NV50_2D_DST_FORMAT_A8R8G8B8_SRGB; + case PIPE_FORMAT_B8G8R8X8_SRGB: + return NV50_2D_DST_FORMAT_X8R8G8B8_SRGB; case PIPE_FORMAT_B5G6R5_UNORM: return NV50_2D_DST_FORMAT_R5G6B5_UNORM; + case PIPE_FORMAT_B5G5R5A1_UNORM: + return NV50_2D_DST_FORMAT_A1R5G5B5_UNORM; case PIPE_FORMAT_A8_UNORM: + case PIPE_FORMAT_I8_UNORM: + case PIPE_FORMAT_L8_UNORM: return NV50_2D_DST_FORMAT_R8_UNORM; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + return NV50_2D_DST_FORMAT_R32G32B32A32_FLOAT; + case PIPE_FORMAT_R32G32B32_FLOAT: + return NV50_2D_DST_FORMAT_R32G32B32X32_FLOAT; + case PIPE_FORMAT_Z32_FLOAT: + return NV50_2D_DST_FORMAT_R32_FLOAT; + + /* only because we require src format == dst format: */ + case PIPE_FORMAT_R16G16_SNORM: + case PIPE_FORMAT_R16G16_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; + case PIPE_FORMAT_L8A8_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + return NV50_2D_DST_FORMAT_R16_UNORM; + default: return -1; } @@ -57,8 +83,11 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); format = nv50_format(ps->format); - if (format < 0) + if (format < 0) { + NOUVEAU_ERR("invalid/unsupported surface format: %s\n", + util_format_name(ps->format)); return 1; + } if (!bo->tile_flags) { MARK_RING (chan, 9, 2); /* flush on lack of space or relocs */ From a9a1b52f959f325affe89a093b05e9b0f100018c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 16:45:36 -0600 Subject: [PATCH 109/483] cell: add missing semicolon --- src/gallium/drivers/cell/ppu/cell_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 4d87f9a038a..f7e2284445d 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -97,7 +97,7 @@ struct cell_velems_state { unsigned count; struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; -} +}; /** * Per-context state, subclass of pipe_context. From e1ee3eaf6d739ddaa31bad1316e000c6220fa707 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 16:45:54 -0600 Subject: [PATCH 110/483] cell: build identity driver too --- configs/linux-cell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/linux-cell b/configs/linux-cell index 306b9e01f47..0908dba9e05 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -6,7 +6,7 @@ CONFIG_NAME = linux-cell # Omiting other gallium drivers: -GALLIUM_DRIVERS_DIRS = cell softpipe trace +GALLIUM_DRIVERS_DIRS = cell softpipe trace identity # Compiler and flags From 90fe8c39f18512d22cdf52cbaa3e86a94a831ee2 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 17 Mar 2010 04:35:14 -0700 Subject: [PATCH 111/483] st/mesa: Fix build breakage. Nearly certain this is what was intended; it compiles, but I'm not sure this path is ever hit in my tests. --- src/mesa/state_tracker/st_cb_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 84b78181a97..3fe01c4721b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -900,7 +900,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - screen->tex_transfer_destroy(tex_xfer); + pipe->tex_transfer_destroy(pipe, tex_xfer); /* destroy the temp / dest surface */ util_destroy_rgba_surface(dst_texture, dst_surface); From 3828910d0e51cd5fb7d4ebcde8bfc98a84b57b06 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 08:41:47 -0600 Subject: [PATCH 112/483] swrast: remove unused compute_coveragei() function --- src/mesa/swrast/s_aatriangle.c | 82 ---------------------------------- 1 file changed, 82 deletions(-) diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index fe3338ecef8..1d90f322a3a 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -268,88 +268,6 @@ compute_coveragef(const GLfloat v0[3], const GLfloat v1[3], -/* - * Compute how much (area) of the given pixel is inside the triangle. - * Vertices MUST be specified in counter-clockwise order. - * Return: coverage in [0, 15]. - */ -static GLint -compute_coveragei(const GLfloat v0[3], const GLfloat v1[3], - const GLfloat v2[3], GLint winx, GLint winy) -{ - /* NOTE: 15 samples instead of 16. */ - static const GLfloat samples[15][2] = { - /* start with the four corners */ - { POS(0, 2), POS(0, 0) }, - { POS(3, 3), POS(0, 2) }, - { POS(0, 0), POS(3, 1) }, - { POS(3, 1), POS(3, 3) }, - /* continue with interior samples */ - { POS(1, 1), POS(0, 1) }, - { POS(2, 0), POS(0, 3) }, - { POS(0, 3), POS(1, 3) }, - { POS(1, 2), POS(1, 0) }, - { POS(2, 3), POS(1, 2) }, - { POS(3, 2), POS(1, 1) }, - { POS(0, 1), POS(2, 2) }, - { POS(1, 0), POS(2, 1) }, - { POS(2, 1), POS(2, 3) }, - { POS(3, 0), POS(2, 0) }, - { POS(1, 3), POS(3, 0) } - }; - const GLfloat x = (GLfloat) winx; - const GLfloat y = (GLfloat) winy; - const GLfloat dx0 = v1[0] - v0[0]; - const GLfloat dy0 = v1[1] - v0[1]; - const GLfloat dx1 = v2[0] - v1[0]; - const GLfloat dy1 = v2[1] - v1[1]; - const GLfloat dx2 = v0[0] - v2[0]; - const GLfloat dy2 = v0[1] - v2[1]; - GLint stop = 4, i; - GLint insideCount = 15; - -#ifdef DEBUG - { - const GLfloat area = dx0 * dy1 - dx1 * dy0; - ASSERT(area >= 0.0); - } -#endif - - for (i = 0; i < stop; i++) { - const GLfloat sx = x + samples[i][0]; - const GLfloat sy = y + samples[i][1]; - const GLfloat fx0 = sx - v0[0]; - const GLfloat fy0 = sy - v0[1]; - const GLfloat fx1 = sx - v1[0]; - const GLfloat fy1 = sy - v1[1]; - const GLfloat fx2 = sx - v2[0]; - const GLfloat fy2 = sy - v2[1]; - /* cross product determines if sample is inside or outside each edge */ - GLfloat cross0 = (dx0 * fy0 - dy0 * fx0); - GLfloat cross1 = (dx1 * fy1 - dy1 * fx1); - GLfloat cross2 = (dx2 * fy2 - dy2 * fx2); - /* Check if the sample is exactly on an edge. If so, let cross be a - * positive or negative value depending on the direction of the edge. - */ - if (cross0 == 0.0F) - cross0 = dx0 + dy0; - if (cross1 == 0.0F) - cross1 = dx1 + dy1; - if (cross2 == 0.0F) - cross2 = dx2 + dy2; - if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F) { - /* point is outside triangle */ - insideCount--; - stop = 15; - } - } - if (stop == 4) - return 15; - else - return insideCount; -} - - static void rgba_aa_tri(GLcontext *ctx, const SWvertex *v0, From 59e743b8d393f2bdf023e3a5ad8fe848a7459ec9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 08:44:09 -0600 Subject: [PATCH 113/483] glapi: fix assorted warnings And replace some instances of GLuint with unsigned int to avoid pulling in GL/gl.h --- src/mesa/glapi/glapi_entrypoint.c | 6 +++--- src/mesa/glapi/glapi_execmem.c | 1 + src/mesa/glapi/glapi_priv.h | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mesa/glapi/glapi_entrypoint.c index c4f43f66a18..239780e7539 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mesa/glapi/glapi_entrypoint.c @@ -56,7 +56,7 @@ extern const GLubyte gl_dispatch_functions_start[]; #if defined(DISPATCH_FUNCTION_SIZE) _glapi_proc -get_entrypoint_address(GLuint functionOffset) +get_entrypoint_address(unsigned int functionOffset) { return (_glapi_proc) (gl_dispatch_functions_start + (DISPATCH_FUNCTION_SIZE * functionOffset)); @@ -97,7 +97,7 @@ init_glapi_relocs( void ) * We need assembly language in order to accomplish this. */ _glapi_proc -generate_entrypoint(GLuint functionOffset) +generate_entrypoint(unsigned int functionOffset) { /* 32 is chosen as something of a magic offset. For x86, the dispatch * at offset 32 is the first one where the offset in the @@ -122,7 +122,7 @@ generate_entrypoint(GLuint functionOffset) * stub that was generated with the preceeding function. */ void -fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) +fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset) { GLubyte * const code = (GLubyte *) entrypoint; diff --git a/src/mesa/glapi/glapi_execmem.c b/src/mesa/glapi/glapi_execmem.c index 6a1fac597f3..57f00be8dcc 100644 --- a/src/mesa/glapi/glapi_execmem.c +++ b/src/mesa/glapi/glapi_execmem.c @@ -40,6 +40,7 @@ #endif #include "glapi/glthread.h" +#include "glapi/glapi_priv.h" #if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) diff --git a/src/mesa/glapi/glapi_priv.h b/src/mesa/glapi/glapi_priv.h index 0e2de460f2e..da6fee63fe7 100644 --- a/src/mesa/glapi/glapi_priv.h +++ b/src/mesa/glapi/glapi_priv.h @@ -27,6 +27,8 @@ #define _GLAPI_PRIV_H #include "glthread.h" +#include "glapi.h" + /* getproc */ @@ -42,7 +44,7 @@ _glapi_check_table(const struct _glapi_table *table); /* execmem */ extern void * -_glapi_exec_malloc(GLuint size); +_glapi_exec_malloc(unsigned int size); /* entrypoint */ @@ -52,15 +54,15 @@ init_glapi_relocs_once(void); extern _glapi_proc -generate_entrypoint(GLuint functionOffset); +generate_entrypoint(unsigned int functionOffset); extern void -fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset); +fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset); extern _glapi_proc -get_entrypoint_address(GLuint functionOffset); +get_entrypoint_address(unsigned int functionOffset); /** From c4922276831528ad2b25acf816ef3f3dfe3211b7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 09:04:26 -0600 Subject: [PATCH 114/483] mesa: rename params in prototype to match implementation --- src/mesa/main/image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 72717d67873..9b34be0dfaa 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -303,7 +303,7 @@ _mesa_clip_drawpixels(const GLcontext *ctx, extern GLboolean _mesa_clip_readpixels(const GLcontext *ctx, - GLint *destX, GLint *destY, + GLint *srcX, GLint *srcY, GLsizei *width, GLsizei *height, struct gl_pixelstore_attrib *pack); From 1bfc314596256b039df59f751d59dac82e3ceba1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 10:06:27 -0600 Subject: [PATCH 115/483] st/mesa: fix glCopyPixels bugs/crashes when src region need clipping Use the _mesa_clip_readpixels() function to clip the src region against the buffer's bounds. Neatly, the resulting pixel unpack object's SkipPixels/SkipRows fields can be used to determine the position of the region in the destination texture. Fixes crash in progs/samples/copy.c and probably other cases. --- src/mesa/state_tracker/st_cb_drawpixels.c | 90 +++++++++-------------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 43dc8d1b836..7c611cb4ec9 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -938,39 +938,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, enum pipe_format srcFormat, texFormat; int ptw, pth; GLboolean invertTex = GL_FALSE; + GLint readX, readY, readW, readH; + struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); st_validate_state(st); - if (srcx < 0) { - width -= -srcx; - dstx += -srcx; - srcx = 0; - } - - if (srcy < 0) { - height -= -srcy; - dsty += -srcy; - srcy = 0; - } - - if (dstx < 0) { - width -= -dstx; - srcx += -dstx; - dstx = 0; - } - - if (dsty < 0) { - height -= -dsty; - srcy += -dsty; - dsty = 0; - } - - if (width < 0 || height < 0) - return; - - if (type == GL_STENCIL) { /* can't use texturing to do stencil */ copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty); @@ -1003,7 +977,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL); - assert(texFormat != PIPE_FORMAT_NONE); /* XXX no depth texture formats??? */ + assert(texFormat != PIPE_FORMAT_NONE); } else { /* default color format */ @@ -1013,20 +987,26 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, } } + /* Invert src region if needed */ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { srcy = ctx->ReadBuffer->Height - srcy - height; - - if (srcy < 0) { - height -= -srcy; - srcy = 0; - } - - if (height < 0) - return; - invertTex = !invertTex; } + /* Clip the read region against the src buffer bounds. + * We'll still allocate a temporary buffer/texture for the original + * src region size but we'll only read the region which is on-screen. + * This may mean that we draw garbage pixels into the dest region, but + * that's expected. + */ + readX = srcx; + readY = srcy; + readW = width; + readH = height; + _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &unpack); + readW = MAX2(0, readW); + readH = MAX2(0, readH); + /* Need to use POT texture? */ ptw = width; pth = height; @@ -1055,7 +1035,6 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, return; /* Make temporary texture which is a copy of the src region. - * We'll draw a quad with this texture to draw the dest image. */ if (srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ @@ -1066,16 +1045,16 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, PIPE_BUFFER_USAGE_GPU_WRITE ); if (pipe->surface_copy) { pipe->surface_copy(pipe, - psTex, /* dest */ - 0, 0, /* destx/y */ - psRead, - srcx, srcy, width, height); + psTex, /* dest surf */ + unpack.SkipPixels, unpack.SkipRows, /* dest pos */ + psRead, /* src surf */ + readX, readY, readW, readH); /* src region */ } else { util_surface_copy(pipe, FALSE, psTex, - 0, 0, + unpack.SkipPixels, unpack.SkipRows, psRead, - srcx, srcy, width, height); + readX, readY, readW, readH); } if (0) { @@ -1091,8 +1070,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* CPU-based fallback/conversion */ struct pipe_transfer *ptRead = st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0, - PIPE_TRANSFER_READ, srcx, srcy, width, - height); + PIPE_TRANSFER_READ, + readX, readY, readW, readH); struct pipe_transfer *ptTex; enum pipe_transfer_usage transfer_usage; @@ -1107,20 +1086,21 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, ptTex = st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, transfer_usage, 0, 0, width, height); + /* copy image from ptRead surface to ptTex surface */ if (type == GL_COLOR) { /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf); - pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf); - + pipe_get_tile_rgba(ptRead, readX, readY, readW, readH, buf); + pipe_put_tile_rgba(ptTex, unpack.SkipPixels, unpack.SkipRows, + readW, readH, buf); free(buf); } else { /* GL_DEPTH */ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); - pipe_get_tile_z(ptRead, 0, 0, width, height, buf); - pipe_put_tile_z(ptTex, 0, 0, width, height, buf); + pipe_get_tile_z(ptRead, readX, readY, readW, readH, buf); + pipe_put_tile_z(ptTex, unpack.SkipPixels, unpack.SkipRows, + readW, readH, buf); free(buf); } @@ -1128,7 +1108,9 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, screen->tex_transfer_destroy(ptTex); } - /* draw textured quad */ + /* OK, the texture 'pt' contains the src image/pixels. Now draw a + * textured quad with that texture. + */ draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2], width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, pt, From bf1974b37d6b92448b068dda8f8f4e9aab4dc537 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 10:11:09 -0600 Subject: [PATCH 116/483] progs/samples: silence warnings --- progs/samples/loadppm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/progs/samples/loadppm.c b/progs/samples/loadppm.c index be056d62940..adae9b491e4 100644 --- a/progs/samples/loadppm.c +++ b/progs/samples/loadppm.c @@ -9,7 +9,7 @@ static PPMImage *LoadPPM(const char *filename) char buff[16]; PPMImage *result; FILE *fp; - int maxval; + int maxval, w, h; fp = fopen(filename, "rb"); if (!fp) @@ -37,11 +37,13 @@ static PPMImage *LoadPPM(const char *filename) exit(1); } - if (fscanf(fp, "%lu %lu", &result->sizeX, &result->sizeY) != 2) + if (fscanf(fp, "%d %d", &w, &h) != 2) { fprintf(stderr, "Error loading image `%s'\n", filename); exit(1); } + result->sizeX = w; + result->sizeY = h; if (fscanf(fp, "%d", &maxval) != 1) { From a196a5d3303a49c5f79a283f91f8e0cc8aa87f69 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 10:17:04 -0600 Subject: [PATCH 117/483] progs/samples: improve copy.c demo If the test image was larger than the window, nothing was drawn because of invalid raster position. Use glWindowPos instead of glRasterPos. Also, use integer src/dst coordinates to avoid grabbing black pixels outside of the src image region. --- progs/samples/copy.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/progs/samples/copy.c b/progs/samples/copy.c index 391c637d6fa..353a3a2e1a2 100644 --- a/progs/samples/copy.c +++ b/progs/samples/copy.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -35,7 +36,6 @@ GLint windW, windH; char *fileName = 0; PPMImage *image; -float point[3]; float zoom; GLint x, y; @@ -97,27 +97,27 @@ static void Mouse(int button, int state, int mouseX, int mouseY) static void Draw(void) { + GLint src[3], dst[3]; glClear(GL_COLOR_BUFFER_BIT); - point[0] = (windW / 2) - (image->sizeX / 2); - point[1] = (windH / 2) - (image->sizeY / 2); - point[2] = 0; - glRasterPos3fv(point); + src[0] = (int) ((windW / 2.0) - (image->sizeX / 2.0)); + src[1] = (int) ((windH / 2.0) - (image->sizeY / 2.0)); + src[2] = 0; + glWindowPos3ivARB(src); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelZoom(1.0, 1.0); glDrawPixels(image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, image->data); - point[0] = (float)x; - point[1] = windH - (float)y; - point[2] = 0.0; - glRasterPos3fv(point); + dst[0] = x; + dst[1] = windH - y; + dst[2] = 0; + glWindowPos3ivARB(dst); glPixelZoom(zoom, zoom); - glCopyPixels((windW/2)-(image->sizeX/2), - (windH/2)-(image->sizeY/2), + glCopyPixels(src[0], src[1], image->sizeX, image->sizeY, GL_COLOR); glFlush(); @@ -170,8 +170,8 @@ int main(int argc, char **argv) image = LoadPPM(fileName); - windW = 300; - windH = 300; + windW = 2*300; + windH = 2*300; glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); type = GLUT_RGB; @@ -182,6 +182,7 @@ int main(int argc, char **argv) exit(1); } + glewInit(); Init(); glutReshapeFunc(Reshape); From c11d582411a999ed40db4c02143dd380113e0ffd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 10:31:57 -0600 Subject: [PATCH 118/483] st/mesa: plug in default for pipe_context::surface_copy() if needed This lets us avoid conditionals and duplicated code in several places. --- src/mesa/state_tracker/st_atom_framebuffer.c | 16 ++++----------- src/mesa/state_tracker/st_cb_drawpixels.c | 19 +++++------------- src/mesa/state_tracker/st_cb_fbo.c | 16 ++++----------- src/mesa/state_tracker/st_cb_texture.c | 3 +-- src/mesa/state_tracker/st_context.c | 18 +++++++++++++++++ src/mesa/state_tracker/st_texture.c | 21 ++++++-------------- 6 files changed, 38 insertions(+), 55 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index fba7bfe2cea..79ad70909a9 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -38,7 +38,6 @@ #include "st_texture.h" #include "pipe/p_context.h" #include "cso_cache/cso_context.h" -#include "util/u_rect.h" #include "util/u_math.h" #include "util/u_inlines.h" @@ -164,17 +163,10 @@ update_framebuffer_state( struct st_context *st ) (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front); (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back); - if (st->pipe->surface_copy) { - st->pipe->surface_copy(st->pipe, - surf_front, 0, 0, /* dest */ - surf_back, 0, 0, /* src */ - fb->Width, fb->Height); - } else { - util_surface_copy(st->pipe, FALSE, - surf_front, 0, 0, - surf_back, 0, 0, - fb->Width, fb->Height); - } + st->pipe->surface_copy(st->pipe, + surf_front, 0, 0, /* dest */ + surf_back, 0, 0, /* src */ + fb->Width, fb->Height); } /* we're assuming we'll really draw to the front buffer */ st->frontbuffer_status = FRONT_STATUS_DIRTY; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 72a2ddb379b..07529ab6af7 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -59,7 +59,6 @@ #include "util/u_draw_quad.h" #include "util/u_format.h" #include "util/u_math.h" -#include "util/u_rect.h" #include "shader/prog_instruction.h" #include "cso_cache/cso_context.h" @@ -1057,19 +1056,11 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, PIPE_BUFFER_USAGE_GPU_READ); struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); - if (pipe->surface_copy) { - pipe->surface_copy(pipe, - psTex, /* dest surf */ - unpack.SkipPixels, unpack.SkipRows, /* dest pos */ - psRead, /* src surf */ - readX, readY, readW, readH); /* src region */ - } else { - util_surface_copy(pipe, FALSE, - psTex, - unpack.SkipPixels, unpack.SkipRows, - psRead, - readX, readY, readW, readH); - } + pipe->surface_copy(pipe, + psTex, /* dest surf */ + unpack.SkipPixels, unpack.SkipRows, /* dest pos */ + psRead, /* src surf */ + readX, readY, readW, readH); /* src region */ if (0) { /* debug */ diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 4ccba1db85d..84c2474038d 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -51,7 +51,6 @@ #include "st_manager.h" #include "util/u_format.h" -#include "util/u_rect.h" #include "util/u_inlines.h" @@ -518,17 +517,10 @@ copy_back_to_front(struct st_context *st, (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back); if (surf_front && surf_back) { - if (st->pipe->surface_copy) { - st->pipe->surface_copy(st->pipe, - surf_front, 0, 0, /* dest */ - surf_back, 0, 0, /* src */ - fb->Width, fb->Height); - } else { - util_surface_copy(st->pipe, FALSE, - surf_front, 0, 0, - surf_back, 0, 0, - fb->Width, fb->Height); - } + st->pipe->surface_copy(st->pipe, + surf_front, 0, 0, /* dest */ + surf_back, 0, 0, /* src */ + fb->Width, fb->Height); } } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 3fe01c4721b..d7a774aa409 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1560,8 +1560,7 @@ st_copy_texsubimage(GLcontext *ctx, if (ctx->_ImageTransferState == 0x0) { - if (pipe->surface_copy && - matching_base_formats && + if (matching_base_formats && src_format == dest_format && !do_flip) { diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0885ad77c7c..72f5a9c1e0b 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -63,6 +63,7 @@ #include "st_program.h" #include "pipe/p_context.h" #include "util/u_inlines.h" +#include "util/u_rect.h" #include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -97,6 +98,19 @@ st_get_msaa(void) } +/** Default method for pipe_context::surface_copy() */ +static void +st_surface_copy(struct pipe_context *pipe, + struct pipe_surface *dst, + unsigned dst_x, unsigned dst_y, + struct pipe_surface *src, + unsigned src_x, unsigned src_y, + unsigned w, unsigned h) +{ + util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h); +} + + static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { @@ -166,6 +180,10 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st_init_limits(st); st_init_extensions(st); + /* plug in helper driver functions if needed */ + if (!pipe->surface_copy) + pipe->surface_copy = st_surface_copy; + return st; } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index ef97d873e50..5809927852d 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -342,21 +342,12 @@ st_texture_image_copy(struct pipe_context *pipe, src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, PIPE_BUFFER_USAGE_GPU_READ); - if (pipe->surface_copy) { - pipe->surface_copy(pipe, - dst_surface, - 0, 0, /* destX, Y */ - src_surface, - 0, 0, /* srcX, Y */ - width, height); - } else { - util_surface_copy(pipe, FALSE, - dst_surface, - 0, 0, /* destX, Y */ - src_surface, - 0, 0, /* srcX, Y */ - width, height); - } + pipe->surface_copy(pipe, + dst_surface, + 0, 0, /* destX, Y */ + src_surface, + 0, 0, /* srcX, Y */ + width, height); pipe_surface_reference(&src_surface, NULL); pipe_surface_reference(&dst_surface, NULL); From b22bb34533050bda0c207008a4933ccbbe69bf8e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 10:53:55 -0600 Subject: [PATCH 119/483] llvmpipe: remove -m32 flag from linux-llvm config --- configs/linux-llvm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/linux-llvm b/configs/linux-llvm index 27e082ebf7e..608f42d6df0 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -10,7 +10,7 @@ CONFIG_NAME = linux-llvm GALLIUM_DRIVERS_DIRS += llvmpipe OPT_FLAGS = -O3 -ansi -pedantic -ARCH_FLAGS = -m32 -mmmx -msse -msse2 -mstackrealign +ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86 From c479a20fced2f4162092e96491da3d310fed8648 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 14:02:22 -0700 Subject: [PATCH 120/483] intel: Rename the z24_x8 depth spans to z24_s8 since they do stencil too. --- src/mesa/drivers/dri/intel/intel_span.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 377f3a8627e..c1e15d1b0f2 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -134,7 +134,7 @@ intel_set_span_functions(struct intel_context *intel, (*(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y)) = d) #define READ_DEPTH(d, _x, _y) \ d = *(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y)) -#define TAG(x) intel_##x##_z24_x8 +#define TAG(x) intel_##x##_z24_s8 #include "depthtmp.h" void @@ -361,7 +361,7 @@ intel_set_span_functions(struct intel_context *intel, break; case MESA_FORMAT_X8_Z24: case MESA_FORMAT_S8_Z24: - intel_InitDepthPointers_z24_x8(rb); + intel_InitDepthPointers_z24_s8(rb); break; default: _mesa_problem(NULL, From 32f143b4327521a058dc05f0ab9087a5696b9618 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 16:05:53 -0700 Subject: [PATCH 121/483] intel: Remove extra tiling setting after allocating a tiled region. --- src/mesa/drivers/dri/intel/intel_regions.c | 11 +++-------- src/mesa/drivers/dri/intel/intel_regions.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index f8107bd0615..581e5ec6b38 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -164,7 +164,6 @@ intel_region_alloc_internal(struct intel_context *intel, /* Default to no tiling */ region->tiling = I915_TILING_NONE; - region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE; _DBG("%s <-- %p\n", __FUNCTION__, region); return region; @@ -194,12 +193,7 @@ intel_region_alloc(struct intel_context *intel, region = intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer); - - if (tiling != I915_TILING_NONE) { - assert(((pitch * cpp) & 127) == 0); - drm_intel_bo_set_tiling(buffer, &tiling, pitch * cpp); - drm_intel_bo_get_tiling(buffer, ®ion->tiling, ®ion->bit_6_swizzle); - } + region->tiling = tiling; return region; } @@ -213,6 +207,7 @@ intel_region_alloc_for_handle(struct intel_context *intel, struct intel_region *region, *dummy; dri_bo *buffer; int ret; + uint32_t bit_6_swizzle; region = _mesa_HashLookup(intel->intelScreen->named_regions, handle); if (region != NULL) { @@ -236,7 +231,7 @@ intel_region_alloc_for_handle(struct intel_context *intel, return region; ret = dri_bo_get_tiling(region->buffer, ®ion->tiling, - ®ion->bit_6_swizzle); + &bit_6_swizzle); if (ret != 0) { fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n", handle, name, strerror(-ret)); diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index 8f32449f345..c81ccde4dad 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -65,7 +65,6 @@ struct intel_region GLuint draw_x, draw_y; /**< Offset of drawing within the region */ uint32_t tiling; /**< Which tiling mode the region is in */ - uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */ struct intel_buffer_object *pbo; /* zero-copy uploads */ uint32_t name; /**< Global name for the bo */ From 0c51390e4b5e04b992e50fcbed751024e6c329de Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 16:11:05 -0700 Subject: [PATCH 122/483] intel: Remove level_offset now that it's unused. This is the last pitch-dependent part of miptree setup. --- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 5 ++--- src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 13 +++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index da17809f16c..ac9e135a01a 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -351,13 +351,12 @@ intel_miptree_set_level_info(struct intel_mipmap_tree *mt, mt->level[level].width = w; mt->level[level].height = h; mt->level[level].depth = d; - mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp; mt->level[level].level_x = x; mt->level[level].level_y = y; mt->level[level].nr_images = nr_images; - DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, - level, w, h, d, x, y, mt->level[level].level_offset); + DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__, + level, w, h, d, x, y); assert(nr_images); assert(!mt->level[level].x_offset); diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index b19c548def3..7f3468f1153 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h @@ -62,14 +62,6 @@ */ struct intel_mipmap_level { - /** - * Byte offset to the base of this level. - * - * This is used for mipmap levels of 1D/2D/3D textures. However, CUBE - * layouts spread images around the whole tree, so the level offset is - * always zero in that case. - */ - GLuint level_offset; /** Offset to this miptree level, used in computing x_offset. */ GLuint level_x; /** Offset to this miptree level, used in computing y_offset. */ @@ -81,8 +73,8 @@ struct intel_mipmap_level /** Number of images at this level: 1 for 1D/2D, 6 for CUBE, depth for 3D */ GLuint nr_images; - /** - * Byte offset from level_offset to the image for each cube face or depth + /** @{ + * offsets from level_[xy] to the image for each cube face or depth * level. * * Pretty much have to accept that hardware formats @@ -91,6 +83,7 @@ struct intel_mipmap_level * so have to store them as a lookup table. */ GLuint *x_offset, *y_offset; + /** @} */ }; struct intel_mipmap_tree From 1a77f8af9bc9982d76a7f602712eb1a5c23ec14e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2010 09:26:37 -0700 Subject: [PATCH 123/483] intel: Assert that the linear blits succeed. We don't have any fallback code here, and we want to avoid this path if failure would happen, so just assert. --- src/mesa/drivers/dri/intel/intel_blit.c | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index f2769aa3e8c..f4f93b5a134 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -482,6 +482,7 @@ intel_emit_linear_blit(struct intel_context *intel, unsigned int size) { GLuint pitch, height; + GLboolean ok; /* Blits are in a different ringbuffer so we don't use them. */ assert(intel->gen < 6); @@ -489,25 +490,27 @@ intel_emit_linear_blit(struct intel_context *intel, /* The pitch is a signed value. */ pitch = MIN2(size, (1 << 15) - 1); height = size / pitch; - intelEmitCopyBlit(intel, 1, - pitch, src_bo, src_offset, I915_TILING_NONE, - pitch, dst_bo, dst_offset, I915_TILING_NONE, - 0, 0, /* src x/y */ - 0, 0, /* dst x/y */ - pitch, height, /* w, h */ - GL_COPY); + ok = intelEmitCopyBlit(intel, 1, + pitch, src_bo, src_offset, I915_TILING_NONE, + pitch, dst_bo, dst_offset, I915_TILING_NONE, + 0, 0, /* src x/y */ + 0, 0, /* dst x/y */ + pitch, height, /* w, h */ + GL_COPY); + assert(ok); src_offset += pitch * height; dst_offset += pitch * height; size -= pitch * height; assert (size < (1 << 15)); if (size != 0) { - intelEmitCopyBlit(intel, 1, - size, src_bo, src_offset, I915_TILING_NONE, - size, dst_bo, dst_offset, I915_TILING_NONE, - 0, 0, /* src x/y */ - 0, 0, /* dst x/y */ - size, 1, /* w, h */ - GL_COPY); + ok = intelEmitCopyBlit(intel, 1, + size, src_bo, src_offset, I915_TILING_NONE, + size, dst_bo, dst_offset, I915_TILING_NONE, + 0, 0, /* src x/y */ + 0, 0, /* dst x/y */ + size, 1, /* w, h */ + GL_COPY); + assert(ok); } } From da011faf48155a5c02ebc1fe1fa20a4f54b8c657 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 16:20:03 -0700 Subject: [PATCH 124/483] intel: Rely on allocated region pitch for the miptree pitch. Bug #26966: 945 miptree pitch disagreement with libdrm. --- src/mesa/drivers/dri/intel/intel_fbo.c | 9 ++------- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 13 ++----------- src/mesa/drivers/dri/intel/intel_regions.c | 8 ++------ src/mesa/drivers/dri/intel/intel_regions.h | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index a429f8d003d..ba3bb8fdba4 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -104,7 +104,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, struct intel_context *intel = intel_context(ctx); struct intel_renderbuffer *irb = intel_renderbuffer(rb); int cpp; - GLuint pitch; ASSERT(rb->Name != 0); @@ -176,15 +175,11 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, /* allocate new memory region/renderbuffer */ - /* Choose a pitch to match hardware requirements: - */ - pitch = ((cpp * width + 63) & ~63) / cpp; - /* alloc hardware renderbuffer */ - DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch); + DBG("Allocating %d x %d Intel RBO\n", width, height); irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp, - width, height, pitch, GL_TRUE); + width, height, GL_TRUE); if (!irb->region) return GL_FALSE; /* out of memory? */ diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index ac9e135a01a..e02b188e354 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -146,8 +146,8 @@ intel_miptree_create(struct intel_context *intel, mt->cpp, mt->pitch, mt->total_height, - mt->pitch, expect_accelerated_upload); + mt->pitch = mt->region->pitch; if (!mt->region) { free(mt); @@ -177,20 +177,11 @@ intel_miptree_create_for_region(struct intel_context *intel, I915_TILING_NONE); if (!mt) return mt; -#if 0 - if (mt->pitch != region->pitch) { - fprintf(stderr, - "region pitch (%d) doesn't match mipmap tree pitch (%d)\n", - region->pitch, mt->pitch); - free(mt); - return NULL; - } -#else + /* The mipmap tree pitch is aligned to 64 bytes to make sure render * to texture works, but we don't need that for texturing from a * pixmap. Just override it here. */ mt->pitch = region->pitch; -#endif intel_region_reference(&mt->region, region); diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 581e5ec6b38..27e454d2942 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -172,7 +172,7 @@ intel_region_alloc_internal(struct intel_context *intel, struct intel_region * intel_region_alloc(struct intel_context *intel, uint32_t tiling, - GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint cpp, GLuint width, GLuint height, GLboolean expect_accelerated_upload) { dri_bo *buffer; @@ -186,13 +186,9 @@ intel_region_alloc(struct intel_context *intel, buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region", width, height, cpp, &tiling, &aligned_pitch, flags); - /* We've already chosen a pitch as part of miptree layout. It had - * better be the same. - */ - assert(aligned_pitch == pitch * cpp); region = intel_region_alloc_internal(intel, cpp, width, height, - pitch, buffer); + aligned_pitch / cpp, buffer); region->tiling = tiling; return region; diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index c81ccde4dad..2459c9a924d 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -78,7 +78,7 @@ struct intel_region struct intel_region *intel_region_alloc(struct intel_context *intel, uint32_t tiling, GLuint cpp, GLuint width, - GLuint height, GLuint pitch, + GLuint height, GLboolean expect_accelerated_upload); struct intel_region * From e1e48ea15c1fe448f0b69e086b66c1123dc98bb7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2010 10:10:37 -0700 Subject: [PATCH 125/483] intel: Respect src pitch in _mesa_copy_rect(). If a non-zero src_y was used, this would break piglit depth-level-clamp. --- src/mesa/drivers/dri/intel/intel_regions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 27e454d2942..1172de90b13 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -307,7 +307,7 @@ _mesa_copy_rect(GLubyte * dst, dst += dst_x * cpp; src += src_x * cpp; dst += dst_y * dst_pitch; - src += src_y * dst_pitch; + src += src_y * src_pitch; width *= cpp; if (width == dst_pitch && width == src_pitch) From 30446f8a708a647401e58da11de2dc464e37823c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2010 09:27:48 -0700 Subject: [PATCH 126/483] intel: Return false like other blit failure paths if out of aperture. The primary consumer of this (miptree relayout) already has this code for handling failure, and the other paths want to know if failure actually occurs and do something appropriate, which may not include memcpy. --- src/mesa/drivers/dri/intel/intel_blit.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index f4f93b5a134..46173703397 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -121,22 +121,8 @@ intelEmitCopyBlit(struct intel_context *intel, intel_prepare_render(intel); - if (pass >= 2) { - drm_intel_gem_bo_map_gtt(dst_buffer); - drm_intel_gem_bo_map_gtt(src_buffer); - _mesa_copy_rect((GLubyte *)dst_buffer->virtual + dst_offset, - cpp, - dst_pitch, - dst_x, dst_y, - w, h, - (GLubyte *)src_buffer->virtual + src_offset, - src_pitch, - src_x, src_y); - drm_intel_gem_bo_unmap_gtt(src_buffer); - drm_intel_gem_bo_unmap_gtt(dst_buffer); - - return GL_TRUE; - } + if (pass >= 2) + return GL_FALSE; intel_batchbuffer_require_space(intel->batch, 8 * 4); DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", From 362c1bf75eb74de5b4655c481b74f79718ed4a34 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2010 09:09:54 -0700 Subject: [PATCH 127/483] intel: Replace mt->pitch with mt->region->pitch. The pitch is not really an inherent part of the miptree, since it's not part of any of the layout calculations, and it's dictated by the libdrm-allocated region pitch now. --- src/mesa/drivers/dri/i915/i830_texstate.c | 6 +- src/mesa/drivers/dri/i915/i915_tex_layout.c | 27 +++--- src/mesa/drivers/dri/i915/i915_texstate.c | 2 +- src/mesa/drivers/dri/i965/brw_tex_layout.c | 23 ++--- .../drivers/dri/i965/brw_wm_surface_state.c | 2 +- src/mesa/drivers/dri/intel/intel_fbo.c | 2 +- .../drivers/dri/intel/intel_mipmap_tree.c | 84 +++---------------- .../drivers/dri/intel/intel_mipmap_tree.h | 3 +- src/mesa/drivers/dri/intel/intel_tex_copy.c | 2 +- src/mesa/drivers/dri/intel/intel_tex_image.c | 4 +- src/mesa/drivers/dri/intel/intel_tex_layout.c | 14 ++-- 11 files changed, 47 insertions(+), 122 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index e8f7e378ec7..a28073919cb 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -146,15 +146,15 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) dri_bo_reference(intelObj->mt->region->buffer); i830->state.tex_buffer[unit] = intelObj->mt->region->buffer; + pitch = intelObj->mt->region->pitch * intelObj->mt->cpp; + /* XXX: This calculation is probably broken for tiled images with * a non-page-aligned offset. */ - i830->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) * - intelObj->mt->cpp; + i830->state.tex_offset[unit] = dst_x * intelObj->mt->cpp + dst_y * pitch; format = translate_texture_format(firstImage->TexFormat, firstImage->InternalFormat); - pitch = intelObj->mt->pitch * intelObj->mt->cpp; state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | (LOAD_TEXTURE_MAP0 << unit) | 4); diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c index fe3908f580a..702655283ba 100644 --- a/src/mesa/drivers/dri/i915/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c @@ -123,13 +123,12 @@ i915_miptree_layout_cube(struct intel_context *intel, assert(lvlWidth == lvlHeight); /* cubemap images are square */ /* double pitch for cube layouts */ - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2); + mt->total_width = dim * 2; mt->total_height = dim * 4; for (level = mt->first_level; level <= mt->last_level; level++) { intel_miptree_set_level_info(mt, level, 6, 0, 0, - /*OLD: mt->pitch, mt->total_height,*/ lvlWidth, lvlHeight, 1); lvlWidth /= 2; @@ -167,7 +166,7 @@ i915_miptree_layout_3d(struct intel_context *intel, GLint level; /* Calculate the size of a single slice. */ - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0); + mt->total_width = mt->width0; /* XXX: hardware expects/requires 9 levels at minimum. */ for (level = mt->first_level; level <= MAX2(8, mt->last_level); level++) { @@ -210,7 +209,7 @@ i915_miptree_layout_2d(struct intel_context *intel, GLuint img_height; GLint level; - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0); + mt->total_width = mt->width0; mt->total_height = 0; for (level = mt->first_level; level <= mt->last_level; level++) { @@ -251,9 +250,8 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt, break; } - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - mt->pitch, - mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp); + DBG("%s: %dx%dx%d\n", __FUNCTION__, + mt->total_width, mt->total_height, mt->cpp); return GL_TRUE; } @@ -336,9 +334,9 @@ i945_miptree_layout_cube(struct intel_context *intel, * or the final row of 4x4, 2x2 and 1x1 faces below this. */ if (dim > 32) - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2); + mt->total_width = dim * 2; else - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, 14 * 8); + mt->total_width = 14 * 8; if (dim >= 4) mt->total_height = dim * 4 + 4; @@ -423,11 +421,11 @@ i945_miptree_layout_3d(struct intel_context *intel, GLuint pack_y_pitch; GLuint level; - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0); + mt->total_width = mt->width0; mt->total_height = 0; pack_y_pitch = MAX2(mt->height0, 2); - pack_x_pitch = mt->pitch; + pack_x_pitch = mt->total_width; pack_x_nr = 1; for (level = mt->first_level; level <= mt->last_level; level++) { @@ -454,7 +452,7 @@ i945_miptree_layout_3d(struct intel_context *intel, if (pack_x_pitch > 4) { pack_x_pitch >>= 1; pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr <= mt->pitch); + assert(pack_x_pitch * pack_x_nr <= mt->total_width); } if (pack_y_pitch > 2) { @@ -491,9 +489,8 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt, break; } - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - mt->pitch, - mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp); + DBG("%s: %dx%dx%d\n", __FUNCTION__, + mt->total_width, mt->total_height, mt->cpp); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index a1ab8f8b6d2..ff9ab88c5ab 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -165,7 +165,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) format = translate_texture_format(firstImage->TexFormat, firstImage->InternalFormat, tObj->DepthMode); - pitch = intelObj->mt->pitch * intelObj->mt->cpp; + pitch = intelObj->mt->region->pitch * intelObj->mt->cpp; state[I915_TEXREG_MS3] = (((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) | diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 09edfd81fde..b1f56a8e648 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -58,12 +58,12 @@ GLboolean brw_miptree_layout(struct intel_context *intel, GLuint qpitch = 0; GLuint y_pitch = 0; - mt->pitch = mt->width0; + mt->total_width = mt->width0; intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h); y_pitch = ALIGN(height, align_h); if (mt->compressed) { - mt->pitch = ALIGN(mt->width0, align_w); + mt->total_width = ALIGN(mt->width0, align_w); } if (mt->first_level != mt->last_level) { @@ -77,13 +77,11 @@ GLboolean brw_miptree_layout(struct intel_context *intel, + minify(minify(mt->width0)); } - if (mip1_width > mt->pitch) { - mt->pitch = mip1_width; + if (mip1_width > mt->total_width) { + mt->total_width = mip1_width; } } - mt->pitch = intel_miptree_pitch_align(intel, mt, tiling, mt->pitch); - if (mt->compressed) { qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4; mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4 * 6; @@ -137,10 +135,10 @@ GLboolean brw_miptree_layout(struct intel_context *intel, intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h); if (mt->compressed) { - mt->pitch = ALIGN(width, align_w); + mt->total_width = ALIGN(width, align_w); pack_y_pitch = (height + 3) / 4; } else { - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0); + mt->total_width = mt->width0; pack_y_pitch = ALIGN(mt->height0, align_h); } @@ -184,7 +182,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel, if (pack_x_pitch > 4) { pack_x_pitch >>= 1; pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr <= mt->pitch); + assert(pack_x_pitch * pack_x_nr <= mt->total_width); } if (pack_y_pitch > 2) { @@ -211,11 +209,8 @@ GLboolean brw_miptree_layout(struct intel_context *intel, i945_miptree_layout_2d(intel, mt, tiling); break; } - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - mt->pitch, - mt->total_height, - mt->cpp, - mt->pitch * mt->total_height * mt->cpp ); + DBG("%s: %dx%dx%d\n", __FUNCTION__, + mt->total_width, mt->total_height, mt->cpp); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index ce0bf0b97d2..6b9e5668862 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -261,7 +261,7 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit ) key.format = firstImage->TexFormat; key.internal_format = firstImage->InternalFormat; - key.pitch = intelObj->mt->pitch; + key.pitch = intelObj->mt->region->pitch; key.depth = firstImage->Depth; key.bo = intelObj->mt->region->buffer; key.offset = 0; diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index ba3bb8fdba4..8278d12bb90 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -568,7 +568,7 @@ intel_render_texture(GLcontext * ctx, att->Zoffset, &dst_x, &dst_y); - intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->pitch + + intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->region->pitch + dst_x) * intel_image->mt->cpp; intel_image->mt->region->draw_x = dst_x; intel_image->mt->region->draw_y = dst_y; diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index e02b188e354..e671355c381 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -83,7 +83,6 @@ intel_miptree_create_internal(struct intel_context *intel, mt->cpp = compress_byte ? compress_byte : cpp; mt->compressed = compress_byte ? 1 : 0; mt->refcount = 1; - mt->pitch = 0; #ifdef I915 if (intel->is_945) @@ -136,7 +135,7 @@ intel_miptree_create(struct intel_context *intel, /* * pitch == 0 || height == 0 indicates the null texture */ - if (!mt || !mt->pitch || !mt->total_height) { + if (!mt || !mt->total_height) { free(mt); return NULL; } @@ -144,10 +143,9 @@ intel_miptree_create(struct intel_context *intel, mt->region = intel_region_alloc(intel, tiling, mt->cpp, - mt->pitch, + mt->total_width, mt->total_height, expect_accelerated_upload); - mt->pitch = mt->region->pitch; if (!mt->region) { free(mt); @@ -178,71 +176,11 @@ intel_miptree_create_for_region(struct intel_context *intel, if (!mt) return mt; - /* The mipmap tree pitch is aligned to 64 bytes to make sure render - * to texture works, but we don't need that for texturing from a - * pixmap. Just override it here. */ - mt->pitch = region->pitch; - intel_region_reference(&mt->region, region); return mt; } - -/** - * intel_miptree_pitch_align: - * - * @intel: intel context pointer - * - * @mt: the miptree to compute pitch alignment for - * - * @pitch: the natural pitch value - * - * Given @pitch, compute a larger value which accounts for - * any necessary alignment required by the device - */ -int intel_miptree_pitch_align (struct intel_context *intel, - struct intel_mipmap_tree *mt, - uint32_t tiling, - int pitch) -{ -#ifdef I915 - GLcontext *ctx = &intel->ctx; -#endif - - if (!mt->compressed) { - int pitch_align; - - /* XXX: Align pitch to multiple of 64 bytes for now to allow - * render-to-texture to work in all cases. This should probably be - * replaced at some point by some scheme to only do this when really - * necessary. - */ - pitch_align = 64; - - if (tiling == I915_TILING_X) - pitch_align = 512; - else if (tiling == I915_TILING_Y) - pitch_align = 128; - - pitch = ALIGN(pitch * mt->cpp, pitch_align); - -#ifdef I915 - /* Do a little adjustment to linear allocations so that we avoid - * hitting the same channel of memory for 2 different pages when - * reading a 2x2 subspan or doing bilinear filtering. - */ - if (tiling == I915_TILING_NONE && !(pitch & 511) && - (pitch + pitch_align) < (1 << ctx->Const.MaxTextureLevels)) - pitch += pitch_align; -#endif - - pitch /= mt->cpp; - } - return pitch; -} - - void intel_miptree_reference(struct intel_mipmap_tree **dst, struct intel_mipmap_tree *src) @@ -414,7 +352,7 @@ intel_miptree_image_map(struct intel_context * intel, DBG("%s \n", __FUNCTION__); if (row_stride) - *row_stride = mt->pitch * mt->cpp; + *row_stride = mt->region->pitch * mt->cpp; if (mt->target == GL_TEXTURE_3D) { int i; @@ -423,7 +361,7 @@ intel_miptree_image_map(struct intel_context * intel, intel_miptree_get_image_offset(mt, level, face, i, &x, &y); - image_offsets[i] = x + y * mt->pitch; + image_offsets[i] = x + y * mt->region->pitch; } return intel_region_map(intel, mt->region); @@ -434,7 +372,7 @@ intel_miptree_image_map(struct intel_context * intel, image_offsets[0] = 0; return intel_region_map(intel, mt->region) + - (x + y * mt->pitch) * mt->cpp; + (x + y * mt->region->pitch) * mt->cpp; } } @@ -524,13 +462,13 @@ intel_miptree_image_copy(struct intel_context *intel, src_ptr = intel_region_map(intel, src->region); dst_ptr = intel_region_map(intel, dst->region); - _mesa_copy_rect(dst_ptr + dst->cpp * (dst_x + dst_y * dst->pitch), + _mesa_copy_rect(dst_ptr, dst->cpp, - dst->pitch, - 0, 0, width, height, - src_ptr + src->cpp * (src_x + src_y * src->pitch), - src->pitch, - 0, 0); + dst->region->pitch, + dst_x, dst_y, width, height, + src_ptr, + src->region->pitch, + src_x, src_y); intel_region_unmap(intel, src->region); intel_region_unmap(intel, dst->region); } diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index 7f3468f1153..21db2f4d3b3 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h @@ -102,8 +102,7 @@ struct intel_mipmap_tree /* Derived from the above: */ - GLuint pitch; - GLuint depth_pitch; /* per-image on i945? */ + GLuint total_width; GLuint total_height; /* Includes image offset tables: diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index 13b8bcfa86c..618f690a5f8 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -155,7 +155,7 @@ do_copy_texsubimage(struct intel_context *intel, src->buffer, 0, src->tiling, - intelImage->mt->pitch, + intelImage->mt->region->pitch, dst_bo, 0, intelImage->mt->region->tiling, diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index bac36eeb569..9db96acdc08 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -236,7 +236,7 @@ try_pbo_upload(struct intel_context *intel, intelImage->face, 0, &dst_x, &dst_y); - dst_stride = intelImage->mt->pitch; + dst_stride = intelImage->mt->region->pitch; if (drm_intel_bo_references(intel->batch->buf, dst_buffer)) intelFlush(&intel->ctx); @@ -290,7 +290,7 @@ try_pbo_zcopy(struct intel_context *intel, intelImage->face, 0, &dst_x, &dst_y); - dst_stride = intelImage->mt->pitch; + dst_stride = intelImage->mt->region->pitch; if (src_stride != dst_stride || dst_x != 0 || dst_y != 0 || src_offset != 0) { diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c index 7d69ea4484a..d132e19e831 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -74,14 +74,14 @@ void i945_miptree_layout_2d( struct intel_context *intel, GLuint width = mt->width0; GLuint height = mt->height0; - mt->pitch = mt->width0; + mt->total_width = mt->width0; intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h); if (mt->compressed) { - mt->pitch = ALIGN(mt->width0, align_w); + mt->total_width = ALIGN(mt->width0, align_w); } - /* May need to adjust pitch to accomodate the placement of + /* May need to adjust width to accomodate the placement of * the 2nd mipmap. This occurs when the alignment * constraints of mipmap placement push the right edge of the * 2nd mipmap out past the width of its parent. @@ -97,15 +97,11 @@ void i945_miptree_layout_2d( struct intel_context *intel, + minify(minify(mt->width0)); } - if (mip1_width > mt->pitch) { - mt->pitch = mip1_width; + if (mip1_width > mt->total_width) { + mt->total_width = mip1_width; } } - /* Pitch must be a whole number of dwords, even though we - * express it in texels. - */ - mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->pitch); mt->total_height = 0; for ( level = mt->first_level ; level <= mt->last_level ; level++ ) { From 6379e47ebde2767ec88504313c4cf2d99ac44920 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 13:50:19 -0600 Subject: [PATCH 128/483] llvmpipe: break lines --- src/gallium/drivers/llvmpipe/lp_jit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 5887613120d..4584135d335 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -95,7 +95,8 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) LLVMTypeRef context_type; elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */ - elem_types[1] = LLVMFloatType(); /* alpha_ref_value */ elem_types[2] = LLVMFloatType(); /* scissor_xmin */ + elem_types[1] = LLVMFloatType(); /* alpha_ref_value */ + elem_types[2] = LLVMFloatType(); /* scissor_xmin */ elem_types[3] = LLVMFloatType(); /* scissor_ymin */ elem_types[4] = LLVMFloatType(); /* scissor_xmax */ elem_types[5] = LLVMFloatType(); /* scissor_ymax */ From eee51147979208feffdf37c588ebbce4df6b40d6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 14:00:40 -0600 Subject: [PATCH 129/483] llvmpipe: added stencil ref values to jit context state --- src/gallium/drivers/llvmpipe/lp_jit.c | 27 ++++++++++--------- src/gallium/drivers/llvmpipe/lp_jit.h | 17 +++++++----- src/gallium/drivers/llvmpipe/lp_setup.c | 14 ++++++++++ src/gallium/drivers/llvmpipe/lp_setup.h | 4 +++ .../drivers/llvmpipe/lp_state_derived.c | 5 +++- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 4584135d335..0254272eeca 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -91,17 +91,18 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) /* struct lp_jit_context */ { - LLVMTypeRef elem_types[8]; + LLVMTypeRef elem_types[9]; LLVMTypeRef context_type; elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */ elem_types[1] = LLVMFloatType(); /* alpha_ref_value */ - elem_types[2] = LLVMFloatType(); /* scissor_xmin */ - elem_types[3] = LLVMFloatType(); /* scissor_ymin */ - elem_types[4] = LLVMFloatType(); /* scissor_xmax */ - elem_types[5] = LLVMFloatType(); /* scissor_ymax */ - elem_types[6] = LLVMPointerType(LLVMInt8Type(), 0); /* blend_color */ - elem_types[7] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */ + elem_types[2] = LLVMArrayType(LLVMInt8Type(), 2); /* stencil_refs */ + elem_types[3] = LLVMFloatType(); /* scissor_xmin */ + elem_types[4] = LLVMFloatType(); /* scissor_ymin */ + elem_types[5] = LLVMFloatType(); /* scissor_xmax */ + elem_types[6] = LLVMFloatType(); /* scissor_ymax */ + elem_types[7] = LLVMPointerType(LLVMInt8Type(), 0); /* blend_color */ + elem_types[8] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */ context_type = LLVMStructType(elem_types, Elements(elem_types), 0); @@ -109,16 +110,18 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) screen->target, context_type, 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value, screen->target, context_type, 1); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref, screen->target, context_type, 2); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin, screen->target, context_type, 3); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin, screen->target, context_type, 4); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax, screen->target, context_type, 5); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax, screen->target, context_type, 6); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color, + screen->target, context_type, 7); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures, screen->target, context_type, LP_JIT_CONTEXT_TEXTURES_INDEX); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 13167ae3bf4..6864265ed02 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -84,6 +84,8 @@ struct lp_jit_context float alpha_ref_value; + ubyte stencil_ref[2]; + /** floats, not ints */ float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax; @@ -100,22 +102,25 @@ struct lp_jit_context #define lp_jit_context_alpha_ref_value(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value") +#define lp_jit_context_stencil_ref_value(_builder, _ptr) \ + lp_build_struct_get(_builder, _ptr, 2, "stencil_ref_values") + #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 2, "scissor_xmin") + lp_build_struct_get(_builder, _ptr, 3, "scissor_xmin") #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 3, "scissor_ymin") + lp_build_struct_get(_builder, _ptr, 4, "scissor_ymin") #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 4, "scissor_xmax") + lp_build_struct_get(_builder, _ptr, 5, "scissor_xmax") #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 5, "scissor_ymax") + lp_build_struct_get(_builder, _ptr, 6, "scissor_ymax") #define lp_jit_context_blend_color(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 6, "blend_color") + lp_build_struct_get(_builder, _ptr, 7, "blend_color") -#define LP_JIT_CONTEXT_TEXTURES_INDEX 7 +#define LP_JIT_CONTEXT_TEXTURES_INDEX 8 #define lp_jit_context_textures(_builder, _ptr) \ lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures") diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index cd16b6b2d38..bcc9d1fc1a4 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -401,6 +401,20 @@ lp_setup_set_alpha_ref_value( struct lp_setup_context *setup, } } +void +lp_setup_set_stencil_ref_values( struct lp_setup_context *setup, + const ubyte refs[2] ) +{ + LP_DBG(DEBUG_SETUP, "%s %d %d\n", __FUNCTION__, refs[0], refs[1]); + + if (setup->fs.current.jit_context.stencil_ref[0] != refs[0] || + setup->fs.current.jit_context.stencil_ref[1] != refs[1]) { + setup->fs.current.jit_context.stencil_ref[0] = refs[0]; + setup->fs.current.jit_context.stencil_ref[1] = refs[1]; + setup->dirty |= LP_SETUP_NEW_FS; + } +} + void lp_setup_set_blend_color( struct lp_setup_context *setup, const struct pipe_blend_color *blend_color ) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 414eaec98d1..dbfc1bf8d4c 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -112,6 +112,10 @@ void lp_setup_set_alpha_ref_value( struct lp_setup_context *setup, float alpha_ref_value ); +void +lp_setup_set_stencil_ref_values( struct lp_setup_context *setup, + const ubyte refs[2] ); + void lp_setup_set_blend_color( struct lp_setup_context *setup, const struct pipe_blend_color *blend_color ); diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 9c91ce9238f..777871638f6 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -174,9 +174,12 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) if (llvmpipe->dirty & LP_NEW_SCISSOR) lp_setup_set_scissor(llvmpipe->setup, &llvmpipe->scissor); - if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) + if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) { lp_setup_set_alpha_ref_value(llvmpipe->setup, llvmpipe->depth_stencil->alpha.ref_value); + lp_setup_set_stencil_ref_values(llvmpipe->setup, + llvmpipe->stencil_ref.ref_value); + } if (llvmpipe->dirty & LP_NEW_CONSTANTS) lp_setup_set_fs_constants(llvmpipe->setup, From b8b1bb946f0bc7d1646e0625c239e08ac60b4fc7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 14:11:43 -0600 Subject: [PATCH 130/483] llvmpipe: use new LP_JIT_CTX_ enums for jit context field positions Use the new enum values rather than integers in a few places. --- src/gallium/drivers/llvmpipe/lp_jit.c | 47 +++++++++++-------- src/gallium/drivers/llvmpipe/lp_jit.h | 40 +++++++++++----- .../drivers/llvmpipe/lp_tex_sample_llvm.c | 2 +- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 0254272eeca..1eee9212e6f 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -91,40 +91,49 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) /* struct lp_jit_context */ { - LLVMTypeRef elem_types[9]; + LLVMTypeRef elem_types[LP_JIT_CTX_COUNT]; LLVMTypeRef context_type; - elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */ - elem_types[1] = LLVMFloatType(); /* alpha_ref_value */ - elem_types[2] = LLVMArrayType(LLVMInt8Type(), 2); /* stencil_refs */ - elem_types[3] = LLVMFloatType(); /* scissor_xmin */ - elem_types[4] = LLVMFloatType(); /* scissor_ymin */ - elem_types[5] = LLVMFloatType(); /* scissor_xmax */ - elem_types[6] = LLVMFloatType(); /* scissor_ymax */ - elem_types[7] = LLVMPointerType(LLVMInt8Type(), 0); /* blend_color */ - elem_types[8] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */ + elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0); + elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType(); + elem_types[LP_JIT_CTX_STENCIL_REF] = LLVMArrayType(LLVMInt8Type(), 2); + elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType(); + elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType(); + elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType(); + elem_types[LP_JIT_CTX_SCISSOR_YMAX] = LLVMFloatType(); + elem_types[LP_JIT_CTX_BLEND_COLOR] = LLVMPointerType(LLVMInt8Type(), 0); + elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type, + PIPE_MAX_SAMPLERS); context_type = LLVMStructType(elem_types, Elements(elem_types), 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants, - screen->target, context_type, 0); + screen->target, context_type, + LP_JIT_CTX_CONSTANTS); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value, - screen->target, context_type, 1); + screen->target, context_type, + LP_JIT_CTX_ALPHA_REF); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref, - screen->target, context_type, 2); + screen->target, context_type, + LP_JIT_CTX_STENCIL_REF); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin, - screen->target, context_type, 3); + screen->target, context_type, + LP_JIT_CTX_SCISSOR_XMIN); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin, - screen->target, context_type, 4); + screen->target, context_type, + LP_JIT_CTX_SCISSOR_YMIN); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax, - screen->target, context_type, 5); + screen->target, context_type, + LP_JIT_CTX_SCISSOR_XMAX); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax, - screen->target, context_type, 6); + screen->target, context_type, + LP_JIT_CTX_SCISSOR_YMAX); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color, - screen->target, context_type, 7); + screen->target, context_type, + LP_JIT_CTX_BLEND_COLOR); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures, screen->target, context_type, - LP_JIT_CONTEXT_TEXTURES_INDEX); + LP_JIT_CTX_TEXTURES); LP_CHECK_STRUCT_SIZE(struct lp_jit_context, screen->target, context_type); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 6864265ed02..8f796f76d5a 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -84,7 +84,7 @@ struct lp_jit_context float alpha_ref_value; - ubyte stencil_ref[2]; + uint8_t stencil_ref[2]; /** floats, not ints */ float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax; @@ -96,34 +96,50 @@ struct lp_jit_context }; +/** + * These enum values must match the position of the fields in the + * lp_jit_context struct above. + */ +enum { + LP_JIT_CTX_CONSTANTS = 0, + LP_JIT_CTX_ALPHA_REF, + LP_JIT_CTX_STENCIL_REF, + LP_JIT_CTX_SCISSOR_XMIN, + LP_JIT_CTX_SCISSOR_YMIN, + LP_JIT_CTX_SCISSOR_XMAX, + LP_JIT_CTX_SCISSOR_YMAX, + LP_JIT_CTX_BLEND_COLOR, + LP_JIT_CTX_TEXTURES, + LP_JIT_CTX_COUNT +}; + + #define lp_jit_context_constants(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 0, "constants") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_CONSTANTS, "constants") #define lp_jit_context_alpha_ref_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value") #define lp_jit_context_stencil_ref_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 2, "stencil_ref_values") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref") #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 3, "scissor_xmin") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin") #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 4, "scissor_ymin") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMIN, "scissor_ymin") #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 5, "scissor_xmax") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMAX, "scissor_xmax") #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 6, "scissor_ymax") + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMAX, "scissor_ymax") #define lp_jit_context_blend_color(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, 7, "blend_color") - -#define LP_JIT_CONTEXT_TEXTURES_INDEX 8 + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_BLEND_COLOR, "blend_color") #define lp_jit_context_textures(_builder, _ptr) \ - lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures") + lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures") typedef void diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index 662508af61a..4715cfe4f62 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -105,7 +105,7 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, /* context[0] */ indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); /* context[0].textures */ - indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CONTEXT_TEXTURES_INDEX, 0); + indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CTX_TEXTURES, 0); /* context[0].textures[unit] */ indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0); /* context[0].textures[unit].member */ From 67b82fc395fc9972fc08233044057ab540c7ab59 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 14:32:18 -0600 Subject: [PATCH 131/483] gallivm/llmvpipe: pass stencil refs state into z/stencil build code --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 1 + src/gallium/auxiliary/gallivm/lp_bld_depth.h | 1 + src/gallium/drivers/llvmpipe/lp_jit.h | 2 +- src/gallium/drivers/llvmpipe/lp_state.h | 1 + src/gallium/drivers/llvmpipe/lp_state_fs.c | 22 ++++++++++++++------ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index cbc48f98651..3a5da4edce7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -217,6 +217,7 @@ lp_build_depth_test(LLVMBuilderRef builder, struct lp_type type, const struct util_format_description *format_desc, struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, LLVMValueRef src, LLVMValueRef dst_ptr) { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index 8375824cbf4..a7f67d21005 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -56,6 +56,7 @@ lp_build_depth_test(LLVMBuilderRef builder, struct lp_type type, const struct util_format_description *format_desc, struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, LLVMValueRef src, LLVMValueRef dst_ptr); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 8f796f76d5a..843345c62d0 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -120,7 +120,7 @@ enum { #define lp_jit_context_alpha_ref_value(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value") -#define lp_jit_context_stencil_ref_value(_builder, _ptr) \ +#define lp_jit_context_stencil_ref_values(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref") #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \ diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index be02e97648e..74ebf90d580 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -67,6 +67,7 @@ struct lp_fragment_shader; struct lp_fragment_shader_variant_key { struct pipe_depth_state depth; + struct pipe_stencil_state stencil[2]; struct pipe_alpha_state alpha; struct pipe_blend_state blend; enum pipe_format zsbuf_format; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index a2ec8c39435..5b00792eec4 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -145,6 +145,7 @@ generate_depth(LLVMBuilderRef builder, const struct lp_fragment_shader_variant_key *key, struct lp_type src_type, struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, LLVMValueRef src, LLVMValueRef dst_ptr) { @@ -189,6 +190,7 @@ generate_depth(LLVMBuilderRef builder, dst_type, format_desc, mask, + stencil_refs, src, dst_ptr); } @@ -405,6 +407,7 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef consts_ptr; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; LLVMValueRef z = interp->pos[2]; + LLVMValueRef stencil_refs; struct lp_build_flow_context *flow; struct lp_build_mask_context mask; boolean early_depth_test; @@ -414,6 +417,8 @@ generate_fs(struct llvmpipe_context *lp, assert(i < 4); + stencil_refs = lp_jit_context_stencil_ref_values(builder, context_ptr); + elem_type = lp_build_elem_type(type); vec_type = lp_build_vec_type(type); int_vec_type = lp_build_int_vec_type(type); @@ -462,7 +467,7 @@ generate_fs(struct llvmpipe_context *lp, if(early_depth_test) generate_depth(builder, key, type, &mask, - z, depth_ptr); + stencil_refs, z, depth_ptr); lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, @@ -509,7 +514,7 @@ generate_fs(struct llvmpipe_context *lp, if(!early_depth_test) generate_depth(builder, key, type, &mask, - z, depth_ptr); + stencil_refs, z, depth_ptr); lp_build_mask_end(&mask); @@ -1054,10 +1059,15 @@ make_variant_key(struct llvmpipe_context *lp, memset(key, 0, sizeof *key); - if(lp->framebuffer.zsbuf && - lp->depth_stencil->depth.enabled) { - key->zsbuf_format = lp->framebuffer.zsbuf->format; - memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth); + if (lp->framebuffer.zsbuf) { + if (lp->depth_stencil->depth.enabled) { + key->zsbuf_format = lp->framebuffer.zsbuf->format; + memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth); + } + if (lp->depth_stencil->stencil[0].enabled) { + key->zsbuf_format = lp->framebuffer.zsbuf->format; + memcpy(&key->stencil, &lp->depth_stencil->stencil, sizeof key->stencil); + } } key->alpha.enabled = lp->depth_stencil->alpha.enabled; From d1c9e598838aeac3c8cb90afee00b2cc683be273 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Mar 2010 18:26:51 -0600 Subject: [PATCH 132/483] gallivm/llvmpipe: more asst changes for stencil testing --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 60 +++++++++++--------- src/gallium/auxiliary/gallivm/lp_bld_depth.h | 17 +++--- src/gallium/drivers/llvmpipe/lp_state_fs.c | 55 +++++++++--------- 3 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 3a5da4edce7..0cbe42c9e5a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -212,34 +212,36 @@ lp_depth_type(const struct util_format_description *format_desc, * \param dst_ptr the outgoing/updated depth/stencil values */ void -lp_build_depth_test(LLVMBuilderRef builder, - const struct pipe_depth_state *state, - struct lp_type type, - const struct util_format_description *format_desc, - struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, - LLVMValueRef src, - LLVMValueRef dst_ptr) +lp_build_depth_stencil_test(LLVMBuilderRef builder, + const struct pipe_depth_state *depth, + const struct pipe_stencil_state stencil[2], + struct lp_type type, + const struct util_format_description *format_desc, + struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, + LLVMValueRef z_src, + LLVMValueRef zs_dst_ptr) { struct lp_build_context bld; - unsigned z_swizzle; - LLVMValueRef dst; + unsigned z_swizzle, s_swizzle; + LLVMValueRef zs_dst; LLVMValueRef z_bitmask = NULL; - LLVMValueRef test; + LLVMValueRef z_pass; (void) lp_build_stencil_test; (void) lp_build_stencil_op; - if(!state->enabled) - return; + assert(depth->enabled || stencil[0].enabled); assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS); assert(format_desc->block.width == 1); assert(format_desc->block.height == 1); z_swizzle = format_desc->swizzle[0]; - if(z_swizzle == UTIL_FORMAT_SWIZZLE_NONE) - return; + s_swizzle = format_desc->swizzle[1]; + + assert(z_swizzle != UTIL_FORMAT_SWIZZLE_NONE || + s_swizzle != UTIL_FORMAT_SWIZZLE_NONE); /* Sanity checking */ assert(z_swizzle < 4); @@ -260,9 +262,9 @@ lp_build_depth_test(LLVMBuilderRef builder, /* Setup build context */ lp_build_context_init(&bld, builder, type); - dst = LLVMBuildLoad(builder, dst_ptr, ""); + zs_dst = LLVMBuildLoad(builder, zs_dst_ptr, ""); - lp_build_name(dst, "zsbuf"); + lp_build_name(zs_dst, "zsbuf"); /* Align the source depth bits with the destination's, and mask out any * stencil or padding bits from both */ @@ -271,6 +273,7 @@ lp_build_depth_test(LLVMBuilderRef builder, /* nothing to do */ } else { + /* shift/mask bits to right-justify the Z bits */ unsigned padding_left; unsigned padding_right; unsigned chan; @@ -287,32 +290,33 @@ lp_build_depth_test(LLVMBuilderRef builder, (padding_right + format_desc->channel[z_swizzle].size); if(padding_left || padding_right) { - const unsigned long long mask_left = ((unsigned long long)1 << (format_desc->block.bits - padding_left)) - 1; - const unsigned long long mask_right = ((unsigned long long)1 << (padding_right)) - 1; + const unsigned long long mask_left = (1ULL << (format_desc->block.bits - padding_left)) - 1; + const unsigned long long mask_right = (1ULL << (padding_right)) - 1; z_bitmask = lp_build_const_int_vec(type, mask_left ^ mask_right); } if(padding_left) - src = LLVMBuildLShr(builder, src, lp_build_const_int_vec(type, padding_left), ""); + z_src = LLVMBuildLShr(builder, z_src, + lp_build_const_int_vec(type, padding_left), ""); if(padding_right) - src = LLVMBuildAnd(builder, src, z_bitmask, ""); + z_src = LLVMBuildAnd(builder, z_src, z_bitmask, ""); if(padding_left || padding_right) - dst = LLVMBuildAnd(builder, dst, z_bitmask, ""); + zs_dst = LLVMBuildAnd(builder, zs_dst, z_bitmask, ""); } - lp_build_name(dst, "zsbuf.z"); + lp_build_name(zs_dst, "zsbuf.z"); /* compare src Z to dst Z, returning 'pass' mask */ - test = lp_build_cmp(&bld, state->func, src, dst); - lp_build_mask_update(mask, test); + z_pass = lp_build_cmp(&bld, depth->func, z_src, zs_dst); + lp_build_mask_update(mask, z_pass); - if(state->writemask) { + if (depth->writemask) { if(z_bitmask) z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, ""); else z_bitmask = mask->value; - dst = lp_build_select(&bld, z_bitmask, src, dst); - LLVMBuildStore(builder, dst, dst_ptr); + zs_dst = lp_build_select(&bld, z_bitmask, z_src, zs_dst); + LLVMBuildStore(builder, zs_dst, zs_dst_ptr); } } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index a7f67d21005..eedc1e419b5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -51,14 +51,15 @@ lp_depth_type(const struct util_format_description *format_desc, void -lp_build_depth_test(LLVMBuilderRef builder, - const struct pipe_depth_state *state, - struct lp_type type, - const struct util_format_description *format_desc, - struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, - LLVMValueRef src, - LLVMValueRef dst_ptr); +lp_build_depth_stencil_test(LLVMBuilderRef builder, + const struct pipe_depth_state *depth, + const struct pipe_stencil_state stencil[2], + struct lp_type type, + const struct util_format_description *format_desc, + struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, + LLVMValueRef zs_src, + LLVMValueRef zs_dst_ptr); #endif /* !LP_BLD_DEPTH_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 5b00792eec4..15317ce10f3 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -141,13 +141,13 @@ generate_pos0(LLVMBuilderRef builder, * Generate the depth test. */ static void -generate_depth(LLVMBuilderRef builder, - const struct lp_fragment_shader_variant_key *key, - struct lp_type src_type, - struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, - LLVMValueRef src, - LLVMValueRef dst_ptr) +generate_depth_stencil(LLVMBuilderRef builder, + const struct lp_fragment_shader_variant_key *key, + struct lp_type src_type, + struct lp_build_mask_context *mask, + LLVMValueRef stencil_refs, + LLVMValueRef src, + LLVMValueRef dst_ptr) { const struct util_format_description *format_desc; struct lp_type dst_type; @@ -179,20 +179,21 @@ generate_depth(LLVMBuilderRef builder, assert(dst_type.width == src_type.width); assert(dst_type.length == src_type.length); + /* Convert fragment Z from float to integer */ lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1); dst_ptr = LLVMBuildBitCast(builder, dst_ptr, LLVMPointerType(lp_build_vec_type(dst_type), 0), ""); - - lp_build_depth_test(builder, - &key->depth, - dst_type, - format_desc, - mask, - stencil_refs, - src, - dst_ptr); + lp_build_depth_stencil_test(builder, + &key->depth, + key->stencil, + dst_type, + format_desc, + mask, + stencil_refs, + src, + dst_ptr); } @@ -410,7 +411,7 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef stencil_refs; struct lp_build_flow_context *flow; struct lp_build_mask_context mask; - boolean early_depth_test; + boolean early_depth_stencil_test; unsigned attrib; unsigned chan; unsigned cbuf; @@ -458,16 +459,16 @@ generate_fs(struct llvmpipe_context *lp, lp_build_mask_update(&mask, smask); } - early_depth_test = - key->depth.enabled && + early_depth_stencil_test = + (key->depth.enabled || key->stencil[0].enabled) && !key->alpha.enabled && !shader->info.uses_kill && !shader->info.writes_z; - if(early_depth_test) - generate_depth(builder, key, - type, &mask, - stencil_refs, z, depth_ptr); + if (early_depth_stencil_test) + generate_depth_stencil(builder, key, + type, &mask, + stencil_refs, z, depth_ptr); lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, @@ -511,10 +512,10 @@ generate_fs(struct llvmpipe_context *lp, } } - if(!early_depth_test) - generate_depth(builder, key, - type, &mask, - stencil_refs, z, depth_ptr); + if (!early_depth_stencil_test) + generate_depth_stencil(builder, key, + type, &mask, + stencil_refs, z, depth_ptr); lp_build_mask_end(&mask); From 8dc8c3f5b11d5f158b0027d1501555c898e0451e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 08:34:23 -0600 Subject: [PATCH 133/483] llvmpipe: silence some pointer/casting warnings --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 15317ce10f3..a4030269704 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -591,6 +591,20 @@ generate_blend(const struct pipe_blend_state *blend, } +/** casting function to avoid compiler warnings */ +static lp_jit_frag_func +cast_voidptr_to_lp_jit_frag_func(void *p) +{ + union { + void *v; + lp_jit_frag_func f; + } tmp; + assert(sizeof(tmp.v) == sizeof(tmp.f)); + tmp.v = p; + return tmp.f; +} + + /** * Generate the runtime callable function for the whole fragment pipeline. * Note that the function which we generate operates on a block of 16 @@ -851,10 +865,14 @@ generate_fragment(struct llvmpipe_context *lp, /* * Translate the LLVM IR into machine code. */ - variant->jit_function[do_tri_test] = (lp_jit_frag_func)LLVMGetPointerToGlobal(screen->engine, function); + { + void *f = LLVMGetPointerToGlobal(screen->engine, function); - if (LP_DEBUG & DEBUG_ASM) - lp_disassemble(variant->jit_function[do_tri_test]); + variant->jit_function[do_tri_test] = cast_voidptr_to_lp_jit_frag_func(f); + + if (LP_DEBUG & DEBUG_ASM) + lp_disassemble(f); + } } From 2b8db4ce156fbd4d094f46fad0b8b3291b057fff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 15:07:45 -0600 Subject: [PATCH 134/483] gallivm: added lp_build_andc() --- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 10 ++++++++++ src/gallium/auxiliary/gallivm/lp_bld_logic.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index e2e533fa7ec..a3b69701162 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -483,3 +483,13 @@ lp_build_alloca(struct lp_build_context *bld) return LLVMBuildAlloca(bld->builder, lp_build_elem_type(type), ""); } } + + +/** Return (a & ~b) */ +LLVMValueRef +lp_build_andc(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b) +{ + b = LLVMBuildNot(bld->builder, b, ""); + b = LLVMBuildAnd(bld->builder, a, b, ""); + return b; +} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.h b/src/gallium/auxiliary/gallivm/lp_bld_logic.h index d849d29e95d..00a8c750196 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.h @@ -79,4 +79,9 @@ lp_build_select_aos(struct lp_build_context *bld, LLVMValueRef lp_build_alloca(struct lp_build_context *bld); + +LLVMValueRef +lp_build_andc(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b); + + #endif /* !LP_BLD_LOGIC_H */ From 227824ac6999a8925b90f093b08a6284d33a7dad Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 15:09:35 -0600 Subject: [PATCH 135/483] llvmpipe: remove incorrect depth test check --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index a4030269704..b38e0f393dc 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -138,7 +138,7 @@ generate_pos0(LLVMBuilderRef builder, /** - * Generate the depth test. + * Generate the depth /stencil test code. */ static void generate_depth_stencil(LLVMBuilderRef builder, @@ -152,9 +152,6 @@ generate_depth_stencil(LLVMBuilderRef builder, const struct util_format_description *format_desc; struct lp_type dst_type; - if(!key->depth.enabled) - return; - format_desc = util_format_description(key->zsbuf_format); assert(format_desc); From fecd4cde501e8b0b5d057a9cc9d2e3af8d853d9e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 16:24:12 -0600 Subject: [PATCH 136/483] gallivm/llvmpipe: basic stencil testing works Most stencil demos look OK (modulo some unrelated rendering glitches). Only single-sided stencil test works at this point. There are probably some bugs to be found... --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 164 ++++++++++++++++--- src/gallium/drivers/llvmpipe/lp_jit.h | 2 +- 2 files changed, 140 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 0cbe42c9e5a..e4500e5aef1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -80,8 +80,8 @@ static LLVMValueRef lp_build_stencil_test(struct lp_build_context *bld, const struct pipe_stencil_state *stencil, - LLVMValueRef stencilVals, - LLVMValueRef stencilRef) + LLVMValueRef stencilRef, + LLVMValueRef stencilVals) { const unsigned stencilMax = 255; /* XXX fix */ struct lp_type type = bld->type; @@ -97,8 +97,7 @@ lp_build_stencil_test(struct lp_build_context *bld, stencilVals = LLVMBuildAnd(bld->builder, stencilVals, valuemask, ""); } - res = lp_build_compare(bld->builder, bld->type, stencil->func, - stencilVals, stencilRef); + res = lp_build_cmp(bld, stencil->func, stencilVals, stencilRef); return res; } @@ -111,10 +110,11 @@ lp_build_stencil_test(struct lp_build_context *bld, */ static LLVMValueRef lp_build_stencil_op(struct lp_build_context *bld, + const struct pipe_stencil_state *stencil, unsigned stencil_op, LLVMValueRef stencilRef, - const struct pipe_stencil_state *stencil, - LLVMValueRef stencilVals) + LLVMValueRef stencilVals, + LLVMValueRef mask) { const unsigned stencilMax = 255; /* XXX fix */ @@ -125,24 +125,33 @@ lp_build_stencil_op(struct lp_build_context *bld, switch (stencil_op) { case PIPE_STENCIL_OP_KEEP: res = stencilVals; + /* we can return early for this case */ + return res; case PIPE_STENCIL_OP_ZERO: res = bld->zero; + break; case PIPE_STENCIL_OP_REPLACE: - res = lp_build_broadcast_scalar(bld, stencilRef); + res = stencilRef; + break; case PIPE_STENCIL_OP_INCR: res = lp_build_add(bld, stencilVals, bld->one); res = lp_build_min(bld, res, max); + break; case PIPE_STENCIL_OP_DECR: res = lp_build_sub(bld, stencilVals, bld->one); res = lp_build_max(bld, res, bld->zero); + break; case PIPE_STENCIL_OP_INCR_WRAP: res = lp_build_add(bld, stencilVals, bld->one); res = LLVMBuildAnd(bld->builder, res, max, ""); + break; case PIPE_STENCIL_OP_DECR_WRAP: res = lp_build_sub(bld, stencilVals, bld->one); res = LLVMBuildAnd(bld->builder, res, max, ""); + break; case PIPE_STENCIL_OP_INVERT: res = LLVMBuildNot(bld->builder, stencilVals, ""); + break; default: assert(0 && "bad stencil op mode"); res = NULL; @@ -157,6 +166,9 @@ lp_build_stencil_op(struct lp_build_context *bld, res = LLVMBuildOr(bld->builder, t1, t2, "t1_or_t2"); } + /* only the update the vector elements enabled by 'mask' */ + res = lp_build_select(bld, mask, res, stencilVals); + return res; } @@ -201,6 +213,27 @@ lp_depth_type(const struct util_format_description *format_desc, } +static LLVMValueRef +lp_build_get_stencil_ref(struct lp_build_context *bld, + struct lp_type type, LLVMValueRef stencil_refs_ptr) +{ + LLVMValueRef indexes[2], ptr, ref, ref_vec; + + /* load 0th element of the array */ + indexes[0] = indexes[1] = LLVMConstInt(LLVMInt32Type(), 0, 0); + ptr = LLVMBuildGEP(bld->builder, stencil_refs_ptr, indexes, 2, ""); + ref = LLVMBuildLoad(bld->builder, ptr, ""); + + /* convert int8 value to i32 */ + ref = LLVMBuildZExt(bld->builder, ref, LLVMIntType(type.width), ""); + + /* make scalar into vector */ + ref_vec = lp_build_broadcast_scalar(bld, ref); + + return ref_vec; +} + + /** * Generate code for performing depth and/or stencil tests. * We operate on a vector of values (typically a 2x2 quad). @@ -224,12 +257,11 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, { struct lp_build_context bld; unsigned z_swizzle, s_swizzle; - LLVMValueRef zs_dst; - LLVMValueRef z_bitmask = NULL; - LLVMValueRef z_pass; - - (void) lp_build_stencil_test; - (void) lp_build_stencil_op; + LLVMValueRef zs_dst, z_dst = NULL; + LLVMValueRef stencil_vals = NULL; + LLVMValueRef z_bitmask = NULL, s_bitmask = NULL; + LLVMValueRef z_pass = NULL, s_pass_mask = NULL; + LLVMValueRef orig_mask = mask->value; assert(depth->enabled || stencil[0].enabled); @@ -262,15 +294,16 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, /* Setup build context */ lp_build_context_init(&bld, builder, type); + /* Load current z/stencil value from z/stencil buffer */ zs_dst = LLVMBuildLoad(builder, zs_dst_ptr, ""); - lp_build_name(zs_dst, "zsbuf"); + lp_build_name(zs_dst, "zsbufval"); /* Align the source depth bits with the destination's, and mask out any * stencil or padding bits from both */ if(format_desc->channel[z_swizzle].size == format_desc->block.bits) { assert(z_swizzle == 0); - /* nothing to do */ + z_dst = zs_dst; } else { /* shift/mask bits to right-justify the Z bits */ @@ -295,28 +328,109 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, z_bitmask = lp_build_const_int_vec(type, mask_left ^ mask_right); } + s_bitmask = LLVMBuildNot(builder, z_bitmask, ""); + + stencil_vals = LLVMBuildAnd(builder, zs_dst, s_bitmask, ""); + if(padding_left) z_src = LLVMBuildLShr(builder, z_src, lp_build_const_int_vec(type, padding_left), ""); if(padding_right) z_src = LLVMBuildAnd(builder, z_src, z_bitmask, ""); if(padding_left || padding_right) - zs_dst = LLVMBuildAnd(builder, zs_dst, z_bitmask, ""); + z_dst = LLVMBuildAnd(builder, zs_dst, z_bitmask, ""); + else + z_dst = zs_dst; } - lp_build_name(zs_dst, "zsbuf.z"); + lp_build_name(z_dst, "zsbuf.z"); - /* compare src Z to dst Z, returning 'pass' mask */ - z_pass = lp_build_cmp(&bld, depth->func, z_src, zs_dst); - lp_build_mask_update(mask, z_pass); + /* + printf("build depth %d stencil %d\n", + depth->enabled, + stencil[0].enabled); + */ - if (depth->writemask) { - if(z_bitmask) - z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, ""); + if (stencil[0].enabled) { + /* Incoming stencil_refs is ptr to int8[2]. Get/convert to int32[4]. */ + stencil_refs = lp_build_get_stencil_ref(&bld, type, stencil_refs); + + s_pass_mask = lp_build_stencil_test(&bld, stencil, + stencil_refs, stencil_vals); + + /* apply stencil-fail operator */ + { + LLVMValueRef s_fail_mask = lp_build_andc(&bld, orig_mask, s_pass_mask); + stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].fail_op, + stencil_refs, stencil_vals, + s_fail_mask); + } + } + + if (depth->enabled) { + /* compare src Z to dst Z, returning 'pass' mask */ + z_pass = lp_build_cmp(&bld, depth->func, z_src, z_dst); + + if (!stencil[0].enabled) { + /* We can potentially skip all remaining operations here, but only + * if stencil is disabled because we still need to update the stencil + * buffer values. Don't need to update Z buffer values. + */ + lp_build_mask_update(mask, z_pass); + } + + if (depth->writemask) { + if(z_bitmask) + z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, ""); + else + z_bitmask = mask->value; + + z_dst = lp_build_select(&bld, z_bitmask, z_src, z_dst); + } + + if (stencil[0].enabled) { + /* update stencil buffer values according to z pass/fail result */ + LLVMValueRef z_fail_mask, z_pass_mask; + + /* apply Z-fail operator */ + z_fail_mask = lp_build_andc(&bld, orig_mask, z_pass); + stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zfail_op, + stencil_refs, stencil_vals, + z_fail_mask); + + /* apply Z-pass operator */ + z_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, z_pass, ""); + stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zpass_op, + stencil_refs, stencil_vals, + z_pass_mask); + } + } + else { + /* No depth test: apply Z-pass operator to stencil buffer values which + * passed the stencil test. + */ + s_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, s_pass_mask, ""); + stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zpass_op, + stencil_refs, stencil_vals, s_pass_mask); + } + + /* Finally, merge/store the z/stencil values */ + if ((depth->enabled && depth->writemask) || + (stencil[0].enabled && stencil[0].writemask)) { + + if (z_dst && stencil_vals) + zs_dst = LLVMBuildOr(bld.builder, z_dst, stencil_vals, ""); + else if (z_dst) + zs_dst = z_dst; else - z_bitmask = mask->value; + zs_dst = stencil_vals; - zs_dst = lp_build_select(&bld, z_bitmask, z_src, zs_dst); LLVMBuildStore(builder, zs_dst, zs_dst_ptr); } + + if (s_pass_mask) + lp_build_mask_update(mask, s_pass_mask); + + if (depth->enabled && stencil[0].enabled) + lp_build_mask_update(mask, z_pass); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 843345c62d0..63e05c5d5e1 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -121,7 +121,7 @@ enum { lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value") #define lp_jit_context_stencil_ref_values(_builder, _ptr) \ - lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref") + lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref") #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin") From 0557d0a4b2c010b6f617613b2b46e055ce12fac9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 16:26:41 -0600 Subject: [PATCH 137/483] progs/trivial: added comments --- progs/trivial/tri-stencil.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c index 9f68bca9149..d66b68c415a 100644 --- a/progs/trivial/tri-stencil.c +++ b/progs/trivial/tri-stencil.c @@ -77,6 +77,7 @@ static void Draw(void) glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + /* red triangle (setting stencil to 1) */ glColor3ub(200, 0, 0); glBegin(GL_POLYGON); glVertex3i(-4, -4, 0); @@ -88,6 +89,7 @@ static void Draw(void) glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_INCR, GL_KEEP, GL_DECR); + /* green quad (if over red, decr stencil to 0, else incr to 1) */ glColor3ub(0, 200, 0); glBegin(GL_POLYGON); glVertex3i(3, 3, 0); @@ -101,6 +103,7 @@ static void Draw(void) glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + /* blue quad (where stencil == 1) */ glColor3ub(0, 0, 200); glBegin(GL_POLYGON); glVertex3f(2.5, 2.5, 0); From 6dd4054ca544952393f74eee1b37406404d7d823 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 16:33:29 -0600 Subject: [PATCH 138/483] cell: be more conservative in cell_is_format_supported() This fixes a regression from commit a84575cdc0c8193b2c7858734e2ec6b1ec4511b2 which changed the depth/stencil format we were trying to use. --- src/gallium/drivers/cell/ppu/cell_screen.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index a43f8638dcd..eada62181af 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -134,12 +134,16 @@ cell_is_format_supported( struct pipe_screen *screen, unsigned tex_usage, unsigned geom_flags ) { - /* cell supports most formats, XXX for now anyway */ - if (format == PIPE_FORMAT_DXT5_RGBA || - format == PIPE_FORMAT_A8B8G8R8_SRGB) - return FALSE; - else + /* only a few formats are known to work at this time */ + switch (format) { + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_I8_UNORM: return TRUE; + default: + return FALSE; + } } From 05a980ac2a6b74af0436c1bb15c986a8160ec2eb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Mar 2010 17:39:49 -0600 Subject: [PATCH 139/483] cell: return 1 for PIPE_CAP_BLEND_EQUATION_SEPARATE With this feature, we get OpenGL version 2.0 and the progs/glsl/ demos run as-is. --- src/gallium/drivers/cell/ppu/cell_screen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index eada62181af..7957e0149d7 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -95,6 +95,8 @@ cell_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + case PIPE_CAP_BLEND_EQUATION_SEPARATE: + return 1; default: return 0; } From ca69249f25e0cb89dbfc3d98b92e7386a3029efa Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Mar 2010 09:47:18 +0800 Subject: [PATCH 140/483] st/dri: Move DRI1 bits in dri_screen.c to dri1.c. --- src/gallium/state_trackers/dri/Makefile | 3 +- src/gallium/state_trackers/dri/SConscript | 1 + src/gallium/state_trackers/dri/dri1.c | 117 ++++++++++++++++++ src/gallium/state_trackers/dri/dri1.h | 43 +++++++ src/gallium/state_trackers/dri/dri_context.c | 1 + src/gallium/state_trackers/dri/dri_drawable.c | 1 + src/gallium/state_trackers/dri/dri_drawable.h | 1 + src/gallium/state_trackers/dri/dri_screen.c | 79 +----------- src/gallium/state_trackers/dri/dri_screen.h | 9 +- 9 files changed, 173 insertions(+), 82 deletions(-) create mode 100644 src/gallium/state_trackers/dri/dri1.c create mode 100644 src/gallium/state_trackers/dri/dri1.h diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index ef8f19709ab..24244417b97 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -15,7 +15,8 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ - dri_extensions.c + dri_extensions.c \ + dri1.c # $(TOP)/src/mesa/drivers/dri/common/utils.c \ $(TOP)/src/mesa/drivers/dri/common/vblank.c \ diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index ce2c2735974..6310fe06e43 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -18,6 +18,7 @@ if env['dri']: 'dri_drawable.c', 'dri_extensions.c', 'dri_screen.c', + 'dri1.c', ] ) Export('st_dri') diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c new file mode 100644 index 00000000000..1222f42e237 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri1.c @@ -0,0 +1,117 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "util/u_memory.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri1.h" + +static const __DRIextension *dri1_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL +}; + +struct dri1_api *__dri1_api_hooks = NULL; + +static INLINE void +dri1_copy_version(struct dri1_api_version *dst, + const struct __DRIversionRec *src) +{ + dst->major = src->major; + dst->minor = src->minor; + dst->patch_level = src->patch; +} + +const __DRIconfig ** +dri1_init_screen(__DRIscreen * sPriv) +{ + struct dri_screen *screen; + const __DRIconfig **configs; + struct dri1_create_screen_arg arg; + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + return NULL; + + screen->api = drm_api_create(); + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; + + sPriv->private = (void *)screen; + sPriv->extensions = dri1_screen_extensions; + + arg.base.mode = DRM_CREATE_DRI1; + arg.lf = &dri1_lf; + arg.ddx_info = sPriv->pDevPriv; + arg.ddx_info_size = sPriv->devPrivSize; + arg.sarea = sPriv->pSAREA; + dri1_copy_version(&arg.ddx_version, &sPriv->ddx_version); + dri1_copy_version(&arg.dri_version, &sPriv->dri_version); + dri1_copy_version(&arg.drm_version, &sPriv->drm_version); + arg.api = NULL; + + screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base); + + if (!screen->pipe_screen || !arg.api) { + debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); + goto out_no_screen; + } + + __dri1_api_hooks = arg.api; + + screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer; + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, __driNConfigOptions); + + /** + * FIXME: If the driver supports format conversion swapbuffer blits, we might + * want to support other color bit depths than the server is currently + * using. + */ + + configs = dri_fill_in_modes(screen, sPriv->fbBPP); + if (!configs) + goto out_no_configs; + + return configs; + out_no_configs: + screen->pipe_screen->destroy(screen->pipe_screen); + out_no_screen: + FREE(screen); + return NULL; +} diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h new file mode 100644 index 00000000000..731b13cb06f --- /dev/null +++ b/src/gallium/state_trackers/dri/dri1.h @@ -0,0 +1,43 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI1_H +#define DRI1_H + +#include "state_tracker/dri1_api.h" +#include "dri_util.h" + +extern struct dri1_api *__dri1_api_hooks; + +const __DRIconfig ** +dri1_init_screen(__DRIscreen * sPriv); + +#endif /* DRI1_H */ diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index f772ba5d16b..a5ed0006dc9 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -38,6 +38,7 @@ #include "pipe/p_context.h" #include "dri_context.h" +#include "dri1.h" #include "util/u_memory.h" diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index c400725c7f2..83b1a29681b 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -32,6 +32,7 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri1.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 8bc59cb4c3d..80bd2f5bdf0 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -29,6 +29,7 @@ #define DRI_DRAWABLE_H #include "pipe/p_compiler.h" +#include "pipe/p_format.h" struct pipe_surface; struct pipe_fence_handle; diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 7ccad8f5dd6..8a586d637fc 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -36,6 +36,7 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri1.h" #include "pipe/p_screen.h" #include "pipe/p_format.h" @@ -53,7 +54,7 @@ PUBLIC const char __driConfigOptions[] = DRI_CONF_ALLOW_LARGE_TEXTURES(1) DRI_CONF_SECTION_END DRI_CONF_END; - const uint __driNConfigOptions = 3; +const uint __driNConfigOptions = 3; static const __DRItexBufferExtension dri2TexBufferExtension = { { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, @@ -83,9 +84,7 @@ static const __DRI2flushExtension dri2FlushExtension = { NULL }; -struct dri1_api *__dri1_api_hooks = NULL; - -static const __DRIconfig ** +const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits) { @@ -240,75 +239,6 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) return 0; } -static INLINE void -dri_copy_version(struct dri1_api_version *dst, - const struct __DRIversionRec *src) -{ - dst->major = src->major; - dst->minor = src->minor; - dst->patch_level = src->patch; -} - -static const __DRIconfig ** -dri_init_screen(__DRIscreen * sPriv) -{ - struct dri_screen *screen; - const __DRIconfig **configs; - struct dri1_create_screen_arg arg; - - screen = CALLOC_STRUCT(dri_screen); - if (!screen) - return NULL; - - screen->api = drm_api_create(); - screen->sPriv = sPriv; - screen->fd = sPriv->fd; - screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; - - sPriv->private = (void *)screen; - sPriv->extensions = dri_screen_extensions; - - arg.base.mode = DRM_CREATE_DRI1; - arg.lf = &dri1_lf; - arg.ddx_info = sPriv->pDevPriv; - arg.ddx_info_size = sPriv->devPrivSize; - arg.sarea = sPriv->pSAREA; - dri_copy_version(&arg.ddx_version, &sPriv->ddx_version); - dri_copy_version(&arg.dri_version, &sPriv->dri_version); - dri_copy_version(&arg.drm_version, &sPriv->drm_version); - arg.api = NULL; - - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base); - - if (!screen->pipe_screen || !arg.api) { - debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); - goto out_no_screen; - } - - __dri1_api_hooks = arg.api; - - screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer; - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - - /** - * FIXME: If the driver supports format conversion swapbuffer blits, we might - * want to support other color bit depths than the server is currently - * using. - */ - - configs = dri_fill_in_modes(screen, sPriv->fbBPP); - if (!configs) - goto out_no_configs; - - return configs; - out_no_configs: - screen->pipe_screen->destroy(screen->pipe_screen); - out_no_screen: - FREE(screen); - return NULL; -} - /** * This is the driver specific part of the createNewScreen entry point. * @@ -375,7 +305,6 @@ dri_destroy_screen(__DRIscreen * sPriv) } PUBLIC const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, .DestroyContext = dri_destroy_context, @@ -388,7 +317,7 @@ PUBLIC const struct __DriverAPIRec driDriverAPI = { .GetDrawableMSC = driDrawableGetMSC32, .WaitForMSC = driWaitForMSC32, .CopySubBuffer = dri_copy_sub_buffer, - .InitScreen = dri_init_screen, + .InitScreen = dri1_init_screen, .InitScreen2 = dri_init_screen2, }; diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 75a0ee4250e..31301356923 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -37,8 +37,6 @@ #include "pipe/p_compiler.h" -#include "state_tracker/dri1_api.h" - struct dri_screen { /* dri */ @@ -69,11 +67,10 @@ dri_screen(__DRIscreen * sPriv) return (struct dri_screen *)sPriv->private; } -/*********************************************************************** - * dri_screen.c - */ +extern const uint __driNConfigOptions; -extern struct dri1_api *__dri1_api_hooks; +const __DRIconfig ** +dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits); #endif From a437bc50f2f8ff6e91fdf4dc9758b35cff35645a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Mar 2010 10:25:50 +0800 Subject: [PATCH 141/483] st/dri: Move DRI1 bits in dri_drawable.c to dri1.c. --- src/gallium/state_trackers/dri/dri1.c | 314 ++++++++++++++++++ src/gallium/state_trackers/dri/dri1.h | 16 + src/gallium/state_trackers/dri/dri_drawable.c | 306 +---------------- src/gallium/state_trackers/dri/dri_drawable.h | 12 - src/gallium/state_trackers/dri/dri_screen.c | 7 +- 5 files changed, 336 insertions(+), 319 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 1222f42e237..2d809459ca2 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -30,12 +30,326 @@ */ #include "util/u_memory.h" +#include "util/u_rect.h" +#include "pipe/p_context.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_public.h" #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" #include "dri1.h" +static struct pipe_fence_handle * +dri_swap_fences_pop_front(struct dri_drawable *draw) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence = NULL; + + if (draw->cur_fences >= draw->desired_fences) { + screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); + screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); + --draw->cur_fences; + draw->tail &= DRI_SWAP_FENCES_MASK; + } + return fence; +} + +static void +dri_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + + if (!fence) + return; + + if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { + draw->cur_fences++; + screen->fence_reference(screen, &draw->swap_fences[draw->head++], + fence); + draw->head &= DRI_SWAP_FENCES_MASK; + } +} + +void +dri1_swap_fences_clear(struct dri_drawable *drawable) +{ + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_fence_handle *fence; + + while (drawable->cur_fences) { + fence = dri_swap_fences_pop_front(drawable); + screen->fence_reference(screen, &fence, NULL); + } +} + +static void +dri1_update_drawables_locked(struct dri_context *ctx, + __DRIdrawable * driDrawPriv, + __DRIdrawable * driReadPriv) +{ + if (ctx->stLostLock) { + ctx->stLostLock = FALSE; + if (driDrawPriv == driReadPriv) + DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv); + else + DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv, + driReadPriv); + } +} + +/** + * This ensures all contexts which bind to a drawable pick up the + * drawable change and signal new buffer state. + * Calling st_resize_framebuffer for each context may seem like overkill, + * but no new buffers will actually be allocated if the dimensions don't + * change. + */ + +static void +dri1_propagate_drawable_change(struct dri_context *ctx) +{ + __DRIdrawable *dPriv = ctx->dPriv; + __DRIdrawable *rPriv = ctx->rPriv; + boolean flushed = FALSE; + + if (dPriv && ctx->d_stamp != dPriv->lastStamp) { + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + flushed = TRUE; + ctx->d_stamp = dPriv->lastStamp; + st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h); + + } + + if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) { + + if (!flushed) + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->r_stamp = rPriv->lastStamp; + st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h); + + } else if (rPriv && dPriv == rPriv) { + + ctx->r_stamp = ctx->d_stamp; + + } +} + +void +dri1_update_drawables(struct dri_context *ctx, + struct dri_drawable *draw, struct dri_drawable *read) +{ + dri_lock(ctx); + dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); + dri_unlock(ctx); + + dri1_propagate_drawable_change(ctx); +} + +static INLINE boolean +dri1_intersect_src_bbox(struct drm_clip_rect *dst, + int dst_x, + int dst_y, + const struct drm_clip_rect *src, + const struct drm_clip_rect *bbox) +{ + int xy1; + int xy2; + + xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 : + (int)bbox->x1 + dst_x; + xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 : + (int)bbox->x2 + dst_x; + if (xy1 >= xy2 || xy1 < 0) + return FALSE; + + dst->x1 = xy1; + dst->x2 = xy2; + + xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 : + (int)bbox->y1 + dst_y; + xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 : + (int)bbox->y2 + dst_y; + if (xy1 >= xy2 || xy1 < 0) + return FALSE; + + dst->y1 = xy1; + dst->y2 = xy2; + return TRUE; +} + +static void +dri1_swap_copy(struct dri_context *ctx, + struct pipe_surface *dst, + struct pipe_surface *src, + __DRIdrawable * dPriv, const struct drm_clip_rect *bbox) +{ + struct pipe_context *pipe = ctx->pipe; + struct drm_clip_rect clip; + struct drm_clip_rect *cur; + int i; + + cur = dPriv->pClipRects; + + for (i = 0; i < dPriv->numClipRects; ++i) { + if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) { + if (pipe->surface_copy) { + pipe->surface_copy(pipe, dst, clip.x1, clip.y1, + src, + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, + clip.x2 - clip.x1, clip.y2 - clip.y1); + } else { + util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1, + src, + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, + clip.x2 - clip.x1, clip.y2 - clip.y1); + } + } + } +} + +static void +dri1_copy_to_front(struct dri_context *ctx, + struct pipe_surface *surf, + __DRIdrawable * dPriv, + const struct drm_clip_rect *sub_box, + struct pipe_fence_handle **fence) +{ + struct pipe_context *pipe = ctx->pipe; + boolean save_lost_lock; + uint cur_w; + uint cur_h; + struct drm_clip_rect bbox; + boolean visible = TRUE; + + *fence = NULL; + + dri_lock(ctx); + save_lost_lock = ctx->stLostLock; + dri1_update_drawables_locked(ctx, dPriv, dPriv); + st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h); + + bbox.x1 = 0; + bbox.x2 = cur_w; + bbox.y1 = 0; + bbox.y2 = cur_h; + + if (sub_box) + visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box); + + if (visible && __dri1_api_hooks->present_locked) { + + __dri1_api_hooks->present_locked(pipe, + surf, + dPriv->pClipRects, + dPriv->numClipRects, + dPriv->x, dPriv->y, &bbox, fence); + + } else if (visible && __dri1_api_hooks->front_srf_locked) { + + struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe); + + if (front) + dri1_swap_copy(ctx, front, surf, dPriv, &bbox); + + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence); + } + + ctx->stLostLock = save_lost_lock; + + /** + * FIXME: Revisit this: Update drawables on copy_sub_buffer ? + */ + + if (!sub_box) + dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv); + + dri_unlock(ctx); + dri1_propagate_drawable_change(ctx); +} + +void +dri1_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, void *context_private) +{ + struct dri_context *ctx = (struct dri_context *)context_private; + struct pipe_fence_handle *dummy_fence; + + dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence); + screen->fence_reference(screen, &dummy_fence, NULL); + + /** + * FIXME: Do we need swap throttling here? + */ +} + +void +dri1_swap_buffers(__DRIdrawable * dPriv) +{ + struct dri_context *ctx; + struct pipe_surface *back_surf; + struct dri_drawable *draw = dri_drawable(dPriv); + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence; + struct st_context *st = st_get_current(); + + assert(__dri1_api_hooks != NULL); + + if (!st) + return; /* For now */ + + ctx = (struct dri_context *)st->pipe->priv; + + st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); + if (back_surf) { + st_notify_swapbuffers(draw->stfb); + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + fence = dri_swap_fences_pop_front(draw); + if (fence) { + (void)screen->fence_finish(screen, fence, 0); + screen->fence_reference(screen, &fence, NULL); + } + dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence); + dri_swap_fences_push_back(draw, fence); + screen->fence_reference(screen, &fence, NULL); + } +} + +void +dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) +{ + struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen; + struct drm_clip_rect sub_bbox; + struct dri_context *ctx; + struct pipe_surface *back_surf; + struct dri_drawable *draw = dri_drawable(dPriv); + struct pipe_fence_handle *dummy_fence; + struct st_context *st = st_get_current(); + + assert(__dri1_api_hooks != NULL); + + if (!st) + return; + + ctx = (struct dri_context *)st->pipe->priv; + + sub_bbox.x1 = x; + sub_bbox.x2 = x + w; + sub_bbox.y1 = y; + sub_bbox.y2 = y + h; + + st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); + if (back_surf) { + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence); + screen->fence_reference(screen, &dummy_fence, NULL); + } +} + static const __DRIextension *dri1_screen_extensions[] = { &driReadDrawableExtension, &driCopySubBufferExtension.base, diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index 731b13cb06f..b2304af7e1a 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -40,4 +40,20 @@ extern struct dri1_api *__dri1_api_hooks; const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv); +void +dri1_update_drawables(struct dri_context *ctx, + struct dri_drawable *draw, struct dri_drawable *read); + +void +dri1_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, void *context_private); + +void dri1_swap_buffers(__DRIdrawable * dPriv); + +void +dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h); + +void +dri1_swap_fences_clear(struct dri_drawable *drawable); + #endif /* DRI1_H */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 83b1a29681b..6c4de71c89f 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -448,319 +448,17 @@ fail: return GL_FALSE; } -static struct pipe_fence_handle * -dri_swap_fences_pop_front(struct dri_drawable *draw) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - struct pipe_fence_handle *fence = NULL; - - if (draw->cur_fences >= draw->desired_fences) { - screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); - screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); - --draw->cur_fences; - draw->tail &= DRI_SWAP_FENCES_MASK; - } - return fence; -} - -static void -dri_swap_fences_push_back(struct dri_drawable *draw, - struct pipe_fence_handle *fence) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - - if (!fence) - return; - - if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { - draw->cur_fences++; - screen->fence_reference(screen, &draw->swap_fences[draw->head++], - fence); - draw->head &= DRI_SWAP_FENCES_MASK; - } -} - void dri_destroy_buffer(__DRIdrawable * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_fence_handle *fence; - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; st_unreference_framebuffer(drawable->stfb); drawable->desired_fences = 0; - while (drawable->cur_fences) { - fence = dri_swap_fences_pop_front(drawable); - screen->fence_reference(screen, &fence, NULL); - } + + dri1_swap_fences_clear(drawable); FREE(drawable); } -static void -dri1_update_drawables_locked(struct dri_context *ctx, - __DRIdrawable * driDrawPriv, - __DRIdrawable * driReadPriv) -{ - if (ctx->stLostLock) { - ctx->stLostLock = FALSE; - if (driDrawPriv == driReadPriv) - DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv); - else - DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv, - driReadPriv); - } -} - -/** - * This ensures all contexts which bind to a drawable pick up the - * drawable change and signal new buffer state. - * Calling st_resize_framebuffer for each context may seem like overkill, - * but no new buffers will actually be allocated if the dimensions don't - * change. - */ - -static void -dri1_propagate_drawable_change(struct dri_context *ctx) -{ - __DRIdrawable *dPriv = ctx->dPriv; - __DRIdrawable *rPriv = ctx->rPriv; - boolean flushed = FALSE; - - if (dPriv && ctx->d_stamp != dPriv->lastStamp) { - - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - flushed = TRUE; - ctx->d_stamp = dPriv->lastStamp; - st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h); - - } - - if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) { - - if (!flushed) - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - ctx->r_stamp = rPriv->lastStamp; - st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h); - - } else if (rPriv && dPriv == rPriv) { - - ctx->r_stamp = ctx->d_stamp; - - } -} - -void -dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, struct dri_drawable *read) -{ - dri_lock(ctx); - dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); - dri_unlock(ctx); - - dri1_propagate_drawable_change(ctx); -} - -static INLINE boolean -dri1_intersect_src_bbox(struct drm_clip_rect *dst, - int dst_x, - int dst_y, - const struct drm_clip_rect *src, - const struct drm_clip_rect *bbox) -{ - int xy1; - int xy2; - - xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 : - (int)bbox->x1 + dst_x; - xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 : - (int)bbox->x2 + dst_x; - if (xy1 >= xy2 || xy1 < 0) - return FALSE; - - dst->x1 = xy1; - dst->x2 = xy2; - - xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 : - (int)bbox->y1 + dst_y; - xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 : - (int)bbox->y2 + dst_y; - if (xy1 >= xy2 || xy1 < 0) - return FALSE; - - dst->y1 = xy1; - dst->y2 = xy2; - return TRUE; -} - -static void -dri1_swap_copy(struct dri_context *ctx, - struct pipe_surface *dst, - struct pipe_surface *src, - __DRIdrawable * dPriv, const struct drm_clip_rect *bbox) -{ - struct pipe_context *pipe = ctx->pipe; - struct drm_clip_rect clip; - struct drm_clip_rect *cur; - int i; - - cur = dPriv->pClipRects; - - for (i = 0; i < dPriv->numClipRects; ++i) { - if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) { - if (pipe->surface_copy) { - pipe->surface_copy(pipe, dst, clip.x1, clip.y1, - src, - (int)clip.x1 - dPriv->x, - (int)clip.y1 - dPriv->y, - clip.x2 - clip.x1, clip.y2 - clip.y1); - } else { - util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1, - src, - (int)clip.x1 - dPriv->x, - (int)clip.y1 - dPriv->y, - clip.x2 - clip.x1, clip.y2 - clip.y1); - } - } - } -} - -static void -dri1_copy_to_front(struct dri_context *ctx, - struct pipe_surface *surf, - __DRIdrawable * dPriv, - const struct drm_clip_rect *sub_box, - struct pipe_fence_handle **fence) -{ - struct pipe_context *pipe = ctx->pipe; - boolean save_lost_lock; - uint cur_w; - uint cur_h; - struct drm_clip_rect bbox; - boolean visible = TRUE; - - *fence = NULL; - - dri_lock(ctx); - save_lost_lock = ctx->stLostLock; - dri1_update_drawables_locked(ctx, dPriv, dPriv); - st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h); - - bbox.x1 = 0; - bbox.x2 = cur_w; - bbox.y1 = 0; - bbox.y2 = cur_h; - - if (sub_box) - visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box); - - if (visible && __dri1_api_hooks->present_locked) { - - __dri1_api_hooks->present_locked(pipe, - surf, - dPriv->pClipRects, - dPriv->numClipRects, - dPriv->x, dPriv->y, &bbox, fence); - - } else if (visible && __dri1_api_hooks->front_srf_locked) { - - struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe); - - if (front) - dri1_swap_copy(ctx, front, surf, dPriv, &bbox); - - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence); - } - - ctx->stLostLock = save_lost_lock; - - /** - * FIXME: Revisit this: Update drawables on copy_sub_buffer ? - */ - - if (!sub_box) - dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv); - - dri_unlock(ctx); - dri1_propagate_drawable_change(ctx); -} - -void -dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) -{ - struct dri_context *ctx = (struct dri_context *)context_private; - struct pipe_fence_handle *dummy_fence; - - dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence); - screen->fence_reference(screen, &dummy_fence, NULL); - - /** - * FIXME: Do we need swap throttling here? - */ -} - -void -dri_swap_buffers(__DRIdrawable * dPriv) -{ - struct dri_context *ctx; - struct pipe_surface *back_surf; - struct dri_drawable *draw = dri_drawable(dPriv); - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - struct pipe_fence_handle *fence; - struct st_context *st = st_get_current(); - - assert(__dri1_api_hooks != NULL); - - if (!st) - return; /* For now */ - - ctx = (struct dri_context *)st->pipe->priv; - - st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - if (back_surf) { - st_notify_swapbuffers(draw->stfb); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - fence = dri_swap_fences_pop_front(draw); - if (fence) { - (void)screen->fence_finish(screen, fence, 0); - screen->fence_reference(screen, &fence, NULL); - } - dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence); - dri_swap_fences_push_back(draw, fence); - screen->fence_reference(screen, &fence, NULL); - } -} - -void -dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) -{ - struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen; - struct drm_clip_rect sub_bbox; - struct dri_context *ctx; - struct pipe_surface *back_surf; - struct dri_drawable *draw = dri_drawable(dPriv); - struct pipe_fence_handle *dummy_fence; - struct st_context *st = st_get_current(); - - assert(__dri1_api_hooks != NULL); - - if (!st) - return; - - ctx = (struct dri_context *)st->pipe->priv; - - sub_bbox.x1 = x; - sub_bbox.x2 = x + w; - sub_bbox.y1 = y; - sub_bbox.y2 = y + h; - - st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - if (back_surf) { - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence); - screen->fence_reference(screen, &dummy_fence, NULL); - } -} - /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 80bd2f5bdf0..48d24e959c0 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -88,11 +88,6 @@ void dri_flush_frontbuffer(struct pipe_screen *screen, struct pipe_surface *surf, void *context_private); -void dri_swap_buffers(__DRIdrawable * dPriv); - -void -dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h); - void dri_get_buffers(__DRIdrawable * dPriv); void dri_destroy_buffer(__DRIdrawable * dPriv); @@ -103,13 +98,6 @@ void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv); -void -dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, struct dri_drawable *read); - -void -dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private); #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 8a586d637fc..b6cd92d0f85 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -310,15 +310,16 @@ PUBLIC const struct __DriverAPIRec driDriverAPI = { .DestroyContext = dri_destroy_context, .CreateBuffer = dri_create_buffer, .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, .MakeCurrent = dri_make_current, .UnbindContext = dri_unbind_context, .GetSwapInfo = dri_get_swap_info, .GetDrawableMSC = driDrawableGetMSC32, .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, - .InitScreen = dri1_init_screen, .InitScreen2 = dri_init_screen2, + + .InitScreen = dri1_init_screen, + .SwapBuffers = dri1_swap_buffers, + .CopySubBuffer = dri1_copy_sub_buffer, }; /* This is the table of extensions that the loader will dlsym() for. */ From 61631a89a3268925c89934c77ed7c2482eaa1fd1 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Mar 2010 10:31:40 +0800 Subject: [PATCH 142/483] st/dri: Move DRI1 bits in dri_context.c to dri1.c. --- src/gallium/state_trackers/dri/dri1.c | 68 ++++++++++++++++++-- src/gallium/state_trackers/dri/dri_context.c | 38 ----------- src/gallium/state_trackers/dri/dri_context.h | 24 ------- 3 files changed, 64 insertions(+), 66 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 2d809459ca2..a4284f6fe7a 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -40,6 +40,28 @@ #include "dri_drawable.h" #include "dri1.h" +static INLINE void +dri1_lock(struct dri_context *ctx) +{ + drm_context_t hw_context = ctx->cPriv->hHWContext; + char ret = 0; + + DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret); + if (ret) { + drmGetLock(ctx->sPriv->fd, hw_context, 0); + ctx->stLostLock = TRUE; + ctx->wsLostLock = TRUE; + } + ctx->isLocked = TRUE; +} + +static INLINE void +dri1_unlock(struct dri_context *ctx) +{ + ctx->isLocked = FALSE; + DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext); +} + static struct pipe_fence_handle * dri_swap_fences_pop_front(struct dri_drawable *draw) { @@ -141,9 +163,9 @@ void dri1_update_drawables(struct dri_context *ctx, struct dri_drawable *draw, struct dri_drawable *read) { - dri_lock(ctx); + dri1_lock(ctx); dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); - dri_unlock(ctx); + dri1_unlock(ctx); dri1_propagate_drawable_change(ctx); } @@ -228,7 +250,7 @@ dri1_copy_to_front(struct dri_context *ctx, *fence = NULL; - dri_lock(ctx); + dri1_lock(ctx); save_lost_lock = ctx->stLostLock; dri1_update_drawables_locked(ctx, dPriv, dPriv); st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h); @@ -268,7 +290,7 @@ dri1_copy_to_front(struct dri_context *ctx, if (!sub_box) dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv); - dri_unlock(ctx); + dri1_unlock(ctx); dri1_propagate_drawable_change(ctx); } @@ -350,6 +372,44 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) } } +static void +st_dri_lock(struct pipe_context *pipe) +{ + dri1_lock((struct dri_context *)pipe->priv); +} + +static void +st_dri_unlock(struct pipe_context *pipe) +{ + dri1_unlock((struct dri_context *)pipe->priv); +} + +static boolean +st_dri_is_locked(struct pipe_context *pipe) +{ + return ((struct dri_context *)pipe->priv)->isLocked; +} + +static boolean +st_dri_lost_lock(struct pipe_context *pipe) +{ + return ((struct dri_context *)pipe->priv)->wsLostLock; +} + +static void +st_dri_clear_lost_lock(struct pipe_context *pipe) +{ + ((struct dri_context *)pipe->priv)->wsLostLock = FALSE; +} + +static struct dri1_api_lock_funcs dri1_lf = { + .lock = st_dri_lock, + .unlock = st_dri_unlock, + .is_locked = st_dri_is_locked, + .is_lock_lost = st_dri_lost_lock, + .clear_lost_lock = st_dri_clear_lost_lock +}; + static const __DRIextension *dri1_screen_extensions[] = { &driReadDrawableExtension, &driCopySubBufferExtension.base, diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index a5ed0006dc9..58f2b17585d 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -182,42 +182,4 @@ dri_make_current(__DRIcontext * cPriv, return GL_TRUE; } -static void -st_dri_lock(struct pipe_context *pipe) -{ - dri_lock((struct dri_context *)pipe->priv); -} - -static void -st_dri_unlock(struct pipe_context *pipe) -{ - dri_unlock((struct dri_context *)pipe->priv); -} - -static boolean -st_dri_is_locked(struct pipe_context *pipe) -{ - return ((struct dri_context *)pipe->priv)->isLocked; -} - -static boolean -st_dri_lost_lock(struct pipe_context *pipe) -{ - return ((struct dri_context *)pipe->priv)->wsLostLock; -} - -static void -st_dri_clear_lost_lock(struct pipe_context *pipe) -{ - ((struct dri_context *)pipe->priv)->wsLostLock = FALSE; -} - -struct dri1_api_lock_funcs dri1_lf = { - .lock = st_dri_lock, - .unlock = st_dri_unlock, - .is_locked = st_dri_is_locked, - .is_lock_lost = st_dri_lost_lock, - .clear_lost_lock = st_dri_clear_lost_lock -}; - /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h index 13f497462f7..f0700b9aaff 100644 --- a/src/gallium/state_trackers/dri/dri_context.h +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -72,33 +72,9 @@ dri_context(__DRIcontext * driContextPriv) return (struct dri_context *)driContextPriv->driverPrivate; } -static INLINE void -dri_lock(struct dri_context *ctx) -{ - drm_context_t hw_context = ctx->cPriv->hHWContext; - char ret = 0; - - DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret); - if (ret) { - drmGetLock(ctx->sPriv->fd, hw_context, 0); - ctx->stLostLock = TRUE; - ctx->wsLostLock = TRUE; - } - ctx->isLocked = TRUE; -} - -static INLINE void -dri_unlock(struct dri_context *ctx) -{ - ctx->isLocked = FALSE; - DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext); -} - /*********************************************************************** * dri_context.c */ -extern struct dri1_api_lock_funcs dri1_lf; - void dri_destroy_context(__DRIcontext * driContextPriv); boolean dri_unbind_context(__DRIcontext * driContextPriv); From 903b90926c7aebb7f48f3c0fdbe90cd22dd5b662 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 16 Mar 2010 10:55:40 +0800 Subject: [PATCH 143/483] st/dri: Headers and public symbols clean up. Remove unused headers and stop marking driDriverAPI as PUBLIC. --- src/gallium/state_trackers/dri/dri1.c | 1 + src/gallium/state_trackers/dri/dri1.h | 3 ++- src/gallium/state_trackers/dri/dri_context.c | 8 ++------ src/gallium/state_trackers/dri/dri_drawable.c | 7 ++----- src/gallium/state_trackers/dri/dri_screen.c | 3 +-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index a4284f6fe7a..543891f813b 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -34,6 +34,7 @@ #include "pipe/p_context.h" #include "state_tracker/st_context.h" #include "state_tracker/st_public.h" +#include "state_tracker/dri1_api.h" #include "dri_screen.h" #include "dri_context.h" diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index b2304af7e1a..e525ce64c3f 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -32,7 +32,8 @@ #ifndef DRI1_H #define DRI1_H -#include "state_tracker/dri1_api.h" +#include "dri_context.h" +#include "dri_drawable.h" #include "dri_util.h" extern struct dri1_api *__dri1_api_hooks; diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 58f2b17585d..8e74d3b9bf1 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -30,16 +30,12 @@ */ #include "dri_screen.h" - #include "dri_drawable.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/dri1_api.h" -#include "state_tracker/st_public.h" -#include "pipe/p_context.h" - #include "dri_context.h" #include "dri1.h" +#include "state_tracker/st_public.h" +#include "pipe/p_context.h" #include "util/u_memory.h" GLboolean diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 6c4de71c89f..9238f942999 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -34,19 +34,16 @@ #include "dri_drawable.h" #include "dri1.h" -#include "pipe/p_context.h" -#include "pipe/p_screen.h" #include "main/mtypes.h" #include "main/renderbuffer.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/dri1_api.h" #include "state_tracker/st_context.h" #include "state_tracker/st_public.h" #include "state_tracker/st_cb_fbo.h" +#include "state_tracker/drm_api.h" +#include "pipe/p_screen.h" #include "util/u_format.h" #include "util/u_memory.h" -#include "util/u_rect.h" #include "util/u_inlines.h" static struct pipe_surface * diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index b6cd92d0f85..cffe3b33b2f 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -41,7 +41,6 @@ #include "pipe/p_screen.h" #include "pipe/p_format.h" #include "state_tracker/drm_api.h" -#include "state_tracker/dri1_api.h" #include "util/u_debug.h" @@ -304,7 +303,7 @@ dri_destroy_screen(__DRIscreen * sPriv) sPriv->private = NULL; } -PUBLIC const struct __DriverAPIRec driDriverAPI = { +const struct __DriverAPIRec driDriverAPI = { .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, .DestroyContext = dri_destroy_context, From 5ff21634f3074122ed8b8e4019c8092e31be0335 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 8 Mar 2010 19:25:32 +0800 Subject: [PATCH 144/483] st/dri: Implement st_api.h callbacks. This commit adds dri_st_api.c that implements st_api.h callbacks. A following commit will switch st/dri from st_public.h to st_api.h. --- src/gallium/state_trackers/dri/Makefile | 1 + src/gallium/state_trackers/dri/SConscript | 1 + src/gallium/state_trackers/dri/dri_drawable.h | 6 + src/gallium/state_trackers/dri/dri_st_api.c | 442 ++++++++++++++++++ src/gallium/state_trackers/dri/dri_st_api.h | 55 +++ 5 files changed, 505 insertions(+) create mode 100644 src/gallium/state_trackers/dri/dri_st_api.c create mode 100644 src/gallium/state_trackers/dri/dri_st_api.h diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index 24244417b97..f5af8aa3a67 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -16,6 +16,7 @@ C_SOURCES = \ dri_screen.c \ dri_drawable.c \ dri_extensions.c \ + dri_st_api.c \ dri1.c # $(TOP)/src/mesa/drivers/dri/common/utils.c \ diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index 6310fe06e43..7c67ceecd80 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -18,6 +18,7 @@ if env['dri']: 'dri_drawable.c', 'dri_extensions.c', 'dri_screen.c', + 'dri_st_api.c', 'dri1.c', ] ) diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 48d24e959c0..ea66c483a1e 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -30,6 +30,7 @@ #include "pipe/p_compiler.h" #include "pipe/p_format.h" +#include "state_tracker/st_api.h" struct pipe_surface; struct pipe_fence_handle; @@ -57,6 +58,11 @@ struct dri_drawable /* gallium */ struct st_framebuffer *stfb; + struct st_visual stvis; + + struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; + unsigned int texture_mask, texture_stamp; + struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; unsigned int head; unsigned int tail; diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c new file mode 100644 index 00000000000..379515152e8 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -0,0 +1,442 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_debug.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/st_manager.h" /* for st_manager_create_api */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri1.h" + +static struct { + int32_t refcnt; + struct st_api *stapi; +} dri_st_api; + +/** + * Get the format of an attachment. + */ +static INLINE enum pipe_format +dri_drawable_get_format(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + enum pipe_format format; + + switch (statt) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + format = drawable->stvis.color_format; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + format = drawable->stvis.depth_stencil_format; + break; + default: + format = PIPE_FORMAT_NONE; + break; + } + + return format; +} + +/** + * Process __DRIbuffer and convert them into pipe_textures. + */ +static void +dri_drawable_process_buffers(struct dri_drawable *drawable, + __DRIbuffer *buffers, unsigned count) +{ + struct dri_screen *screen = dri_screen(drawable->sPriv); + __DRIdrawable *dri_drawable = drawable->dPriv; + struct pipe_texture templ; + struct winsys_handle whandle; + boolean have_depth = FALSE; + unsigned i; + + if (drawable->old_num == count && + drawable->old_w == dri_drawable->w && + drawable->old_h == dri_drawable->h && + memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) + return; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + + memset(&templ, 0, sizeof(templ)); + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = dri_drawable->w; + templ.height0 = dri_drawable->h; + templ.depth0 = 1; + + memset(&whandle, 0, sizeof(whandle)); + + for (i = 0; i < count; i++) { + __DRIbuffer *buf = &buffers[i]; + enum st_attachment_type statt; + enum pipe_format format; + + switch (buf->attachment) { + case __DRI_BUFFER_FRONT_LEFT: + if (!screen->auto_fake_front) { + statt = ST_ATTACHMENT_INVALID; + break; + } + /* fallthrough */ + case __DRI_BUFFER_FAKE_FRONT_LEFT: + statt = ST_ATTACHMENT_FRONT_LEFT; + break; + case __DRI_BUFFER_BACK_LEFT: + statt = ST_ATTACHMENT_BACK_LEFT; + break; + case __DRI_BUFFER_DEPTH: + case __DRI_BUFFER_DEPTH_STENCIL: + case __DRI_BUFFER_STENCIL: + statt = ST_ATTACHMENT_DEPTH_STENCIL; + /* use only the first depth/stencil buffer */ + if (have_depth) + statt = ST_ATTACHMENT_INVALID; + else + have_depth = TRUE; + break; + default: + statt = ST_ATTACHMENT_INVALID; + break; + } + + format = dri_drawable_get_format(drawable, statt); + if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE) + continue; + + templ.format = format; + whandle.handle = buf->name; + whandle.stride = buf->pitch; + + drawable->textures[statt] = + screen->pipe_screen->texture_from_handle(screen->pipe_screen, + &templ, &whandle); + } + + drawable->old_num = count; + drawable->old_w = dri_drawable->w; + drawable->old_h = dri_drawable->h; + memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); +} + +/** + * Retrieve __DRIbuffer from the DRI loader. + */ +static __DRIbuffer * +dri_drawable_get_buffers(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned *count) +{ + __DRIdrawable *dri_drawable = drawable->dPriv; + struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; + boolean with_format; + __DRIbuffer *buffers; + int num_buffers; + unsigned attachments[8]; + unsigned num_attachments, i; + + assert(loader); + with_format = (loader->base.version > 2 && loader->getBuffersWithFormat); + + num_attachments = 0; + for (i = 0; i < *count; i++) { + enum pipe_format format; + int att; + + format = dri_drawable_get_format(drawable, statts[i]); + if (format == PIPE_FORMAT_NONE) + continue; + + switch (statts[i]) { + case ST_ATTACHMENT_FRONT_LEFT: + att = __DRI_BUFFER_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + att = __DRI_BUFFER_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + att = __DRI_BUFFER_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + att = __DRI_BUFFER_BACK_RIGHT; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + att = __DRI_BUFFER_DEPTH_STENCIL; + break; + default: + att = -1; + break; + } + + if (att >= 0) { + attachments[num_attachments++] = att; + if (with_format) { + attachments[num_attachments++] = + util_format_get_blocksizebits(format); + } + } + } + + if (with_format) { + num_attachments /= 2; + buffers = loader->getBuffersWithFormat(dri_drawable, + &dri_drawable->w, &dri_drawable->h, + attachments, num_attachments, + &num_buffers, dri_drawable->loaderPrivate); + } + else { + buffers = loader->getBuffers(dri_drawable, + &dri_drawable->w, &dri_drawable->h, + attachments, num_attachments, + &num_buffers, dri_drawable->loaderPrivate); + } + + if (buffers) { + /* set one cliprect to cover the whole dri_drawable */ + dri_drawable->x = 0; + dri_drawable->y = 0; + dri_drawable->backX = 0; + dri_drawable->backY = 0; + dri_drawable->numClipRects = 1; + dri_drawable->pClipRects[0].x1 = 0; + dri_drawable->pClipRects[0].y1 = 0; + dri_drawable->pClipRects[0].x2 = dri_drawable->w; + dri_drawable->pClipRects[0].y2 = dri_drawable->h; + dri_drawable->numBackClipRects = 1; + dri_drawable->pBackClipRects[0].x1 = 0; + dri_drawable->pBackClipRects[0].y1 = 0; + dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; + dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; + + *count = num_buffers; + } + + return buffers; +} + +static boolean +dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_texture **out) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + unsigned statt_mask, i; + + statt_mask = 0x0; + for (i = 0; i < count; i++) + statt_mask |= (1 << statts[i]); + + /* + * dPriv->pStamp is the server stamp. It should be accessed with a lock, at + * least for DRI1. dPriv->lastStamp is the client stamp. It has the value + * of the server stamp when last checked. + * + * This function updates the textures and records the stamp of the textures. + */ + if (drawable->texture_stamp != drawable->dPriv->lastStamp || + (statt_mask & ~drawable->texture_mask)) { + if (__dri1_api_hooks) { + /* TODO */ + return FALSE; + } + else { + __DRIbuffer *buffers; + unsigned num_buffers = count; + + buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); + dri_drawable_process_buffers(drawable, buffers, num_buffers); + } + + drawable->texture_stamp = drawable->dPriv->lastStamp; + drawable->texture_mask = statt_mask; + } + + if (!out) + return TRUE; + + for (i = 0; i < count; i++) { + out[i] = NULL; + pipe_texture_reference(&out[i], drawable->textures[statts[i]]); + } + + return TRUE; +} + +static boolean +dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + struct __DRIdri2LoaderExtensionRec *loader = + drawable->sPriv->dri2.loader; + + /* TODO */ + if (__dri1_api_hooks) + return FALSE; + + if (statt == ST_ATTACHMENT_FRONT_LEFT && loader->flushFrontBuffer) { + loader->flushFrontBuffer(drawable->dPriv, + drawable->dPriv->loaderPrivate); + } + + return TRUE; +} + +/** + * Create a framebuffer from the given drawable. + */ +struct st_framebuffer_iface * +dri_create_st_framebuffer(struct dri_drawable *drawable) +{ + struct st_framebuffer_iface *stfbi; + + stfbi = CALLOC_STRUCT(st_framebuffer_iface); + if (stfbi) { + stfbi->visual = &drawable->stvis; + stfbi->flush_front = dri_st_framebuffer_flush_front; + stfbi->validate = dri_st_framebuffer_validate; + stfbi->st_manager_private = (void *) drawable; + } + + return stfbi; +} + +/** + * Destroy a framebuffer. + */ +void +dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) +{ + FREE(stfbi); +} + +/** + * Return the texture at an attachment. Allocate the texture if it does not + * exist. + */ +struct pipe_texture * +dri_get_st_framebuffer_texture(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + + if (!(drawable->texture_mask & (1 << statt))) { + enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; + unsigned i, count = 0; + + /* make sure DRI2 does not destroy existing buffers */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->texture_mask & (1 << i)) { + statts[count++] = i; + } + } + statts[count++] = statt; + + drawable->texture_stamp = drawable->dPriv->lastStamp - 1; + dri_st_framebuffer_validate(stfbi, statts, count, NULL); + } + + return drawable->textures[statt]; +} + +/** + * Add a reference to the st_api of the state tracker. + */ +static void +_dri_get_st_api(void) +{ + p_atomic_inc(&dri_st_api.refcnt); + if (p_atomic_read(&dri_st_api.refcnt) == 1) + dri_st_api.stapi = st_manager_create_api(); +} + +/** + * Remove a reference to the st_api of the state tracker. + */ +static void +_dri_put_st_api(void) +{ + struct st_api *stapi = dri_st_api.stapi; + + if (p_atomic_dec_zero(&dri_st_api.refcnt)) { + stapi->destroy(dri_st_api.stapi); + dri_st_api.stapi = NULL; + } +} + +/** + * Create a state tracker manager from the given screen. + */ +struct st_manager * +dri_create_st_manager(struct dri_screen *screen) +{ + struct st_manager *smapi; + + smapi = CALLOC_STRUCT(st_manager); + if (smapi) { + smapi->screen = screen->pipe_screen; + _dri_get_st_api(); + } + + return smapi; +} + +/** + * Destroy a state tracker manager. + */ +void +dri_destroy_st_manager(struct st_manager *smapi) +{ + _dri_put_st_api(); + FREE(smapi); +} + +/** + * Return the st_api of OpenGL state tracker. + */ +struct st_api * +dri_get_st_api(void) +{ + assert(dri_st_api.stapi); + return dri_st_api.stapi; +} diff --git a/src/gallium/state_trackers/dri/dri_st_api.h b/src/gallium/state_trackers/dri/dri_st_api.h new file mode 100644 index 00000000000..7cf522e4690 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_st_api.h @@ -0,0 +1,55 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _DRI_ST_API_H_ +#define _DRI_ST_API_H_ + +#include "state_tracker/st_api.h" + +struct dri_screen; +struct dri_drawable; + +struct st_api * +dri_get_st_api(void); + +struct st_manager * +dri_create_st_manager(struct dri_screen *screen); + +void +dri_destroy_st_manager(struct st_manager *smapi); + +struct st_framebuffer_iface * +dri_create_st_framebuffer(struct dri_drawable *drawable); + +void +dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); + +struct pipe_texture * +dri_get_st_framebuffer_texture(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt); + +#endif /* _DRI_ST_API_H_ */ From bd1ce874728c06d08a1f9881f51edbdd2f1c9db0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 8 Mar 2010 22:19:48 +0800 Subject: [PATCH 145/483] st/dri: Switch from st_public.h to st_api.h. This is tested with demos found in progs/demos. However, only the DRI2 path is tested. --- src/gallium/state_trackers/dri/dri1.c | 283 ++++++++----- src/gallium/state_trackers/dri/dri1.h | 11 +- src/gallium/state_trackers/dri/dri_context.c | 82 ++-- src/gallium/state_trackers/dri/dri_context.h | 9 +- src/gallium/state_trackers/dri/dri_drawable.c | 378 +----------------- src/gallium/state_trackers/dri/dri_drawable.h | 24 +- .../state_trackers/dri/dri_extensions.c | 4 +- src/gallium/state_trackers/dri/dri_screen.c | 137 +++++-- src/gallium/state_trackers/dri/dri_screen.h | 12 + src/gallium/state_trackers/dri/dri_st_api.c | 13 +- 10 files changed, 394 insertions(+), 559 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 543891f813b..41dba82d528 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -29,16 +29,18 @@ * Author: Jakob Bornecrantz */ +/* XXX DRI1 is untested after the switch to st_api.h */ + #include "util/u_memory.h" #include "util/u_rect.h" +#include "util/u_inlines.h" #include "pipe/p_context.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_public.h" #include "state_tracker/dri1_api.h" #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri_st_api.h" #include "dri1.h" static INLINE void @@ -125,52 +127,29 @@ dri1_update_drawables_locked(struct dri_context *ctx, /** * This ensures all contexts which bind to a drawable pick up the * drawable change and signal new buffer state. - * Calling st_resize_framebuffer for each context may seem like overkill, - * but no new buffers will actually be allocated if the dimensions don't - * change. */ - static void dri1_propagate_drawable_change(struct dri_context *ctx) { __DRIdrawable *dPriv = ctx->dPriv; __DRIdrawable *rPriv = ctx->rPriv; + struct dri_drawable *draw = dri_drawable(dPriv); + struct dri_drawable *read = dri_drawable(rPriv); boolean flushed = FALSE; - if (dPriv && ctx->d_stamp != dPriv->lastStamp) { - - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + if (dPriv && draw->texture_stamp != dPriv->lastStamp) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); flushed = TRUE; - ctx->d_stamp = dPriv->lastStamp; - st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h); - + ctx->st->notify_invalid_framebuffer(ctx->st, draw->stfb); } - if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) { - + if (rPriv && dPriv != rPriv && read->texture_stamp != rPriv->lastStamp) { if (!flushed) - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - ctx->r_stamp = rPriv->lastStamp; - st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h); - - } else if (rPriv && dPriv == rPriv) { - - ctx->r_stamp = ctx->d_stamp; - + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->st->notify_invalid_framebuffer(ctx->st, read->stfb); } } -void -dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, struct dri_drawable *read) -{ - dri1_lock(ctx); - dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv); - dri1_unlock(ctx); - - dri1_propagate_drawable_change(ctx); -} - static INLINE boolean dri1_intersect_src_bbox(struct drm_clip_rect *dst, int dst_x, @@ -204,12 +183,11 @@ dri1_intersect_src_bbox(struct drm_clip_rect *dst, } static void -dri1_swap_copy(struct dri_context *ctx, +dri1_swap_copy(struct pipe_context *pipe, struct pipe_surface *dst, struct pipe_surface *src, __DRIdrawable * dPriv, const struct drm_clip_rect *bbox) { - struct pipe_context *pipe = ctx->pipe; struct drm_clip_rect clip; struct drm_clip_rect *cur; int i; @@ -235,52 +213,96 @@ dri1_swap_copy(struct dri_context *ctx, } } -static void -dri1_copy_to_front(struct dri_context *ctx, - struct pipe_surface *surf, - __DRIdrawable * dPriv, - const struct drm_clip_rect *sub_box, - struct pipe_fence_handle **fence) +static struct pipe_surface * +dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex) { - struct pipe_context *pipe = ctx->pipe; - boolean save_lost_lock; - uint cur_w; - uint cur_h; + struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_surface *psurf = drawable->dri1_surface; + + if (!psurf || psurf->texture != ptex) { + pipe_surface_reference(&drawable->dri1_surface, NULL); + + drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, + ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); + + psurf = drawable->dri1_surface; + } + + return psurf; +} + +static struct pipe_context * +dri1_get_pipe_context(struct dri_drawable *drawable) +{ + struct dri_screen *screen = dri_screen(drawable->sPriv); + struct pipe_context *pipe = screen->dri1_pipe; + + if (!pipe) { + screen->dri1_pipe = + screen->pipe_screen->context_create(screen->pipe_screen, NULL); + pipe = screen->dri1_pipe; + } + + return pipe; +} + +static void +dri1_present_texture_locked(__DRIdrawable * dPriv, + struct pipe_texture *ptex, + const struct drm_clip_rect *sub_box, + struct pipe_fence_handle **fence) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_context *pipe; + struct pipe_surface *psurf; struct drm_clip_rect bbox; boolean visible = TRUE; *fence = NULL; - dri1_lock(ctx); - save_lost_lock = ctx->stLostLock; - dri1_update_drawables_locked(ctx, dPriv, dPriv); - st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h); - bbox.x1 = 0; - bbox.x2 = cur_w; + bbox.x2 = ptex->width0; bbox.y1 = 0; - bbox.y2 = cur_h; + bbox.y2 = ptex->height0; if (sub_box) visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box); + if (!visible) + return; - if (visible && __dri1_api_hooks->present_locked) { - - __dri1_api_hooks->present_locked(pipe, - surf, - dPriv->pClipRects, - dPriv->numClipRects, - dPriv->x, dPriv->y, &bbox, fence); - - } else if (visible && __dri1_api_hooks->front_srf_locked) { + pipe = dri1_get_pipe_context(drawable); + psurf = dri1_get_pipe_surface(drawable, ptex); + if (!pipe || !psurf) + return; + if (__dri1_api_hooks->present_locked) { + __dri1_api_hooks->present_locked(pipe, psurf, + dPriv->pClipRects, dPriv->numClipRects, + dPriv->x, dPriv->y, &bbox, fence); + } else if (__dri1_api_hooks->front_srf_locked) { struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe); if (front) - dri1_swap_copy(ctx, front, surf, dPriv, &bbox); + dri1_swap_copy(pipe, front, psurf, dPriv, &bbox); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence); + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, fence); } +} + +static void +dri1_copy_to_front(struct dri_context *ctx, + struct pipe_texture *ptex, + __DRIdrawable * dPriv, + const struct drm_clip_rect *sub_box, + struct pipe_fence_handle **fence) +{ + boolean save_lost_lock; + + dri1_lock(ctx); + save_lost_lock = ctx->stLostLock; + dri1_update_drawables_locked(ctx, dPriv, dPriv); + + dri1_present_texture_locked(dPriv, ptex, sub_box, fence); ctx->stLostLock = save_lost_lock; @@ -296,14 +318,23 @@ dri1_copy_to_front(struct dri_context *ctx, } void -dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) +dri1_flush_frontbuffer(struct dri_drawable *drawable, + struct pipe_texture *ptex) { - struct dri_context *ctx = (struct dri_context *)context_private; + struct st_api *stapi = dri_get_st_api(); + struct dri_screen *screen = dri_screen(drawable->sPriv); + struct pipe_screen *pipe_screen = screen->pipe_screen; + struct dri_context *ctx; struct pipe_fence_handle *dummy_fence; + struct st_context_iface *st = stapi->get_current(stapi); - dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence); - screen->fence_reference(screen, &dummy_fence, NULL); + if (!st) + return; + + ctx = (struct dri_context *) st->st_manager_private; + + dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence); + pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL); /** * FIXME: Do we need swap throttling here? @@ -313,66 +344,127 @@ dri1_flush_frontbuffer(struct pipe_screen *screen, void dri1_swap_buffers(__DRIdrawable * dPriv) { - struct dri_context *ctx; - struct pipe_surface *back_surf; + struct dri_context *ctx = dri_get_current(); struct dri_drawable *draw = dri_drawable(dPriv); - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct dri_screen *screen = dri_screen(draw->sPriv); + struct pipe_screen *pipe_screen = screen->pipe_screen; struct pipe_fence_handle *fence; - struct st_context *st = st_get_current(); + struct pipe_texture *ptex; assert(__dri1_api_hooks != NULL); - if (!st) + if (!ctx) return; /* For now */ - ctx = (struct dri_context *)st->pipe->priv; - - st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - if (back_surf) { - st_notify_swapbuffers(draw->stfb); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT]; + if (ptex) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); fence = dri_swap_fences_pop_front(draw); if (fence) { - (void)screen->fence_finish(screen, fence, 0); - screen->fence_reference(screen, &fence, NULL); + (void)pipe_screen->fence_finish(pipe_screen, fence, 0); + pipe_screen->fence_reference(pipe_screen, &fence, NULL); } - dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence); + dri1_copy_to_front(ctx, ptex, dPriv, NULL, &fence); dri_swap_fences_push_back(draw, fence); - screen->fence_reference(screen, &fence, NULL); + pipe_screen->fence_reference(pipe_screen, &fence, NULL); } } void dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) { - struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen; + struct dri_context *ctx = dri_get_current(); + struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); + struct pipe_screen *pipe_screen = screen->pipe_screen; struct drm_clip_rect sub_bbox; - struct dri_context *ctx; - struct pipe_surface *back_surf; struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_fence_handle *dummy_fence; - struct st_context *st = st_get_current(); + struct pipe_texture *ptex; assert(__dri1_api_hooks != NULL); - if (!st) + if (!ctx) return; - ctx = (struct dri_context *)st->pipe->priv; - sub_bbox.x1 = x; sub_bbox.x2 = x + w; sub_bbox.y1 = y; sub_bbox.y2 = y + h; - st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - if (back_surf) { - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence); - screen->fence_reference(screen, &dummy_fence, NULL); + ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT]; + if (ptex) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + dri1_copy_to_front(ctx, ptex, dPriv, &sub_bbox, &dummy_fence); + pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL); } } +void +dri1_allocate_textures(struct dri_drawable *drawable, + unsigned width, unsigned height, + unsigned mask) +{ + struct dri_screen *screen = dri_screen(drawable->sPriv); + struct pipe_texture templ; + int i; + + /* remove outdated textures */ + if (drawable->old_w != width || drawable->old_h != height) { + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + } + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.width0 = width; + templ.height0 = height; + templ.depth0 = 1; + templ.last_level = 0; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + enum pipe_format format; + unsigned tex_usage; + + /* the texture already exists or not requested */ + if (drawable->textures[i] || !(mask & (1 << i))) { + /* remember the texture */ + if (drawable->textures[i]) + mask |= (1 << i); + continue; + } + + switch (i) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + format = drawable->stvis.color_format; + tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_RENDER_TARGET; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + format = drawable->stvis.depth_stencil_format; + tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + break; + default: + format = PIPE_FORMAT_NONE; + break; + } + + if (templ.format != PIPE_FORMAT_NONE) { + templ.format = format; + templ.tex_usage = tex_usage; + + drawable->textures[i] = + screen->pipe_screen->texture_create(screen->pipe_screen, &templ); + } + } + + drawable->old_w = width; + drawable->old_h = height; + drawable->texture_mask = mask; +} + static void st_dri_lock(struct pipe_context *pipe) { @@ -469,7 +561,6 @@ dri1_init_screen(__DRIscreen * sPriv) __dri1_api_hooks = arg.api; - screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer; driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index e525ce64c3f..e83571e57be 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -34,6 +34,8 @@ #include "dri_context.h" #include "dri_drawable.h" + +#include "state_tracker/st_api.h" #include "dri_util.h" extern struct dri1_api *__dri1_api_hooks; @@ -42,12 +44,13 @@ const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv); void -dri1_update_drawables(struct dri_context *ctx, - struct dri_drawable *draw, struct dri_drawable *read); +dri1_flush_frontbuffer(struct dri_drawable *drawable, + struct pipe_texture *ptex); void -dri1_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private); +dri1_allocate_textures(struct dri_drawable *drawable, + unsigned width, unsigned height, + unsigned mask); void dri1_swap_buffers(__DRIdrawable * dPriv); diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 8e74d3b9bf1..c1848b026cd 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -32,9 +32,9 @@ #include "dri_screen.h" #include "dri_drawable.h" #include "dri_context.h" +#include "dri_st_api.h" #include "dri1.h" -#include "state_tracker/st_public.h" #include "pipe/p_context.h" #include "util/u_memory.h" @@ -42,10 +42,12 @@ GLboolean dri_create_context(const __GLcontextModes * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { + struct st_api *stapi = dri_get_st_api(); __DRIscreen *sPriv = cPriv->driScreenPriv; struct dri_screen *screen = dri_screen(sPriv); struct dri_context *ctx = NULL; - struct st_context *st_share = NULL; + struct st_context_iface *st_share = NULL; + struct st_visual stvis; if (sharedContextPrivate) { st_share = ((struct dri_context *)sharedContextPrivate)->st; @@ -59,21 +61,15 @@ dri_create_context(const __GLcontextModes * visual, ctx->cPriv = cPriv; ctx->sPriv = sPriv; ctx->lock = screen->drmLock; - ctx->d_stamp = -1; - ctx->r_stamp = -1; driParseConfigFiles(&ctx->optionCache, &screen->optionCache, sPriv->myNum, "dri"); - ctx->pipe = screen->pipe_screen->context_create( screen->pipe_screen, - ctx ); - - if (ctx->pipe == NULL) - goto fail; - - ctx->st = st_create_context(ctx->pipe, visual, st_share); + dri_fill_st_visual(&stvis, screen, visual); + ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share); if (ctx->st == NULL) goto fail; + ctx->st->st_manager_private = (void *) ctx; dri_init_extensions(ctx); @@ -81,10 +77,7 @@ dri_create_context(const __GLcontextModes * visual, fail: if (ctx && ctx->st) - st_destroy_context(ctx->st); - - if (ctx && ctx->pipe) - ctx->pipe->destroy(ctx->pipe); + ctx->st->destroy(ctx->st); FREE(ctx); return FALSE; @@ -106,11 +99,8 @@ dri_destroy_context(__DRIcontext * cPriv) * to avoid having to add code elsewhere to cope with flushing a * partially destroyed context. */ - st_flush(ctx->st, 0, NULL); - - /* Also frees ctx->pipe? - */ - st_destroy_context(ctx->st); + ctx->st->flush(ctx->st, 0, NULL); + ctx->st->destroy(ctx->st); FREE(ctx); } @@ -118,14 +108,16 @@ dri_destroy_context(__DRIcontext * cPriv) GLboolean dri_unbind_context(__DRIcontext * cPriv) { + struct st_api *stapi = dri_get_st_api(); + if (cPriv) { struct dri_context *ctx = dri_context(cPriv); if (--ctx->bind_count == 0) { - if (ctx->st && ctx->st == st_get_current()) { - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - st_make_current(NULL, NULL, NULL, NULL); - } + if (ctx->st == stapi->get_current(stapi)) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + stapi->make_current(stapi, NULL, NULL, NULL); + } } } @@ -137,45 +129,47 @@ dri_make_current(__DRIcontext * cPriv, __DRIdrawable * driDrawPriv, __DRIdrawable * driReadPriv) { + struct st_api *stapi = dri_get_st_api(); + if (cPriv) { struct dri_context *ctx = dri_context(cPriv); struct dri_drawable *draw = dri_drawable(driDrawPriv); struct dri_drawable *read = dri_drawable(driReadPriv); - struct st_context *old_st = st_get_current(); + struct st_context_iface *old_st; + old_st = stapi->get_current(stapi); if (old_st && old_st != ctx->st) - st_flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL); ++ctx->bind_count; if (ctx->dPriv != driDrawPriv) { ctx->dPriv = driDrawPriv; - ctx->d_stamp = driDrawPriv->lastStamp - 1; + draw->texture_stamp = driDrawPriv->lastStamp - 1; } if (ctx->rPriv != driReadPriv) { ctx->rPriv = driReadPriv; - ctx->r_stamp = driReadPriv->lastStamp - 1; + draw->texture_stamp = driReadPriv->lastStamp - 1; } - /* DRI co-state tracker currently overrides flush_frontbuffer. - * When this is fixed, will need to pass the drawable in the - * fourth parameter here so that when Mesa calls - * flush_frontbuffer directly (in front-buffer rendering), it - * will have access to the drawable argument: - */ - st_make_current(ctx->st, draw->stfb, read->stfb, ctx); - - if (__dri1_api_hooks) { - dri1_update_drawables(ctx, draw, read); - } else { - dri_update_buffer(ctx->pipe->screen, - ctx->pipe->priv); - } - } else { - st_make_current(NULL, NULL, NULL, NULL); + stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb); + } + else { + stapi->make_current(stapi, NULL, NULL, NULL); } return GL_TRUE; } +struct dri_context * +dri_get_current(void) +{ + struct st_api *stapi = dri_get_st_api(); + struct st_context_iface *st; + + st = stapi->get_current(stapi); + + return (struct dri_context *) (st) ? st->st_manager_private : NULL; +} + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h index f0700b9aaff..845b420cf89 100644 --- a/src/gallium/state_trackers/dri/dri_context.h +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -51,9 +51,6 @@ struct dri_context driOptionCache optionCache; - unsigned int d_stamp; - unsigned int r_stamp; - drmLock *lock; boolean isLocked; boolean stLostLock; @@ -62,8 +59,7 @@ struct dri_context unsigned int bind_count; /* gallium */ - struct st_context *st; - struct pipe_context *pipe; + struct st_context_iface *st; }; static INLINE struct dri_context * @@ -84,6 +80,9 @@ dri_make_current(__DRIcontext * driContextPriv, __DRIdrawable * driDrawPriv, __DRIdrawable * driReadPriv); +struct dri_context * +dri_get_current(void); + boolean dri_create_context(const __GLcontextModes * visual, __DRIcontext * driContextPriv, diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 9238f942999..930387f8a67 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -32,249 +32,30 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri_st_api.h" #include "dri1.h" -#include "main/mtypes.h" -#include "main/renderbuffer.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_cb_fbo.h" -#include "state_tracker/drm_api.h" - #include "pipe/p_screen.h" #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_inlines.h" -static struct pipe_surface * -dri_surface_from_handle(struct drm_api *api, - struct pipe_screen *screen, - unsigned handle, - enum pipe_format format, - unsigned width, unsigned height, unsigned pitch) -{ - struct pipe_surface *surface = NULL; - struct pipe_texture *texture = NULL; - struct pipe_texture templat; - struct winsys_handle whandle; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth0 = 1; - templat.format = format; - templat.width0 = width; - templat.height0 = height; - - memset(&whandle, 0, sizeof(whandle)); - whandle.handle = handle; - whandle.stride = pitch; - - texture = screen->texture_from_handle(screen, &templat, &whandle); - - if (!texture) { - debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__); - return NULL; - } - - surface = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* we don't need the texture from this point on */ - pipe_texture_reference(&texture, NULL); - return surface; -} - -/** - * Pixmaps have will have the same name of fake front and front. - */ -static boolean -dri2_check_if_pixmap(__DRIbuffer *buffers, int count) -{ - boolean found = FALSE; - boolean is_pixmap = FALSE; - unsigned name; - int i; - - for (i = 0; i < count; i++) { - switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - case __DRI_BUFFER_FAKE_FRONT_LEFT: - if (found) { - is_pixmap = buffers[i].name == name; - } else { - name = buffers[i].name; - found = TRUE; - } - default: - continue; - } - } - - return is_pixmap; -} - -/** - * This will be called a drawable is known to have been resized. - */ -void -dri_get_buffers(__DRIdrawable * dPriv) -{ - - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *surface = NULL; - struct dri_screen *st_screen = dri_screen(drawable->sPriv); - struct pipe_screen *screen = st_screen->pipe_screen; - __DRIbuffer *buffers = NULL; - __DRIscreen *dri_screen = drawable->sPriv; - __DRIdrawable *dri_drawable = drawable->dPriv; - struct drm_api *api = st_screen->api; - boolean have_depth = FALSE; - int i, count; - - if ((dri_screen->dri2.loader - && (dri_screen->dri2.loader->base.version > 2) - && (dri_screen->dri2.loader->getBuffersWithFormat != NULL))) { - buffers = (*dri_screen->dri2.loader->getBuffersWithFormat) - (dri_drawable, &dri_drawable->w, &dri_drawable->h, - drawable->attachments, drawable->num_attachments, - &count, dri_drawable->loaderPrivate); - } else { - assert(dri_screen->dri2.loader); - buffers = (*dri_screen->dri2.loader->getBuffers) (dri_drawable, - &dri_drawable->w, - &dri_drawable->h, - drawable->attachments, - drawable-> - num_attachments, &count, - dri_drawable-> - loaderPrivate); - } - - if (buffers == NULL) { - return; - } - - /* set one cliprect to cover the whole dri_drawable */ - dri_drawable->x = 0; - dri_drawable->y = 0; - dri_drawable->backX = 0; - dri_drawable->backY = 0; - dri_drawable->numClipRects = 1; - dri_drawable->pClipRects[0].x1 = 0; - dri_drawable->pClipRects[0].y1 = 0; - dri_drawable->pClipRects[0].x2 = dri_drawable->w; - dri_drawable->pClipRects[0].y2 = dri_drawable->h; - dri_drawable->numBackClipRects = 1; - dri_drawable->pBackClipRects[0].x1 = 0; - dri_drawable->pBackClipRects[0].y1 = 0; - dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; - dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; - - if (drawable->old_num == count && - drawable->old_w == dri_drawable->w && - drawable->old_h == dri_drawable->h && - memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) { - return; - } else { - drawable->old_num = count; - drawable->old_w = dri_drawable->w; - drawable->old_h = dri_drawable->h; - memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); - } - - drawable->is_pixmap = dri2_check_if_pixmap(buffers, count); - - for (i = 0; i < count; i++) { - enum pipe_format format = 0; - int index = 0; - - switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - if (!st_screen->auto_fake_front) - continue; - /* fallthrough */ - case __DRI_BUFFER_FAKE_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = drawable->color_format; - break; - case __DRI_BUFFER_BACK_LEFT: - index = ST_SURFACE_BACK_LEFT; - format = drawable->color_format; - break; - case __DRI_BUFFER_DEPTH: - case __DRI_BUFFER_DEPTH_STENCIL: - case __DRI_BUFFER_STENCIL: - index = ST_SURFACE_DEPTH; - format = drawable->depth_stencil_format; - break; - case __DRI_BUFFER_ACCUM: - default: - assert(0); - } - - if (index == ST_SURFACE_DEPTH) { - if (have_depth) - continue; - else - have_depth = TRUE; - } - - surface = dri_surface_from_handle(api, - screen, - buffers[i].name, - format, - dri_drawable->w, - dri_drawable->h, buffers[i].pitch); - - switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - case __DRI_BUFFER_FAKE_FRONT_LEFT: - case __DRI_BUFFER_BACK_LEFT: - drawable->color_format = surface->format; - break; - case __DRI_BUFFER_DEPTH: - case __DRI_BUFFER_DEPTH_STENCIL: - case __DRI_BUFFER_STENCIL: - drawable->depth_stencil_format = surface->format; - break; - case __DRI_BUFFER_ACCUM: - default: - assert(0); - } - - st_set_framebuffer_surface(drawable->stfb, index, surface); - pipe_surface_reference(&surface, NULL); - } - /* this needed, or else the state tracker fails to pick the new buffers */ - st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); -} - /** * These are used for GLX_EXT_texture_from_pixmap */ void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, GLint format, __DRIdrawable *dPriv) { + struct dri_context *ctx = dri_context(pDRICtx); struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *ps; + struct pipe_texture *pt = + dri_get_st_framebuffer_texture(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); - if (!drawable->stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer) { - struct gl_renderbuffer *rb = - st_new_renderbuffer_fb(drawable->color_format, 0 /*XXX*/, FALSE); - _mesa_add_renderbuffer(&drawable->stfb->Base, BUFFER_FRONT_LEFT, rb); + if (pt) { + ctx->st->teximage(ctx->st, + (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, + 0, drawable->stvis.color_format, pt, FALSE); } - - dri_get_buffers(drawable->dPriv); - st_get_framebuffer_surface(drawable->stfb, ST_SURFACE_FRONT_LEFT, &ps); - - if (!ps) - return; - - st_bind_texture_surface(ps, target == GL_TEXTURE_2D ? ST_TEXTURE_2D : - ST_TEXTURE_RECT, 0, drawable->color_format); } void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, @@ -283,53 +64,6 @@ void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); } -void -dri_update_buffer(struct pipe_screen *screen, void *context_private) -{ - struct dri_context *ctx = (struct dri_context *)context_private; - - if (ctx->d_stamp == *ctx->dPriv->pStamp && - ctx->r_stamp == *ctx->rPriv->pStamp) - return; - - ctx->d_stamp = *ctx->dPriv->pStamp; - ctx->r_stamp = *ctx->rPriv->pStamp; - - /* Ask the X server for new renderbuffers. */ - dri_get_buffers(ctx->dPriv); - if (ctx->dPriv != ctx->rPriv) - dri_get_buffers(ctx->rPriv); - -} - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) -{ - struct dri_context *ctx = (struct dri_context *)context_private; - struct dri_drawable *drawable = dri_drawable(ctx->dPriv); - __DRIdrawable *dri_drawable = ctx->dPriv; - __DRIscreen *dri_screen = ctx->sPriv; - - /* XXX Does this function get called with DRI1? */ - - if (ctx->dPriv == NULL) { - debug_printf("%s: no drawable bound to context\n", __func__); - return; - } - -#if 0 - /* TODO if rendering to pixmaps is slow enable this code. */ - if (drawable->is_pixmap) - return; -#else - (void)drawable; -#endif - - (*dri_screen->dri2.loader->flushFrontBuffer)(dri_drawable, - dri_drawable->loaderPrivate); -} - /** * This is called when we need to set up GL rendering to a new X window. */ @@ -340,7 +74,6 @@ dri_create_buffer(__DRIscreen * sPriv, { struct dri_screen *screen = sPriv->private; struct dri_drawable *drawable = NULL; - int i; if (isPixmap) goto fail; /* not implemented */ @@ -349,45 +82,8 @@ dri_create_buffer(__DRIscreen * sPriv, if (drawable == NULL) goto fail; - if (visual->redBits == 8) { - if (visual->alphaBits == 8) - drawable->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; - else - drawable->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; - } else { - drawable->color_format = PIPE_FORMAT_B5G6R5_UNORM; - } - - switch(visual->depthBits) { - default: - case 0: - drawable->depth_stencil_format = PIPE_FORMAT_NONE; - break; - case 16: - drawable->depth_stencil_format = PIPE_FORMAT_Z16_UNORM; - break; - case 24: - if (visual->stencilBits == 0) { - drawable->depth_stencil_format = (screen->d_depth_bits_last) ? - PIPE_FORMAT_Z24X8_UNORM: - PIPE_FORMAT_X8Z24_UNORM; - } else { - drawable->depth_stencil_format = (screen->sd_depth_bits_last) ? - PIPE_FORMAT_Z24S8_UNORM: - PIPE_FORMAT_S8Z24_UNORM; - } - break; - case 32: - drawable->depth_stencil_format = PIPE_FORMAT_Z32_UNORM; - break; - } - - drawable->stfb = st_create_framebuffer(visual, - drawable->color_format, - drawable->depth_stencil_format, - drawable->depth_stencil_format, - dPriv->w, - dPriv->h, (void *)drawable); + dri_fill_st_visual(&drawable->stvis, screen, visual); + drawable->stfb = dri_create_st_framebuffer(drawable); if (drawable->stfb == NULL) goto fail; @@ -395,48 +91,6 @@ dri_create_buffer(__DRIscreen * sPriv, drawable->dPriv = dPriv; dPriv->driverPrivate = (void *)drawable; - /* setup dri2 buffers information */ - /* TODO incase of double buffer visual, delay fake creation */ - i = 0; - if (sPriv->dri2.loader - && (sPriv->dri2.loader->base.version > 2) - && (sPriv->dri2.loader->getBuffersWithFormat != NULL)) { - drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - drawable->attachments[i++] = visual->rgbBits; - if (!screen->auto_fake_front) { - drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; - drawable->attachments[i++] = visual->rgbBits; - } - if (visual->doubleBufferMode) { - drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; - drawable->attachments[i++] = visual->rgbBits; - } - if (visual->depthBits && visual->stencilBits) { - drawable->attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL; - drawable->attachments[i++] = visual->depthBits + visual->stencilBits; - } else if (visual->depthBits) { - drawable->attachments[i++] = __DRI_BUFFER_DEPTH; - drawable->attachments[i++] = visual->depthBits; - } else if (visual->stencilBits) { - drawable->attachments[i++] = __DRI_BUFFER_STENCIL; - drawable->attachments[i++] = visual->stencilBits; - } - drawable->num_attachments = i / 2; - } else { - drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - if (!screen->auto_fake_front) - drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; - if (visual->doubleBufferMode) - drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; - if (visual->depthBits && visual->stencilBits) - drawable->attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL; - else if (visual->depthBits) - drawable->attachments[i++] = __DRI_BUFFER_DEPTH; - else if (visual->stencilBits) - drawable->attachments[i++] = __DRI_BUFFER_STENCIL; - drawable->num_attachments = i; - } - drawable->desired_fences = 2; return GL_TRUE; @@ -449,12 +103,18 @@ void dri_destroy_buffer(__DRIdrawable * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); - - st_unreference_framebuffer(drawable->stfb); - drawable->desired_fences = 0; + int i; dri1_swap_fences_clear(drawable); + pipe_surface_reference(&drawable->dri1_surface, NULL); + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + + dri_destroy_st_framebuffer(drawable->stfb); + + drawable->desired_fences = 0; + FREE(drawable); } diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index ea66c483a1e..7f687b65f23 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -46,20 +46,15 @@ struct dri_drawable __DRIdrawable *dPriv; __DRIscreen *sPriv; - unsigned attachments[8]; - unsigned num_attachments; - - boolean is_pixmap; + /* gallium */ + struct st_framebuffer_iface *stfb; + struct st_visual stvis; __DRIbuffer old[8]; unsigned old_num; unsigned old_w; unsigned old_h; - /* gallium */ - struct st_framebuffer *stfb; - struct st_visual stvis; - struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; unsigned int texture_mask, texture_stamp; @@ -69,8 +64,8 @@ struct dri_drawable unsigned int desired_fences; unsigned int cur_fences; - enum pipe_format color_format; - enum pipe_format depth_stencil_format; + /* used only by DRI1 */ + struct pipe_surface *dri1_surface; }; static INLINE struct dri_drawable * @@ -87,15 +82,6 @@ dri_create_buffer(__DRIscreen * sPriv, __DRIdrawable * dPriv, const __GLcontextModes * visual, boolean isPixmap); -void -dri_update_buffer(struct pipe_screen *screen, void *context_private); - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private); - -void dri_get_buffers(__DRIdrawable * dPriv); - void dri_destroy_buffer(__DRIdrawable * dPriv); void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 800677a2d1e..df458e1eb0f 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -38,9 +38,11 @@ void dri_init_extensions(struct dri_context *ctx) { + struct st_context *st = (struct st_context *) ctx->st; + /* New extensions should be added in mesa/state_tracker/st_extensions.c * and not in this file. */ - driInitExtensions(ctx->st->ctx, NULL, GL_FALSE); + driInitExtensions(st->ctx, NULL, GL_FALSE); } /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index cffe3b33b2f..17b9f1c5faf 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -36,8 +36,10 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri_st_api.h" #include "dri1.h" +#include "util/u_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_format.h" #include "state_tracker/drm_api.h" @@ -66,10 +68,23 @@ dri2_flush_drawable(__DRIdrawable *draw) { } +static void +dri2_invalidate_drawable(__DRIdrawable *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct dri_context *ctx = dri_context(dPriv->driContextPriv); + + dri2InvalidateDrawable(dPriv); + drawable->dPriv->lastStamp = *drawable->dPriv->pStamp; + + if (ctx) + ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); +} + static const __DRI2flushExtension dri2FlushExtension = { { __DRI2_FLUSH, __DRI2_FLUSH_VERSION }, dri2_flush_drawable, - dri2InvalidateDrawable, + dri2_invalidate_drawable, }; static const __DRIextension *dri_screen_extensions[] = { @@ -226,6 +241,68 @@ dri_fill_in_modes(struct dri_screen *screen, return (const __DRIconfig **)configs; } +/** + * Roughly the converse of dri_fill_in_modes. + */ +void +dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, + const __GLcontextModes *mode) +{ + memset(stvis, 0, sizeof(*stvis)); + + stvis->samples = mode->samples; + stvis->render_buffer = ST_ATTACHMENT_INVALID; + + if (mode->redBits == 8) { + if (mode->alphaBits == 8) + stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; + else + stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; + } else { + stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM; + } + + switch (mode->depthBits) { + default: + case 0: + stvis->depth_stencil_format = PIPE_FORMAT_NONE; + break; + case 16: + stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM; + break; + case 24: + if (mode->stencilBits == 0) { + stvis->depth_stencil_format = (screen->d_depth_bits_last) ? + PIPE_FORMAT_Z24X8_UNORM: + PIPE_FORMAT_X8Z24_UNORM; + } else { + stvis->depth_stencil_format = (screen->sd_depth_bits_last) ? + PIPE_FORMAT_Z24S8_UNORM: + PIPE_FORMAT_S8Z24_UNORM; + } + break; + case 32: + stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM; + break; + } + + stvis->accum_format = (mode->haveAccumBuffer) ? + PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE; + + stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK; + if (mode->doubleBufferMode) + stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; + if (mode->stereoMode) { + stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK; + if (mode->doubleBufferMode) + stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK; + } + + if (mode->haveDepthBuffer || mode->haveStencilBuffer) + stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK; + /* let the state tracker allocate the accum buffer */ +} + /** * Get information about previous buffer swaps. */ @@ -238,6 +315,33 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) return 0; } +static void +dri_destroy_screen(__DRIscreen * sPriv) +{ + struct dri_screen *screen = dri_screen(sPriv); + int i; + + if (screen->dri1_pipe) + screen->dri1_pipe->destroy(screen->dri1_pipe); + + if (screen->smapi) + dri_destroy_st_manager(screen->smapi); + if (screen->pipe_screen) + screen->pipe_screen->destroy(screen->pipe_screen); + + for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { + FREE(screen->optionCache.info[i].name); + FREE(screen->optionCache.info[i].ranges); + } + + FREE(screen->optionCache.info); + FREE(screen->optionCache.values); + + FREE(screen); + sPriv->private = NULL; + sPriv->extensions = NULL; +} + /** * This is the driver specific part of the createNewScreen entry point. * @@ -253,7 +357,7 @@ dri_init_screen2(__DRIscreen * sPriv) screen = CALLOC_STRUCT(dri_screen); if (!screen) - goto fail; + return NULL; screen->api = drm_api_create(); screen->sPriv = sPriv; @@ -268,9 +372,9 @@ dri_init_screen2(__DRIscreen * sPriv) goto fail; } - /* We need to hook in here */ - screen->pipe_screen->update_buffer = dri_update_buffer; - screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; + screen->smapi = dri_create_st_manager(screen); + if (!screen->smapi) + goto fail; driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); @@ -279,30 +383,11 @@ dri_init_screen2(__DRIscreen * sPriv) dri2_ext->getBuffersWithFormat != NULL; return dri_fill_in_modes(screen, 32); - fail: +fail: + dri_destroy_screen(sPriv); return NULL; } -static void -dri_destroy_screen(__DRIscreen * sPriv) -{ - struct dri_screen *screen = dri_screen(sPriv); - int i; - - screen->pipe_screen->destroy(screen->pipe_screen); - - for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { - FREE(screen->optionCache.info[i].name); - FREE(screen->optionCache.info[i].ranges); - } - - FREE(screen->optionCache.info); - FREE(screen->optionCache.values); - - FREE(screen); - sPriv->private = NULL; -} - const struct __DriverAPIRec driDriverAPI = { .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 31301356923..e9944e0f63e 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -36,6 +36,9 @@ #include "xmlconfig.h" #include "pipe/p_compiler.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "state_tracker/st_api.h" struct dri_screen { @@ -58,6 +61,11 @@ struct dri_screen boolean d_depth_bits_last; boolean sd_depth_bits_last; boolean auto_fake_front; + + struct st_manager *smapi; + + /* used only by DRI1 */ + struct pipe_context *dri1_pipe; }; /** cast wrapper */ @@ -72,6 +80,10 @@ extern const uint __driNConfigOptions; const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits); +void +dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, + const __GLcontextModes *mode); + #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 379515152e8..2cde01967d8 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -274,8 +274,8 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, if (drawable->texture_stamp != drawable->dPriv->lastStamp || (statt_mask & ~drawable->texture_mask)) { if (__dri1_api_hooks) { - /* TODO */ - return FALSE; + dri1_allocate_textures(drawable, + drawable->dPriv->w, drawable->dPriv->h, statt_mask); } else { __DRIbuffer *buffers; @@ -309,9 +309,12 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; - /* TODO */ - if (__dri1_api_hooks) - return FALSE; + if (__dri1_api_hooks) { + struct pipe_texture *ptex = drawable->textures[statt]; + if (ptex) + dri1_flush_frontbuffer(drawable, ptex); + return TRUE; + } if (statt == ST_ATTACHMENT_FRONT_LEFT && loader->flushFrontBuffer) { loader->flushFrontBuffer(drawable->dPriv, From a0d615fd978aaa2e8ca2d31cb574f5de3890e140 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 18 Mar 2010 09:24:10 +0800 Subject: [PATCH 146/483] st/mesa: Set the pipe context of the texture object. The field was added in b8030c6561e019e079b5be2fe64ec804df4bfa03. This fixes a NULL dereference in xdemos/texture_from_pixmap. --- src/mesa/state_tracker/st_manager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 1b005c1ee17..6ec4c8d792c 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -553,6 +553,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target _mesa_clear_texture_image(ctx, texImage); } + stObj->pipe = st->pipe; pipe_texture_reference(&stImage->pt, tex); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); From 6de8e563ac4dad818fc2bfea23f557919ed36234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 17 Mar 2010 22:44:58 -0400 Subject: [PATCH 147/483] intel: Call _mesa_make_current() after getting initial buffers The default viewport is the window rectangle, which is set up by _mesa_make_current(). To be able to do that we need to get the window dimension (and buffers) first, so we have to call intel_prepare_render() before we can call into _mesa_make_current(). Fixes #26676 and #26678. --- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index d6a1ba69524..c86dd1d0d98 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -880,12 +880,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv, struct gl_framebuffer *fb = driDrawPriv->driverPrivate; struct gl_framebuffer *readFb = driReadPriv->driverPrivate; - _mesa_make_current(&intel->ctx, fb, readFb); intel->driReadDrawable = driReadPriv; intel->driDrawable = driDrawPriv; driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1; driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1; intel_prepare_render(intel); + _mesa_make_current(&intel->ctx, fb, readFb); } else { _mesa_make_current(NULL, NULL, NULL); From 9d48a621d2a0e55a76a2cfd0aea3b773e907ed50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 18 Mar 2010 10:24:10 +0000 Subject: [PATCH 148/483] llvmpipe: Fix crashes when there is no depth buffer bound. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index b38e0f393dc..2cecf7e0974 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -152,6 +152,9 @@ generate_depth_stencil(LLVMBuilderRef builder, const struct util_format_description *format_desc; struct lp_type dst_type; + if (!key->depth.enabled && !key->stencil[0].enabled && !key->stencil[1].enabled) + return; + format_desc = util_format_description(key->zsbuf_format); assert(format_desc); From 38bd7282f2c2d28681f1c242545727e4c36df113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 17 Mar 2010 22:44:58 -0400 Subject: [PATCH 149/483] intel: Call _mesa_make_current() after getting initial buffers The default viewport is the window rectangle, which is set up by _mesa_make_current(). To be able to do that we need to get the window dimension (and buffers) first, so we have to call intel_prepare_render() before we can call into _mesa_make_current(). Fixes #26676 and #26678. --- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index d6a1ba69524..c86dd1d0d98 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -880,12 +880,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv, struct gl_framebuffer *fb = driDrawPriv->driverPrivate; struct gl_framebuffer *readFb = driReadPriv->driverPrivate; - _mesa_make_current(&intel->ctx, fb, readFb); intel->driReadDrawable = driReadPriv; intel->driDrawable = driDrawPriv; driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1; driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1; intel_prepare_render(intel); + _mesa_make_current(&intel->ctx, fb, readFb); } else { _mesa_make_current(NULL, NULL, NULL); From 50be9bc6ce8582b3d3cd4fa47976cbeac28b8c26 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sat, 13 Mar 2010 19:28:07 +0100 Subject: [PATCH 150/483] dri/nouveau: only reallocate texture when needed nouveau reallocated the mipmap tree on every MIN_FILTER call to account for mipmap change. We only need to do this if the texture does not fit in the existing mipmap tree. This gives a big performance boost for a game like bzflag which changes MIN_FILTER all the time for its font rendering. Signed-off-by: Xavier Chantry Signed-off-by: Francisco Jerez --- .../drivers/dri/nouveau/nouveau_texture.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index bf365bfca34..20bc0f6688f 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -177,15 +177,15 @@ nouveau_choose_tex_format(GLcontext *ctx, GLint internalFormat, } static GLboolean -teximage_fits(struct gl_texture_object *t, int level, - struct gl_texture_image *ti) +teximage_fits(struct gl_texture_object *t, int level) { struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level]; + struct gl_texture_image *ti = t->Image[0][level]; - return t->Target == GL_TEXTURE_RECTANGLE || - (s->bo && s->width == ti->Width && - s->height == ti->Height && - s->format == ti->TexFormat); + return ti && (t->Target == GL_TEXTURE_RECTANGLE || + (s->bo && s->width == ti->Width && + s->height == ti->Height && + s->format == ti->TexFormat)); } static GLboolean @@ -195,7 +195,7 @@ validate_teximage(GLcontext *ctx, struct gl_texture_object *t, { struct gl_texture_image *ti = t->Image[0][level]; - if (ti && teximage_fits(t, level, ti)) { + if (teximage_fits(t, level)) { struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces; struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface; @@ -304,9 +304,12 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t) void nouveau_texture_reallocate(GLcontext *ctx, struct gl_texture_object *t) { - texture_dirty(t); - relayout_texture(ctx, t); - nouveau_texture_validate(ctx, t); + if (!teximage_fits(t, t->BaseLevel) || + !teximage_fits(t, get_last_level(t))) { + texture_dirty(t); + relayout_texture(ctx, t); + nouveau_texture_validate(ctx, t); + } } static unsigned @@ -364,7 +367,7 @@ nouveau_teximage(GLcontext *ctx, GLint dims, GLenum target, GLint level, } if (level == t->BaseLevel) { - if (!teximage_fits(t, level, ti)) + if (!teximage_fits(t, level)) relayout_texture(ctx, t); nouveau_texture_validate(ctx, t); } From d475eae50b15646efd83fa7f73ad7f2b40dd5206 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 11 Mar 2010 21:48:51 +0100 Subject: [PATCH 151/483] dri/nouveau: Some minor vertex submission fixes. --- .../drivers/dri/nouveau/nouveau_render_t.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c index c0505781cfe..7ccd7e64165 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c @@ -254,7 +254,7 @@ get_scratch_vbo(GLcontext *ctx, unsigned size, struct nouveau_bo **bo, */ static inline unsigned get_max_vertices(GLcontext *ctx, const struct _mesa_index_buffer *ib, - unsigned n) + int n) { struct nouveau_render_state *render = to_render_state(ctx); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index a365b977f29..f20a7df45ec 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -244,17 +244,20 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays) } static unsigned -get_max_client_stride(GLcontext *ctx) +get_max_client_stride(GLcontext *ctx, const struct gl_client_array **arrays) { struct nouveau_render_state *render = to_render_state(ctx); int i, s = 0; for (i = 0; i < render->attr_count; i++) { int attr = render->map[i]; - struct nouveau_array_state *a = &render->attrs[attr]; - if (attr >= 0 && !a->bo) - s = MAX2(a->stride, s); + if (attr >= 0) { + const struct gl_client_array *a = arrays[attr]; + + if (!_mesa_is_bufferobj(a->BufferObj)) + s = MAX2(a->StrideB, s); + } } return s; @@ -275,14 +278,15 @@ vbo_maybe_split(GLcontext *ctx, const struct gl_client_array **arrays, { struct nouveau_context *nctx = to_nouveau_context(ctx); struct nouveau_render_state *render = to_render_state(ctx); - unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * nctx->bo.count, + unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * (nctx->bo.count + + render->attr_count), vert_avail = get_max_vertices(ctx, NULL, pushbuf_avail), idx_avail = get_max_vertices(ctx, ib, pushbuf_avail); int stride; /* Try to keep client buffers smaller than the scratch BOs. */ if (render->mode == VBO && - (stride = get_max_client_stride(ctx))) + (stride = get_max_client_stride(ctx, arrays))) vert_avail = MIN2(vert_avail, RENDER_SCRATCH_SIZE / stride); @@ -371,8 +375,6 @@ vbo_draw_vbo(GLcontext *ctx, const struct gl_client_array **arrays, dispatch(ctx, start, delta, count); BATCH_END(); } - - FIRE_RING(chan); } /* Immediate rendering path. */ @@ -416,8 +418,6 @@ vbo_draw_imm(GLcontext *ctx, const struct gl_client_array **arrays, BATCH_END(); } - - FIRE_RING(chan); } /* draw_prims entry point when we're doing hw-tnl. */ From 1a812ab57a71d16e45ca44de7ae0570d2bd46674 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 18 Mar 2010 14:13:36 +0100 Subject: [PATCH 152/483] dri/nouveau: Implement texture matrices. --- src/mesa/drivers/dri/nouveau/nouveau_state.c | 7 ++++++ src/mesa/drivers/dri/nouveau/nouveau_state.h | 4 +++ src/mesa/drivers/dri/nouveau/nv04_context.c | 4 +++ src/mesa/drivers/dri/nouveau/nv10_context.c | 4 +++ src/mesa/drivers/dri/nouveau/nv10_driver.h | 3 +++ src/mesa/drivers/dri/nouveau/nv10_state_tex.c | 25 +++++++++++++++++++ src/mesa/drivers/dri/nouveau/nv20_context.c | 4 +++ src/mesa/drivers/dri/nouveau/nv20_driver.h | 3 +++ src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 24 ++++++++++++++++++ 9 files changed, 78 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index bc610451b40..603a46ed242 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -454,12 +454,19 @@ nouveau_state_emit(GLcontext *ctx) static void nouveau_update_state(GLcontext *ctx, GLbitfield new_state) { + int i; + if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW)) context_dirty(ctx, PROJECTION); if (new_state & _NEW_MODELVIEW) context_dirty(ctx, MODELVIEW); + if (new_state & _NEW_TEXTURE_MATRIX) { + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) + context_dirty_i(ctx, TEX_MAT, i); + } + if (new_state & _NEW_CURRENT_ATTRIB && new_state & _NEW_LIGHT) { context_dirty(ctx, MATERIAL_FRONT_AMBIENT); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.h b/src/mesa/drivers/dri/nouveau/nouveau_state.h index d01d962c9f2..38ac9753c8c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.h @@ -89,6 +89,10 @@ enum { NOUVEAU_STATE_TEX_GEN1, NOUVEAU_STATE_TEX_GEN2, NOUVEAU_STATE_TEX_GEN3, + NOUVEAU_STATE_TEX_MAT0, + NOUVEAU_STATE_TEX_MAT1, + NOUVEAU_STATE_TEX_MAT2, + NOUVEAU_STATE_TEX_MAT3, NOUVEAU_STATE_TEX_OBJ0, NOUVEAU_STATE_TEX_OBJ1, NOUVEAU_STATE_TEX_OBJ2, diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 3624b3af921..6834f7cd3dc 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -276,6 +276,10 @@ const struct nouveau_driver nv04_driver = { nouveau_emit_nothing, nouveau_emit_nothing, nouveau_emit_nothing, + nouveau_emit_nothing, + nouveau_emit_nothing, + nouveau_emit_nothing, + nouveau_emit_nothing, nv04_emit_tex_obj, nv04_emit_tex_obj, nouveau_emit_nothing, diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index 860d0aeb8f5..d008063d3c4 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -412,6 +412,10 @@ const struct nouveau_driver nv10_driver = { nv10_emit_tex_gen, nouveau_emit_nothing, nouveau_emit_nothing, + nv10_emit_tex_mat, + nv10_emit_tex_mat, + nouveau_emit_nothing, + nouveau_emit_nothing, nv10_emit_tex_obj, nv10_emit_tex_obj, nouveau_emit_nothing, diff --git a/src/mesa/drivers/dri/nouveau/nv10_driver.h b/src/mesa/drivers/dri/nouveau/nv10_driver.h index d662712533b..cefd6c6fba8 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv10_driver.h @@ -133,6 +133,9 @@ nv10_emit_frag(GLcontext *ctx, int emit); void nv10_emit_tex_gen(GLcontext *ctx, int emit); +void +nv10_emit_tex_mat(GLcontext *ctx, int emit); + void nv10_emit_tex_obj(GLcontext *ctx, int emit); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c index 02a5ca797ae..92148722af7 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c @@ -32,11 +32,36 @@ #include "nouveau_util.h" #include "nv10_driver.h" +#define TX_MATRIX(i) (NV10TCL_TX0_MATRIX(0) + 64 * (i)) + void nv10_emit_tex_gen(GLcontext *ctx, int emit) { } +void +nv10_emit_tex_mat(GLcontext *ctx, int emit) +{ + const int i = emit - NOUVEAU_STATE_TEX_MAT0; + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_grobj *celsius = context_eng3d(ctx); + + if (nctx->fallback == HWTNL && + ((ctx->Texture._TexMatEnabled & 1 << i) || + ctx->Texture.Unit[i]._GenFlags)) { + BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1); + OUT_RING(chan, 1); + + BEGIN_RING(chan, celsius, TX_MATRIX(i), 16); + OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m); + + } else { + BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1); + OUT_RING(chan, 0); + } +} + static uint32_t get_tex_format_pot(struct gl_texture_image *ti) { diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index db39ef70750..99df34716fc 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -501,6 +501,10 @@ const struct nouveau_driver nv20_driver = { nv10_emit_tex_gen, nv10_emit_tex_gen, nv10_emit_tex_gen, + nv20_emit_tex_mat, + nv20_emit_tex_mat, + nv20_emit_tex_mat, + nv20_emit_tex_mat, nv20_emit_tex_obj, nv20_emit_tex_obj, nv20_emit_tex_obj, diff --git a/src/mesa/drivers/dri/nouveau/nv20_driver.h b/src/mesa/drivers/dri/nouveau/nv20_driver.h index 18574e9be64..05770b2d6cf 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv20_driver.h @@ -67,6 +67,9 @@ void nv20_emit_frag(GLcontext *ctx, int emit); /* nv20_state_tex.c */ +void +nv20_emit_tex_mat(GLcontext *ctx, int emit); + void nv20_emit_tex_obj(GLcontext *ctx, int emit); diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index 92870105f96..d7ac4c57bce 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -32,6 +32,30 @@ #include "nouveau_util.h" #include "nv20_driver.h" +#define TX_MATRIX(i) (NV20TCL_TX0_MATRIX(0) + 64 * (i)) + +void +nv20_emit_tex_mat(GLcontext *ctx, int emit) +{ + const int i = emit - NOUVEAU_STATE_TEX_MAT0; + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_grobj *kelvin = context_eng3d(ctx); + + if (nctx->fallback == HWTNL && + (ctx->Texture._TexMatEnabled & 1 << i)) { + BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1); + OUT_RING(chan, 1); + + BEGIN_RING(chan, kelvin, TX_MATRIX(i), 16); + OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m); + + } else { + BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1); + OUT_RING(chan, 0); + } +} + static uint32_t get_tex_format_pot(struct gl_texture_image *ti) { From c944fb5ffe7cf16154d6395001f43a6c965cab1f Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 18 Mar 2010 14:18:55 +0100 Subject: [PATCH 153/483] dri/nouveau: Implement texcoord generation. --- src/mesa/drivers/dri/nouveau/nouveau_gldefs.h | 19 ++++++++++ src/mesa/drivers/dri/nouveau/nouveau_state.c | 17 ++++++++- src/mesa/drivers/dri/nouveau/nouveau_util.h | 18 ++++++++++ src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 4 ++- src/mesa/drivers/dri/nouveau/nv10_context.c | 2 +- src/mesa/drivers/dri/nouveau/nv10_state_tex.c | 33 +++++++++++++++++ src/mesa/drivers/dri/nouveau/nv10_state_tnl.c | 6 ++-- src/mesa/drivers/dri/nouveau/nv20_context.c | 14 ++++---- src/mesa/drivers/dri/nouveau/nv20_driver.h | 3 ++ src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 35 +++++++++++++++++++ src/mesa/drivers/dri/nouveau/nv20_state_tnl.c | 6 ++-- 11 files changed, 143 insertions(+), 14 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h index 00007a9a351..fbeed3baeab 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h @@ -260,4 +260,23 @@ nvgl_filter_mode(unsigned filter) } } +static inline unsigned +nvgl_texgen_mode(unsigned mode) +{ + switch (mode) { + case GL_EYE_LINEAR: + return 0x2400; + case GL_OBJECT_LINEAR: + return 0x2401; + case GL_SPHERE_MAP: + return 0x2402; + case GL_NORMAL_MAP: + return 0x8511; + case GL_REFLECTION_MAP: + return 0x8512; + default: + assert(0); + } +} + #endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 603a46ed242..ef2cc787de7 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -234,6 +234,13 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state) context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit); context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit); break; + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_Q: + context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); + context_dirty(ctx, MODELVIEW); + break; } } @@ -368,7 +375,15 @@ static void nouveau_tex_gen(GLcontext *ctx, GLenum coord, GLenum pname, const GLfloat *params) { - context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); + switch (pname) { + case GL_TEXTURE_GEN_MODE: + context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); + context_dirty(ctx, MODELVIEW); + break; + default: + context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit); + break; + } } static void diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h index d6007aba2b9..584cb80ef62 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h @@ -191,4 +191,22 @@ is_texture_source(int s) return s == GL_TEXTURE || (s >= GL_TEXTURE0 && s <= GL_TEXTURE31); } +static inline struct gl_texgen * +get_texgen_coord(struct gl_texture_unit *u, int i) +{ + return ((struct gl_texgen *[]) + { &u->GenS, &u->GenT, &u->GenR, &u->GenQ }) [i]; +} + +static inline float * +get_texgen_coeff(struct gl_texgen *c) +{ + if (c->Mode == GL_OBJECT_LINEAR) + return c->ObjectPlane; + else if (c->Mode == GL_EYE_LINEAR) + return c->EyePlane; + else + return NULL; +} + #endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index f20a7df45ec..0c29eec8eec 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -224,9 +224,11 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays) if (ctx->Fog.Enabled && ctx->Fog.FogCoordinateSource == GL_FOG_COORD) vbo_emit_attr(ctx, arrays, VERT_ATTRIB_FOG); - if (ctx->Light.Enabled) { + if (ctx->Light.Enabled || + (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS)) vbo_emit_attr(ctx, arrays, VERT_ATTRIB_NORMAL); + if (ctx->Light.Enabled) { vbo_emit_attr(ctx, arrays, MAT(FRONT_AMBIENT)); vbo_emit_attr(ctx, arrays, MAT(FRONT_DIFFUSE)); vbo_emit_attr(ctx, arrays, MAT(FRONT_SPECULAR)); diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index d008063d3c4..b6d10361de0 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -212,7 +212,7 @@ nv10_hwctx_init(GLcontext *ctx) OUT_RING(chan, 0); BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1); OUT_RING(chan, 0); - BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8); + BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_MODE_S(0), 8); for (i = 0; i < 8; i++) OUT_RING(chan, 0); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c index 92148722af7..35f41d7295b 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c @@ -32,11 +32,44 @@ #include "nouveau_util.h" #include "nv10_driver.h" +#define TX_GEN_MODE(i, j) (NV10TCL_TX_GEN_MODE_S(i) + 4 * (j)) +#define TX_GEN_COEFF(i, j) (NV10TCL_TX_GEN_COEFF_S_A(i) + 16 * (j)) #define TX_MATRIX(i) (NV10TCL_TX0_MATRIX(0) + 64 * (i)) void nv10_emit_tex_gen(GLcontext *ctx, int emit) { + const int i = emit - NOUVEAU_STATE_TEX_GEN0; + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_grobj *celsius = context_eng3d(ctx); + struct gl_texture_unit *unit = &ctx->Texture.Unit[i]; + int j; + + for (j = 0; j < 4; j++) { + if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) { + struct gl_texgen *coord = get_texgen_coord(unit, j); + float *k = get_texgen_coeff(coord); + + if (k) { + BEGIN_RING(chan, celsius, + TX_GEN_COEFF(i, j), 4); + OUT_RINGf(chan, k[0]); + OUT_RINGf(chan, k[1]); + OUT_RINGf(chan, k[2]); + OUT_RINGf(chan, k[3]); + } + + BEGIN_RING(chan, celsius, TX_GEN_MODE(i, j), 1); + OUT_RING(chan, nvgl_texgen_mode(coord->Mode)); + + } else { + BEGIN_RING(chan, celsius, TX_GEN_MODE(i, j), 1); + OUT_RING(chan, 0); + } + } + + context_dirty_i(ctx, TEX_MAT, i); } void diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c index 406e24c455d..2624c9bf305 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c @@ -474,12 +474,14 @@ nv10_emit_modelview(GLcontext *ctx, int emit) if (nctx->fallback != HWTNL) return; - if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled) { + if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled || + (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { BEGIN_RING(chan, celsius, NV10TCL_MODELVIEW0_MATRIX(0), 16); OUT_RINGm(chan, m->m); } - if (ctx->Light.Enabled) { + if (ctx->Light.Enabled || + (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { int i, j; BEGIN_RING(chan, celsius, diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index 99df34716fc..789dcaa6b46 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -297,9 +297,9 @@ nv20_hwctx_init(GLcontext *ctx) BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1); OUT_RING (chan, 0); - BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0), - 4 * NV20TCL_TX_GEN_S__SIZE); - for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; i++) + BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_MODE_S(0), + 4 * NV20TCL_TX_GEN_MODE_S__SIZE); + for (i=0; i < 4 * NV20TCL_TX_GEN_MODE_S__SIZE; i++) OUT_RING(chan, 0); BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3); @@ -497,10 +497,10 @@ const struct nouveau_driver nv20_driver = { nv20_emit_tex_env, nv20_emit_tex_env, nv20_emit_tex_env, - nv10_emit_tex_gen, - nv10_emit_tex_gen, - nv10_emit_tex_gen, - nv10_emit_tex_gen, + nv20_emit_tex_gen, + nv20_emit_tex_gen, + nv20_emit_tex_gen, + nv20_emit_tex_gen, nv20_emit_tex_mat, nv20_emit_tex_mat, nv20_emit_tex_mat, diff --git a/src/mesa/drivers/dri/nouveau/nv20_driver.h b/src/mesa/drivers/dri/nouveau/nv20_driver.h index 05770b2d6cf..8adecef2c4e 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv20_driver.h @@ -67,6 +67,9 @@ void nv20_emit_frag(GLcontext *ctx, int emit); /* nv20_state_tex.c */ +void +nv20_emit_tex_gen(GLcontext *ctx, int emit); + void nv20_emit_tex_mat(GLcontext *ctx, int emit); diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index d7ac4c57bce..bb8a79c2c92 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -32,8 +32,43 @@ #include "nouveau_util.h" #include "nv20_driver.h" +#define TX_GEN_MODE(i, j) (NV20TCL_TX_GEN_MODE_S(i) + 4 * (j)) +#define TX_GEN_COEFF(i, j) (NV20TCL_TX_GEN_COEFF_S_A(i) + 16 * (j)) #define TX_MATRIX(i) (NV20TCL_TX0_MATRIX(0) + 64 * (i)) +void +nv20_emit_tex_gen(GLcontext *ctx, int emit) +{ + const int i = emit - NOUVEAU_STATE_TEX_GEN0; + struct nouveau_context *nctx = to_nouveau_context(ctx); + struct nouveau_channel *chan = context_chan(ctx); + struct nouveau_grobj *kelvin = context_eng3d(ctx); + struct gl_texture_unit *unit = &ctx->Texture.Unit[i]; + int j; + + for (j = 0; j < 4; j++) { + if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) { + struct gl_texgen *coord = get_texgen_coord(unit, j); + float *k = get_texgen_coeff(coord); + + if (k) { + BEGIN_RING(chan, kelvin, TX_GEN_COEFF(i, j), 4); + OUT_RINGf(chan, k[0]); + OUT_RINGf(chan, k[1]); + OUT_RINGf(chan, k[2]); + OUT_RINGf(chan, k[3]); + } + + BEGIN_RING(chan, kelvin, TX_GEN_MODE(i, j), 1); + OUT_RING(chan, nvgl_texgen_mode(coord->Mode)); + + } else { + BEGIN_RING(chan, kelvin, TX_GEN_MODE(i, j), 1); + OUT_RING(chan, 0); + } + } +} + void nv20_emit_tex_mat(GLcontext *ctx, int emit) { diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c index 43f8c723122..df22adf2729 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c @@ -359,12 +359,14 @@ nv20_emit_modelview(GLcontext *ctx, int emit) if (nctx->fallback != HWTNL) return; - if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled) { + if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled || + (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { BEGIN_RING(chan, kelvin, NV20TCL_MODELVIEW0_MATRIX(0), 16); OUT_RINGm(chan, m->m); } - if (ctx->Light.Enabled) { + if (ctx->Light.Enabled || + (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) { int i, j; BEGIN_RING(chan, kelvin, From 6193c41bcd8c50d3f4fb38690061029866c37667 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 18 Mar 2010 14:19:10 +0100 Subject: [PATCH 154/483] dri/nouveau: Avoid pushbuf flushes in the middle of LMA setup. --- src/mesa/drivers/dri/nouveau/nv10_state_fb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c index 6bd383ebcd3..f7c3d36e1cf 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c @@ -71,6 +71,7 @@ setup_lma_buffer(GLcontext *ctx) nouveau_bo_markl(bctx, celsius, NV17TCL_LMA_DEPTH_BUFFER_OFFSET, nfb->lma_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); + WAIT_RING(chan, 9); BEGIN_RING(chan, celsius, NV17TCL_LMA_DEPTH_WINDOW_X, 4); OUT_RINGf(chan, - 1792); OUT_RINGf(chan, - 2304 + fb->Height); From 3c0eab714816618314324ac02712fa59e5ed385a Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 18 Mar 2010 13:46:20 +0100 Subject: [PATCH 155/483] dri/nouveau: Flush after texture validation. Swizzling needs the destination surface in VRAM, but the subsequent rendering operations making use of it are likely to not care. Fire the ring after validation to leave the memory manager more room for maneuvering. --- src/mesa/drivers/dri/nouveau/nouveau_texture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 20bc0f6688f..e89018653b1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -296,6 +296,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t) validate_teximage(ctx, t, i, 0, 0, 0, s->width, s->height, 1); } + + FIRE_RING(context_chan(ctx)); } return GL_TRUE; From b7e8039132830a2cd7a75691d11750d2ccc0a4e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 09:17:11 -0600 Subject: [PATCH 156/483] st/mesa: s/unpack/pack/ to be more consistent --- src/mesa/state_tracker/st_cb_drawpixels.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 7c611cb4ec9..b937288f8c0 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -939,7 +939,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, int ptw, pth; GLboolean invertTex = GL_FALSE; GLint readX, readY, readW, readH; - struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; + struct gl_pixelstore_attrib pack = ctx->DefaultPacking; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); @@ -1003,7 +1003,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, readY = srcy; readW = width; readH = height; - _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &unpack); + _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &pack); readW = MAX2(0, readW); readH = MAX2(0, readH); @@ -1046,13 +1046,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (pipe->surface_copy) { pipe->surface_copy(pipe, psTex, /* dest surf */ - unpack.SkipPixels, unpack.SkipRows, /* dest pos */ + pack.SkipPixels, pack.SkipRows, /* dest pos */ psRead, /* src surf */ readX, readY, readW, readH); /* src region */ } else { util_surface_copy(pipe, FALSE, psTex, - unpack.SkipPixels, unpack.SkipRows, + pack.SkipPixels, pack.SkipRows, psRead, readX, readY, readW, readH); } @@ -1091,7 +1091,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(ptRead, readX, readY, readW, readH, buf); - pipe_put_tile_rgba(ptTex, unpack.SkipPixels, unpack.SkipRows, + pipe_put_tile_rgba(ptTex, pack.SkipPixels, pack.SkipRows, readW, readH, buf); free(buf); } @@ -1099,7 +1099,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* GL_DEPTH */ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); pipe_get_tile_z(ptRead, readX, readY, readW, readH, buf); - pipe_put_tile_z(ptTex, unpack.SkipPixels, unpack.SkipRows, + pipe_put_tile_z(ptTex, pack.SkipPixels, pack.SkipRows, readW, readH, buf); free(buf); } From a1e7aeecc25cedbd54e43afa72a1a2926ae51a32 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 09:30:13 -0600 Subject: [PATCH 157/483] llvmpipe: set opaque = FALSE if stencil enabled Fixes occasional bad tiles seen in some demos like progs/demos/reflect.c --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 2cecf7e0974..921c51fbe84 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1169,6 +1169,7 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) opaque = !key.blend.logicop_enable && !key.blend.rt[0].blend_enable && key.blend.rt[0].colormask == 0xf && + !key.stencil[0].enabled && !key.alpha.enabled && !key.depth.enabled && !key.scissor && From ecf85c7d750478e433e640897bb25a18069f14de Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 11:18:01 -0600 Subject: [PATCH 158/483] gallivm: checkpoint WIP two-sided stencil test --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 221 ++++++++++++++++--- 1 file changed, 191 insertions(+), 30 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index e4500e5aef1..49de5c94a3c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -52,7 +52,14 @@ * Z31 Z32 Z41 Z42 Z33 Z34 Z43 Z44 ... * ... ... ... ... ... ... ... ... ... * - * FIXME: Code generate stencil test + * + * Stencil test: + * Two-sided stencil test is supported but probably not as efficient as + * it could be. Currently, we use if/then/else constructs to do the + * operations for front vs. back-facing polygons. We could probably do + * both the front and back arithmetic then use a Select() instruction to + * choose the result depending on polyon orientation. We'd have to + * measure performance both ways and see which is better. * * @author Jose Fonseca */ @@ -70,18 +77,28 @@ #include "lp_bld_swizzle.h" +/** Used to select fields from pipe_stencil_state */ +enum stencil_op { + S_FAIL_OP, + Z_FAIL_OP, + Z_PASS_OP +}; + + /** - * Do the stencil test comparison (compare fb Z values against ref value. - * \param stencilVals vector of stencil values from framebuffer + * Do the stencil test comparison (compare FB stencil values against ref value). + * This will be used twice when generating two-sided stencil code. + * \param stencil the front/back stencil state * \param stencilRef the stencil reference value, replicated as a vector - * \return mask of pass/fail values + * \param stencilVals vector of stencil values from framebuffer + * \return vector mask of pass/fail values (~0 or 0) */ static LLVMValueRef -lp_build_stencil_test(struct lp_build_context *bld, - const struct pipe_stencil_state *stencil, - LLVMValueRef stencilRef, - LLVMValueRef stencilVals) +lp_build_stencil_test_single(struct lp_build_context *bld, + const struct pipe_stencil_state *stencil, + LLVMValueRef stencilRef, + LLVMValueRef stencilVals) { const unsigned stencilMax = 255; /* XXX fix */ struct lp_type type = bld->type; @@ -103,24 +120,100 @@ lp_build_stencil_test(struct lp_build_context *bld, } +/** + * Do the one or two-sided stencil test comparison. + * \sa lp_build_stencil_test_single + * \param face an integer indicating front (+) or back (-) facing polygon. + * If NULL, assume front-facing. + */ +static LLVMValueRef +lp_build_stencil_test(struct lp_build_context *bld, + const struct pipe_stencil_state stencil[2], + LLVMValueRef stencilRefs[2], + LLVMValueRef stencilVals, + LLVMValueRef face) +{ + LLVMValueRef res; + + assert(stencil[0].enabled); + + if (stencil[1].enabled && face) { + /* do two-sided test */ + struct lp_build_flow_context *flow_ctx; + struct lp_build_if_state if_ctx; + LLVMValueRef front_facing; + LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0); + LLVMValueRef result = NULL; + + flow_ctx = lp_build_flow_create(bld->builder); + lp_build_flow_scope_begin(flow_ctx); + + lp_build_flow_scope_declare(flow_ctx, &result); + + /* front_facing = face > 0.0 */ + front_facing = lp_build_cmp(bld, PIPE_FUNC_GREATER, face, zero); + + lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing); + { + result = lp_build_stencil_test_single(bld, &stencil[0], + stencilRefs[0], stencilVals); + } + lp_build_else(&if_ctx); + { + result = lp_build_stencil_test_single(bld, &stencil[1], + stencilRefs[1], stencilVals); + } + lp_build_endif(&if_ctx); + + lp_build_flow_scope_end(flow_ctx); + lp_build_flow_destroy(flow_ctx); + + res = result; + } + else { + /* do single-side test */ + res = lp_build_stencil_test_single(bld, &stencil[0], + stencilRefs[0], stencilVals); + } + + return res; +} + + /** * Apply the stencil operator (add/sub/keep/etc) to the given vector * of stencil values. * \return new stencil values vector */ static LLVMValueRef -lp_build_stencil_op(struct lp_build_context *bld, - const struct pipe_stencil_state *stencil, - unsigned stencil_op, - LLVMValueRef stencilRef, - LLVMValueRef stencilVals, - LLVMValueRef mask) +lp_build_stencil_op_single(struct lp_build_context *bld, + const struct pipe_stencil_state *stencil, + enum stencil_op op, + LLVMValueRef stencilRef, + LLVMValueRef stencilVals, + LLVMValueRef mask) { const unsigned stencilMax = 255; /* XXX fix */ struct lp_type type = bld->type; LLVMValueRef res; LLVMValueRef max = lp_build_const_int_vec(type, stencilMax); + unsigned stencil_op; + + switch (op) { + case S_FAIL_OP: + stencil_op = stencil->fail_op; + break; + case Z_FAIL_OP: + stencil_op = stencil->zfail_op; + break; + case Z_PASS_OP: + stencil_op = stencil->zpass_op; + break; + default: + assert(0 && "Invalid stencil_op mode"); + stencil_op = PIPE_STENCIL_OP_KEEP; + } switch (stencil_op) { case PIPE_STENCIL_OP_KEEP: @@ -173,6 +266,63 @@ lp_build_stencil_op(struct lp_build_context *bld, } +/** + * Do the one or two-sided stencil test op/update. + */ +static LLVMValueRef +lp_build_stencil_op(struct lp_build_context *bld, + const struct pipe_stencil_state stencil[2], + enum stencil_op op, + LLVMValueRef stencilRefs[2], + LLVMValueRef stencilVals, + LLVMValueRef mask, + LLVMValueRef face) + +{ + assert(stencil[0].enabled); + + if (stencil[1].enabled && face) { + /* do two-sided op */ + struct lp_build_flow_context *flow_ctx; + struct lp_build_if_state if_ctx; + LLVMValueRef front_facing; + LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0); + LLVMValueRef result = NULL; + + flow_ctx = lp_build_flow_create(bld->builder); + lp_build_flow_scope_begin(flow_ctx); + + lp_build_flow_scope_declare(flow_ctx, &result); + + /* front_facing = face > 0.0 */ + front_facing = lp_build_cmp(bld, PIPE_FUNC_GREATER, face, zero); + + lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing); + { + result = lp_build_stencil_op_single(bld, &stencil[0], op, + stencilRefs[0], stencilVals, mask); + } + lp_build_else(&if_ctx); + { + result = lp_build_stencil_op_single(bld, &stencil[1], op, + stencilRefs[1], stencilVals, mask); + } + lp_build_endif(&if_ctx); + + lp_build_flow_scope_end(flow_ctx); + lp_build_flow_destroy(flow_ctx); + + return result; + } + else { + /* do single-sided op */ + return lp_build_stencil_op_single(bld, &stencil[0], op, + stencilRefs[0], stencilVals, mask); + } +} + + + /** * Return a type appropriate for depth/stencil testing. */ @@ -213,14 +363,19 @@ lp_depth_type(const struct util_format_description *format_desc, } +/** Get front/back-face stencil ref value */ static LLVMValueRef lp_build_get_stencil_ref(struct lp_build_context *bld, - struct lp_type type, LLVMValueRef stencil_refs_ptr) + struct lp_type type, LLVMValueRef stencil_refs_ptr, + unsigned face_index) { LLVMValueRef indexes[2], ptr, ref, ref_vec; - /* load 0th element of the array */ - indexes[0] = indexes[1] = LLVMConstInt(LLVMInt32Type(), 0, 0); + assert(face_index < 2); + + /* load [face_index] element of the array */ + indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indexes[1] = LLVMConstInt(LLVMInt32Type(), face_index, 0); ptr = LLVMBuildGEP(bld->builder, stencil_refs_ptr, indexes, 2, ""); ref = LLVMBuildLoad(bld->builder, ptr, ""); @@ -251,17 +406,19 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_type type, const struct util_format_description *format_desc, struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, + LLVMValueRef stencil_refs_ptr, LLVMValueRef z_src, LLVMValueRef zs_dst_ptr) { struct lp_build_context bld; unsigned z_swizzle, s_swizzle; + LLVMValueRef stencil_refs[2]; LLVMValueRef zs_dst, z_dst = NULL; LLVMValueRef stencil_vals = NULL; LLVMValueRef z_bitmask = NULL, s_bitmask = NULL; LLVMValueRef z_pass = NULL, s_pass_mask = NULL; LLVMValueRef orig_mask = mask->value; + LLVMValueRef face = NULL; assert(depth->enabled || stencil[0].enabled); @@ -345,25 +502,29 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, lp_build_name(z_dst, "zsbuf.z"); - /* + printf("build depth %d stencil %d\n", depth->enabled, stencil[0].enabled); - */ + if (stencil[0].enabled) { /* Incoming stencil_refs is ptr to int8[2]. Get/convert to int32[4]. */ - stencil_refs = lp_build_get_stencil_ref(&bld, type, stencil_refs); + stencil_refs[0] = lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 0); + + if (stencil[1].enabled) + stencil_refs[1] = + lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 1); s_pass_mask = lp_build_stencil_test(&bld, stencil, - stencil_refs, stencil_vals); + stencil_refs, stencil_vals, face); /* apply stencil-fail operator */ { LLVMValueRef s_fail_mask = lp_build_andc(&bld, orig_mask, s_pass_mask); - stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].fail_op, + stencil_vals = lp_build_stencil_op(&bld, stencil, S_FAIL_OP, stencil_refs, stencil_vals, - s_fail_mask); + s_fail_mask, face); } } @@ -394,15 +555,15 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, /* apply Z-fail operator */ z_fail_mask = lp_build_andc(&bld, orig_mask, z_pass); - stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zfail_op, + stencil_vals = lp_build_stencil_op(&bld, stencil, Z_FAIL_OP, stencil_refs, stencil_vals, - z_fail_mask); + z_fail_mask, face); /* apply Z-pass operator */ z_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, z_pass, ""); - stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zpass_op, + stencil_vals = lp_build_stencil_op(&bld, stencil, Z_PASS_OP, stencil_refs, stencil_vals, - z_pass_mask); + z_pass_mask, face); } } else { @@ -410,8 +571,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, * passed the stencil test. */ s_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, s_pass_mask, ""); - stencil_vals = lp_build_stencil_op(&bld, stencil, stencil[0].zpass_op, - stencil_refs, stencil_vals, s_pass_mask); + stencil_vals = lp_build_stencil_op(&bld, stencil, Z_PASS_OP, stencil_refs, + stencil_vals, s_pass_mask, face); } /* Finally, merge/store the z/stencil values */ From 521c61ff017ab15b829abbe9a98b179136a36009 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 11:31:38 -0600 Subject: [PATCH 159/483] gallivm/llvmpipe: simplify front/back stencil ref value handling Instead of passing an array, just pass two scalar values. --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 41 +++----------------- src/gallium/auxiliary/gallivm/lp_bld_depth.h | 2 +- src/gallium/drivers/llvmpipe/lp_jit.c | 10 +++-- src/gallium/drivers/llvmpipe/lp_jit.h | 12 ++++-- src/gallium/drivers/llvmpipe/lp_setup.c | 8 ++-- src/gallium/drivers/llvmpipe/lp_state_fs.c | 7 ++-- 6 files changed, 30 insertions(+), 50 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 49de5c94a3c..c253764e603 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -363,32 +363,6 @@ lp_depth_type(const struct util_format_description *format_desc, } -/** Get front/back-face stencil ref value */ -static LLVMValueRef -lp_build_get_stencil_ref(struct lp_build_context *bld, - struct lp_type type, LLVMValueRef stencil_refs_ptr, - unsigned face_index) -{ - LLVMValueRef indexes[2], ptr, ref, ref_vec; - - assert(face_index < 2); - - /* load [face_index] element of the array */ - indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); - indexes[1] = LLVMConstInt(LLVMInt32Type(), face_index, 0); - ptr = LLVMBuildGEP(bld->builder, stencil_refs_ptr, indexes, 2, ""); - ref = LLVMBuildLoad(bld->builder, ptr, ""); - - /* convert int8 value to i32 */ - ref = LLVMBuildZExt(bld->builder, ref, LLVMIntType(type.width), ""); - - /* make scalar into vector */ - ref_vec = lp_build_broadcast_scalar(bld, ref); - - return ref_vec; -} - - /** * Generate code for performing depth and/or stencil tests. * We operate on a vector of values (typically a 2x2 quad). @@ -406,13 +380,12 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_type type, const struct util_format_description *format_desc, struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs_ptr, + LLVMValueRef stencil_refs[2], LLVMValueRef z_src, LLVMValueRef zs_dst_ptr) { struct lp_build_context bld; unsigned z_swizzle, s_swizzle; - LLVMValueRef stencil_refs[2]; LLVMValueRef zs_dst, z_dst = NULL; LLVMValueRef stencil_vals = NULL; LLVMValueRef z_bitmask = NULL, s_bitmask = NULL; @@ -502,19 +475,17 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, lp_build_name(z_dst, "zsbuf.z"); - + /* printf("build depth %d stencil %d\n", depth->enabled, stencil[0].enabled); - + */ if (stencil[0].enabled) { - /* Incoming stencil_refs is ptr to int8[2]. Get/convert to int32[4]. */ - stencil_refs[0] = lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 0); + /* convert scalar stencil refs into vectors */ + stencil_refs[0] = lp_build_broadcast_scalar(&bld, stencil_refs[0]); + stencil_refs[1] = lp_build_broadcast_scalar(&bld, stencil_refs[1]); - if (stencil[1].enabled) - stencil_refs[1] = - lp_build_get_stencil_ref(&bld, type, stencil_refs_ptr, 1); s_pass_mask = lp_build_stencil_test(&bld, stencil, stencil_refs, stencil_vals, face); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index eedc1e419b5..5708ced9839 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -57,7 +57,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_type type, const struct util_format_description *format_desc, struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, + LLVMValueRef stencil_refs[2], LLVMValueRef zs_src, LLVMValueRef zs_dst_ptr); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 1eee9212e6f..927e472ff26 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -96,7 +96,8 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0); elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType(); - elem_types[LP_JIT_CTX_STENCIL_REF] = LLVMArrayType(LLVMInt8Type(), 2); + elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] = LLVMInt32Type(); + elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32Type(); elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType(); elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType(); elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType(); @@ -113,9 +114,12 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value, screen->target, context_type, LP_JIT_CTX_ALPHA_REF); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_front, screen->target, context_type, - LP_JIT_CTX_STENCIL_REF); + LP_JIT_CTX_STENCIL_REF_FRONT); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_back, + screen->target, context_type, + LP_JIT_CTX_STENCIL_REF_BACK); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin, screen->target, context_type, LP_JIT_CTX_SCISSOR_XMIN); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 63e05c5d5e1..bbd0c9610de 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -84,7 +84,7 @@ struct lp_jit_context float alpha_ref_value; - uint8_t stencil_ref[2]; + uint32_t stencil_ref_front, stencil_ref_back; /** floats, not ints */ float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax; @@ -103,7 +103,8 @@ struct lp_jit_context enum { LP_JIT_CTX_CONSTANTS = 0, LP_JIT_CTX_ALPHA_REF, - LP_JIT_CTX_STENCIL_REF, + LP_JIT_CTX_STENCIL_REF_FRONT, + LP_JIT_CTX_STENCIL_REF_BACK, LP_JIT_CTX_SCISSOR_XMIN, LP_JIT_CTX_SCISSOR_YMIN, LP_JIT_CTX_SCISSOR_XMAX, @@ -120,8 +121,11 @@ enum { #define lp_jit_context_alpha_ref_value(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value") -#define lp_jit_context_stencil_ref_values(_builder, _ptr) \ - lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref") +#define lp_jit_context_stencil_ref_front_value(_builder, _ptr) \ + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front") + +#define lp_jit_context_stencil_ref_back_value(_builder, _ptr) \ + lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back") #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin") diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index bcc9d1fc1a4..fbb0d6f8a60 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -407,10 +407,10 @@ lp_setup_set_stencil_ref_values( struct lp_setup_context *setup, { LP_DBG(DEBUG_SETUP, "%s %d %d\n", __FUNCTION__, refs[0], refs[1]); - if (setup->fs.current.jit_context.stencil_ref[0] != refs[0] || - setup->fs.current.jit_context.stencil_ref[1] != refs[1]) { - setup->fs.current.jit_context.stencil_ref[0] = refs[0]; - setup->fs.current.jit_context.stencil_ref[1] = refs[1]; + if (setup->fs.current.jit_context.stencil_ref_front != refs[0] || + setup->fs.current.jit_context.stencil_ref_back != refs[1]) { + setup->fs.current.jit_context.stencil_ref_front = refs[0]; + setup->fs.current.jit_context.stencil_ref_back = refs[1]; setup->dirty |= LP_SETUP_NEW_FS; } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 921c51fbe84..0f96654a673 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -145,7 +145,7 @@ generate_depth_stencil(LLVMBuilderRef builder, const struct lp_fragment_shader_variant_key *key, struct lp_type src_type, struct lp_build_mask_context *mask, - LLVMValueRef stencil_refs, + LLVMValueRef stencil_refs[2], LLVMValueRef src, LLVMValueRef dst_ptr) { @@ -408,7 +408,7 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef consts_ptr; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; LLVMValueRef z = interp->pos[2]; - LLVMValueRef stencil_refs; + LLVMValueRef stencil_refs[2]; struct lp_build_flow_context *flow; struct lp_build_mask_context mask; boolean early_depth_stencil_test; @@ -418,7 +418,8 @@ generate_fs(struct llvmpipe_context *lp, assert(i < 4); - stencil_refs = lp_jit_context_stencil_ref_values(builder, context_ptr); + stencil_refs[0] = lp_jit_context_stencil_ref_front_value(builder, context_ptr); + stencil_refs[1] = lp_jit_context_stencil_ref_back_value(builder, context_ptr); elem_type = lp_build_elem_type(type); vec_type = lp_build_vec_type(type); From 94abc4b51e134bee1ace2b57400e35c295bda6f8 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 18 Mar 2010 18:01:05 +0000 Subject: [PATCH 160/483] Add format B5G5R5X1 --- src/gallium/auxiliary/util/u_format.csv | 1 + src/gallium/auxiliary/util/u_format_tests.c | 7 +++ src/gallium/auxiliary/util/u_gen_mipmap.c | 1 + src/gallium/auxiliary/util/u_pack_color.h | 19 +++++++ src/gallium/auxiliary/util/u_tile.c | 55 +++++++++++++++++++++ src/gallium/include/pipe/p_format.h | 1 + 6 files changed, 84 insertions(+) diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 96a0fa65507..11243e73492 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -63,6 +63,7 @@ PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb diff --git a/src/gallium/auxiliary/util/u_format_tests.c b/src/gallium/auxiliary/util/u_format_tests.c index 182a4740448..9d6debcd8c7 100644 --- a/src/gallium/auxiliary/util/u_format_tests.c +++ b/src/gallium/auxiliary/util/u_format_tests.c @@ -120,6 +120,13 @@ util_format_test_cases[] = * 16-bit rendertarget formats */ + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}}, {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}}, diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 61d64cff6d4..509d38754f5 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -938,6 +938,7 @@ format_to_type_comps(enum pipe_format pformat, *datatype = DTYPE_UBYTE; *comps = 4; return; + case PIPE_FORMAT_B5G5R5X1_UNORM: case PIPE_FORMAT_B5G5R5A1_UNORM: *datatype = DTYPE_USHORT_1_5_5_5_REV; *comps = 4; diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 50f1b1670b6..c5fd7a6783e 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -92,6 +92,11 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); } return; + case PIPE_FORMAT_B5G5R5X1_UNORM: + { + uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); + } + return; case PIPE_FORMAT_B5G5R5A1_UNORM: { uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); @@ -216,6 +221,15 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; + case PIPE_FORMAT_B5G5R5X1_UNORM: + { + ushort p = uc->us; + *r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7)); + *g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7)); + *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7)); + *a = (ubyte) 0xff; + } + return; case PIPE_FORMAT_B5G5R5A1_UNORM: { ushort p = uc->us; @@ -361,6 +375,11 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); } return; + case PIPE_FORMAT_B5G5R5X1_UNORM: + { + uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); + } + return; case PIPE_FORMAT_B5G5R5A1_UNORM: { uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 82e44192aaf..09b2382733d 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -295,6 +295,55 @@ r8g8b8a8_put_tile_rgba(unsigned *dst, } +/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/ + +static void +x1r5g5b5_get_tile_rgba(const ushort *src, + unsigned w, unsigned h, + float *p, + unsigned dst_stride) +{ + unsigned i, j; + + for (i = 0; i < h; i++) { + float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + const ushort pixel = *src++; + pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f); + pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f); + pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); + pRow[3] = 1.0f; + } + p += dst_stride; + } +} + + +static void +x1r5g5b5_put_tile_rgba(ushort *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) +{ + unsigned i, j; + + for (i = 0; i < h; i++) { + const float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + unsigned r, g, b; + r = float_to_ubyte(pRow[0]); + g = float_to_ubyte(pRow[1]); + b = float_to_ubyte(pRow[2]); + r = r >> 3; /* 5 bits */ + g = g >> 3; /* 5 bits */ + b = b >> 3; /* 5 bits */ + *dst++ = (1 << 15) | (r << 10) | (g << 5) | b; + } + p += src_stride; + } +} + + /*** PIPE_FORMAT_B5G5R5A1_UNORM ***/ static void @@ -1174,6 +1223,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_A8B8G8R8_UNORM: r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; + case PIPE_FORMAT_B5G5R5X1_UNORM: + x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); + break; case PIPE_FORMAT_B5G5R5A1_UNORM: a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; @@ -1368,6 +1420,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe, case PIPE_FORMAT_A8B8G8R8_UNORM: r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; + case PIPE_FORMAT_B5G5R5X1_UNORM: + x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); + break; case PIPE_FORMAT_B5G5R5A1_UNORM: a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index cbf3273ec8d..ba2985f4491 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -157,6 +157,7 @@ enum pipe_format { PIPE_FORMAT_DXT5_SRGBA = 109, PIPE_FORMAT_A8B8G8R8_UNORM = 110, + PIPE_FORMAT_B5G5R5X1_UNORM = 111, PIPE_FORMAT_COUNT }; From d219b8a022a6fdaa0106c6e160b594c359f85185 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 12:04:50 -0600 Subject: [PATCH 161/483] llvmpipe: defines for RAST_WHOLE, RAST_EDGE_TEST --- src/gallium/drivers/llvmpipe/lp_jit.h | 5 +++ src/gallium/drivers/llvmpipe/lp_rast.c | 38 ++++++++++++---------- src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 +-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index bbd0c9610de..690b4393079 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -146,6 +146,11 @@ enum { lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures") +/** Indexes into jit_function[] array */ +#define RAST_WHOLE 0 +#define RAST_EDGE_TEST 1 + + typedef void (*lp_jit_frag_func)(const struct lp_jit_context *context, uint32_t x, diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 81ea11a16b6..30b43cce19b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -312,15 +312,15 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task, depth = lp_rast_depth_pointer(rast, tile_x + x, tile_y + y); /* run shader */ - state->jit_function[0]( &state->jit_context, - tile_x + x, tile_y + y, - inputs->a0, - inputs->dadx, - inputs->dady, - color, - depth, - INT_MIN, INT_MIN, INT_MIN, - NULL, NULL, NULL ); + state->jit_function[RAST_WHOLE]( &state->jit_context, + tile_x + x, tile_y + y, + inputs->a0, + inputs->dadx, + inputs->dady, + color, + depth, + INT_MIN, INT_MIN, INT_MIN, + NULL, NULL, NULL ); } } } @@ -375,15 +375,17 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, assert(lp_check_alignment(inputs->step[2], 16)); /* run shader */ - state->jit_function[1]( &state->jit_context, - x, y, - inputs->a0, - inputs->dadx, - inputs->dady, - color, - depth, - c1, c2, c3, - inputs->step[0], inputs->step[1], inputs->step[2]); + state->jit_function[RAST_EDGE_TEST]( &state->jit_context, + x, y, + inputs->a0, + inputs->dadx, + inputs->dady, + color, + depth, + c1, c2, c3, + inputs->step[0], + inputs->step[1], + inputs->step[2]); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 0f96654a673..5f70d52b6cc 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1178,7 +1178,7 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) ? TRUE : FALSE; lp_setup_set_fs_functions(lp->setup, - shader->current->jit_function[0], - shader->current->jit_function[1], + shader->current->jit_function[RAST_WHOLE], + shader->current->jit_function[RAST_EDGE_TEST], opaque); } From 22e6dc387039e79f6d1435ae8b7422a6514d5d10 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 13:02:53 -0600 Subject: [PATCH 162/483] gallivm/llvmpipe: added lp_rast_shader_inputs::facing and pass through The triangle rasterizer sets this field to indicate front/back-facing. It gets passed into the generated fragment code as another parameter. Used now for stencil front/back selection but will also be used for fragment shaders in general (see TGSI_SEMANTIC_FACE). With this commit two-sided stenciling mostly works but there's still a bug or two... --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 22 ++++--- src/gallium/auxiliary/gallivm/lp_bld_depth.h | 3 +- src/gallium/drivers/llvmpipe/lp_jit.h | 1 + src/gallium/drivers/llvmpipe/lp_rast.c | 2 + src/gallium/drivers/llvmpipe/lp_rast.h | 2 + src/gallium/drivers/llvmpipe/lp_rast_priv.h | 1 + src/gallium/drivers/llvmpipe/lp_setup_tri.c | 2 + src/gallium/drivers/llvmpipe/lp_state_fs.c | 61 +++++++++++--------- 8 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index c253764e603..e1558dca0e7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -143,7 +143,7 @@ lp_build_stencil_test(struct lp_build_context *bld, struct lp_build_if_state if_ctx; LLVMValueRef front_facing; LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0); - LLVMValueRef result = NULL; + LLVMValueRef result = bld->undef; flow_ctx = lp_build_flow_create(bld->builder); lp_build_flow_scope_begin(flow_ctx); @@ -151,7 +151,7 @@ lp_build_stencil_test(struct lp_build_context *bld, lp_build_flow_scope_declare(flow_ctx, &result); /* front_facing = face > 0.0 */ - front_facing = lp_build_cmp(bld, PIPE_FUNC_GREATER, face, zero); + front_facing = LLVMBuildFCmp(bld->builder, LLVMRealUGT, face, zero, ""); lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing); { @@ -287,7 +287,7 @@ lp_build_stencil_op(struct lp_build_context *bld, struct lp_build_if_state if_ctx; LLVMValueRef front_facing; LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0); - LLVMValueRef result = NULL; + LLVMValueRef result = bld->undef; flow_ctx = lp_build_flow_create(bld->builder); lp_build_flow_scope_begin(flow_ctx); @@ -295,7 +295,7 @@ lp_build_stencil_op(struct lp_build_context *bld, lp_build_flow_scope_declare(flow_ctx, &result); /* front_facing = face > 0.0 */ - front_facing = lp_build_cmp(bld, PIPE_FUNC_GREATER, face, zero); + front_facing = LLVMBuildFCmp(bld->builder, LLVMRealUGT, face, zero, ""); lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing); { @@ -367,11 +367,15 @@ lp_depth_type(const struct util_format_description *format_desc, * Generate code for performing depth and/or stencil tests. * We operate on a vector of values (typically a 2x2 quad). * + * \param depth the depth test state + * \param stencil the front/back stencil state * \param type the data type of the fragment depth/stencil values * \param format_desc description of the depth/stencil surface - * \param mask the alive/dead pixel mask for the quad - * \param src the incoming depth/stencil values (a 2x2 quad) - * \param dst_ptr the outgoing/updated depth/stencil values + * \param mask the alive/dead pixel mask for the quad (vector) + * \param stencil_refs the front/back stencil ref values (scalar) + * \param z_src the incoming depth/stencil values (a 2x2 quad) + * \param zs_dst_ptr pointer to depth/stencil values in framebuffer + * \param facing contains float value indicating front/back facing polygon */ void lp_build_depth_stencil_test(LLVMBuilderRef builder, @@ -382,7 +386,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_build_mask_context *mask, LLVMValueRef stencil_refs[2], LLVMValueRef z_src, - LLVMValueRef zs_dst_ptr) + LLVMValueRef zs_dst_ptr, + LLVMValueRef face) { struct lp_build_context bld; unsigned z_swizzle, s_swizzle; @@ -391,7 +396,6 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, LLVMValueRef z_bitmask = NULL, s_bitmask = NULL; LLVMValueRef z_pass = NULL, s_pass_mask = NULL; LLVMValueRef orig_mask = mask->value; - LLVMValueRef face = NULL; assert(depth->enabled || stencil[0].enabled); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index 5708ced9839..27dd46b625d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -59,7 +59,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_build_mask_context *mask, LLVMValueRef stencil_refs[2], LLVMValueRef zs_src, - LLVMValueRef zs_dst_ptr); + LLVMValueRef zs_dst_ptr, + LLVMValueRef facing); #endif /* !LP_BLD_DEPTH_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 690b4393079..4930ff02e6b 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -155,6 +155,7 @@ typedef void (*lp_jit_frag_func)(const struct lp_jit_context *context, uint32_t x, uint32_t y, + float facing, const void *a0, const void *dadx, const void *dady, diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 30b43cce19b..3a51800c40d 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -314,6 +314,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task, /* run shader */ state->jit_function[RAST_WHOLE]( &state->jit_context, tile_x + x, tile_y + y, + inputs->facing, inputs->a0, inputs->dadx, inputs->dady, @@ -377,6 +378,7 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, /* run shader */ state->jit_function[RAST_EDGE_TEST]( &state->jit_context, x, y, + inputs->facing, inputs->a0, inputs->dadx, inputs->dady, diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 303f6e3f7e4..ae838f3fbef 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -82,6 +82,8 @@ struct lp_rast_state { * These pointers point into the bin data buffer. */ struct lp_rast_shader_inputs { + float facing; /** Positive for front-facing, negative for back-facing */ + float (*a0)[4]; float (*dadx)[4]; float (*dady)[4]; diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 39bf2c25879..6ee9bcaae3a 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -195,6 +195,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task, /* run shader */ state->jit_function[0]( &state->jit_context, x, y, + inputs->facing, inputs->a0, inputs->dadx, inputs->dady, diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index ac6264dc73e..ce689d3d568 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -361,6 +361,8 @@ do_triangle_ccw(struct lp_setup_context *setup, */ setup_tri_coefficients( setup, tri, oneoverarea, v1, v2, v3, frontfacing ); + tri->inputs.facing = frontfacing ? 1.0F : -1.0F; + /* half-edge constants, will be interated over the whole render target. */ tri->c1 = tri->dy12 * x1 - tri->dx12 * y1; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 5f70d52b6cc..7bbf348e0b8 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -147,7 +147,8 @@ generate_depth_stencil(LLVMBuilderRef builder, struct lp_build_mask_context *mask, LLVMValueRef stencil_refs[2], LLVMValueRef src, - LLVMValueRef dst_ptr) + LLVMValueRef dst_ptr, + LLVMValueRef facing) { const struct util_format_description *format_desc; struct lp_type dst_type; @@ -193,7 +194,8 @@ generate_depth_stencil(LLVMBuilderRef builder, mask, stencil_refs, src, - dst_ptr); + dst_ptr, + facing); } @@ -393,6 +395,7 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef *pmask, LLVMValueRef (*color)[4], LLVMValueRef depth_ptr, + LLVMValueRef facing, unsigned do_tri_test, LLVMValueRef c0, LLVMValueRef c1, @@ -469,7 +472,7 @@ generate_fs(struct llvmpipe_context *lp, if (early_depth_stencil_test) generate_depth_stencil(builder, key, type, &mask, - stencil_refs, z, depth_ptr); + stencil_refs, z, depth_ptr, facing); lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, @@ -516,7 +519,7 @@ generate_fs(struct llvmpipe_context *lp, if (!early_depth_stencil_test) generate_depth_stencil(builder, key, type, &mask, - stencil_refs, z, depth_ptr); + stencil_refs, z, depth_ptr, facing); lp_build_mask_end(&mask); @@ -627,7 +630,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMTypeRef fs_int_vec_type; LLVMTypeRef blend_vec_type; LLVMTypeRef blend_int_vec_type; - LLVMTypeRef arg_types[14]; + LLVMTypeRef arg_types[15]; LLVMTypeRef func_type; LLVMTypeRef int32_vec4_type = lp_build_int32_vec4_type(); LLVMValueRef context_ptr; @@ -650,6 +653,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMValueRef blend_mask; LLVMValueRef blend_in_color[NUM_CHANNELS]; LLVMValueRef function; + LLVMValueRef facing; unsigned num_fs; unsigned i; unsigned chan; @@ -689,20 +693,21 @@ generate_fragment(struct llvmpipe_context *lp, arg_types[0] = screen->context_ptr_type; /* context */ arg_types[1] = LLVMInt32Type(); /* x */ arg_types[2] = LLVMInt32Type(); /* y */ - arg_types[3] = LLVMPointerType(fs_elem_type, 0); /* a0 */ - arg_types[4] = LLVMPointerType(fs_elem_type, 0); /* dadx */ - arg_types[5] = LLVMPointerType(fs_elem_type, 0); /* dady */ - arg_types[6] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0); /* color */ - arg_types[7] = LLVMPointerType(fs_int_vec_type, 0); /* depth */ - arg_types[8] = LLVMInt32Type(); /* c0 */ - arg_types[9] = LLVMInt32Type(); /* c1 */ - arg_types[10] = LLVMInt32Type(); /* c2 */ + arg_types[3] = LLVMFloatType(); /* facing */ + arg_types[4] = LLVMPointerType(fs_elem_type, 0); /* a0 */ + arg_types[5] = LLVMPointerType(fs_elem_type, 0); /* dadx */ + arg_types[6] = LLVMPointerType(fs_elem_type, 0); /* dady */ + arg_types[7] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0); /* color */ + arg_types[8] = LLVMPointerType(fs_int_vec_type, 0); /* depth */ + arg_types[9] = LLVMInt32Type(); /* c0 */ + arg_types[10] = LLVMInt32Type(); /* c1 */ + arg_types[11] = LLVMInt32Type(); /* c2 */ /* Note: the step arrays are built as int32[16] but we interpret * them here as int32_vec4[4]. */ - arg_types[11] = LLVMPointerType(int32_vec4_type, 0);/* step0 */ - arg_types[12] = LLVMPointerType(int32_vec4_type, 0);/* step1 */ - arg_types[13] = LLVMPointerType(int32_vec4_type, 0);/* step2 */ + arg_types[12] = LLVMPointerType(int32_vec4_type, 0);/* step0 */ + arg_types[13] = LLVMPointerType(int32_vec4_type, 0);/* step1 */ + arg_types[14] = LLVMPointerType(int32_vec4_type, 0);/* step2 */ func_type = LLVMFunctionType(LLVMVoidType(), arg_types, Elements(arg_types), 0); @@ -722,17 +727,18 @@ generate_fragment(struct llvmpipe_context *lp, context_ptr = LLVMGetParam(function, 0); x = LLVMGetParam(function, 1); y = LLVMGetParam(function, 2); - a0_ptr = LLVMGetParam(function, 3); - dadx_ptr = LLVMGetParam(function, 4); - dady_ptr = LLVMGetParam(function, 5); - color_ptr_ptr = LLVMGetParam(function, 6); - depth_ptr = LLVMGetParam(function, 7); - c0 = LLVMGetParam(function, 8); - c1 = LLVMGetParam(function, 9); - c2 = LLVMGetParam(function, 10); - step0_ptr = LLVMGetParam(function, 11); - step1_ptr = LLVMGetParam(function, 12); - step2_ptr = LLVMGetParam(function, 13); + facing = LLVMGetParam(function, 3); + a0_ptr = LLVMGetParam(function, 4); + dadx_ptr = LLVMGetParam(function, 5); + dady_ptr = LLVMGetParam(function, 6); + color_ptr_ptr = LLVMGetParam(function, 7); + depth_ptr = LLVMGetParam(function, 8); + c0 = LLVMGetParam(function, 9); + c1 = LLVMGetParam(function, 10); + c2 = LLVMGetParam(function, 11); + step0_ptr = LLVMGetParam(function, 12); + step1_ptr = LLVMGetParam(function, 13); + step2_ptr = LLVMGetParam(function, 14); lp_build_name(context_ptr, "context"); lp_build_name(x, "x"); @@ -791,6 +797,7 @@ generate_fragment(struct llvmpipe_context *lp, &fs_mask[i], /* output */ out_color, depth_ptr_i, + facing, do_tri_test, c0, c1, c2, step0_ptr, step1_ptr, step2_ptr); From 705ed3326c9b56fcee193748f87b14ed6d67b65f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 14:53:43 -0600 Subject: [PATCH 163/483] progs/tests: comments and clean-ups --- progs/tests/stencil_twoside.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c index 7d871e5877f..f9c109146d0 100644 --- a/progs/tests/stencil_twoside.c +++ b/progs/tests/stencil_twoside.c @@ -85,6 +85,9 @@ static void Display( void ) /* Draw the first two squares using incr for the affected face */ + /************************************************************************* + * 2nd square + */ if (use20syntax) { stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0); stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0); @@ -98,8 +101,8 @@ static void Display( void ) glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.9, 0.9, 0.9 ); - /* this should be front facing */ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + /* this should be front facing */ glVertex2f(-1, -1); glVertex2f( 1, -1); glVertex2f( 1, 1); @@ -107,6 +110,7 @@ static void Display( void ) } glEnd(); + /* stencil vals should be equal to max_stencil */ glStencilFunc(GL_EQUAL, max_stencil, ~0); glBegin(GL_QUADS); glColor3f( 0.5, 0.5, 0.5 ); @@ -116,6 +120,9 @@ static void Display( void ) glVertex2f(-1, 1); glEnd(); + /************************************************************************* + * 3rd square + */ if (use20syntax) { stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0); stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0); @@ -129,9 +136,8 @@ static void Display( void ) glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.9, 0.9, 0.9 ); - - /* this should be back facing */ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + /* this should be back facing */ glVertex2f(-1, -1); glVertex2f(-1, 1); glVertex2f( 1, 1); @@ -139,6 +145,7 @@ static void Display( void ) } glEnd(); + /* stencil vals should be equal to max_stencil */ glStencilFunc(GL_EQUAL, max_stencil, ~0); glBegin(GL_QUADS); glColor3f( 0.5, 0.5, 0.5 ); @@ -148,6 +155,9 @@ static void Display( void ) glVertex2f(-1, 1); glEnd(); + /************************************************************************* + * 4th square + */ if (use20syntax) { stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0); stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0); @@ -161,15 +171,13 @@ static void Display( void ) glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.9, 0.9, 0.9 ); - - /* this should be back facing */ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { - /* this should be back facing */ + /* this should be back facing */ glVertex2f(-1, -1); glVertex2f(-1, 1); glVertex2f( 1, 1); glVertex2f( 1, -1); - /* this should be front facing */ + /* this should be front facing */ glVertex2f(-1, -1); glVertex2f( 1, -1); glVertex2f( 1, 1); @@ -177,6 +185,7 @@ static void Display( void ) } glEnd(); + /* stencil vals should be equal to max_stencil */ glStencilFunc(GL_EQUAL, max_stencil, ~0); glBegin(GL_QUADS); glColor3f( 0.5, 0.5, 0.5 ); @@ -186,6 +195,9 @@ static void Display( void ) glVertex2f(-1, 1); glEnd(); + /************************************************************************* + * 5th square + */ if (use20syntax) { stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0); stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0); @@ -199,15 +211,13 @@ static void Display( void ) glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.9, 0.9, 0.9 ); - - /* this should be back facing */ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { - /* this should be back facing */ + /* this should be back facing */ glVertex2f(-1, -1); glVertex2f(-1, 1); glVertex2f( 1, 1); glVertex2f( 1, -1); - /* this should be front facing */ + /* this should be front facing */ glVertex2f(-1, -1); glVertex2f( 1, -1); glVertex2f( 1, 1); From 66b6676d141463b8229e62be6249efd1cb6873a8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 15:02:13 -0600 Subject: [PATCH 164/483] gallivm: fix broken INCR/DECR stencil modes We were mistakenly using the wrong data type for stencil values before. --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index e1558dca0e7..0841aa8ef86 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -104,6 +104,8 @@ lp_build_stencil_test_single(struct lp_build_context *bld, struct lp_type type = bld->type; LLVMValueRef res; + assert(type.sign); + assert(stencil->enabled); if (stencil->valuemask != stencilMax) { @@ -200,6 +202,8 @@ lp_build_stencil_op_single(struct lp_build_context *bld, LLVMValueRef max = lp_build_const_int_vec(type, stencilMax); unsigned stencil_op; + assert(type.sign); + switch (op) { case S_FAIL_OP: stencil_op = stencil->fail_op; @@ -244,6 +248,7 @@ lp_build_stencil_op_single(struct lp_build_context *bld, break; case PIPE_STENCIL_OP_INVERT: res = LLVMBuildNot(bld->builder, stencilVals, ""); + res = LLVMBuildAnd(bld->builder, res, max, ""); break; default: assert(0 && "bad stencil op mode"); @@ -390,6 +395,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, LLVMValueRef face) { struct lp_build_context bld; + struct lp_build_context sbld; + struct lp_type s_type; unsigned z_swizzle, s_swizzle; LLVMValueRef zs_dst, z_dst = NULL; LLVMValueRef stencil_vals = NULL; @@ -425,9 +432,13 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, assert(type.norm); } - /* Setup build context */ + /* Setup build context for Z vals */ lp_build_context_init(&bld, builder, type); + /* Setup build context for stencil vals */ + s_type = lp_type_int_vec(type.width); + lp_build_context_init(&sbld, builder, s_type); + /* Load current z/stencil value from z/stencil buffer */ zs_dst = LLVMBuildLoad(builder, zs_dst_ptr, ""); @@ -491,13 +502,13 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, stencil_refs[1] = lp_build_broadcast_scalar(&bld, stencil_refs[1]); - s_pass_mask = lp_build_stencil_test(&bld, stencil, + s_pass_mask = lp_build_stencil_test(&sbld, stencil, stencil_refs, stencil_vals, face); /* apply stencil-fail operator */ { LLVMValueRef s_fail_mask = lp_build_andc(&bld, orig_mask, s_pass_mask); - stencil_vals = lp_build_stencil_op(&bld, stencil, S_FAIL_OP, + stencil_vals = lp_build_stencil_op(&sbld, stencil, S_FAIL_OP, stencil_refs, stencil_vals, s_fail_mask, face); } @@ -530,13 +541,13 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, /* apply Z-fail operator */ z_fail_mask = lp_build_andc(&bld, orig_mask, z_pass); - stencil_vals = lp_build_stencil_op(&bld, stencil, Z_FAIL_OP, + stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_FAIL_OP, stencil_refs, stencil_vals, z_fail_mask, face); /* apply Z-pass operator */ z_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, z_pass, ""); - stencil_vals = lp_build_stencil_op(&bld, stencil, Z_PASS_OP, + stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP, stencil_refs, stencil_vals, z_pass_mask, face); } @@ -546,7 +557,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, * passed the stencil test. */ s_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, s_pass_mask, ""); - stencil_vals = lp_build_stencil_op(&bld, stencil, Z_PASS_OP, stencil_refs, + stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP, stencil_refs, stencil_vals, s_pass_mask, face); } From c9c0baabdc653f162f9ce51cb17775aed1a707f7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 15:04:31 -0600 Subject: [PATCH 165/483] progs/tests: also test stencil INCR_WRAP mode if supported --- progs/tests/stencil_twoside.c | 53 +++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c index f9c109146d0..1010139a20e 100644 --- a/progs/tests/stencil_twoside.c +++ b/progs/tests/stencil_twoside.c @@ -26,7 +26,7 @@ * \file stencil_twoside.c * * Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality. - * Four squares are drawn + * Five squares (or six if stencil wrap is available) are drawn * with different stencil modes, but all should be rendered with the same * final color. */ @@ -37,7 +37,7 @@ #include static int use20syntax = 1; -static int Width = 550; +static int Width = 650; static int Height = 200; static const GLfloat Near = 5.0, Far = 25.0; @@ -70,7 +70,7 @@ static void Display( void ) */ glDisable(GL_STENCIL_TEST); - glTranslatef(-6.0, 0, 0); + glTranslatef(-7.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.5, 0.5, 0.5 ); glVertex2f(-1, -1); @@ -205,8 +205,8 @@ static void Display( void ) else { stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0); } - stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR); - stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR); + stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR); + stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR); glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); @@ -234,6 +234,47 @@ static void Display( void ) glVertex2f(-1, 1); glEnd(); + /************************************************************************* + * 6th square + */ + if (glutExtensionSupported("GL_EXT_stencil_wrap")) { + if (use20syntax) { + stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0); + stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0); + } + else { + stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0); + } + stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP); + stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP); + + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.9, 0.9 ); + for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + /* this should be back facing */ + glVertex2f(-1, -1); + glVertex2f(-1, 1); + glVertex2f( 1, 1); + glVertex2f( 1, -1); + /* this should be front facing */ + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + } + glEnd(); + + glStencilFunc(GL_EQUAL, 260 - 255, ~0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + } + glPopMatrix(); glutSwapBuffers(); @@ -288,7 +329,7 @@ static void Init( void ) stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" ); stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" ); - printf("\nAll 5 squares should be the same color.\n"); + printf("\nAll 5 (or 6) squares should be the same color.\n"); } From fda5078324e0a940a2ddfdd1c63ffceb47c5a717 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Mar 2010 15:35:05 -0700 Subject: [PATCH 166/483] Use bit-wise not instead of logical not. The assertion is checking that the low-order bits of offset are not set. It does this by anding the inverted offset mask with the offset. This is clearly intended to be a bit-wise "invert". Fixes bug #25984. --- src/mesa/drivers/dri/i915/intel_tris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index fb191fe346f..4b6d3b4c5be 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -251,7 +251,7 @@ void intel_flush_prim(struct intel_context *intel) BEGIN_BATCH(5); OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(0) | I1_LOAD_S(1) | 1); - assert((offset & !S0_VB_OFFSET_MASK) == 0); + assert((offset & ~S0_VB_OFFSET_MASK) == 0); OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset); OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) | (intel->vertex_size << S1_VERTEX_PITCH_SHIFT)); From 8df65e98998b4c104db30cbba8a38be7eb2a9acd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Mar 2010 17:27:39 -0600 Subject: [PATCH 167/483] gallivm: support PIPE_FORMAT_Z24S8_UNORM in depth/stencil code --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 0841aa8ef86..5b5ae7b5ea8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -400,7 +400,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, unsigned z_swizzle, s_swizzle; LLVMValueRef zs_dst, z_dst = NULL; LLVMValueRef stencil_vals = NULL; - LLVMValueRef z_bitmask = NULL, s_bitmask = NULL; + LLVMValueRef z_bitmask = NULL, s_bitmask = NULL, s_shift = NULL; LLVMValueRef z_pass = NULL, s_pass_mask = NULL; LLVMValueRef orig_mask = mask->value; @@ -416,6 +416,11 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, assert(z_swizzle != UTIL_FORMAT_SWIZZLE_NONE || s_swizzle != UTIL_FORMAT_SWIZZLE_NONE); + if (stencil[0].enabled) { + assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM || + format_desc->format == PIPE_FORMAT_S8Z24_UNORM); + } + /* Sanity checking */ assert(z_swizzle < 4); assert(format_desc->block.bits == type.width); @@ -473,9 +478,16 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, z_bitmask = lp_build_const_int_vec(type, mask_left ^ mask_right); } - s_bitmask = LLVMBuildNot(builder, z_bitmask, ""); + /* If PIPE_FORMAT_Z24S8, we'll shift zs >> 24 to position stencil_vals */ + if (format_desc->format == PIPE_FORMAT_Z24S8_UNORM) + s_shift = lp_build_const_int_vec(type, 24); + else + s_shift = lp_build_const_int_vec(type, 0); - stencil_vals = LLVMBuildAnd(builder, zs_dst, s_bitmask, ""); + s_bitmask = lp_build_const_int_vec(s_type, 0xff); + + stencil_vals = LLVMBuildLShr(builder, zs_dst, s_shift, ""); + stencil_vals = LLVMBuildAnd(builder, stencil_vals, s_bitmask, ""); if(padding_left) z_src = LLVMBuildLShr(builder, z_src, @@ -561,6 +573,9 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, stencil_vals, s_pass_mask, face); } + if (stencil_vals) + stencil_vals = LLVMBuildShl(bld.builder, stencil_vals, s_shift, ""); + /* Finally, merge/store the z/stencil values */ if ((depth->enabled && depth->writemask) || (stencil[0].enabled && stencil[0].writemask)) { From cba6430524198a1bdcdeada03cbe946a454f3935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 24 Dec 2009 21:29:41 +0100 Subject: [PATCH 168/483] r300g: add generating texture coordinates for point sprites (WIP) --- src/gallium/drivers/r300/r300_context.c | 2 ++ src/gallium/drivers/r300/r300_context.h | 13 +++++++ src/gallium/drivers/r300/r300_emit.c | 6 ++++ src/gallium/drivers/r300/r300_state.c | 35 ++++++++++++++++++- src/gallium/drivers/r300/r300_state_derived.c | 5 ++- .../drivers/r300/r300_state_invariant.c | 13 ++----- 6 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index d994a46ccfe..210e31e69c7 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -202,6 +202,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_setup_atoms(r300); + r300->sprite_coord_index = -1; + /* Open up the OQ BO. */ r300->oqbo = screen->buffer_create(screen, 4096, PIPE_BUFFER_USAGE_VERTEX, 4096); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 0c8fb6860eb..edebeab86fd 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -98,6 +98,16 @@ struct r300_rs_state { uint32_t line_stipple_value; /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */ uint32_t color_control; /* R300_GA_COLOR_CONTROL: 0x4278 */ uint32_t polygon_mode; /* R300_GA_POLY_MODE: 0x4288 */ + + /* Specifies top of Raster pipe specific enable controls, + * i.e. texture coordinates stuffing for points, lines, triangles */ + uint32_t stuffing_enable; /* R300_GB_ENABLE: 0x4008 */ + + /* Point sprites texture coordinates, 0: lower left, 1: upper right */ + float point_texcoord_left; /* R300_GA_POINT_S0: 0x4200 */ + float point_texcoord_bottom; /* R300_GA_POINT_T0: 0x4204 */ + float point_texcoord_right; /* R300_GA_POINT_S1: 0x4208 */ + float point_texcoord_top; /* R300_GA_POINT_T1: 0x420c */ }; struct r300_rs_block { @@ -390,6 +400,9 @@ struct r300_context { uint32_t zbuffer_bpp; /* Whether scissor is enabled. */ boolean scissor_enabled; + /* Point sprites texcoord index, -1 = unused. */ + int sprite_coord_index; + /* upload managers */ struct u_upload_mgr *upload_vb; struct u_upload_mgr *upload_ib; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 3ad0e561bc1..5522fb306db 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -616,6 +616,12 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config); OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, rs->line_stipple_value); OUT_CS_REG(R300_GA_POLY_MODE, rs->polygon_mode); + OUT_CS_REG(R300_GB_ENABLE, rs->stuffing_enable); + OUT_CS_REG_SEQ(R300_GA_POINT_S0, 4); + OUT_CS_32F(rs->point_texcoord_left); + OUT_CS_32F(rs->point_texcoord_bottom); + OUT_CS_32F(rs->point_texcoord_right); + OUT_CS_32F(rs->point_texcoord_top); END_CS; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index d7d654dc315..db7844eef0e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -715,6 +715,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, { struct r300_screen* r300screen = r300_screen(pipe->screen); struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); + unsigned coord_index; /* Copy rasterizer state for Draw. */ rs->rs = *state; @@ -807,6 +808,32 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->color_control = R300_SHADE_MODEL_SMOOTH; } + /* Point sprites */ + if (state->sprite_coord_enable) { + coord_index = ffs(state->sprite_coord_enable)-1; + + SCREEN_DBG(r300screen, DBG_DRAW, + "r300: point sprite: shader coord=%d\n", coord_index); + + rs->stuffing_enable = + R300_GB_POINT_STUFF_ENABLE | + R300_GB_TEX_ST << (R300_GB_TEX0_SOURCE_SHIFT + (coord_index*2)); + + rs->point_texcoord_left = 0.0f; + rs->point_texcoord_right = 1.0f; + + switch (state->sprite_coord_mode) { + case PIPE_SPRITE_COORD_UPPER_LEFT: + rs->point_texcoord_top = 0.0f; + rs->point_texcoord_bottom = 1.0f; + break; + case PIPE_SPRITE_COORD_LOWER_LEFT: + rs->point_texcoord_top = 1.0f; + rs->point_texcoord_bottom = 0.0f; + break; + } + } + return (void*)rs; } @@ -816,6 +843,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) struct r300_context* r300 = r300_context(pipe); struct r300_rs_state* rs = (struct r300_rs_state*)state; boolean scissor_was_enabled = r300->scissor_enabled; + int last_sprite_coord_index = r300->sprite_coord_index; if (r300->draw) { draw_flush(r300->draw); @@ -825,17 +853,22 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; r300->scissor_enabled = rs->rs.scissor; + r300->sprite_coord_index = ffs(rs->rs.sprite_coord_enable)-1; } else { r300->polygon_offset_enabled = FALSE; r300->scissor_enabled = FALSE; + r300->sprite_coord_index = -1; } UPDATE_STATE(state, r300->rs_state); - r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0); + r300->rs_state.size = 24 + (r300->polygon_offset_enabled ? 5 : 0); if (scissor_was_enabled != r300->scissor_enabled) { r300->scissor_state.dirty = TRUE; } + if (last_sprite_coord_index != r300->sprite_coord_index) { + r300->rs_block_state.dirty = TRUE; + } } /* Free rasterizer state. */ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 7947ec6641d..74663bda514 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -178,7 +178,8 @@ static void r300_update_rs_block(struct r300_context* r300, /* Rasterize texture coordinates. */ for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED) { + if (vs_outputs->generic[i] != ATTR_UNUSED || + r300->sprite_coord_index == i) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ rX00_rs_tex(&rs, tex_count, tex_count, FALSE); @@ -186,6 +187,8 @@ static void r300_update_rs_block(struct r300_context* r300, /* Write it to the FS input register if it's used by the FS. */ if (fs_inputs->generic[i] != ATTR_UNUSED) { rX00_rs_tex_write(&rs, tex_count, fp_offset); + if (r300->sprite_coord_index == i) + debug_printf("r300: SpriteCoord (generic index %i) is being written to reg %i\n", i, fp_offset); fp_offset++; } tex_count++; diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 4a2c68269b1..2d9a63d29a4 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -44,13 +44,9 @@ void r300_emit_invariant_state(struct r300_context* r300, struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); - BEGIN_CS(14 + (caps->has_tcl ? 2: 0)); + BEGIN_CS(12 + (caps->has_tcl ? 2: 0)); /*** Graphics Backend (GB) ***/ - /* Various GB enables */ - OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE | - R300_GB_LINE_STUFF_ENABLE | - R300_GB_TRIANGLE_STUFF_ENABLE); /* Subpixel multisampling for AA * These are commented out because glisse's CS checker doesn't like them. * I presume these will be re-enabled later. @@ -78,7 +74,7 @@ void r300_emit_invariant_state(struct r300_context* r300, END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(44 + (caps->has_tcl ? 7 : 0) + + BEGIN_CS(40 + (caps->has_tcl ? 7 : 0) + (caps->family >= CHIP_FAMILY_RV350 ? 4 : 0)); if (caps->has_tcl) { @@ -90,11 +86,6 @@ void r300_emit_invariant_state(struct r300_context* r300, OUT_CS_32F(1.0); OUT_CS_32F(1.0); } - /* XXX point tex stuffing */ - OUT_CS_REG_SEQ(R300_GA_POINT_S0, 1); - OUT_CS_32F(0.0); - OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1); - OUT_CS_32F(1.0); /* XXX line tex stuffing */ OUT_CS_REG_SEQ(R300_GA_LINE_S0, 1); OUT_CS_32F(0.0); From 0c81739528fd8f240176bb120c90c712f9606718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 18 Mar 2010 20:58:04 +0100 Subject: [PATCH 169/483] r300g: mark SRGB colorbuffers as unsupported I can't find the register bits for SRGB-aware blending and it's not even exposed by fglrx so it's most probably not supported by hw. --- src/gallium/drivers/r300/r300_texture.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7c7656068bb..09067aab3bf 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -302,7 +302,6 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_L8_SRGB: case PIPE_FORMAT_R8_UNORM: case PIPE_FORMAT_R8_SNORM: return R300_COLOR_FORMAT_I8; @@ -317,18 +316,12 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) /* 32-bit buffers. */ case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_B8G8R8A8_SRGB: case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_B8G8R8X8_SRGB: case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_SRGB: case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_SRGB: case PIPE_FORMAT_A8B8G8R8_UNORM: case PIPE_FORMAT_R8G8B8A8_SNORM: - case PIPE_FORMAT_A8B8G8R8_SRGB: case PIPE_FORMAT_X8B8G8R8_UNORM: - case PIPE_FORMAT_X8B8G8R8_SRGB: case PIPE_FORMAT_R8SG8SB8UX8U_NORM: return R300_COLOR_FORMAT_ARGB8888; case PIPE_FORMAT_R10G10B10A2_UNORM: @@ -393,12 +386,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) desc = util_format_description(format); /* Specifies how the shader output is written to the fog unit. */ - if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { - /* The gamma correction causes precision loss so we need - * higher precision to maintain reasonable quality. - * It has nothing to do with the colorbuffer format. */ - modifier |= R300_US_OUT_FMT_C4_10_GAMMA; - } else if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) { + if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) { if (desc->channel[0].size == 32) { modifier |= R300_US_OUT_FMT_C4_32_FP; } else { @@ -428,7 +416,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) return modifier | R300_C2_SEL_A; case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_L8_SRGB: case PIPE_FORMAT_R8_UNORM: case PIPE_FORMAT_R8_SNORM: return modifier | R300_C2_SEL_R; @@ -438,18 +425,14 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) case PIPE_FORMAT_B5G5R5A1_UNORM: case PIPE_FORMAT_B4G4R4A4_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_B8G8R8A8_SRGB: case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_B8G8R8X8_SRGB: return modifier | R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A; /* BGRA 32-bit outputs. */ case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_SRGB: case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_SRGB: return modifier | R300_C0_SEL_A | R300_C1_SEL_R | R300_C2_SEL_G | R300_C3_SEL_B; @@ -457,9 +440,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) /* RGBA 32-bit outputs. */ case PIPE_FORMAT_A8B8G8R8_UNORM: case PIPE_FORMAT_R8G8B8A8_SNORM: - case PIPE_FORMAT_A8B8G8R8_SRGB: case PIPE_FORMAT_X8B8G8R8_UNORM: - case PIPE_FORMAT_X8B8G8R8_SRGB: return modifier | R300_C0_SEL_A | R300_C1_SEL_B | R300_C2_SEL_G | R300_C3_SEL_R; From f6e987ce7839d66edb88403d2c9ac1b28db2832b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 18 Mar 2010 21:18:36 +0100 Subject: [PATCH 170/483] r300g: add PIPE_FORMAT_B5G5R5X1_UNORM colorbuffer support, cleanups --- src/gallium/drivers/r300/r300_texture.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 09067aab3bf..cb53619fe5e 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -310,6 +310,7 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_B5G6R5_UNORM: return R300_COLOR_FORMAT_RGB565; case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B5G5R5X1_UNORM: return R300_COLOR_FORMAT_ARGB1555; case PIPE_FORMAT_B4G4R4A4_UNORM: return R300_COLOR_FORMAT_ARGB4444; @@ -420,9 +421,10 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) case PIPE_FORMAT_R8_SNORM: return modifier | R300_C2_SEL_R; - /* ARGB 32-bit outputs. */ + /* BGRA outputs. */ case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B5G5R5X1_UNORM: case PIPE_FORMAT_B4G4R4A4_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_B8G8R8X8_UNORM: @@ -430,25 +432,24 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A; - /* BGRA 32-bit outputs. */ + /* ARGB outputs. */ case PIPE_FORMAT_A8R8G8B8_UNORM: case PIPE_FORMAT_X8R8G8B8_UNORM: return modifier | R300_C0_SEL_A | R300_C1_SEL_R | R300_C2_SEL_G | R300_C3_SEL_B; - /* RGBA 32-bit outputs. */ + /* ABGR outputs. */ case PIPE_FORMAT_A8B8G8R8_UNORM: - case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_X8B8G8R8_UNORM: return modifier | R300_C0_SEL_A | R300_C1_SEL_B | R300_C2_SEL_G | R300_C3_SEL_R; - /* ABGR 32-bit outputs. */ + /* RGBA outputs. */ + case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_R8SG8SB8UX8U_NORM: case PIPE_FORMAT_R10G10B10A2_UNORM: - /* RGBA high precision outputs (same swizzles as ABGR low precision) */ case PIPE_FORMAT_R16G16B16A16_UNORM: case PIPE_FORMAT_R16G16B16A16_SNORM: //case PIPE_FORMAT_R16G16B16A16_FLOAT: /* not in pipe_format */ From 689e4b554123bbf9af727b910dad9d1b32521f95 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Mar 2010 17:28:52 -0700 Subject: [PATCH 171/483] intel: Correct value of S0_VB_OFFSET_MASK to match hardware docs. --- src/mesa/drivers/dri/intel/intel_reg.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_reg.h b/src/mesa/drivers/dri/intel/intel_reg.h index d19f1bae34c..36d8180598e 100644 --- a/src/mesa/drivers/dri/intel/intel_reg.h +++ b/src/mesa/drivers/dri/intel/intel_reg.h @@ -70,8 +70,10 @@ /** @{ * 915 definitions + * + * 915 documents say that bits 31:28 and 1 are "undefined, must be zero." */ -#define S0_VB_OFFSET_MASK 0xffffffc0 +#define S0_VB_OFFSET_MASK 0x0ffffffc #define S0_AUTO_CACHE_INV_DISABLE (1<<0) /** @} */ From 062a208814ad65d330f403c46d4bed88648f334f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Mar 2010 17:30:15 -0700 Subject: [PATCH 172/483] intel: Use bit-wise not instead of logical not (i830 path) The assertion is checking that the low-order bits of offset are not set. It does this by anding the inverted offset mask with the offset. This is clearly intended to be a bit-wise "invert". Fixes bug #25984. --- src/mesa/drivers/dri/i915/intel_tris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 4b6d3b4c5be..81c4adeaf34 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -270,7 +270,7 @@ void intel_flush_prim(struct intel_context *intel) OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(0) | I1_LOAD_S(2) | 1); /* S0 */ - assert((offset & !S0_VB_OFFSET_MASK_830) == 0); + assert((offset & ~S0_VB_OFFSET_MASK_830) == 0); OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset | (intel->vertex_size << S0_VB_PITCH_SHIFT_830) | S0_VB_ENABLE_830); From afae0891949b72a2ede2a3b6a01d4d6bcf4ceae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 19 Mar 2010 01:13:57 +0100 Subject: [PATCH 173/483] r300g: fix breakage after the gallium-sampler-view merge --- src/gallium/drivers/r300/r300_emit.c | 6 ++++-- src/gallium/drivers/r300/r300_state.c | 12 ++++++++---- src/gallium/drivers/r300/r300_state_derived.c | 13 ++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 5522fb306db..c897df628d2 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1050,9 +1050,11 @@ validate: } /* ...textures... */ for (i = 0; i < texstate->count; i++) { - tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture; - if (!tex || !texstate->sampler_states[i]) + if (!(texstate->tx_enable & (1 << i))) { continue; + } + + tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture; if (!r300_add_texture(r300->rws, tex, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { r300->context.flush(&r300->context, 0, NULL); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index db7844eef0e..bdfe74ed2a0 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -973,6 +973,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); struct r300_textures_state* state = (struct r300_textures_state*)r300->textures_state.state; + struct r300_texture *texture; unsigned i; boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; boolean dirty_tex = FALSE; @@ -984,15 +985,18 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe, for (i = 0; i < count; i++) { if (state->fragment_sampler_views[i] != views[i]) { - struct r300_texture *texture; - pipe_sampler_view_reference(&state->fragment_sampler_views[i], views[i]); + + if (!views[i]) { + continue; + } + + /* A new sampler view (= texture)... */ dirty_tex = TRUE; - texture = (struct r300_texture *)views[i]->texture; - /* R300-specific - set the texrect factor in the fragment shader */ + texture = (struct r300_texture *)views[i]->texture; if (!is_r500 && texture->is_npot) { /* XXX It would be nice to re-emit just 1 constant, * XXX not all of them */ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 74663bda514..85947353ee9 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -335,20 +335,25 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) (struct r300_textures_state*)r300->textures_state.state; struct r300_texture_sampler_state *texstate; struct r300_sampler_state *sampler; + struct pipe_sampler_view *view; struct r300_texture *tex; unsigned min_level, max_level, i, size; unsigned count = MIN2(state->texture_count, state->sampler_count); state->tx_enable = 0; + state->count = 0; size = 2; for (i = 0; i < count; i++) { if (state->fragment_sampler_views[i] && state->sampler_states[i]) { state->tx_enable |= 1 << i; - tex = (struct r300_texture *)state->fragment_sampler_views[i]->texture; + view = state->fragment_sampler_views[i]; + tex = (struct r300_texture *)view->texture; sampler = state->sampler_states[i]; + assert(view->format == tex->tex.format); + texstate = &state->regs[i]; memcpy(texstate->format, &tex->state, sizeof(uint32_t)*3); texstate->filter[0] = sampler->filter0; @@ -370,8 +375,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) } else { /* determine min/max levels */ /* the MAX_MIP level is the largest (finest) one */ - max_level = MIN2(sampler->max_lod, tex->tex.last_level); - min_level = MIN2(sampler->min_lod, max_level); + max_level = MIN3(sampler->max_lod, tex->tex.last_level, + view->last_level); + min_level = MIN2(MAX2(sampler->min_lod, view->first_level), + max_level); texstate->format[0] |= R300_TX_NUM_LEVELS(max_level); texstate->filter[0] |= R300_TX_MAX_MIP_LEVEL(min_level); } From 12a40dda394bd14e31c679551bc5abc8b601fdbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 19 Mar 2010 04:46:15 +0100 Subject: [PATCH 174/483] r300g: lod min/max clamping should be relative to the base level --- src/gallium/drivers/r300/r300_state_derived.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 85947353ee9..8178d55dc9a 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -375,9 +375,9 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) } else { /* determine min/max levels */ /* the MAX_MIP level is the largest (finest) one */ - max_level = MIN3(sampler->max_lod, tex->tex.last_level, - view->last_level); - min_level = MIN2(MAX2(sampler->min_lod, view->first_level), + max_level = MIN3(sampler->max_lod + view->first_level, + tex->tex.last_level, view->last_level); + min_level = MIN2(sampler->min_lod + view->first_level, max_level); texstate->format[0] |= R300_TX_NUM_LEVELS(max_level); texstate->filter[0] |= R300_TX_MAX_MIP_LEVEL(min_level); From 8e1768cfd32a4fa47dd5d4e8f5434fafc3b31201 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 19 Mar 2010 00:07:55 -0700 Subject: [PATCH 175/483] gallium/docs: Fix a couple ReST errors. --- src/gallium/docs/source/context.rst | 1 + src/gallium/docs/source/cso/velems.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 1f022570dbb..e7a693251ef 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -50,6 +50,7 @@ Non-CSO State These pieces of state are too small, variable, and/or trivial to have CSO objects. They all follow simple, one-method binding calls, e.g. ``set_blend_color``. + * ``set_stencil_ref`` sets the stencil front and back reference values which are used as comparison values in stencil test. * ``set_blend_color`` diff --git a/src/gallium/docs/source/cso/velems.rst b/src/gallium/docs/source/cso/velems.rst index 8e758fae103..92cde014fb8 100644 --- a/src/gallium/docs/source/cso/velems.rst +++ b/src/gallium/docs/source/cso/velems.rst @@ -1,4 +1,4 @@ -.. _vertex,elements +.. _vertexelements: Vertex Elements =============== From 980da4aed28eca5770323e4fa55b2fd2670261cf Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 19 Mar 2010 09:08:33 +0100 Subject: [PATCH 176/483] gallium/docs: Clarify sampler view descriptions. --- src/gallium/docs/source/context.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index e7a693251ef..2b0941010b0 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -74,11 +74,11 @@ is being cast to another format. Casting can be done only between compatible formats, that is formats that have matching component order and sizes. Swizzle fields specify they way in which fetched texel components are placed -in the result register. For example, swizzle_r specifies what is going to be -placed in destination register x (AKA r). +in the result register. For example, ``swizzle_r`` specifies what is going to be +placed in first component of result register. -first_level and last_level fields of sampler view template specify the LOD -range the texture is going to be constrained to. +The ``first_level`` and ``last_level`` fields of sampler view template specify +the LOD range the texture is going to be constrained to. * ``set_fragment_sampler_views`` binds an array of sampler views to fragment shader stage. Every binding point acquires a reference @@ -89,7 +89,7 @@ range the texture is going to be constrained to. shader stage. Every binding point acquires a reference to a respective sampler view and releases a reference to the previous sampler view. -* ``create_sampler_view`` creates a new sampler view. texture is associated +* ``create_sampler_view`` creates a new sampler view. ``texture`` is associated with the sampler view which results in sampler view holding a reference to the texture. Format specified in template must be compatible with texture format. From 8221a0e7f7eeff2c8201afcf4f5b46fc36dc8606 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Mar 2010 07:36:50 -0600 Subject: [PATCH 177/483] es: added -I$(TOP)/include path --- src/gallium/state_trackers/es/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile index e33685d2471..089d4411675 100644 --- a/src/gallium/state_trackers/es/Makefile +++ b/src/gallium/state_trackers/es/Makefile @@ -38,6 +38,7 @@ SYS_LIBS = -lm -pthread INCLUDE_DIRS = \ + -I$(TOP)/include \ -I$(TOP)/src/mesa \ -I$(TOP)/src/gallium/include From e5f0384ad06359aa1b9dc1b4bc6f475f7a119af2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 19 Mar 2010 16:29:22 +0100 Subject: [PATCH 178/483] st/vega: fix up vega state tracker to use cso changes use cso fragment sampler views instead of sampler textures. since we don't really change views, try to store sampler views instead of the textures to avoid having to recreate views most of the time. --- src/gallium/state_trackers/vega/api_filters.c | 73 ++++++++++++------- src/gallium/state_trackers/vega/image.c | 37 ++++++---- src/gallium/state_trackers/vega/image.h | 4 +- src/gallium/state_trackers/vega/mask.c | 66 ++++++++++------- src/gallium/state_trackers/vega/mask.h | 2 +- src/gallium/state_trackers/vega/paint.c | 62 +++++++++++----- src/gallium/state_trackers/vega/paint.h | 2 +- src/gallium/state_trackers/vega/renderer.c | 37 ++++++---- src/gallium/state_trackers/vega/renderer.h | 3 +- src/gallium/state_trackers/vega/shader.c | 32 ++++---- src/gallium/state_trackers/vega/vg_context.c | 16 +++- src/gallium/state_trackers/vega/vg_context.h | 5 +- src/gallium/state_trackers/vega/vg_tracker.c | 58 ++++++++++----- 13 files changed, 252 insertions(+), 145 deletions(-) diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 18e2cc1f250..a643f38624f 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -40,6 +40,7 @@ #include "util/u_format.h" #include "util/u_memory.h" +#include "util/u_sampler.h" #include "asm_filters.h" @@ -53,7 +54,7 @@ struct filter_info { const void *const_buffer; VGint const_buffer_len; VGTilingMode tiling_mode; - struct pipe_texture *extra_texture; + struct pipe_sampler_view *extra_texture_view; }; static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, @@ -91,13 +92,35 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, return tex; } +static INLINE struct pipe_sampler_view *create_texture_1d_view(struct vg_context *ctx, + const VGuint *color_data, + const VGint color_data_len) +{ + struct pipe_context *pipe = ctx->pipe; + struct pipe_texture *texture; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; + + texture = create_texture_1d(ctx, color_data, color_data_len); + + if (!texture) + return NULL; + + u_sampler_view_default_template(&view_templ, texture, texture->format); + view = pipe->create_sampler_view(pipe, texture, &view_templ); + /* want the texture to go away if the view is freed */ + pipe_texture_reference(&texture, NULL); + + return view; +} + static INLINE struct pipe_surface * setup_framebuffer(struct vg_image *dst) { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; struct pipe_framebuffer_state fb; struct pipe_surface *dst_surf = pipe->screen->get_tex_surface( - pipe->screen, dst->texture, 0, 0, 0, + pipe->screen, dst->sampler_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); /* drawing dest */ @@ -168,7 +191,7 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer, static void setup_samplers(struct vg_context *ctx, struct filter_info *info) { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state sampler[3]; int num_samplers = 0; int num_textures = 0; @@ -177,10 +200,10 @@ static void setup_samplers(struct vg_context *ctx, struct filter_info *info) samplers[1] = NULL; samplers[2] = NULL; samplers[3] = NULL; - textures[0] = NULL; - textures[1] = NULL; - textures[2] = NULL; - textures[3] = NULL; + sampler_views[0] = NULL; + sampler_views[1] = NULL; + sampler_views[2] = NULL; + sampler_views[3] = NULL; memset(&sampler[0], 0, sizeof(struct pipe_sampler_state)); sampler[0].wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; @@ -215,21 +238,21 @@ static void setup_samplers(struct vg_context *ctx, struct filter_info *info) } samplers[0] = &sampler[0]; - textures[0] = info->src->texture; + sampler_views[0] = info->src->sampler_view; ++num_samplers; ++num_textures; - if (info->extra_texture) { + if (info->extra_texture_view) { memcpy(&sampler[1], &sampler[0], sizeof(struct pipe_sampler_state)); samplers[1] = &sampler[1]; - textures[1] = info->extra_texture; + sampler_views[1] = info->extra_texture_view; ++num_samplers; ++num_textures; } cso_set_samplers(ctx->cso_context, num_samplers, (const struct pipe_sampler_state **)samplers); - cso_set_sampler_textures(ctx->cso_context, num_textures, textures); + cso_set_fragment_sampler_views(ctx->cso_context, num_textures, sampler_views); } static struct vg_shader * setup_color_matrix(struct vg_context *ctx, void *user_data) @@ -308,7 +331,7 @@ static void execute_filter(struct vg_context *ctx, cso_save_viewport(ctx->cso_context); cso_save_blend(ctx->cso_context); cso_save_samplers(ctx->cso_context); - cso_save_sampler_textures(ctx->cso_context); + cso_save_fragment_sampler_views(ctx->cso_context); dst_surf = setup_framebuffer(info->dst); setup_viewport(info->dst); @@ -318,7 +341,7 @@ static void execute_filter(struct vg_context *ctx, setup_samplers(ctx, info); renderer_draw_texture(ctx->renderer, - info->src->texture, + info->src->sampler_view->texture, info->dst->x, info->dst->y, info->dst->x + info->dst->width, info->dst->y + info->dst->height, @@ -331,7 +354,7 @@ static void execute_filter(struct vg_context *ctx, cso_restore_viewport(ctx->cso_context); cso_restore_blend(ctx->cso_context); cso_restore_samplers(ctx->cso_context); - cso_restore_sampler_textures(ctx->cso_context); + cso_restore_fragment_sampler_views(ctx->cso_context); vg_shader_destroy(ctx, shader); @@ -369,7 +392,7 @@ void vgColorMatrix(VGImage dst, VGImage src, info.const_buffer = matrix; info.const_buffer_len = 20 * sizeof(VGfloat); info.tiling_mode = VG_TILE_PAD; - info.extra_texture = 0; + info.extra_texture_view = NULL; execute_filter(ctx, &info); } @@ -479,7 +502,7 @@ void vgConvolve(VGImage dst, VGImage src, info.const_buffer = buffer; info.const_buffer_len = buffer_len * sizeof(VGfloat); info.tiling_mode = tilingMode; - info.extra_texture = 0; + info.extra_texture_view = NULL; execute_filter(ctx, &info); free(buffer); @@ -669,7 +692,7 @@ void vgGaussianBlur(VGImage dst, VGImage src, info.const_buffer = buffer; info.const_buffer_len = buffer_len * sizeof(VGfloat); info.tiling_mode = tilingMode; - info.extra_texture = 0; + info.extra_texture_view = NULL; execute_filter(ctx, &info); free(buffer); @@ -688,7 +711,7 @@ void vgLookup(VGImage dst, VGImage src, struct vg_image *d, *s; VGuint color_data[256]; VGint i; - struct pipe_texture *lut_texture; + struct pipe_sampler_view *lut_texture_view; VGfloat buffer[4]; struct filter_info info; @@ -714,7 +737,7 @@ void vgLookup(VGImage dst, VGImage src, color_data[i] = blueLUT[i] << 24 | greenLUT[i] << 16 | redLUT[i] << 8 | alphaLUT[i]; } - lut_texture = create_texture_1d(ctx, color_data, 255); + lut_texture_view = create_texture_1d_view(ctx, color_data, 255); buffer[0] = 0.f; buffer[1] = 0.f; @@ -728,11 +751,11 @@ void vgLookup(VGImage dst, VGImage src, info.const_buffer = buffer; info.const_buffer_len = 4 * sizeof(VGfloat); info.tiling_mode = VG_TILE_PAD; - info.extra_texture = lut_texture; + info.extra_texture_view = lut_texture_view; execute_filter(ctx, &info); - pipe_texture_reference(&lut_texture, NULL); + pipe_sampler_view_reference(&lut_texture_view, NULL); } void vgLookupSingle(VGImage dst, VGImage src, @@ -743,7 +766,7 @@ void vgLookupSingle(VGImage dst, VGImage src, { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; - struct pipe_texture *lut_texture; + struct pipe_sampler_view *lut_texture_view; VGfloat buffer[4]; struct filter_info info; VGuint color_data[256]; @@ -783,7 +806,7 @@ void vgLookupSingle(VGImage dst, VGImage src, color_data[i] = blue << 24 | green << 16 | red << 8 | alpha; } - lut_texture = create_texture_1d(ctx, color_data, 256); + lut_texture_view = create_texture_1d_view(ctx, color_data, 256); buffer[0] = 0.f; buffer[1] = 0.f; @@ -797,9 +820,9 @@ void vgLookupSingle(VGImage dst, VGImage src, info.const_buffer = buffer; info.const_buffer_len = 4 * sizeof(VGfloat); info.tiling_mode = VG_TILE_PAD; - info.extra_texture = lut_texture; + info.extra_texture_view = lut_texture_view; execute_filter(ctx, &info); - pipe_texture_reference(&lut_texture, NULL); + pipe_sampler_view_reference(&lut_texture_view, NULL); } diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index a71579cd264..c3268a84a60 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -43,6 +43,7 @@ #include "util/u_tile.h" #include "util/u_memory.h" #include "util/u_math.h" +#include "util/u_sampler.h" static enum pipe_format vg_format_to_pipe(VGImageFormat format) { @@ -81,7 +82,7 @@ static INLINE void vg_sync_size(VGfloat *src_loc, VGfloat *dst_loc) static void vg_copy_texture(struct vg_context *ctx, struct pipe_texture *dst, VGint dx, VGint dy, - struct pipe_texture *src, VGint sx, VGint sy, + struct pipe_sampler_view *src, VGint sx, VGint sy, VGint width, VGint height) { VGfloat dst_loc[4], src_loc[4]; @@ -103,8 +104,8 @@ static void vg_copy_texture(struct vg_context *ctx, src_loc[3] = height; src_bounds[0] = 0.f; src_bounds[1] = 0.f; - src_bounds[2] = src->width0; - src_bounds[3] = src->height0; + src_bounds[2] = src->texture->width0; + src_bounds[3] = src->texture->height0; vg_bound_rect(src_loc, src_bounds, src_shift); vg_bound_rect(dst_loc, dst_bounds, dst_shift); @@ -218,7 +219,7 @@ void vg_copy_surface(struct vg_context *ctx, static struct pipe_texture *image_texture(struct vg_image *img) { - struct pipe_texture *tex = img->texture; + struct pipe_texture *tex = img->sampler_view->texture; return tex; } @@ -247,9 +248,12 @@ struct vg_image * image_create(VGImageFormat format, VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); + struct pipe_context *pipe = ctx->pipe; struct vg_image *image = CALLOC_STRUCT(vg_image); enum pipe_format pformat = vg_format_to_pipe(format); struct pipe_texture pt, *newtex; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; struct pipe_screen *screen = ctx->pipe->screen; vg_init_object(&image->base, ctx, VG_OBJECT_IMAGE); @@ -281,7 +285,12 @@ struct vg_image * image_create(VGImageFormat format, debug_assert(newtex); - image->texture = newtex; + u_sampler_view_default_template(&view_templ, newtex, newtex->format); + view = pipe->create_sampler_view(pipe, newtex, &view_templ); + /* want the texture to go away if the view is freed */ + pipe_texture_reference(&newtex, NULL); + + image->sampler_view = view; vg_context_add_object(ctx, VG_OBJECT_IMAGE, image); @@ -345,7 +354,7 @@ void image_destroy(struct vg_image *img) array_destroy(img->children_array); } - pipe_texture_reference(&img->texture, NULL); + pipe_sampler_view_reference(&img->sampler_view, NULL); free(img); } @@ -444,7 +453,7 @@ void image_get_sub_data(struct vg_image * image, { struct pipe_transfer *transfer = pipe->get_tex_transfer(pipe, - image->texture, 0, 0, 0, + image->sampler_view->texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, image->x + image->width, @@ -478,9 +487,9 @@ struct vg_image * image_child_image(struct vg_image *parent, image->width = width; image->height = height; image->parent = parent; - image->texture = 0; - pipe_texture_reference(&image->texture, - parent->texture); + image->sampler_view = NULL; + pipe_sampler_view_reference(&image->sampler_view, + parent->sampler_view); image->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; image->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; @@ -514,8 +523,8 @@ void image_copy(struct vg_image *dst, VGint dx, VGint dy, } /* make sure rendering has completed */ ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - vg_copy_texture(ctx, dst->texture, dst->x + dx, dst->y + dy, - src->texture, src->x + sx, src->y + sy, width, height); + vg_copy_texture(ctx, dst->sampler_view->texture, dst->x + dx, dst->y + dy, + src->sampler_view, src->x + sx, src->y + sy, width, height); } void image_draw(struct vg_image *img) @@ -624,12 +633,12 @@ VGboolean vg_image_overlaps(struct vg_image *dst, } VGint image_bind_samplers(struct vg_image *img, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_sampler_view **sampler_views) { img->sampler.min_img_filter = image_sampler_filter(img->base.ctx); img->sampler.mag_img_filter = image_sampler_filter(img->base.ctx); samplers[3] = &img->sampler; - textures[3] = img->texture; + sampler_views[3] = img->sampler_view; return 1; } diff --git a/src/gallium/state_trackers/vega/image.h b/src/gallium/state_trackers/vega/image.h index 78e17cffa64..805b35fab9f 100644 --- a/src/gallium/state_trackers/vega/image.h +++ b/src/gallium/state_trackers/vega/image.h @@ -43,7 +43,7 @@ struct vg_image { struct vg_image *parent; - struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; struct pipe_sampler_state sampler; struct array *children_array; @@ -89,7 +89,7 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, VGint width, VGint height); VGint image_bind_samplers(struct vg_image *dst, struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_sampler_view **sampler_views); VGboolean vg_image_overlaps(struct vg_image *dst, struct vg_image *src); diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 839dc19a3b8..316ea7a9c95 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -45,7 +45,7 @@ struct vg_mask_layer { VGint width; VGint height; - struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; }; static INLINE struct pipe_surface * @@ -54,7 +54,7 @@ alpha_mask_surface(struct vg_context *ctx, int usage) struct pipe_screen *screen = ctx->pipe->screen; struct st_framebuffer *stfb = ctx->draw_buffer; return screen->get_tex_surface(screen, - stfb->alpha_mask, + stfb->alpha_mask_view->texture, 0, 0, 0, usage); } @@ -284,35 +284,33 @@ static void setup_mask_operation(VGMaskOperation operation) cso_set_fragment_shader_handle(ctx->cso_context, shader); } -static void setup_mask_samplers(struct pipe_texture *umask) +static void setup_mask_samplers(struct pipe_sampler_view *umask) { struct vg_context *ctx = vg_current_context(); struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct st_framebuffer *fb_buffers = ctx->draw_buffer; - struct pipe_texture *uprev = NULL; + struct pipe_sampler_view *uprev = NULL; struct pipe_sampler_state sampler; - uprev = fb_buffers->blend_texture; + uprev = fb_buffers->blend_texture_view; sampler = ctx->mask.sampler; sampler.normalized_coords = 1; samplers[0] = NULL; samplers[1] = NULL; - samplers[2] = NULL; - textures[0] = NULL; - textures[1] = NULL; - textures[2] = NULL; + sampler_views[0] = NULL; + sampler_views[1] = NULL; samplers[0] = &sampler; samplers[1] = &ctx->mask.sampler; - textures[0] = umask; - textures[1] = uprev; + sampler_views[0] = umask; + sampler_views[1] = uprev; cso_set_samplers(ctx->cso_context, 2, (const struct pipe_sampler_state **)samplers); - cso_set_sampler_textures(ctx->cso_context, 2, textures); + cso_set_fragment_sampler_views(ctx->cso_context, 2, sampler_views); } @@ -411,12 +409,13 @@ static void surface_fill(struct pipe_surface *surf, } -static void mask_using_texture(struct pipe_texture *texture, +static void mask_using_texture(struct pipe_sampler_view *sampler_view, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); + struct pipe_texture *texture = sampler_view->texture; struct pipe_surface *surface = alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_GPU_WRITE); VGint offsets[4], loc[4]; @@ -439,13 +438,13 @@ static void mask_using_texture(struct pipe_texture *texture, vg_prepare_blend_surface_from_mask(ctx); cso_save_samplers(ctx->cso_context); - cso_save_sampler_textures(ctx->cso_context); + cso_save_fragment_sampler_views(ctx->cso_context); cso_save_framebuffer(ctx->cso_context); cso_save_blend(ctx->cso_context); cso_save_fragment_shader(ctx->cso_context); cso_save_viewport(ctx->cso_context); - setup_mask_samplers(texture); + setup_mask_samplers(sampler_view); setup_mask_blend(); setup_mask_operation(operation); setup_mask_framebuffer(surface, surface->width, surface->height); @@ -463,7 +462,7 @@ static void mask_using_texture(struct pipe_texture *texture, cso_restore_framebuffer(ctx->cso_context); cso_restore_fragment_shader(ctx->cso_context); cso_restore_samplers(ctx->cso_context); - cso_restore_sampler_textures(ctx->cso_context); + cso_restore_fragment_sampler_views(ctx->cso_context); cso_restore_viewport(ctx->cso_context); pipe_surface_reference(&surface, NULL); @@ -484,7 +483,11 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) { struct pipe_texture pt; + struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = ctx->pipe->screen; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view = NULL; + struct pipe_texture *texture; memset(&pt, 0, sizeof(pt)); pt.target = PIPE_TEXTURE_2D; @@ -496,7 +499,14 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; pt.compressed = 0; - mask->texture = screen->texture_create(screen, &pt); + texture = screen->texture_create(screen, &pt); + + if (texture) { + u_sampler_view_default_template(&view_templ, texture, texture->format); + view = pipe->create_sampler_view(pipe, texture, &view_templ); + } + pipe_texture_reference(&texture, NULL); + mask->sampler_view = view; } vg_context_add_object(ctx, VG_OBJECT_MASK, mask); @@ -525,7 +535,7 @@ void mask_layer_fill(struct vg_mask_layer *layer, alpha_color[3] = value; surface = ctx->pipe->screen->get_tex_surface( - ctx->pipe->screen, layer->texture, + ctx->pipe->screen, layer->sampler_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); @@ -545,10 +555,10 @@ void mask_copy(struct vg_mask_layer *layer, struct st_framebuffer *fb_buffers = ctx->draw_buffer; renderer_copy_texture(ctx->renderer, - layer->texture, + layer->sampler_view, sx, sy, sx + width, sy + height, - fb_buffers->alpha_mask, + fb_buffers->alpha_mask_view->texture, dx, dy, dx + width, dy + height); } @@ -562,7 +572,7 @@ static void mask_layer_render_to(struct vg_mask_layer *layer, struct pipe_screen *screen = ctx->pipe->screen; struct pipe_surface *surface; - surface = screen->get_tex_surface(screen, layer->texture, 0, 0, 0, + surface = screen->get_tex_surface(screen, layer->sampler_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); cso_save_framebuffer(ctx->cso_context); @@ -604,8 +614,8 @@ void mask_render_to(struct path *path, struct vg_mask_layer *temp_layer; VGint width, height; - width = fb_buffers->alpha_mask->width0; - height = fb_buffers->alpha_mask->width0; + width = fb_buffers->alpha_mask_view->texture->width0; + height = fb_buffers->alpha_mask_view->texture->width0; temp_layer = mask_layer_create(width, height); @@ -622,7 +632,7 @@ void mask_using_layer(struct vg_mask_layer *layer, VGint x, VGint y, VGint width, VGint height) { - mask_using_texture(layer->texture, operation, + mask_using_texture(layer->sampler_view, operation, x, y, width, height); } @@ -644,7 +654,7 @@ void mask_using_image(struct vg_image *image, VGint x, VGint y, VGint width, VGint height) { - mask_using_texture(image->texture, operation, + mask_using_texture(image->sampler_view, operation, x, y, width, height); } @@ -672,7 +682,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height, } VGint mask_bind_samplers(struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_sampler_view **sampler_views) { struct vg_context *ctx = vg_current_context(); @@ -680,7 +690,7 @@ VGint mask_bind_samplers(struct pipe_sampler_state **samplers, struct st_framebuffer *fb_buffers = ctx->draw_buffer; samplers[1] = &ctx->mask.sampler; - textures[1] = fb_buffers->alpha_mask; + sampler_views[1] = fb_buffers->alpha_mask_view; return 1; } else return 0; diff --git a/src/gallium/state_trackers/vega/mask.h b/src/gallium/state_trackers/vega/mask.h index 5eaaede0e3a..4feacbefda8 100644 --- a/src/gallium/state_trackers/vega/mask.h +++ b/src/gallium/state_trackers/vega/mask.h @@ -63,6 +63,6 @@ void mask_fill(VGint x, VGint y, VGfloat value); VGint mask_bind_samplers(struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_sampler_view **sampler_views); #endif diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index dc56b8c5f3b..508e1863a57 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -37,6 +37,7 @@ #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_math.h" +#include "util/u_sampler.h" #include "cso_cache/cso_context.h" @@ -61,7 +62,7 @@ struct vg_paint { VGfloat vals[5]; VGint valsi[5]; } radial; - struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; struct pipe_sampler_state sampler; VGfloat *ramp_stops; @@ -72,7 +73,7 @@ struct vg_paint { } gradient; struct { - struct pipe_texture *texture; + struct pipe_sampler_view *sampler_view; VGTilingMode tiling_mode; struct pipe_sampler_state sampler; } pattern; @@ -173,6 +174,26 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) return tex; } +static INLINE struct pipe_sampler_view *create_gradient_sampler_view(struct vg_paint *p) +{ + struct pipe_context *pipe = p->base.ctx->pipe; + struct pipe_texture *texture; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; + + texture = create_gradient_texture(p); + + if (!texture) + return NULL; + + u_sampler_view_default_template(&view_templ, texture, texture->format); + view = pipe->create_sampler_view(pipe, texture, &view_templ); + /* want the texture to go away if the view is freed */ + pipe_texture_reference(&texture, NULL); + + return view; +} + struct vg_paint * paint_create(struct vg_context *ctx) { struct vg_paint *paint = CALLOC_STRUCT(vg_paint); @@ -207,8 +228,9 @@ struct vg_paint * paint_create(struct vg_context *ctx) void paint_destroy(struct vg_paint *paint) { struct vg_context *ctx = paint->base.ctx; - if (paint->pattern.texture) - pipe_texture_reference(&paint->pattern.texture, NULL); + pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL); + if (paint->pattern.sampler_view) + pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL); if (ctx) vg_context_remove_object(ctx, VG_OBJECT_PAINT, paint); @@ -329,8 +351,8 @@ static INLINE void paint_pattern_buffer(struct vg_paint *paint, void *buffer) map[4] = 0.f; map[5] = 1.f; - map[6] = paint->pattern.texture->width0; - map[7] = paint->pattern.texture->height0; + map[6] = paint->pattern.sampler_view->texture->width0; + map[7] = paint->pattern.sampler_view->texture->height0; { struct matrix mat; memcpy(&mat, &ctx->state.vg.fill_paint_to_user_matrix, @@ -394,12 +416,12 @@ void paint_set_ramp_stops(struct vg_paint *paint, const VGfloat *stops, create_gradient_data(stops, num / 5, paint->gradient.color_data, 1024); - if (paint->gradient.texture) { - pipe_texture_reference(&paint->gradient.texture, NULL); - paint->gradient.texture = 0; + if (paint->gradient.sampler_view) { + pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL); + paint->gradient.sampler_view = NULL; } - paint->gradient.texture = create_gradient_texture(paint); + paint->gradient.sampler_view = create_gradient_sampler_view(paint); } void paint_set_colori(struct vg_paint *p, @@ -459,12 +481,12 @@ void paint_set_radial_gradient(struct vg_paint *paint, void paint_set_pattern(struct vg_paint *paint, struct vg_image *img) { - if (paint->pattern.texture) - pipe_texture_reference(&paint->pattern.texture, NULL); + if (paint->pattern.sampler_view) + pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL); - paint->pattern.texture = 0; - pipe_texture_reference(&paint->pattern.texture, - img->texture); + paint->pattern.sampler_view = NULL; + pipe_sampler_view_reference(&paint->pattern.sampler_view, + img->sampler_view); } void paint_set_pattern_tiling(struct vg_paint *paint, @@ -611,18 +633,18 @@ VGTilingMode paint_pattern_tiling(struct vg_paint *paint) } VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_sampler_view **sampler_views) { struct vg_context *ctx = vg_current_context(); switch(paint->type) { case VG_PAINT_TYPE_LINEAR_GRADIENT: case VG_PAINT_TYPE_RADIAL_GRADIENT: { - if (paint->gradient.texture) { + if (paint->gradient.sampler_view) { paint->gradient.sampler.min_img_filter = image_sampler_filter(ctx); paint->gradient.sampler.mag_img_filter = image_sampler_filter(ctx); samplers[0] = &paint->gradient.sampler; - textures[0] = paint->gradient.texture; + sampler_views[0] = paint->gradient.sampler_view; return 1; } } @@ -634,7 +656,7 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa paint->pattern.sampler.min_img_filter = image_sampler_filter(ctx); paint->pattern.sampler.mag_img_filter = image_sampler_filter(ctx); samplers[0] = &paint->pattern.sampler; - textures[0] = paint->pattern.texture; + sampler_views[0] = paint->pattern.sampler_view; return 1; } break; @@ -647,7 +669,7 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa void paint_resolve_type(struct vg_paint *paint) { if (paint->type == VG_PAINT_TYPE_PATTERN && - !paint->pattern.texture) { + !paint->pattern.sampler_view) { paint->type = VG_PAINT_TYPE_COLOR; } } diff --git a/src/gallium/state_trackers/vega/paint.h b/src/gallium/state_trackers/vega/paint.h index 999b5c167ca..9ea67c4b1e6 100644 --- a/src/gallium/state_trackers/vega/paint.h +++ b/src/gallium/state_trackers/vega/paint.h @@ -108,7 +108,7 @@ VGboolean paint_color_ramp_premultiplied(struct vg_paint *paint); VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers, - struct pipe_texture **textures); + struct pipe_sampler_view **sampler_views); VGint paint_constant_buffer_size(struct vg_paint *paint); void paint_fill_constant_buffer(struct vg_paint *paint, diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 47e8b470a11..2bb4c8bc756 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -39,6 +39,7 @@ #include "util/u_simple_shaders.h" #include "util/u_memory.h" #include "util/u_rect.h" +#include "util/u_sampler.h" #include "cso_cache/cso_context.h" @@ -263,7 +264,7 @@ void renderer_draw_texture(struct renderer *r, } void renderer_copy_texture(struct renderer *ctx, - struct pipe_texture *src, + struct pipe_sampler_view *src, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, struct pipe_texture *dst, @@ -272,6 +273,7 @@ void renderer_copy_texture(struct renderer *ctx, { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; + struct pipe_texture *tex = src->texture; struct pipe_buffer *buf; struct pipe_surface *dst_surf = screen->get_tex_surface( screen, dst, 0, 0, 0, @@ -279,8 +281,8 @@ void renderer_copy_texture(struct renderer *ctx, struct pipe_framebuffer_state fb; float s0, t0, s1, t1; - assert(src->width0 != 0); - assert(src->height0 != 0); + assert(tex->width0 != 0); + assert(tex->height0 != 0); assert(dst->width0 != 0); assert(dst->height0 != 0); @@ -290,10 +292,10 @@ void renderer_copy_texture(struct renderer *ctx, #endif #if 1 - s0 = sx1 / src->width0; - s1 = sx2 / src->width0; - t0 = sy1 / src->height0; - t1 = sy2 / src->height0; + s0 = sx1 / tex->width0; + s1 = sx2 / tex->width0; + t0 = sy1 / tex->height0; + t1 = sy2 / tex->height0; #else s0 = 0; s1 = 1; @@ -307,7 +309,7 @@ void renderer_copy_texture(struct renderer *ctx, /* save state (restored below) */ cso_save_blend(ctx->cso); cso_save_samplers(ctx->cso); - cso_save_sampler_textures(ctx->cso); + cso_save_fragment_sampler_views(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); @@ -345,7 +347,7 @@ void renderer_copy_texture(struct renderer *ctx, vg_set_viewport(ctx->owner, VEGA_Y0_TOP); /* texture */ - cso_set_sampler_textures(ctx->cso, 1, &src); + cso_set_fragment_sampler_views(ctx->cso, 1, &src); /* shaders */ cso_set_vertex_shader_handle(ctx->cso, vg_texture_vs(ctx->owner)); @@ -385,7 +387,7 @@ void renderer_copy_texture(struct renderer *ctx, /* restore state we changed */ cso_restore_blend(ctx->cso); cso_restore_samplers(ctx->cso); - cso_restore_sampler_textures(ctx->cso); + cso_restore_fragment_sampler_views(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_vertex_shader(ctx->cso); cso_restore_fragment_shader(ctx->cso); @@ -406,6 +408,8 @@ void renderer_copy_surface(struct renderer *ctx, struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_buffer *buf; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; struct pipe_texture texTemp, *tex; struct pipe_surface *texSurf; struct pipe_framebuffer_state fb; @@ -457,6 +461,12 @@ void renderer_copy_surface(struct renderer *ctx, if (!tex) return; + u_sampler_view_default_template(&view_templ, tex, tex->format); + view = pipe->create_sampler_view(pipe, tex, &view_templ); + + if (!view) + return; + texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); @@ -479,7 +489,7 @@ void renderer_copy_surface(struct renderer *ctx, /* save state (restored below) */ cso_save_blend(ctx->cso); cso_save_samplers(ctx->cso); - cso_save_sampler_textures(ctx->cso); + cso_save_fragment_sampler_views(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); @@ -515,7 +525,7 @@ void renderer_copy_surface(struct renderer *ctx, } /* texture */ - cso_set_sampler_textures(ctx->cso, 1, &tex); + cso_set_fragment_sampler_views(ctx->cso, 1, &view); /* shaders */ cso_set_fragment_shader_handle(ctx->cso, ctx->fs); @@ -552,13 +562,14 @@ void renderer_copy_surface(struct renderer *ctx, /* restore state we changed */ cso_restore_blend(ctx->cso); cso_restore_samplers(ctx->cso); - cso_restore_sampler_textures(ctx->cso); + cso_restore_fragment_sampler_views(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); cso_restore_viewport(ctx->cso); pipe_texture_reference(&tex, NULL); + pipe_sampler_view_reference(&view, NULL); } void renderer_texture_quad(struct renderer *r, diff --git a/src/gallium/state_trackers/vega/renderer.h b/src/gallium/state_trackers/vega/renderer.h index 990cd32c313..03366f13614 100644 --- a/src/gallium/state_trackers/vega/renderer.h +++ b/src/gallium/state_trackers/vega/renderer.h @@ -33,6 +33,7 @@ struct renderer; struct vg_context; struct pipe_texture; +struct pipe_sampler_view; struct pipe_surface; struct renderer *renderer_create(struct vg_context *owner); @@ -57,7 +58,7 @@ void renderer_texture_quad(struct renderer *, VGfloat x3, VGfloat y3, VGfloat x4, VGfloat y4); void renderer_copy_texture(struct renderer *r, - struct pipe_texture *src, + struct pipe_sampler_view *src, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, struct pipe_texture *dst, diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c index 0e71a507bff..f2ec24c57ff 100644 --- a/src/gallium/state_trackers/vega/shader.c +++ b/src/gallium/state_trackers/vega/shader.c @@ -119,7 +119,7 @@ static void setup_constant_buffer(struct shader *shader) static VGint blend_bind_samplers(struct vg_context *ctx, struct pipe_sampler_state **samplers, - struct pipe_texture **textures) + struct pipe_sampler_view **sampler_views) { VGBlendMode bmode = ctx->state.vg.blend_mode; @@ -132,15 +132,15 @@ static VGint blend_bind_samplers(struct vg_context *ctx, vg_prepare_blend_surface(ctx); samplers[2] = &ctx->blend_sampler; - textures[2] = stfb->blend_texture; + sampler_views[2] = stfb->blend_texture_view; - if (!samplers[0] || !textures[0]) { + if (!samplers[0] || !sampler_views[0]) { samplers[0] = samplers[2]; - textures[0] = textures[2]; + sampler_views[0] = sampler_views[2]; } - if (!samplers[1] || !textures[1]) { + if (!samplers[1] || !sampler_views[1]) { samplers[1] = samplers[0]; - textures[1] = textures[0]; + sampler_views[1] = sampler_views[0]; } return 1; @@ -151,7 +151,7 @@ static VGint blend_bind_samplers(struct vg_context *ctx, static void setup_samplers(struct shader *shader) { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct vg_context *ctx = shader->context; /* a little wonky: we use the num as a boolean that just says * whether any sampler/textures have been set. the actual numbering @@ -167,20 +167,20 @@ static void setup_samplers(struct shader *shader) samplers[1] = NULL; samplers[2] = NULL; samplers[3] = NULL; - textures[0] = NULL; - textures[1] = NULL; - textures[2] = NULL; - textures[3] = NULL; + sampler_views[0] = NULL; + sampler_views[1] = NULL; + sampler_views[2] = NULL; + sampler_views[3] = NULL; - num += paint_bind_samplers(shader->paint, samplers, textures); - num += mask_bind_samplers(samplers, textures); - num += blend_bind_samplers(ctx, samplers, textures); + num += paint_bind_samplers(shader->paint, samplers, sampler_views); + num += mask_bind_samplers(samplers, sampler_views); + num += blend_bind_samplers(ctx, samplers, sampler_views); if (shader->drawing_image && shader->image) - num += image_bind_samplers(shader->image, samplers, textures); + num += image_bind_samplers(shader->image, samplers, sampler_views); if (num) { cso_set_samplers(ctx->cso_context, 4, (const struct pipe_sampler_state **)samplers); - cso_set_sampler_textures(ctx->cso_context, 4, textures); + cso_set_fragment_sampler_views(ctx->cso_context, 4, sampler_views); } } diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 7769112a31e..11ebbbe5444 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -43,6 +43,7 @@ #include "util/u_simple_shaders.h" #include "util/u_memory.h" #include "util/u_blit.h" +#include "util/u_sampler.h" struct vg_context *_vg_context = 0; @@ -436,19 +437,24 @@ void vg_prepare_blend_surface(struct vg_context *ctx) { struct pipe_surface *dest_surface = NULL; struct pipe_context *pipe = ctx->pipe; + struct pipe_sampler_view *view; + struct pipe_sampler_view view_templ; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; /* first finish all pending rendering */ vgFinish(); + u_sampler_view_default_template(&view_templ, strb->texture, strb->texture->format); + view = pipe->create_sampler_view(pipe, strb->texture, &view_templ); + dest_surface = pipe->screen->get_tex_surface(pipe->screen, - stfb->blend_texture, + stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, - strb->texture, + view, 0, strb->height, strb->width, 0, dest_surface, @@ -461,6 +467,8 @@ void vg_prepare_blend_surface(struct vg_context *ctx) /* make sure it's complete */ vgFinish(); + + pipe_sampler_view_reference(&view, NULL); } @@ -477,13 +485,13 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) vgFinish(); dest_surface = pipe->screen->get_tex_surface(pipe->screen, - stfb->blend_texture, + stfb->blend_texture_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, - stfb->alpha_mask, + stfb->alpha_mask_view, 0, strb->height, strb->width, 0, dest_surface, diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index 17c7d2ad1c5..c9e36d7d767 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -55,9 +55,10 @@ struct st_framebuffer { struct st_renderbuffer *strb; struct st_renderbuffer *dsrb; - struct pipe_texture *alpha_mask; + struct pipe_sampler_view *alpha_mask_view; + + struct pipe_sampler_view *blend_texture_view; - struct pipe_texture *blend_texture; struct st_framebuffer_iface *iface; enum st_attachment_type strb_att; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index ea5c2ce41f6..f438e34087e 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -32,6 +32,7 @@ #include "util/u_inlines.h" #include "pipe/p_screen.h" #include "util/u_format.h" +#include "util/u_sampler.h" #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_rect.h" @@ -41,7 +42,7 @@ PUBLIC const int st_api_OpenVG = 1; static struct pipe_texture * create_texture(struct pipe_context *pipe, enum pipe_format format, - VGint width, VGint height) + VGint width, VGint height) { struct pipe_texture templ; @@ -71,6 +72,27 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, return pipe->screen->texture_create(pipe->screen, &templ); } +static struct pipe_sampler_view * +create_tex_and_view(struct pipe_context *pipe, enum pipe_format format, + VGint width, VGint height) +{ + struct pipe_texture *texture; + struct pipe_sampler_view view_templ; + struct pipe_sampler_view *view; + + texture = create_texture(pipe, format, width, height); + + if (!texture) + return NULL; + + u_sampler_view_default_template(&view_templ, texture, texture->format); + view = pipe->create_sampler_view(pipe, texture, &view_templ); + /* want the texture to go away if the view is freed */ + pipe_texture_reference(&texture, NULL); + + return view; +} + /** * Allocate a renderbuffer for a an on-screen window (not a user-created * renderbuffer). The window system code determines the format. @@ -115,8 +137,8 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx, surface_usage = (PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); - strb->texture = create_texture(pipe, strb->format, - width, height); + strb->texture = create_texture(pipe, strb->format, width, height); + if (!strb->texture) return FALSE; @@ -191,7 +213,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual, /*### currently we always allocate it but it's possible it's not necessary if EGL_ALPHA_MASK_SIZE was 0 */ - stfb->alpha_mask = 0; + stfb->alpha_mask_view = NULL; stfb->width = width; stfb->height = height; @@ -206,19 +228,19 @@ static void setup_new_alpha_mask(struct vg_context *ctx, uint width, uint height) { struct pipe_context *pipe = ctx->pipe; - struct pipe_texture *old_texture = stfb->alpha_mask; + struct pipe_sampler_view *old_sampler_view = stfb->alpha_mask_view; /* we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to this texture and use it as a sampler, so while this wastes some space it makes both of those a lot simpler */ - stfb->alpha_mask = - create_texture(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); + stfb->alpha_mask_view = + create_tex_and_view(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); - if (!stfb->alpha_mask) { - if (old_texture) - pipe_texture_reference(&old_texture, NULL); + if (!stfb->alpha_mask_view) { + if (old_sampler_view) + pipe_sampler_view_reference(&old_sampler_view, NULL); return; } @@ -228,15 +250,15 @@ static void setup_new_alpha_mask(struct vg_context *ctx, mask_fill(0, 0, width, height, 1.f); /* if we had an old surface copy it over */ - if (old_texture) { + if (old_sampler_view) { struct pipe_surface *surface = pipe->screen->get_tex_surface( pipe->screen, - stfb->alpha_mask, + stfb->alpha_mask_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); struct pipe_surface *old_surface = pipe->screen->get_tex_surface( pipe->screen, - old_texture, + old_sampler_view->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); if (pipe->surface_copy) { @@ -264,8 +286,8 @@ static void setup_new_alpha_mask(struct vg_context *ctx, /* Free the old texture */ - if (old_texture) - pipe_texture_reference(&old_texture, NULL); + if (old_sampler_view) + pipe_sampler_view_reference(&old_sampler_view, NULL); } void st_resize_framebuffer(struct st_framebuffer *stfb, @@ -326,9 +348,9 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, setup_new_alpha_mask(ctx, stfb, width, height); - pipe_texture_reference( &stfb->blend_texture, NULL ); - stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, - width, height); + pipe_sampler_view_reference( &stfb->blend_texture_view, NULL ); + stfb->blend_texture_view = create_tex_and_view(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, + width, height); } void st_set_framebuffer_surface(struct st_framebuffer *stfb, From 3b9555094d128052bdaf9957fe9062b35f7f5392 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 19 Mar 2010 16:30:47 +0100 Subject: [PATCH 179/483] cso: remove cso_set/save/restore_sampler_textures no longer used after all statetrackers have been converted. --- src/gallium/auxiliary/cso_cache/cso_context.c | 68 ------------------- src/gallium/auxiliary/cso_cache/cso_context.h | 8 --- 2 files changed, 76 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 4ed9e09c529..d6f8dd34bfa 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -618,74 +618,6 @@ cso_restore_vertex_samplers(struct cso_context *ctx) } -enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, - uint count, - struct pipe_texture **textures ) -{ - uint i; - - ctx->nr_fragment_sampler_views = count; - - for (i = 0; i < count; i++) { - struct pipe_sampler_view templ, *view; - - u_sampler_view_default_template(&templ, - textures[i], - textures[i]->format); - - view = ctx->pipe->create_sampler_view(ctx->pipe, - textures[i], - &templ); - - pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], view); - } - for ( ; i < PIPE_MAX_SAMPLERS; i++) { - pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); - } - - ctx->pipe->set_fragment_sampler_views(ctx->pipe, - count, - ctx->fragment_sampler_views); - - return PIPE_OK; -} - -void cso_save_sampler_textures( struct cso_context *ctx ) -{ - uint i; - - ctx->nr_fragment_sampler_views_saved = ctx->nr_fragment_sampler_views; - for (i = 0; i < ctx->nr_fragment_sampler_views; i++) { - assert(!ctx->fragment_sampler_views_saved[i]); - - pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], - ctx->fragment_sampler_views[i]); - } -} - -void cso_restore_sampler_textures( struct cso_context *ctx ) -{ - uint i; - - ctx->nr_fragment_sampler_views = ctx->nr_fragment_sampler_views_saved; - - for (i = 0; i < ctx->nr_fragment_sampler_views; i++) { - pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); - ctx->fragment_sampler_views[i] = ctx->fragment_sampler_views_saved[i]; - ctx->fragment_sampler_views_saved[i] = NULL; - } - for ( ; i < PIPE_MAX_SAMPLERS; i++) { - pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); - } - - ctx->pipe->set_fragment_sampler_views(ctx->pipe, - ctx->nr_fragment_sampler_views, - ctx->fragment_sampler_views); - - ctx->nr_fragment_sampler_views_saved = 0; -} - - enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx, const struct pipe_depth_stencil_alpha_state *templ) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index a24077e009c..d6bcb1fe8f7 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -103,14 +103,6 @@ void cso_single_vertex_sampler_done(struct cso_context *cso); - -enum pipe_error cso_set_sampler_textures( struct cso_context *cso, - uint count, - struct pipe_texture **textures ); -void cso_save_sampler_textures( struct cso_context *cso ); -void cso_restore_sampler_textures( struct cso_context *cso ); - - enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, unsigned count, const struct pipe_vertex_element *states); From 05c03c6a1bcfb8ad77d3025f166f02ddaa741aa2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Mar 2010 10:02:16 -0600 Subject: [PATCH 180/483] gallivm: simplify and clean-up Z/stencil bit mask/shift code Refactor the code into two helper functions which compute the bit mask and shift terms for Z and stencil. Plus add a bunch of new comments to explain everything. --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 245 ++++++++++++------- 1 file changed, 159 insertions(+), 86 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 5b5ae7b5ea8..4ce1a27a061 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -368,6 +368,83 @@ lp_depth_type(const struct util_format_description *format_desc, } +/** + * Compute bitmask and bit shift to apply to the incoming fragment Z values + * and the Z buffer values needed before doing the Z comparison. + * + * Note that we leave the Z bits in the position that we find them + * in the Z buffer (typically 0xffffff00 or 0x00ffffff). That lets us + * get by with fewer bit twiddling steps. + */ +static boolean +get_z_shift_and_mask(const struct util_format_description *format_desc, + unsigned *shift, unsigned *mask) +{ + const unsigned total_bits = format_desc->block.bits; + unsigned z_swizzle; + int chan; + unsigned padding_left, padding_right; + + assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS); + assert(format_desc->block.width == 1); + assert(format_desc->block.height == 1); + + z_swizzle = format_desc->swizzle[0]; + + if (z_swizzle == UTIL_FORMAT_SWIZZLE_NONE) + return FALSE; + + padding_right = 0; + for (chan = 0; chan < z_swizzle; ++chan) + padding_right += format_desc->channel[chan].size; + + padding_left = + total_bits - (padding_right + format_desc->channel[z_swizzle].size); + + if (padding_left || padding_right) { + unsigned long long mask_left = (1ULL << (total_bits - padding_left)) - 1; + unsigned long long mask_right = (1ULL << (padding_right)) - 1; + *mask = mask_left ^ mask_right; + } + else { + *mask = 0xffffffff; + } + + *shift = padding_left; + + return TRUE; +} + + +/** + * Compute bitmask and bit shift to apply to the framebuffer pixel values + * to put the stencil bits in the least significant position. + * (i.e. 0x000000ff) + */ +static boolean +get_s_shift_and_mask(const struct util_format_description *format_desc, + unsigned *shift, unsigned *mask) +{ + unsigned s_swizzle; + int chan, sz; + + s_swizzle = format_desc->swizzle[1]; + + if (s_swizzle == UTIL_FORMAT_SWIZZLE_NONE) + return FALSE; + + *shift = 0; + for (chan = 0; chan < s_swizzle; chan++) + *shift += format_desc->channel[chan].size; + + sz = format_desc->channel[s_swizzle].size; + *mask = (1U << sz) - 1U; + + return TRUE; +} + + + /** * Generate code for performing depth and/or stencil tests. * We operate on a vector of values (typically a 2x2 quad). @@ -397,46 +474,51 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, struct lp_build_context bld; struct lp_build_context sbld; struct lp_type s_type; - unsigned z_swizzle, s_swizzle; LLVMValueRef zs_dst, z_dst = NULL; LLVMValueRef stencil_vals = NULL; - LLVMValueRef z_bitmask = NULL, s_bitmask = NULL, s_shift = NULL; + LLVMValueRef z_bitmask = NULL, stencil_shift = NULL; LLVMValueRef z_pass = NULL, s_pass_mask = NULL; LLVMValueRef orig_mask = mask->value; - assert(depth->enabled || stencil[0].enabled); - - assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS); - assert(format_desc->block.width == 1); - assert(format_desc->block.height == 1); - - z_swizzle = format_desc->swizzle[0]; - s_swizzle = format_desc->swizzle[1]; - - assert(z_swizzle != UTIL_FORMAT_SWIZZLE_NONE || - s_swizzle != UTIL_FORMAT_SWIZZLE_NONE); - - if (stencil[0].enabled) { - assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM || - format_desc->format == PIPE_FORMAT_S8Z24_UNORM); - } - /* Sanity checking */ - assert(z_swizzle < 4); - assert(format_desc->block.bits == type.width); - if(type.floating) { - assert(z_swizzle == 0); - assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_FLOAT); - assert(format_desc->channel[z_swizzle].size == format_desc->block.bits); - } - else { - assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED); - assert(format_desc->channel[z_swizzle].normalized); - assert(!type.fixed); - assert(!type.sign); - assert(type.norm); + { + const unsigned z_swizzle = format_desc->swizzle[0]; + const unsigned s_swizzle = format_desc->swizzle[1]; + + assert(z_swizzle != UTIL_FORMAT_SWIZZLE_NONE || + s_swizzle != UTIL_FORMAT_SWIZZLE_NONE); + + assert(depth->enabled || stencil[0].enabled); + + assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS); + assert(format_desc->block.width == 1); + assert(format_desc->block.height == 1); + + if (stencil[0].enabled) { + assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM || + format_desc->format == PIPE_FORMAT_S8Z24_UNORM); + } + + assert(z_swizzle < 4); + assert(format_desc->block.bits == type.width); + if (type.floating) { + assert(z_swizzle == 0); + assert(format_desc->channel[z_swizzle].type == + UTIL_FORMAT_TYPE_FLOAT); + assert(format_desc->channel[z_swizzle].size == + format_desc->block.bits); + } + else { + assert(format_desc->channel[z_swizzle].type == + UTIL_FORMAT_TYPE_UNSIGNED); + assert(format_desc->channel[z_swizzle].normalized); + assert(!type.fixed); + assert(!type.sign); + assert(type.norm); + } } + /* Setup build context for Z vals */ lp_build_context_init(&bld, builder, type); @@ -449,71 +531,57 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, lp_build_name(zs_dst, "zsbufval"); - /* Align the source depth bits with the destination's, and mask out any - * stencil or padding bits from both */ - if(format_desc->channel[z_swizzle].size == format_desc->block.bits) { - assert(z_swizzle == 0); - z_dst = zs_dst; - } - else { - /* shift/mask bits to right-justify the Z bits */ - unsigned padding_left; - unsigned padding_right; - unsigned chan; - assert(format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); - assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED); - assert(format_desc->channel[z_swizzle].size <= format_desc->block.bits); - assert(format_desc->channel[z_swizzle].normalized); + /* Compute and apply the Z/stencil bitmasks and shifts. + */ + { + unsigned z_shift, z_mask; + unsigned s_shift, s_mask; - padding_right = 0; - for(chan = 0; chan < z_swizzle; ++chan) - padding_right += format_desc->channel[chan].size; - padding_left = format_desc->block.bits - - (padding_right + format_desc->channel[z_swizzle].size); + if (get_z_shift_and_mask(format_desc, &z_shift, &z_mask)) { + if (z_shift) { + LLVMValueRef shift = lp_build_const_int_vec(type, z_shift); + z_src = LLVMBuildLShr(builder, z_src, shift, ""); + } - if(padding_left || padding_right) { - const unsigned long long mask_left = (1ULL << (format_desc->block.bits - padding_left)) - 1; - const unsigned long long mask_right = (1ULL << (padding_right)) - 1; - z_bitmask = lp_build_const_int_vec(type, mask_left ^ mask_right); + if (z_mask != 0xffffffff) { + LLVMValueRef mask = lp_build_const_int_vec(type, z_mask); + z_src = LLVMBuildAnd(builder, z_src, mask, ""); + z_dst = LLVMBuildAnd(builder, zs_dst, mask, ""); + z_bitmask = mask; /* used below */ + } + else { + z_dst = zs_dst; + } + + lp_build_name(z_dst, "zsbuf.z"); } - /* If PIPE_FORMAT_Z24S8, we'll shift zs >> 24 to position stencil_vals */ - if (format_desc->format == PIPE_FORMAT_Z24S8_UNORM) - s_shift = lp_build_const_int_vec(type, 24); - else - s_shift = lp_build_const_int_vec(type, 0); + if (get_s_shift_and_mask(format_desc, &s_shift, &s_mask)) { + if (s_shift) { + LLVMValueRef shift = lp_build_const_int_vec(type, s_shift); + stencil_vals = LLVMBuildLShr(builder, zs_dst, shift, ""); + stencil_shift = shift; /* used below */ + } + else { + stencil_vals = zs_dst; + } - s_bitmask = lp_build_const_int_vec(s_type, 0xff); + if (s_mask != 0xffffffff) { + LLVMValueRef mask = lp_build_const_int_vec(type, s_mask); + stencil_vals = LLVMBuildAnd(builder, stencil_vals, mask, ""); + } - stencil_vals = LLVMBuildLShr(builder, zs_dst, s_shift, ""); - stencil_vals = LLVMBuildAnd(builder, stencil_vals, s_bitmask, ""); - - if(padding_left) - z_src = LLVMBuildLShr(builder, z_src, - lp_build_const_int_vec(type, padding_left), ""); - if(padding_right) - z_src = LLVMBuildAnd(builder, z_src, z_bitmask, ""); - if(padding_left || padding_right) - z_dst = LLVMBuildAnd(builder, zs_dst, z_bitmask, ""); - else - z_dst = zs_dst; + lp_build_name(stencil_vals, "stencil"); + } } - lp_build_name(z_dst, "zsbuf.z"); - - /* - printf("build depth %d stencil %d\n", - depth->enabled, - stencil[0].enabled); - */ if (stencil[0].enabled) { /* convert scalar stencil refs into vectors */ stencil_refs[0] = lp_build_broadcast_scalar(&bld, stencil_refs[0]); stencil_refs[1] = lp_build_broadcast_scalar(&bld, stencil_refs[1]); - s_pass_mask = lp_build_stencil_test(&sbld, stencil, stencil_refs, stencil_vals, face); @@ -569,12 +637,17 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, * passed the stencil test. */ s_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, s_pass_mask, ""); - stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP, stencil_refs, - stencil_vals, s_pass_mask, face); + stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP, + stencil_refs, stencil_vals, + s_pass_mask, face); } - if (stencil_vals) - stencil_vals = LLVMBuildShl(bld.builder, stencil_vals, s_shift, ""); + /* The Z bits are already in the right place but we may need to shift the + * stencil bits before ORing Z with Stencil to make the final pixel value. + */ + if (stencil_vals && stencil_shift) + stencil_vals = LLVMBuildShl(bld.builder, stencil_vals, + stencil_shift, ""); /* Finally, merge/store the z/stencil values */ if ((depth->enabled && depth->writemask) || From 73060ec7ebaa6a304402caa60610f94dac2cf24b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Mar 2010 10:35:58 -0600 Subject: [PATCH 181/483] drivers/x11: add PUBLIC qualifier to more API functions Based on a patch from Tom Fogal. --- src/mesa/drivers/x11/glxapi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c index e11aff1a849..955eba4e944 100644 --- a/src/mesa/drivers/x11/glxapi.c +++ b/src/mesa/drivers/x11/glxapi.c @@ -1113,7 +1113,7 @@ glXGetAGPOffsetMESA( const GLvoid *pointer ) /*** GLX_MESA_allocate_memory */ -void * +void PUBLIC * glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority) { @@ -1121,14 +1121,14 @@ glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, return NULL; } -void +void PUBLIC glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer) { /* dummy */ } -GLuint +GLuint PUBLIC glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer) { /* dummy */ @@ -1138,7 +1138,7 @@ glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer) /*** GLX_EXT_texture_from_pixmap */ -void +void PUBLIC glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list) { @@ -1148,7 +1148,7 @@ glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, t->BindTexImageEXT(dpy, drawable, buffer, attrib_list); } -void +void PUBLIC glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) { struct _glxapi_table *t; @@ -1426,7 +1426,7 @@ _glxapi_get_proc_address(const char *funcName) * This function does not get dispatched through the dispatch table * since it's really a "meta" function. */ -__GLXextFuncPtr +__GLXextFuncPtr PUBLIC glXGetProcAddressARB(const GLubyte *procName) { __GLXextFuncPtr f; @@ -1442,7 +1442,8 @@ glXGetProcAddressARB(const GLubyte *procName) /* GLX 1.4 */ -void (*glXGetProcAddress(const GLubyte *procName))() +void PUBLIC +(*glXGetProcAddress(const GLubyte *procName))() { return glXGetProcAddressARB(procName); } From 7e6e049bb769012ef93d373d8a95a727120d2bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 9 Mar 2010 02:10:36 +0100 Subject: [PATCH 182/483] r300g: remove hacks from translate_vertex_data_swizzle Fixing RGBA 4ub vertex colors. --- src/gallium/drivers/r300/r300_state_inlines.h | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 2f3a56e1fbc..af7827820cc 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -453,7 +453,6 @@ r300_translate_vertex_data_type(enum pipe_format format) { static INLINE uint16_t r300_translate_vertex_data_swizzle(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - unsigned swizzle[4], i; assert(format); @@ -463,25 +462,10 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { return 0; } - /* Swizzles for 8bits formats are in the reversed order, not sure why. */ - if (desc->channel[0].size == 8) { - for (i = 0; i < 4; i++) { - if (desc->swizzle[i] <= 3) { - swizzle[i] = 3 - desc->swizzle[i]; - } else { - swizzle[i] = desc->swizzle[i]; - } - } - } else { - for (i = 0; i < 4; i++) { - swizzle[i] = desc->swizzle[i]; - } - } - - return ((swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | - (swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | - (swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | - (swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | + return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | + (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | + (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | + (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | (0xf << R300_WRITE_ENA_SHIFT)); } From 92827cd4511fabcaeb8abfdd11122e04502d5944 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:10 +0200 Subject: [PATCH 183/483] st/dri: fix bug in allocate_textures --- src/gallium/state_trackers/dri/dri1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 41dba82d528..240bc69efd5 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -451,7 +451,7 @@ dri1_allocate_textures(struct dri_drawable *drawable, break; } - if (templ.format != PIPE_FORMAT_NONE) { + if (format != PIPE_FORMAT_NONE) { templ.format = format; templ.tex_usage = tex_usage; From fe5f070ef94219f12196bff6cb3274756ea03660 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 19:16:21 +0000 Subject: [PATCH 184/483] st/dri: fix bug in make_current --- src/gallium/state_trackers/dri/dri_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index c1848b026cd..54568a8b220 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -149,7 +149,7 @@ dri_make_current(__DRIcontext * cPriv, } if (ctx->rPriv != driReadPriv) { ctx->rPriv = driReadPriv; - draw->texture_stamp = driReadPriv->lastStamp - 1; + read->texture_stamp = driReadPriv->lastStamp - 1; } stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb); From 41a87a43e11c664935349f938022d58d3e22da4e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 18 Mar 2010 11:36:57 +0800 Subject: [PATCH 185/483] glapi: Correctly generate static disatches for X86. The entry point names, instead of the function name, should be used to test if the entry point should be statically dispatched. --- src/mesa/glapi/gen/gl_x86_asm.py | 4 +- src/mesa/x86/glapi_x86.S | 66 ++------------------------------ 2 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/mesa/glapi/gen/gl_x86_asm.py b/src/mesa/glapi/gen/gl_x86_asm.py index a48724ee615..7fb7af50b53 100644 --- a/src/mesa/glapi/gen/gl_x86_asm.py +++ b/src/mesa/glapi/gen/gl_x86_asm.py @@ -226,8 +226,8 @@ class PrintGenericStubs(gl_XML.gl_print_base): stack = self.get_stack_size(f) alt = "%s@%u" % (name, stack) - if f.is_static_entry_point(f.name): - for n in f.entry_points: + for n in f.entry_points: + if f.is_static_entry_point(n): if n != f.name: alt2 = "%s@%u" % (n, stack) text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, f.name, alt) diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index a7dd8d72186..26c1ce4bc2a 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -1022,74 +1022,16 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(BlendColorEXT, _gloffset_BlendColor, BlendColorEXT@16, BlendColor, BlendColor@16) GL_STUB_ALIAS(BlendEquationEXT, _gloffset_BlendEquation, BlendEquationEXT@4, BlendEquation, BlendEquation@4) GL_STUB_ALIAS(DrawRangeElementsEXT, _gloffset_DrawRangeElements, DrawRangeElementsEXT@24, DrawRangeElements, DrawRangeElements@24) - GL_STUB_ALIAS(ColorTableSGI, _gloffset_ColorTable, ColorTableSGI@24, ColorTable, ColorTable@24) GL_STUB_ALIAS(ColorTableEXT, _gloffset_ColorTable, ColorTableEXT@24, ColorTable, ColorTable@24) - GL_STUB_ALIAS(ColorTableParameterfvSGI, _gloffset_ColorTableParameterfv, ColorTableParameterfvSGI@12, ColorTableParameterfv, ColorTableParameterfv@12) - GL_STUB_ALIAS(ColorTableParameterivSGI, _gloffset_ColorTableParameteriv, ColorTableParameterivSGI@12, ColorTableParameteriv, ColorTableParameteriv@12) - GL_STUB_ALIAS(CopyColorTableSGI, _gloffset_CopyColorTable, CopyColorTableSGI@20, CopyColorTable, CopyColorTable@20) -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetColorTableSGI, _gloffset_GetColorTable, GetColorTableSGI@16, GetColorTable, GetColorTable@16) -#endif #ifndef GLX_INDIRECT_RENDERING GL_STUB_ALIAS(GetColorTableEXT, _gloffset_GetColorTable, GetColorTableEXT@16, GetColorTable, GetColorTable@16) #endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetColorTableParameterfvSGI, _gloffset_GetColorTableParameterfv, GetColorTableParameterfvSGI@12, GetColorTableParameterfv, GetColorTableParameterfv@12) -#endif #ifndef GLX_INDIRECT_RENDERING GL_STUB_ALIAS(GetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv, GetColorTableParameterfvEXT@12, GetColorTableParameterfv, GetColorTableParameterfv@12) #endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetColorTableParameterivSGI, _gloffset_GetColorTableParameteriv, GetColorTableParameterivSGI@12, GetColorTableParameteriv, GetColorTableParameteriv@12) -#endif #ifndef GLX_INDIRECT_RENDERING GL_STUB_ALIAS(GetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv, GetColorTableParameterivEXT@12, GetColorTableParameteriv, GetColorTableParameteriv@12) #endif - GL_STUB_ALIAS(ColorSubTableEXT, _gloffset_ColorSubTable, ColorSubTableEXT@24, ColorSubTable, ColorSubTable@24) - GL_STUB_ALIAS(CopyColorSubTableEXT, _gloffset_CopyColorSubTable, CopyColorSubTableEXT@20, CopyColorSubTable, CopyColorSubTable@20) - GL_STUB_ALIAS(ConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D, ConvolutionFilter1DEXT@24, ConvolutionFilter1D, ConvolutionFilter1D@24) - GL_STUB_ALIAS(ConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D, ConvolutionFilter2DEXT@28, ConvolutionFilter2D, ConvolutionFilter2D@28) - GL_STUB_ALIAS(ConvolutionParameterfEXT, _gloffset_ConvolutionParameterf, ConvolutionParameterfEXT@12, ConvolutionParameterf, ConvolutionParameterf@12) - GL_STUB_ALIAS(ConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv, ConvolutionParameterfvEXT@12, ConvolutionParameterfv, ConvolutionParameterfv@12) - GL_STUB_ALIAS(ConvolutionParameteriEXT, _gloffset_ConvolutionParameteri, ConvolutionParameteriEXT@12, ConvolutionParameteri, ConvolutionParameteri@12) - GL_STUB_ALIAS(ConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv, ConvolutionParameterivEXT@12, ConvolutionParameteriv, ConvolutionParameteriv@12) - GL_STUB_ALIAS(CopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D, CopyConvolutionFilter1DEXT@20, CopyConvolutionFilter1D, CopyConvolutionFilter1D@20) - GL_STUB_ALIAS(CopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D, CopyConvolutionFilter2DEXT@24, CopyConvolutionFilter2D, CopyConvolutionFilter2D@24) -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetConvolutionFilterEXT, _gloffset_GetConvolutionFilter, GetConvolutionFilterEXT@16, GetConvolutionFilter, GetConvolutionFilter@16) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetConvolutionParameterfvEXT, _gloffset_GetConvolutionParameterfv, GetConvolutionParameterfvEXT@12, GetConvolutionParameterfv, GetConvolutionParameterfv@12) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetConvolutionParameterivEXT, _gloffset_GetConvolutionParameteriv, GetConvolutionParameterivEXT@12, GetConvolutionParameteriv, GetConvolutionParameteriv@12) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetSeparableFilterEXT, _gloffset_GetSeparableFilter, GetSeparableFilterEXT@24, GetSeparableFilter, GetSeparableFilter@24) -#endif - GL_STUB_ALIAS(SeparableFilter2DEXT, _gloffset_SeparableFilter2D, SeparableFilter2DEXT@32, SeparableFilter2D, SeparableFilter2D@32) -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetHistogramEXT, _gloffset_GetHistogram, GetHistogramEXT@20, GetHistogram, GetHistogram@20) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetHistogramParameterfvEXT, _gloffset_GetHistogramParameterfv, GetHistogramParameterfvEXT@12, GetHistogramParameterfv, GetHistogramParameterfv@12) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetHistogramParameterivEXT, _gloffset_GetHistogramParameteriv, GetHistogramParameterivEXT@12, GetHistogramParameteriv, GetHistogramParameteriv@12) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetMinmaxEXT, _gloffset_GetMinmax, GetMinmaxEXT@20, GetMinmax, GetMinmax@20) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetMinmaxParameterfvEXT, _gloffset_GetMinmaxParameterfv, GetMinmaxParameterfvEXT@12, GetMinmaxParameterfv, GetMinmaxParameterfv@12) -#endif -#ifndef GLX_INDIRECT_RENDERING - GL_STUB_ALIAS(GetMinmaxParameterivEXT, _gloffset_GetMinmaxParameteriv, GetMinmaxParameterivEXT@12, GetMinmaxParameteriv, GetMinmaxParameteriv@12) -#endif - GL_STUB_ALIAS(HistogramEXT, _gloffset_Histogram, HistogramEXT@16, Histogram, Histogram@16) - GL_STUB_ALIAS(MinmaxEXT, _gloffset_Minmax, MinmaxEXT@12, Minmax, Minmax@12) - GL_STUB_ALIAS(ResetHistogramEXT, _gloffset_ResetHistogram, ResetHistogramEXT@4, ResetHistogram, ResetHistogram@4) - GL_STUB_ALIAS(ResetMinmaxEXT, _gloffset_ResetMinmax, ResetMinmaxEXT@4, ResetMinmax, ResetMinmax@4) GL_STUB_ALIAS(TexImage3DEXT, _gloffset_TexImage3D, TexImage3DEXT@40, TexImage3D, TexImage3D@40) GL_STUB_ALIAS(TexSubImage3DEXT, _gloffset_TexSubImage3D, TexSubImage3DEXT@44, TexSubImage3D, TexSubImage3D@44) GL_STUB_ALIAS(CopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D, CopyTexSubImage3DEXT@36, CopyTexSubImage3D, CopyTexSubImage3D@36) @@ -1127,7 +1069,6 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(MultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB, MultiTexCoord4iv@8, MultiTexCoord4ivARB, MultiTexCoord4ivARB@8) GL_STUB_ALIAS(MultiTexCoord4s, _gloffset_MultiTexCoord4sARB, MultiTexCoord4s@20, MultiTexCoord4sARB, MultiTexCoord4sARB@20) GL_STUB_ALIAS(MultiTexCoord4sv, _gloffset_MultiTexCoord4svARB, MultiTexCoord4sv@8, MultiTexCoord4svARB, MultiTexCoord4svARB@8) - GL_STUB_ALIAS(StencilOpSeparateATI, _gloffset_StencilOpSeparate, StencilOpSeparateATI@16, StencilOpSeparate, StencilOpSeparate@16) GL_STUB_ALIAS(LoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB, LoadTransposeMatrixd@4, LoadTransposeMatrixdARB, LoadTransposeMatrixdARB@4) GL_STUB_ALIAS(LoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB, LoadTransposeMatrixf@4, LoadTransposeMatrixfARB, LoadTransposeMatrixfARB@4) GL_STUB_ALIAS(MultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB, MultTransposeMatrixd@4, MultTransposeMatrixdARB, MultTransposeMatrixdARB@4) @@ -1242,10 +1183,8 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(RenderbufferStorageMultisampleEXT, _gloffset_RenderbufferStorageMultisample, RenderbufferStorageMultisampleEXT@20, RenderbufferStorageMultisample, RenderbufferStorageMultisample@20) GL_STUB_ALIAS(PointParameterf, _gloffset_PointParameterfEXT, PointParameterf@8, PointParameterfEXT, PointParameterfEXT@8) GL_STUB_ALIAS(PointParameterfARB, _gloffset_PointParameterfEXT, PointParameterfARB@8, PointParameterfEXT, PointParameterfEXT@8) - GL_STUB_ALIAS(PointParameterfSGIS, _gloffset_PointParameterfEXT, PointParameterfSGIS@8, PointParameterfEXT, PointParameterfEXT@8) GL_STUB_ALIAS(PointParameterfv, _gloffset_PointParameterfvEXT, PointParameterfv@8, PointParameterfvEXT, PointParameterfvEXT@8) GL_STUB_ALIAS(PointParameterfvARB, _gloffset_PointParameterfvEXT, PointParameterfvARB@8, PointParameterfvEXT, PointParameterfvEXT@8) - GL_STUB_ALIAS(PointParameterfvSGIS, _gloffset_PointParameterfvEXT, PointParameterfvSGIS@8, PointParameterfvEXT, PointParameterfvEXT@8) GL_STUB_ALIAS(SecondaryColor3b, _gloffset_SecondaryColor3bEXT, SecondaryColor3b@12, SecondaryColor3bEXT, SecondaryColor3bEXT@12) GL_STUB_ALIAS(SecondaryColor3bv, _gloffset_SecondaryColor3bvEXT, SecondaryColor3bv@4, SecondaryColor3bvEXT, SecondaryColor3bvEXT@4) GL_STUB_ALIAS(SecondaryColor3d, _gloffset_SecondaryColor3dEXT, SecondaryColor3d@24, SecondaryColor3dEXT, SecondaryColor3dEXT@24) @@ -1271,7 +1210,6 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(FogCoordf, _gloffset_FogCoordfEXT, FogCoordf@4, FogCoordfEXT, FogCoordfEXT@4) GL_STUB_ALIAS(FogCoordfv, _gloffset_FogCoordfvEXT, FogCoordfv@4, FogCoordfvEXT, FogCoordfvEXT@4) GL_STUB_ALIAS(BlendFuncSeparate, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparate@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16) - GL_STUB_ALIAS(BlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparateINGR@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16) GL_STUB_ALIAS(WindowPos2d, _gloffset_WindowPos2dMESA, WindowPos2d@16, WindowPos2dMESA, WindowPos2dMESA@16) GL_STUB_ALIAS(WindowPos2dARB, _gloffset_WindowPos2dMESA, WindowPos2dARB@16, WindowPos2dMESA, WindowPos2dMESA@16) GL_STUB_ALIAS(WindowPos2dv, _gloffset_WindowPos2dvMESA, WindowPos2dv@4, WindowPos2dvMESA, WindowPos2dvMESA@4) @@ -1312,6 +1250,9 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(IsProgramARB, _gloffset_IsProgramNV, IsProgramARB@4, IsProgramNV, IsProgramNV@4) GL_STUB_ALIAS(PointParameteri, _gloffset_PointParameteriNV, PointParameteri@8, PointParameteriNV, PointParameteriNV@8) GL_STUB_ALIAS(PointParameteriv, _gloffset_PointParameterivNV, PointParameteriv@8, PointParameterivNV, PointParameterivNV@8) + GL_STUB_ALIAS(DeleteVertexArrays, _gloffset_DeleteVertexArraysAPPLE, DeleteVertexArrays@8, DeleteVertexArraysAPPLE, _dispatch_stub_755@8) + GL_STUB_ALIAS(IsVertexArray, _gloffset_IsVertexArrayAPPLE, IsVertexArray@4, IsVertexArrayAPPLE, _dispatch_stub_757@4) + GL_STUB_ALIAS(BlendEquationSeparate, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparate@8, BlendEquationSeparateEXT, _dispatch_stub_765@8) GL_STUB_ALIAS(BindFramebuffer, _gloffset_BindFramebufferEXT, BindFramebuffer@8, BindFramebufferEXT, BindFramebufferEXT@8) GL_STUB_ALIAS(BindRenderbuffer, _gloffset_BindRenderbufferEXT, BindRenderbuffer@8, BindRenderbufferEXT, BindRenderbufferEXT@8) GL_STUB_ALIAS(CheckFramebufferStatus, _gloffset_CheckFramebufferStatusEXT, CheckFramebufferStatus@4, CheckFramebufferStatusEXT, CheckFramebufferStatusEXT@4) @@ -1329,6 +1270,7 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(IsFramebuffer, _gloffset_IsFramebufferEXT, IsFramebuffer@4, IsFramebufferEXT, IsFramebufferEXT@4) GL_STUB_ALIAS(IsRenderbuffer, _gloffset_IsRenderbufferEXT, IsRenderbuffer@4, IsRenderbufferEXT, IsRenderbufferEXT@4) GL_STUB_ALIAS(RenderbufferStorage, _gloffset_RenderbufferStorageEXT, RenderbufferStorage@16, RenderbufferStorageEXT, RenderbufferStorageEXT@16) + GL_STUB_ALIAS(BlitFramebuffer, _gloffset_BlitFramebufferEXT, BlitFramebuffer@40, BlitFramebufferEXT, _dispatch_stub_783@40) GL_STUB_ALIAS(FramebufferTextureLayer, _gloffset_FramebufferTextureLayerEXT, FramebufferTextureLayer@20, FramebufferTextureLayerEXT, FramebufferTextureLayerEXT@20) GL_STUB_ALIAS(ProvokingVertex, _gloffset_ProvokingVertexEXT, ProvokingVertex@4, ProvokingVertexEXT, ProvokingVertexEXT@4) From 6fed3a9fa0a87ae797f995de5b51eb9be3493fe0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 20 Mar 2010 23:58:15 +0800 Subject: [PATCH 186/483] glapi: Fix aliases to non-static functions. The bug is triggered by 41a87a43e11c664935349f938022d58d3e22da4e. glBlitFramebuffer, for example, is an alias to the non-static glBlitFramebufferEXT. We should define glBlitFramebuffer as an alias to _dispatch_stub_NNN. --- src/mesa/glapi/gen/gl_x86_asm.py | 2 +- src/mesa/x86/glapi_x86.S | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/glapi/gen/gl_x86_asm.py b/src/mesa/glapi/gen/gl_x86_asm.py index 7fb7af50b53..10dfa1ddb34 100644 --- a/src/mesa/glapi/gen/gl_x86_asm.py +++ b/src/mesa/glapi/gen/gl_x86_asm.py @@ -230,7 +230,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): if f.is_static_entry_point(n): if n != f.name: alt2 = "%s@%u" % (n, stack) - text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, f.name, alt) + text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, name, alt) if f.has_different_protocol(n): print '#ifndef GLX_INDIRECT_RENDERING' diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index 26c1ce4bc2a..b1730d25a0d 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -1250,9 +1250,9 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(IsProgramARB, _gloffset_IsProgramNV, IsProgramARB@4, IsProgramNV, IsProgramNV@4) GL_STUB_ALIAS(PointParameteri, _gloffset_PointParameteriNV, PointParameteri@8, PointParameteriNV, PointParameteriNV@8) GL_STUB_ALIAS(PointParameteriv, _gloffset_PointParameterivNV, PointParameteriv@8, PointParameterivNV, PointParameterivNV@8) - GL_STUB_ALIAS(DeleteVertexArrays, _gloffset_DeleteVertexArraysAPPLE, DeleteVertexArrays@8, DeleteVertexArraysAPPLE, _dispatch_stub_755@8) - GL_STUB_ALIAS(IsVertexArray, _gloffset_IsVertexArrayAPPLE, IsVertexArray@4, IsVertexArrayAPPLE, _dispatch_stub_757@4) - GL_STUB_ALIAS(BlendEquationSeparate, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparate@8, BlendEquationSeparateEXT, _dispatch_stub_765@8) + GL_STUB_ALIAS(DeleteVertexArrays, _gloffset_DeleteVertexArraysAPPLE, DeleteVertexArrays@8, _dispatch_stub_755, _dispatch_stub_755@8) + GL_STUB_ALIAS(IsVertexArray, _gloffset_IsVertexArrayAPPLE, IsVertexArray@4, _dispatch_stub_757, _dispatch_stub_757@4) + GL_STUB_ALIAS(BlendEquationSeparate, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparate@8, _dispatch_stub_765, _dispatch_stub_765@8) GL_STUB_ALIAS(BindFramebuffer, _gloffset_BindFramebufferEXT, BindFramebuffer@8, BindFramebufferEXT, BindFramebufferEXT@8) GL_STUB_ALIAS(BindRenderbuffer, _gloffset_BindRenderbufferEXT, BindRenderbuffer@8, BindRenderbufferEXT, BindRenderbufferEXT@8) GL_STUB_ALIAS(CheckFramebufferStatus, _gloffset_CheckFramebufferStatusEXT, CheckFramebufferStatus@4, CheckFramebufferStatusEXT, CheckFramebufferStatusEXT@4) @@ -1270,7 +1270,7 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(IsFramebuffer, _gloffset_IsFramebufferEXT, IsFramebuffer@4, IsFramebufferEXT, IsFramebufferEXT@4) GL_STUB_ALIAS(IsRenderbuffer, _gloffset_IsRenderbufferEXT, IsRenderbuffer@4, IsRenderbufferEXT, IsRenderbufferEXT@4) GL_STUB_ALIAS(RenderbufferStorage, _gloffset_RenderbufferStorageEXT, RenderbufferStorage@16, RenderbufferStorageEXT, RenderbufferStorageEXT@16) - GL_STUB_ALIAS(BlitFramebuffer, _gloffset_BlitFramebufferEXT, BlitFramebuffer@40, BlitFramebufferEXT, _dispatch_stub_783@40) + GL_STUB_ALIAS(BlitFramebuffer, _gloffset_BlitFramebufferEXT, BlitFramebuffer@40, _dispatch_stub_783, _dispatch_stub_783@40) GL_STUB_ALIAS(FramebufferTextureLayer, _gloffset_FramebufferTextureLayerEXT, FramebufferTextureLayer@20, FramebufferTextureLayerEXT, FramebufferTextureLayerEXT@20) GL_STUB_ALIAS(ProvokingVertex, _gloffset_ProvokingVertexEXT, ProvokingVertex@4, ProvokingVertexEXT, ProvokingVertexEXT@4) From f0491c945cb5d10ef1c45f4e28e874dffba8be4b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 10:33:10 -0600 Subject: [PATCH 187/483] docs: remove the 'Last updated date' --- docs/shading.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/shading.html b/docs/shading.html index bd02335a803..750884cf36c 100644 --- a/docs/shading.html +++ b/docs/shading.html @@ -14,10 +14,6 @@ This page describes the features and status of Mesa's support for the OpenGL Shading Language.

-

-Last updated on 15 December 2008. -

-

Contents

From 3d72c4ae78cfdad7d160b0960adb792cbbbb863b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 20 Mar 2010 18:31:11 +0100 Subject: [PATCH 188/483] r300/compiler: fix assertion failure in the r500-fragprog emission path --- src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c index 710cae727a1..4e84eefd658 100644 --- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c +++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c @@ -469,9 +469,8 @@ void r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compi if (compiler->Base.Error) return; - assert(code->inst_end >= 0); - - if ((code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) { + if (code->inst_end == -1 || + (code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) { /* This may happen when dead-code elimination is disabled or * when most of the fragment program logic is leading to a KIL */ if (code->inst_end >= 511) { From 00225af999acabcd5eced0b075b0a56018fd5eb8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 11:50:29 -0600 Subject: [PATCH 189/483] mesa: added GL3 ContextFlags field and query code --- src/mesa/main/get.c | 12 ++++++++++++ src/mesa/main/get_gen.py | 3 ++- src/mesa/main/mtypes.h | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index edc44009120..b91f8db584f 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1932,6 +1932,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_MINOR_VERSION: params[0] = INT_TO_BOOLEAN(ctx->VersionMinor); break; + case GL_CONTEXT_FLAGS: + params[0] = INT_TO_BOOLEAN(ctx->Const.ContextFlags); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -3801,6 +3804,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_MINOR_VERSION: params[0] = (GLfloat)(ctx->VersionMinor); break; + case GL_CONTEXT_FLAGS: + params[0] = (GLfloat)(ctx->Const.ContextFlags); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname); } @@ -5670,6 +5676,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_MINOR_VERSION: params[0] = ctx->VersionMinor; break; + case GL_CONTEXT_FLAGS: + params[0] = ctx->Const.ContextFlags; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } @@ -7540,6 +7549,9 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) case GL_MINOR_VERSION: params[0] = (GLint64)(ctx->VersionMinor); break; + case GL_CONTEXT_FLAGS: + params[0] = (GLint64)(ctx->Const.ContextFlags); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 9d5a51d58c5..3b0a5130f98 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1062,7 +1062,8 @@ StateVars = [ # GL3 ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ), ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ), - ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None ) + ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None ), + ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", None ) ] diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9d9b475dd17..82e004f3486 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2385,6 +2385,9 @@ struct gl_constants /**< GL_EXT_provoking_vertex */ GLboolean QuadsFollowProvokingVertexConvention; + + /**< OpenGL version 3.x */ + GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ }; From 8829e063aa87ade63c49d3df27a7edd0c63cf160 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 11:50:55 -0600 Subject: [PATCH 190/483] mesa: added GL3 buffer attachment aliases --- src/mesa/main/fbobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 7c442e390c2..07827348694 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -180,8 +180,12 @@ _mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, return &fb->Attachment[BUFFER_COLOR0 + i]; case GL_DEPTH_STENCIL_ATTACHMENT: /* fall-through */ + case GL_DEPTH_BUFFER: + /* fall-through / new in GL 3.0 */ case GL_DEPTH_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_DEPTH]; + case GL_STENCIL_BUFFER: + /* fall-through / new in GL 3.0 */ case GL_STENCIL_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_STENCIL]; default: From d6a9f5b3da7ce43a7b4ee068902dfd0d35c7bfa8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 11:52:12 -0600 Subject: [PATCH 191/483] mesa: added new GL3 buffer object queries And clean up the error checking code. --- src/mesa/main/bufferobj.c | 68 ++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 71d1514fe49..dbaba2975e3 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -32,6 +32,7 @@ #include "glheader.h" +#include "enums.h" #include "hash.h" #include "imports.h" #include "image.h" @@ -1376,31 +1377,49 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) bufObj = get_buffer(ctx, target); if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "GetBufferParameterivARB(target)" ); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)" ); return; } if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameterivARB" ); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameterivARB" ); return; } switch (pname) { case GL_BUFFER_SIZE_ARB: *params = (GLint) bufObj->Size; - break; + return; case GL_BUFFER_USAGE_ARB: *params = bufObj->Usage; - break; + return; case GL_BUFFER_ACCESS_ARB: *params = simplified_access_mode(bufObj->AccessFlags); - break; + return; case GL_BUFFER_MAPPED_ARB: *params = _mesa_bufferobj_mapped(bufObj); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname)"); return; + case GL_BUFFER_ACCESS_FLAGS: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->AccessFlags; + return; + case GL_BUFFER_MAP_OFFSET: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = (GLint) bufObj->Offset; + return; + case GL_BUFFER_MAP_LENGTH: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = (GLint) bufObj->Length; + return; + default: + ; /* fall-through */ } + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); } @@ -1418,31 +1437,50 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) bufObj = get_buffer(ctx, target); if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "GetBufferParameteri64v(target)" ); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(target)" ); return; } if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameteri64v" ); + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameteri64v" ); return; } switch (pname) { case GL_BUFFER_SIZE_ARB: *params = bufObj->Size; - break; + return; case GL_BUFFER_USAGE_ARB: *params = bufObj->Usage; - break; + return; case GL_BUFFER_ACCESS_ARB: *params = simplified_access_mode(bufObj->AccessFlags); - break; + return; + case GL_BUFFER_ACCESS_FLAGS: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->AccessFlags; + return; case GL_BUFFER_MAPPED_ARB: *params = _mesa_bufferobj_mapped(bufObj); - break; + return; + case GL_BUFFER_MAP_OFFSET: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->Offset; + return; + case GL_BUFFER_MAP_LENGTH: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->Length; + return; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname)"); + ; /* fall-through */ return; } + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); } From 9fca5d2e39a530c633fbd374d3b1f1ec935601d1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 11:55:24 -0600 Subject: [PATCH 192/483] mesa: added missing glGet query for GL_MAX_ARRAY_TEXTURE_LAYERS_EXT --- src/mesa/main/get.c | 16 ++++++++++++++++ src/mesa/main/get_gen.py | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index b91f8db584f..523dc2e4f7e 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -917,6 +917,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) CHECK_EXT1(MESA_texture_array, "GetBooleanv"); params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); break; + case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: + CHECK_EXT1(MESA_texture_array, "GetBooleanv"); + params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayTextureLayers); + break; case GL_TEXTURE_GEN_S: params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0); break; @@ -2789,6 +2793,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) CHECK_EXT1(MESA_texture_array, "GetFloatv"); params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); break; + case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: + CHECK_EXT1(MESA_texture_array, "GetFloatv"); + params[0] = (GLfloat)(ctx->Const.MaxArrayTextureLayers); + break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; @@ -4661,6 +4669,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) CHECK_EXT1(MESA_texture_array, "GetIntegerv"); params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name; break; + case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: + CHECK_EXT1(MESA_texture_array, "GetIntegerv"); + params[0] = ctx->Const.MaxArrayTextureLayers; + break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; @@ -6534,6 +6546,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) CHECK_EXT1(MESA_texture_array, "GetInteger64v"); params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); break; + case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: + CHECK_EXT1(MESA_texture_array, "GetInteger64v"); + params[0] = (GLint64)(ctx->Const.MaxArrayTextureLayers); + break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 3b0a5130f98..0ef9d8fe94e 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -457,6 +457,8 @@ StateVars = [ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ), ( "GL_TEXTURE_BINDING_2D_ARRAY_EXT", GLint, ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ), + ( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT", GLint, + ["ctx->Const.MaxArrayTextureLayers"], "", ["MESA_texture_array"] ), ( "GL_TEXTURE_GEN_S", GLboolean, ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None ), ( "GL_TEXTURE_GEN_T", GLboolean, From 61753c4bf7f6948aad208eddc7a2bae24763e028 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 12:04:52 -0600 Subject: [PATCH 193/483] mesa: added GL3 query for GL_TEXTURE_SHARED_SIZE --- src/mesa/main/texparam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 0fde89b5079..714c4cfd523 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -940,6 +940,18 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, "glGetTexLevelParameter[if]v(pname)"); } break; + case GL_TEXTURE_SHARED_SIZE: + if (ctx->VersionMajor >= 3) { + /* XXX return number of exponent bits for shared exponent texture + * formats, like GL_RGB9_E5. + */ + *params = 0; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: From 449721a3d0082879c504b7a3b25cdf38c2293a85 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 20 Mar 2010 12:05:25 -0600 Subject: [PATCH 194/483] docs: note GL_EXT_packed_float, GL_EXT_shared_exponent extensions --- docs/GL3.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/GL3.txt b/docs/GL3.txt index 889edefbce1..a485878af2d 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -16,6 +16,7 @@ GLSL changes (GL_EXT_gpu_shader4, etc) not started Conditional rendering (GL_NV_conditional_render) DONE (swrast & softpipe) Map buffer subranges (GL_APPLE_flush_buffer_range) not started Float textures, renderbuffers some infrastructure done + (incl. GL_EXT_packed_float, GL_EXT_shared_exponent) Framebuffer objects (GL_EXT_framebuffer_object) DONE Half-float some infrastructure done Multisample blit DONE From 03f1896304da481bd054779a025a4509f7ea59af Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Mar 2010 06:32:48 +1000 Subject: [PATCH 195/483] r300g: add buffer/texture referenced checks. I've no idea about the comments that were in there, just pass this down to the winsys. Signed-off-by: Dave Airlie --- src/gallium/drivers/r300/r300_context.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 210e31e69c7..a55d2db039f 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -72,29 +72,23 @@ static void r300_destroy_context(struct pipe_context* context) } static unsigned int -r300_is_texture_referenced(struct pipe_context *pipe, +r300_is_texture_referenced(struct pipe_context *context, struct pipe_texture *texture, unsigned face, unsigned level) { - return 0; + struct r300_context* r300 = r300_context(context); + struct r300_texture* tex = (struct r300_texture*)texture; + + return r300->rws->is_buffer_referenced(r300->rws, tex->buffer); } static unsigned int -r300_is_buffer_referenced(struct pipe_context *pipe, +r300_is_buffer_referenced(struct pipe_context *context, struct pipe_buffer *buf) { - /* This only checks to see whether actual hardware buffers are - * referenced. Since we use managed BOs and transfers, it's actually not - * possible for pipe_buffers to ever reference the actual hardware, so - * buffers are never referenced. - */ + struct r300_context* r300 = r300_context(context); - /* XXX: that doesn't make sense given that - * r300_is_texture_referenced is implemented on top of this - * function and hardware can certainly refer to textures - * directly... - */ - return 0; + return r300_buffer_is_referenced(r300, buf); } static void r300_flush_cb(void *data) From c2d17dce27d412012a3a45bbde954fb9374d5db9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Mar 2010 06:34:11 +1000 Subject: [PATCH 196/483] r300g: winsys fix tiling change flushes. If we change the tiling on a buffer we need to flush it, the old radeon_buffer.c code had this but it crossed streams when I ported to radeon_drm_buffer.c and I missed it. Should fix some piglit regressions. Signed-off-by: Dave Airlie --- .../winsys/drm/radeon/core/radeon_drm_buffer.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index cc56a2bb8fd..73472aabc5e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -306,13 +306,21 @@ boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch) { struct radeon_drm_buffer *buf = get_drm_buffer(_buf); - uint32_t flags = 0; - + uint32_t flags = 0, old_flags, old_pitch; if (microtiled) flags |= RADEON_BO_FLAGS_MICRO_TILE; if (macrotiled) flags |= RADEON_BO_FLAGS_MACRO_TILE; + radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch); + + if (flags != old_flags || pitch != old_pitch) { + /* Tiling determines how DRM treats the buffer data. + * We must flush CS when changing it if the buffer is referenced. */ + if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) { + buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data); + } + } radeon_bo_set_tiling(buf->bo, flags, pitch); } From 20dedcca3ca5bfeaaa275bec8a14ca8c69615f6a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 20 Mar 2010 16:14:20 -0700 Subject: [PATCH 197/483] radeong: Test the BO ptr for NULL instead of using a bool. Slight memory savings, but more importantly also avoids a potential NULL dereference. --- .../winsys/drm/radeon/core/radeon_drm_buffer.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 73472aabc5e..2f7456e12dd 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -23,7 +23,6 @@ struct radeon_drm_buffer { boolean flinked; uint32_t flink; - boolean mapped; struct radeon_drm_buffer *next, *prev; }; @@ -56,10 +55,10 @@ radeon_drm_buffer_destroy(struct pb_buffer *_buf) { struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); - if (buf->mapped) { + if (buf->bo->ptr != NULL) { remove_from_list(buf); radeon_bo_unmap(buf->bo); - buf->mapped = false; + buf->bo->ptr = NULL; } radeon_bo_unref(buf->bo); @@ -73,7 +72,7 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); int write; - if (buf->mapped) + if (buf->bo->ptr != NULL) return buf->bo->ptr; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { @@ -95,7 +94,6 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, if (radeon_bo_map(buf->bo, write)) { return NULL; } - buf->mapped = true; insert_at_tail(&buf->mgr->buffer_map_list, buf); return buf->bo->ptr; } @@ -365,12 +363,10 @@ void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr) struct radeon_drm_buffer *rpb, *t_rpb; foreach_s(rpb, t_rpb, &mgr->buffer_map_list) { - rpb->mapped = 0; radeon_bo_unmap(rpb->bo); + rpb->bo->ptr = NULL; remove_from_list(rpb); } make_empty_list(&mgr->buffer_map_list); - - } From 7c8221b46008cd4f217d3ddab59dcc4c488a54b3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 20 Mar 2010 16:15:36 -0700 Subject: [PATCH 198/483] radeong: Use TRUE and FALSE. --- src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 2f7456e12dd..2472b6bf952 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -287,7 +287,7 @@ boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); if (retval) { - return false; + return FALSE; } buf->flinked = TRUE; @@ -329,7 +329,7 @@ boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf, struct radeon_drm_buffer *buf = get_drm_buffer(_buf); radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo, rd, wd); - return true; + return TRUE; } void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf, From 4711aa089ec7af70bb9118ad8d7830e475805297 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 20 Mar 2010 17:16:46 -0700 Subject: [PATCH 199/483] r300g: Correctly hax max_index on pipe_vertex_buffers. Still not happy with this, but at least things seem to work. --- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state.c | 42 ++++++++++++++++++-------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 47100c83b0b..40c1a420428 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -307,7 +307,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, assert((start * indexSize) % 4 == 0); assert(count < (1 << 24)); - maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, count - minIndex); + maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index bdfe74ed2a0..6328374e301 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1109,26 +1109,42 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, const struct pipe_vertex_buffer* buffers) { struct r300_context* r300 = r300_context(pipe); - int i; - unsigned max_index = (1 << 24) - 1; - boolean any_user_buffer = false; + struct pipe_vertex_buffer *vbo; + unsigned i, max_index = (1 << 24) - 1; + boolean any_user_buffer = FALSE; if (count == r300->vertex_buffer_count && - memcmp(r300->vertex_buffer, buffers, count * sizeof(buffers[0])) == 0) + memcmp(r300->vertex_buffer, buffers, + sizeof(struct pipe_vertex_buffer) * count) == 0) { return; - - for (i = 0; i < count; i++) { - pipe_buffer_reference(&r300->vertex_buffer[i].buffer, buffers[i].buffer); - if (r300_buffer_is_user_buffer(buffers[i].buffer)) - any_user_buffer = true; - max_index = MIN2(buffers[i].max_index, max_index); } - for ( ; i < r300->vertex_buffer_count; i++) - pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL); + for (i = 0; i < count; i++) { + /* Why, yes, I AM casting away constness. How did you know? */ + vbo = (struct pipe_vertex_buffer*)&buffers[i]; + + /* Reference our buffer. */ + pipe_buffer_reference(&r300->vertex_buffer[i].buffer, vbo->buffer); + if (r300_buffer_is_user_buffer(vbo->buffer)) { + any_user_buffer = TRUE; + } + + if (vbo->max_index == ~0) { + /* Bogus value from broken state tracker; hax it. */ + vbo->max_index = + (vbo->buffer->size - vbo->buffer_offset) / vbo->stride; + } + + max_index = MIN2(vbo->max_index, max_index); + } + + for (; i < r300->vertex_buffer_count; i++) { + /* Dereference any old buffers. */ + pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL); + } memcpy(r300->vertex_buffer, buffers, - sizeof(struct pipe_vertex_buffer) * count); + sizeof(struct pipe_vertex_buffer) * count); r300->vertex_buffer_count = count; r300->vertex_buffer_max_index = max_index; From 44cfc4ad740bfc89fc30e19fde4dcc130c605d02 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 20 Mar 2010 17:18:22 -0700 Subject: [PATCH 200/483] r300g: Bump immediate limits. Seems like a decent idea, especially since the big barrier now is getting the VBOs back from the VRAM boundary. --- src/gallium/drivers/r300/r300_render.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 40c1a420428..ff93a16a107 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -141,7 +141,7 @@ static boolean immd_is_good_idea(struct r300_context *r300, unsigned vertex_element_count = r300->velems->count; unsigned i, vbi; - if (count > 4) { + if (count > 10) { return FALSE; } @@ -155,8 +155,7 @@ static boolean immd_is_good_idea(struct r300_context *r300, if (!checked[vbi]) { vbuf = &r300->vertex_buffer[vbi]; - if (r300_buffer_is_referenced(r300, - vbuf->buffer)) { + if (r300_buffer_is_referenced(r300, vbuf->buffer)) { /* It's a very bad idea to map it... */ return FALSE; } From 7b38f946a05045323da0d367baff19bb62950af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 20 Mar 2010 18:31:11 +0100 Subject: [PATCH 201/483] r300/compiler: fix assertion failure in the r500-fragprog emission path --- src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c index 710cae727a1..4e84eefd658 100644 --- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c +++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c @@ -469,9 +469,8 @@ void r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compi if (compiler->Base.Error) return; - assert(code->inst_end >= 0); - - if ((code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) { + if (code->inst_end == -1 || + (code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) { /* This may happen when dead-code elimination is disabled or * when most of the fragment program logic is leading to a KIL */ if (code->inst_end >= 511) { From 951d89ae3a01b2d7f482b95da0a6d647c6855a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 20 Mar 2010 21:26:19 +0100 Subject: [PATCH 202/483] r300g: skip null vertex buffers --- src/gallium/drivers/r300/r300_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 6328374e301..7ab76bfb8d3 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1039,7 +1039,6 @@ r300_create_sampler_view(struct pipe_context *pipe, return view; } - static void r300_sampler_view_destroy(struct pipe_context *pipe, struct pipe_sampler_view *view) @@ -1125,6 +1124,12 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, /* Reference our buffer. */ pipe_buffer_reference(&r300->vertex_buffer[i].buffer, vbo->buffer); + + /* Skip NULL buffers */ + if (!buffers[i].buffer) { + continue; + } + if (r300_buffer_is_user_buffer(vbo->buffer)) { any_user_buffer = TRUE; } From 04de5f4b8bf68a4594ed7fef8348bcf068701ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 20 Mar 2010 22:14:59 +0100 Subject: [PATCH 203/483] r300g: split the vertex buffer alignment validation --- src/gallium/drivers/r300/r300_state.c | 51 +++++++++++++++------------ 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 7ab76bfb8d3..f396b42e950 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1118,6 +1118,20 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, return; } + /* Check if the stride is aligned to the size of DWORD. */ + for (i = 0; i < count; i++) { + if (buffers[i].buffer) { + if (buffers[i].stride % 4 != 0) { + // XXX Shouldn't we align the buffer? + fprintf(stderr, "r300_set_vertex_buffers: " + "Unaligned buffer stride %i isn't supported.\n", + buffers[i].stride); + assert(0); + abort(); + } + } + } + for (i = 0; i < count; i++) { /* Why, yes, I AM casting away constness. How did you know? */ vbo = (struct pipe_vertex_buffer*)&buffers[i]; @@ -1161,22 +1175,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, } } -static boolean r300_validate_aos(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->velems->velem; - int i; - - /* Check if formats and strides are aligned to the size of DWORD. */ - for (i = 0; i < r300->velems->count; i++) { - if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || - util_format_get_blocksize(velem[i].src_format) % 4 != 0) { - return FALSE; - } - } - return TRUE; -} - static void r300_draw_emit_attrib(struct r300_context* r300, enum attrib_emit emit, enum interp_mode interp, @@ -1346,6 +1344,7 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, struct r300_context *r300 = r300_context(pipe); struct r300_screen* r300screen = r300_screen(pipe->screen); struct r300_vertex_element_state *velems; + unsigned i, size; assert(count <= PIPE_MAX_ATTRIBS); velems = CALLOC_STRUCT(r300_vertex_element_state); @@ -1354,6 +1353,20 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, memcpy(velems->velem, attribs, sizeof(struct pipe_vertex_element) * count); if (r300screen->caps->has_tcl) { + /* Check if the format is aligned to the size of DWORD. */ + for (i = 0; i < count; i++) { + size = util_format_get_blocksize(attribs[i].src_format); + + if (size % 4 != 0) { + /* XXX Shouldn't we align the format? */ + fprintf(stderr, "r300_create_vertex_elements_state: " + "Unaligned format %s:%i isn't supported\n", + util_format_name(attribs[i].src_format), size); + assert(0); + abort(); + } + } + r300_vertex_psc(velems); } else { memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); @@ -1382,12 +1395,6 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe, draw_set_vertex_elements(r300->draw, velems->count, velems->velem); } - if (!r300_validate_aos(r300)) { - /* XXX We should fallback using draw. */ - assert(0); - abort(); - } - UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state); r300->vertex_stream_state.size = (1 + velems->vertex_stream.count) * 2; } From 53ca4f8401f2fc552636d69f7d0dcfd7621769e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 04:39:33 +0100 Subject: [PATCH 204/483] r300g: fix misaligned generated offset for ubyte vertex indices --- src/gallium/drivers/r300/r300_render.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index ff93a16a107..afd871ae302 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -353,6 +353,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, static void r300_shorten_ubyte_elts(struct r300_context* r300, struct pipe_buffer** elts, + unsigned start, unsigned count) { struct pipe_screen* screen = r300->context.screen; @@ -370,6 +371,8 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300, in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ); out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE); + in_map += start; + for (i = 0; i < count; i++) { *out_map = (unsigned short)*in_map; in_map++; @@ -407,8 +410,9 @@ void r300_draw_range_elements(struct pipe_context* pipe, } if (indexSize == 1) { - r300_shorten_ubyte_elts(r300, &indexBuffer, count); + r300_shorten_ubyte_elts(r300, &indexBuffer, start, count); indexSize = 2; + start = 0; } r300_update_derived_state(r300); From 162bc831c93bf8632b25c11f116a1405b93a1704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 04:49:35 +0100 Subject: [PATCH 205/483] r300g: align misaligned ushort vertex indices --- src/gallium/drivers/r300/r300_render.c | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index afd871ae302..2fed263a7a9 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -303,7 +303,6 @@ static void r300_emit_draw_elements(struct r300_context *r300, #endif CS_LOCALS(r300); - assert((start * indexSize) % 4 == 0); assert(count < (1 << 24)); maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); @@ -385,6 +384,32 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300, *elts = new_elts; } +static void r300_align_ushort_elts(struct r300_context *r300, + struct pipe_buffer **elts, + unsigned start, unsigned count) +{ + struct pipe_screen* screen = r300->context.screen; + struct pipe_buffer* new_elts; + unsigned short *in_map; + unsigned short *out_map; + + new_elts = screen->buffer_create(screen, 32, + PIPE_BUFFER_USAGE_INDEX | + PIPE_BUFFER_USAGE_CPU_WRITE | + PIPE_BUFFER_USAGE_GPU_READ, + 2 * count); + + in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ); + out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE); + + memcpy(out_map, in_map+start, 2 * count); + + pipe_buffer_unmap(screen, *elts); + pipe_buffer_unmap(screen, new_elts); + + *elts = new_elts; +} + /* This is the fast-path drawing & emission for HW TCL. */ void r300_draw_range_elements(struct pipe_context* pipe, struct pipe_buffer* indexBuffer, @@ -413,6 +438,9 @@ void r300_draw_range_elements(struct pipe_context* pipe, r300_shorten_ubyte_elts(r300, &indexBuffer, start, count); indexSize = 2; start = 0; + } else if (indexSize == 2 && start % 2 != 0) { + r300_align_ushort_elts(r300, &indexBuffer, start, count); + start = 0; } r300_update_derived_state(r300); From 0dab3189e1d100a9a2487f7aff45589b423c386c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Mar 2010 18:23:22 +1000 Subject: [PATCH 206/483] gallium: cached bufmgr add map busy check Suggested by Jose on the list, probably not perfect but will let me get past this for now, testing with a fenced bufmgr on top of this, was slower, Also this doesn't let you do the busy early exit optimisation either from what I can see. Signed-off-by: Dave Airlie --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 86f9266c95f..0f2ae05daed 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -227,6 +227,8 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf, pb_size size, const struct pb_desc *desc) { + void *map; + if(buf->base.base.size < size) return FALSE; @@ -239,6 +241,13 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf, if(!pb_check_usage(desc->usage, buf->base.base.usage)) return FALSE; + + map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_DONTBLOCK); + if (!map) { + return FALSE; + } + + pb_unmap(buf->buffer); return TRUE; } From ff1c7baad241dd722341023806e00a07606de206 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Mar 2010 18:25:31 +1000 Subject: [PATCH 207/483] r300g: add bufmgr cached for vertex/index buffers. This adds the cached bufmgr for vertex/index buffers on top of the kernel manager. Signed-off-by: Dave Airlie --- .../winsys/drm/radeon/core/radeon_drm_buffer.c | 9 ++++++--- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 11 ++++++++++- src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 2472b6bf952..1d29b0b727a 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -72,17 +72,20 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); int write; + if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { + if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) + return NULL; + } + if (buf->bo->ptr != NULL) return buf->bo->ptr; - + if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { uint32_t domain; - if (radeon_bo_is_busy(buf->bo, &domain)) return NULL; } - if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) { buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data); } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 5b82a776a81..62d66d31dc1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -44,6 +44,9 @@ radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws, if (usage & PIPE_BUFFER_USAGE_CONSTANT) provider = ws->mman; + else if ((usage & PIPE_BUFFER_USAGE_VERTEX) || + (usage & PIPE_BUFFER_USAGE_INDEX)) + provider = ws->cman; else provider = ws->kman; buffer = provider->create_buffer(provider, size, &desc); @@ -260,6 +263,7 @@ radeon_winsys_destroy(struct r300_winsys_screen *rws) struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws; radeon_cs_destroy(ws->cs); + ws->cman->destroy(ws->cman); ws->kman->destroy(ws->kman); ws->mman->destroy(ws->mman); @@ -281,6 +285,10 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws) if (!ws->kman) goto fail; + ws->cman = pb_cache_manager_create(ws->kman, 100000); + if (!ws->cman) + goto fail; + ws->mman = pb_malloc_bufmgr_create(); if (!ws->mman) goto fail; @@ -325,7 +333,8 @@ fail: if (ws->bom) radeon_bo_manager_gem_dtor(ws->bom); - + if (ws->cman) + ws->cman->destroy(ws->cman); if (ws->kman) ws->kman->destroy(ws->kman); if (ws->mman) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 16cc701ad6f..ad7b976abd2 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -38,6 +38,8 @@ struct radeon_libdrm_winsys { struct pb_manager *kman; + struct pb_manager *cman; + struct pb_manager *mman; /* PCI ID */ From bb324182fc7cd9cfaa62ee44bdd9287f1ed2ac7a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Mar 2010 19:36:15 +1000 Subject: [PATCH 208/483] r300g: fix occlusion query hangs. Okay need to revist the whole OQ stuff anyways, glean test asserts which is never good. I'm liking the cached bufmgr restrictions less and less, I think I'll probably play with the fence and/or busy stuff ASAP and try and clean it up. Signed-off-by: Dave Airlie --- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index a55d2db039f..60b441176d9 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -200,7 +200,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, /* Open up the OQ BO. */ r300->oqbo = screen->buffer_create(screen, 4096, - PIPE_BUFFER_USAGE_VERTEX, 4096); + PIPE_BUFFER_USAGE_PIXEL, 4096); make_empty_list(&r300->query_list); r300_init_flush_functions(r300); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 1d29b0b727a..a8a7c45a96f 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -73,8 +73,10 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, int write; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { - if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) - return NULL; + if ((_buf->base.usage & PIPE_BUFFER_USAGE_VERTEX) || + (_buf->base.usage & PIPE_BUFFER_USAGE_INDEX)) + if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) + return NULL; } if (buf->bo->ptr != NULL) From 7f1f4c14eced51bf3f43764e2864693ba1c4a6d5 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sun, 21 Mar 2010 11:49:20 +0100 Subject: [PATCH 209/483] dri/nouveau: Random cleanups. --- src/mesa/drivers/dri/nouveau/nouveau_render.h | 4 +- .../drivers/dri/nouveau/nouveau_texture.h | 2 +- src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 31 ++++++----- src/mesa/drivers/dri/nouveau/nv10_state_fb.c | 4 +- src/mesa/drivers/dri/nouveau/nv10_state_tex.c | 5 +- src/mesa/drivers/dri/nouveau/nv10_state_tnl.c | 51 ++++--------------- src/mesa/drivers/dri/nouveau/nv20_state_fb.c | 4 +- src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 5 +- src/mesa/drivers/dri/nouveau/nv20_state_tnl.c | 51 ++++--------------- 9 files changed, 48 insertions(+), 109 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render.h b/src/mesa/drivers/dri/nouveau/nouveau_render.h index bff0ccfd762..923b79b2cf6 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_render.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_render.h @@ -32,8 +32,8 @@ struct nouveau_array_state; typedef void (*dispatch_t)(GLcontext *, unsigned int, int, unsigned int); -typedef unsigned (*extract_u_t)(struct nouveau_array_state *a, int i, int j); -typedef float (*extract_f_t)(struct nouveau_array_state *a, int i, int j); +typedef unsigned (*extract_u_t)(struct nouveau_array_state *, int, int); +typedef float (*extract_f_t)(struct nouveau_array_state *, int, int); struct nouveau_attr_info { int vbo_index; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.h b/src/mesa/drivers/dri/nouveau/nouveau_texture.h index b91facbdeb6..251f537bba7 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.h @@ -41,7 +41,7 @@ struct nouveau_texture { #define to_nouveau_texture(x) ((struct nouveau_texture *)(x)) #define texture_dirty(t) \ - to_nouveau_texture(t)->dirty = GL_TRUE; + to_nouveau_texture(t)->dirty = GL_TRUE void nouveau_set_texbuffer(__DRIcontext *dri_ctx, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index 0c29eec8eec..e5858f82684 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -85,6 +85,18 @@ vbo_deinit_array(struct nouveau_array_state *a) a->fields = 0; } +static int +get_array_stride(GLcontext *ctx, const struct gl_client_array *a) +{ + struct nouveau_render_state *render = to_render_state(ctx); + + if (render->mode == VBO && !_mesa_is_bufferobj(a->BufferObj)) + /* Pack client buffers. */ + return align(_mesa_sizeof_type(a->Type) * a->Size, 4); + else + return a->StrideB; +} + static void vbo_init_arrays(GLcontext *ctx, const struct _mesa_index_buffer *ib, const struct gl_client_array **arrays) @@ -101,18 +113,10 @@ vbo_init_arrays(GLcontext *ctx, const struct _mesa_index_buffer *ib, if (attr >= 0) { const struct gl_client_array *array = arrays[attr]; - int stride; - - if (render->mode == VBO && - !_mesa_is_bufferobj(array->BufferObj)) - /* Pack client buffers. */ - stride = align(_mesa_sizeof_type(array->Type) - * array->Size, 4); - else - stride = array->StrideB; vbo_init_array(&render->attrs[attr], attr, - stride, array->Size, array->Type, + get_array_stride(ctx, array), + array->Size, array->Type, array->BufferObj, array->Ptr, render->mode == IMM); } @@ -245,7 +249,7 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays) vbo_emit_attr(ctx, arrays, VERT_ATTRIB_POS); } -static unsigned +static int get_max_client_stride(GLcontext *ctx, const struct gl_client_array **arrays) { struct nouveau_render_state *render = to_render_state(ctx); @@ -258,7 +262,7 @@ get_max_client_stride(GLcontext *ctx, const struct gl_client_array **arrays) const struct gl_client_array *a = arrays[attr]; if (!_mesa_is_bufferobj(a->BufferObj)) - s = MAX2(a->StrideB, s); + s = MAX2(s, get_array_stride(ctx, a)); } } @@ -327,6 +331,7 @@ vbo_bind_vertices(GLcontext *ctx, const struct gl_client_array **arrays, * array->StrideB; if (a->bo) { + /* Array in a buffer obj. */ a->offset = (intptr_t)array->Ptr + delta; } else { int j, n = max_index - min_index + 1; @@ -334,6 +339,8 @@ vbo_bind_vertices(GLcontext *ctx, const struct gl_client_array **arrays, char *dp = get_scratch_vbo(ctx, n * a->stride, &a->bo, &a->offset); + /* Array in client memory, move it to + * a scratch buffer obj. */ for (j = 0; j < n; j++) memcpy(dp + j * a->stride, sp + j * array->StrideB, diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c index f7c3d36e1cf..a2fcb6b6959 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c @@ -172,15 +172,13 @@ nv10_emit_viewport(GLcontext *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; - int i; get_viewport_translate(ctx, a); a[0] -= 2048; a[1] -= 2048; BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_TRANSLATE_X, 4); - for (i = 0; i < 4; i++) - OUT_RINGf(chan, a[i]); + OUT_RINGp(chan, a, 4); BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING(chan, (fb->Width - 1) << 16 | 0x08000800); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c index 35f41d7295b..6dedb18c72b 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c @@ -54,10 +54,7 @@ nv10_emit_tex_gen(GLcontext *ctx, int emit) if (k) { BEGIN_RING(chan, celsius, TX_GEN_COEFF(i, j), 4); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); + OUT_RINGp(chan, k, 4); } BEGIN_RING(chan, celsius, TX_GEN_MODE(i, j), 1); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c index 2624c9bf305..0e592a16292 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c @@ -140,9 +140,7 @@ nv10_emit_fog(GLcontext *ctx, int emit) OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); + OUT_RINGp(chan, k, 3); context_dirty(ctx, FRAG); } @@ -284,9 +282,7 @@ nv10_emit_light_source(GLcontext *ctx, int emit) if (l->_Flags & LIGHT_POSITIONAL) { BEGIN_RING(chan, celsius, NV10TCL_LIGHT_POSITION_X(i), 3); - OUT_RINGf(chan, l->_Position[0]); - OUT_RINGf(chan, l->_Position[1]); - OUT_RINGf(chan, l->_Position[2]); + OUT_RINGp(chan, l->_Position, 3); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_ATTENUATION_CONSTANT(i), 3); @@ -296,14 +292,10 @@ nv10_emit_light_source(GLcontext *ctx, int emit) } else { BEGIN_RING(chan, celsius, NV10TCL_LIGHT_DIRECTION_X(i), 3); - OUT_RINGf(chan, l->_VP_inf_norm[0]); - OUT_RINGf(chan, l->_VP_inf_norm[1]); - OUT_RINGf(chan, l->_VP_inf_norm[2]); + OUT_RINGp(chan, l->_VP_inf_norm, 3); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_HALF_VECTOR_X(i), 3); - OUT_RINGf(chan, l->_h_inf_norm[0]); - OUT_RINGf(chan, l->_h_inf_norm[1]); - OUT_RINGf(chan, l->_h_inf_norm[2]); + OUT_RINGp(chan, l->_h_inf_norm, 3); } if (l->_Flags & LIGHT_SPOT) { @@ -312,13 +304,7 @@ nv10_emit_light_source(GLcontext *ctx, int emit) nv10_get_spot_coeff(l, k); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_SPOT_CUTOFF_A(i), 7); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); - OUT_RINGf(chan, k[4]); - OUT_RINGf(chan, k[5]); - OUT_RINGf(chan, k[6]); + OUT_RINGp(chan, k, 7); } } @@ -350,15 +336,11 @@ nv10_emit_material_ambient(GLcontext *ctx, int emit) } BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL_AMBIENT_R, 3); - OUT_RINGf(chan, c_scene[0]); - OUT_RINGf(chan, c_scene[1]); - OUT_RINGf(chan, c_scene[2]); + OUT_RINGp(chan, c_scene, 3); if (ctx->Light.ColorMaterialEnabled) { BEGIN_RING(chan, celsius, NV10TCL_MATERIAL_FACTOR_R, 3); - OUT_RINGf(chan, c_factor[0]); - OUT_RINGf(chan, c_factor[1]); - OUT_RINGf(chan, c_factor[2]); + OUT_RINGp(chan, c_factor, 3); } foreach(l, &ctx->Light.EnabledList) { @@ -368,9 +350,7 @@ nv10_emit_material_ambient(GLcontext *ctx, int emit) l->_MatAmbient[0]); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_AMBIENT_R(i), 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -392,9 +372,7 @@ nv10_emit_material_diffuse(GLcontext *ctx, int emit) l->_MatDiffuse[0]); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_DIFFUSE_R(i), 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -412,9 +390,7 @@ nv10_emit_material_specular(GLcontext *ctx, int emit) l->_MatSpecular[0]); BEGIN_RING(chan, celsius, NV10TCL_LIGHT_SPECULAR_R(i), 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -455,12 +431,7 @@ nv10_emit_material_shininess(GLcontext *ctx, int emit) k); BEGIN_RING(chan, celsius, NV10TCL_MATERIAL_SHININESS(0), 6); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); - OUT_RINGf(chan, k[4]); - OUT_RINGf(chan, k[5]); + OUT_RINGp(chan, k, 6); } void diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_fb.c b/src/mesa/drivers/dri/nouveau/nv20_state_fb.c index d638541df9e..21da4f7af16 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_fb.c @@ -106,13 +106,11 @@ nv20_emit_viewport(GLcontext *ctx, int emit) struct nouveau_grobj *kelvin = context_eng3d(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; - int i; get_viewport_translate(ctx, a); BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4); - for (i = 0; i < 4; i++) - OUT_RINGf(chan, a[i]); + OUT_RINGp(chan, a, 4); BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING(chan, (fb->Width - 1) << 16); diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index bb8a79c2c92..e46118e4fce 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -53,10 +53,7 @@ nv20_emit_tex_gen(GLcontext *ctx, int emit) if (k) { BEGIN_RING(chan, kelvin, TX_GEN_COEFF(i, j), 4); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); + OUT_RINGp(chan, k, 4); } BEGIN_RING(chan, kelvin, TX_GEN_MODE(i, j), 1); diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c index df22adf2729..62efe80fe4b 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c @@ -139,9 +139,7 @@ nv20_emit_fog(GLcontext *ctx, int emit) OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); + OUT_RINGp(chan, k, 3); } void @@ -176,9 +174,7 @@ nv20_emit_light_source(GLcontext *ctx, int emit) if (l->_Flags & LIGHT_POSITIONAL) { BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_POSITION_X(i), 3); - OUT_RINGf(chan, l->_Position[0]); - OUT_RINGf(chan, l->_Position[1]); - OUT_RINGf(chan, l->_Position[2]); + OUT_RINGp(chan, l->_Position, 3); BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_ATTENUATION_CONSTANT(i), 3); OUT_RINGf(chan, l->ConstantAttenuation); @@ -187,14 +183,10 @@ nv20_emit_light_source(GLcontext *ctx, int emit) } else { BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_DIRECTION_X(i), 3); - OUT_RINGf(chan, l->_VP_inf_norm[0]); - OUT_RINGf(chan, l->_VP_inf_norm[1]); - OUT_RINGf(chan, l->_VP_inf_norm[2]); + OUT_RINGp(chan, l->_VP_inf_norm, 3); BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_HALF_VECTOR_X(i), 3); - OUT_RINGf(chan, l->_h_inf_norm[0]); - OUT_RINGf(chan, l->_h_inf_norm[1]); - OUT_RINGf(chan, l->_h_inf_norm[2]); + OUT_RINGp(chan, l->_h_inf_norm, 3); } if (l->_Flags & LIGHT_SPOT) { @@ -203,13 +195,7 @@ nv20_emit_light_source(GLcontext *ctx, int emit) nv10_get_spot_coeff(l, k); BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_SPOT_CUTOFF_A(i), 7); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); - OUT_RINGf(chan, k[4]); - OUT_RINGf(chan, k[5]); - OUT_RINGf(chan, k[6]); + OUT_RINGp(chan, k, 7); } } @@ -246,15 +232,11 @@ nv20_emit_material_ambient(GLcontext *ctx, int emit) } BEGIN_RING(chan, kelvin, m_scene[side], 3); - OUT_RINGf(chan, c_scene[0]); - OUT_RINGf(chan, c_scene[1]); - OUT_RINGf(chan, c_scene[2]); + OUT_RINGp(chan, c_scene, 3); if (ctx->Light.ColorMaterialEnabled) { BEGIN_RING(chan, kelvin, m_factor[side], 3); - OUT_RINGf(chan, c_factor[0]); - OUT_RINGf(chan, c_factor[1]); - OUT_RINGf(chan, c_factor[2]); + OUT_RINGp(chan, c_factor, 3); } foreach(l, &ctx->Light.EnabledList) { @@ -266,9 +248,7 @@ nv20_emit_material_ambient(GLcontext *ctx, int emit) l->_MatAmbient[side]); BEGIN_RING(chan, kelvin, m_light[side], 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -295,9 +275,7 @@ nv20_emit_material_diffuse(GLcontext *ctx, int emit) l->_MatDiffuse[side]); BEGIN_RING(chan, kelvin, m_light[side], 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -318,9 +296,7 @@ nv20_emit_material_specular(GLcontext *ctx, int emit) l->_MatSpecular[side]); BEGIN_RING(chan, kelvin, m_light[side], 3); - OUT_RINGf(chan, c_light[0]); - OUT_RINGf(chan, c_light[1]); - OUT_RINGf(chan, c_light[2]); + OUT_RINGp(chan, c_light, 3); } } @@ -340,12 +316,7 @@ nv20_emit_material_shininess(GLcontext *ctx, int emit) k); BEGIN_RING(chan, kelvin, mthd[side], 6); - OUT_RINGf(chan, k[0]); - OUT_RINGf(chan, k[1]); - OUT_RINGf(chan, k[2]); - OUT_RINGf(chan, k[3]); - OUT_RINGf(chan, k[4]); - OUT_RINGf(chan, k[5]); + OUT_RINGp(chan, k, 6); } void From c48226e81d6a070a4bbaf42e0a310a868bcbe935 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sun, 21 Mar 2010 11:49:46 +0100 Subject: [PATCH 210/483] dri/nouveau: Reemit the light model state when lighting goes on/off. --- src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index ef2cc787de7..7697090f6a6 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -189,6 +189,7 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_LIGHTING: context_dirty(ctx, FRAG); context_dirty(ctx, MODELVIEW); + context_dirty(ctx, LIGHT_MODEL); context_dirty(ctx, LIGHT_ENABLE); for (i = 0; i < MAX_LIGHTS; i++) { From a81cd67a4f37233319281a69385f07feaa97fd13 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 13:11:47 +0200 Subject: [PATCH 211/483] tests: Add test for huge client arrays that has to be split. When running this test case in valgrind report includes read of unitialized value in _tnl_draw_prims. The bug doesn't cause any vissible errors. Bug is caused by vbo_split_copy that is calling draw function with max_index one past the end instead of the end. --- progs/tests/Makefile | 1 + progs/tests/cva_huge.c | 236 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 progs/tests/cva_huge.c diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 67efc3b7a9c..6bb0249e171 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -41,6 +41,7 @@ SOURCES = \ copypixrate.c \ crossbar.c \ cva.c \ + cva_huge.c \ cylwrap.c \ drawbuffers.c \ drawbuffers2.c \ diff --git a/progs/tests/cva_huge.c b/progs/tests/cva_huge.c new file mode 100644 index 00000000000..da63596d486 --- /dev/null +++ b/progs/tests/cva_huge.c @@ -0,0 +1,236 @@ +/* + * Copyright © 2010 Pauli Nieminen + * + * 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 (including the next + * paragraph) 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 + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + */ + + +/* + * Test case for huge cva arrays. Mesa code has to split this to multiple VBOs + * which had memory access error. + * This test case doesn't render incorrectly but valgrind showed the memory + * access error. + */ + +#include +#include +#include +#ifdef __VMS +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#else +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#endif +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_LEGACY +#include + +GLfloat *verts; + +GLubyte *color; + +GLuint *indices; + +#define rows 1000 /* Create 1000x1000 vertex grid */ +#define row_width 5000.0 +#define grid_depth -50.0 +GLuint nr_verts_in_row = rows; +GLuint nr_indices_in_strip = rows * 2; + +GLboolean double_buffer; +GLboolean compiled = GL_TRUE; + +static void generate_verts( void ) +{ + unsigned x, y; + GLfloat step = row_width /(GLfloat)(nr_verts_in_row - 1); + verts = malloc(sizeof(verts[0]) * 4 * nr_verts_in_row * nr_verts_in_row); + + for (y = 0; y < nr_verts_in_row; ++y) { + for (x = 0; x < nr_verts_in_row; ++x) { + unsigned idx = 4*(x + y * nr_verts_in_row); + verts[idx + 0] = step * x - row_width/2.0; + verts[idx + 1] = step * y - row_width/2.0; + /* deep enough not to be vissible */ + verts[idx + 2] = grid_depth; + verts[idx + 3] = 0.0; + } + } + glVertexPointer( 3, GL_FLOAT, sizeof(verts[0])*4, verts ); +} + +static void generate_colors( void ) +{ + unsigned x, y; + GLfloat step = 255.0/(GLfloat)(nr_verts_in_row - 1); + color = malloc(sizeof(color[0]) * 4 * nr_verts_in_row * nr_verts_in_row); + + for (y = 0; y < nr_verts_in_row; ++y) { + for (x = 0; x < nr_verts_in_row; ++x) { + unsigned idx = 4*(x + y * nr_verts_in_row); + color[idx + 0] = (GLubyte)(step * x); + color[idx + 1] = 0x00; + color[idx + 2] = (GLubyte)(step * y); + color[idx + 3] = 0x00; + } + } + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color ); +} + +static void generate_indices( void ) +{ + unsigned strip, i; + + /* indice size * number of strips * number of indices in strip */ + indices = malloc(sizeof(indices[0]) * (nr_verts_in_row - 1) * + (nr_indices_in_strip)); + + for (strip = 0; strip < nr_verts_in_row - 1; strip += 2) { + for (i = 0; i < nr_indices_in_strip; i+=2) { + unsigned idx = i + strip * nr_indices_in_strip; + unsigned idx2 = (nr_indices_in_strip - i - 2) + (strip + + 1) * (nr_indices_in_strip); + indices[idx + 1] = i/2 + strip*nr_verts_in_row; + indices[idx] = i/2 + (strip + 1)*nr_verts_in_row; + if (strip + 1 < nr_verts_in_row - 1) { + indices[idx2] = i/2 + (strip + 1)*nr_verts_in_row; + indices[idx2 + 1] = i/2 + (strip + 2)*nr_verts_in_row; + } + } + } +} + +static void init( void ) +{ + + + generate_verts(); + generate_colors(); + generate_indices(); + + glClearColor( 0.0, 0.0, 0.0, 0.0 ); + glShadeModel( GL_SMOOTH ); + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -100.0, 100.0, -100.0, 100.0, 1.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + +#ifdef GL_EXT_compiled_vertex_array + if ( compiled ) { + glLockArraysEXT( 0, rows * rows ); + } +#endif +} + +static void display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glDrawElements( GL_TRIANGLE_STRIP, nr_indices_in_strip * (nr_verts_in_row - 1) , GL_UNSIGNED_INT, indices ); + + if ( double_buffer ) + glutSwapBuffers(); + else + glFlush(); +} + +static void keyboard( unsigned char key, int x, int y ) +{ + switch ( key ) { + case 27: + exit( 0 ); + break; + } + + glutPostRedisplay(); +} + +static GLboolean args( int argc, char **argv ) +{ + GLint i; + + double_buffer = GL_TRUE; + + for ( i = 1 ; i < argc ; i++ ) { + if ( strcmp( argv[i], "-sb" ) == 0 ) { + double_buffer = GL_FALSE; + } else if ( strcmp( argv[i], "-db" ) == 0 ) { + double_buffer = GL_TRUE; + } else { + fprintf( stderr, "%s (Bad option).\n", argv[i] ); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main( int argc, char **argv ) +{ + GLenum type; + char *string; + double version; + + glutInit( &argc, argv ); + + if ( args( argc, argv ) == GL_FALSE ) { + exit( 1 ); + } + + type = GLUT_RGB | GLUT_DEPTH; + type |= ( double_buffer ) ? GLUT_DOUBLE : GLUT_SINGLE; + + glutInitDisplayMode( type ); + glutInitWindowSize( 250, 250 ); + glutInitWindowPosition( 100, 100 ); + glutCreateWindow( "CVA Test" ); + + /* Make sure the server supports GL 1.2 vertex arrays. + */ + string = (char *) glGetString( GL_VERSION ); + + version = atof(string); + if ( version < 1.2 ) { + fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" ); + exit( -1 ); + } + + /* See if the server supports compiled vertex arrays. + */ + string = (char *) glGetString( GL_EXTENSIONS ); + + if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) { + fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" ); + compiled = GL_FALSE; + } + + init(); + + glutDisplayFunc( display ); + glutKeyboardFunc( keyboard ); + glutMainLoop(); + + return 0; +} From 9a7acbccfbc061322be493633d5c5bf4afd302b5 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 12:42:10 +0200 Subject: [PATCH 212/483] vbo: Fix vbo_split_copy to pass correct max_index to draw. vbo_split_copy was passing one past the max_index to draw function which caused _tnl_draw_prims function to read uninitialized values from copied array. Bug was spoted in valgrind report of progs/tests/cva_huge. --- src/mesa/vbo/vbo_split_copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index bce401744da..2ec7d9b0fe3 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -196,7 +196,7 @@ flush( struct copy_context *copy ) ©->dstib, GL_TRUE, 0, - copy->dstbuf_nr ); + copy->dstbuf_nr - 1 ); /* Reset all pointers: */ From 2d1641b1917309d6397a6c9c773b801eb83838f8 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:09 +0200 Subject: [PATCH 213/483] glx: swapBuffers prototype has changed --- src/glx/drisw_glx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 1b94a56fd13..93826bc6825 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -334,10 +334,17 @@ driCreateDrawable(__GLXscreenConfigs * psc, return pdraw; } -static void -driSwapBuffers(__GLXDRIdrawable * pdraw) +static int64_t +driSwapBuffers(__GLXDRIdrawable * pdraw, + int64_t target_msc, int64_t divisor, int64_t remainder) { + (void) target_msc; + (void) divisor; + (void) remainder; + (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); + + return 0; } static void From 2b5a6e083c1e6e45757a2192721d8675309835c1 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 20 Mar 2010 01:51:00 +0200 Subject: [PATCH 214/483] glx: minor cosmetic --- src/glx/drisw_glx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 93826bc6825..3db2d63f1f7 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -85,11 +85,14 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, visMask = (VisualScreenMask | VisualIDMask); pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals); - pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ + pdp->ximage = XCreateImage(dpy, + pdp->visinfo->visual, + pdp->visinfo->depth, + ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* size */ + 32, /* bitmap_pad */ + 0); /* bytes_per_line */ /* get the true number of bits per pixel */ pdp->bpp = pdp->ximage->bits_per_pixel; From 0b932284f2294a1dc02004d3b6ef6dfb633bc4bb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:09 +0200 Subject: [PATCH 215/483] dri_inteface: add define for checking presence of drm.h __NOT_HAVE_DRM_H is a like a feature, defined by default on specific platforms and allows to be defined externally as well. __NOT_HAVE_DRM_H should only be used by xserver and mesa swrast_dri drivers --- include/GL/internal/dri_interface.h | 8 +++++++- src/mesa/drivers/dri/swrast/Makefile | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 1d4e82e154a..aa56eb45d79 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -41,7 +41,13 @@ #define DRI_INTERFACE_H /* For archs with no drm.h */ -#if !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__GNU__) +#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__) +#ifndef __NOT_HAVE_DRM_H +#define __NOT_HAVE_DRM_H +#endif +#endif + +#ifndef __NOT_HAVE_DRM_H #include #else typedef unsigned int drm_context_t; diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index cc59eefdb2d..aeefece4402 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -5,6 +5,8 @@ include $(TOP)/configs/current LIBNAME = swrast_dri.so +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H + DRIVER_SOURCES = \ swrast.c \ swrast_span.c From a13bcf945fdc455c184284552d8f39c57982d61f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:10 +0200 Subject: [PATCH 216/483] rename dri_sw to drisw_util for consistency --- src/mesa/drivers/dri/common/{dri_sw.c => drisw_util.c} | 4 ++-- src/mesa/drivers/dri/common/{dri_sw.h => drisw_util.h} | 0 src/mesa/drivers/dri/swrast/Makefile | 2 +- src/mesa/drivers/dri/swrast/swrast_priv.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename src/mesa/drivers/dri/common/{dri_sw.c => drisw_util.c} (99%) rename src/mesa/drivers/dri/common/{dri_sw.h => drisw_util.h} (100%) diff --git a/src/mesa/drivers/dri/common/dri_sw.c b/src/mesa/drivers/dri/common/drisw_util.c similarity index 99% rename from src/mesa/drivers/dri/common/dri_sw.c rename to src/mesa/drivers/dri/common/drisw_util.c index b7f9036f473..141ca302d08 100644 --- a/src/mesa/drivers/dri/common/dri_sw.c +++ b/src/mesa/drivers/dri/common/drisw_util.c @@ -22,12 +22,12 @@ */ /** - * \file dri_sw.c + * \file drisw_util.c * * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits. */ -#include "dri_sw.h" +#include "drisw_util.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/drisw_util.h similarity index 100% rename from src/mesa/drivers/dri/common/dri_sw.h rename to src/mesa/drivers/dri/common/drisw_util.h diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index aeefece4402..d2cf6dbc55b 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -20,7 +20,7 @@ ASM_SOURCES = SWRAST_COMMON_SOURCES = \ ../../common/driverfuncs.c \ ../common/utils.c \ - ../common/dri_sw.c + ../common/drisw_util.c include ../Makefile.template diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 77670d89a5e..007642be95f 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -30,7 +30,7 @@ #include #include #include "main/mtypes.h" -#include "dri_sw.h" +#include "drisw_util.h" /** From 9ec29e31919e85f9230867f43841c0e74be930d3 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:10 +0200 Subject: [PATCH 217/483] Makefile.template: respect LIBRARY_DEFINES in mkdep --- src/gallium/Makefile.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 91a9b54b362..7606a947e22 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -34,7 +34,7 @@ lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefil depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES) rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(LIBRARY_DEFINES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null # Emacs tags tags: From 016c5c953f05bc8f20cc48d352e1013dd71a98a2 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:11 +0200 Subject: [PATCH 218/483] drm/sw: llvmpipe texture_from_handle Not sure, but judging by softpipe, this hook was forgotten. --- src/gallium/drivers/llvmpipe/lp_texture.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 93ad789c35d..8137f29af52 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -464,6 +464,7 @@ llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen) { screen->texture_create = llvmpipe_texture_create; screen->texture_destroy = llvmpipe_texture_destroy; + screen->texture_from_handle = llvmpipe_texture_from_handle; screen->texture_get_handle = llvmpipe_texture_get_handle; screen->get_tex_surface = llvmpipe_get_tex_surface; From 97a694e2211dc804090f282d8e096c028f29579f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:11 +0200 Subject: [PATCH 219/483] drm/sw: does not need sw_winsys --- src/gallium/winsys/drm/sw/sw_drm_api.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index 0fd2163913e..9c5933c73af 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -40,7 +40,6 @@ struct sw_drm_api { struct drm_api base; struct drm_api *api; - struct sw_winsys *sw; }; static INLINE struct sw_drm_api * From c28f5f98d6d57d3dd74fc6c1205a36ed584d1c93 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:11 +0200 Subject: [PATCH 220/483] dri1_api: need not include drm.h --- src/gallium/include/state_tracker/dri1_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h index b173ba3683d..27b7a28c467 100644 --- a/src/gallium/include/state_tracker/dri1_api.h +++ b/src/gallium/include/state_tracker/dri1_api.h @@ -7,7 +7,7 @@ #include "state_tracker/drm_api.h" -#include +struct drm_clip_rect; struct pipe_screen; struct pipe_winsys; From f87a5f6499f51f651c2a9f2d4682875b22926905 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:11 +0200 Subject: [PATCH 221/483] gallium: add soft screen helper --- .../auxiliary/target-helpers/soft_screen.c | 73 +++++++++++++++++++ .../auxiliary/target-helpers/soft_screen.h | 12 +++ src/gallium/targets/libgl-xlib/Makefile | 1 + src/gallium/targets/libgl-xlib/soft_screen.c | 1 + src/gallium/targets/libgl-xlib/xlib.c | 34 +-------- src/gallium/winsys/drm/sw/Makefile | 3 +- src/gallium/winsys/drm/sw/soft_screen.c | 1 + src/gallium/winsys/drm/sw/sw_drm_api.c | 32 +++++++- 8 files changed, 120 insertions(+), 37 deletions(-) create mode 100644 src/gallium/auxiliary/target-helpers/soft_screen.c create mode 100644 src/gallium/auxiliary/target-helpers/soft_screen.h create mode 120000 src/gallium/targets/libgl-xlib/soft_screen.c create mode 120000 src/gallium/winsys/drm/sw/soft_screen.c diff --git a/src/gallium/auxiliary/target-helpers/soft_screen.c b/src/gallium/auxiliary/target-helpers/soft_screen.c new file mode 100644 index 00000000000..00d386ee1de --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/soft_screen.c @@ -0,0 +1,73 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +#include "target-helpers/soft_screen.h" +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "cell/ppu/cell_public.h" +#include "util/u_debug.h" + +/** + * Choose and create a software renderer screen. + */ +struct pipe_screen * +gallium_soft_create_screen( struct sw_winsys *winsys ) +{ + const char *default_driver = NULL; + const char *driver = NULL; + struct pipe_screen *screen = NULL; + +#if defined(GALLIUM_CELL) + default_driver = "cell"; +#elif defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#if defined(GALLIUM_CELL) + if (screen == NULL && strcmp(driver, "cell") == 0) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif + + return screen; +} diff --git a/src/gallium/auxiliary/target-helpers/soft_screen.h b/src/gallium/auxiliary/target-helpers/soft_screen.h new file mode 100644 index 00000000000..5c1012644aa --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/soft_screen.h @@ -0,0 +1,12 @@ +#ifndef SOFT_SCREEN_HELPER_H +#define SOFT_SCREEN_HELPER_H + +#include "pipe/p_compiler.h" + +struct pipe_screen; +struct sw_winsys; + +struct pipe_screen * +gallium_soft_create_screen( struct sw_winsys *winsys ); + +#endif diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile index 5a4e035c2eb..2c44a62102e 100644 --- a/src/gallium/targets/libgl-xlib/Makefile +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -27,6 +27,7 @@ DEFINES += \ #-DGALLIUM_CELL will be defined by the config */ XLIB_TARGET_SOURCES = \ + soft_screen.c \ xlib.c diff --git a/src/gallium/targets/libgl-xlib/soft_screen.c b/src/gallium/targets/libgl-xlib/soft_screen.c new file mode 120000 index 00000000000..d6d878f3658 --- /dev/null +++ b/src/gallium/targets/libgl-xlib/soft_screen.c @@ -0,0 +1 @@ +../../auxiliary/target-helpers/soft_screen.c \ No newline at end of file diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 48e79fe4f3b..e7862212106 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -36,6 +36,7 @@ #include "softpipe/sp_public.h" #include "llvmpipe/lp_public.h" #include "cell/ppu/cell_public.h" +#include "target-helpers/soft_screen.h" #include "target-helpers/wrap_screen.h" #include "xm_public.h" @@ -63,8 +64,6 @@ PUBLIC const struct st_module st_module_OpenGL = { static struct pipe_screen * swrast_xlib_create_screen( Display *display ) { - const char *default_driver; - const char *driver; struct sw_winsys *winsys; struct pipe_screen *screen = NULL; @@ -75,36 +74,7 @@ swrast_xlib_create_screen( Display *display ) if (winsys == NULL) return NULL; -#if defined(GALLIUM_CELL) - default_driver = "cell"; -#elif defined(GALLIUM_LLVMPIPE) - default_driver = "llvmpipe"; -#elif defined(GALLIUM_SOFTPIPE) - default_driver = "softpipe"; -#else - default_driver = ""; -#endif - - driver = debug_get_option("GALLIUM_DRIVER", default_driver); - - /* Create a software rasterizer on top of that winsys: - */ -#if defined(GALLIUM_CELL) - if (screen == NULL && - strcmp(driver, "cell") == 0) - screen = cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) - if (screen == NULL && - strcmp(driver, "llvmpipe") == 0) - screen = llvmpipe_create_screen( winsys ); -#endif - -#if defined(GALLIUM_SOFTPIPE) - if (screen == NULL) - screen = softpipe_create_screen( winsys ); -#endif + screen = gallium_soft_create_screen( winsys ); if (screen == NULL) goto fail; diff --git a/src/gallium/winsys/drm/sw/Makefile b/src/gallium/winsys/drm/sw/Makefile index 5f3c3ec325d..12b20cbd454 100644 --- a/src/gallium/winsys/drm/sw/Makefile +++ b/src/gallium/winsys/drm/sw/Makefile @@ -4,11 +4,12 @@ include $(TOP)/configs/current LIBNAME = swdrm C_SOURCES = \ + soft_screen.c \ wrapper_sw_winsys.c \ sw_drm_api.c LIBRARY_INCLUDES = -LIBRARY_DEFINES = +LIBRARY_DEFINES = -DGALLIUM_SOFTPIPE include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/sw/soft_screen.c b/src/gallium/winsys/drm/sw/soft_screen.c new file mode 120000 index 00000000000..423597ba31f --- /dev/null +++ b/src/gallium/winsys/drm/sw/soft_screen.c @@ -0,0 +1 @@ +../../../auxiliary/target-helpers/soft_screen.c \ No newline at end of file diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index 9c5933c73af..ed3ce146eb1 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -24,8 +24,11 @@ **********************************************************/ +#include "pipe/p_screen.h" #include "util/u_memory.h" -#include "softpipe/sp_public.h" +#include "target-helpers/soft_screen.h" + +#include "state_tracker/sw_winsys.h" #include "state_tracker/drm_api.h" #include "wrapper_sw_winsys.h" #include "sw_drm_api.h" @@ -60,14 +63,35 @@ sw_drm_create_screen(struct drm_api *_api, int drmFD, { struct sw_drm_api *swapi = sw_drm_api(_api); struct drm_api *api = swapi->api; - struct sw_winsys *sww; - struct pipe_screen *screen; + struct sw_winsys *sww = NULL; + struct pipe_screen *screen = NULL; + struct pipe_screen *soft_screen = NULL; screen = api->create_screen(api, drmFD, arg); + if (screen == NULL) + goto fail; sww = wrapper_sw_winsys_warp_pipe_screen(screen); + if (sww == NULL) + goto fail; - return softpipe_create_screen(sww); + soft_screen = gallium_soft_create_screen(sww); + if (soft_screen == NULL) + goto fail; + + return soft_screen; + +fail: + if (soft_screen) + soft_screen->destroy(soft_screen); + + if (sww) + sww->destroy(sww); + + if (screen) + screen->destroy(screen); + + return NULL; } static void From 272bbbffb0138024564cbf8410a30ea9e25eb179 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 21 Mar 2010 13:17:02 +0100 Subject: [PATCH 222/483] nv50: get rid of the static_init stateobj Relocations of per-screen buffers are now emitted directly, and include the necessary method to get changes in constbuf addresses committed to the hw. It should also be a bit cheaper than the way stateobjs emit relocation markers, use a little less pushbuf space. --- src/gallium/drivers/nv50/nv50_screen.c | 274 +++++++++--------- src/gallium/drivers/nv50/nv50_screen.h | 4 +- .../drivers/nv50/nv50_state_validate.c | 2 +- 3 files changed, 141 insertions(+), 139 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index d7f5863fb71..8fab06c55da 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -190,8 +190,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen) nouveau_bo_ref(NULL, &screen->tic); if (screen->tsc) nouveau_bo_ref(NULL, &screen->tsc); - if (screen->static_init) - so_ref(NULL, &screen->static_init); nouveau_notifier_free(&screen->sync); nouveau_grobj_free(&screen->tesla); @@ -204,16 +202,65 @@ nv50_screen_destroy(struct pipe_screen *pscreen) FREE(screen); } +#define BGN_RELOC(ch, bo, gr, m, n, fl) \ + OUT_RELOC(ch, bo, (n << 18) | (gr->subc << 13) | m, fl, 0, 0) + +void +nv50_screen_relocs(struct nv50_screen *screen) +{ + struct nouveau_channel *chan = screen->base.channel; + struct nouveau_grobj *tesla = screen->tesla; + unsigned i; + const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_DUMMY; + + MARK_RING (chan, 28, 26); + + /* cause grobj autobind */ + BEGIN_RING(chan, tesla, 0x0100, 1); + OUT_RING (chan, 0); + + BGN_RELOC (chan, screen->tic, tesla, NV50TCL_TIC_ADDRESS_HIGH, 2, rl); + OUT_RELOCh(chan, screen->tic, 0, rl); + OUT_RELOCl(chan, screen->tic, 0, rl); + + BGN_RELOC (chan, screen->tsc, tesla, NV50TCL_TSC_ADDRESS_HIGH, 2, rl); + OUT_RELOCh(chan, screen->tsc, 0, rl); + OUT_RELOCl(chan, screen->tsc, 0, rl); + + BGN_RELOC (chan, screen->constbuf_misc[0], + tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl); + OUT_RELOCh(chan, screen->constbuf_misc[0], 0, rl); + OUT_RELOCl(chan, screen->constbuf_misc[0], 0, rl); + OUT_RELOC (chan, screen->constbuf_misc[0], + (NV50_CB_PMISC << 16) | 0x0200, rl, 0, 0); + + BGN_RELOC (chan, screen->constbuf_misc[0], + tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl); + OUT_RELOCh(chan, screen->constbuf_misc[0], 0x200, rl); + OUT_RELOCl(chan, screen->constbuf_misc[0], 0x200, rl); + OUT_RELOC (chan, screen->constbuf_misc[0], + (NV50_CB_AUX << 16) | 0x0200, rl, 0, 0); + + for (i = 0; i < 3; ++i) { + BGN_RELOC (chan, screen->constbuf_parm[i], + tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl); + OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl); + OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl); + OUT_RELOC (chan, screen->constbuf_parm[i], + ((NV50_CB_PVP + i) << 16) | 0x0800, rl, 0, 0); + } +} + struct pipe_screen * nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); struct nouveau_channel *chan; struct pipe_screen *pscreen; - struct nouveau_stateobj *so; unsigned chipset = dev->chipset; unsigned tesla_class = 0; int ret, i; + const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD; if (!screen) return NULL; @@ -296,64 +343,58 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static M2MF init */ - so = so_new(1, 3, 0); - so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3); - so_data (so, screen->sync->handle); - so_data (so, chan->vram->handle); - so_data (so, chan->vram->handle); - so_emit(chan, so); - so_ref (NULL, &so); + BEGIN_RING(chan, screen->m2mf, + NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3); + OUT_RING (chan, screen->sync->handle); + OUT_RING (chan, chan->vram->handle); + OUT_RING (chan, chan->vram->handle); /* Static 2D init */ - so = so_new(4, 7, 0); - so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); - so_data (so, screen->sync->handle); - so_data (so, chan->vram->handle); - so_data (so, chan->vram->handle); - so_data (so, chan->vram->handle); - so_method(so, screen->eng2d, NV50_2D_OPERATION, 1); - so_data (so, NV50_2D_OPERATION_SRCCOPY); - so_method(so, screen->eng2d, NV50_2D_CLIP_ENABLE, 1); - so_data (so, 0); - so_method(so, screen->eng2d, 0x0888, 1); - so_data (so, 1); - so_emit(chan, so); - so_ref(NULL, &so); + BEGIN_RING(chan, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); + OUT_RING (chan, screen->sync->handle); + OUT_RING (chan, chan->vram->handle); + OUT_RING (chan, chan->vram->handle); + OUT_RING (chan, chan->vram->handle); + BEGIN_RING(chan, screen->eng2d, NV50_2D_OPERATION, 1); + OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY); + BEGIN_RING(chan, screen->eng2d, NV50_2D_CLIP_ENABLE, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, screen->eng2d, 0x0888, 1); + OUT_RING (chan, 1); /* Static tesla init */ - so = so_new(47, 95, 24); - - so_method(so, screen->tesla, NV50TCL_COND_MODE, 1); - so_data (so, NV50TCL_COND_MODE_ALWAYS); - so_method(so, screen->tesla, NV50TCL_DMA_NOTIFY, 1); - so_data (so, screen->sync->handle); - so_method(so, screen->tesla, NV50TCL_DMA_ZETA, 11); + BEGIN_RING(chan, screen->tesla, NV50TCL_COND_MODE, 1); + OUT_RING (chan, NV50TCL_COND_MODE_ALWAYS); + BEGIN_RING(chan, screen->tesla, NV50TCL_DMA_NOTIFY, 1); + OUT_RING (chan, screen->sync->handle); + BEGIN_RING(chan, screen->tesla, NV50TCL_DMA_ZETA, 11); for (i = 0; i < 11; i++) - so_data(so, chan->vram->handle); - so_method(so, screen->tesla, NV50TCL_DMA_COLOR(0), - NV50TCL_DMA_COLOR__SIZE); + OUT_RING (chan, chan->vram->handle); + BEGIN_RING(chan, screen->tesla, + NV50TCL_DMA_COLOR(0), NV50TCL_DMA_COLOR__SIZE); for (i = 0; i < NV50TCL_DMA_COLOR__SIZE; i++) - so_data(so, chan->vram->handle); - so_method(so, screen->tesla, NV50TCL_RT_CONTROL, 1); - so_data (so, 1); + OUT_RING (chan, chan->vram->handle); + + BEGIN_RING(chan, screen->tesla, NV50TCL_RT_CONTROL, 1); + OUT_RING (chan, 1); /* activate all 32 lanes (threads) in a warp */ - so_method(so, screen->tesla, NV50TCL_WARP_HALVES, 1); - so_data (so, 0x2); - so_method(so, screen->tesla, 0x1400, 1); - so_data (so, 0xf); + BEGIN_RING(chan, screen->tesla, NV50TCL_WARP_HALVES, 1); + OUT_RING (chan, 2); + BEGIN_RING(chan, screen->tesla, 0x1400, 1); + OUT_RING (chan, 0xf); /* max TIC (bits 4:8) & TSC (ignored) bindings, per program type */ for (i = 0; i < 3; ++i) { - so_method(so, screen->tesla, NV50TCL_TEX_LIMITS(i), 1); - so_data (so, 0x54); + BEGIN_RING(chan, screen->tesla, NV50TCL_TEX_LIMITS(i), 1); + OUT_RING (chan, 0x54); } /* origin is top left (set to 1 for bottom left) */ - so_method(so, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1); - so_data (so, 0); - so_method(so, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1); - so_data (so, 8); + BEGIN_RING(chan, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1); + OUT_RING (chan, 8); /* constant buffers for immediates and VP/FP parameters */ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4, @@ -362,6 +403,14 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } + BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, screen->constbuf_misc[0], 0, rl); + OUT_RELOCl(chan, screen->constbuf_misc[0], 0, rl); + OUT_RING (chan, (NV50_CB_PMISC << 16) | 0x0200); + BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, screen->constbuf_misc[0], 0x200, rl); + OUT_RELOCl(chan, screen->constbuf_misc[0], 0x200, rl); + OUT_RING (chan, (NV50_CB_AUX << 16) | 0x0200); for (i = 0; i < 3; i++) { ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (256 * 4) * 4, @@ -370,6 +419,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } + BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl); + OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl); + OUT_RING (chan, ((NV50_CB_PVP + i) << 16) | 0x0800); } if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) || @@ -381,80 +434,16 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) return NULL; } - /* - // map constant buffers: - // B = buffer ID (maybe more than 1 byte) - // N = CB index used in shader instruction - // P = program type (0 = VP, 2 = GP, 3 = FP) - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x000BBNP1); - */ - - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PMISC << 16) | 0x00000200); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000001 | (NV50_CB_PMISC << 12)); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000021 | (NV50_CB_PMISC << 12)); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000031 | (NV50_CB_PMISC << 12)); - - /* bind auxiliary constbuf to immediate data bo */ - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_AUX << 16) | 0x00000200); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000201 | (NV50_CB_AUX << 12)); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000221 | (NV50_CB_AUX << 12)); - - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PVP << 16) | 0x00000800); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000101 | (NV50_CB_PVP << 12)); - - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PGP << 16) | 0x00000800); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000121 | (NV50_CB_PGP << 12)); - - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0, - NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PFP << 16) | 0x00000800); - so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); - so_data (so, 0x00000131 | (NV50_CB_PFP << 12)); - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4), &screen->tic); if (ret) { nv50_screen_destroy(pscreen); return NULL; } - - so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3); - so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, 3 * 32 - 1); + BEGIN_RING(chan, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCl(chan, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RING (chan, 3 * 32 - 1); ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4), &screen->tsc); @@ -462,37 +451,50 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } + BEGIN_RING(chan, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RELOCl(chan, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD); + OUT_RING (chan, 0); /* ignored if TSC_LINKED (0x1234) == 1 */ - so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3); - so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, 0x00000000); /* ignored if TSC_LINKED (0x1234) = 1 */ - + /* map constant buffers: + * B = buffer ID (maybe more than 1 byte) + * N = CB index used in shader instruction + * P = program type (0 = VP, 2 = GP, 3 = FP) + * SET_PROGRAM_CB = 0x000BBNP1 + */ + BEGIN_RING_NI(chan, screen->tesla, NV50TCL_SET_PROGRAM_CB, 8); + /* bind immediate buffer */ + OUT_RING (chan, 0x001 | (NV50_CB_PMISC << 12)); + OUT_RING (chan, 0x021 | (NV50_CB_PMISC << 12)); + OUT_RING (chan, 0x031 | (NV50_CB_PMISC << 12)); + /* bind auxiliary constbuf to immediate data bo */ + OUT_RING (chan, 0x201 | (NV50_CB_AUX << 12)); + OUT_RING (chan, 0x221 | (NV50_CB_AUX << 12)); + /* bind parameter buffers */ + OUT_RING (chan, 0x101 | (NV50_CB_PVP << 12)); + OUT_RING (chan, 0x121 | (NV50_CB_PGP << 12)); + OUT_RING (chan, 0x131 | (NV50_CB_PFP << 12)); /* Vertex array limits - max them out */ for (i = 0; i < 16; i++) { - so_method(so, screen->tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2); - so_data (so, 0x000000ff); - so_data (so, 0xffffffff); + BEGIN_RING(chan, screen->tesla, + NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2); + OUT_RING (chan, 0x000000ff); + OUT_RING (chan, 0xffffffff); } - so_method(so, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2); - so_data (so, fui(0.0)); - so_data (so, fui(1.0)); + BEGIN_RING(chan, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2); + OUT_RINGf (chan, 0.0f); + OUT_RINGf (chan, 1.0f); /* no dynamic combination of TIC & TSC entries => only BIND_TIC used */ - so_method(so, screen->tesla, NV50TCL_LINKED_TSC, 1); - so_data (so, 1); + BEGIN_RING(chan, screen->tesla, NV50TCL_LINKED_TSC, 1); + OUT_RING (chan, 1); - so_method(so, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1); - so_data (so, 1); /* default edgeflag to TRUE */ + BEGIN_RING(chan, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1); + OUT_RING (chan, 1); /* default edgeflag to TRUE */ - so_emit(chan, so); - so_ref (so, &screen->static_init); - so_ref (NULL, &so); - nouveau_pushbuf_flush(chan, 0); + FIRE_RING (chan); screen->force_push = debug_get_bool_option("NV50_ALWAYS_PUSH", FALSE); return pscreen; diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index ec19ea655b1..15bd4eed399 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -27,8 +27,6 @@ struct nv50_screen { struct nouveau_bo *tic; struct nouveau_bo *tsc; - struct nouveau_stateobj *static_init; - boolean force_push; }; @@ -38,4 +36,6 @@ nv50_screen(struct pipe_screen *screen) return (struct nv50_screen *)screen; } +extern void nv50_screen_relocs(struct nv50_screen *); + #endif diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 63d73b5ce83..b7e355283c8 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -435,7 +435,7 @@ nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) so_emit_reloc_markers(chan, nv50->state.hw[3]); /* vp */ so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */ so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */ - so_emit_reloc_markers(chan, nv50->screen->static_init); + nv50_screen_relocs(nv50->screen); /* No idea.. */ BEGIN_RING(chan, tesla, 0x142c, 1); From 1afda5303d2eaf9581fa7c9eec872a0022ff35b5 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 21 Mar 2010 12:26:08 +0100 Subject: [PATCH 223/483] nv50: don't validate arrays on clear The vertex elements and buffers might not be valid anymore. --- src/gallium/drivers/nv50/nv50_clear.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index 8afc95c9fc6..5447904e9ca 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -35,7 +35,10 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned mode = 0, i; + const unsigned dirty = nv50->dirty; + /* don't need NEW_BLEND, NV50TCL_COLOR_MASK doesn't affect CLEAR_BUFFERS */ + nv50->dirty &= NV50_NEW_FRAMEBUFFER | NV50_NEW_SCISSOR; if (!nv50_state_validate(nv50, 64)) return; @@ -64,5 +67,6 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1); OUT_RING (chan, (i << 6) | 0x3c); } + nv50->dirty = dirty; } From 5d524cce9c4fcc18ed977801d59ba7bb911020db Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 15:01:36 +0200 Subject: [PATCH 224/483] drm/sw: just s/softpipe_create_screen/gallium_soft_create_screen/ This partially reverts commit f87a5f6499f51f651c2a9f2d4682875b22926905. --- src/gallium/winsys/drm/sw/sw_drm_api.c | 30 ++++---------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index ed3ce146eb1..fa16600fe6a 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -24,11 +24,9 @@ **********************************************************/ -#include "pipe/p_screen.h" #include "util/u_memory.h" #include "target-helpers/soft_screen.h" -#include "state_tracker/sw_winsys.h" #include "state_tracker/drm_api.h" #include "wrapper_sw_winsys.h" #include "sw_drm_api.h" @@ -43,6 +41,7 @@ struct sw_drm_api { struct drm_api base; struct drm_api *api; + struct sw_winsys *sw; }; static INLINE struct sw_drm_api * @@ -63,35 +62,14 @@ sw_drm_create_screen(struct drm_api *_api, int drmFD, { struct sw_drm_api *swapi = sw_drm_api(_api); struct drm_api *api = swapi->api; - struct sw_winsys *sww = NULL; - struct pipe_screen *screen = NULL; - struct pipe_screen *soft_screen = NULL; + struct sw_winsys *sww; + struct pipe_screen *screen; screen = api->create_screen(api, drmFD, arg); - if (screen == NULL) - goto fail; sww = wrapper_sw_winsys_warp_pipe_screen(screen); - if (sww == NULL) - goto fail; - soft_screen = gallium_soft_create_screen(sww); - if (soft_screen == NULL) - goto fail; - - return soft_screen; - -fail: - if (soft_screen) - soft_screen->destroy(soft_screen); - - if (sww) - sww->destroy(sww); - - if (screen) - screen->destroy(screen); - - return NULL; + return gallium_soft_create_screen(sww); } static void From f7273f2a2741b34ee4d31b0c734bcb3de92098c1 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 21 Mar 2010 14:05:20 +0100 Subject: [PATCH 225/483] nv50: report driver as GLSL capable There's still no hint of optimization in the shaders, but we support conditionals, loops and even integer opcodes so it isn't that big a lie. --- src/gallium/drivers/nv50/nv50_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 8fab06c55da..1a4606d9e25 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -109,7 +109,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) case PIPE_CAP_TWO_SIDED_STENCIL: return 1; case PIPE_CAP_GLSL: - return 0; + return 1; case PIPE_CAP_ANISOTROPIC_FILTER: return 1; case PIPE_CAP_POINT_SPRITE: From 59629b413a7e3e3ba4b4213eb3ba4b65bdf3f9fb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 15:32:50 +0200 Subject: [PATCH 226/483] Revert "Makefile.template: respect LIBRARY_DEFINES in mkdep" This reverts commit 9ec29e31919e85f9230867f43841c0e74be930d3. --- src/gallium/Makefile.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 7606a947e22..91a9b54b362 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -34,7 +34,7 @@ lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefil depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES) rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(LIBRARY_DEFINES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null # Emacs tags tags: From 29ec05164838f13d9535271796a50fa213d07912 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 19:20:15 +0200 Subject: [PATCH 227/483] fix scons build --- src/gallium/targets/libgl-xlib/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index efa7e797d1f..4de463e743e 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -40,6 +40,7 @@ env.Prepend(LIBS = [ ]) sources = [ + 'soft_screen.c', 'xlib.c', ] From 63aa8a39c4e7ee996afc87404474cce570ac3729 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 19:32:40 +0200 Subject: [PATCH 228/483] Revert "fix scons build" This reverts commit 29ec05164838f13d9535271796a50fa213d07912. --- src/gallium/targets/libgl-xlib/SConscript | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 4de463e743e..efa7e797d1f 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -40,7 +40,6 @@ env.Prepend(LIBS = [ ]) sources = [ - 'soft_screen.c', 'xlib.c', ] From f9c0cbd1ad0c5948ea577edb5c76b0c45976a285 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 19:33:09 +0200 Subject: [PATCH 229/483] Revert "drm/sw: just s/softpipe_create_screen/gallium_soft_create_screen/" This reverts commit 5d524cce9c4fcc18ed977801d59ba7bb911020db. --- src/gallium/winsys/drm/sw/sw_drm_api.c | 30 ++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index fa16600fe6a..ed3ce146eb1 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -24,9 +24,11 @@ **********************************************************/ +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "target-helpers/soft_screen.h" +#include "state_tracker/sw_winsys.h" #include "state_tracker/drm_api.h" #include "wrapper_sw_winsys.h" #include "sw_drm_api.h" @@ -41,7 +43,6 @@ struct sw_drm_api { struct drm_api base; struct drm_api *api; - struct sw_winsys *sw; }; static INLINE struct sw_drm_api * @@ -62,14 +63,35 @@ sw_drm_create_screen(struct drm_api *_api, int drmFD, { struct sw_drm_api *swapi = sw_drm_api(_api); struct drm_api *api = swapi->api; - struct sw_winsys *sww; - struct pipe_screen *screen; + struct sw_winsys *sww = NULL; + struct pipe_screen *screen = NULL; + struct pipe_screen *soft_screen = NULL; screen = api->create_screen(api, drmFD, arg); + if (screen == NULL) + goto fail; sww = wrapper_sw_winsys_warp_pipe_screen(screen); + if (sww == NULL) + goto fail; - return gallium_soft_create_screen(sww); + soft_screen = gallium_soft_create_screen(sww); + if (soft_screen == NULL) + goto fail; + + return soft_screen; + +fail: + if (soft_screen) + soft_screen->destroy(soft_screen); + + if (sww) + sww->destroy(sww); + + if (screen) + screen->destroy(screen); + + return NULL; } static void From 15c7fa460b93039a1676cc08a218101f92681190 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 19:33:17 +0200 Subject: [PATCH 230/483] Revert "gallium: add soft screen helper" This reverts commit f87a5f6499f51f651c2a9f2d4682875b22926905. --- .../auxiliary/target-helpers/soft_screen.c | 73 ------------------- .../auxiliary/target-helpers/soft_screen.h | 12 --- src/gallium/targets/libgl-xlib/Makefile | 1 - src/gallium/targets/libgl-xlib/soft_screen.c | 1 - src/gallium/targets/libgl-xlib/xlib.c | 34 ++++++++- src/gallium/winsys/drm/sw/Makefile | 3 +- src/gallium/winsys/drm/sw/soft_screen.c | 1 - src/gallium/winsys/drm/sw/sw_drm_api.c | 32 +------- 8 files changed, 37 insertions(+), 120 deletions(-) delete mode 100644 src/gallium/auxiliary/target-helpers/soft_screen.c delete mode 100644 src/gallium/auxiliary/target-helpers/soft_screen.h delete mode 120000 src/gallium/targets/libgl-xlib/soft_screen.c delete mode 120000 src/gallium/winsys/drm/sw/soft_screen.c diff --git a/src/gallium/auxiliary/target-helpers/soft_screen.c b/src/gallium/auxiliary/target-helpers/soft_screen.c deleted file mode 100644 index 00d386ee1de..00000000000 --- a/src/gallium/auxiliary/target-helpers/soft_screen.c +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -#include "target-helpers/soft_screen.h" -#include "softpipe/sp_public.h" -#include "llvmpipe/lp_public.h" -#include "cell/ppu/cell_public.h" -#include "util/u_debug.h" - -/** - * Choose and create a software renderer screen. - */ -struct pipe_screen * -gallium_soft_create_screen( struct sw_winsys *winsys ) -{ - const char *default_driver = NULL; - const char *driver = NULL; - struct pipe_screen *screen = NULL; - -#if defined(GALLIUM_CELL) - default_driver = "cell"; -#elif defined(GALLIUM_LLVMPIPE) - default_driver = "llvmpipe"; -#elif defined(GALLIUM_SOFTPIPE) - default_driver = "softpipe"; -#else - default_driver = ""; -#endif - - driver = debug_get_option("GALLIUM_DRIVER", default_driver); - -#if defined(GALLIUM_CELL) - if (screen == NULL && strcmp(driver, "cell") == 0) - screen = cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) - if (screen == NULL && strcmp(driver, "llvmpipe") == 0) - screen = llvmpipe_create_screen( winsys ); -#endif - -#if defined(GALLIUM_SOFTPIPE) - if (screen == NULL) - screen = softpipe_create_screen( winsys ); -#endif - - return screen; -} diff --git a/src/gallium/auxiliary/target-helpers/soft_screen.h b/src/gallium/auxiliary/target-helpers/soft_screen.h deleted file mode 100644 index 5c1012644aa..00000000000 --- a/src/gallium/auxiliary/target-helpers/soft_screen.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef SOFT_SCREEN_HELPER_H -#define SOFT_SCREEN_HELPER_H - -#include "pipe/p_compiler.h" - -struct pipe_screen; -struct sw_winsys; - -struct pipe_screen * -gallium_soft_create_screen( struct sw_winsys *winsys ); - -#endif diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile index 2c44a62102e..5a4e035c2eb 100644 --- a/src/gallium/targets/libgl-xlib/Makefile +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -27,7 +27,6 @@ DEFINES += \ #-DGALLIUM_CELL will be defined by the config */ XLIB_TARGET_SOURCES = \ - soft_screen.c \ xlib.c diff --git a/src/gallium/targets/libgl-xlib/soft_screen.c b/src/gallium/targets/libgl-xlib/soft_screen.c deleted file mode 120000 index d6d878f3658..00000000000 --- a/src/gallium/targets/libgl-xlib/soft_screen.c +++ /dev/null @@ -1 +0,0 @@ -../../auxiliary/target-helpers/soft_screen.c \ No newline at end of file diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index e7862212106..48e79fe4f3b 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -36,7 +36,6 @@ #include "softpipe/sp_public.h" #include "llvmpipe/lp_public.h" #include "cell/ppu/cell_public.h" -#include "target-helpers/soft_screen.h" #include "target-helpers/wrap_screen.h" #include "xm_public.h" @@ -64,6 +63,8 @@ PUBLIC const struct st_module st_module_OpenGL = { static struct pipe_screen * swrast_xlib_create_screen( Display *display ) { + const char *default_driver; + const char *driver; struct sw_winsys *winsys; struct pipe_screen *screen = NULL; @@ -74,7 +75,36 @@ swrast_xlib_create_screen( Display *display ) if (winsys == NULL) return NULL; - screen = gallium_soft_create_screen( winsys ); +#if defined(GALLIUM_CELL) + default_driver = "cell"; +#elif defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + + /* Create a software rasterizer on top of that winsys: + */ +#if defined(GALLIUM_CELL) + if (screen == NULL && + strcmp(driver, "cell") == 0) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && + strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif if (screen == NULL) goto fail; diff --git a/src/gallium/winsys/drm/sw/Makefile b/src/gallium/winsys/drm/sw/Makefile index 12b20cbd454..5f3c3ec325d 100644 --- a/src/gallium/winsys/drm/sw/Makefile +++ b/src/gallium/winsys/drm/sw/Makefile @@ -4,12 +4,11 @@ include $(TOP)/configs/current LIBNAME = swdrm C_SOURCES = \ - soft_screen.c \ wrapper_sw_winsys.c \ sw_drm_api.c LIBRARY_INCLUDES = -LIBRARY_DEFINES = -DGALLIUM_SOFTPIPE +LIBRARY_DEFINES = include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/sw/soft_screen.c b/src/gallium/winsys/drm/sw/soft_screen.c deleted file mode 120000 index 423597ba31f..00000000000 --- a/src/gallium/winsys/drm/sw/soft_screen.c +++ /dev/null @@ -1 +0,0 @@ -../../../auxiliary/target-helpers/soft_screen.c \ No newline at end of file diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index ed3ce146eb1..9c5933c73af 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -24,11 +24,8 @@ **********************************************************/ -#include "pipe/p_screen.h" #include "util/u_memory.h" -#include "target-helpers/soft_screen.h" - -#include "state_tracker/sw_winsys.h" +#include "softpipe/sp_public.h" #include "state_tracker/drm_api.h" #include "wrapper_sw_winsys.h" #include "sw_drm_api.h" @@ -63,35 +60,14 @@ sw_drm_create_screen(struct drm_api *_api, int drmFD, { struct sw_drm_api *swapi = sw_drm_api(_api); struct drm_api *api = swapi->api; - struct sw_winsys *sww = NULL; - struct pipe_screen *screen = NULL; - struct pipe_screen *soft_screen = NULL; + struct sw_winsys *sww; + struct pipe_screen *screen; screen = api->create_screen(api, drmFD, arg); - if (screen == NULL) - goto fail; sww = wrapper_sw_winsys_warp_pipe_screen(screen); - if (sww == NULL) - goto fail; - soft_screen = gallium_soft_create_screen(sww); - if (soft_screen == NULL) - goto fail; - - return soft_screen; - -fail: - if (soft_screen) - soft_screen->destroy(soft_screen); - - if (sww) - sww->destroy(sww); - - if (screen) - screen->destroy(screen); - - return NULL; + return softpipe_create_screen(sww); } static void From a0ce95576463cedb817ad3b262c82eb06eec9b9e Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 21 Mar 2010 19:36:28 +0200 Subject: [PATCH 231/483] Revert "drm/sw: does not need sw_winsys" This reverts commit 97a694e2211dc804090f282d8e096c028f29579f. --- src/gallium/winsys/drm/sw/sw_drm_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c index 9c5933c73af..0fd2163913e 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/drm/sw/sw_drm_api.c @@ -40,6 +40,7 @@ struct sw_drm_api { struct drm_api base; struct drm_api *api; + struct sw_winsys *sw; }; static INLINE struct sw_drm_api * From 44e3ec3c05f0806f0940887ed9e30d94bf0748e0 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 20:02:10 +0200 Subject: [PATCH 232/483] r200: Fix mixed indetion in r200TclFallback. --- src/mesa/drivers/dri/r200/r200_tcl.c | 39 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index f3f558b7def..41b68cc0ca0 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -687,25 +687,24 @@ static char *getFallbackString(GLuint bit) void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLuint oldfallback = rmesa->radeon.TclFallback; + r200ContextPtr rmesa = R200_CONTEXT(ctx); + GLuint oldfallback = rmesa->radeon.TclFallback; - if (mode) { - rmesa->radeon.TclFallback |= bit; - if (oldfallback == 0) { - if (R200_DEBUG & RADEON_FALLBACKS) - fprintf(stderr, "R200 begin tcl fallback %s\n", - getFallbackString( bit )); - transition_to_swtnl( ctx ); - } - } - else { - rmesa->radeon.TclFallback &= ~bit; - if (oldfallback == bit) { - if (R200_DEBUG & RADEON_FALLBACKS) - fprintf(stderr, "R200 end tcl fallback %s\n", - getFallbackString( bit )); - transition_to_hwtnl( ctx ); - } - } + if (mode) { + rmesa->radeon.TclFallback |= bit; + if (oldfallback == 0) { + if (R200_DEBUG & RADEON_FALLBACKS) + fprintf(stderr, "R200 begin tcl fallback %s\n", + getFallbackString( bit )); + transition_to_swtnl( ctx ); + } + } else { + rmesa->radeon.TclFallback &= ~bit; + if (oldfallback == bit) { + if (R200_DEBUG & RADEON_FALLBACKS) + fprintf(stderr, "R200 end tcl fallback %s\n", + getFallbackString( bit )); + transition_to_hwtnl( ctx ); + } + } } From 1968d8f31d0ac83557c9366dea39b15e92bb1516 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 20:16:17 +0200 Subject: [PATCH 233/483] r200: Fix swtnl fallback to flush pending rendering before transition. Flush after transition would emit wrong state that could cause wrong state emited for pending rendering operation. Fixes wan once from extrement tuxracer that is using per vertex materials. --- src/mesa/drivers/dri/r200/r200_tcl.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index 41b68cc0ca0..f52e4fe9177 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -691,20 +691,30 @@ void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) GLuint oldfallback = rmesa->radeon.TclFallback; if (mode) { - rmesa->radeon.TclFallback |= bit; if (oldfallback == 0) { + /* We have to flush before transition */ + if ( rmesa->radeon.dma.flush ) + rmesa->radeon.dma.flush( rmesa->radeon.glCtx ); + if (R200_DEBUG & RADEON_FALLBACKS) fprintf(stderr, "R200 begin tcl fallback %s\n", getFallbackString( bit )); + rmesa->radeon.TclFallback |= bit; transition_to_swtnl( ctx ); - } + } else + rmesa->radeon.TclFallback |= bit; } else { - rmesa->radeon.TclFallback &= ~bit; if (oldfallback == bit) { + /* We have to flush before transition */ + if ( rmesa->radeon.dma.flush ) + rmesa->radeon.dma.flush( rmesa->radeon.glCtx ); + if (R200_DEBUG & RADEON_FALLBACKS) fprintf(stderr, "R200 end tcl fallback %s\n", getFallbackString( bit )); + rmesa->radeon.TclFallback &= ~bit; transition_to_hwtnl( ctx ); - } + } else + rmesa->radeon.TclFallback &= ~bit; } } From bc5778e2023543e5049ab41398aa28fb0709f5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 21:22:21 +0100 Subject: [PATCH 234/483] r300g: remove unused code --- src/gallium/drivers/r300/r300_screen.h | 2 - src/gallium/drivers/r300/r300_screen_buffer.c | 2 +- src/gallium/drivers/r300/r300_winsys.h | 2 - .../winsys/drm/radeon/core/radeon_buffer.c | 388 ------------------ .../winsys/drm/radeon/core/radeon_buffer.h | 2 - 5 files changed, 1 insertion(+), 395 deletions(-) delete mode 100644 src/gallium/winsys/drm/radeon/core/radeon_buffer.c diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 1ccc0bfb7a5..c31f39e6917 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -30,8 +30,6 @@ #define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM -struct radeon_winsys; - struct r300_screen { /* Parent class */ struct pipe_screen screen; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index b97d0d76a4a..a1cd48ee730 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -237,7 +237,7 @@ r300_buffer_map_range(struct pipe_screen *screen, } } just_map: - map = rws->buffer_map(rws, rbuf->buf, usage | R300_USAGE_FLAG_DONT_SYNC); + map = rws->buffer_map(rws, rbuf->buf, usage); return map; } diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index e5183a8239c..1e6d43bea31 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -49,8 +49,6 @@ enum r300_value_id { R300_VID_Z_PIPES, }; -#define R300_USAGE_FLAG_DONT_SYNC (1 << 17) - struct r300_winsys_screen { void (*destroy)(struct r300_winsys_screen *ws); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c deleted file mode 100644 index 25b58b2926c..00000000000 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright © 2008 Jérôme Glisse - * 2009 Corbin Simpson - * 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, sub license, 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 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS - * AND/OR ITS SUPPLIERS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - */ -/* - * Authors: - * Jérôme Glisse - * Corbin Simpson - */ - -#include "radeon_buffer.h" -#include "radeon_drm.h" - -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "radeon_bo_gem.h" -#include - -struct radeon_vl_context -{ - Display *display; - int screen; - Drawable drawable; -}; - -static const char *radeon_get_name(struct pipe_winsys *ws) -{ - return "Radeon/GEM+KMS"; -} - -static uint32_t radeon_domain_from_usage(unsigned usage) -{ - uint32_t domain = 0; - - if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) { - domain |= RADEON_GEM_DOMAIN_VRAM; - } - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - domain |= RADEON_GEM_DOMAIN_VRAM; - } - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - if (usage & PIPE_BUFFER_USAGE_INDEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - - return domain; -} - -static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws; - struct radeon_pipe_buffer *radeon_buffer; - struct pb_desc desc; - uint32_t domain; - - radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); - if (radeon_buffer == NULL) { - return NULL; - } - - pipe_reference_init(&radeon_buffer->base.reference, 1); - radeon_buffer->base.alignment = alignment; - radeon_buffer->base.usage = usage; - radeon_buffer->base.size = size; - - if (usage & PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { - /* Don't bother allocating a BO, as it'll never get to the card. */ - desc.alignment = alignment; - desc.usage = usage; - radeon_buffer->pb = pb_malloc_buffer_create(size, &desc); - return &radeon_buffer->base; - } - - domain = radeon_domain_from_usage(usage); - - radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, - alignment, domain, 0); - if (radeon_buffer->bo == NULL) { - FREE(radeon_buffer); - return NULL; - } - return &radeon_buffer->base; -} - -static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, - void *ptr, - unsigned bytes) -{ - struct radeon_pipe_buffer *radeon_buffer; - - radeon_buffer = - (struct radeon_pipe_buffer*)radeon_buffer_create(ws, 0, 0, bytes); - if (radeon_buffer == NULL) { - return NULL; - } - radeon_bo_map(radeon_buffer->bo, 1); - memcpy(radeon_buffer->bo->ptr, ptr, bytes); - radeon_bo_unmap(radeon_buffer->bo); - return &radeon_buffer->base; -} - -static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws, - unsigned width, - unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - /* Radeons enjoy things in multiples of 32. */ - /* XXX this can be 32 when POT */ - const unsigned alignment = 64; - unsigned nblocksy, size; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - size = *stride * nblocksy; - - return radeon_buffer_create(ws, 64, usage, size); -} - -static void radeon_buffer_del(struct pipe_buffer *buffer) -{ - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - - if (radeon_buffer->pb) { - pipe_reference_init(&radeon_buffer->pb->base.reference, 0); - pb_destroy(radeon_buffer->pb); - } - - if (radeon_buffer->bo) { - radeon_bo_unref(radeon_buffer->bo); - } - - FREE(radeon_buffer); -} - -static void *radeon_buffer_map(struct pipe_winsys *ws, - struct pipe_buffer *buffer, - unsigned flags) -{ - struct radeon_winsys_priv *priv = ((struct radeon_winsys *)ws)->priv; - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - int write = 0; - - if (radeon_buffer->pb) { - return pb_map(radeon_buffer->pb, flags); - } - - if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { - uint32_t domain; - - if (radeon_bo_is_busy(radeon_buffer->bo, &domain)) - return NULL; - } - - if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) { - priv->flush_cb(priv->flush_data); - } - - if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) { - write = 1; - } - - if (radeon_bo_map(radeon_buffer->bo, write)) { - return NULL; - } - - return radeon_buffer->bo->ptr; -} - -static void radeon_buffer_unmap(struct pipe_winsys *ws, - struct pipe_buffer *buffer) -{ - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - - if (radeon_buffer->pb) { - pb_unmap(radeon_buffer->pb); - } else { - radeon_bo_unmap(radeon_buffer->bo); - } -} - -static boolean radeon_is_buffer_referenced(struct radeon_winsys *ws, - struct pipe_buffer *buffer) -{ - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - uint32_t domain; - - /* Referenced by CS or HW. */ - return radeon_bo_is_referenced_by_cs(radeon_buffer->bo, ws->priv->cs) || - radeon_bo_is_busy(radeon_buffer->bo, &domain); -} - -static void radeon_buffer_set_tiling(struct radeon_winsys *ws, - struct pipe_buffer *buffer, - uint32_t pitch, - boolean microtiled, - boolean macrotiled) -{ - struct radeon_winsys_priv *priv = ((struct radeon_winsys *)ws)->priv; - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - uint32_t flags = 0, old_flags, old_pitch; - - if (microtiled) { - flags |= RADEON_BO_FLAGS_MICRO_TILE; - } - if (macrotiled) { - flags |= RADEON_BO_FLAGS_MACRO_TILE; - } - - radeon_bo_get_tiling(radeon_buffer->bo, &old_flags, &old_pitch); - - if (flags != old_flags || pitch != old_pitch) { - /* Tiling determines how DRM treats the buffer data. - * We must flush CS when changing it if the buffer is referenced. */ - if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) { - priv->flush_cb(priv->flush_data); - } - - radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch); - } -} - -static void radeon_fence_reference(struct pipe_winsys *ws, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *pfence) -{ -} - -static int radeon_fence_signalled(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, - unsigned flag) -{ - return 1; -} - -static int radeon_fence_finish(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, - unsigned flag) -{ - return 0; -} - -/* Create a buffer from a handle. */ -static struct pipe_buffer* radeon_buffer_from_handle(struct radeon_winsys *radeon_ws, - struct pipe_screen *screen, - struct winsys_handle *whandle, - unsigned *stride) -{ - struct radeon_bo_manager* bom = radeon_ws->priv->bom; - struct radeon_pipe_buffer* radeon_buffer; - struct radeon_bo* bo = NULL; - - bo = radeon_bo_open(bom, whandle->handle, 0, 0, 0, 0); - if (bo == NULL) { - return NULL; - } - - radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); - if (radeon_buffer == NULL) { - radeon_bo_unref(bo); - return NULL; - } - - pipe_reference_init(&radeon_buffer->base.reference, 1); - radeon_buffer->base.screen = screen; - radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; - radeon_buffer->bo = bo; - - *stride = whandle->stride; - - return &radeon_buffer->base; -} - -static boolean radeon_buffer_get_handle(struct radeon_winsys *radeon_ws, - struct pipe_buffer *buffer, - unsigned stride, - struct winsys_handle *whandle) -{ - int retval, fd; - struct drm_gem_flink flink; - struct radeon_pipe_buffer* radeon_buffer; - - radeon_buffer = (struct radeon_pipe_buffer*)buffer; - - - if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { - if (!radeon_buffer->flinked) { - fd = radeon_ws->priv->fd; - - flink.handle = radeon_buffer->bo->handle; - - retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); - if (retval) { - debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", - retval); - return FALSE; - } - - radeon_buffer->flink = flink.name; - radeon_buffer->flinked = TRUE; - } - - whandle->handle = radeon_buffer->flink; - } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { - whandle->handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle; - } - whandle->stride = stride; - - return TRUE; -} - -struct radeon_winsys* radeon_pipe_winsys(int fd) -{ - struct radeon_winsys* radeon_ws; - - radeon_ws = CALLOC_STRUCT(radeon_winsys); - if (radeon_ws == NULL) { - return NULL; - } - - radeon_ws->priv = CALLOC_STRUCT(radeon_winsys_priv); - if (radeon_ws->priv == NULL) { - FREE(radeon_ws); - return NULL; - } - - radeon_ws->priv->fd = fd; - radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd); - - radeon_ws->base.flush_frontbuffer = NULL; /* overriden by co-state tracker */ - - radeon_ws->base.buffer_create = radeon_buffer_create; - radeon_ws->base.user_buffer_create = radeon_buffer_user_create; - radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create; - radeon_ws->base.buffer_map = radeon_buffer_map; - radeon_ws->base.buffer_unmap = radeon_buffer_unmap; - radeon_ws->base.buffer_destroy = radeon_buffer_del; - - radeon_ws->base.fence_reference = radeon_fence_reference; - radeon_ws->base.fence_signalled = radeon_fence_signalled; - radeon_ws->base.fence_finish = radeon_fence_finish; - - radeon_ws->base.get_name = radeon_get_name; - - radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling; - radeon_ws->buffer_from_handle = radeon_buffer_from_handle; - radeon_ws->buffer_get_handle = radeon_buffer_get_handle; - - radeon_ws->is_buffer_referenced = radeon_is_buffer_referenced; - - return radeon_ws; -} diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index e1fcfcfccaa..3d14c861dfa 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -69,8 +69,6 @@ void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf, uint32_t rd, uint32_t wd, uint32_t flags); -struct radeon_libdrm_winsys* radeon_pipe_winsys(int fd); - struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr, uint32_t handle); From d0d3abd360a0d98302841e62ab9acdebea2ca8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 21:34:18 +0100 Subject: [PATCH 235/483] r300g: put common defines into one file --- src/gallium/drivers/r300/r300_context.h | 16 +-------- src/gallium/drivers/r300/r300_defines.h | 47 +++++++++++++++++++++++++ src/gallium/drivers/r300/r300_render.c | 7 ++-- src/gallium/drivers/r300/r300_screen.h | 2 -- src/gallium/drivers/r300/r300_winsys.h | 2 ++ 5 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 src/gallium/drivers/r300/r300_defines.h diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index edebeab86fd..4bb385238ed 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -30,6 +30,7 @@ #include "pipe/p_context.h" #include "util/u_inlines.h" +#include "r300_defines.h" #include "r300_screen.h" struct u_upload_mgr; @@ -135,8 +136,6 @@ struct r300_texture_format_state { uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */ }; -#define R300_MAX_TEXTURE_LEVELS 13 - struct r300_texture_fb_state { /* Colorbuffer. */ uint32_t colorpitch[R300_MAX_TEXTURE_LEVELS]; /* R300_RB3D_COLORPITCH[0-3]*/ @@ -195,12 +194,6 @@ struct r300_ztop_state { uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */ }; -#define R300_NEW_FRAGMENT_SHADER 0x00000020 -#define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040 -#define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 -#define R300_NEW_QUERY 0x40000000 -#define R300_NEW_KITCHEN_SINK 0x7fffffff - /* The next several objects are not pure Radeon state; they inherit from * various Gallium classes. */ @@ -238,12 +231,6 @@ struct r300_query { struct r300_query* next; }; -enum r300_buffer_tiling { - R300_BUFFER_LINEAR = 0, - R300_BUFFER_TILED, - R300_BUFFER_SQUARETILED -}; - struct r300_texture { /* Parent class */ struct pipe_texture tex; @@ -444,4 +431,3 @@ static INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags, #define DBG CTX_DBG #endif /* R300_CONTEXT_H */ - diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h new file mode 100644 index 00000000000..2e04876de92 --- /dev/null +++ b/src/gallium/drivers/r300/r300_defines.h @@ -0,0 +1,47 @@ +/* + * Copyright 2010 Marek Olšák + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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. */ + +#ifndef R300_DEFINES_H +#define R300_DEFINES_H + +#include "pipe/p_defines.h" + +#define R300_MAX_TEXTURE_LEVELS 13 +#define R300_MAX_DRAW_VBO_SIZE (1024 * 1024) + +#define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM + +/* Non-atom dirty state flags. */ +#define R300_NEW_FRAGMENT_SHADER 0x00000020 +#define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040 +#define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 +#define R300_NEW_QUERY 0x40000000 +#define R300_NEW_KITCHEN_SINK 0x7fffffff + +/* Tiling flags. */ +enum r300_buffer_tiling { + R300_BUFFER_LINEAR = 0, + R300_BUFFER_TILED, + R300_BUFFER_SQUARETILED +}; + +#endif diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 2fed263a7a9..93bf388776c 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -41,9 +41,6 @@ #include "r300_render.h" #include "r300_state_derived.h" -/* r300_render: Vertex and index buffer primitive emission. */ -#define R300_MAX_VBO_SIZE (1024 * 1024) - /* XXX The DRM rejects VAP_ALT_NUM_VERTICES.. */ //#define ENABLE_ALT_NUM_VERTS @@ -689,9 +686,9 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render, r300render->vbo = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, - R300_MAX_VBO_SIZE); + R300_MAX_DRAW_VBO_SIZE); r300render->vbo_offset = 0; - r300render->vbo_size = R300_MAX_VBO_SIZE; + r300render->vbo_size = R300_MAX_DRAW_VBO_SIZE; } r300render->vertex_size = vertex_size; diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index c31f39e6917..a055159c93b 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -28,8 +28,6 @@ #include "r300_chipset.h" -#define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM - struct r300_screen { /* Parent class */ struct pipe_screen screen; diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 1e6d43bea31..cd03355ab3e 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -30,6 +30,8 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "r300_defines.h" + struct r300_winsys_screen; /* Creates a new r300 screen. */ From 33d2349119ada410dbfbaa667fc7aef8b60d1a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 21:34:57 +0100 Subject: [PATCH 236/483] r300g: cleanup tiling flags propagation --- src/gallium/drivers/r300/r300_state.c | 16 ++++++++-------- src/gallium/drivers/r300/r300_texture.c | 4 ++-- src/gallium/drivers/r300/r300_winsys.h | 4 ++-- .../winsys/drm/radeon/core/radeon_buffer.h | 5 ++++- .../winsys/drm/radeon/core/radeon_drm_buffer.c | 9 ++++++--- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 4 ++-- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index f396b42e950..397369015a5 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -528,8 +528,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300, if (tex) { r300->rws->buffer_set_tiling(r300->rws, tex->buffer, tex->pitch[0], - tex->microtile != 0, - tex->macrotile != 0); + tex->microtile, + tex->macrotile); } } if (old_state->zsbuf && @@ -540,8 +540,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300, if (tex) { r300->rws->buffer_set_tiling(r300->rws, tex->buffer, tex->pitch[0], - tex->microtile != 0, - tex->macrotile != 0); + tex->microtile, + tex->macrotile); } } @@ -552,8 +552,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300, r300->rws->buffer_set_tiling(r300->rws, tex->buffer, tex->pitch[level], - tex->microtile != 0, - tex->mip_macrotile[level] != 0); + tex->microtile, + tex->mip_macrotile[level]); } if (new_state->zsbuf) { tex = (struct r300_texture*)new_state->zsbuf->texture; @@ -561,8 +561,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300, r300->rws->buffer_set_tiling(r300->rws, tex->buffer, tex->pitch[level], - tex->microtile != 0, - tex->mip_macrotile[level] != 0); + tex->microtile, + tex->mip_macrotile[level]); } } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index cb53619fe5e..2fa656067fa 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -777,8 +777,8 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen, tex->size); rws->buffer_set_tiling(rws, tex->buffer, tex->pitch[0], - tex->microtile != R300_BUFFER_LINEAR, - tex->macrotile != R300_BUFFER_LINEAR); + tex->microtile, + tex->macrotile); if (!tex->buffer) { FREE(tex); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index cd03355ab3e..93f9dd7cfac 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -148,8 +148,8 @@ struct r300_winsys_screen { void (*buffer_set_tiling)(struct r300_winsys_screen *winsys, struct r300_winsys_buffer *buffer, uint32_t pitch, - boolean microtiled, - boolean macrotiled); + enum r300_buffer_tiling microtiled, + enum r300_buffer_tiling macrotiled); uint32_t (*get_value)(struct r300_winsys_screen *winsys, enum r300_value_id vid); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index 3d14c861dfa..218a3763018 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -72,7 +72,10 @@ void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf, struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr, uint32_t handle); -void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch); +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, + enum r300_buffer_tiling microtiled, + enum r300_buffer_tiling macrotiled, + uint32_t pitch); void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index a8a7c45a96f..0a86acc2284 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -306,13 +306,16 @@ boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, } -void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch) +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, + enum r300_buffer_tiling microtiled, + enum r300_buffer_tiling macrotiled, + uint32_t pitch) { struct radeon_drm_buffer *buf = get_drm_buffer(_buf); uint32_t flags = 0, old_flags, old_pitch; - if (microtiled) + if (microtiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MICRO_TILE; - if (macrotiled) + if (macrotiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MACRO_TILE; radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 62d66d31dc1..0c0fee1586c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -65,8 +65,8 @@ static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf) static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws, struct r300_winsys_buffer *buf, uint32_t pitch, - boolean microtiled, - boolean macrotiled) + enum r300_buffer_tiling microtiled, + enum r300_buffer_tiling macrotiled) { struct pb_buffer *_buf = radeon_pb_buffer(buf); radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch); From 12dc4971735a8703c298d35eb21e3d1a2e053217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 14 Feb 2010 17:43:32 +0100 Subject: [PATCH 237/483] r300g: add and enable square microtiling It requires DRM 2.1.0 (e.g. kernel 2.6.34) and is disabled on older ones. Finally, the texture tiling implementation is now complete. Uff. --- src/gallium/drivers/r300/r300_texture.c | 11 ++++++----- src/gallium/drivers/r300/r300_winsys.h | 1 + src/gallium/winsys/drm/radeon/core/radeon_drm.c | 4 ++++ .../winsys/drm/radeon/core/radeon_drm_buffer.c | 6 ++++-- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 2 ++ src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 3 +++ 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 2fa656067fa..fe2ba60b9c9 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -715,6 +715,7 @@ static void r300_setup_flags(struct r300_texture* tex) static void r300_setup_tiling(struct pipe_screen *screen, struct r300_texture *tex) { + struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys; enum pipe_format format = tex->tex.format; boolean rv350_mode = r300_screen(screen)->caps->family >= CHIP_FAMILY_RV350; @@ -734,12 +735,12 @@ static void r300_setup_tiling(struct pipe_screen *screen, tex->microtile = R300_BUFFER_TILED; break; - /* XXX Square-tiling doesn't work with kernel older than 2.6.34, - * XXX need to check the DRM version */ - /*case 2: + case 2: case 8: - tex->microtile = R300_BUFFER_SQUARETILED; - break;*/ + if (rws->get_value(rws, R300_VID_SQUARE_TILING_SUPPORT)) { + tex->microtile = R300_BUFFER_SQUARETILED; + } + break; } /* Set macrotiling. */ diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 93f9dd7cfac..acfa5dbeb9c 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -49,6 +49,7 @@ enum r300_value_id { R300_VID_PCI_ID, R300_VID_GB_PIPES, R300_VID_Z_PIPES, + R300_VID_SQUARE_TILING_SUPPORT }; struct r300_winsys_screen { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index d70173e805d..7aa9c5425d6 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -93,6 +93,10 @@ static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys) exit(1); } + // Supported since 2.1.0. + winsys->squaretiling = version->version_major > 2 || + version->version_minor >= 1; + info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 0a86acc2284..e36bad7ea8c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -314,9 +314,11 @@ void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, struct radeon_drm_buffer *buf = get_drm_buffer(_buf); uint32_t flags = 0, old_flags, old_pitch; if (microtiled == R300_BUFFER_TILED) - flags |= RADEON_BO_FLAGS_MICRO_TILE; + flags |= RADEON_BO_FLAGS_MICRO_TILE; + else if (microtiled == R300_BUFFER_SQUARETILED) + flags |= RADEON_BO_FLAGS_MICRO_TILE_SQUARE; if (macrotiled == R300_BUFFER_TILED) - flags |= RADEON_BO_FLAGS_MACRO_TILE; + flags |= RADEON_BO_FLAGS_MACRO_TILE; radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 0c0fee1586c..38fcf889c8b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -253,6 +253,8 @@ static uint32_t radeon_get_value(struct r300_winsys_screen *rws, return ws->gb_pipes; case R300_VID_Z_PIPES: return ws->z_pipes; + case R300_VID_SQUARE_TILING_SUPPORT: + return ws->squaretiling; } return 0; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index ad7b976abd2..4260dbaad72 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -57,6 +57,9 @@ struct radeon_libdrm_winsys { /* VRAM size. */ uint32_t vram_size; + /* Square tiling support. */ + boolean squaretiling; + /* DRM FD */ int fd; From 7733bac66c071a64cf12930b16b808b3450f853b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 21:47:41 +0100 Subject: [PATCH 238/483] r300g: accelerate blitting for all 64-bit texture formats --- src/gallium/drivers/r300/r300_blit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index f99f9dffaa5..bcdf950df9c 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -149,6 +149,9 @@ void r300_surface_copy(struct pipe_context* pipe, case 4: new_format = PIPE_FORMAT_B8G8R8A8_UNORM; break; + case 8: + new_format = PIPE_FORMAT_R16G16B16A16_UNORM; + break; default: debug_printf("r300: surface_copy: Unhandled format: %s. Falling back to software.\n" "r300: surface_copy: Software fallback doesn't work for tiled textures.\n", From 8bf9842fac00369b5cd3a82fb4d87db0e31848b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 22:05:27 +0100 Subject: [PATCH 239/483] r300g: fix scons build --- src/gallium/drivers/r300/r300_context.c | 4 ++-- src/gallium/drivers/r300/r300_cs.h | 3 +-- src/gallium/drivers/r300/r300_screen.c | 4 +--- src/gallium/drivers/r300/r300_state.c | 3 +-- src/gallium/drivers/r300/r300_texture.c | 3 +-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 60b441176d9..2bec946fe89 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -33,11 +33,11 @@ #include "r300_query.h" #include "r300_render.h" #include "r300_screen.h" +#include "r300_screen_buffer.h" #include "r300_state_invariant.h" #include "r300_texture.h" #include "r300_transfer.h" - -#include "radeon_winsys.h" +#include "r300_winsys.h" static void r300_destroy_context(struct pipe_context* context) { diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index ad07efbffdb..456b2ec7b92 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -26,8 +26,7 @@ #include "util/u_math.h" #include "r300_reg.h" - -#include "radeon_winsys.h" +#include "r300_winsys.h" /* Yes, I know macros are ugly. However, they are much prettier than the code * that they neatly hide away, and don't have the cost of function setup,so diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 3e31688f8e8..bcb8b20f736 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -26,10 +26,8 @@ #include "r300_context.h" #include "r300_texture.h" - -#include "radeon_winsys.h" - #include "r300_screen_buffer.h" +#include "r300_winsys.h" /* Return the identifier behind whom the brave coders responsible for this * amalgamation of code, sweat, and duct tape, routinely obscure their names. diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 397369015a5..31e32114b60 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -38,8 +38,7 @@ #include "r300_state_inlines.h" #include "r300_fs.h" #include "r300_vs.h" - -#include "radeon_winsys.h" +#include "r300_winsys.h" /* r300_state: Functions used to intialize state context by translating * Gallium state objects into semi-native r300 state objects. */ diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index fe2ba60b9c9..eaefd9d7d4e 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -31,8 +31,7 @@ #include "r300_texture.h" #include "r300_screen.h" #include "r300_state_inlines.h" - -#include "radeon_winsys.h" +#include "r300_winsys.h" #define TILE_WIDTH 0 #define TILE_HEIGHT 1 From 9fc6c8b831e5b43ae86ece6a531fc892f6f66356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2010 22:17:14 +0100 Subject: [PATCH 240/483] r300g: disable tiling for YUV formats --- src/gallium/drivers/r300/r300_texture.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index eaefd9d7d4e..1b796257e4f 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -45,6 +45,18 @@ static const unsigned microblock_table[5][3][2] = { {{ 2, 1}, {0, 0}, {0, 0}} /* 128 bits per pixel */ }; +/* Return true for non-compressed and non-YUV formats. */ +static boolean r300_format_is_plain(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + + if (!format) { + return FALSE; + } + + return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN; +} + /* Translate a pipe_format into a useful texture format for sampling. * * Some special formats are translated directly using R300_EASY_TX_FORMAT, @@ -639,7 +651,7 @@ unsigned r300_texture_get_stride(struct r300_screen* screen, width = u_minify(tex->tex.width0, level); - if (!util_format_is_compressed(tex->tex.format)) { + if (r300_format_is_plain(tex->tex.format)) { tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH, tex->mip_macrotile[level]); width = align(width, tile_width); @@ -657,7 +669,7 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, height = u_minify(tex->tex.height0, level); - if (!util_format_is_compressed(tex->tex.format)) { + if (r300_format_is_plain(tex->tex.format)) { tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT, tex->mip_macrotile[level]); height = align(height, tile_height); @@ -718,7 +730,7 @@ static void r300_setup_tiling(struct pipe_screen *screen, enum pipe_format format = tex->tex.format; boolean rv350_mode = r300_screen(screen)->caps->family >= CHIP_FAMILY_RV350; - if (util_format_is_compressed(format)) { + if (!r300_format_is_plain(format)) { return; } From 0900544fb54cbc2127b8729393c9c1308cd218f9 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 22:55:13 +0200 Subject: [PATCH 241/483] r200: Don't flush when closing elts in KMS. Flush in middle of rendering in KMS is not allowed because buffers are discarded in flush. Fixes crash when emiting split indices with RADEON_DEBUG=all. --- src/mesa/drivers/dri/r200/r200_cmdbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r200/r200_cmdbuf.c b/src/mesa/drivers/dri/r200/r200_cmdbuf.c index 2f2b8d94dca..382ae0daa4f 100644 --- a/src/mesa/drivers/dri/r200/r200_cmdbuf.c +++ b/src/mesa/drivers/dri/r200/r200_cmdbuf.c @@ -189,7 +189,8 @@ void r200FlushElts(GLcontext *ctx) if (R200_ELT_BUF_SZ > elt_used) radeonReturnDmaRegion(&rmesa->radeon, R200_ELT_BUF_SZ - elt_used); - if (radeon_is_debug_enabled(RADEON_SYNC, RADEON_CRITICAL)) { + if (radeon_is_debug_enabled(RADEON_SYNC, RADEON_CRITICAL) + && !rmesa->radeon.radeonScreen->kernel_mm) { radeon_print(RADEON_SYNC, RADEON_NORMAL, "%s: Syncing\n", __FUNCTION__); radeonFinish( rmesa->radeon.glCtx ); } From 4ea694a26b99835d0b5bc814cf024850874a9a83 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 21 Mar 2010 23:23:21 +0200 Subject: [PATCH 242/483] r200: Fix emit size prediction to account elt splitting. Emit sizes prediction didn't account for render splitting in hwtnl path. --- src/mesa/drivers/dri/r200/r200_cmdbuf.c | 2 +- src/mesa/drivers/dri/r200/r200_tcl.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_cmdbuf.c b/src/mesa/drivers/dri/r200/r200_cmdbuf.c index 382ae0daa4f..ad43a8ca920 100644 --- a/src/mesa/drivers/dri/r200/r200_cmdbuf.c +++ b/src/mesa/drivers/dri/r200/r200_cmdbuf.c @@ -190,7 +190,7 @@ void r200FlushElts(GLcontext *ctx) radeonReturnDmaRegion(&rmesa->radeon, R200_ELT_BUF_SZ - elt_used); if (radeon_is_debug_enabled(RADEON_SYNC, RADEON_CRITICAL) - && !rmesa->radeon.radeonScreen->kernel_mm) { + && !rmesa->radeon.radeonScreen->kernel_mm) { radeon_print(RADEON_SYNC, RADEON_NORMAL, "%s: Syncing\n", __FUNCTION__); radeonFinish( rmesa->radeon.glCtx ); } diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index f52e4fe9177..d43e14581e9 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -404,8 +404,9 @@ static GLuint r200EnsureEmitSize( GLcontext * ctx , GLubyte* vimap_rev ) rendering code may decide convert to elts. In that case we have to make pessimistic prediction. and use larger of 2 paths. */ - const GLuint elts = ELTS_BUFSZ(nr_aos); - const GLuint index = INDEX_BUFSZ; + const GLuint elt_count =(VB->Primitive[i].count/GET_MAX_HW_ELTS() + 1); + const GLuint elts = ELTS_BUFSZ(nr_aos) * elt_count; + const GLuint index = INDEX_BUFSZ * elt_count; const GLuint vbuf = VBUF_BUFSZ; if ( (!VB->Elts && VB->Primitive[i].count >= MAX_CONVERSION_SIZE) || vbuf > index + elts) From 1e7d65bb5b50efbd5812e7996910b7688eb27192 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 21 Mar 2010 19:09:54 -0700 Subject: [PATCH 243/483] progs/tests: Include stddef.h for ptrdiff_t on all platforms. stddef.h is the standard C header that defines ptrdiff_t. Fixes build of cva_huge on Mac OS X. --- progs/tests/cva_huge.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/progs/tests/cva_huge.c b/progs/tests/cva_huge.c index da63596d486..88ec2af2a84 100644 --- a/progs/tests/cva_huge.c +++ b/progs/tests/cva_huge.c @@ -32,11 +32,7 @@ #include #include #include -#ifdef __VMS -# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ -#else -# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ -#endif +#include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ #ifdef _WIN32 #include #endif From fce72d58036eb8a993bda1a7c5d74b8fcc819a8c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 21 Mar 2010 19:21:11 -0700 Subject: [PATCH 244/483] progs/tests: Add cva_huge to SCons build. --- progs/tests/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/progs/tests/SConscript b/progs/tests/SConscript index 3580ba914db..b1c7c99a7b6 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -45,6 +45,7 @@ progs = [ 'copypixrate', 'crossbar', 'cva', + 'cva_huge', 'cylwrap', 'drawbuffers', 'drawbuffers2', From 904d129322337be4a2571b77255b14d42252fafc Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 22 Mar 2010 13:30:54 +0800 Subject: [PATCH 245/483] docs: Update the path to build libgl-xlib. --- docs/egl.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/egl.html b/docs/egl.html index 55907f6cfac..e960309fc47 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -106,11 +106,11 @@ noted that the classic libGL is not a state tracker and cannot be used with EGL (unless the EGL driver in use is egl_glx). To build the OpenGL state tracker, one may append glx to --with-state-trackers and manually build -src/gallium/winsys/xlib/.

+src/gallium/targets/libgl-xlib/.

Use EGL

-

The demos for OpenGL ES and OpenVG can be found in progs/es1/, +

The demos for OpenGL ES and OpenVG can be found in progs/es1/, progs/es2/ and progs/openvg/. You can use them to test your build. For example,

From 361e8e911886784407c7aff91e09b9b2bfd5cde8 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 22 Mar 2010 15:14:16 +0200 Subject: [PATCH 246/483] mesa: Add end of line to the end of a debug output. --- src/mesa/main/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 5c863f6f32a..4b8c00b5b63 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -322,7 +322,7 @@ _mesa_LoadIdentity( void ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLoadIdentity()"); + _mesa_debug(ctx, "glLoadIdentity()\n"); _math_matrix_set_identity( ctx->CurrentStack->Top ); ctx->NewState |= ctx->CurrentStack->DirtyFlag; From 5cb4a3524b54480418b4c4717c4a0f0a8669939c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 08:23:14 -0600 Subject: [PATCH 247/483] mesa: remove return, do as the comment says --- src/mesa/main/bufferobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index dbaba2975e3..1854b980beb 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1475,7 +1475,6 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) return; default: ; /* fall-through */ - return; } invalid_pname: From ca97f8b9bab80844be613a9253643b7da8e738c7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 09:00:13 -0600 Subject: [PATCH 248/483] glslcompiler: fix build breakage --- src/mesa/drivers/glslcompiler/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index 080fe475c16..d3404988d52 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -10,9 +10,10 @@ PROGRAM = glslcompiler OBJECTS = \ glslcompiler.o \ ../../glapi/glapi.o \ + ../../glapi/glapi_getproc.o \ + ../../glapi/glapi_dispatch.o \ ../../glapi/glapi_nop.o \ ../../glapi/glthread.o \ - ../../main/dispatch.o \ ../common/driverfuncs.o \ ../../libmesa.a From 98b4e7aee83c7874db0ea23f632851b6fb5ba62a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 09:08:09 -0600 Subject: [PATCH 249/483] glslcompiler: fix build breakage --- src/mesa/drivers/glslcompiler/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index d3404988d52..1b9a056baae 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -10,6 +10,7 @@ PROGRAM = glslcompiler OBJECTS = \ glslcompiler.o \ ../../glapi/glapi.o \ + ../../glapi/glapi_entrypoint.o \ ../../glapi/glapi_getproc.o \ ../../glapi/glapi_dispatch.o \ ../../glapi/glapi_nop.o \ From 4e3b950c70721b826c712636d37197dd5a76b910 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Mon, 22 Mar 2010 18:36:16 +0100 Subject: [PATCH 250/483] nvfx: fix sampler views support The code was half converted, resulting in texturing being totally broken. --- src/gallium/drivers/nvfx/nv30_fragtex.c | 2 +- src/gallium/drivers/nvfx/nv40_fragtex.c | 2 +- src/gallium/drivers/nvfx/nvfx_context.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c b/src/gallium/drivers/nvfx/nv30_fragtex.c index 2b56f454921..54e47574c4d 100644 --- a/src/gallium/drivers/nvfx/nv30_fragtex.c +++ b/src/gallium/drivers/nvfx/nv30_fragtex.c @@ -91,7 +91,7 @@ struct nouveau_stateobj * nv30_fragtex_build(struct nvfx_context *nvfx, int unit) { struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit]; - struct nvfx_miptree *nv30mt = nvfx->tex_miptree[unit]; + struct nvfx_miptree *nv30mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture; struct pipe_texture *pt = &nv30mt->base; struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer); struct nv30_texture_format *tf; diff --git a/src/gallium/drivers/nvfx/nv40_fragtex.c b/src/gallium/drivers/nvfx/nv40_fragtex.c index 5889b5e40d5..05506e28099 100644 --- a/src/gallium/drivers/nvfx/nv40_fragtex.c +++ b/src/gallium/drivers/nvfx/nv40_fragtex.c @@ -109,7 +109,7 @@ struct nouveau_stateobj * nv40_fragtex_build(struct nvfx_context *nvfx, int unit) { struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit]; - struct nvfx_miptree *nv40mt = nvfx->tex_miptree[unit]; + struct nvfx_miptree *nv40mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture; struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer); struct pipe_texture *pt = &nv40mt->base; struct nv40_texture_format *tf; diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h index 001b19eedf0..ab7225cf6c3 100644 --- a/src/gallium/drivers/nvfx/nvfx_context.h +++ b/src/gallium/drivers/nvfx/nvfx_context.h @@ -158,7 +158,6 @@ struct nvfx_context { struct pipe_buffer *idxbuf; unsigned idxbuf_format; struct nvfx_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS]; - struct nvfx_miptree *tex_miptree[PIPE_MAX_SAMPLERS]; struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; unsigned nr_samplers; unsigned nr_textures; From c695e80017373caf6e8d7139b8d3df2d945ccce5 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 14:15:52 +0100 Subject: [PATCH 251/483] dri/nouveau: Emit dirty states on nouveau_validate_framebuffer. Fixes broken intermediate frames when a window is being resized (regression caused by 878eef8c4). --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index be57d48b8dd..deb7b5b1d0d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -337,6 +337,8 @@ nouveau_validate_framebuffer(GLcontext *ctx) update_framebuffer(dri_ctx, dri_read, &dri_ctx->dri2.read_stamp); - if (nouveau_next_dirty_state(ctx) >= 0) + if (nouveau_next_dirty_state(ctx) >= 0) { + nouveau_state_emit(ctx); FIRE_RING(context_chan(ctx)); + } } From fc7890dc6c1f70a4f1c4bffb0fca7ae0cde30a2e Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 14:23:40 +0100 Subject: [PATCH 252/483] dri/nouveau: Plug in some mesa_meta functions instead of the swrast variants. --- src/mesa/drivers/dri/nouveau/nouveau_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index 1d12f43741f..19daef156dc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -135,4 +135,7 @@ nouveau_driver_functions_init(struct dd_function_table *functions) functions->Flush = nouveau_flush; functions->Finish = nouveau_finish; functions->Clear = nouveau_clear; + functions->DrawPixels = _mesa_meta_DrawPixels; + functions->CopyPixels = _mesa_meta_CopyPixels; + functions->Bitmap = _mesa_meta_Bitmap; } From fe7d0e6dc81c493b9ff7163c640d75db25386675 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 18:21:13 +0100 Subject: [PATCH 253/483] dri/nouveau: Expose EXT_framebuffer_blit. --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_driver.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index deb7b5b1d0d..42bec659d73 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -54,6 +54,7 @@ static const struct dri_extension nouveau_extensions[] = { { "GL_ARB_texture_env_dot3", NULL }, { "GL_ARB_texture_mirrored_repeat", NULL }, { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, + { "GL_EXT_framebuffer_blit", NULL }, { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, { "GL_EXT_stencil_wrap", NULL }, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index 19daef156dc..4ec864c181c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -138,4 +138,5 @@ nouveau_driver_functions_init(struct dd_function_table *functions) functions->DrawPixels = _mesa_meta_DrawPixels; functions->CopyPixels = _mesa_meta_CopyPixels; functions->Bitmap = _mesa_meta_Bitmap; + functions->BlitFramebuffer = _mesa_meta_BlitFramebuffer; } From 199fab25b7cb047c0d7ac26ee12df3b2e1369723 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 18:25:30 +0100 Subject: [PATCH 254/483] dri/nouveau: Fix swrast fallbacks when the read and draw buffers aren't the same. --- src/mesa/drivers/dri/nouveau/nouveau_span.c | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index f1a56dd03af..1bfdecc6a21 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -32,7 +32,6 @@ #include "swrast/swrast.h" #define LOCAL_VARS \ - struct gl_framebuffer *fb = ctx->DrawBuffer; \ struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface; \ GLuint p; \ (void)p; @@ -45,12 +44,12 @@ #define HW_CLIPLOOP() { \ int minx = 0; \ int miny = 0; \ - int maxx = fb->Width; \ - int maxy = fb->Height; + int maxx = rb->Width; \ + int maxy = rb->Height; #define HW_ENDCLIPLOOP() } -#define Y_FLIP(y) (fb->Name ? (y) : rb->Height - 1 - (y)) +#define Y_FLIP(y) (rb->Name ? (y) : rb->Height - 1 - (y)) /* RGB565 span functions */ #define SPANTMP_PIXEL_FMT GL_RGB @@ -143,18 +142,29 @@ texture_unit_map_unmap(GLcontext *ctx, struct gl_texture_unit *u, GLboolean map) ctx->Driver.UnmapTexture(ctx, u->_Current); } +static void +framebuffer_map_unmap(struct gl_framebuffer *fb, GLboolean map) +{ + int i; + + for (i = 0; i < fb->_NumColorDrawBuffers; i++) + renderbuffer_map_unmap(fb->_ColorDrawBuffers[i], map); + + renderbuffer_map_unmap(fb->_ColorReadBuffer, map); + + if (fb->_DepthBuffer) + renderbuffer_map_unmap(fb->_DepthBuffer->Wrapped, map); +} + static void span_map_unmap(GLcontext *ctx, GLboolean map) { int i; - for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) - renderbuffer_map_unmap(ctx->DrawBuffer->_ColorDrawBuffers[i], map); + framebuffer_map_unmap(ctx->DrawBuffer, map); - renderbuffer_map_unmap(ctx->DrawBuffer->_ColorReadBuffer, map); - - if (ctx->DrawBuffer->_DepthBuffer) - renderbuffer_map_unmap(ctx->DrawBuffer->_DepthBuffer->Wrapped, map); + if (ctx->ReadBuffer != ctx->DrawBuffer) + framebuffer_map_unmap(ctx->ReadBuffer, map); for (i = 0; i < ctx->Const.MaxTextureUnits; i++) texture_unit_map_unmap(ctx, &ctx->Texture.Unit[i], map); From bfdea90f251c1bc3cf4f8096f8c62a37b9ac78c1 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 18:28:51 +0100 Subject: [PATCH 255/483] dri/nouveau: Some render to texture fixes. --- src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c index 2ec3dc92420..8be7edb150b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c @@ -236,7 +236,7 @@ nouveau_render_texture(GLcontext *ctx, struct gl_framebuffer *fb, /* Allocate a renderbuffer object for the texture if we * haven't already done so. */ if (!rb) { - rb = nouveau_renderbuffer_new(ctx, 0); + rb = nouveau_renderbuffer_new(ctx, ~0); assert(rb); rb->AllocStorage = NULL; @@ -259,11 +259,7 @@ static void nouveau_finish_render_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att) { - struct nouveau_renderbuffer *nrb - = to_nouveau_renderbuffer(att->Renderbuffer); - texture_dirty(att->Texture); - nouveau_surface_ref(NULL, &nrb->surface); } void From fc14fb9d1a897dbcf750b8158d6cb08388a422c4 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Mon, 22 Mar 2010 18:10:25 +0100 Subject: [PATCH 256/483] dri/nouveau: Rectangle texture fixes. --- src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 + .../drivers/dri/nouveau/nouveau_texture.c | 73 ++++++++++++------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 7697090f6a6..a57df2d9dcd 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -232,6 +232,7 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_TEXTURE_1D: case GL_TEXTURE_2D: case GL_TEXTURE_3D: + case GL_TEXTURE_RECTANGLE: context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit); context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit); break; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index e89018653b1..dbf9a5cc613 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -283,7 +283,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t) struct nouveau_texture *nt = to_nouveau_texture(t); int i, last = get_last_level(t); - if (!nt->surfaces[last].bo) + if (!teximage_fits(t, t->BaseLevel) || + !teximage_fits(t, last)) return GL_FALSE; if (nt->dirty) { @@ -420,6 +421,40 @@ nouveau_teximage_3d(GLcontext *ctx, GLenum target, GLint level, packing, t, ti); } +static void +nouveau_texsubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *t, + struct gl_texture_image *ti) +{ + struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface; + int ret; + + pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, + format, type, pixels, packing, + "glTexSubImage"); + if (pixels) { + nouveau_teximage_map(ctx, ti); + + ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat, + ti->Data, xoffset, yoffset, zoffset, + s->pitch, ti->ImageOffsets, + width, height, depth, format, type, + pixels, packing); + assert(ret); + + nouveau_teximage_unmap(ctx, ti); + _mesa_unmap_teximage_pbo(ctx, packing); + } + + if (!to_nouveau_texture(t)->dirty) + validate_teximage(ctx, t, level, xoffset, yoffset, zoffset, + width, height, depth); +} + static void nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, @@ -429,15 +464,9 @@ nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *t, struct gl_texture_image *ti) { - nouveau_teximage_map(ctx, ti); - _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, pixels, - packing, t, ti); - nouveau_teximage_unmap(ctx, ti); - - if (!to_nouveau_texture(t)->dirty) - validate_teximage(ctx, t, level, xoffset, yoffset, zoffset, - width, height, depth); + nouveau_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels, + packing, t, ti); } static void @@ -449,15 +478,9 @@ nouveau_texsubimage_2d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *t, struct gl_texture_image *ti) { - nouveau_teximage_map(ctx, ti); - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, - width, height, format, type, pixels, - packing, t, ti); - nouveau_teximage_unmap(ctx, ti); - - if (!to_nouveau_texture(t)->dirty) - validate_teximage(ctx, t, level, xoffset, yoffset, 0, - width, height, 1); + nouveau_texsubimage(ctx, 2, target, level, xoffset, yoffset, 0, + width, height, 1, format, type, pixels, + packing, t, ti); } static void @@ -468,15 +491,9 @@ nouveau_texsubimage_1d(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *t, struct gl_texture_image *ti) { - nouveau_teximage_map(ctx, ti); - _mesa_store_texsubimage1d(ctx, target, level, xoffset, - width, format, type, pixels, - packing, t, ti); - nouveau_teximage_unmap(ctx, ti); - - if (!to_nouveau_texture(t)->dirty) - validate_teximage(ctx, t, level, xoffset, 0, 0, - width, 1, 1); + nouveau_texsubimage(ctx, 1, target, level, xoffset, 0, 0, + width, 1, 1, format, type, pixels, + packing, t, ti); } static void From 092ca30366d15debb35939205d82a6ac2408fbb9 Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Mon, 22 Mar 2010 12:18:02 -0600 Subject: [PATCH 257/483] Fix potential compilation issue in visual studio project file Add quotes around filespec in post-build event to allow paths with embedded spaces. --- windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj b/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj index 8995c03886b..6e9aef2e1f8 100644 --- a/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj +++ b/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj @@ -89,7 +89,7 @@ /> From 45d1dc26072ea83ee10cf1c8907cfdf5df51928e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 22 Mar 2010 11:34:18 -0700 Subject: [PATCH 258/483] cso: Remove unnecessary header. --- src/gallium/auxiliary/cso_cache/cso_context.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index d6f8dd34bfa..6fd4bd36428 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -39,7 +39,6 @@ #include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "util/u_sampler.h" #include "tgsi/tgsi_parse.h" #include "cso_cache/cso_context.h" From f42acbeebf8267b61d89c0d1be5cb26009a30496 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 13:36:27 -0600 Subject: [PATCH 259/483] glslcompiler: fix build again Simply use the libglapi.a archive instead of individual .o files. Fixes the non-debug build. --- src/mesa/drivers/glslcompiler/Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index 1b9a056baae..7dcf9a6541a 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -9,14 +9,9 @@ PROGRAM = glslcompiler OBJECTS = \ glslcompiler.o \ - ../../glapi/glapi.o \ - ../../glapi/glapi_entrypoint.o \ - ../../glapi/glapi_getproc.o \ - ../../glapi/glapi_dispatch.o \ - ../../glapi/glapi_nop.o \ - ../../glapi/glthread.o \ ../common/driverfuncs.o \ - ../../libmesa.a + ../../libmesa.a \ + ../../libglapi.a INCLUDES = \ -I$(TOP)/include \ From 262961ef694d90fd008041c8384014fd7ed45594 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 22 Mar 2010 13:02:09 -0700 Subject: [PATCH 260/483] st/mesa: Remove unnecessary headers. --- src/mesa/state_tracker/st_atom.c | 2 -- src/mesa/state_tracker/st_manager.c | 1 - 2 files changed, 3 deletions(-) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 9fa4dae5ca9..cf391f1f91f 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -36,8 +36,6 @@ #include "st_program.h" #include "st_manager.h" -#include "pipe/p_context.h" - /** * This is used to initialize st->atoms[]. diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 6ec4c8d792c..ab86ed5513a 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -40,7 +40,6 @@ #include "main/teximage.h" #include "main/texstate.h" #include "main/texfetch.h" -#include "main/fbobject.h" #include "main/framebuffer.h" #include "main/renderbuffer.h" #include "st_texture.h" From 6422cf387baef75df9e5dbbed5cea4c0f495fe41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 22 Mar 2010 17:54:35 -0400 Subject: [PATCH 261/483] intel: Call intel_prepare_render() before looking up regions. Fixes #27213. --- src/mesa/drivers/dri/intel/intel_blit.c | 2 -- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 2 ++ src/mesa/drivers/dri/intel/intel_pixel_copy.c | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 46173703397..167140d274a 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -119,8 +119,6 @@ intelEmitCopyBlit(struct intel_context *intel, break; } while (pass < 2); - intel_prepare_render(intel); - if (pass >= 2) return GL_FALSE; diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index e671355c381..ef1966ea7e1 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -448,6 +448,8 @@ intel_miptree_image_copy(struct intel_context *intel, width = ALIGN(width, align_w); } + intel_prepare_render(intel); + for (i = 0; i < depth; i++) { intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y); intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index 8efb7a60c26..56faf076c7e 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -108,8 +108,8 @@ do_blit_copypixels(GLcontext * ctx, GLint dstx, GLint dsty, GLenum type) { struct intel_context *intel = intel_context(ctx); - struct intel_region *dst = intel_drawbuf_region(intel); - struct intel_region *src = copypix_src_region(intel, type); + struct intel_region *dst; + struct intel_region *src; struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_framebuffer *read_fb = ctx->ReadBuffer; GLint orig_dstx; @@ -134,13 +134,16 @@ do_blit_copypixels(GLcontext * ctx, ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; + intel_prepare_render(intel); + + dst = intel_drawbuf_region(intel); + src = copypix_src_region(intel, type); + if (!src || !dst) return GL_FALSE; intelFlush(&intel->ctx); - intel_prepare_render(intel); - /* Clip to destination buffer. */ orig_dstx = dstx; orig_dsty = dsty; From 62d54f0387610ec4f71cc3d0fb2a5d49e370a0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 22 Mar 2010 17:54:35 -0400 Subject: [PATCH 262/483] intel: Call intel_prepare_render() before looking up regions. Fixes #27213. --- src/mesa/drivers/dri/intel/intel_blit.c | 2 -- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 2 ++ src/mesa/drivers/dri/intel/intel_pixel_copy.c | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index f2769aa3e8c..4ad42a7c280 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -119,8 +119,6 @@ intelEmitCopyBlit(struct intel_context *intel, break; } while (pass < 2); - intel_prepare_render(intel); - if (pass >= 2) { drm_intel_gem_bo_map_gtt(dst_buffer); drm_intel_gem_bo_map_gtt(src_buffer); diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 4f14946ec72..1b340afc6a5 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -520,6 +520,8 @@ intel_miptree_image_copy(struct intel_context *intel, width = ALIGN(width, align_w); } + intel_prepare_render(intel); + for (i = 0; i < depth; i++) { intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y); intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index f4f3fd6d889..757f2f7d4db 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -108,8 +108,8 @@ do_blit_copypixels(GLcontext * ctx, GLint dstx, GLint dsty, GLenum type) { struct intel_context *intel = intel_context(ctx); - struct intel_region *dst = intel_drawbuf_region(intel); - struct intel_region *src = copypix_src_region(intel, type); + struct intel_region *dst; + struct intel_region *src; struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_framebuffer *read_fb = ctx->ReadBuffer; GLint orig_dstx; @@ -133,13 +133,16 @@ do_blit_copypixels(GLcontext * ctx, ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; + intel_prepare_render(intel); + + dst = intel_drawbuf_region(intel); + src = copypix_src_region(intel, type); + if (!src || !dst) return GL_FALSE; intelFlush(&intel->ctx); - intel_prepare_render(intel); - /* XXX: We fail to handle different inversion between read and draw framebuffer. */ /* Clip to destination buffer. */ From af0b0e1172a14ca215777f6ef6569d1433f45af2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 15:49:38 -0600 Subject: [PATCH 263/483] st/mesa: rename st_framebuffer() to st_ws_framebuffer() Be clear that this function is not just a cast wrapper. --- src/mesa/state_tracker/st_manager.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index ab86ed5513a..ca3a29cb2b8 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -59,10 +59,13 @@ void st_flush(struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence); /** + * Cast wrapper to convert a GLframebuffer to an st_framebuffer. + * Return NULL if the GLframebuffer is a user-created framebuffer. + * We'll only return non-null for window system framebuffers. * Note that this function may fail. */ static INLINE struct st_framebuffer * -st_framebuffer(GLframebuffer *fb) +st_ws_framebuffer(GLframebuffer *fb) { /* FBO cannot be casted. See st_new_framebuffer */ return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL); @@ -473,9 +476,9 @@ st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi, struct st_framebuffer *stfb; /* either draw or read winsys fb */ - stfb = st_framebuffer(st->ctx->WinSysDrawBuffer); + stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer); if (!stfb || stfb->iface != stfbi) - stfb = st_framebuffer(st->ctx->WinSysReadBuffer); + stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer); assert(stfb && stfb->iface == stfbi); p_atomic_set(&stfb->revalidate, TRUE); @@ -616,7 +619,7 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, if (st) { /* reuse/create the draw fb */ - stfb = st_framebuffer(st->ctx->WinSysDrawBuffer); + stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer); if (stfb && stfb->iface == stdrawi) { stdraw = NULL; st_framebuffer_reference(&stdraw, stfb); @@ -626,7 +629,7 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, } /* reuse/create the read fb */ - stfb = st_framebuffer(st->ctx->WinSysReadBuffer); + stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer); if (!stfb || stfb->iface != streadi) stfb = stdraw; if (stfb && stfb->iface == streadi) { @@ -698,7 +701,7 @@ st_api_destroy(struct st_api *stapi) void st_manager_flush_frontbuffer(struct st_context *st) { - struct st_framebuffer *stfb = st_framebuffer(st->ctx->DrawBuffer); + struct st_framebuffer *stfb = st_ws_framebuffer(st->ctx->DrawBuffer); struct st_renderbuffer *strb = NULL; if (stfb) @@ -723,8 +726,8 @@ st_manager_flush_frontbuffer(struct st_context *st) void st_manager_validate_framebuffers(struct st_context *st) { - struct st_framebuffer *stdraw = st_framebuffer(st->ctx->DrawBuffer); - struct st_framebuffer *stread = st_framebuffer(st->ctx->ReadBuffer); + struct st_framebuffer *stdraw = st_ws_framebuffer(st->ctx->DrawBuffer); + struct st_framebuffer *stread = st_ws_framebuffer(st->ctx->ReadBuffer); /* st_public.h */ if ((stdraw && !stdraw->iface) || (stread && !stread->iface)) { @@ -747,7 +750,7 @@ boolean st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, gl_buffer_index idx) { - struct st_framebuffer *stfb = st_framebuffer(fb); + struct st_framebuffer *stfb = st_ws_framebuffer(fb); /* FBO or st_public.h */ if (!stfb || !stfb->iface) From ef2664da6c4db1b52ef351641e3ee949b87f9c7b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Mar 2010 15:55:43 -0600 Subject: [PATCH 264/483] st/glx: fix depth/stencil format selection code This fixes a pretty big performance regression caused by commit 3475e88442c16fb2b50b903fe246b3ebe49da226. When the user does not request a stencil buffer it's important that we don't use a depth/stencil format (or at least make it our last choice). If the user calls glClear(GL_DEPTH_BUFFER_BIT) when we have a combined depth/stencil buffer, that causes us to hit the clear_with_quad() path which can be much, much slower than calling pipe_context::clear(). Also, try to use a shallower depth format before a deeper one. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 62a2bfcfa07..8dd54206af2 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -309,8 +309,9 @@ choose_pixel_format(XMesaVisual v) return 0; } + /** - * Choose a depth/stencil format that is "better" than the given depth and + * Choose a depth/stencil format that satisfies the given depth and * stencil sizes. */ static enum pipe_format @@ -324,16 +325,20 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil) int count, i; count = 0; + + if (depth <= 16 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z16_UNORM; + } + if (depth <= 24 && stencil == 0) { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } if (depth <= 24 && stencil <= 8) { formats[count++] = PIPE_FORMAT_S8Z24_UNORM; formats[count++] = PIPE_FORMAT_Z24S8_UNORM; } - - if (!stencil) { - if (depth <= 16) - formats[count++] = PIPE_FORMAT_Z16_UNORM; - if (depth <= 32) - formats[count++] = PIPE_FORMAT_Z32_UNORM; + if (depth <= 32 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z32_UNORM; } fmt = PIPE_FORMAT_NONE; From 8a998342c6bf591f1969b432bdda1732d480ee56 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 11:44:43 -0700 Subject: [PATCH 265/483] i965: Optimize OPCODE_CMP by using BRW_SEL to choose results. Tested with piglit glsl-fs-sqrt-branch, fp-cmp.vpfp. --- src/mesa/drivers/dri/i965/brw_wm_emit.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 1869fd06d5a..5abc0672f3f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -620,14 +620,10 @@ void emit_cmp(struct brw_compile *p, for (i = 0; i < 4; i++) { if (mask & (1< Date: Fri, 19 Mar 2010 12:27:38 -0700 Subject: [PATCH 266/483] i965: Add INTEL_DEBUG=glsl_force to force brw_wm_glsl.c. I keep finding the desire to force this path to debug it instead of cooking up goofy-looking testcases to do so. --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 3 +++ src/mesa/drivers/dri/intel/intel_context.c | 1 + src/mesa/drivers/dri/intel/intel_context.h | 1 + 3 files changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 0b66cc6c9f3..d9d6ddae8c4 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -23,6 +23,9 @@ GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp) { int i; + if (INTEL_DEBUG & DEBUG_GLSL_FORCE) + return GL_TRUE; + for (i = 0; i < fp->Base.NumInstructions; i++) { const struct prog_instruction *inst = &fp->Base.Instructions[i]; switch (inst->Opcode) { diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index c86dd1d0d98..5289e954dbd 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -444,6 +444,7 @@ static const struct dri_debug_control debug_control[] = { { "sing", DEBUG_SINGLE_THREAD }, { "thre", DEBUG_SINGLE_THREAD }, { "wm", DEBUG_WM }, + { "glsl_force", DEBUG_GLSL_FORCE }, { "urb", DEBUG_URB }, { "vs", DEBUG_VS }, { NULL, 0 } diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 22736a93279..6a68c903ee0 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -342,6 +342,7 @@ extern int INTEL_DEBUG; #define DEBUG_WM 0x800000 #define DEBUG_URB 0x1000000 #define DEBUG_VS 0x2000000 +#define DEBUG_GLSL_FORCE 0x4000000 #define DBG(...) do { \ if (INTEL_DEBUG & FILE_DEBUG_FLAG) \ From 4fc57322258a750c0a9cabc77372b5ccde1fa877 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 12:34:53 -0700 Subject: [PATCH 267/483] i965: Allow FS constants to be used as immediates instead of push/pull. The hope is to later take advantage of the reduced constant usage to free up regs. This only covers the GLSL path at the moment, because the brw_wm_emit path doesn't get the information as to whether a float value is a constant or a uniform. --- src/mesa/drivers/dri/i965/brw_wm.h | 2 +- src/mesa/drivers/dri/i965/brw_wm_emit.c | 38 +++++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_wm_glsl.c | 25 ++++++++++++---- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 47b764d24d1..5aade1c4e69 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -286,7 +286,7 @@ void brw_wm_pass0( struct brw_wm_compile *c ); void brw_wm_pass1( struct brw_wm_compile *c ); void brw_wm_pass2( struct brw_wm_compile *c ); void brw_wm_emit( struct brw_wm_compile *c ); - +GLboolean brw_wm_arg_can_be_immediate(enum prog_opcode, int arg); void brw_wm_print_value( struct brw_wm_compile *c, struct brw_wm_value *value ); diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 5abc0672f3f..f79de5dbffc 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -61,6 +61,44 @@ static INLINE struct brw_reg sechalf( struct brw_reg reg ) return reg; } +/* Return the SrcReg index of the channels that can be immediate float operands + * instead of usage of PROGRAM_CONSTANT values through push/pull. + */ +GLboolean +brw_wm_arg_can_be_immediate(enum prog_opcode opcode, int arg) +{ + int opcode_array[] = { + [OPCODE_ADD] = 2, + [OPCODE_CMP] = 3, + [OPCODE_DP3] = 2, + [OPCODE_DP4] = 2, + [OPCODE_DPH] = 2, + [OPCODE_MAX] = 2, + [OPCODE_MIN] = 2, + [OPCODE_MOV] = 1, + [OPCODE_MUL] = 2, + [OPCODE_SEQ] = 2, + [OPCODE_SGE] = 2, + [OPCODE_SGT] = 2, + [OPCODE_SLE] = 2, + [OPCODE_SLT] = 2, + [OPCODE_SNE] = 2, + [OPCODE_XPD] = 2, + }; + + /* These opcodes get broken down in a way that allow two + * args to be immediates. + */ + if (opcode == OPCODE_MAD || opcode == OPCODE_LRP) { + if (arg == 1 || arg == 2) + return GL_TRUE; + } + + if (opcode > ARRAY_SIZE(opcode_array)) + return GL_FALSE; + + return arg == opcode_array[opcode] - 1; +} /** * Computes the screen-space x,y position of the pixels. diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index d9d6ddae8c4..d78fb4ed09f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -570,12 +570,25 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c, const GLuint nr = 1; const GLuint component = GET_SWZ(src->Swizzle, channel); - /* Extended swizzle terms */ - if (component == SWIZZLE_ZERO) { - return brw_imm_f(0.0F); - } - else if (component == SWIZZLE_ONE) { - return brw_imm_f(1.0F); + /* Only one immediate value can be used per native opcode, and it + * has be in the src1 slot, so not all Mesa instructions will get + * to take advantage of immediate constants. + */ + if (brw_wm_arg_can_be_immediate(inst->Opcode, srcRegIndex)) { + const struct gl_program_parameter_list *params; + + params = c->fp->program.Base.Parameters; + + /* Extended swizzle terms */ + if (component == SWIZZLE_ZERO) { + return brw_imm_f(0.0F); + } else if (component == SWIZZLE_ONE) { + return brw_imm_f(1.0F); + } + + if (src->File == PROGRAM_CONSTANT) { + return brw_imm_f(params->ParameterValues[src->Index][component]); + } } if (c->fp->use_const_buffer && From a9acde6a723c8f343f65243d1ccac6836215ba0c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 15:04:17 -0700 Subject: [PATCH 268/483] i965: Ignore execution mask for the mov(m0, g0) of VS URB write header on SNB. Otherwise, we may not get the FFTID set up which would break freeing of resources. --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index d2395dec288..c33c3def304 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1416,7 +1416,10 @@ void brw_urb_WRITE(struct brw_compile *p, * and the first message register index comes from src0. */ if (intel->gen >= 6) { + brw_push_insn_state(p); + brw_set_mask_control( p, BRW_MASK_DISABLE ); brw_MOV(p, brw_message_reg(msg_reg_nr), src0); + brw_pop_insn_state(p); src0 = brw_message_reg(msg_reg_nr); } From d163d5fac0eb5e57a2afb77f557525110753359e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 15:57:50 -0700 Subject: [PATCH 269/483] i965: Remove gratuitous jump or nop from OPCODE_END to vertex emit. Just emit the URB write at END time. Subroutine code that sits after OPCODE_END won't be executed since we've ended the thread at the point that the URB write is done. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 43 ++----------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 14c3b936b7e..227261409c4 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1361,31 +1361,6 @@ static void emit_vertex_write( struct brw_vs_compile *c) } } - -/** - * Called after code generation to resolve subroutine calls and the - * END instruction. - * \param end_inst points to brw code for END instruction - * \param last_inst points to last instruction emitted before vertex write - */ -static void -post_vs_emit( struct brw_vs_compile *c, - struct brw_instruction *end_inst, - struct brw_instruction *last_inst ) -{ - GLint offset; - - brw_resolve_cals(&c->func); - - /* patch up the END code to jump past subroutines, etc */ - offset = last_inst - end_inst; - if (offset > 1) { - brw_set_src1(end_inst, brw_imm_d(offset * 16)); - } else { - end_inst->header.opcode = BRW_OPCODE_NOP; - } -} - static GLboolean accumulator_contains(struct brw_vs_compile *c, struct brw_reg val) { @@ -1466,8 +1441,6 @@ void brw_vs_emit(struct brw_vs_compile *c ) struct intel_context *intel = &brw->intel; const GLuint nr_insns = c->vp->program.Base.NumInstructions; GLuint insn, if_depth = 0, loop_depth = 0; - GLuint end_offset = 0; - struct brw_instruction *end_inst, *last_inst; struct brw_instruction *if_inst[MAX_IF_DEPTH], *loop_inst[MAX_LOOP_DEPTH] = { 0 }; const struct brw_indirect stack_index = brw_indirect(0, 0); GLuint index; @@ -1751,12 +1724,8 @@ void brw_vs_emit(struct brw_vs_compile *c ) brw_MOV(p, brw_ip_reg(), deref_1d(stack_index, 0)); brw_set_access_mode(p, BRW_ALIGN_16); break; - case OPCODE_END: - end_offset = p->nr_insn; - /* this instruction will get patched later to jump past subroutine - * code, etc. - */ - brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16)); + case OPCODE_END: + emit_vertex_write(c); break; case OPCODE_PRINT: /* no-op */ @@ -1817,13 +1786,7 @@ void brw_vs_emit(struct brw_vs_compile *c ) release_tmps(c); } - end_inst = &p->store[end_offset]; - last_inst = &p->store[p->nr_insn]; - - /* The END instruction will be patched to jump to this code */ - emit_vertex_write(c); - - post_vs_emit(c, end_inst, last_inst); + brw_resolve_cals(p); brw_optimize(p); From edc8a99d1dc9963f61c3ecb5fdf481efae359ce4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 16:00:31 -0700 Subject: [PATCH 270/483] i965: Enable VS on SNB. It appears that the thing that was killing VS threads was the gratuitous NOP that replaced the gratuitous jump from OPCODE_END to the nearby OPCODE_END implementation. With that gone, we can move on to the rest of the pipeline. --- src/mesa/drivers/dri/i965/gen6_vs_state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c index fe597dfb945..5916a139946 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -100,7 +100,8 @@ upload_vs_state(struct brw_context *brw) (brw->vs.prog_data->urb_read_length << GEN6_VS_URB_READ_LENGTH_SHIFT) | (0 << GEN6_VS_URB_ENTRY_READ_OFFSET_SHIFT)); OUT_BATCH((0 << GEN6_VS_MAX_THREADS_SHIFT) | - GEN6_VS_STATISTICS_ENABLE); + GEN6_VS_STATISTICS_ENABLE | + GEN6_VS_ENABLE); ADVANCE_BATCH(); intel_batchbuffer_emit_mi_flush(intel->batch); From 073f8d1c00165acccb60f878a2aa770c2b885aec Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 17:08:42 -0700 Subject: [PATCH 271/483] i965: Correct copy and wasted field shifts for SNB GS URB. --- src/mesa/drivers/dri/i965/brw_defines.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 984e56d00c8..6fe574b22e2 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -831,8 +831,8 @@ #define CMD_URB 0x7805 /* GEN6+ */ # define GEN6_URB_VS_SIZE_SHIFT 16 # define GEN6_URB_VS_ENTRIES_SHIFT 0 -# define GEN6_URB_GS_SIZE_SHIFT 8 -# define GEN6_URB_GS_ENTRIES_SHIFT 0 +# define GEN6_URB_GS_ENTRIES_SHIFT 8 +# define GEN6_URB_GS_SIZE_SHIFT 0 #define CMD_VIEWPORT_STATE_POINTERS 0x780d /* GEN6+ */ # define GEN6_CC_VIEWPORT_MODIFY (1 << 12) From 7319b19fc94c3b49d19b8bf9ce52dc17db3ac6f3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 19 Mar 2010 17:14:12 -0700 Subject: [PATCH 272/483] i965: Force single program flow in SNB GS, to match gen4 GS. --- src/mesa/drivers/dri/i965/gen6_gs_state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen6_gs_state.c b/src/mesa/drivers/dri/i965/gen6_gs_state.c index 161e7b85c28..cefc93ba48b 100644 --- a/src/mesa/drivers/dri/i965/gen6_gs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_gs_state.c @@ -50,7 +50,8 @@ upload_gs_state(struct brw_context *brw) BEGIN_BATCH(7); OUT_BATCH(CMD_3D_GS_STATE << 16 | (7 - 2)); OUT_RELOC(brw->gs.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_BATCH((0 << GEN6_GS_SAMPLER_COUNT_SHIFT) | + OUT_BATCH(GEN6_GS_SPF_MODE | + (0 << GEN6_GS_SAMPLER_COUNT_SHIFT) | (0 << GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT)); OUT_BATCH(0); /* scratch space base offset */ OUT_BATCH((1 << GEN6_GS_DISPATCH_START_GRF_SHIFT) | From 10069916c71d55ddaeca793f5dade203a8b42da5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 22 Mar 2010 09:04:25 -0700 Subject: [PATCH 273/483] i965: Enable normal clipping on SNB. Rejecting all doesn't seem to be helping get the pipeline lit up. --- src/mesa/drivers/dri/i965/gen6_clip_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index 06f8145e32d..acc4b7f1019 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -55,7 +55,7 @@ upload_clip_state(struct brw_context *brw) OUT_BATCH(GEN6_CLIP_STATISTICS_ENABLE); OUT_BATCH(GEN6_CLIP_ENABLE | GEN6_CLIP_API_OGL | - GEN6_CLIP_MODE_REJECT_ALL | /* XXX: debug: get VS working */ + GEN6_CLIP_MODE_NORMAL | GEN6_CLIP_XY_TEST | depth_clamp | provoking); From d9ea1af82c233a10adbf9b842546e9322480591b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 22 Mar 2010 10:17:19 -0700 Subject: [PATCH 274/483] i965: Add disasm for SNB MATH opcode. --- src/mesa/drivers/dri/i965/brw_disasm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c index ad61770212c..db3fc50a63b 100644 --- a/src/mesa/drivers/dri/i965/brw_disasm.c +++ b/src/mesa/drivers/dri/i965/brw_disasm.c @@ -57,6 +57,7 @@ struct { [BRW_OPCODE_DPH] = { .name = "dph", .nsrc = 2, .ndst = 1 }, [BRW_OPCODE_DP3] = { .name = "dp3", .nsrc = 2, .ndst = 1 }, [BRW_OPCODE_DP2] = { .name = "dp2", .nsrc = 2, .ndst = 1 }, + [BRW_OPCODE_MATH] = { .name = "math", .nsrc = 2, .ndst = 1 }, [BRW_OPCODE_AVG] = { .name = "avg", .nsrc = 2, .ndst = 1 }, [BRW_OPCODE_ADD] = { .name = "add", .nsrc = 2, .ndst = 1 }, @@ -797,7 +798,11 @@ int brw_disasm (FILE *file, struct brw_instruction *inst) err |= control (file, "saturate", saturate, inst->header.saturate, NULL); err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL); - if (inst->header.opcode != BRW_OPCODE_SEND) + if (inst->header.opcode == BRW_OPCODE_MATH) { + string (file, " "); + err |= control (file, "function", math_function, + inst->header.destreg__conditionalmod, NULL); + } else if (inst->header.opcode != BRW_OPCODE_SEND) err |= control (file, "conditional modifier", conditional_modifier, inst->header.destreg__conditionalmod, NULL); From 8f4f2a0c3625de2bb2b8e955afc23b3ce8c95f93 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 22 Mar 2010 16:39:11 -0700 Subject: [PATCH 275/483] GLX/OML: honor OML semantics even if target, divisor and remainder are 0 This change passes a remainder of 1 to the server with the DRI2SwapBuffers request, causing it to honor the OML semantics for the swap rather than falling through to glXSwapBuffers behavior. The remainder actually ends up ignored since the divisor is 0, but we need to differentiate the OML and standard behavior somehow. Reported-by: Mario Kleiner Signed-off-by: Jesse Barnes --- src/glx/glxcmds.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 49cbce72f8a..ea267f3dd8a 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -2507,6 +2507,9 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, if (divisor > 0 && remainder >= divisor) return -1; + if (target_msc == 0 && divisor == 0 && remainder == 0) + remainder = 1; + #ifdef __DRI_SWAP_BUFFER_COUNTER if (psc->counters != NULL) return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, From 4eead425504057e0862bc214bceaa512775973f1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Mar 2010 18:09:15 -0700 Subject: [PATCH 276/483] mesa: set version string to 7.8-rc2 --- Makefile | 2 +- src/mesa/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 68b5adffbe9..733d57b782d 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-rc1 +VERSION=7.8-rc2 DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index 7ed1e1a32a4..23d74ee2c97 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -35,7 +35,7 @@ #define MESA_MAJOR 7 #define MESA_MINOR 8 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.8-rc1" +#define MESA_VERSION_STRING "7.8-rc2" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) From ca49a72a55895f8fefb090405a79918cbaa805ee Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 22 Mar 2010 03:10:19 -0700 Subject: [PATCH 277/483] r300g: Cleanup a few old warnings. Those paths aren't important anymore, and a debugging warning won't stop a hardlock anyway. --- src/gallium/drivers/r300/r300_emit.c | 33 ++++++++-------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index c897df628d2..796e3eca5bf 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -146,10 +146,8 @@ static const float * get_shader_constant( struct rc_constant * constant, struct r300_constant_buffer * externals) { - struct r300_viewport_state* viewport = - (struct r300_viewport_state*)r300->viewport_state.state; - struct r300_textures_state* texstate = - (struct r300_textures_state*)r300->textures_state.state; + struct r300_viewport_state* viewport = r300->viewport_state.state; + struct r300_textures_state* texstate = r300->textures_state.state; static float vec[4] = { 0.0, 0.0, 0.0, 1.0 }; struct pipe_texture *tex; @@ -900,12 +898,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) CS_LOCALS(r300); - if (!r300screen->caps->has_tcl) { - debug_printf("r300: Implementation error: emit_vs_state called," - " but has_tcl is FALSE!\n"); - return; - } - BEGIN_CS(size); /* R300_VAP_PVS_CODE_CNTL_0 * R300_VAP_PVS_CONST_CNTL @@ -935,28 +927,19 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) void r300_emit_vs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants) { - int i; struct r300_screen* r300screen = r300_screen(r300->context.screen); + unsigned i; CS_LOCALS(r300); - if (!r300screen->caps->has_tcl) { - debug_printf("r300: Implementation error: emit_vs_constant_buffer called," - " but has_tcl is FALSE!\n"); - return; - } - - if (constants->Count == 0) - return; - BEGIN_CS(constants->Count * 4 + 3); OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300screen->caps->is_r500 ? R500_PVS_CONST_START : R300_PVS_CONST_START)); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, constants->Count * 4); for (i = 0; i < constants->Count; i++) { - const float * data = get_shader_constant(r300, - &constants->Constants[i], - &r300->shader_constants[PIPE_SHADER_VERTEX]); + const float *data = get_shader_constant(r300, + &constants->Constants[i], + &r300->shader_constants[PIPE_SHADER_VERTEX]); OUT_CS_32F(data[0]); OUT_CS_32F(data[1]); OUT_CS_32F(data[2]); @@ -1167,7 +1150,9 @@ void r300_emit_dirty_state(struct r300_context* r300) if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { struct r300_vertex_shader* vs = r300->vs_state.state; - r300_emit_vs_constant_buffer(r300, &vs->code.constants); + if (vs->code.constants.Count) { + r300_emit_vs_constant_buffer(r300, &vs->code.constants); + } r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS; } From ed61faec7ea307ff22738b4fcc96933f910e4145 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 22 Mar 2010 18:11:40 -0700 Subject: [PATCH 278/483] radeong: Always initialize this variable. May or may not be responsible for slight increases in ipers FPS. --- src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index e36bad7ea8c..ec45abf4676 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -70,7 +70,7 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, unsigned flags) { struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); - int write; + int write = 0; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { if ((_buf->base.usage & PIPE_BUFFER_USAGE_VERTEX) || @@ -365,7 +365,7 @@ boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf) return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) || radeon_bo_is_busy(buf->bo, &domain)); } - + void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr) { From d5b2cecb03e8985aae589f1a8118e60eb693452a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 22 Mar 2010 18:12:16 -0700 Subject: [PATCH 279/483] gallium/docs: Cleanup and clarify point ras info. ...This state's interdependent? Really? Needs moar cleanup. --- src/gallium/docs/source/cso/rasterizer.rst | 76 +++++++++++++--------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index ccd9136a2eb..e8dc82964fa 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -7,7 +7,7 @@ The rasterizer state controls the rendering of points, lines and triangles. Attributes include polygon culling state, line width, line stipple, multisample state, scissoring and flat/smooth shading. -Members +Shading ------- flatshade @@ -46,6 +46,49 @@ There are several important exceptions to the specification of this rule. second vertex, not the first. This permits each segment of the fan to have a different color. +Points +------ + +sprite_coord_enable +^^^^^^^^^^^^^^^^^^^ + +Specifies if a texture unit has its texture coordinates replaced or not. This +is a packed bitfield containing the enable for all texcoords -- if all bits +are zero, point sprites are effectively disabled. If any bit is set, then +point_smooth and point_quad_rasterization are ignored; point smoothing is +disabled and points are always rasterized as quads. If enabled, the four +vertices of the resulting quad will be assigned texture coordinates, +according to sprite_coord_mode. + +sprite_coord_mode +^^^^^^^^^^^^^^^^^ + +Specifies how the value for each shader output should be computed when drawing +point sprites. For PIPE_SPRITE_COORD_LOWER_LEFT, the lower-left vertex will +have coordinates (0,0,0,1). For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left +vertex will have coordinates (0,0,0,1). +This state is used by :ref:`Draw` to generate texcoords. + +.. note:: + + When geometry shaders are available, a special geometry shader could be + used instead of this functionality, to convert incoming points into quads + with the proper texture coordinates. + +point_quad_rasterization +^^^^^^^^^^^^^^^^^^^^^^^^ + +Determines if points should be rasterized as quads or points. Certain APIs, +like Direct3D, always use quad rasterization for points, regardless of +whether point sprites are enabled or not. If this state is enabled, point +smoothing and antialiasing are disabled, and sprite coordinates are not +generated. + +.. note:: + + Some renderers always internally translate points into quads; this state + still affects those renderers by overriding other rasterization state. + Other Members ^^^^^^^^^^^^^ @@ -107,37 +150,6 @@ point_size_per_vertex Whether vertices have a point size element. point_size The size of points, if not specified per-vertex. -sprite_coord_enable - Specifies if a coord has its texture coordinates replaced or not. This - is a packed bitfield containing the enable for all coords - if all are 0 - point sprites are effectively disabled, though points may still be - rendered slightly different according to point_quad_rasterization. - If any coord is non-zero, point_smooth should be disabled, and - point_quad_rasterization enabled. - If enabled, the four vertices of the resulting quad will be assigned - texture coordinates, according to sprite_coord_mode. -sprite_coord_mode - Specifies how the value for each shader output should be computed when - drawing sprites, for each coord which has sprite_coord_enable set. - For PIPE_SPRITE_COORD_LOWER_LEFT, the lower left vertex will have - coordinate (0,0,0,1). - For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left vertex will have - coordinate (0,0,0,1). - This state is needed by :ref:`Draw` because that's where each - point vertex is converted into four quad vertices. There's no other - place to emit the new vertex texture coordinates which are required for - sprite rendering. - Note that when geometry shaders are available, this state could be - removed. A special geometry shader defined by the state tracker could - convert the incoming points into quads with the proper texture coords. -point_quad_rasterization - This determines if points should be rasterized as quads or points. - d3d always uses quad rasterization for points, regardless if point sprites - are enabled or not, but OGL has different rules. If point_quad_rasterization - is set, point_smooth should be disabled, and points will be rendered as - squares even if multisample is enabled. - sprite_coord_enable should be zero if point_quad_rasterization is not - enabled. scissor Whether the scissor test is enabled. From 7a0bcba9f9d7a4dcba11d06f207a5d494a330d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 22 Mar 2010 21:57:26 -0400 Subject: [PATCH 280/483] glx: Suppress BadDrawable from DRI2CopyRegion This can happen when an X window is destroyed behind our back. We use DRI2CopyRegion behind the scenes in many places (like flushing the fake front to the real front) so we have to ignore X errors triggered in that case. The glean test cases trigger this consistently as they don't destroy the GLX drawable nicely, they just destroy the X window. --- src/glx/dri2.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/glx/dri2.c b/src/glx/dri2.c index 5de55cdbf29..9ca9b3eb065 100644 --- a/src/glx/dri2.c +++ b/src/glx/dri2.c @@ -62,6 +62,8 @@ static Bool DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); static Status DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code); static /* const */ XExtensionHooks dri2ExtensionHooks = { NULL, /* create_gc */ @@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = { DRI2CloseDisplay, /* close_display */ DRI2WireToEvent, /* wire_to_event */ DRI2EventToWire, /* event_to_wire */ - NULL, /* error */ + DRI2Error, /* error */ NULL, /* error_string */ }; @@ -160,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) return Success; } +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code) +{ + if (err->majorCode == codes->major_opcode && + err->errorCode == BadDrawable && + err->minorCode == X_DRI2CopyRegion) + return True; + + return False; +} + Bool DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) { From 094c6fbc45cee1b53d9f1d7d4123d6da6a8958a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 22 Mar 2010 21:57:26 -0400 Subject: [PATCH 281/483] glx: Suppress BadDrawable from DRI2CopyRegion This can happen when an X window is destroyed behind our back. We use DRI2CopyRegion behind the scenes in many places (like flushing the fake front to the real front) so we have to ignore X errors triggered in that case. The glean test cases trigger this consistently as they don't destroy the GLX drawable nicely, they just destroy the X window. --- src/glx/dri2.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/glx/dri2.c b/src/glx/dri2.c index 5de55cdbf29..9ca9b3eb065 100644 --- a/src/glx/dri2.c +++ b/src/glx/dri2.c @@ -62,6 +62,8 @@ static Bool DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); static Status DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code); static /* const */ XExtensionHooks dri2ExtensionHooks = { NULL, /* create_gc */ @@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = { DRI2CloseDisplay, /* close_display */ DRI2WireToEvent, /* wire_to_event */ DRI2EventToWire, /* event_to_wire */ - NULL, /* error */ + DRI2Error, /* error */ NULL, /* error_string */ }; @@ -160,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) return Success; } +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code) +{ + if (err->majorCode == codes->major_opcode && + err->errorCode == BadDrawable && + err->minorCode == X_DRI2CopyRegion) + return True; + + return False; +} + Bool DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) { From 2ded27b2f0a7b01f5db77ea9a2a25df5baa876b3 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 23 Mar 2010 14:37:24 +0800 Subject: [PATCH 282/483] Add missing EGL files to the tarballs. Add the Makefile of Gallium EGL drivers and demos using EGL to the tarballs. --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 733d57b782d..7c75d7f833d 100644 --- a/Makefile +++ b/Makefile @@ -324,6 +324,7 @@ GALLIUM_FILES = \ $(DIRECTORY)/src/gallium/*/Makefile \ $(DIRECTORY)/src/gallium/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/Makefile \ + $(DIRECTORY)/src/gallium/*/*/Makefile.egl \ $(DIRECTORY)/src/gallium/*/*/Makefile.template \ $(DIRECTORY)/src/gallium/*/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/*.[ch] \ @@ -407,6 +408,14 @@ DEMO_FILES = \ $(DIRECTORY)/progs/demos/*.cxx \ $(DIRECTORY)/progs/demos/*.dat \ $(DIRECTORY)/progs/demos/README \ + $(DIRECTORY)/progs/egl/Makefile \ + $(DIRECTORY)/progs/egl/*.[ch] \ + $(DIRECTORY)/progs/es1/*/Makefile \ + $(DIRECTORY)/progs/es1/*/*.[ch] \ + $(DIRECTORY)/progs/es2/*/Makefile \ + $(DIRECTORY)/progs/es2/*/*.[ch] \ + $(DIRECTORY)/progs/openvg/*/Makefile \ + $(DIRECTORY)/progs/openvg/*/*.[ch] \ $(DIRECTORY)/progs/fbdev/Makefile \ $(DIRECTORY)/progs/fbdev/glfbdevtest.c \ $(DIRECTORY)/progs/objviewer/*.[ch] \ From 2a3accbc00c565e6641f926d6d3761249540fdea Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 22 Mar 2010 13:35:20 +1000 Subject: [PATCH 283/483] r300g: fix glean occlusion query test --- src/gallium/drivers/r300/r300_query.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index ca00b043c51..9822e6b48dd 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -97,8 +97,10 @@ static void r300_end_query(struct pipe_context* pipe, struct pipe_query* query) { struct r300_context* r300 = r300_context(pipe); + struct r300_query* q = (struct r300_query*)query; r300_emit_query_end(r300); + q->begin_emitted = false; r300->query_current = NULL; } From 1f25eca311715f5ebceaee50ba4d68c3c9ea79a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 23 Mar 2010 13:33:16 +0100 Subject: [PATCH 284/483] radeong: fix build issue with libdrm < 2.4.19 --- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 3 +++ src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 7aa9c5425d6..3dfcc5aef07 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -93,9 +93,12 @@ static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys) exit(1); } +/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */ +#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE // Supported since 2.1.0. winsys->squaretiling = version->version_major > 2 || version->version_minor >= 1; +#endif info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index ec45abf4676..66f61322457 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -315,8 +315,11 @@ void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, uint32_t flags = 0, old_flags, old_pitch; if (microtiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MICRO_TILE; +/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */ +#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE else if (microtiled == R300_BUFFER_SQUARETILED) flags |= RADEON_BO_FLAGS_MICRO_TILE_SQUARE; +#endif if (macrotiled == R300_BUFFER_TILED) flags |= RADEON_BO_FLAGS_MACRO_TILE; From 3e17a5b047124c46ee45dbd1848127c67e0d62f3 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Mon, 15 Mar 2010 18:36:27 +0100 Subject: [PATCH 285/483] dri: test whether the built drivers have unresolved symbols This is a different approach to solving this problem that the patch I previously posted, and unlike that, should not cause any problems. Right now undefined symbols in DRI drivers will still allow the build to succeed. As a result, people modifying drivers they cannot test risk creating unloadable drivers with no easy way of automatically avoiding it. For instance, the modifications to nv50 for context transfers caused such an issue recently. Unfortunately, just adding -Wl,--no-undefined doesn't work, because the DRI drivers depend on glapi symbols, but do not depend on libGL.so.1 Adding -lGL is not the correct solution since DRI drivers are not loaded just by libGL, but also by X and possibly by other clients. So, this patch simply tries to build an executable linked to the DRI driver and to libGL. If the DRI driver contains any undefined symbols not satisfied by its dependencies or by libGL, this will fail. This solution does not alter the built drivers, and does not significantly slow down the build process. All classic DRI drivers as well as all the Gallium drivers with configure options compiled successfully with this change. Thanks to Xavier Chantry and Michel Daenzer for helping with this. Signed-off-by: Luca Barbieri Acked-by: Brian Paul --- src/gallium/winsys/drm/Makefile.template | 7 +++++-- src/mesa/drivers/dri/Makefile.template | 7 +++++-- src/mesa/drivers/dri/common/dri_test.c | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/mesa/drivers/dri/common/dri_test.c diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index f4cc0def471..9f984f1090c 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -64,11 +64,14 @@ SHARED_INCLUDES = \ default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ - $(TOP)/src/mesa/drivers/dri/Makefile.template - $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o + $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL + @rm -f $@.test + mv $@.tmp $@ $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index a0c25d26cdf..2b7634bbf6c 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -51,9 +51,12 @@ lib: symlinks subdirs depend @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ - $(TOP)/src/mesa/drivers/dri/Makefile.template - $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o + $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL + @rm -f $@.test + mv $@.tmp $@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c new file mode 100644 index 00000000000..cf59b2b7378 --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -0,0 +1,10 @@ +/* This is just supposed to make sure we get a reference to + the driver entry symbol that the compiler doesn't optimize away */ + +extern char __driDriverExtensions[]; + +int main(int argc, char** argv) +{ + void* p = __driDriverExtensions; + return (int)(unsigned long)p; +} From c652ad907f0715a0c23476ebd48ab722c96a5064 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Wed, 17 Mar 2010 15:44:45 +0100 Subject: [PATCH 286/483] nvfx: fix/workaround nv3x hwtnl issues This patch re-emits the viewport state on framebuffer or rasterizer change. This seems to be necessary on nv3x, but the reason is not fully understood. It is quite likely that this isn't really the correct fix, but seems to work, and makes nv3x much better. --- src/gallium/drivers/nvfx/nvfx_state_viewport.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_state_viewport.c b/src/gallium/drivers/nvfx/nvfx_state_viewport.c index 82e0e9220b0..ec730e3a9e9 100644 --- a/src/gallium/drivers/nvfx/nvfx_state_viewport.c +++ b/src/gallium/drivers/nvfx/nvfx_state_viewport.c @@ -1,15 +1,16 @@ #include "nvfx_context.h" +/* Having this depend on FB and RAST looks wrong, but it seems + necessary to make this work on nv3x + TODO: find the right fix +*/ + static boolean nvfx_state_viewport_validate(struct nvfx_context *nvfx) { struct pipe_viewport_state *vpt = &nvfx->viewport; struct nouveau_stateobj *so; - if (nvfx->state.hw[NVFX_STATE_VIEWPORT] && - !(nvfx->dirty & NVFX_NEW_VIEWPORT)) - return FALSE; - so = so_new(2, 9, 0); so_method(so, nvfx->screen->eng3d, NV34TCL_VIEWPORT_TRANSLATE_X, 8); @@ -45,7 +46,7 @@ nvfx_state_viewport_validate(struct nvfx_context *nvfx) struct nvfx_state_entry nvfx_state_viewport = { .validate = nvfx_state_viewport_validate, .dirty = { - .pipe = NVFX_NEW_VIEWPORT, + .pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_FB | NVFX_NEW_RAST, .hw = NVFX_STATE_VIEWPORT } }; From a6cc9cf38d6e01d39b34f17a51c42e2d4962c0c9 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Wed, 17 Mar 2010 20:31:56 +0100 Subject: [PATCH 287/483] nvfx: stop incessantly spewing debug messages on the terminal Currently we are continuously spewing messages about these variables since we call debug_get_bool_option everytime we want to check their value. This is annoying, slows things down due to terminal rerendering and obscures useful messages. This patch only calls debug_get_bool_option once and caches the result in a static variable. --- src/gallium/drivers/nvfx/nvfx_miptree.c | 5 ++++- src/gallium/drivers/nvfx/nvfx_transfer.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c index 0f5ed61aab7..9de25175e78 100644 --- a/src/gallium/drivers/nvfx/nvfx_miptree.c +++ b/src/gallium/drivers/nvfx/nvfx_miptree.c @@ -67,6 +67,9 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) struct nvfx_miptree *mt; unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL | NOUVEAU_BUFFER_USAGE_TEXTURE; + static int no_swizzle = -1; + if(no_swizzle < 0) + no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE); mt = MALLOC(sizeof(struct nvfx_miptree)); if (!mt) @@ -106,7 +109,7 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_R16_SNORM: { - if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE)) + if (no_swizzle) mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; break; } diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.c b/src/gallium/drivers/nvfx/nvfx_transfer.c index 409b354d582..c81b44a789b 100644 --- a/src/gallium/drivers/nvfx/nvfx_transfer.c +++ b/src/gallium/drivers/nvfx/nvfx_transfer.c @@ -42,6 +42,9 @@ nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, struct nvfx_miptree *mt = (struct nvfx_miptree *)pt; struct nvfx_transfer *tx; struct pipe_texture tx_tex_template, *tx_tex; + static int no_transfer = -1; + if(no_transfer < 0) + no_transfer = debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/); tx = CALLOC_STRUCT(nvfx_transfer); if (!tx) @@ -59,8 +62,7 @@ nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, tx->base.zslice = zslice; /* Direct access to texture */ - if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || - debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) && + if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || no_transfer) && pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) { tx->direct = true; From e14d812e158a667ffb096a99e2510da326155670 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Wed, 17 Mar 2010 22:31:29 +0100 Subject: [PATCH 288/483] nvfx: fix coding style in nvfx_transfer.c --- src/gallium/drivers/nvfx/nvfx_transfer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.c b/src/gallium/drivers/nvfx/nvfx_transfer.c index c81b44a789b..1c250e9fe44 100644 --- a/src/gallium/drivers/nvfx/nvfx_transfer.c +++ b/src/gallium/drivers/nvfx/nvfx_transfer.c @@ -33,12 +33,12 @@ nvfx_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h } static struct pipe_transfer * -nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, +nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { - struct pipe_screen *pscreen = pcontext->screen; + struct pipe_screen *pscreen = pipe->screen; struct nvfx_miptree *mt = (struct nvfx_miptree *)pt; struct nvfx_transfer *tx; struct pipe_texture tx_tex_template, *tx_tex; @@ -120,13 +120,13 @@ nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, } static void -nvfx_transfer_del(struct pipe_context *pcontext, +nvfx_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx) { struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx; if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = pcontext->screen; + struct pipe_screen *pscreen = pipe->screen; struct nvfx_screen *nvscreen = nvfx_screen(pscreen); struct pipe_surface *dst; @@ -149,9 +149,9 @@ nvfx_transfer_del(struct pipe_context *pcontext, } static void * -nvfx_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx) +nvfx_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx) { - struct pipe_screen *pscreen = pcontext->screen; + struct pipe_screen *pscreen = pipe->screen; struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx; struct nv04_surface *ns = (struct nv04_surface *)tx->surface; struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture; @@ -165,9 +165,9 @@ nvfx_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx) } static void -nvfx_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx) +nvfx_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *ptx) { - struct pipe_screen *pscreen = pcontext->screen; + struct pipe_screen *pscreen = pipe->screen; struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx; struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture; From 83f4c444f4e630fe2bfd17ad750f3f17ceff13f6 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sun, 17 Jan 2010 22:27:53 +0100 Subject: [PATCH 289/483] nvfx: don't crash on empty fragment program --- src/gallium/drivers/nvfx/nvfx_fragprog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c index 76351430f44..b9c91cec8ce 100644 --- a/src/gallium/drivers/nvfx/nvfx_fragprog.c +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c @@ -803,7 +803,8 @@ nvfx_fragprog_translate(struct nvfx_context *nvfx, fp->fp_control |= fpc->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT; /* Terminate final instruction */ - fp->insn[fpc->inst_offset] |= 0x00000001; + if(fp->insn) + fp->insn[fpc->inst_offset] |= 0x00000001; /* Append NOP + END instruction, may or may not be necessary. */ fpc->inst_offset = fp->insn_len; From 4ceeb1307a018f426784620d3376f9f1ea07e53b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 08:58:09 -0600 Subject: [PATCH 290/483] st/glx: better format selection in xmesa_choose_z_stencil_format() This is a back-port of commit ef2664da6c4db1b52ef351641e3ee949b87f9c7b from master. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 41 ++++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 217bdeff75e..e8524a21c21 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -324,7 +324,7 @@ choose_pixel_format(XMesaVisual v) * at least matches the given depthBits and stencilBits. */ static void -xmesa_choose_z_stencil_format(int depthBits, int stencilBits, +xmesa_choose_z_stencil_format(int depth, int stencil, enum pipe_format *depthFormat, enum pipe_format *stencilFormat) { @@ -332,20 +332,28 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits, const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); - static enum pipe_format formats[] = { - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_Z32_UNORM - }; - int i; + enum pipe_format formats[8]; + int count, i; - assert(screen); + count = 0; - *depthFormat = *stencilFormat = PIPE_FORMAT_NONE; + if (depth <= 16 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z16_UNORM; + } + if (depth <= 24 && stencil == 0) { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } + if (depth <= 24 && stencil <= 8) { + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + } + if (depth <= 32 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z32_UNORM; + } - /* search for supported format */ - for (i = 0; i < Elements(formats); i++) { + *depthFormat = PIPE_FORMAT_NONE; + for (i = 0; i < count; i++) { if (screen->is_format_supported(screen, formats[i], target, tex_usage, geom_flags)) { *depthFormat = formats[i]; @@ -353,13 +361,12 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits, } } - if (stencilBits) { + if (stencil) { *stencilFormat = *depthFormat; } - - /* XXX we should check that he chosen format has at least as many bits - * as what was requested. - */ + else { + *stencilFormat = PIPE_FORMAT_NONE; + } } From fc1ba0423ac31cff14346dbc888255fb5fd7d1b2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 09:00:19 -0600 Subject: [PATCH 291/483] softpipe: add special cases for all Z compare modes for 16-bit Z buffer We had fast paths for PIPE_FUNC_LESS and LEQUAL before. To satisfy OpenGL invariance rules, all depth compare modes should produce the same fragment Z values. Fixes progs/demos/singlebuffer.c --- .../drivers/softpipe/sp_quad_depth_test.c | 221 ++++-------------- .../drivers/softpipe/sp_quad_depth_test_tmp.h | 147 ++++++++++++ 2 files changed, 195 insertions(+), 173 deletions(-) create mode 100644 src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 4815a0d49f1..5854cee1be0 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -730,169 +730,36 @@ depth_test_quads_fallback(struct quad_stage *qs, /** - * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LESS and - * Z buffer writes enabled. - * - * NOTE: there's no guarantee that the quads are sequentially side by - * side. The fragment shader may have culled some quads, etc. Sliver - * triangles may generate non-sequential quads. + * Special-case Z testing for 16-bit Zbuffer and Z buffer writes enabled. */ -static void -depth_interp_z16_less_write(struct quad_stage *qs, - struct quad_header *quads[], - unsigned nr) -{ - unsigned i, pass = 0; - const unsigned ix = quads[0]->input.x0; - const unsigned iy = quads[0]->input.y0; - const float fx = (float) ix; - const float fy = (float) iy; - const float dzdx = quads[0]->posCoef->dadx[2]; - const float dzdy = quads[0]->posCoef->dady[2]; - const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; - struct softpipe_cached_tile *tile; - ushort (*depth16)[TILE_SIZE]; - ushort init_idepth[4], idepth[4], depth_step; - const float scale = 65535.0; - /* compute scaled depth of the four pixels in first quad */ - init_idepth[0] = (ushort)((z0) * scale); - init_idepth[1] = (ushort)((z0 + dzdx) * scale); - init_idepth[2] = (ushort)((z0 + dzdy) * scale); - init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); +#define NAME depth_interp_z16_less_write +#define OPERATOR < +#include "sp_quad_depth_test_tmp.h" - depth_step = (ushort)(dzdx * scale); +#define NAME depth_interp_z16_equal_write +#define OPERATOR == +#include "sp_quad_depth_test_tmp.h" - tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); +#define NAME depth_interp_z16_lequal_write +#define OPERATOR <= +#include "sp_quad_depth_test_tmp.h" - for (i = 0; i < nr; i++) { - const unsigned outmask = quads[i]->inout.mask; - const int dx = quads[i]->input.x0 - ix; - unsigned mask = 0; +#define NAME depth_interp_z16_greater_write +#define OPERATOR > +#include "sp_quad_depth_test_tmp.h" - /* compute depth for this quad */ - idepth[0] = init_idepth[0] + dx * depth_step; - idepth[1] = init_idepth[1] + dx * depth_step; - idepth[2] = init_idepth[2] + dx * depth_step; - idepth[3] = init_idepth[3] + dx * depth_step; - - depth16 = (ushort (*)[TILE_SIZE]) - &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; - - if ((outmask & 1) && idepth[0] < depth16[0][0]) { - depth16[0][0] = idepth[0]; - mask |= (1 << 0); - } - - if ((outmask & 2) && idepth[1] < depth16[0][1]) { - depth16[0][1] = idepth[1]; - mask |= (1 << 1); - } - - if ((outmask & 4) && idepth[2] < depth16[1][0]) { - depth16[1][0] = idepth[2]; - mask |= (1 << 2); - } - - if ((outmask & 8) && idepth[3] < depth16[1][1]) { - depth16[1][1] = idepth[3]; - mask |= (1 << 3); - } - - quads[i]->inout.mask = mask; - if (quads[i]->inout.mask) - quads[pass++] = quads[i]; - } - - if (pass) - qs->next->run(qs->next, quads, pass); - -} - - -/** - * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LEQUAL and - * Z buffer writes enabled. - * - * NOTE: there's no guarantee that the quads are sequentially side by - * side. The fragment shader may have culled some quads, etc. Sliver - * triangles may generate non-sequential quads. - */ -static void -depth_interp_z16_lequal_write(struct quad_stage *qs, - struct quad_header *quads[], - unsigned nr) -{ - unsigned i, pass = 0; - const unsigned ix = quads[0]->input.x0; - const unsigned iy = quads[0]->input.y0; - const float fx = (float) ix; - const float fy = (float) iy; - const float dzdx = quads[0]->posCoef->dadx[2]; - const float dzdy = quads[0]->posCoef->dady[2]; - const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; - struct softpipe_cached_tile *tile; - ushort (*depth16)[TILE_SIZE]; - ushort init_idepth[4], idepth[4], depth_step; - const float scale = 65535.0; - - /* compute scaled depth of the four pixels in first quad */ - init_idepth[0] = (ushort)((z0) * scale); - init_idepth[1] = (ushort)((z0 + dzdx) * scale); - init_idepth[2] = (ushort)((z0 + dzdy) * scale); - init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); - - depth_step = (ushort)(dzdx * scale); - - tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); - - for (i = 0; i < nr; i++) { - const unsigned outmask = quads[i]->inout.mask; - const int dx = quads[i]->input.x0 - ix; - unsigned mask = 0; - - /* compute depth for this quad */ - idepth[0] = init_idepth[0] + dx * depth_step; - idepth[1] = init_idepth[1] + dx * depth_step; - idepth[2] = init_idepth[2] + dx * depth_step; - idepth[3] = init_idepth[3] + dx * depth_step; - - depth16 = (ushort (*)[TILE_SIZE]) - &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; - - if ((outmask & 1) && idepth[0] <= depth16[0][0]) { - depth16[0][0] = idepth[0]; - mask |= (1 << 0); - } - - if ((outmask & 2) && idepth[1] <= depth16[0][1]) { - depth16[0][1] = idepth[1]; - mask |= (1 << 1); - } - - if ((outmask & 4) && idepth[2] <= depth16[1][0]) { - depth16[1][0] = idepth[2]; - mask |= (1 << 2); - } - - if ((outmask & 8) && idepth[3] <= depth16[1][1]) { - depth16[1][1] = idepth[3]; - mask |= (1 << 3); - } - - depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2]; - - quads[i]->inout.mask = mask; - if (quads[i]->inout.mask) - quads[pass++] = quads[i]; - } - - if (pass) - qs->next->run(qs->next, quads, pass); - -} +#define NAME depth_interp_z16_notequal_write +#define OPERATOR != +#include "sp_quad_depth_test_tmp.h" +#define NAME depth_interp_z16_gequal_write +#define OPERATOR >= +#include "sp_quad_depth_test_tmp.h" +#define NAME depth_interp_z16_always_write +#define ALWAYS 1 +#include "sp_quad_depth_test_tmp.h" @@ -926,6 +793,10 @@ choose_depth_test(struct quad_stage *qs, boolean occlusion = qs->softpipe->active_query_count; + /* default */ + qs->run = depth_test_quads_fallback; + + /* look for special cases */ if (!alpha && !depth && !stencil) { @@ -938,36 +809,40 @@ choose_depth_test(struct quad_stage *qs, !occlusion && !stencil) { - switch (depthfunc) { - case PIPE_FUNC_LESS: - switch (qs->softpipe->framebuffer.zsbuf->format) { - case PIPE_FORMAT_Z16_UNORM: + if (qs->softpipe->framebuffer.zsbuf->format == PIPE_FORMAT_Z16_UNORM) { + switch (depthfunc) { + case PIPE_FUNC_NEVER: + qs->run = depth_test_quads_fallback; + break; + case PIPE_FUNC_LESS: qs->run = depth_interp_z16_less_write; break; - default: - qs->run = depth_test_quads_fallback; + case PIPE_FUNC_EQUAL: + qs->run = depth_interp_z16_equal_write; break; - } - break; - case PIPE_FUNC_LEQUAL: - switch (qs->softpipe->framebuffer.zsbuf->format) { - case PIPE_FORMAT_Z16_UNORM: + case PIPE_FUNC_LEQUAL: qs->run = depth_interp_z16_lequal_write; break; + case PIPE_FUNC_GREATER: + qs->run = depth_interp_z16_greater_write; + break; + case PIPE_FUNC_NOTEQUAL: + qs->run = depth_interp_z16_notequal_write; + break; + case PIPE_FUNC_GEQUAL: + qs->run = depth_interp_z16_gequal_write; + break; + case PIPE_FUNC_ALWAYS: + qs->run = depth_interp_z16_always_write; + break; default: qs->run = depth_test_quads_fallback; break; } - break; - default: - qs->run = depth_test_quads_fallback; } } - else { - qs->run = depth_test_quads_fallback; - } - + /* next quad/fragment stage */ qs->run( qs, quads, nr ); } diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h b/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h new file mode 100644 index 00000000000..25af415c256 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h @@ -0,0 +1,147 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +/* + * Template for generating Z test functions + * Only PIPE_FORMAT_Z16_UNORM supported at this time. + */ + + +#ifndef NAME +#error "NAME is not defined!" +#endif + +#if !defined(OPERATOR) && !defined(ALWAYS) +#error "neither OPERATOR nor ALWAYS is defined!" +#endif + + +/* + * NOTE: there's no guarantee that the quads are sequentially side by + * side. The fragment shader may have culled some quads, etc. Sliver + * triangles may generate non-sequential quads. + */ +static void +NAME(struct quad_stage *qs, + struct quad_header *quads[], + unsigned nr) +{ + unsigned i, pass = 0; + const unsigned ix = quads[0]->input.x0; + const unsigned iy = quads[0]->input.y0; + const float fx = (float) ix; + const float fy = (float) iy; + const float dzdx = quads[0]->posCoef->dadx[2]; + const float dzdy = quads[0]->posCoef->dady[2]; + const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; + struct softpipe_cached_tile *tile; + ushort (*depth16)[TILE_SIZE]; + ushort init_idepth[4], idepth[4], depth_step; + const float scale = 65535.0; + + /* compute scaled depth of the four pixels in first quad */ + init_idepth[0] = (ushort)((z0) * scale); + init_idepth[1] = (ushort)((z0 + dzdx) * scale); + init_idepth[2] = (ushort)((z0 + dzdy) * scale); + init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); + + depth_step = (ushort)(dzdx * scale); + + tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); + + for (i = 0; i < nr; i++) { + const unsigned outmask = quads[i]->inout.mask; + const int dx = quads[i]->input.x0 - ix; + unsigned mask = 0; + + /* compute depth for this quad */ + idepth[0] = init_idepth[0] + dx * depth_step; + idepth[1] = init_idepth[1] + dx * depth_step; + idepth[2] = init_idepth[2] + dx * depth_step; + idepth[3] = init_idepth[3] + dx * depth_step; + + depth16 = (ushort (*)[TILE_SIZE]) + &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; + +#ifdef ALWAYS + if (outmask & 1) { + depth16[0][0] = idepth[0]; + mask |= (1 << 0); + } + + if (outmask & 2) { + depth16[0][1] = idepth[1]; + mask |= (1 << 1); + } + + if (outmask & 4) { + depth16[1][0] = idepth[2]; + mask |= (1 << 2); + } + + if (outmask & 8) { + depth16[1][1] = idepth[3]; + mask |= (1 << 3); + } +#else + /* Note: OPERATOR appears here: */ + if ((outmask & 1) && (idepth[0] OPERATOR depth16[0][0])) { + depth16[0][0] = idepth[0]; + mask |= (1 << 0); + } + + if ((outmask & 2) && (idepth[1] OPERATOR depth16[0][1])) { + depth16[0][1] = idepth[1]; + mask |= (1 << 1); + } + + if ((outmask & 4) && (idepth[2] OPERATOR depth16[1][0])) { + depth16[1][0] = idepth[2]; + mask |= (1 << 2); + } + + if ((outmask & 8) && (idepth[3] OPERATOR depth16[1][1])) { + depth16[1][1] = idepth[3]; + mask |= (1 << 3); + } +#endif + + depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2]; + + quads[i]->inout.mask = mask; + if (quads[i]->inout.mask) + quads[pass++] = quads[i]; + } + + if (pass) + qs->next->run(qs->next, quads, pass); +} + + +#undef NAME +#undef OPERATOR +#undef ALWAYS From ff54af530bc17429eda73a761dd6b73e3ec0d6ef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 09:08:35 -0600 Subject: [PATCH 292/483] softpipe: comments, re-formatting, etc --- .../drivers/softpipe/sp_quad_depth_test.c | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 5854cee1be0..17cd5b82072 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +19,7 @@ * 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS 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. @@ -26,7 +27,7 @@ **************************************************************************/ /** - * \brief Quad depth testing + * \brief Quad depth / stencil testing */ #include "pipe/p_defines.h" @@ -96,7 +97,9 @@ get_depth_stencil_values( struct depth_data *data, } } -/* If the shader has not been run, interpolate the depth values + +/** + * If the shader has not been run, interpolate the depth values * ourselves. */ static void @@ -115,6 +118,9 @@ interpolate_quad_depth( struct quad_header *quad ) } +/** + * Compute the depth_data::qzzzz[] values from the float fragment Z values. + */ static void convert_quad_depth( struct depth_data *data, const struct quad_header *quad ) @@ -173,6 +179,9 @@ convert_quad_depth( struct depth_data *data, +/** + * Write data->bzzzz[] values and data->stencilVals into the Z/stencil buffer. + */ static void write_depth_stencil_values( struct depth_data *data, struct quad_header *quad ) @@ -225,7 +234,6 @@ write_depth_stencil_values( struct depth_data *data, - /** Only 8-bit stencil supported */ #define STENCIL_MAX 0xff @@ -408,12 +416,11 @@ apply_stencil_op(struct depth_data *data, -/* +/** * To increase efficiency, we should probably have multiple versions * of this function that are specifically for Z16, Z32 and FP Z buffers. * Try to effectively do that with codegen... */ - static boolean depth_test_quad(struct quad_stage *qs, struct depth_data *data, @@ -523,7 +530,6 @@ depth_stencil_test_quad(struct quad_stage *qs, wrtMask = softpipe->depth_stencil->stencil[face].writemask; valMask = softpipe->depth_stencil->stencil[face].valuemask; - /* do the stencil test first */ { unsigned passMask, failMask; @@ -563,7 +569,7 @@ depth_stencil_test_quad(struct quad_stage *qs, #define ALPHATEST( FUNC, COMP ) \ - static int \ + static int \ alpha_test_quads_##FUNC( struct quad_stage *qs, \ struct quad_header *quads[], \ unsigned nr ) \ @@ -629,6 +635,7 @@ alpha_test_quads(struct quad_stage *qs, } } + static unsigned mask_count[16] = { 0, /* 0x0 */ @@ -665,6 +672,9 @@ get_depth_bits(struct quad_stage *qs) +/** + * General depth/stencil test function. Used when there's no fast-path. + */ static void depth_test_quads_fallback(struct quad_stage *qs, struct quad_header *quads[], @@ -712,7 +722,6 @@ depth_test_quads_fallback(struct quad_stage *qs, write_depth_stencil_values(&data, quads[i]); } - quads[pass++] = quads[i]; } @@ -848,22 +857,23 @@ choose_depth_test(struct quad_stage *qs, - - -static void depth_test_begin(struct quad_stage *qs) +static void +depth_test_begin(struct quad_stage *qs) { qs->run = choose_depth_test; qs->next->begin(qs->next); } -static void depth_test_destroy(struct quad_stage *qs) +static void +depth_test_destroy(struct quad_stage *qs) { FREE( qs ); } -struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe ) +struct quad_stage * +sp_quad_depth_test_stage(struct softpipe_context *softpipe) { struct quad_stage *stage = CALLOC_STRUCT(quad_stage); From ed29329b085c31c42d4c366b619222e5476e9b75 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 09:23:26 -0600 Subject: [PATCH 293/483] docs: update docs with 7.7.1 and 7.8 release info --- docs/news.html | 13 +++++++++++++ docs/relnotes-7.7.1.html | 14 +++++++------- docs/relnotes-7.8.html | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/news.html b/docs/news.html index 0a0be715c1b..a60d7a87d88 100644 --- a/docs/news.html +++ b/docs/news.html @@ -10,6 +10,19 @@

News

+ +

March 26, 2010

+

+Mesa 7.7.1 is released. This is a bug-fix +release fixing issues found in the 7.7 release. +

+

+Also, Mesa 7.8 is released. This is a new +development release. +

+ + +

December 21, 2009

Mesa 7.6.1 is released. This is a bug-fix diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html index c3d42c1d546..46f4cac5637 100644 --- a/docs/relnotes-7.7.1.html +++ b/docs/relnotes-7.7.1.html @@ -8,7 +8,7 @@ -

Mesa 7.7.1 Release Notes / date tbd

+

Mesa 7.7.1 Release Notes / March 26, 2010

Mesa 7.7.1 is a bug-fix release. @@ -30,12 +30,6 @@ tbd -

New features

-
    -
  • tbd -
- -

Bug fixes

  • Assorted fixes to VMware SVGA gallium driver. @@ -45,6 +39,12 @@ tbd
  • Gallium SSE codegen for XPD didn't always work.
  • Fixed Windows build.
  • Fixed broken glMultiDrawElements(). +
  • Silence bogus GL errors generated in glxinfo. +
  • Fixed several render to texture bugs. +
  • Assorted bug fixes in Mesa/Gallium state tracker including + glCopy/DrawPixels() to FBOs. +
  • Assorted fixes to Gallium drivers. +
  • Fixed broken glPush/PopClientAttrib() for vertex arrays in GLX code.
diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index ebe3d498b57..eaf3a8d54a0 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -8,7 +8,7 @@ -

Mesa 7.8 Release Notes / date TBD

+

Mesa 7.8 Release Notes / March 26, 2010

Mesa 7.8 is a new development release. From fff86eb0aab506fdfe3e956587d453c52ab07730 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 17:55:38 +0100 Subject: [PATCH 294/483] dri: use mv -f instead of mv to ensure no prompting occurs Using just mv may cause prompts on some systems/configurations. --- src/gallium/winsys/drm/Makefile.template | 2 +- src/mesa/drivers/dri/Makefile.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 9f984f1090c..7146e112d04 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -71,7 +71,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL @rm -f $@.test - mv $@.tmp $@ + mv -f $@.tmp $@ $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 2b7634bbf6c..15682b76ff1 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -56,7 +56,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL @rm -f $@.test - mv $@.tmp $@ + mv -f $@.tmp $@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) From 9f0e302cc792f21c6523a85c353e053f942cd035 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 17:40:42 +0100 Subject: [PATCH 295/483] st/mesa: make st_manager.c set have[Stencil|Depth]Buffer only if bits > 0 Fixes a segfault when clearing a non-existent stencil buffer. --- src/mesa/state_tracker/st_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index ca3a29cb2b8..cac62e4a14c 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -333,15 +333,15 @@ st_visual_to_context_mode(const struct st_visual *visual, } if (visual->depth_stencil_format != PIPE_FORMAT_NONE) { - mode->haveDepthBuffer = GL_TRUE; - mode->haveStencilBuffer = GL_TRUE; - mode->depthBits = util_format_get_component_bits(visual->depth_stencil_format, UTIL_FORMAT_COLORSPACE_ZS, 0); mode->stencilBits = util_format_get_component_bits(visual->depth_stencil_format, UTIL_FORMAT_COLORSPACE_ZS, 1); + + mode->haveDepthBuffer = mode->depthBits > 0; + mode->haveStencilBuffer = mode->stencilBits > 0; } if (visual->accum_format != PIPE_FORMAT_NONE) { From 208f5bf3cd8555f5b896c3e9d60c26f1bdb8683c Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 16:34:51 +0100 Subject: [PATCH 296/483] nvfx: delay allocation of buffers in GART/VRAM to validation time Currently we allocate buffers in GART or VRAM at creation time. However, when using swtnl, this results in reads from uncached memory, which drastically impair performance. So, for now, cause nouveau_screen.c to not pass any placement flags to buffer creation, so that the buffers are moved later. Previously libdrm itself did this, but was changed to not to do it. This may introduce an extra copy in normal usage, but this currently does not seem to introduce significant performance degradation. This will be revisited when pipebuffer is integrated. Note that for AGP systems, properly solving this may be complex since currently there is no fast way of reading from GART/VRAM. We will probably need to try mapping AGP as writethrough and, in addition, make buffer creation more aware of future buffer usage. --- src/gallium/drivers/nvfx/nvfx_screen.c | 6 ++---- src/gallium/drivers/nvfx/nvfx_vbo.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index 8138715cc7d..6cbd8b23e1f 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -68,11 +68,9 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, int param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: return !!screen->is_nv4x; case NOUVEAU_CAP_HW_VTXBUF: - /* TODO: this is almost surely wrong */ - return !!screen->is_nv4x; + return 0; case NOUVEAU_CAP_HW_IDXBUF: - /* TODO: this is also almost surely wrong */ - return screen->is_nv4x && screen->eng3d->grclass == NV40TCL; + return 0; case PIPE_CAP_MAX_COMBINED_SAMPLERS: return 16; case PIPE_CAP_INDEP_BLEND_ENABLE: diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c index 257087f8f63..db47acb9502 100644 --- a/src/gallium/drivers/nvfx/nvfx_vbo.c +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c @@ -495,7 +495,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx) struct nouveau_grobj *eng3d = nvfx->screen->eng3d; struct pipe_buffer *ib = nvfx->idxbuf; unsigned ib_format = nvfx->idxbuf_format; - unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + unsigned vb_flags = NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; vtxbuf = so_new(3, 17, 18); From 3428a305150e98c8002e0fb339f5667c5533c0d1 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Mon, 11 Jan 2010 03:13:42 +0100 Subject: [PATCH 297/483] nvfx: add NOUVEAU_VTXIDX_IN_VRAM variable to put vertex/index buffers in VRAM On some systems, putting vertex and index buffers in VRAM instead of GART memory eliminates massive graphics corruption which is otherwise present, due to unclear causes. This patch adds an environment variable that does that, along with helpful messages. It turns it on by default on G7x, as it is what I am seeing corruption on and some other reports also seemed to pinpoint these cards. --- src/gallium/drivers/nvfx/nvfx_screen.c | 31 ++++++++++++++++++++++++++ src/gallium/drivers/nvfx/nvfx_screen.h | 1 + src/gallium/drivers/nvfx/nvfx_vbo.c | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index 6cbd8b23e1f..f7f39218944 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -293,6 +293,36 @@ static void nv40_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj so_data (so, 0x00000001); } +static void +nvfx_screen_init_buffer_functions(struct nvfx_screen* screen) +{ + int vram_hack_default = 0; + int vram_hack; + // TODO: this is a bit of a guess; also add other cards that may need this hack. + // It may also depend on the specific card or the AGP/PCIe chipset. + if(screen->base.device->chipset == 0x47 /* G70 */ + || screen->base.device->chipset == 0x49 /* G71 */ + || screen->base.device->chipset == 0x46 /* G72 */ + ) + vram_hack_default = 1; + vram_hack = debug_get_bool_option("NOUVEAU_VTXIDX_IN_VRAM", vram_hack_default); + +#ifdef DEBUG + if(!vram_hack) + { + fprintf(stderr, "Some systems may experience graphics corruption due to randomly misplaced vertices.\n" + "If this is happening, export NOUVEAU_VTXIDX_IN_VRAM=1 may reduce or eliminate the problem\n"); + } + else + { + fprintf(stderr, "A performance reducing hack is being used to help avoid graphics corruption.\n" + "You can try export NOUVEAU_VTXIDX_IN_VRAM=0 to disable it.\n"); + } +#endif + + screen->vertex_buffer_flags = vram_hack ? NOUVEAU_BO_VRAM : NOUVEAU_BO_GART; +} + struct pipe_screen * nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { @@ -350,6 +380,7 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) return NULL; } + nvfx_screen_init_buffer_functions(screen); nvfx_screen_init_miptree_functions(pscreen); ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d); diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h index c0b4b9899dd..baa848c47aa 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.h +++ b/src/gallium/drivers/nvfx/nvfx_screen.h @@ -12,6 +12,7 @@ struct nvfx_screen { struct nvfx_context *cur_ctx; unsigned is_nv4x; /* either 0 or ~0 */ + int vertex_buffer_flags; /* HW graphics objects */ struct nv04_surface_2d *eng2d; diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c index db47acb9502..c26536b0e77 100644 --- a/src/gallium/drivers/nvfx/nvfx_vbo.c +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c @@ -495,7 +495,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx) struct nouveau_grobj *eng3d = nvfx->screen->eng3d; struct pipe_buffer *ib = nvfx->idxbuf; unsigned ib_format = nvfx->idxbuf_format; - unsigned vb_flags = NOUVEAU_BO_GART | NOUVEAU_BO_RD; + unsigned vb_flags = nvfx->screen->vertex_buffer_flags | NOUVEAU_BO_RD; int hw; vtxbuf = so_new(3, 17, 18); From 57edf6b1fc6d126821f9395b35a27462c3d94202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 23 Mar 2010 12:07:45 -0400 Subject: [PATCH 298/483] mesa: Also print _NEW_STENCIL in _mesa_print_state() --- src/mesa/main/debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 33b35e03c79..9bcfc1008a8 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -85,7 +85,7 @@ void _mesa_print_state( const char *msg, GLuint state ) { _mesa_debug(NULL, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", msg, state, (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "", @@ -105,6 +105,7 @@ _mesa_print_state( const char *msg, GLuint state ) (state & _NEW_POLYGON) ? "ctx->Polygon, " : "", (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "", (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "", + (state & _NEW_STENCIL) ? "ctx->Stencil, " : "", (state & _NEW_TEXTURE) ? "ctx->Texture, " : "", (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "", (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "", From 3d99e990c078f3e1096e7d09bc686643e71d5681 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:52:06 -0700 Subject: [PATCH 299/483] i965: Stop abusing ctx->NewState flags for storing driver internal changes. We're still abusing the flags by putting them where our driver stores ctx->NewState changes. Making them into more restricted state change flags would be a project for later. Fixes a failure where calling intel_draw_buffer() too often would trip up Mesa assertions about when Mesa state could get changed, when it hadn't. Bug #27034. --- src/mesa/drivers/dri/intel/intel_buffers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index b10693050a9..0480770ba1d 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -226,7 +226,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) * only changes with _NEW_STENCIL (which seems sensible). So flag it * here since this is the _NEW_BUFFERS path. */ - ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL); + intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL); } intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, @@ -236,7 +236,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) #ifdef I915 intelCalcViewport(ctx); #else - ctx->NewState |= _NEW_VIEWPORT; + intel->NewGLState |= _NEW_VIEWPORT; #endif /* Set state we know depends on drawable parameters: */ @@ -256,7 +256,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) if (ctx->Driver.FrontFace) ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); else - ctx->NewState |= _NEW_POLYGON; + intel->NewGLState |= _NEW_POLYGON; } From ba5a53edd12fac24c176e714560b1f9ec255bbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 23 Mar 2010 15:47:49 -0400 Subject: [PATCH 300/483] dri: Add $(DRI_LIB_DEPS) when linking the test binary This will make sure we pick up libdrm_$(chipset).so from the right place. --- src/gallium/winsys/drm/Makefile.template | 2 +- src/mesa/drivers/dri/Makefile.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 7146e112d04..8c16094688c 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -69,7 +69,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL @rm -f $@.test mv -f $@.tmp $@ diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 15682b76ff1..cd800e5e017 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -54,7 +54,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) - $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp -L$(TOP)/lib -lGL + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL @rm -f $@.test mv -f $@.tmp $@ From 516334b7fff5e0167d3f3fbcd15de08b5ca89747 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:52:06 -0700 Subject: [PATCH 301/483] i965: Stop abusing ctx->NewState flags for storing driver internal changes. We're still abusing the flags by putting them where our driver stores ctx->NewState changes. Making them into more restricted state change flags would be a project for later. Fixes a failure where calling intel_draw_buffer() too often would trip up Mesa assertions about when Mesa state could get changed, when it hadn't. Bug #27034. --- src/mesa/drivers/dri/intel/intel_buffers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index b10693050a9..0480770ba1d 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -226,7 +226,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) * only changes with _NEW_STENCIL (which seems sensible). So flag it * here since this is the _NEW_BUFFERS path. */ - ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL); + intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL); } intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, @@ -236,7 +236,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) #ifdef I915 intelCalcViewport(ctx); #else - ctx->NewState |= _NEW_VIEWPORT; + intel->NewGLState |= _NEW_VIEWPORT; #endif /* Set state we know depends on drawable parameters: */ @@ -256,7 +256,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) if (ctx->Driver.FrontFace) ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); else - ctx->NewState |= _NEW_POLYGON; + intel->NewGLState |= _NEW_POLYGON; } From e725ef171b5a4d5425461f237d9ccab223806913 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Mon, 15 Mar 2010 20:53:56 -0700 Subject: [PATCH 302/483] Change libX11 variables to not conflict with AC_PATH_XTRA The variable X_LIBS from AC_PATH_XTRA contains only the -L searchdir parameter and not the -lX11 to link to Xlib. Use X11 prefixed build vars for linking with Xlib to avoid the conflict. Signed-off-by: Dan Nicholson --- configs/autoconf.in | 4 ++-- configure.ac | 6 +++++- progs/egl/Makefile | 6 +++--- progs/xdemos/Makefile | 2 +- src/gallium/state_trackers/glx/xlib/Makefile | 2 +- src/gallium/winsys/xlib/Makefile | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/configs/autoconf.in b/configs/autoconf.in index f50fb7dd093..66c1ee48e87 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -24,8 +24,8 @@ RADEON_CFLAGS = @RADEON_CFLAGS@ RADEON_LDFLAGS = @RADEON_LDFLAGS@ INTEL_LIBS = @INTEL_LIBS@ INTEL_CFLAGS = @INTEL_CFLAGS@ -X_LIBS = @X_LIBS@ -X_CFLAGS = @X_CFLAGS@ +X11_LIBS = @X11_LIBS@ +X11_CFLAGS = @X11_CFLAGS@ # Assembler MESA_ASM_SOURCES = @MESA_ASM_SOURCES@ diff --git a/configure.ac b/configure.ac index 0f51097ef62..26960e85ea4 100644 --- a/configure.ac +++ b/configure.ac @@ -548,9 +548,13 @@ else fi dnl Use the autoconf macro if no pkg-config files if test "$x11_pkgconfig" = yes; then - PKG_CHECK_MODULES([X], [x11]) + PKG_CHECK_MODULES([X11], [x11]) else AC_PATH_XTRA + test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS" + test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11" + AC_SUBST([X11_CFLAGS]) + AC_SUBST([X11_LIBS]) fi dnl Try to tell the user that the --x-* options are only used when diff --git a/progs/egl/Makefile b/progs/egl/Makefile index 5f51104fed6..8dfcb4eabcb 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -57,13 +57,13 @@ peglgears: peglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -lm xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) xeglthreads: xeglthreads.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) xegl_tri: xegl_tri.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) clean: -rm -f *.o *~ diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index f81aafe00f6..660c540657a 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -9,7 +9,7 @@ INCDIR = $(TOP)/include LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) # Add X11 and pthread libs to satisfy GNU gold. -APP_LIB_DEPS += $(X_LIBS) -lpthread +APP_LIB_DEPS += $(X11_LIBS) -lpthread LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS) diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile index 582e72bb463..35509fd708b 100644 --- a/src/gallium/state_trackers/glx/xlib/Makefile +++ b/src/gallium/state_trackers/glx/xlib/Makefile @@ -6,7 +6,7 @@ LIBNAME = xlib LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - $(X_CFLAGS) + $(X11_CFLAGS) C_SOURCES = \ glx_api.c \ diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 18357a41127..83d53c59542 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -7,7 +7,7 @@ LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/gallium/auxiliary \ - $(X_CFLAGS) + $(X11_CFLAGS) C_SOURCES = \ xlib_sw_winsys.c From 7e246e6aa63979d53731a591f4caee3651c1d96b Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 21:10:07 +0100 Subject: [PATCH 303/483] dri: make unresolved symbol test link work even without a libGL.so Currently the test link uses -lGL to define the glapi symbols. This makes it impossible to build DRI drivers on systems without Mesa installed and without building the libGL from the Mesa tree first. Some automated build systems trigger this problem. This commit removes -lGL and instead adds a dummy implementation of glapi to dri_test.c This, along with Kristian's commit, should fix all known regressions due to the addition of unresolved symbol checking. --- src/gallium/winsys/drm/Makefile.template | 2 +- src/mesa/drivers/dri/Makefile.template | 2 +- src/mesa/drivers/dri/common/dri_test.c | 68 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 8c16094688c..6d9b81aa249 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -69,7 +69,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) @rm -f $@.test mv -f $@.tmp $@ diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index cd800e5e017..f19cc039b22 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -54,7 +54,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) - $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL + $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) @rm -f $@.test mv -f $@.tmp $@ diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index cf59b2b7378..f55ec6d52be 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -1,8 +1,76 @@ +#include "main/glheader.h" +#include "main/compiler.h" +#include "glapi/glapi.h" + /* This is just supposed to make sure we get a reference to the driver entry symbol that the compiler doesn't optimize away */ extern char __driDriverExtensions[]; +/* provide glapi symbols */ + +#if defined(GLX_USE_TLS) + +PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch + __attribute__((tls_model("initial-exec"))); + +PUBLIC __thread void * _glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +#endif + +PUBLIC const struct _glapi_table *_glapi_Dispatch; +PUBLIC const void *_glapi_Context; + +PUBLIC void +_glapi_check_multithread(void) +{} + +PUBLIC void +_glapi_set_context(void *context) +{} + +PUBLIC void * +_glapi_get_context(void) +{ + return 0; +} + +PUBLIC void +_glapi_set_dispatch(struct _glapi_table *dispatch) +{} + +PUBLIC struct _glapi_table * +_glapi_get_dispatch(void) +{ + return 0; +} + +PUBLIC int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ) +{ + return 0; +} + +PUBLIC GLint +_glapi_get_proc_offset(const char *funcName) +{ + return 0; +} + +PUBLIC _glapi_proc +_glapi_get_proc_address(const char *funcName) +{ + return 0; +} + +PUBLIC GLuint +_glapi_get_dispatch_table_size(void) +{ + return 0; +} + int main(int argc, char** argv) { void* p = __driDriverExtensions; From 5f229547a525554ded621f4f245e22c9090e9205 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 22:57:25 +0100 Subject: [PATCH 304/483] dri: add _glthread_GetID to dri_test.c dummy glapi --- src/mesa/drivers/dri/common/dri_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index f55ec6d52be..6013c02ac5b 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -71,6 +71,12 @@ _glapi_get_dispatch_table_size(void) return 0; } +PUBLIC unsigned long +_glthread_GetID(void) +{ + return 0; +} + int main(int argc, char** argv) { void* p = __driDriverExtensions; From 3790199e041236ab8db1effaba2922e10b8b81ac Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 22:59:44 +0100 Subject: [PATCH 305/483] dri: fix dri_test.c for non-TLS build _glapi_Context and _glapi_Dispatch have different constness between TLS and non-TLS builds. --- src/mesa/drivers/dri/common/dri_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index 6013c02ac5b..793f0c37d79 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -17,11 +17,16 @@ PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch PUBLIC __thread void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); -#endif - PUBLIC const struct _glapi_table *_glapi_Dispatch; PUBLIC const void *_glapi_Context; +#else + +PUBLIC struct _glapi_table *_glapi_Dispatch; +PUBLIC void *_glapi_Context; + +#endif + PUBLIC void _glapi_check_multithread(void) {} From 2d84d58975187639291d8f02faa02ffc83b5c195 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 11:46:02 -0600 Subject: [PATCH 306/483] glslcompiler: added option to do linking of vert/frag shaders --- src/mesa/drivers/glslcompiler/glslcompiler.c | 51 +++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index 66035a4a43c..d58f32b2930 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -68,6 +68,7 @@ static const char *Prog = "glslcompiler"; struct options { GLboolean LineNumbers; + GLboolean Link; gl_prog_print_mode Mode; const char *VertFile; const char *FragFile; @@ -207,23 +208,29 @@ ReadShader(GLuint shader, const char *filename) } -#if 0 static void -CheckLink(GLuint prog) +CheckLink(GLuint v_shader, GLuint f_shader) { + GLuint prog; GLint stat; + + prog = _mesa_CreateProgram(); + + _mesa_AttachShader(prog, v_shader); + _mesa_AttachShader(prog, f_shader); + + _mesa_LinkProgramARB(prog); _mesa_GetProgramiv(prog, GL_LINK_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; _mesa_GetProgramInfoLog(prog, 1000, &len, log); - fprintf(stderr, "%s: Linker error:\n%s\n", Prog, log); + fprintf(stderr, "Linker error:\n%s\n", log); } else { - fprintf(stderr, "%s: Link success!\n", Prog); + fprintf(stderr, "Link success!\n"); } } -#endif static void @@ -262,6 +269,7 @@ Usage(void) printf(" --fs FILE fragment shader input filename\n"); printf(" --arb emit ARB-style instructions\n"); printf(" --nv emit NV-style instructions\n"); + printf(" --link run linker\n"); printf(" --debug force #pragma debug(on)\n"); printf(" --nodebug force #pragma debug(off)\n"); printf(" --opt force #pragma optimize(on)\n"); @@ -309,6 +317,9 @@ ParseOptions(int argc, char *argv[]) else if (strcmp(argv[i], "--nv") == 0) { Options.Mode = PROG_PRINT_NV; } + else if (strcmp(argv[i], "--link") == 0) { + Options.Link = GL_TRUE; + } else if (strcmp(argv[i], "--debug") == 0) { Options.Pragmas.IgnoreDebug = GL_TRUE; Options.Pragmas.Debug = GL_TRUE; @@ -358,7 +369,7 @@ ParseOptions(int argc, char *argv[]) int main(int argc, char *argv[]) { - GLuint shader = 0; + GLuint v_shader = 0, f_shader = 0; ParseOptions(argc, argv); @@ -368,24 +379,38 @@ main(int argc, char *argv[]) } if (Options.VertFile) { - shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); - } - else if (Options.FragFile) { - shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); + v_shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); } - if (shader) { + if (Options.FragFile) { + f_shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); + } + + if (v_shader || f_shader) { if (Options.OutputFile) { fclose(stdout); /*stdout =*/ freopen(Options.OutputFile, "w", stdout); } - if (stdout) { - PrintShaderInstructions(shader, stdout); + if (stdout && v_shader) { + PrintShaderInstructions(v_shader, stdout); + } + if (stdout && f_shader) { + PrintShaderInstructions(f_shader, stdout); } if (Options.OutputFile) { fclose(stdout); } } + if (Options.Link) { + if (!v_shader || !f_shader) { + fprintf(stderr, + "--link option requires both a vertex and fragment shader.\n"); + exit(1); + } + + CheckLink(v_shader, f_shader); + } + return 0; } From 8ba47561dd45e1cd737992544545d7fa0f61918b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 17:22:43 -0600 Subject: [PATCH 307/483] st/glx: add support for multiple displays This is a quick & dirty solution, but it works. See comments in the code for other ideas. Fixes regressions/breakage seen in progs/xdemos/glxheads, etc. from commit 6632915e957149c153a3f793c400a532b4995b18. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 30 +++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 8dd54206af2..3022d45157a 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -78,17 +78,39 @@ void xmesa_set_driver( const struct xm_driver *templ ) stapi = driver.create_st_api(); } + +/* + * XXX replace this with a linked list, or better yet, try to attach the + * gallium/mesa extra bits to the X Display object with XAddExtension(). + */ +#define MAX_DISPLAYS 10 +static struct xmesa_display Displays[MAX_DISPLAYS]; +static int NumDisplays = 0; + + static XMesaDisplay xmesa_init_display( Display *display ) { pipe_static_mutex(init_mutex); - static struct xmesa_display xm_display; XMesaDisplay xmdpy; - + int i; + pipe_mutex_lock(init_mutex); - /* TODO support for multiple displays */ - xmdpy = &xm_display; + /* Look for XMesaDisplay which corresponds to 'display' */ + for (i = 0; i < NumDisplays; i++) { + if (Displays[i].display == display) { + /* Found it */ + pipe_mutex_unlock(init_mutex); + return &Displays[i]; + } + } + + /* Create new XMesaDisplay */ + + assert(NumDisplays < MAX_DISPLAYS); + xmdpy = &Displays[NumDisplays]; + NumDisplays++; if (!xmdpy->display && display) { xmdpy->display = display; From 2b5de09b3ea8754fb004d4f216bca29303f99490 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 17:55:41 -0600 Subject: [PATCH 308/483] swrast: improve depth texture mipmap selection We still don't do proper min/mag filtering but this is better than just sampling the base mipmap level all the time. Fixes piglit depth-level-clamp test. Fixes fd.o bug 27256. --- src/mesa/swrast/s_texfilter.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 997c2f4bb79..3fc554c5a20 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -488,14 +488,15 @@ tex_array_slice(GLfloat coord, GLsizei size) /** * Compute nearest integer texcoords for given texobj and coordinate. + * NOTE: only used for depth texture sampling. */ static INLINE void nearest_texcoord(const struct gl_texture_object *texObj, + GLuint level, const GLfloat texcoord[4], GLint *i, GLint *j, GLint *k) { - const GLint baseLevel = texObj->BaseLevel; - const struct gl_texture_image *img = texObj->Image[0][baseLevel]; + const struct gl_texture_image *img = texObj->Image[0][level]; const GLint width = img->Width; const GLint height = img->Height; const GLint depth = img->Depth; @@ -534,15 +535,16 @@ nearest_texcoord(const struct gl_texture_object *texObj, /** * Compute linear integer texcoords for given texobj and coordinate. + * NOTE: only used for depth texture sampling. */ static INLINE void linear_texcoord(const struct gl_texture_object *texObj, + GLuint level, const GLfloat texcoord[4], GLint *i0, GLint *i1, GLint *j0, GLint *j1, GLint *slice, GLfloat *wi, GLfloat *wj) { - const GLint baseLevel = texObj->BaseLevel; - const struct gl_texture_image *img = texObj->Image[0][baseLevel]; + const struct gl_texture_image *img = texObj->Image[0][level]; const GLint width = img->Width; const GLint height = img->Height; const GLint depth = img->Depth; @@ -2963,7 +2965,26 @@ shadow_compare4(GLenum function, GLfloat coord, /** - * Sample a shadow/depth texture. + * Choose the mipmap level to use when sampling from a depth texture. + */ +static int +choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda) +{ + GLint level; + + lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod); + + level = (GLint) lambda; + + level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel); + + return level; +} + + +/** + * Sample a shadow/depth texture. This function is incomplete. It doesn't + * check for minification vs. magnification, etc. */ static void sample_depth_texture( GLcontext *ctx, @@ -2971,8 +2992,8 @@ sample_depth_texture( GLcontext *ctx, const GLfloat texcoords[][4], const GLfloat lambda[], GLfloat texel[][4] ) { - const GLint baseLevel = tObj->BaseLevel; - const struct gl_texture_image *img = tObj->Image[0][baseLevel]; + const GLint level = choose_depth_texture_level(tObj, lambda[0]); + const struct gl_texture_image *img = tObj->Image[0][level]; const GLint width = img->Width; const GLint height = img->Height; const GLint depth = img->Depth; @@ -2982,8 +3003,6 @@ sample_depth_texture( GLcontext *ctx, GLenum function; GLfloat result; - (void) lambda; - ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT || img->_BaseFormat == GL_DEPTH_STENCIL_EXT); @@ -3006,7 +3025,7 @@ sample_depth_texture( GLcontext *ctx, GLfloat depthSample; GLint col, row, slice; - nearest_texcoord(tObj, texcoords[i], &col, &row, &slice); + nearest_texcoord(tObj, level, texcoords[i], &col, &row, &slice); if (col >= 0 && row >= 0 && col < width && row < height && slice >= 0 && slice < depth) { @@ -3044,7 +3063,7 @@ sample_depth_texture( GLcontext *ctx, GLfloat wi, wj; GLuint useBorderTexel; - linear_texcoord(tObj, texcoords[i], &i0, &i1, &j0, &j1, &slice, + linear_texcoord(tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice, &wi, &wj); useBorderTexel = 0; From 99386921e778271c9b3edf90123ab6319e23fc95 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 24 Mar 2010 08:34:39 +0800 Subject: [PATCH 309/483] progs/egl: Link xeglthreads to libpthread. This should hopefully fix a build failure reported by Chris Ball when binutils-gold is used. --- progs/egl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/egl/Makefile b/progs/egl/Makefile index 8dfcb4eabcb..890240f9a38 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -60,7 +60,7 @@ xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) xeglthreads: xeglthreads.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lpthread -lm $(X11_LIBS) xegl_tri: xegl_tri.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS) From f66d70b930e2a5026b0d6d7bdb047a2a78a10d7a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 08:16:25 -0600 Subject: [PATCH 310/483] st/mesa: return GL_TRUE/GL_FALSE if return type is GLboolean Just to be consistent. --- src/mesa/state_tracker/st_cb_clear.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index de86062fc40..27775059fa6 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -316,15 +316,15 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) ctx->Scissor.Y != 0 || ctx->Scissor.Width < rb->Width || ctx->Scissor.Height < rb->Height)) - return TRUE; + return GL_TRUE; if (!ctx->Color.ColorMask[0][0] || !ctx->Color.ColorMask[0][1] || !ctx->Color.ColorMask[0][2] || !ctx->Color.ColorMask[0][3]) - return TRUE; + return GL_TRUE; - return FALSE; + return GL_FALSE; } @@ -344,12 +344,12 @@ check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) ctx->Scissor.Y != 0 || ctx->Scissor.Width < rb->Width || ctx->Scissor.Height < rb->Height)) - return TRUE; + return GL_TRUE; if (maskStencil) - return TRUE; + return GL_TRUE; - return FALSE; + return GL_FALSE; } @@ -367,13 +367,13 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) ctx->Scissor.Y != 0 || ctx->Scissor.Width < rb->Width || ctx->Scissor.Height < rb->Height)) - return TRUE; + return GL_TRUE; if (isDS && ctx->DrawBuffer->Visual.stencilBits > 0) - return TRUE; + return GL_TRUE; - return FALSE; + return GL_FALSE; } @@ -394,14 +394,14 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) rb->Format == MESA_FORMAT_S8_Z24); if (maskStencil) - return TRUE; + return GL_TRUE; if (ctx->Scissor.Enabled && (ctx->Scissor.X != 0 || ctx->Scissor.Y != 0 || ctx->Scissor.Width < rb->Width || ctx->Scissor.Height < rb->Height)) - return TRUE; + return GL_TRUE; /* This is correct, but it is necessary to look at the depth clear * value held in the surface when it comes time to issue the clear, @@ -410,9 +410,9 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) */ if (isDS && ctx->DrawBuffer->Visual.depthBits > 0) - return TRUE; + return GL_TRUE; - return FALSE; + return GL_FALSE; } @@ -430,8 +430,6 @@ void st_flush_clear( struct st_context *st ) /** * Called via ctx->Driver.Clear() - * XXX: doesn't pick up the differences between front/back/left/right - * clears. Need to sort that out... */ static void st_clear(GLcontext *ctx, GLbitfield mask) { From 3374b26f52313f629b69876bbca30845fb78b371 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 08:18:13 -0600 Subject: [PATCH 311/483] st/mesa: rename st_clear() to st_Clear() To be consistent with other Mesa driver functions. --- src/mesa/state_tracker/st_cb_clear.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 27775059fa6..08c3e08097b 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -431,7 +431,7 @@ void st_flush_clear( struct st_context *st ) /** * Called via ctx->Driver.Clear() */ -static void st_clear(GLcontext *ctx, GLbitfield mask) +static void st_Clear(GLcontext *ctx, GLbitfield mask) { static const GLbitfield BUFFER_BITS_DS = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); @@ -528,5 +528,5 @@ static void st_clear(GLcontext *ctx, GLbitfield mask) void st_init_clear_functions(struct dd_function_table *functions) { - functions->Clear = st_clear; + functions->Clear = st_Clear; } From ab93f8d0679d1f2a116b98831fc4967a2b707b3a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 08:25:24 -0600 Subject: [PATCH 312/483] st/mesa: code clean-ups, formatting fixes, comments, etc --- src/mesa/state_tracker/st_cb_clear.c | 47 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 08c3e08097b..6007c767182 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -47,16 +47,19 @@ #include "st_inlines.h" #include "pipe/p_context.h" -#include "util/u_inlines.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_format.h" +#include "util/u_inlines.h" #include "util/u_simple_shaders.h" #include "util/u_draw_quad.h" #include "cso_cache/cso_context.h" +/** + * Do per-context initialization for glClear. + */ void st_init_clear(struct st_context *st) { @@ -67,8 +70,7 @@ st_init_clear(struct st_context *st) st->clear.raster.gl_rasterization_rules = 1; /* fragment shader state: color pass-through program */ - st->clear.fs = - util_make_fragment_passthrough_shader(pipe); + st->clear.fs = util_make_fragment_passthrough_shader(pipe); /* vertex shader state: color/position pass-through */ { @@ -82,6 +84,9 @@ st_init_clear(struct st_context *st) } +/** + * Free per-context state for glClear. + */ void st_destroy_clear(struct st_context *st) { @@ -131,7 +136,8 @@ draw_quad(GLcontext *ctx, } if (!st->clear.vbuf) { - st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, + st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, + PIPE_BUFFER_USAGE_VERTEX, max_slots * sizeof(st->clear.vertices)); } @@ -160,7 +166,8 @@ draw_quad(GLcontext *ctx, /* put vertex data into vbuf */ st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf, - st->clear.vbuf_slot * sizeof(st->clear.vertices), + st->clear.vbuf_slot + * sizeof(st->clear.vertices), sizeof(st->clear.vertices), st->clear.vertices); @@ -289,7 +296,8 @@ clear_with_quad(GLcontext *ctx, cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); + draw_quad(ctx, x0, y0, x1, y1, + (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ cso_restore_blend(st->cso_context); @@ -301,7 +309,6 @@ clear_with_quad(GLcontext *ctx, cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); cso_restore_vertex_elements(st->cso_context); - } @@ -328,6 +335,10 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) } +/** + * Determine if we need to clear the combiend depth/stencil buffer by + * drawing a quad. + */ static INLINE GLboolean check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) { @@ -369,8 +380,7 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) ctx->Scissor.Height < rb->Height)) return GL_TRUE; - if (isDS && - ctx->DrawBuffer->Visual.stencilBits > 0) + if (isDS && ctx->DrawBuffer->Visual.stencilBits > 0) return GL_TRUE; return GL_FALSE; @@ -408,8 +418,7 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) * rather than taking depth and stencil clear values from the * current state. */ - if (isDS && - ctx->DrawBuffer->Visual.depthBits > 0) + if (isDS && ctx->DrawBuffer->Visual.depthBits > 0) return GL_TRUE; return GL_FALSE; @@ -417,7 +426,11 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) -void st_flush_clear( struct st_context *st ) +/** + * Called when we need to flush. + */ +void +st_flush_clear(struct st_context *st) { /* Release vertex buffer to avoid synchronous rendering if we were * to map it in the next frame. @@ -431,7 +444,8 @@ void st_flush_clear( struct st_context *st ) /** * Called via ctx->Driver.Clear() */ -static void st_Clear(GLcontext *ctx, GLbitfield mask) +static void +st_Clear(GLcontext *ctx, GLbitfield mask) { static const GLbitfield BUFFER_BITS_DS = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); @@ -440,8 +454,8 @@ static void st_Clear(GLcontext *ctx, GLbitfield mask) = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *stencilRb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - GLbitfield quad_buffers = 0; - GLbitfield clear_buffers = 0; + GLbitfield quad_buffers = 0x0; + GLbitfield clear_buffers = 0x0; GLuint i; /* This makes sure the pipe has the latest scissor, etc values */ @@ -526,7 +540,8 @@ static void st_Clear(GLcontext *ctx, GLbitfield mask) } -void st_init_clear_functions(struct dd_function_table *functions) +void +st_init_clear_functions(struct dd_function_table *functions) { functions->Clear = st_Clear; } From 2d6befd9d1e8dcf6495fe1b9cef12224046f3095 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 08:34:26 -0600 Subject: [PATCH 313/483] st/mesa: fix sampler_view destruction bug when texture is shared Since texture's can be shared by many contexts, the texture's sampler view's context pointer might be invalid by time we delete the texture. Prevent crashes/etc by setting the sampler view's context to be the calling context before deleting it. This should be safe as long as all contexts which share the texture are using the same gallium driver. That's a reasonable assumption since pipe_texture objects aren't compatible between different drivers anyway. --- src/mesa/state_tracker/st_cb_texture.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index d7a774aa409..bda17cdc92f 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -124,9 +124,17 @@ st_DeleteTextureObject(GLcontext *ctx, struct st_texture_object *stObj = st_texture_object(texObj); if (stObj->pt) pipe_texture_reference(&stObj->pt, NULL); - if (stObj->sampler_view) + if (stObj->sampler_view) { + if (stObj->sampler_view->context != ctx->st->pipe) { + /* Take "ownership" of this texture sampler view by setting + * its context pointer to this context. This avoids potential + * crashes when the texture object is shared among contexts + * and the original/owner context has already been destroyed. + */ + stObj->sampler_view->context == ctx->st->pipe; + } pipe_sampler_view_reference(&stObj->sampler_view, NULL); - + } _mesa_delete_texture_object(ctx, texObj); } From e71c1589d8e5ab3c81b0fc04f4720c74849c4f15 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 09:00:48 -0600 Subject: [PATCH 314/483] st/mesa: fix typo in prev commit --- src/mesa/state_tracker/st_cb_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index bda17cdc92f..8cdd3ff2ae2 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -131,7 +131,7 @@ st_DeleteTextureObject(GLcontext *ctx, * crashes when the texture object is shared among contexts * and the original/owner context has already been destroyed. */ - stObj->sampler_view->context == ctx->st->pipe; + stObj->sampler_view->context = ctx->st->pipe; } pipe_sampler_view_reference(&stObj->sampler_view, NULL); } From 4e328774d49629fc4bf8960669bdfdab7bb80466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?RALOVICH=2C=20Krist=C3=B3f?= Date: Tue, 23 Mar 2010 21:48:15 -0400 Subject: [PATCH 315/483] demos: import GLSL raytracing demos --- progs/glsl/Makefile | 4 +- progs/glsl/fsraytrace.c | 385 ++++++++++++++++++++++++++++++++++++++++ progs/glsl/vsraytrace.c | 363 +++++++++++++++++++++++++++++++++++++ 3 files changed, 751 insertions(+), 1 deletion(-) create mode 100644 progs/glsl/fsraytrace.c create mode 100644 progs/glsl/vsraytrace.c diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 3b5a5959aee..6030c8002f5 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -26,6 +26,7 @@ PROG_SOURCES = \ convolutions.c \ deriv.c \ fragcoord.c \ + fsraytrace.c \ identity.c \ linktest.c \ mandelbrot.c \ @@ -46,7 +47,8 @@ PROG_SOURCES = \ trirast.c \ twoside.c \ vert-or-frag-only.c \ - vert-tex.c + vert-tex.c \ + vsraytrace.c UTIL_HEADERS = \ extfuncs.h \ diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c new file mode 100644 index 00000000000..dca8fd2db00 --- /dev/null +++ b/progs/glsl/fsraytrace.c @@ -0,0 +1,385 @@ +// -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- +/* + Copyright (c) 2010 Kristóf Ralovich + + 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 THE + AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + + +#include +#include +#include +#include +#include "shaderutil.h" + + +static int Win; +static int WinWidth = 512, WinHeight = 512; +static GLfloat Xrot = 0, Yrot = 0; +static int mouseGrabbed = 0; +static GLuint vertShader; +static GLuint fragShader; +static GLuint program; + +static const char* vsSource = + "varying vec2 rayDir;\n" + "\n" + "void main()\n" + "{\n" + " rayDir = gl_MultiTexCoord0.xy - vec2(0.5,0.5);\n" + " gl_Position = gl_ProjectionMatrix * gl_Vertex;\n" + "}\n"; + +static const char* fsSource = + "const float INF = 9999.9; \n" + "const float EPSILON = 0.00001; \n" + "const vec3 lightPos = vec3(0.0, 8.0, 1.0); \n" + "const vec4 backgroundColor = vec4(0.2,0.3,0.4,1); \n" + " \n" + "varying vec2 rayDir; \n" + " \n" + "uniform mat3 rot; \n" + " \n" + "struct Ray \n" + "{ \n" + "vec3 orig; \n" + "vec3 dir; \n" + "}; \n" + " \n" + "struct Sphere \n" + "{ \n" + " vec3 c; \n" + " float r; \n" + "}; \n" + " \n" + "struct Isec \n" + "{ \n" + " float t; \n" + " int idx; \n" + " vec3 hit; \n" + " vec3 n; \n" + "}; \n" + " \n" + "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" + "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" + "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" + "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" + " \n" + "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n" + "// sqrt, let's work around. \n" + "float \n" + "sqrt_hack(float f2) \n" + "{ \n" + " vec3 v = vec3(f2,0.0,0.0); \n" + " return length(v); \n" + "} \n" + " \n" + "void \n" + "intersect(const in Ray ray, \n" + " const in Sphere sph, \n" + " const in int idx, \n" + " inout Isec isec) \n" + "{ \n" + " // Project both o and the sphere to the plane perpendicular to d \n" + " // and containing c. Let x be the point where the ray intersects \n" + " // the plane. If |x-c| < r, the ray intersects the sphere. \n" + " vec3 o = ray.orig; \n" + " vec3 d = ray.dir; \n" + " vec3 n = -d; \n" + " vec3 c = sph.c; \n" + " float r = sph.r; \n" + " float t = dot(c-o,n)/dot(n,d); \n" + " vec3 x = o+d*t; \n" + " float e = length(x-c); \n" + " if(e > r) \n" + " { \n" + " // no intersection \n" + " return; \n" + " } \n" + " \n" + " // Apply Pythagorean theorem on the (intersection,x,c) triangle \n" + " // to get the distance between c and the intersection. \n" + "#ifndef BUGGY_INTEL_GEN4_GLSL \n" + " float f = sqrt(r*r - e*e); \n" + "#else \n" + " float f = sqrt_hack(r*r - e*e); \n" + "#endif \n" + " float dist = t - f; \n" + " if(dist < 0.0) \n" + " { \n" + " // inside the sphere \n" + " return; \n" + " } \n" + " \n" + " if(dist < EPSILON) \n" + " return; \n" + " \n" + " if(dist > isec.t) \n" + " return; \n" + " \n" + " isec.t = dist; \n" + " isec.idx = idx; \n" + " \n" + " isec.hit = ray.orig + ray.dir * isec.t; \n" + " isec.n = (isec.hit - c) / r; \n" + "} \n" + " \n" + "Isec \n" + "intersect(const in Ray ray, \n" + " const in float max_t /*= INF*/) \n" + "{ \n" + " Isec nearest; \n" + " nearest.t = max_t; \n" + " nearest.idx = -1; \n" + " \n" + " intersect(ray, spheres0, 0, nearest); \n" + " intersect(ray, spheres1, 1, nearest); \n" + " intersect(ray, spheres2, 2, nearest); \n" + " intersect(ray, spheres3, 3, nearest); \n" + " \n" + " return nearest; \n" + "} \n" + " \n" + "vec4 \n" + "idx2color(const in int idx) \n" + "{ \n" + " vec4 diff; \n" + " if(idx == 0) \n" + " diff = vec4(1.0, 0.0, 0.0, 0.0); \n" + " else if(idx == 1) \n" + " diff = vec4(0.0, 1.0, 0.0, 0.0); \n" + " else if(idx == 2) \n" + " diff = vec4(0.0, 0.0, 1.0, 0.0); \n" + " else if(idx == 3) \n" + " diff = vec4(1.0, 1.0, 0.0, 0.0); \n" + " return diff; \n" + "} \n" + " \n" + "vec4 \n" + "trace0(const in Ray ray) \n" + "{ \n" + " Isec isec = intersect(ray, INF); \n" + " \n" + " if(isec.idx == -1) \n" + " { \n" + " return backgroundColor; \n" + " } \n" + " \n" + " vec4 diff = idx2color(isec.idx); \n" + " \n" + " vec3 N = isec.n; \n" + " vec3 L = normalize(lightPos-isec.hit); \n" + " vec3 camera_dir = normalize(ray.orig - isec.hit); \n" + " return dot(N,L)*diff + pow( \n" + " clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0); \n" + "} \n" + " \n" + "vec4 \n" + "trace1(const in Ray ray) \n" + "{ \n" + " Isec isec = intersect(ray, INF); \n" + " \n" + " if(isec.idx == -1) \n" + " { \n" + " return backgroundColor; \n" + " } \n" + " \n" + " Ray reflRay = Ray(isec.hit, reflect(ray.dir, isec.n)); \n" + " \n" + " vec4 reflCol = trace0(reflRay); \n" + " \n" + " vec4 diff = idx2color(isec.idx) + reflCol; \n" + " \n" + " vec3 N = isec.n; \n" + " vec3 L = normalize(lightPos-isec.hit); \n" + " vec3 camera_dir = normalize(ray.orig - isec.hit); \n" + " return dot(N,L)*diff + pow( \n" + " clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0); \n" + "} \n" + " \n" + "\n" + "void\n" + "main()\n" + "{\n" + " const float z = -0.5;\n" + " const vec3 cameraPos = vec3(0,0,3); \n" + " Ray r = Ray(cameraPos, normalize(vec3(rayDir, z) * rot));\n" + " gl_FragColor = trace1(r);\n" + "}\n"; + + + +static void +Idle(void) +{ + glutPostRedisplay(); +} + + +static void +Draw(void) +{ + float rot[9] = {1,0,0, 0,1,0, 0,0,1}; + GLint location = glGetUniformLocation(program, "rot"); + + glUseProgram(program); + glUniformMatrix3fv(location, 1, 0, rot); + static const float m = -10.F; + static const float p = 10.F; + static const float d = -0.5F; + glBegin(GL_QUADS); + { + glTexCoord2f(0.0F, 0.0F); glVertex3f(m, m, d); + glTexCoord2f(1.0F, 0.0F); glVertex3f(p, m, d); + glTexCoord2f(1.0F, 1.0F); glVertex3f(p, p, d); + glTexCoord2f(0.0F, 1.0F); glVertex3f(m, p, d); + } + glEnd(); + glUseProgram(0); + + glutSwapBuffers(); + + static int frames = 0; + static int t0 = 0; + static int t1 = 0; + frames++; + t1 = glutGet(GLUT_ELAPSED_TIME); + float dt = (float)(t1-t0)/1000.0F; + if(dt >= 5.0F) + { + float fps = (float)frames / dt; + printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); + frames = 0; + t0 = t1; + } +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-10, 10, -10, 10, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static +void +drag(int x, int y) +{ + float scale = 1.5F; + if(mouseGrabbed) + { + Xrot = (float)(x - WinWidth/2) / scale; + Yrot = (float)(y - WinHeight/2) / scale; + printf("%4.2f %4.2f\n", Xrot, Yrot); + } +} + + +static +void +mouse(int button, int state, int x, int y) +{ + if(state == GLUT_DOWN) + { + mouseGrabbed = !mouseGrabbed; + } +} + + +static void +Init(void) +{ + glDisable(GL_DEPTH_TEST); + + if(!ShadersSupported()) + { + fprintf(stderr, "Shaders are not supported!\n"); + exit(-1); + } + + vertShader = CompileShaderText(GL_VERTEX_SHADER, vsSource); + fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fsSource); + program = LinkShaders(vertShader, fragShader); + glUseProgram(0); + + if(glGetError() != 0) + { + fprintf(stderr, "Shaders were not loaded!\n"); + exit(-1); + } + + if(!glIsShader(vertShader)) + { + fprintf(stderr, "Vertex shader failed!\n"); + exit(-1); + } + + if(!glIsProgram(program)) + { + fprintf(stderr, "Shader program failed!\n"); + exit(-1); + } + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); +} + + +int +main(int argc, char *argv[]) +{ + /*setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);*/ + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMouseFunc(mouse); + glutPassiveMotionFunc(drag); + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} + diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c new file mode 100644 index 00000000000..6e1617a7ebd --- /dev/null +++ b/progs/glsl/vsraytrace.c @@ -0,0 +1,363 @@ +// -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- +/* + Copyright (c) 2010 Kristóf Ralovich + + 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 THE + AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + + +#include +#include +#include +#include +#include "shaderutil.h" + + +static int Win; +//static int WinWidth = 256, WinHeight = 256; +static int WinWidth = 50, WinHeight = 50; +static int mouseGrabbed = 0; + +static const char* vsSource = + "const float INF = 9999.9; \n" + "const float EPSILON = 0.00001; \n" + "const vec3 lightPos = vec3(0.0, 8.0, 1.0); \n" + "const vec4 backgroundColor = vec4(0.2,0.3,0.4,1); \n" + " \n" + "uniform mat3 rot; \n" + " \n" + "struct Ray \n" + "{ \n" + "vec3 orig; \n" + "vec3 dir; \n" + "}; \n" + " \n" + "struct Sphere \n" + "{ \n" + " vec3 c; \n" + " float r; \n" + "}; \n" + " \n" + "struct Isec \n" + "{ \n" + " float t; \n" + " int idx; \n" + " vec3 hit; \n" + " vec3 n; \n" + "}; \n" + " \n" + "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" + "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" + "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" + "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" + " \n" + "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n" + "// sqrt, let's work around. \n" + "float \n" + "sqrt_hack(float f2) \n" + "{ \n" + " vec3 v = vec3(f2,0.0,0.0); \n" + " return length(v); \n" + "} \n" + " \n" + "void \n" + "intersect(const in Ray ray, \n" + " const in Sphere sph, \n" + " const in int idx, \n" + " inout Isec isec) \n" + "{ \n" + " // Project both o and the sphere to the plane perpendicular to d \n" + " // and containing c. Let x be the point where the ray intersects \n" + " // the plane. If |x-c| < r, the ray intersects the sphere. \n" + " vec3 o = ray.orig; \n" + " vec3 d = ray.dir; \n" + " vec3 n = -d; \n" + " vec3 c = sph.c; \n" + " float r = sph.r; \n" + " float t = dot(c-o,n)/dot(n,d); \n" + " vec3 x = o+d*t; \n" + " float e = length(x-c); \n" + " if(e > r) \n" + " { \n" + " // no intersection \n" + " return; \n" + " } \n" + " \n" + " // Apply Pythagorean theorem on the (intersection,x,c) triangle \n" + " // to get the distance between c and the intersection. \n" + "#define BUGGY_INTEL_GEN4_GLSL 1 \n" + "#ifndef BUGGY_INTEL_GEN4_GLSL \n" + " float f = sqrt(r*r - e*e); \n" + "#else \n" + " float f = sqrt_hack(r*r - e*e); \n" + "#endif \n" + " float dist = t - f; \n" + " if(dist < 0.0) \n" + " { \n" + " // inside the sphere \n" + " return; \n" + " } \n" + " \n" + " if(dist < EPSILON) \n" + " return; \n" + " \n" + " if(dist > isec.t) \n" + " return; \n" + " \n" + " isec.t = dist; \n" + " isec.idx = idx; \n" + " \n" + " isec.hit = ray.orig + ray.dir * isec.t; \n" + " isec.n = (isec.hit - c) / r; \n" + "} \n" + " \n" + "Isec \n" + "intersect(const in Ray ray, \n" + " const in float max_t /*= INF*/) \n" + "{ \n" + " Isec nearest; \n" + " nearest.t = max_t; \n" + " nearest.idx = -1; \n" + " \n" + " intersect(ray, spheres0, 0, nearest); \n" + " intersect(ray, spheres1, 1, nearest); \n" + " intersect(ray, spheres2, 2, nearest); \n" + " intersect(ray, spheres3, 3, nearest); \n" + " \n" + " return nearest; \n" + "} \n" + " \n" + "vec4 \n" + "idx2color(const in int idx) \n" + "{ \n" + " vec4 diff; \n" + " if(idx == 0) \n" + " diff = vec4(1.0, 0.0, 0.0, 0.0); \n" + " else if(idx == 1) \n" + " diff = vec4(0.0, 1.0, 0.0, 0.0); \n" + " else if(idx == 2) \n" + " diff = vec4(0.0, 0.0, 1.0, 0.0); \n" + " else if(idx == 3) \n" + " diff = vec4(1.0, 1.0, 0.0, 0.0); \n" + " return diff; \n" + "} \n" + " \n" + "vec4 \n" + "trace0(const in Ray ray) \n" + "{ \n" + " Isec isec = intersect(ray, INF); \n" + " \n" + " if(isec.idx == -1) \n" + " { \n" + " return backgroundColor; \n" + " } \n" + " \n" + " vec4 diff = idx2color(isec.idx); \n" + " \n" + " vec3 N = isec.n; \n" + " vec3 L = normalize(lightPos-isec.hit); \n" + " vec3 camera_dir = normalize(ray.orig - isec.hit); \n" + " return dot(N,L)*diff + pow( \n" + " clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0); \n" + "} \n" + " \n" + "vec4 \n" + "trace1(const in Ray ray) \n" + "{ \n" + " Isec isec = intersect(ray, INF); \n" + " \n" + " if(isec.idx == -1) \n" + " { \n" + " return backgroundColor; \n" + " } \n" + " \n" + " Ray reflRay = Ray(isec.hit, reflect(ray.dir, isec.n)); \n" + " \n" + " vec4 reflCol = trace0(reflRay); \n" + " \n" + " vec4 diff = idx2color(isec.idx) + reflCol; \n" + " \n" + " vec3 N = isec.n; \n" + " vec3 L = normalize(lightPos-isec.hit); \n" + " vec3 camera_dir = normalize(ray.orig - isec.hit); \n" + " return dot(N,L)*diff + pow( \n" + " clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0); \n" + "} \n" + " \n" + "void main() \n" + "{ \n" + " const vec3 cameraPos = vec3(0,0,3); \n" + " const vec3 rayDir = normalize(vec3(gl_Vertex.x, gl_Vertex.y, -1.0) * rot);\n" + " Ray ray = Ray(cameraPos, rayDir); \n" + " gl_Position = gl_Vertex; \n" + " gl_FrontColor = trace1(ray); \n" + "} \n"; + +static GLuint vertShader; +static GLuint program; + + +static void +Draw(void) +{ + const float w = 0.5F * WinWidth; + const float h = 0.5F * WinHeight; + int x,y; + + float rot[9] = {1,0,0, 0,1,0, 0,0,1}; + GLint location = glGetUniformLocation(program, "rot"); + //printf("loc=%d\n", location); + + glUseProgram(program); + glUniformMatrix3fv(location, 1, 0, rot); + glBegin(GL_POINTS); + for(y = 0; y < WinHeight; y++) + { + for(x = 0; x < WinWidth; x++) + { + const float posx = x / w - 1.0F; + const float posy = y / h - 1.0F; + glVertex2f(posx, posy); + } + } + glEnd(); + glUseProgram(0); + + glutSwapBuffers(); + + static int frames = 0; + static int t0 = 0; + static int t1 = 0; + frames++; + t1 = glutGet(GLUT_ELAPSED_TIME); + float dt = (float)(t1-t0)/1000.0F; + if(dt >= 5.0F) + { + float fps = (float)frames / dt; + printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); + frames = 0; + t0 = t1; + } +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +Key(unsigned char key, int x, int y) +{ + if(key == 27) + { + glutDestroyWindow(Win); + exit(0); + } + glutPostRedisplay(); +} + + +static +void +drag(int x, int y) +{ + if(mouseGrabbed) + { + printf("%4d %4d\n", x, y); + } +} + + +static +void +mouse(int button, int state, int x, int y) +{ + if(state == GLUT_DOWN) + { + mouseGrabbed = !mouseGrabbed; + } +} + + +static void +Init(void) +{ + glDisable(GL_DEPTH_TEST); + + if(!ShadersSupported()) + { + fprintf(stderr, "Shaders are not supported!\n"); + exit(-1); + } + + vertShader = CompileShaderText(GL_VERTEX_SHADER, vsSource); + program = LinkShaders(vertShader, 0); + glUseProgram(0); + + if(glGetError() != 0) + { + fprintf(stderr, "Shaders were not loaded!\n"); + exit(-1); + } + + if(!glIsShader(vertShader)) + { + fprintf(stderr, "Vertex shader failed!\n"); + exit(-1); + } + + if(!glIsProgram(program)) + { + fprintf(stderr, "Shader program failed!\n"); + exit(-1); + } + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); +} + + +int +main(int argc, char *argv[]) +{ +// setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1); + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutIdleFunc(Draw); + glutMouseFunc(mouse); + glutMotionFunc(drag); + Init(); + glutMainLoop(); + return 0; +} + From 79394f0267a41cc9ea446c69f4b6530b255019dc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 09:03:33 -0600 Subject: [PATCH 316/483] progs/glsl: silence warnings, remove debug code, adjust window size, etc --- progs/glsl/fsraytrace.c | 35 +++++++++++++++++++---------------- progs/glsl/vsraytrace.c | 31 ++++++++++++++++--------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index dca8fd2db00..e35af0fc5a3 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -237,12 +237,13 @@ Draw(void) { float rot[9] = {1,0,0, 0,1,0, 0,0,1}; GLint location = glGetUniformLocation(program, "rot"); - - glUseProgram(program); - glUniformMatrix3fv(location, 1, 0, rot); static const float m = -10.F; static const float p = 10.F; static const float d = -0.5F; + + glUseProgram(program); + glUniformMatrix3fv(location, 1, 0, rot); + glBegin(GL_QUADS); { glTexCoord2f(0.0F, 0.0F); glVertex3f(m, m, d); @@ -255,18 +256,21 @@ Draw(void) glutSwapBuffers(); - static int frames = 0; - static int t0 = 0; - static int t1 = 0; - frames++; - t1 = glutGet(GLUT_ELAPSED_TIME); - float dt = (float)(t1-t0)/1000.0F; - if(dt >= 5.0F) { - float fps = (float)frames / dt; - printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); - frames = 0; - t0 = t1; + static int frames = 0; + static int t0 = 0; + static int t1 = 0; + float dt; + frames++; + t1 = glutGet(GLUT_ELAPSED_TIME); + dt = (float)(t1-t0)/1000.0F; + if(dt >= 5.0F) + { + float fps = (float)frames / dt; + printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); + frames = 0; + t0 = t1; + } } } @@ -366,9 +370,8 @@ Init(void) int main(int argc, char *argv[]) { - /*setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);*/ - glutInit(&argc, argv); glutInitWindowSize(WinWidth, WinHeight); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index 6e1617a7ebd..37b8f774aa7 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -30,8 +30,7 @@ static int Win; -//static int WinWidth = 256, WinHeight = 256; -static int WinWidth = 50, WinHeight = 50; +static int WinWidth = 256, WinHeight = 256; static int mouseGrabbed = 0; static const char* vsSource = @@ -241,18 +240,21 @@ Draw(void) glutSwapBuffers(); - static int frames = 0; - static int t0 = 0; - static int t1 = 0; - frames++; - t1 = glutGet(GLUT_ELAPSED_TIME); - float dt = (float)(t1-t0)/1000.0F; - if(dt >= 5.0F) { - float fps = (float)frames / dt; - printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); - frames = 0; - t0 = t1; + static int frames = 0; + static int t0 = 0; + static int t1 = 0; + float dt; + frames++; + t1 = glutGet(GLUT_ELAPSED_TIME); + dt = (float)(t1-t0)/1000.0F; + if (dt >= 5.0F) + { + float fps = (float)frames / dt; + printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt); + frames = 0; + t0 = t1; + } } } @@ -344,9 +346,8 @@ Init(void) int main(int argc, char *argv[]) { -// setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1); - glutInit(&argc, argv); glutInitWindowSize(WinWidth, WinHeight); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); glewInit(); From 01f7acb700789abacca21e89400f57375eb82499 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 09:08:24 -0600 Subject: [PATCH 317/483] progs/glsl: remove/replace //-style comments --- progs/glsl/fsraytrace.c | 2 +- progs/glsl/vsraytrace.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index e35af0fc5a3..8d54757e590 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -1,4 +1,4 @@ -// -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- +/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- */ /* Copyright (c) 2010 Kristóf Ralovich diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index 37b8f774aa7..d7726c787b8 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -1,4 +1,4 @@ -// -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- +/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- */ /* Copyright (c) 2010 Kristóf Ralovich @@ -221,7 +221,6 @@ Draw(void) float rot[9] = {1,0,0, 0,1,0, 0,0,1}; GLint location = glGetUniformLocation(program, "rot"); - //printf("loc=%d\n", location); glUseProgram(program); glUniformMatrix3fv(location, 1, 0, rot); From 41d2ebf2020311eb032882d9b0bd1efe916f1feb Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Mar 2010 13:44:32 +0000 Subject: [PATCH 318/483] gallium: Remove GALLIUM_WINSYS_DRM_DIRS --- configs/autoconf.in | 1 - configs/default | 3 +-- configs/linux-dri | 3 +-- configs/linux-opengl-es | 3 +-- configure.ac | 25 +++++++++++++++---------- src/gallium/winsys/drm/Makefile | 12 ------------ 6 files changed, 18 insertions(+), 29 deletions(-) delete mode 100644 src/gallium/winsys/drm/Makefile diff --git a/configs/autoconf.in b/configs/autoconf.in index 66c1ee48e87..b6cc9b3b73e 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -76,7 +76,6 @@ GALLIUM_DIRS = @GALLIUM_DIRS@ GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@ GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@ GALLIUM_TARGET_DIRS = @GALLIUM_TARGET_DIRS@ -GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@ GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@ GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) diff --git a/configs/default b/configs/default index 8fbf8dd219a..03feed973a2 100644 --- a/configs/default +++ b/configs/default @@ -100,9 +100,8 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = null xlib drm +GALLIUM_WINSYS_DIRS = null xlib drm/swrast GALLIUM_TARGET_DIRS = libgl-xlib -GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx vega # native displays EGL should support diff --git a/configs/linux-dri b/configs/linux-dri index d362fd8b377..e10021d7994 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -58,9 +58,8 @@ PROGRAM_DIRS := egl $(PROGRAM_DIRS) EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri -GALLIUM_WINSYS_DIRS = null xlib drm +GALLIUM_WINSYS_DIRS = null xlib drm/vmware drm/intel drm/i965 GALLIUM_TARGET_DIRS = -GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 GALLIUM_STATE_TRACKERS_DIRS = egl DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 76054aad14e..ddcb717f836 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -24,5 +24,4 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 GALLIUM_STATE_TRACKERS_DIRS += egl -GALLIUM_WINSYS_DIRS += drm -GALLIUM_WINSYS_DRM_DIRS += intel swrast +GALLIUM_WINSYS_DIRS += drm/intel drm/swrast diff --git a/configure.ac b/configure.ac index 26960e85ea4..aab16b6ea8a 100644 --- a/configure.ac +++ b/configure.ac @@ -461,8 +461,7 @@ SRC_DIRS="glew" GLU_DIRS="sgi" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_TARGET_DIRS="" -GALLIUM_WINSYS_DIRS="" -GALLIUM_WINSYS_DRM_DIRS="" +GALLIUM_WINSYS_DIRS="null" GALLIUM_DRIVERS_DIRS="softpipe failover trace identity" GALLIUM_STATE_TRACKERS_DIRS="" @@ -475,7 +474,7 @@ xlib) dri) SRC_DIRS="$SRC_DIRS glx" DRIVER_DIRS="dri" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib drm" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib drm/sw" ;; osmesa) DRIVER_DIRS="osmesa" @@ -487,7 +486,6 @@ AC_SUBST([DRIVER_DIRS]) AC_SUBST([GALLIUM_DIRS]) AC_SUBST([GALLIUM_TARGET_DIRS]) AC_SUBST([GALLIUM_WINSYS_DIRS]) -AC_SUBST([GALLIUM_WINSYS_DRM_DIRS]) AC_SUBST([GALLIUM_DRIVERS_DIRS]) AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS]) @@ -1318,7 +1316,9 @@ AC_ARG_ENABLE([gallium-svga], [enable_gallium_svga="$enableval"], [enable_gallium_svga=auto]) if test "x$enable_gallium_svga" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware" + if test "x$mesa_driver" = xdri; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/vmware" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" elif test "x$enable_gallium_svga" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" @@ -1333,7 +1333,9 @@ AC_ARG_ENABLE([gallium-intel], [enable_gallium_intel="$enableval"], [enable_gallium_intel=auto]) if test "x$enable_gallium_intel" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel i965" + if test "x$mesa_driver" = xdri; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/intel drm/i965" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" elif test "x$enable_gallium_intel" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" @@ -1348,7 +1350,9 @@ AC_ARG_ENABLE([gallium-radeon], [enable_gallium_radeon="$enableval"], [enable_gallium_radeon=auto]) if test "x$enable_gallium_radeon" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon" + if test "x$mesa_driver" = xdri; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/radeon" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" elif test "x$enable_gallium_radeon" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" @@ -1363,7 +1367,9 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau="$enableval"], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau" + if test "x$mesa_driver" = xdri; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/nouveau" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" fi @@ -1376,7 +1382,7 @@ AC_ARG_ENABLE([gallium-swrast], [enable_gallium_swrast="$enableval"], [enable_gallium_swrast=auto]) if test "x$enable_gallium_swrast" = xyes; then - GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS swrast" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/swrast" fi dnl prepend CORE_DIRS to SRC_DIRS @@ -1434,7 +1440,6 @@ if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then echo " Gallium dirs: $GALLIUM_DIRS" echo " Target dirs: $GALLIUM_TARGET_DIRS" echo " Winsys dirs: $GALLIUM_WINSYS_DIRS" - echo " Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS" echo " Driver dirs: $GALLIUM_DRIVERS_DIRS" echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS" else diff --git a/src/gallium/winsys/drm/Makefile b/src/gallium/winsys/drm/Makefile deleted file mode 100644 index a998aff931d..00000000000 --- a/src/gallium/winsys/drm/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/Makefile -TOP = ../../../.. -include $(TOP)/configs/current - -SUBDIRS = sw $(GALLIUM_WINSYS_DRM_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done From be38b32531cc974ff8a33e4504d4169150be4d55 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 23 Mar 2010 13:23:26 +0000 Subject: [PATCH 319/483] gallium: Move dri drivers to targets Attached output from git commit: rename src/gallium/{winsys/drm/Makefile.template => targets/Makefile.dri} (100%) rename src/gallium/{winsys/drm/intel/dri => targets/dri-i915}/Makefile (75%) rename src/gallium/{winsys/drm/intel/dri => targets/dri-i915}/SConscript (100%) rename src/gallium/{winsys/drm/i965/dri => targets/dri-i965}/Makefile (76%) rename src/gallium/{winsys/drm/i965/dri => targets/dri-i965}/SConscript (100%) rename src/gallium/{winsys/drm/nouveau/dri => targets/dri-nouveau}/Makefile (86%) rename src/gallium/{winsys/drm/radeon/dri => targets/dri-radeong}/Makefile (85%) rename src/gallium/{winsys/drm/radeon/dri => targets/dri-radeong}/SConscript (100%) rename src/gallium/{winsys/drm/vmware/dri => targets/dri-vmwgfx}/Makefile (85%) rename src/gallium/{winsys/drm/vmware/dri => targets/dri-vmwgfx}/SConscript (100%) --- configure.ac | 6 +++++- .../drm/Makefile.template => targets/Makefile.dri} | 0 .../drm/intel/dri => targets/dri-i915}/Makefile | 10 +++------- .../drm/intel/dri => targets/dri-i915}/SConscript | 0 .../{winsys/drm/i965/dri => targets/dri-i965}/Makefile | 10 +++------- .../drm/i965/dri => targets/dri-i965}/SConscript | 0 .../drm/nouveau/dri => targets/dri-nouveau}/Makefile | 6 ++---- .../drm/radeon/dri => targets/dri-radeong}/Makefile | 7 ++----- .../drm/radeon/dri => targets/dri-radeong}/SConscript | 0 .../drm/vmware/dri => targets/dri-vmwgfx}/Makefile | 5 ++--- .../drm/vmware/dri => targets/dri-vmwgfx}/SConscript | 0 src/gallium/winsys/drm/i965/SConscript | 4 ---- src/gallium/winsys/drm/intel/SConscript | 4 ---- src/gallium/winsys/drm/radeon/SConscript | 4 ---- src/gallium/winsys/drm/vmware/SConscript | 4 ---- 15 files changed, 17 insertions(+), 43 deletions(-) rename src/gallium/{winsys/drm/Makefile.template => targets/Makefile.dri} (100%) rename src/gallium/{winsys/drm/intel/dri => targets/dri-i915}/Makefile (75%) rename src/gallium/{winsys/drm/intel/dri => targets/dri-i915}/SConscript (100%) rename src/gallium/{winsys/drm/i965/dri => targets/dri-i965}/Makefile (76%) rename src/gallium/{winsys/drm/i965/dri => targets/dri-i965}/SConscript (100%) rename src/gallium/{winsys/drm/nouveau/dri => targets/dri-nouveau}/Makefile (86%) rename src/gallium/{winsys/drm/radeon/dri => targets/dri-radeong}/Makefile (85%) rename src/gallium/{winsys/drm/radeon/dri => targets/dri-radeong}/SConscript (100%) rename src/gallium/{winsys/drm/vmware/dri => targets/dri-vmwgfx}/Makefile (85%) rename src/gallium/{winsys/drm/vmware/dri => targets/dri-vmwgfx}/SConscript (100%) diff --git a/configure.ac b/configure.ac index aab16b6ea8a..51b480ff972 100644 --- a/configure.ac +++ b/configure.ac @@ -1180,7 +1180,7 @@ AC_ARG_ENABLE([gallium], [enable_gallium="$enableval"], [enable_gallium=yes]) if test "x$enable_gallium" = xyes; then - SRC_DIRS="$SRC_DIRS gallium gallium/winsys" + SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets" fi dnl @@ -1318,6 +1318,7 @@ AC_ARG_ENABLE([gallium-svga], if test "x$enable_gallium_svga" = xyes; then if test "x$mesa_driver" = xdri; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/vmware" + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-vmwgfx" fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" elif test "x$enable_gallium_svga" = xauto; then @@ -1335,6 +1336,7 @@ AC_ARG_ENABLE([gallium-intel], if test "x$enable_gallium_intel" = xyes; then if test "x$mesa_driver" = xdri; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/intel drm/i965" + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-i915 dri-i965" fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" elif test "x$enable_gallium_intel" = xauto; then @@ -1352,6 +1354,7 @@ AC_ARG_ENABLE([gallium-radeon], if test "x$enable_gallium_radeon" = xyes; then if test "x$mesa_driver" = xdri; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/radeon" + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-radeong" fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" elif test "x$enable_gallium_radeon" = xauto; then @@ -1369,6 +1372,7 @@ AC_ARG_ENABLE([gallium-nouveau], if test "x$enable_gallium_nouveau" = xyes; then if test "x$mesa_driver" = xdri; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/nouveau" + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-nouveau" fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" fi diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/targets/Makefile.dri similarity index 100% rename from src/gallium/winsys/drm/Makefile.template rename to src/gallium/targets/Makefile.dri diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/targets/dri-i915/Makefile similarity index 75% rename from src/gallium/winsys/drm/intel/dri/Makefile rename to src/gallium/targets/dri-i915/Makefile index 26aae4122eb..33eaae624f2 100644 --- a/src/gallium/winsys/drm/intel/dri/Makefile +++ b/src/gallium/targets/dri-i915/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current LIBNAME = i915_dri.so @@ -11,16 +11,12 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i915/libi915.a - -DRIVER_SOURCES = - C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) \ $(DRIVER_SOURCES) -include ../../Makefile.template +include ../Makefile.dri DRI_LIB_DEPS += -ldrm_intel -symlinks: $(TOP)/$(LIB_DIR)/gallium - @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so +symlinks: diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/targets/dri-i915/SConscript similarity index 100% rename from src/gallium/winsys/drm/intel/dri/SConscript rename to src/gallium/targets/dri-i915/SConscript diff --git a/src/gallium/winsys/drm/i965/dri/Makefile b/src/gallium/targets/dri-i965/Makefile similarity index 76% rename from src/gallium/winsys/drm/i965/dri/Makefile rename to src/gallium/targets/dri-i965/Makefile index 56690769fc7..e17775a842a 100644 --- a/src/gallium/winsys/drm/i965/dri/Makefile +++ b/src/gallium/targets/dri-i965/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current LIBNAME = i965_dri.so @@ -12,16 +12,12 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i965/libi965.a - -DRIVER_SOURCES = - C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) \ $(DRIVER_SOURCES) -include ../../Makefile.template +include ../Makefile.dri DRI_LIB_DEPS += -ldrm_intel -symlinks: $(TOP)/$(LIB_DIR)/gallium - @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so +symlinks: diff --git a/src/gallium/winsys/drm/i965/dri/SConscript b/src/gallium/targets/dri-i965/SConscript similarity index 100% rename from src/gallium/winsys/drm/i965/dri/SConscript rename to src/gallium/targets/dri-i965/SConscript diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/targets/dri-nouveau/Makefile similarity index 86% rename from src/gallium/winsys/drm/nouveau/dri/Makefile rename to src/gallium/targets/dri-nouveau/Makefile index 50ac3f203e5..680bad79177 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/targets/dri-nouveau/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current LIBNAME = nouveau_dri.so @@ -10,13 +10,11 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a -DRIVER_SOURCES = - C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) \ $(DRIVER_SOURCES) -include ../../Makefile.template +include ../Makefile.dri DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs) diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/targets/dri-radeong/Makefile similarity index 85% rename from src/gallium/winsys/drm/radeon/dri/Makefile rename to src/gallium/targets/dri-radeong/Makefile index d75f7dd6da7..c6d8c524694 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/targets/dri-radeong/Makefile @@ -1,5 +1,4 @@ - -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current LIBNAME = radeong_dri.so @@ -15,9 +14,7 @@ C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) \ $(DRIVER_SOURCES) -ASM_SOURCES = - -include ../../Makefile.template +include ../Makefile.dri DRI_LIB_DEPS += -ldrm_radeon diff --git a/src/gallium/winsys/drm/radeon/dri/SConscript b/src/gallium/targets/dri-radeong/SConscript similarity index 100% rename from src/gallium/winsys/drm/radeon/dri/SConscript rename to src/gallium/targets/dri-radeong/SConscript diff --git a/src/gallium/winsys/drm/vmware/dri/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile similarity index 85% rename from src/gallium/winsys/drm/vmware/dri/Makefile rename to src/gallium/targets/dri-vmwgfx/Makefile index 8a39e23da6d..1d2ddfe548f 100644 --- a/src/gallium/winsys/drm/vmware/dri/Makefile +++ b/src/gallium/targets/dri-vmwgfx/Makefile @@ -1,5 +1,4 @@ - -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current LIBNAME = vmwgfx_dri.so @@ -13,6 +12,6 @@ PIPE_DRIVERS = \ C_SOURCES = \ $(COMMON_GALLIUM_SOURCES) -include ../../Makefile.template +include ../Makefile.dri symlinks: diff --git a/src/gallium/winsys/drm/vmware/dri/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript similarity index 100% rename from src/gallium/winsys/drm/vmware/dri/SConscript rename to src/gallium/targets/dri-vmwgfx/SConscript diff --git a/src/gallium/winsys/drm/i965/SConscript b/src/gallium/winsys/drm/i965/SConscript index 50d7b75ed68..fdf57eedb94 100644 --- a/src/gallium/winsys/drm/i965/SConscript +++ b/src/gallium/winsys/drm/i965/SConscript @@ -1,7 +1,3 @@ Import('*') SConscript(['gem/SConscript',]) - -if 'mesa' in env['statetrackers']: - - SConscript(['dri/SConscript']) diff --git a/src/gallium/winsys/drm/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript index 50d7b75ed68..fdf57eedb94 100644 --- a/src/gallium/winsys/drm/intel/SConscript +++ b/src/gallium/winsys/drm/intel/SConscript @@ -1,7 +1,3 @@ Import('*') SConscript(['gem/SConscript',]) - -if 'mesa' in env['statetrackers']: - - SConscript(['dri/SConscript']) diff --git a/src/gallium/winsys/drm/radeon/SConscript b/src/gallium/winsys/drm/radeon/SConscript index b2dfd504d42..eff87e7d010 100644 --- a/src/gallium/winsys/drm/radeon/SConscript +++ b/src/gallium/winsys/drm/radeon/SConscript @@ -1,7 +1,3 @@ Import('*') SConscript(['core/SConscript',]) - -if 'mesa' in env['statetrackers']: - - SConscript(['dri/SConscript']) diff --git a/src/gallium/winsys/drm/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript index 06e6d5be9ca..e4da31a6933 100644 --- a/src/gallium/winsys/drm/vmware/SConscript +++ b/src/gallium/winsys/drm/vmware/SConscript @@ -2,10 +2,6 @@ Import('*') SConscript(['core/SConscript',]) -if 'mesa' in env['statetrackers']: - - SConscript(['dri/SConscript']) - if 'xorg' in env['statetrackers']: SConscript(['xorg/SConscript']) From f5ba2cdeb902993b993187a958aad89c5ac79d6b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 24 Mar 2010 10:58:45 +0100 Subject: [PATCH 320/483] gallium: Move egl drivers to targets Atteched output from git commit: rename src/gallium/{winsys/drm => targets}/Makefile.egl (100%) rename src/gallium/{winsys/drm/intel/egl => targets/egl-i915}/Makefile (86%) rename src/gallium/{winsys/drm/i965/egl => targets/egl-i915}/dummy.c (100%) rename src/gallium/{winsys/drm/i965/egl => targets/egl-i965}/Makefile (86%) rename src/gallium/{winsys/drm/intel/egl => targets/egl-i965}/dummy.c (100%) rename src/gallium/{winsys/drm/nouveau/egl => targets/egl-nouveau}/Makefile (88%) rename src/gallium/{winsys/drm/nouveau/egl => targets/egl-nouveau}/dummy.c (100%) rename src/gallium/{winsys/drm/radeon/egl => targets/egl-radeon}/Makefile (87%) rename src/gallium/{winsys/drm/radeon/egl => targets/egl-radeon}/dummy.c (100%) create mode 100644 src/gallium/targets/egl-swrast/Makefile create mode 100644 src/gallium/targets/egl-swrast/swrast_glue.c rename src/gallium/{winsys/drm/vmware/egl => targets/egl-vmwgfx}/Makefile (86%) rename src/gallium/{winsys/drm/swrast/egl => targets/egl-vmwgfx}/dummy.c (100%) delete mode 100644 src/gallium/winsys/drm/swrast/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/core/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/core/swrast_drm_api.c delete mode 100644 src/gallium/winsys/drm/swrast/egl/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/egl/dummy.c --- configs/default | 2 +- configs/linux-dri | 2 +- configs/linux-opengl-es | 3 ++- configure.ac | 23 +++++++++++++++++-- .../{winsys/drm => targets}/Makefile.egl | 0 .../intel/egl => targets/egl-i915}/Makefile | 4 ++-- .../drm/i965/egl => targets/egl-i915}/dummy.c | 0 .../i965/egl => targets/egl-i965}/Makefile | 4 ++-- .../intel/egl => targets/egl-i965}/dummy.c | 0 .../egl => targets/egl-nouveau}/Makefile | 4 ++-- .../egl => targets/egl-nouveau}/dummy.c | 0 .../egl => targets/egl-radeon}/Makefile | 4 ++-- .../radeon/egl => targets/egl-radeon}/dummy.c | 0 src/gallium/targets/egl-swrast/Makefile | 12 ++++++++++ .../egl-swrast/swrast_glue.c} | 4 ++++ .../egl => targets/egl-vmwgfx}/Makefile | 4 ++-- .../swrast/egl => targets/egl-vmwgfx}/dummy.c | 0 src/gallium/winsys/drm/swrast/Makefile | 12 ---------- src/gallium/winsys/drm/swrast/core/Makefile | 10 -------- src/gallium/winsys/drm/swrast/egl/Makefile | 12 ---------- src/gallium/winsys/drm/vmware/egl/dummy.c | 3 --- 21 files changed, 51 insertions(+), 52 deletions(-) rename src/gallium/{winsys/drm => targets}/Makefile.egl (100%) rename src/gallium/{winsys/drm/intel/egl => targets/egl-i915}/Makefile (86%) rename src/gallium/{winsys/drm/i965/egl => targets/egl-i915}/dummy.c (100%) rename src/gallium/{winsys/drm/i965/egl => targets/egl-i965}/Makefile (86%) rename src/gallium/{winsys/drm/intel/egl => targets/egl-i965}/dummy.c (100%) rename src/gallium/{winsys/drm/nouveau/egl => targets/egl-nouveau}/Makefile (88%) rename src/gallium/{winsys/drm/nouveau/egl => targets/egl-nouveau}/dummy.c (100%) rename src/gallium/{winsys/drm/radeon/egl => targets/egl-radeon}/Makefile (87%) rename src/gallium/{winsys/drm/radeon/egl => targets/egl-radeon}/dummy.c (100%) create mode 100644 src/gallium/targets/egl-swrast/Makefile rename src/gallium/{winsys/drm/swrast/core/swrast_drm_api.c => targets/egl-swrast/swrast_glue.c} (60%) rename src/gallium/{winsys/drm/vmware/egl => targets/egl-vmwgfx}/Makefile (86%) rename src/gallium/{winsys/drm/swrast/egl => targets/egl-vmwgfx}/dummy.c (100%) delete mode 100644 src/gallium/winsys/drm/swrast/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/core/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/egl/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/egl/dummy.c diff --git a/configs/default b/configs/default index 03feed973a2..65e9847bd20 100644 --- a/configs/default +++ b/configs/default @@ -100,7 +100,7 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = null xlib drm/swrast +GALLIUM_WINSYS_DIRS = null xlib GALLIUM_TARGET_DIRS = libgl-xlib GALLIUM_STATE_TRACKERS_DIRS = glx vega diff --git a/configs/linux-dri b/configs/linux-dri index e10021d7994..b11daeda7c2 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -59,7 +59,7 @@ EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri GALLIUM_WINSYS_DIRS = null xlib drm/vmware drm/intel drm/i965 -GALLIUM_TARGET_DIRS = +GALLIUM_TARGET_DIRS = egl-swrast GALLIUM_STATE_TRACKERS_DIRS = egl DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index ddcb717f836..32fe40fb848 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -24,4 +24,5 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 GALLIUM_STATE_TRACKERS_DIRS += egl -GALLIUM_WINSYS_DIRS += drm/intel drm/swrast +GALLIUM_WINSYS_DIRS += drm/intel +GALLIUM_TARGET_DIRS += egl-swrast egl-i915 diff --git a/configure.ac b/configure.ac index 51b480ff972..dccff6f7cc4 100644 --- a/configure.ac +++ b/configure.ac @@ -1320,6 +1320,9 @@ if test "x$enable_gallium_svga" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/vmware" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-vmwgfx" fi + if test "x$enable_egl" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-vmwgfx" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" elif test "x$enable_gallium_svga" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" @@ -1338,6 +1341,9 @@ if test "x$enable_gallium_intel" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/intel drm/i965" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-i915 dri-i965" fi + if test "x$enable_egl" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-i915 egl-i965" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" elif test "x$enable_gallium_intel" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" @@ -1356,6 +1362,9 @@ if test "x$enable_gallium_radeon" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/radeon" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-radeong" fi + if test "x$enable_egl" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-radeon" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" elif test "x$enable_gallium_radeon" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" @@ -1374,6 +1383,9 @@ if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/nouveau" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-nouveau" fi + if test "x$enable_egl" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-nouveau" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" fi @@ -1382,11 +1394,18 @@ dnl Gallium swrast configuration dnl AC_ARG_ENABLE([gallium-swrast], [AS_HELP_STRING([--enable-gallium-swrast], - [build gallium swrast @<:@default=disabled@:>@])], + [build gallium swrast @<:@default=auto@:>@])], [enable_gallium_swrast="$enableval"], [enable_gallium_swrast=auto]) if test "x$enable_gallium_swrast" = xyes; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/swrast" + if test "x$enable_egl" != xyes; then + AC_MSG_ERROR([EGL needs to be enabled for egl-swrast target]) + fi + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast" +elif test "x$enable_gallium_swrast" = xauto; then + if test "x$enable_egl" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast" + fi fi dnl prepend CORE_DIRS to SRC_DIRS diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/targets/Makefile.egl similarity index 100% rename from src/gallium/winsys/drm/Makefile.egl rename to src/gallium/targets/Makefile.egl diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/targets/egl-i915/Makefile similarity index 86% rename from src/gallium/winsys/drm/intel/egl/Makefile rename to src/gallium/targets/egl-i915/Makefile index 60d675ca73d..596dd092f75 100644 --- a/src/gallium/winsys/drm/intel/egl/Makefile +++ b/src/gallium/targets/egl-i915/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current EGL_DRIVER_NAME = i915 @@ -11,4 +11,4 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i915/libi915.a -include ../../Makefile.egl +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/i965/egl/dummy.c b/src/gallium/targets/egl-i915/dummy.c similarity index 100% rename from src/gallium/winsys/drm/i965/egl/dummy.c rename to src/gallium/targets/egl-i915/dummy.c diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/targets/egl-i965/Makefile similarity index 86% rename from src/gallium/winsys/drm/i965/egl/Makefile rename to src/gallium/targets/egl-i965/Makefile index 1c132582005..e4c1a88f4c6 100644 --- a/src/gallium/winsys/drm/i965/egl/Makefile +++ b/src/gallium/targets/egl-i965/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current EGL_DRIVER_NAME = i965 @@ -11,4 +11,4 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i965/libi965.a -include ../../Makefile.egl +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/targets/egl-i965/dummy.c similarity index 100% rename from src/gallium/winsys/drm/intel/egl/dummy.c rename to src/gallium/targets/egl-i965/dummy.c diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/targets/egl-nouveau/Makefile similarity index 88% rename from src/gallium/winsys/drm/nouveau/egl/Makefile rename to src/gallium/targets/egl-nouveau/Makefile index 47d11276155..46fcdf5e4b0 100644 --- a/src/gallium/winsys/drm/nouveau/egl/Makefile +++ b/src/gallium/targets/egl-nouveau/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current EGL_DRIVER_NAME = nouveau @@ -12,4 +12,4 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a -include ../../Makefile.egl +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/nouveau/egl/dummy.c b/src/gallium/targets/egl-nouveau/dummy.c similarity index 100% rename from src/gallium/winsys/drm/nouveau/egl/dummy.c rename to src/gallium/targets/egl-nouveau/dummy.c diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/targets/egl-radeon/Makefile similarity index 87% rename from src/gallium/winsys/drm/radeon/egl/Makefile rename to src/gallium/targets/egl-radeon/Makefile index cd4f9b20f06..56818365dda 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/targets/egl-radeon/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current EGL_DRIVER_NAME = radeon @@ -11,4 +11,4 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -include ../../Makefile.egl +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/targets/egl-radeon/dummy.c similarity index 100% rename from src/gallium/winsys/drm/radeon/egl/dummy.c rename to src/gallium/targets/egl-radeon/dummy.c diff --git a/src/gallium/targets/egl-swrast/Makefile b/src/gallium/targets/egl-swrast/Makefile new file mode 100644 index 00000000000..937343defe5 --- /dev/null +++ b/src/gallium/targets/egl-swrast/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +# Do propperly +CFLAGS+="-I$(TOP)/src/gallium/include" + +EGL_DRIVER_NAME = swrast +EGL_DRIVER_SOURCES = swrast_glue.c +EGL_DRIVER_LIBS = +EGL_DRIVER_PIPES = $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c b/src/gallium/targets/egl-swrast/swrast_glue.c similarity index 60% rename from src/gallium/winsys/drm/swrast/core/swrast_drm_api.c rename to src/gallium/targets/egl-swrast/swrast_glue.c index 8c9f80e2c15..9db8089a666 100644 --- a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c +++ b/src/gallium/targets/egl-swrast/swrast_glue.c @@ -11,3 +11,7 @@ drm_api_create() (void) swrast_drm_api; return NULL; } + +/* A poor man's --whole-archive for EGL drivers */ +void *_eglMain(void *); +void *_eglWholeArchive = (void *) _eglMain; diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile similarity index 86% rename from src/gallium/winsys/drm/vmware/egl/Makefile rename to src/gallium/targets/egl-vmwgfx/Makefile index a3e73131c35..007158a6408 100644 --- a/src/gallium/winsys/drm/vmware/egl/Makefile +++ b/src/gallium/targets/egl-vmwgfx/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../.. include $(TOP)/configs/current EGL_DRIVER_NAME = vmwgfx @@ -11,4 +11,4 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a -include ../../Makefile.egl +include ../Makefile.egl diff --git a/src/gallium/winsys/drm/swrast/egl/dummy.c b/src/gallium/targets/egl-vmwgfx/dummy.c similarity index 100% rename from src/gallium/winsys/drm/swrast/egl/dummy.c rename to src/gallium/targets/egl-vmwgfx/dummy.c diff --git a/src/gallium/winsys/drm/swrast/Makefile b/src/gallium/winsys/drm/swrast/Makefile deleted file mode 100644 index 363b89584f2..00000000000 --- a/src/gallium/winsys/drm/swrast/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/drm/swrast/Makefile -TOP = ../../../../.. -include $(TOP)/configs/current - -SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done diff --git a/src/gallium/winsys/drm/swrast/core/Makefile b/src/gallium/winsys/drm/swrast/core/Makefile deleted file mode 100644 index 93931ae22b9..00000000000 --- a/src/gallium/winsys/drm/swrast/core/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# src/gallium/winsys/drm/swrast/core/Makefile - -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = swrastdrm - -C_SOURCES = swrast_drm_api.c - -include ../../../../Makefile.template diff --git a/src/gallium/winsys/drm/swrast/egl/Makefile b/src/gallium/winsys/drm/swrast/egl/Makefile deleted file mode 100644 index 26fe2d2805a..00000000000 --- a/src/gallium/winsys/drm/swrast/egl/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = swrast -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a - -include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/vmware/egl/dummy.c b/src/gallium/winsys/drm/vmware/egl/dummy.c deleted file mode 100644 index 3181d0ba7e8..00000000000 --- a/src/gallium/winsys/drm/vmware/egl/dummy.c +++ /dev/null @@ -1,3 +0,0 @@ -/* A poor man's --whole-archive for EGL drivers */ -void *_eglMain(void *); -void *_eglWholeArchive = (void *) _eglMain; From 43218a45a4cdbe2bc92867dc143f4b0e5fe9ca8d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 24 Mar 2010 11:45:30 +0100 Subject: [PATCH 321/483] gallium: Move xorg drivers to targets Attached output from git commit: rename src/gallium/{winsys/drm/intel/xorg => targets/xorg-i915}/Makefile (95%) rename src/gallium/{winsys/drm/intel/xorg => targets/xorg-i915}/intel_xorg.c (98%) rename src/gallium/{winsys/drm/i965/xorg => targets/xorg-i965}/Makefile (78%) rename src/gallium/{winsys/drm/i965/xorg => targets/xorg-i965}/intel_xorg.c (98%) rename src/gallium/{winsys/drm/nouveau/xorg => targets/xorg-nouveau}/Makefile (96%) rename src/gallium/{winsys/drm/nouveau/xorg => targets/xorg-nouveau}/nouveau_xorg.c (98%) rename src/gallium/{winsys/drm/radeon/xorg => targets/xorg-radeon}/Makefile (73%) rename src/gallium/{winsys/drm/radeon/xorg => targets/xorg-radeon}/radeon_xorg.c (98%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/Makefile (97%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/SConscript (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_driver.h (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_hook.h (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_ioctl.c (99%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_screen.c (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_video.c (99%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_xorg.c (100%) --- configure.ac | 12 ++++++++++ .../intel/xorg => targets/xorg-i915}/Makefile | 8 +++---- .../xorg => targets/xorg-i915}/intel_xorg.c | 2 +- .../i965/xorg => targets/xorg-i965}/Makefile | 20 ++++++----------- .../xorg => targets/xorg-i965}/intel_xorg.c | 2 +- .../xorg => targets/xorg-nouveau}/Makefile | 7 +++--- .../xorg-nouveau}/nouveau_xorg.c | 2 +- .../xorg => targets/xorg-radeon}/Makefile | 22 +++++++------------ .../xorg-radeon}/radeon_xorg.c | 2 +- .../xorg => targets/xorg-vmwgfx}/Makefile | 3 +-- .../xorg => targets/xorg-vmwgfx}/SConscript | 0 .../xorg => targets/xorg-vmwgfx}/vmw_driver.h | 0 .../xorg => targets/xorg-vmwgfx}/vmw_hook.h | 0 .../xorg => targets/xorg-vmwgfx}/vmw_ioctl.c | 2 +- .../xorg => targets/xorg-vmwgfx}/vmw_screen.c | 0 .../xorg => targets/xorg-vmwgfx}/vmw_video.c | 2 +- .../xorg => targets/xorg-vmwgfx}/vmw_xorg.c | 0 src/gallium/winsys/drm/vmware/SConscript | 4 ---- 18 files changed, 41 insertions(+), 47 deletions(-) rename src/gallium/{winsys/drm/intel/xorg => targets/xorg-i915}/Makefile (95%) rename src/gallium/{winsys/drm/intel/xorg => targets/xorg-i915}/intel_xorg.c (98%) rename src/gallium/{winsys/drm/i965/xorg => targets/xorg-i965}/Makefile (78%) rename src/gallium/{winsys/drm/i965/xorg => targets/xorg-i965}/intel_xorg.c (98%) rename src/gallium/{winsys/drm/nouveau/xorg => targets/xorg-nouveau}/Makefile (96%) rename src/gallium/{winsys/drm/nouveau/xorg => targets/xorg-nouveau}/nouveau_xorg.c (98%) rename src/gallium/{winsys/drm/radeon/xorg => targets/xorg-radeon}/Makefile (73%) rename src/gallium/{winsys/drm/radeon/xorg => targets/xorg-radeon}/radeon_xorg.c (98%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/Makefile (97%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/SConscript (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_driver.h (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_hook.h (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_ioctl.c (99%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_screen.c (100%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_video.c (99%) rename src/gallium/{winsys/drm/vmware/xorg => targets/xorg-vmwgfx}/vmw_xorg.c (100%) diff --git a/configure.ac b/configure.ac index dccff6f7cc4..c8f78dc74e8 100644 --- a/configure.ac +++ b/configure.ac @@ -1323,6 +1323,9 @@ if test "x$enable_gallium_svga" = xyes; then if test "x$enable_egl" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-vmwgfx" fi + if test "x$HAVE_XORG" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-vmwgfx" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" elif test "x$enable_gallium_svga" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" @@ -1344,6 +1347,9 @@ if test "x$enable_gallium_intel" = xyes; then if test "x$enable_egl" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-i915 egl-i965" fi + if test "x$HAVE_XORG" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-i915 xorg-i965" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" elif test "x$enable_gallium_intel" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" @@ -1365,6 +1371,9 @@ if test "x$enable_gallium_radeon" = xyes; then if test "x$enable_egl" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-radeon" fi + if test "x$HAVE_XORG" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-radeon" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" elif test "x$enable_gallium_radeon" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" @@ -1386,6 +1395,9 @@ if test "x$enable_gallium_nouveau" = xyes; then if test "x$enable_egl" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-nouveau" fi + if test "x$HAVE_XORG" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-nouveau" + fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" fi diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/targets/xorg-i915/Makefile similarity index 95% rename from src/gallium/winsys/drm/intel/xorg/Makefile rename to src/gallium/targets/xorg-i915/Makefile index 14c2462524b..4442147e83f 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/targets/xorg-i915/Makefile @@ -1,13 +1,13 @@ +TOP = ../../../.. +include $(TOP)/configs/current + TARGET = modesetting_drv.so CFILES = $(wildcard ./*.c) OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) -TOP = ../../../../../.. - -include $(TOP)/configs/current INCLUDES = \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ - -I../gem \ + -I$(TOP)/src/gallium/winsys/drm/intel/gem \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/gallium/auxiliary \ diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/targets/xorg-i915/intel_xorg.c similarity index 98% rename from src/gallium/winsys/drm/intel/xorg/intel_xorg.c rename to src/gallium/targets/xorg-i915/intel_xorg.c index 369dc356cf8..08f3b088636 100644 --- a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c +++ b/src/gallium/targets/xorg-i915/intel_xorg.c @@ -28,7 +28,7 @@ * */ -#include "../../../../state_trackers/xorg/xorg_winsys.h" +#include "../../state_trackers/xorg/xorg_winsys.h" static void intel_xorg_identify(int flags); static Bool intel_xorg_pci_probe(DriverPtr driver, diff --git a/src/gallium/winsys/drm/i965/xorg/Makefile b/src/gallium/targets/xorg-i965/Makefile similarity index 78% rename from src/gallium/winsys/drm/i965/xorg/Makefile rename to src/gallium/targets/xorg-i965/Makefile index c25726b0bb1..8d6a741e5d1 100644 --- a/src/gallium/winsys/drm/i965/xorg/Makefile +++ b/src/gallium/targets/xorg-i965/Makefile @@ -1,23 +1,17 @@ -TOP = ../../../../../.. - - -GALLIUMDIR = $(TOP)/src/gallium +TOP = ../../../.. +include $(TOP)/configs/current TARGET = i965g_drv.so - CFILES = $(wildcard ./*.c) - -include ${TOP}/configs/current - OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) CFLAGS = -DHAVE_CONFIG_H \ -g -Wall -Wimplicit-function-declaration -fPIC \ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \ - -I${GALLIUMDIR}/include \ - -I${GALLIUMDIR}/drivers \ - -I${GALLIUMDIR}/auxiliary \ - -I${TOP}/src/mesa \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/mesa \ -I$(TOP)/include \ -I$(TOP)/src/egl/main @@ -34,7 +28,7 @@ TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET) all default: $(TARGET) $(TARGET_STAGING) -$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS) +$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS) $(TOP)/bin/mklib -noprefix -o $@ \ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel diff --git a/src/gallium/winsys/drm/i965/xorg/intel_xorg.c b/src/gallium/targets/xorg-i965/intel_xorg.c similarity index 98% rename from src/gallium/winsys/drm/i965/xorg/intel_xorg.c rename to src/gallium/targets/xorg-i965/intel_xorg.c index ac691cb76b3..f4608f0eb41 100644 --- a/src/gallium/winsys/drm/i965/xorg/intel_xorg.c +++ b/src/gallium/targets/xorg-i965/intel_xorg.c @@ -28,7 +28,7 @@ * */ -#include "../../../../state_trackers/xorg/xorg_winsys.h" +#include "../../state_trackers/xorg/xorg_winsys.h" static void intel_xorg_identify(int flags); static Bool intel_xorg_pci_probe(DriverPtr driver, diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/targets/xorg-nouveau/Makefile similarity index 96% rename from src/gallium/winsys/drm/nouveau/xorg/Makefile rename to src/gallium/targets/xorg-nouveau/Makefile index f7f6fe17dd6..d41de0b3110 100644 --- a/src/gallium/winsys/drm/nouveau/xorg/Makefile +++ b/src/gallium/targets/xorg-nouveau/Makefile @@ -1,13 +1,12 @@ +TOP = ../../../.. +include $(TOP)/configs/current + TARGET = modesetting_drv.so CFILES = $(wildcard ./*.c) OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) -TOP = ../../../../../.. - -include $(TOP)/configs/current INCLUDES = \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ - -I../gem \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/gallium/auxiliary \ diff --git a/src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c b/src/gallium/targets/xorg-nouveau/nouveau_xorg.c similarity index 98% rename from src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c rename to src/gallium/targets/xorg-nouveau/nouveau_xorg.c index a669b3080aa..699af09029f 100644 --- a/src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c +++ b/src/gallium/targets/xorg-nouveau/nouveau_xorg.c @@ -28,7 +28,7 @@ * */ -#include "../../../../state_trackers/xorg/xorg_winsys.h" +#include "../../state_trackers/xorg/xorg_winsys.h" static void nouveau_xorg_identify(int flags); static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num, diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/targets/xorg-radeon/Makefile similarity index 73% rename from src/gallium/winsys/drm/radeon/xorg/Makefile rename to src/gallium/targets/xorg-radeon/Makefile index 0eb1b3988f3..9618d30b4d6 100644 --- a/src/gallium/winsys/drm/radeon/xorg/Makefile +++ b/src/gallium/targets/xorg-radeon/Makefile @@ -1,29 +1,23 @@ -TOP = ../../../../../.. - - -GALLIUMDIR = $(TOP)/src/gallium +TOP = ../../../.. +include $(TOP)/configs/current TARGET = radeong_drv.so - CFILES = $(wildcard ./*.c) - -include ${TOP}/configs/current - OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) CFLAGS = -DHAVE_CONFIG_H \ -g -Wall -Wimplicit-function-declaration -fPIC \ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \ - -I${GALLIUMDIR}/include \ - -I${GALLIUMDIR}/drivers \ - -I${GALLIUMDIR}/auxiliary \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary \ -I${TOP}/src/mesa \ -I$(TOP)/include \ -I$(TOP)/src/egl/main LIBS = \ - $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \ - $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/r300/libr300.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ @@ -34,7 +28,7 @@ TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET) all default: $(TARGET) $(TARGET_STAGING) -$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS) +$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS) $(TOP)/bin/mklib -noprefix -o $@ \ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/targets/xorg-radeon/radeon_xorg.c similarity index 98% rename from src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c rename to src/gallium/targets/xorg-radeon/radeon_xorg.c index bb76cc03499..0d6aa567229 100644 --- a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c +++ b/src/gallium/targets/xorg-radeon/radeon_xorg.c @@ -29,7 +29,7 @@ * */ -#include "../../../../state_trackers/xorg/xorg_winsys.h" +#include "../../state_trackers/xorg/xorg_winsys.h" static void radeon_xorg_identify(int flags); static Bool radeon_xorg_pci_probe(DriverPtr driver, diff --git a/src/gallium/winsys/drm/vmware/xorg/Makefile b/src/gallium/targets/xorg-vmwgfx/Makefile similarity index 97% rename from src/gallium/winsys/drm/vmware/xorg/Makefile rename to src/gallium/targets/xorg-vmwgfx/Makefile index 49e28ae17f5..3691b883588 100644 --- a/src/gallium/winsys/drm/vmware/xorg/Makefile +++ b/src/gallium/targets/xorg-vmwgfx/Makefile @@ -1,5 +1,4 @@ -TOP = ../../../../../.. - +TOP = ../../../.. include $(TOP)/configs/current TARGET = vmwgfx_drv.so diff --git a/src/gallium/winsys/drm/vmware/xorg/SConscript b/src/gallium/targets/xorg-vmwgfx/SConscript similarity index 100% rename from src/gallium/winsys/drm/vmware/xorg/SConscript rename to src/gallium/targets/xorg-vmwgfx/SConscript diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h similarity index 100% rename from src/gallium/winsys/drm/vmware/xorg/vmw_driver.h rename to src/gallium/targets/xorg-vmwgfx/vmw_driver.h diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h b/src/gallium/targets/xorg-vmwgfx/vmw_hook.h similarity index 100% rename from src/gallium/winsys/drm/vmware/xorg/vmw_hook.h rename to src/gallium/targets/xorg-vmwgfx/vmw_hook.h diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c similarity index 99% rename from src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c rename to src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c index 521578ab35d..fe9c0393e23 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c +++ b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c @@ -42,7 +42,7 @@ #include #include "xf86drm.h" -#include "../core/vmwgfx_drm.h" +#include "../../winsys/drm/vmware/core/vmwgfx_drm.h" #include "vmw_driver.h" #include "util/u_debug.h" diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c similarity index 100% rename from src/gallium/winsys/drm/vmware/xorg/vmw_screen.c rename to src/gallium/targets/xorg-vmwgfx/vmw_screen.c diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/targets/xorg-vmwgfx/vmw_video.c similarity index 99% rename from src/gallium/winsys/drm/vmware/xorg/vmw_video.c rename to src/gallium/targets/xorg-vmwgfx/vmw_video.c index de28f06a475..7909999edfb 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c +++ b/src/gallium/targets/xorg-vmwgfx/vmw_video.c @@ -62,7 +62,7 @@ typedef uint8_t uint8; #include #include "xf86drm.h" -#include "../core/vmwgfx_drm.h" +#include "../../winsys/drm/vmware/core/vmwgfx_drm.h" #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/targets/xorg-vmwgfx/vmw_xorg.c similarity index 100% rename from src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c rename to src/gallium/targets/xorg-vmwgfx/vmw_xorg.c diff --git a/src/gallium/winsys/drm/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript index e4da31a6933..eff87e7d010 100644 --- a/src/gallium/winsys/drm/vmware/SConscript +++ b/src/gallium/winsys/drm/vmware/SConscript @@ -1,7 +1,3 @@ Import('*') SConscript(['core/SConscript',]) - -if 'xorg' in env['statetrackers']: - - SConscript(['xorg/SConscript']) From c9f98673c5b6830cd1f41c0c53a9e5e299d47464 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Mar 2010 13:54:18 +0000 Subject: [PATCH 322/483] gallium: Reorg winsys directories Attached output from commit. delete mode 100644 src/gallium/winsys/drm/SConscript delete mode 100644 src/gallium/winsys/drm/i965/SConscript delete mode 100644 src/gallium/winsys/drm/intel/Makefile delete mode 100644 src/gallium/winsys/drm/intel/SConscript delete mode 100644 src/gallium/winsys/drm/nouveau/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/SConscript delete mode 100644 src/gallium/winsys/drm/vmware/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/SConscript rename src/gallium/winsys/{drm/intel/gem => i915/drm}/Makefile (82%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/SConscript (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_api.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_batchbuffer.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_buffer.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_fence.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_winsys.h (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/Makefile (78%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/SConscript (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_api.c (98%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_buffer.c (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_winsys.h (100%) rename src/gallium/winsys/{drm => }/i965/xlib/Makefile (97%) rename src/gallium/winsys/{drm => }/i965/xlib/xlib_i965.c (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/Makefile (79%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_dri.h (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_drm_api.c (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_drm_api.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/Makefile (79%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/SConscript (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_buffer.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm_buffer.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_r300.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_r300.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_winsys.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/Makefile (63%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/SConscript (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_buffer.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_buffer.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_context.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_context.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_fence.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_fence.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_dri.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_ioctl.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_pools.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_svga.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_surface.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_surface.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmwgfx_drm.h (100%) rename src/gallium/winsys/{drm/i965 => sw}/Makefile (61%) copy src/gallium/winsys/{drm/sw => sw/drm}/Makefile (73%) rename src/gallium/winsys/{drm/sw => sw/drm}/sw_drm_api.c (98%) rename src/gallium/winsys/{drm/sw => sw/drm}/sw_drm_api.h (100%) rename src/gallium/winsys/{ => sw}/gdi/SConscript (100%) rename src/gallium/winsys/{ => sw}/gdi/gdi_sw_winsys.c (100%) rename src/gallium/winsys/{ => sw}/gdi/gdi_sw_winsys.h (100%) rename src/gallium/winsys/{ => sw}/null/Makefile (78%) rename src/gallium/winsys/{ => sw}/null/SConscript (100%) rename src/gallium/winsys/{ => sw}/null/null_sw_winsys.c (100%) rename src/gallium/winsys/{ => sw}/null/null_sw_winsys.h (100%) rename src/gallium/winsys/{drm/sw => sw/wrapper}/Makefile (65%) rename src/gallium/winsys/{drm/sw => sw/wrapper}/wrapper_sw_winsys.c (100%) rename src/gallium/winsys/{drm/sw => sw/wrapper}/wrapper_sw_winsys.h (100%) rename src/gallium/winsys/{ => sw}/xlib/Makefile (79%) rename src/gallium/winsys/{ => sw}/xlib/SConscript (100%) rename src/gallium/winsys/{ => sw}/xlib/xlib_sw_winsys.c (100%) --- configs/default | 2 +- configs/linux-dri | 2 +- configure.ac | 14 ++-- src/gallium/SConscript | 2 +- src/gallium/targets/Makefile.egl | 2 +- src/gallium/targets/dri-i915/Makefile | 2 +- src/gallium/targets/dri-i965/Makefile | 5 +- src/gallium/targets/dri-nouveau/Makefile | 2 +- src/gallium/targets/dri-radeong/Makefile | 2 +- src/gallium/targets/dri-vmwgfx/Makefile | 2 +- src/gallium/targets/egl-i915/Makefile | 2 +- src/gallium/targets/egl-i965/Makefile | 2 +- src/gallium/targets/egl-nouveau/Makefile | 2 +- src/gallium/targets/egl-radeon/Makefile | 2 +- src/gallium/targets/egl-vmwgfx/Makefile | 2 +- src/gallium/targets/xorg-i915/Makefile | 2 +- src/gallium/targets/xorg-i965/Makefile | 2 +- src/gallium/targets/xorg-nouveau/Makefile | 2 +- src/gallium/targets/xorg-radeon/Makefile | 2 +- src/gallium/targets/xorg-vmwgfx/Makefile | 2 +- src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c | 2 +- src/gallium/targets/xorg-vmwgfx/vmw_video.c | 2 +- src/gallium/winsys/SConscript | 9 +-- src/gallium/winsys/drm/SConscript | 69 ------------------- src/gallium/winsys/drm/i965/SConscript | 3 - src/gallium/winsys/drm/intel/Makefile | 12 ---- src/gallium/winsys/drm/intel/SConscript | 3 - src/gallium/winsys/drm/nouveau/Makefile | 12 ---- src/gallium/winsys/drm/radeon/Makefile | 12 ---- src/gallium/winsys/drm/radeon/SConscript | 3 - src/gallium/winsys/drm/vmware/Makefile | 12 ---- src/gallium/winsys/drm/vmware/SConscript | 3 - .../{drm/intel/gem => i915/drm}/Makefile | 4 +- .../{drm/intel/gem => i915/drm}/SConscript | 0 .../intel/gem => i915/drm}/intel_drm_api.c | 0 .../gem => i915/drm}/intel_drm_batchbuffer.c | 0 .../intel/gem => i915/drm}/intel_drm_buffer.c | 0 .../intel/gem => i915/drm}/intel_drm_fence.c | 0 .../intel/gem => i915/drm}/intel_drm_winsys.h | 0 .../{drm/i965/gem => i965/drm}/Makefile | 4 +- .../{drm/i965/gem => i965/drm}/SConscript | 0 .../{drm/i965/gem => i965/drm}/i965_drm_api.c | 2 +- .../i965/gem => i965/drm}/i965_drm_buffer.c | 0 .../i965/gem => i965/drm}/i965_drm_winsys.h | 0 .../winsys/{drm => }/i965/xlib/Makefile | 4 +- .../winsys/{drm => }/i965/xlib/xlib_i965.c | 0 .../winsys/{drm => }/nouveau/drm/Makefile | 4 +- .../{drm => }/nouveau/drm/nouveau_dri.h | 0 .../{drm => }/nouveau/drm/nouveau_drm_api.c | 0 .../{drm => }/nouveau/drm/nouveau_drm_api.h | 0 .../{drm/radeon/core => radeon/drm}/Makefile | 4 +- .../radeon/core => radeon/drm}/SConscript | 0 .../core => radeon/drm}/radeon_buffer.h | 0 .../radeon/core => radeon/drm}/radeon_drm.c | 0 .../radeon/core => radeon/drm}/radeon_drm.h | 0 .../core => radeon/drm}/radeon_drm_buffer.c | 0 .../radeon/core => radeon/drm}/radeon_r300.c | 0 .../radeon/core => radeon/drm}/radeon_r300.h | 0 .../core => radeon/drm}/radeon_winsys.h | 0 .../{drm/vmware/core => svga/drm}/Makefile | 12 +--- .../{drm/vmware/core => svga/drm}/SConscript | 0 .../vmware/core => svga/drm}/vmw_buffer.c | 0 .../vmware/core => svga/drm}/vmw_buffer.h | 0 .../vmware/core => svga/drm}/vmw_context.c | 0 .../vmware/core => svga/drm}/vmw_context.h | 0 .../{drm/vmware/core => svga/drm}/vmw_fence.c | 0 .../{drm/vmware/core => svga/drm}/vmw_fence.h | 0 .../vmware/core => svga/drm}/vmw_screen.c | 0 .../vmware/core => svga/drm}/vmw_screen.h | 0 .../vmware/core => svga/drm}/vmw_screen_dri.c | 0 .../core => svga/drm}/vmw_screen_ioctl.c | 0 .../core => svga/drm}/vmw_screen_pools.c | 0 .../core => svga/drm}/vmw_screen_svga.c | 0 .../vmware/core => svga/drm}/vmw_surface.c | 0 .../vmware/core => svga/drm}/vmw_surface.h | 0 .../vmware/core => svga/drm}/vmwgfx_drm.h | 0 src/gallium/winsys/{drm/i965 => sw}/Makefile | 6 +- .../winsys/{drm/sw => sw/drm}/Makefile | 4 +- .../winsys/{drm/sw => sw/drm}/sw_drm_api.c | 2 +- .../winsys/{drm/sw => sw/drm}/sw_drm_api.h | 0 src/gallium/winsys/{ => sw}/gdi/SConscript | 0 .../winsys/{ => sw}/gdi/gdi_sw_winsys.c | 0 .../winsys/{ => sw}/gdi/gdi_sw_winsys.h | 0 src/gallium/winsys/{ => sw}/null/Makefile | 4 +- src/gallium/winsys/{ => sw}/null/SConscript | 0 .../winsys/{ => sw}/null/null_sw_winsys.c | 0 .../winsys/{ => sw}/null/null_sw_winsys.h | 0 src/gallium/winsys/sw/wrapper/Makefile | 12 ++++ .../sw => sw/wrapper}/wrapper_sw_winsys.c | 0 .../sw => sw/wrapper}/wrapper_sw_winsys.h | 0 src/gallium/winsys/{ => sw}/xlib/Makefile | 4 +- src/gallium/winsys/{ => sw}/xlib/SConscript | 0 .../winsys/{ => sw}/xlib/xlib_sw_winsys.c | 0 93 files changed, 66 insertions(+), 197 deletions(-) delete mode 100644 src/gallium/winsys/drm/SConscript delete mode 100644 src/gallium/winsys/drm/i965/SConscript delete mode 100644 src/gallium/winsys/drm/intel/Makefile delete mode 100644 src/gallium/winsys/drm/intel/SConscript delete mode 100644 src/gallium/winsys/drm/nouveau/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/SConscript delete mode 100644 src/gallium/winsys/drm/vmware/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/SConscript rename src/gallium/winsys/{drm/intel/gem => i915/drm}/Makefile (82%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/SConscript (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_api.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_batchbuffer.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_buffer.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_fence.c (100%) rename src/gallium/winsys/{drm/intel/gem => i915/drm}/intel_drm_winsys.h (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/Makefile (78%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/SConscript (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_api.c (98%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_buffer.c (100%) rename src/gallium/winsys/{drm/i965/gem => i965/drm}/i965_drm_winsys.h (100%) rename src/gallium/winsys/{drm => }/i965/xlib/Makefile (97%) rename src/gallium/winsys/{drm => }/i965/xlib/xlib_i965.c (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/Makefile (79%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_dri.h (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_drm_api.c (100%) rename src/gallium/winsys/{drm => }/nouveau/drm/nouveau_drm_api.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/Makefile (79%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/SConscript (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_buffer.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_drm_buffer.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_r300.c (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_r300.h (100%) rename src/gallium/winsys/{drm/radeon/core => radeon/drm}/radeon_winsys.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/Makefile (63%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/SConscript (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_buffer.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_buffer.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_context.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_context.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_fence.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_fence.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_dri.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_ioctl.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_pools.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_screen_svga.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_surface.c (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmw_surface.h (100%) rename src/gallium/winsys/{drm/vmware/core => svga/drm}/vmwgfx_drm.h (100%) rename src/gallium/winsys/{drm/i965 => sw}/Makefile (61%) rename src/gallium/winsys/{drm/sw => sw/drm}/Makefile (73%) rename src/gallium/winsys/{drm/sw => sw/drm}/sw_drm_api.c (98%) rename src/gallium/winsys/{drm/sw => sw/drm}/sw_drm_api.h (100%) rename src/gallium/winsys/{ => sw}/gdi/SConscript (100%) rename src/gallium/winsys/{ => sw}/gdi/gdi_sw_winsys.c (100%) rename src/gallium/winsys/{ => sw}/gdi/gdi_sw_winsys.h (100%) rename src/gallium/winsys/{ => sw}/null/Makefile (78%) rename src/gallium/winsys/{ => sw}/null/SConscript (100%) rename src/gallium/winsys/{ => sw}/null/null_sw_winsys.c (100%) rename src/gallium/winsys/{ => sw}/null/null_sw_winsys.h (100%) create mode 100644 src/gallium/winsys/sw/wrapper/Makefile rename src/gallium/winsys/{drm/sw => sw/wrapper}/wrapper_sw_winsys.c (100%) rename src/gallium/winsys/{drm/sw => sw/wrapper}/wrapper_sw_winsys.h (100%) rename src/gallium/winsys/{ => sw}/xlib/Makefile (79%) rename src/gallium/winsys/{ => sw}/xlib/SConscript (100%) rename src/gallium/winsys/{ => sw}/xlib/xlib_sw_winsys.c (100%) diff --git a/configs/default b/configs/default index 65e9847bd20..77a9898775c 100644 --- a/configs/default +++ b/configs/default @@ -100,7 +100,7 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = null xlib +GALLIUM_WINSYS_DIRS = sw sw/xlib GALLIUM_TARGET_DIRS = libgl-xlib GALLIUM_STATE_TRACKERS_DIRS = glx vega diff --git a/configs/linux-dri b/configs/linux-dri index b11daeda7c2..e21a3e95943 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -58,7 +58,7 @@ PROGRAM_DIRS := egl $(PROGRAM_DIRS) EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri -GALLIUM_WINSYS_DIRS = null xlib drm/vmware drm/intel drm/i965 +GALLIUM_WINSYS_DIRS = sw sw/xlib drm/vmware drm/intel drm/i965 GALLIUM_TARGET_DIRS = egl-swrast GALLIUM_STATE_TRACKERS_DIRS = egl diff --git a/configure.ac b/configure.ac index c8f78dc74e8..edf2363a717 100644 --- a/configure.ac +++ b/configure.ac @@ -461,20 +461,20 @@ SRC_DIRS="glew" GLU_DIRS="sgi" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_TARGET_DIRS="" -GALLIUM_WINSYS_DIRS="null" +GALLIUM_WINSYS_DIRS="sw" GALLIUM_DRIVERS_DIRS="softpipe failover trace identity" GALLIUM_STATE_TRACKERS_DIRS="" case "$mesa_driver" in xlib) DRIVER_DIRS="x11" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib" ;; dri) SRC_DIRS="$SRC_DIRS glx" DRIVER_DIRS="dri" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib drm/sw" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/drm" ;; osmesa) DRIVER_DIRS="osmesa" @@ -1317,7 +1317,7 @@ AC_ARG_ENABLE([gallium-svga], [enable_gallium_svga=auto]) if test "x$enable_gallium_svga" = xyes; then if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/vmware" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS svga/drm" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-vmwgfx" fi if test "x$enable_egl" = xyes; then @@ -1341,7 +1341,7 @@ AC_ARG_ENABLE([gallium-intel], [enable_gallium_intel=auto]) if test "x$enable_gallium_intel" = xyes; then if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/intel drm/i965" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/drm i965/drm" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-i915 dri-i965" fi if test "x$enable_egl" = xyes; then @@ -1365,7 +1365,7 @@ AC_ARG_ENABLE([gallium-radeon], [enable_gallium_radeon=auto]) if test "x$enable_gallium_radeon" = xyes; then if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/radeon" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS radeon/drm" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-radeong" fi if test "x$enable_egl" = xyes; then @@ -1389,7 +1389,7 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm/nouveau" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS nouveau/drm" GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-nouveau" fi if test "x$enable_egl" = xyes; then diff --git a/src/gallium/SConscript b/src/gallium/SConscript index c833d83e65b..b8c04f72379 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -8,7 +8,7 @@ for driver in env['drivers']: SConscript(os.path.join('drivers', driver, 'SConscript')) # Needed by some state trackers -SConscript('winsys/null/SConscript') +SConscript('winsys/sw/null/SConscript') SConscript('state_trackers/python/SConscript') if platform != 'embedded': diff --git a/src/gallium/targets/Makefile.egl b/src/gallium/targets/Makefile.egl index bc5dd3a53b8..30fced7e3c8 100644 --- a/src/gallium/targets/Makefile.egl +++ b/src/gallium/targets/Makefile.egl @@ -14,7 +14,7 @@ EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) common_LIBS = -ldrm -lm -ldl x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \ - $(TOP)/src/gallium/winsys/xlib/libws_xlib.a + $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile index 33eaae624f2..facbcb1803a 100644 --- a/src/gallium/targets/dri-i915/Makefile +++ b/src/gallium/targets/dri-i915/Makefile @@ -5,7 +5,7 @@ LIBNAME = i915_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ diff --git a/src/gallium/targets/dri-i965/Makefile b/src/gallium/targets/dri-i965/Makefile index e17775a842a..c622bbcaf65 100644 --- a/src/gallium/targets/dri-i965/Makefile +++ b/src/gallium/targets/dri-i965/Makefile @@ -5,9 +5,10 @@ LIBNAME = i965_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/winsys/drm/sw/libswdrm.a \ + $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \ + $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i965/libi965.a diff --git a/src/gallium/targets/dri-nouveau/Makefile b/src/gallium/targets/dri-nouveau/Makefile index 680bad79177..9ba5e18ba70 100644 --- a/src/gallium/targets/dri-nouveau/Makefile +++ b/src/gallium/targets/dri-nouveau/Makefile @@ -5,7 +5,7 @@ LIBNAME = nouveau_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a diff --git a/src/gallium/targets/dri-radeong/Makefile b/src/gallium/targets/dri-radeong/Makefile index c6d8c524694..ce25559e946 100644 --- a/src/gallium/targets/dri-radeong/Makefile +++ b/src/gallium/targets/dri-radeong/Makefile @@ -5,7 +5,7 @@ LIBNAME = radeong_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile index 1d2ddfe548f..32edc46a3d9 100644 --- a/src/gallium/targets/dri-vmwgfx/Makefile +++ b/src/gallium/targets/dri-vmwgfx/Makefile @@ -5,7 +5,7 @@ LIBNAME = vmwgfx_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile index 596dd092f75..6c2fc14d70f 100644 --- a/src/gallium/targets/egl-i915/Makefile +++ b/src/gallium/targets/egl-i915/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i915/libi915.a diff --git a/src/gallium/targets/egl-i965/Makefile b/src/gallium/targets/egl-i965/Makefile index e4c1a88f4c6..dfb3cc45a7d 100644 --- a/src/gallium/targets/egl-i965/Makefile +++ b/src/gallium/targets/egl-i965/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i965/libi965.a diff --git a/src/gallium/targets/egl-nouveau/Makefile b/src/gallium/targets/egl-nouveau/Makefile index 46fcdf5e4b0..3da93790f25 100644 --- a/src/gallium/targets/egl-nouveau/Makefile +++ b/src/gallium/targets/egl-nouveau/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_nouveau EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ diff --git a/src/gallium/targets/egl-radeon/Makefile b/src/gallium/targets/egl-radeon/Makefile index 56818365dda..f55d84de810 100644 --- a/src/gallium/targets/egl-radeon/Makefile +++ b/src/gallium/targets/egl-radeon/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_radeon EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a diff --git a/src/gallium/targets/egl-vmwgfx/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile index 007158a6408..6db12e03a75 100644 --- a/src/gallium/targets/egl-vmwgfx/Makefile +++ b/src/gallium/targets/egl-vmwgfx/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a diff --git a/src/gallium/targets/xorg-i915/Makefile b/src/gallium/targets/xorg-i915/Makefile index 4442147e83f..e2cffcd70b3 100644 --- a/src/gallium/targets/xorg-i915/Makefile +++ b/src/gallium/targets/xorg-i915/Makefile @@ -17,7 +17,7 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ $(TOP)/src/gallium/drivers/i915/libi915.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/targets/xorg-i965/Makefile b/src/gallium/targets/xorg-i965/Makefile index 8d6a741e5d1..104a1434a84 100644 --- a/src/gallium/targets/xorg-i965/Makefile +++ b/src/gallium/targets/xorg-i965/Makefile @@ -17,7 +17,7 @@ CFLAGS = -DHAVE_CONFIG_H \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/i965/libi965.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/targets/xorg-nouveau/Makefile b/src/gallium/targets/xorg-nouveau/Makefile index d41de0b3110..b514b570007 100644 --- a/src/gallium/targets/xorg-nouveau/Makefile +++ b/src/gallium/targets/xorg-nouveau/Makefile @@ -16,7 +16,7 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile index 9618d30b4d6..cd32914c0d3 100644 --- a/src/gallium/targets/xorg-radeon/Makefile +++ b/src/gallium/targets/xorg-radeon/Makefile @@ -17,7 +17,7 @@ CFLAGS = -DHAVE_CONFIG_H \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/r300/libr300.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/targets/xorg-vmwgfx/Makefile b/src/gallium/targets/xorg-vmwgfx/Makefile index 3691b883588..12bc307ef9b 100644 --- a/src/gallium/targets/xorg-vmwgfx/Makefile +++ b/src/gallium/targets/xorg-vmwgfx/Makefile @@ -20,7 +20,7 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c index fe9c0393e23..96ee4ff82b4 100644 --- a/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c +++ b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c @@ -42,7 +42,7 @@ #include #include "xf86drm.h" -#include "../../winsys/drm/vmware/core/vmwgfx_drm.h" +#include "../../winsys/svga/drm/vmwgfx_drm.h" #include "vmw_driver.h" #include "util/u_debug.h" diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_video.c b/src/gallium/targets/xorg-vmwgfx/vmw_video.c index 7909999edfb..eced60d0ec1 100644 --- a/src/gallium/targets/xorg-vmwgfx/vmw_video.c +++ b/src/gallium/targets/xorg-vmwgfx/vmw_video.c @@ -62,7 +62,7 @@ typedef uint8_t uint8; #include #include "xf86drm.h" -#include "../../winsys/drm/vmware/core/vmwgfx_drm.h" +#include "../../winsys/svga/drm/vmwgfx_drm.h" #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 30c3378dfff..97ea82ea761 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -1,16 +1,11 @@ Import('*') -if env['dri']: - SConscript([ - 'drm/SConscript', - ]) - if 'xlib' in env['winsys']: SConscript([ - 'xlib/SConscript', + 'sw/xlib/SConscript', ]) if 'gdi' in env['winsys']: SConscript([ - 'gdi/SConscript', + 'sw/gdi/SConscript', ]) diff --git a/src/gallium/winsys/drm/SConscript b/src/gallium/winsys/drm/SConscript deleted file mode 100644 index 66b73a8bf93..00000000000 --- a/src/gallium/winsys/drm/SConscript +++ /dev/null @@ -1,69 +0,0 @@ -Import('*') - -if env['dri']: - - drienv = env.Clone() - - drienv.Replace(CPPPATH = [ - '#src/mesa/drivers/dri/common', - '#include', - '#include/GL/internal', - '#src/gallium/include', - '#src/gallium/auxiliary', - '#src/gallium/drivers', - '#src/mesa', - '#src/mesa/main', - '#src/mesa/glapi', - '#src/mesa/math', - '#src/mesa/transform', - '#src/mesa/shader', - '#src/mesa/swrast', - '#src/mesa/swrast_setup', - '#src/egl/main', - '#src/egl/drivers/dri', - ]) - - drienv.ParseConfig('pkg-config --cflags --libs libdrm') - - COMMON_GALLIUM_SOURCES = [ - '#src/mesa/drivers/dri/common/utils.c', - '#src/mesa/drivers/dri/common/vblank.c', - '#src/mesa/drivers/dri/common/dri_util.c', - '#src/mesa/drivers/dri/common/xmlconfig.c', - ] - - COMMON_BM_SOURCES = [ - '#src/mesa/drivers/dri/common/dri_bufmgr.c', - '#src/mesa/drivers/dri/common/dri_drmpool.c', - ] - - Export([ - 'drienv', - 'COMMON_GALLIUM_SOURCES', - 'COMMON_BM_SOURCES', - ]) - - # TODO: Installation - #install: $(LIBNAME) - # $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR) - # $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR) - - if 'vmware' in env['winsys']: - SConscript([ - 'vmware/SConscript', - ]) - - if 'intel' in env['winsys']: - SConscript([ - 'intel/SConscript', - ]) - - if 'i965' in env['winsys']: - SConscript([ - 'i965/SConscript', - ]) - - if 'radeon' in env['winsys']: - SConscript([ - 'radeon/SConscript', - ]) diff --git a/src/gallium/winsys/drm/i965/SConscript b/src/gallium/winsys/drm/i965/SConscript deleted file mode 100644 index fdf57eedb94..00000000000 --- a/src/gallium/winsys/drm/i965/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -Import('*') - -SConscript(['gem/SConscript',]) diff --git a/src/gallium/winsys/drm/intel/Makefile b/src/gallium/winsys/drm/intel/Makefile deleted file mode 100644 index d8feef6824a..00000000000 --- a/src/gallium/winsys/drm/intel/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/drm/intel/Makefile -TOP = ../../../../.. -include $(TOP)/configs/current - -SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done diff --git a/src/gallium/winsys/drm/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript deleted file mode 100644 index fdf57eedb94..00000000000 --- a/src/gallium/winsys/drm/intel/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -Import('*') - -SConscript(['gem/SConscript',]) diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile deleted file mode 100644 index 6c9cbef26df..00000000000 --- a/src/gallium/winsys/drm/nouveau/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/drm/nouveau/Makefile -TOP = ../../../../.. -include $(TOP)/configs/current - -SUBDIRS = drm $(GALLIUM_STATE_TRACKERS_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile deleted file mode 100644 index bacdf3de28a..00000000000 --- a/src/gallium/winsys/drm/radeon/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/drm/radeon/Makefile -TOP = ../../../../.. -include $(TOP)/configs/current - -SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done diff --git a/src/gallium/winsys/drm/radeon/SConscript b/src/gallium/winsys/drm/radeon/SConscript deleted file mode 100644 index eff87e7d010..00000000000 --- a/src/gallium/winsys/drm/radeon/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -Import('*') - -SConscript(['core/SConscript',]) diff --git a/src/gallium/winsys/drm/vmware/Makefile b/src/gallium/winsys/drm/vmware/Makefile deleted file mode 100644 index 2ae6dead5c1..00000000000 --- a/src/gallium/winsys/drm/vmware/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# src/gallium/winsys/drm/vmware/Makefile -TOP = ../../../../.. -include $(TOP)/configs/current - -SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS) - -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done diff --git a/src/gallium/winsys/drm/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript deleted file mode 100644 index eff87e7d010..00000000000 --- a/src/gallium/winsys/drm/vmware/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -Import('*') - -SConscript(['core/SConscript',]) diff --git a/src/gallium/winsys/drm/intel/gem/Makefile b/src/gallium/winsys/i915/drm/Makefile similarity index 82% rename from src/gallium/winsys/drm/intel/gem/Makefile rename to src/gallium/winsys/i915/drm/Makefile index 0d6d4e37dbd..4aac3309aa7 100644 --- a/src/gallium/winsys/drm/intel/gem/Makefile +++ b/src/gallium/winsys/i915/drm/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = inteldrm @@ -13,4 +13,4 @@ LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other) -include ../../../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/intel/gem/SConscript b/src/gallium/winsys/i915/drm/SConscript similarity index 100% rename from src/gallium/winsys/drm/intel/gem/SConscript rename to src/gallium/winsys/i915/drm/SConscript diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/i915/drm/intel_drm_api.c similarity index 100% rename from src/gallium/winsys/drm/intel/gem/intel_drm_api.c rename to src/gallium/winsys/i915/drm/intel_drm_api.c diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c b/src/gallium/winsys/i915/drm/intel_drm_batchbuffer.c similarity index 100% rename from src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c rename to src/gallium/winsys/i915/drm/intel_drm_batchbuffer.c diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c b/src/gallium/winsys/i915/drm/intel_drm_buffer.c similarity index 100% rename from src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c rename to src/gallium/winsys/i915/drm/intel_drm_buffer.c diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c b/src/gallium/winsys/i915/drm/intel_drm_fence.c similarity index 100% rename from src/gallium/winsys/drm/intel/gem/intel_drm_fence.c rename to src/gallium/winsys/i915/drm/intel_drm_fence.c diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h b/src/gallium/winsys/i915/drm/intel_drm_winsys.h similarity index 100% rename from src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h rename to src/gallium/winsys/i915/drm/intel_drm_winsys.h diff --git a/src/gallium/winsys/drm/i965/gem/Makefile b/src/gallium/winsys/i965/drm/Makefile similarity index 78% rename from src/gallium/winsys/drm/i965/gem/Makefile rename to src/gallium/winsys/i965/drm/Makefile index 6a7497b6be3..bbb71e25d84 100644 --- a/src/gallium/winsys/drm/i965/gem/Makefile +++ b/src/gallium/winsys/i965/drm/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = i965drm @@ -11,4 +11,4 @@ LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other) -include ../../../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/i965/gem/SConscript b/src/gallium/winsys/i965/drm/SConscript similarity index 100% rename from src/gallium/winsys/drm/i965/gem/SConscript rename to src/gallium/winsys/i965/drm/SConscript diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/i965/drm/i965_drm_api.c similarity index 98% rename from src/gallium/winsys/drm/i965/gem/i965_drm_api.c rename to src/gallium/winsys/i965/drm/i965_drm_api.c index c644eedcb31..9072a186384 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c +++ b/src/gallium/winsys/i965/drm/i965_drm_api.c @@ -10,7 +10,7 @@ #include "trace/tr_drm.h" -#include "../../sw/sw_drm_api.h" +#include "../../sw/drm/sw_drm_api.h" /* * Helper functions diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/i965/drm/i965_drm_buffer.c similarity index 100% rename from src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c rename to src/gallium/winsys/i965/drm/i965_drm_buffer.c diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h b/src/gallium/winsys/i965/drm/i965_drm_winsys.h similarity index 100% rename from src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h rename to src/gallium/winsys/i965/drm/i965_drm_winsys.h diff --git a/src/gallium/winsys/drm/i965/xlib/Makefile b/src/gallium/winsys/i965/xlib/Makefile similarity index 97% rename from src/gallium/winsys/drm/i965/xlib/Makefile rename to src/gallium/winsys/i965/xlib/Makefile index 0efa0ca6f9a..3730db6997e 100644 --- a/src/gallium/winsys/drm/i965/xlib/Makefile +++ b/src/gallium/winsys/i965/xlib/Makefile @@ -1,10 +1,10 @@ -# src/gallium/winsys/xlib/Makefile +# src/gallium/winsys/i965/xlib/Makefile # This makefile produces a "stand-alone" libGL.so which is based on # Xlib (no DRI HW acceleration) -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/i965/xlib/xlib_i965.c similarity index 100% rename from src/gallium/winsys/drm/i965/xlib/xlib_i965.c rename to src/gallium/winsys/i965/xlib/xlib_i965.c diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/nouveau/drm/Makefile similarity index 79% rename from src/gallium/winsys/drm/nouveau/drm/Makefile rename to src/gallium/winsys/nouveau/drm/Makefile index 54c3b26c755..71029858f75 100644 --- a/src/gallium/winsys/drm/nouveau/drm/Makefile +++ b/src/gallium/winsys/nouveau/drm/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = nouveaudrm @@ -8,4 +8,4 @@ C_SOURCES = nouveau_drm_api.c LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other) -include ../../../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h b/src/gallium/winsys/nouveau/drm/nouveau_dri.h similarity index 100% rename from src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h rename to src/gallium/winsys/nouveau/drm/nouveau_dri.h diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c similarity index 100% rename from src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c rename to src/gallium/winsys/nouveau/drm/nouveau_drm_api.c diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.h similarity index 100% rename from src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h rename to src/gallium/winsys/nouveau/drm/nouveau_drm_api.h diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/radeon/drm/Makefile similarity index 79% rename from src/gallium/winsys/drm/radeon/core/Makefile rename to src/gallium/winsys/radeon/drm/Makefile index 13bbbf730d6..7f69e392735 100644 --- a/src/gallium/winsys/drm/radeon/core/Makefile +++ b/src/gallium/winsys/radeon/drm/Makefile @@ -1,5 +1,5 @@ -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = radeonwinsys @@ -12,6 +12,6 @@ C_SOURCES = \ LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \ $(shell pkg-config libdrm --cflags-only-I) -include ../../../../Makefile.template +include ../../../Makefile.template symlinks: diff --git a/src/gallium/winsys/drm/radeon/core/SConscript b/src/gallium/winsys/radeon/drm/SConscript similarity index 100% rename from src/gallium/winsys/drm/radeon/core/SConscript rename to src/gallium/winsys/radeon/drm/SConscript diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/radeon/drm/radeon_buffer.h similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_buffer.h rename to src/gallium/winsys/radeon/drm/radeon_buffer.h diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/radeon/drm/radeon_drm.c similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_drm.c rename to src/gallium/winsys/radeon/drm/radeon_drm.c diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/radeon/drm/radeon_drm.h similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_drm.h rename to src/gallium/winsys/radeon/drm/radeon_drm.h diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c rename to src/gallium/winsys/radeon/drm/radeon_drm_buffer.c diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_r300.c rename to src/gallium/winsys/radeon/drm/radeon_r300.c diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/radeon/drm/radeon_r300.h similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_r300.h rename to src/gallium/winsys/radeon/drm/radeon_r300.h diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h similarity index 100% rename from src/gallium/winsys/drm/radeon/core/radeon_winsys.h rename to src/gallium/winsys/radeon/drm/radeon_winsys.h diff --git a/src/gallium/winsys/drm/vmware/core/Makefile b/src/gallium/winsys/svga/drm/Makefile similarity index 63% rename from src/gallium/winsys/drm/vmware/core/Makefile rename to src/gallium/winsys/svga/drm/Makefile index a52957c1a5b..c2f59e01b0d 100644 --- a/src/gallium/winsys/drm/vmware/core/Makefile +++ b/src/gallium/winsys/svga/drm/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = svgadrm @@ -17,14 +17,6 @@ C_SOURCES = \ LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/drivers/svga \ -I$(TOP)/src/gallium/drivers/svga/include \ - -I$(GALLIUM)/src/mesa/drivers/dri/common \ - -I$(GALLIUM)/include \ - -I$(GALLIUM)/include/GL/internal \ - -I$(GALLIUM)/src/mesa \ - -I$(GALLIUM)/src/mesa/main \ - -I$(GALLIUM)/src/mesa/glapi \ - -I$(GALLIUM)/src/egl/main \ - -I$(GALLIUM)/src/egl/drivers/dri \ $(shell pkg-config libdrm --cflags-only-I) LIBRARY_DEFINES = \ @@ -32,4 +24,4 @@ LIBRARY_DEFINES = \ -DHAVE_STDINT_H -D_FILE_OFFSET_BITS=64 \ $(shell pkg-config libdrm --cflags-only-other) -include ../../../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/vmware/core/SConscript b/src/gallium/winsys/svga/drm/SConscript similarity index 100% rename from src/gallium/winsys/drm/vmware/core/SConscript rename to src/gallium/winsys/svga/drm/SConscript diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_buffer.c rename to src/gallium/winsys/svga/drm/vmw_buffer.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/svga/drm/vmw_buffer.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_buffer.h rename to src/gallium/winsys/svga/drm/vmw_buffer.h diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_context.c rename to src/gallium/winsys/svga/drm/vmw_context.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.h b/src/gallium/winsys/svga/drm/vmw_context.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_context.h rename to src/gallium/winsys/svga/drm/vmw_context.h diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.c b/src/gallium/winsys/svga/drm/vmw_fence.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_fence.c rename to src/gallium/winsys/svga/drm/vmw_fence.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.h b/src/gallium/winsys/svga/drm/vmw_fence.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_fence.h rename to src/gallium/winsys/svga/drm/vmw_fence.h diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen.c rename to src/gallium/winsys/svga/drm/vmw_screen.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/svga/drm/vmw_screen.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen.h rename to src/gallium/winsys/svga/drm/vmw_screen.h diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c rename to src/gallium/winsys/svga/drm/vmw_screen_dri.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c rename to src/gallium/winsys/svga/drm/vmw_screen_ioctl.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/svga/drm/vmw_screen_pools.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c rename to src/gallium/winsys/svga/drm/vmw_screen_pools.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/svga/drm/vmw_screen_svga.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c rename to src/gallium/winsys/svga/drm/vmw_screen_svga.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.c b/src/gallium/winsys/svga/drm/vmw_surface.c similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_surface.c rename to src/gallium/winsys/svga/drm/vmw_surface.c diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/svga/drm/vmw_surface.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmw_surface.h rename to src/gallium/winsys/svga/drm/vmw_surface.h diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/svga/drm/vmwgfx_drm.h similarity index 100% rename from src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h rename to src/gallium/winsys/svga/drm/vmwgfx_drm.h diff --git a/src/gallium/winsys/drm/i965/Makefile b/src/gallium/winsys/sw/Makefile similarity index 61% rename from src/gallium/winsys/drm/i965/Makefile rename to src/gallium/winsys/sw/Makefile index d8feef6824a..e9182ea5b1b 100644 --- a/src/gallium/winsys/drm/i965/Makefile +++ b/src/gallium/winsys/sw/Makefile @@ -1,8 +1,8 @@ -# src/gallium/winsys/drm/intel/Makefile -TOP = ../../../../.. +# src/gallium/winsys/sw/Makefile +TOP = ../../../.. include $(TOP)/configs/current -SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS) +SUBDIRS = null wrapper default install clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/gallium/winsys/drm/sw/Makefile b/src/gallium/winsys/sw/drm/Makefile similarity index 73% rename from src/gallium/winsys/drm/sw/Makefile rename to src/gallium/winsys/sw/drm/Makefile index 5f3c3ec325d..79664536aa0 100644 --- a/src/gallium/winsys/drm/sw/Makefile +++ b/src/gallium/winsys/sw/drm/Makefile @@ -3,9 +3,7 @@ include $(TOP)/configs/current LIBNAME = swdrm -C_SOURCES = \ - wrapper_sw_winsys.c \ - sw_drm_api.c +C_SOURCES = sw_drm_api.c LIBRARY_INCLUDES = diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/sw/drm/sw_drm_api.c similarity index 98% rename from src/gallium/winsys/drm/sw/sw_drm_api.c rename to src/gallium/winsys/sw/drm/sw_drm_api.c index 0fd2163913e..eb81d26a593 100644 --- a/src/gallium/winsys/drm/sw/sw_drm_api.c +++ b/src/gallium/winsys/sw/drm/sw_drm_api.c @@ -27,7 +27,7 @@ #include "util/u_memory.h" #include "softpipe/sp_public.h" #include "state_tracker/drm_api.h" -#include "wrapper_sw_winsys.h" +#include "../../sw/wrapper/wrapper_sw_winsys.h" #include "sw_drm_api.h" diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.h b/src/gallium/winsys/sw/drm/sw_drm_api.h similarity index 100% rename from src/gallium/winsys/drm/sw/sw_drm_api.h rename to src/gallium/winsys/sw/drm/sw_drm_api.h diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/sw/gdi/SConscript similarity index 100% rename from src/gallium/winsys/gdi/SConscript rename to src/gallium/winsys/sw/gdi/SConscript diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c similarity index 100% rename from src/gallium/winsys/gdi/gdi_sw_winsys.c rename to src/gallium/winsys/sw/gdi/gdi_sw_winsys.c diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h similarity index 100% rename from src/gallium/winsys/gdi/gdi_sw_winsys.h rename to src/gallium/winsys/sw/gdi/gdi_sw_winsys.h diff --git a/src/gallium/winsys/null/Makefile b/src/gallium/winsys/sw/null/Makefile similarity index 78% rename from src/gallium/winsys/null/Makefile rename to src/gallium/winsys/sw/null/Makefile index 3a3fb75ab36..b1882b582e9 100644 --- a/src/gallium/winsys/null/Makefile +++ b/src/gallium/winsys/sw/null/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = ws_null @@ -11,6 +11,6 @@ LIBRARY_INCLUDES = \ C_SOURCES = \ null_sw_winsys.c -include ../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/null/SConscript b/src/gallium/winsys/sw/null/SConscript similarity index 100% rename from src/gallium/winsys/null/SConscript rename to src/gallium/winsys/sw/null/SConscript diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/sw/null/null_sw_winsys.c similarity index 100% rename from src/gallium/winsys/null/null_sw_winsys.c rename to src/gallium/winsys/sw/null/null_sw_winsys.c diff --git a/src/gallium/winsys/null/null_sw_winsys.h b/src/gallium/winsys/sw/null/null_sw_winsys.h similarity index 100% rename from src/gallium/winsys/null/null_sw_winsys.h rename to src/gallium/winsys/sw/null/null_sw_winsys.h diff --git a/src/gallium/winsys/sw/wrapper/Makefile b/src/gallium/winsys/sw/wrapper/Makefile new file mode 100644 index 00000000000..4771fbcf700 --- /dev/null +++ b/src/gallium/winsys/sw/wrapper/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = wsw + +C_SOURCES = wrapper_sw_winsys.c + +LIBRARY_INCLUDES = + +LIBRARY_DEFINES = + +include ../../../Makefile.template diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c similarity index 100% rename from src/gallium/winsys/drm/sw/wrapper_sw_winsys.c rename to src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.h similarity index 100% rename from src/gallium/winsys/drm/sw/wrapper_sw_winsys.h rename to src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.h diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/sw/xlib/Makefile similarity index 79% rename from src/gallium/winsys/xlib/Makefile rename to src/gallium/winsys/sw/xlib/Makefile index 83d53c59542..c6693899281 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/sw/xlib/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = ws_xlib @@ -12,6 +12,6 @@ LIBRARY_INCLUDES = \ C_SOURCES = \ xlib_sw_winsys.c -include ../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/sw/xlib/SConscript similarity index 100% rename from src/gallium/winsys/xlib/SConscript rename to src/gallium/winsys/sw/xlib/SConscript diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c similarity index 100% rename from src/gallium/winsys/xlib/xlib_sw_winsys.c rename to src/gallium/winsys/sw/xlib/xlib_sw_winsys.c From 42a1bcc22f0ed84faa51dafe9e61703e02e93eba Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 24 Mar 2010 18:09:19 +0100 Subject: [PATCH 323/483] radeong: Fix scons build --- src/gallium/winsys/radeon/drm/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/radeon/drm/SConscript b/src/gallium/winsys/radeon/drm/SConscript index f4e9c397bdf..19e895f10b9 100644 --- a/src/gallium/winsys/radeon/drm/SConscript +++ b/src/gallium/winsys/radeon/drm/SConscript @@ -3,7 +3,7 @@ Import('*') env = drienv.Clone() radeon_sources = [ - 'radeon_buffer.c', + 'radeon_drm_buffer.c', 'radeon_drm.c', 'radeon_r300.c', ] From 3695cdd6061abe5af430bddaac2237bff3d87ad0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 24 Mar 2010 10:26:05 -0700 Subject: [PATCH 324/483] i965: Handle the negate and abs swizzles on brw_wm_glsl.c immediate args. Fixes piglit glsl-orangebook-ch06-bump, regressed with 4fc57322258a750c0a9cabc77372b5ccde1fa877 --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index d78fb4ed09f..3b7e421b16a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -583,11 +583,21 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c, if (component == SWIZZLE_ZERO) { return brw_imm_f(0.0F); } else if (component == SWIZZLE_ONE) { - return brw_imm_f(1.0F); + if (src->Negate) + return brw_imm_f(-1.0F); + else + return brw_imm_f(1.0F); } if (src->File == PROGRAM_CONSTANT) { - return brw_imm_f(params->ParameterValues[src->Index][component]); + float f = params->ParameterValues[src->Index][component]; + + if (src->Abs) + f = fabs(f); + if (src->Negate) + f = -f; + + return brw_imm_f(f); } } From 738850e52260a76ffee57e22193b21126d6d39a1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 24 Mar 2010 18:42:35 +0100 Subject: [PATCH 325/483] gallium: Make scons build dri/xorg drivers again --- src/gallium/targets/SConscript | 68 ++++++++++++++++++++ src/gallium/targets/dri-vmwgfx/SConscript | 75 +++++------------------ src/gallium/winsys/SConscript | 21 +++++++ src/gallium/winsys/i915/drm/SConscript | 2 +- src/gallium/winsys/i965/drm/SConscript | 2 +- src/gallium/winsys/radeon/drm/SConscript | 2 +- 6 files changed, 108 insertions(+), 62 deletions(-) diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index df62fc65fb7..38645646883 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -14,3 +14,71 @@ if 'gdi' in env['winsys']: SConscript([ 'libgl-gdi/SConscript', ]) + +if env['dri']: + drienv = env.Clone() + + drienv.Replace(CPPPATH = [ + '#src/mesa/drivers/dri/common', + '#include', + '#include/GL/internal', + '#src/gallium/include', + '#src/gallium/auxiliary', + '#src/gallium/drivers', + '#src/mesa', + '#src/mesa/main', + '#src/mesa/glapi', + '#src/mesa/math', + '#src/mesa/transform', + '#src/mesa/shader', + '#src/mesa/swrast', + '#src/mesa/swrast_setup', + '#src/egl/main', + '#src/egl/drivers/dri', + ]) + + drienv.ParseConfig('pkg-config --cflags --libs libdrm') + + COMMON_GALLIUM_SOURCES = [ + '#src/mesa/drivers/dri/common/utils.c', + '#src/mesa/drivers/dri/common/vblank.c', + '#src/mesa/drivers/dri/common/dri_util.c', + '#src/mesa/drivers/dri/common/xmlconfig.c', + ] + + COMMON_BM_SOURCES = [ + '#src/mesa/drivers/dri/common/dri_bufmgr.c', + '#src/mesa/drivers/dri/common/dri_drmpool.c', + ] + + Export([ + 'drienv', + 'COMMON_GALLIUM_SOURCES', + 'COMMON_BM_SOURCES', + ]) + + if 'vmware' in env['winsys']: + SConscript([ + 'dri-vmwgfx/SConscript', + ]) + + if 'intel' in env['winsys']: + SConscript([ + 'dri-i915/SConscript', + ]) + + if 'i965' in env['winsys']: + SConscript([ + 'dri-i965/SConscript', + ]) + + if 'radeon' in env['winsys']: + SConscript([ + 'dri-radeong/SConscript', + ]) + +if 'xorg' in env['statetrackers']: + if 'vmware' in env['winsys']: + SConscript([ + 'xorg-vmwgfx/SConscript', + ]) diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript index d26d0cd7483..4437916c293 100644 --- a/src/gallium/targets/dri-vmwgfx/SConscript +++ b/src/gallium/targets/dri-vmwgfx/SConscript @@ -1,63 +1,20 @@ -import os -import os.path - Import('*') -if env['platform'] == 'linux': +env = drienv.Clone() - if env['dri']: - env = env.Clone() - - sources = [ - '#/src/mesa/drivers/dri/common/utils.c', - '#/src/mesa/drivers/dri/common/vblank.c', - '#/src/mesa/drivers/dri/common/dri_util.c', - '#/src/mesa/drivers/dri/common/xmlconfig.c', - ] - - - env.ParseConfig('pkg-config --cflags --libs libdrm') - - env.Prepend(CPPPATH = [ - '#/src/mesa/state_tracker', - '#/src/mesa/drivers/dri/common', - '#/src/mesa/main', - '#/src/mesa/glapi', - '#/src/mesa', - '#/include', - '#/src/gallium/drivers/svga', - '#/src/gallium/drivers/svga/include', - ]) - - env.Append(CPPDEFINES = [ - 'HAVE_STDINT_H', - 'HAVE_SYS_TYPES_H', - ]) - - env.Append(CFLAGS = [ - '-std=gnu99', - '-D_FILE_OFFSET_BITS=64', - ]) - - env.Prepend(LIBPATH = [ - ]) - - env.Prepend(LIBS = [ - trace, - st_dri, - svgadrm, - svga, - mesa, - glsl, - gallium, - ]) - - # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions - env.LoadableModule( - target ='vmwgfx_dri.so', - source = sources, - LIBS = env['LIBS'], - SHLIBPREFIX = '', - ) - +drivers = [ + trace, + st_dri, + svgadrm, + svga, + mesa, + glsl, + gallium, +] +env.LoadableModule( + target ='vmwgfx_dri.so', + source = COMMON_GALLIUM_SOURCES, + LIBS = drivers + mesa + gallium + env['LIBS'], + SHLIBPREFIX = '', +) diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 97ea82ea761..90ca693eb68 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -9,3 +9,24 @@ if 'gdi' in env['winsys']: SConscript([ 'sw/gdi/SConscript', ]) + +if env['dri']: + if 'vmware' in env['winsys']: + SConscript([ + 'svga/drm/SConscript', + ]) + + if 'intel' in env['winsys']: + SConscript([ + 'i915/drm/SConscript', + ]) + + if 'i965' in env['winsys']: + SConscript([ + 'i965/drm/SConscript', + ]) + + if 'radeon' in env['winsys']: + SConscript([ + 'radeon/drm/SConscript', + ]) diff --git a/src/gallium/winsys/i915/drm/SConscript b/src/gallium/winsys/i915/drm/SConscript index 26717f391fa..b47b8add837 100644 --- a/src/gallium/winsys/i915/drm/SConscript +++ b/src/gallium/winsys/i915/drm/SConscript @@ -1,6 +1,6 @@ Import('*') -env = drienv.Clone() +env = env.Clone() inteldrm_sources = [ 'intel_drm_api.c', diff --git a/src/gallium/winsys/i965/drm/SConscript b/src/gallium/winsys/i965/drm/SConscript index 6256ec6eaf0..150ab19a33e 100644 --- a/src/gallium/winsys/i965/drm/SConscript +++ b/src/gallium/winsys/i965/drm/SConscript @@ -1,6 +1,6 @@ Import('*') -env = drienv.Clone() +env = env.Clone() i965drm_sources = [ 'i965_drm_api.c', diff --git a/src/gallium/winsys/radeon/drm/SConscript b/src/gallium/winsys/radeon/drm/SConscript index 19e895f10b9..fab42929514 100644 --- a/src/gallium/winsys/radeon/drm/SConscript +++ b/src/gallium/winsys/radeon/drm/SConscript @@ -1,6 +1,6 @@ Import('*') -env = drienv.Clone() +env = env.Clone() radeon_sources = [ 'radeon_drm_buffer.c', From f5ae5b5396ce93d138d6fde5d79e999175dfd63f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 24 Mar 2010 19:16:29 +0100 Subject: [PATCH 326/483] gallium: Add warnings incase pipe drivers are not built in targets --- src/gallium/targets/dri-i915/SConscript | 4 ++++ src/gallium/targets/dri-i965/SConscript | 4 ++++ src/gallium/targets/dri-radeong/SConscript | 4 ++++ src/gallium/targets/dri-vmwgfx/SConscript | 4 ++++ src/gallium/targets/xorg-vmwgfx/SConscript | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript index 0df841d8798..8d4ecefbe1b 100644 --- a/src/gallium/targets/dri-i915/SConscript +++ b/src/gallium/targets/dri-i915/SConscript @@ -1,5 +1,9 @@ Import('*') +if not 'i915' in env['drivers']: + print 'warning: i915 pipe driver not built skipping i915_dri.so' + Return() + env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_intel') diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript index a99533fd245..3b37d8e1af4 100644 --- a/src/gallium/targets/dri-i965/SConscript +++ b/src/gallium/targets/dri-i965/SConscript @@ -1,5 +1,9 @@ Import('*') +if not 'i965' in env['drivers']: + print 'warning: i965 pipe driver not built skipping i965_dri.so' + Return() + env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_intel') diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript index c4989d1b595..bb3b5b9304b 100644 --- a/src/gallium/targets/dri-radeong/SConscript +++ b/src/gallium/targets/dri-radeong/SConscript @@ -1,5 +1,9 @@ Import('*') +if not 'r300' in env['drivers']: + print 'warning: r300 pipe driver not built skipping radeong_dri.so' + Return() + env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_radeon') diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript index 4437916c293..7d248e8a9ce 100644 --- a/src/gallium/targets/dri-vmwgfx/SConscript +++ b/src/gallium/targets/dri-vmwgfx/SConscript @@ -1,5 +1,9 @@ Import('*') +if not 'svga' in env['drivers']: + print 'warning: svga pipe driver not built skipping vmwgfx_dri.so' + Return() + env = drienv.Clone() drivers = [ diff --git a/src/gallium/targets/xorg-vmwgfx/SConscript b/src/gallium/targets/xorg-vmwgfx/SConscript index 1e5d8ff7fed..b63ab99e050 100644 --- a/src/gallium/targets/xorg-vmwgfx/SConscript +++ b/src/gallium/targets/xorg-vmwgfx/SConscript @@ -2,6 +2,10 @@ import os.path Import('*') +if not 'svga' in env['drivers']: + print 'warning: svga pipe driver not built skipping vmwgfx_drv.so' + Return() + if env['platform'] == 'linux': env = env.Clone() From 70929f4505d5cb1b9848a02e8359e9f7a8ef598c Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 11:19:02 +0100 Subject: [PATCH 327/483] r300: clean fog_attr/wpos_attr if code accessing these attributes has been removed FP during compilation --- src/mesa/drivers/dri/r300/r300_fragprog_common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index 61ea5e4d9a3..0646da46249 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -256,6 +256,19 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog fp->InputsRead = compiler.Base.Program.InputsRead; + /* Clear the fog/wpos_attr if code accessing these + * attributes has been removed during compilation + */ + if (fp->fog_attr != FRAG_ATTRIB_MAX) { + if (!(fp->InputsRead & (1 << fp->fog_attr))) + fp->fog_attr = FRAG_ATTRIB_MAX; + } + + if (fp->wpos_attr != FRAG_ATTRIB_MAX) { + if (!(fp->InputsRead & (1 << fp->wpos_attr))) + fp->wpos_attr = FRAG_ATTRIB_MAX; + } + rc_destroy(&compiler.Base); } From bed7d88708eba69118fe3805f95b104194872f3a Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 11:34:19 +0100 Subject: [PATCH 328/483] r300: fix wpos/fog handling It may happen that the vertex attribute we were going to stuff the wpos/fog attrs in was already written by vertex program. In such cases we need to remove instruction accessing these attributes, so they don't overwrite the wpos/fog related instructions. This fixes non-textured models in many wine games. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 129004fee78..e77cd611f7a 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -263,15 +263,25 @@ static struct r300_vertex_program *build_program(GLcontext *ctx, rc_move_output(&compiler.Base, VERT_RESULT_PSIZ, VERT_RESULT_PSIZ, WRITEMASK_X); if (vp->key.WPosAttr != FRAG_ATTRIB_MAX) { - rc_copy_output(&compiler.Base, - VERT_RESULT_HPOS, - vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0); + unsigned int vp_wpos_attr = vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0; + + /* Set empty writemask for instructions writing to vp_wpos_attr + * before moving the wpos attr there. + * Such instructions will be removed by DCE. + */ + rc_move_output(&compiler.Base, vp_wpos_attr, vp->key.WPosAttr, 0); + rc_copy_output(&compiler.Base, VERT_RESULT_HPOS, vp_wpos_attr); } if (vp->key.FogAttr != FRAG_ATTRIB_MAX) { - rc_move_output(&compiler.Base, - VERT_RESULT_FOGC, - vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0, WRITEMASK_X); + unsigned int vp_fog_attr = vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0; + + /* Set empty writemask for instructions writing to vp_fog_attr + * before moving the fog attr there. + * Such instructions will be removed by DCE. + */ + rc_move_output(&compiler.Base, vp_fog_attr, vp->key.FogAttr, 0); + rc_move_output(&compiler.Base, VERT_RESULT_FOGC, vp_fog_attr, WRITEMASK_X); } r3xx_compile_vertex_program(&compiler); From 7a77effb0b7eeefd5eb350aa9a487e10f62eb7ed Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:10:06 +0100 Subject: [PATCH 329/483] r300: fix vertex programs with big number of params (>255) under KMS UMS will probably require some kernel work --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 40 +++++++++++++++++++---- src/mesa/drivers/dri/r300/r300_vertprog.c | 6 +++- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 6cfa5686f4a..8eb596d1c5a 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -83,6 +83,23 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom) return cnt ? (cnt * 4) + extra : 0; } +static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom) +{ + r300ContextPtr r300 = R300_CONTEXT(ctx); + int cnt; + int extra = 1; + + if (r300->radeon.radeonScreen->kernel_mm) { + cnt = r300->selected_vp->code.constants.Count * 4; + extra = 5; + } else { + cnt = vpu_count(atom->cmd); + extra = 1; + } + + return cnt ? (cnt * 4) + extra : 0; +} + void r300_emit_vpu(struct r300_context *r300, uint32_t *data, unsigned len, @@ -101,15 +118,26 @@ static void emit_vpu_state(GLcontext *ctx, struct radeon_state_atom * atom) { r300ContextPtr r300 = R300_CONTEXT(ctx); drm_r300_cmd_header_t cmd; - uint32_t addr, ndw; + uint32_t addr; cmd.u = atom->cmd[0]; addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo; - ndw = atom->check(ctx, atom); r300_emit_vpu(r300, &atom->cmd[1], vpu_count(atom->cmd) * 4, addr); } +static void emit_vpp_state(GLcontext *ctx, struct radeon_state_atom * atom) +{ + r300ContextPtr r300 = R300_CONTEXT(ctx); + drm_r300_cmd_header_t cmd; + uint32_t addr; + + cmd.u = atom->cmd[0]; + addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo; + + r300_emit_vpu(r300, &atom->cmd[1], r300->selected_vp->code.constants.Count * 4, addr); +} + void r500_emit_fp(struct r300_context *r300, uint32_t *data, unsigned len, @@ -784,11 +812,11 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.vpi.emit = emit_vpu_state; if (is_r500) { - ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0); + ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0); r300->hw.vpp.cmd[0] = cmdvpu(r300->radeon.radeonScreen, R500_PVS_CONST_START, 0); if (r300->radeon.radeonScreen->kernel_mm) - r300->hw.vpp.emit = emit_vpu_state; + r300->hw.vpp.emit = emit_vpp_state; ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0); r300->hw.vps.cmd[0] = @@ -805,11 +833,11 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.vpucp[i].emit = emit_vpu_state; } } else { - ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0); + ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0); r300->hw.vpp.cmd[0] = cmdvpu(r300->radeon.radeonScreen, R300_PVS_CONST_START, 0); if (r300->radeon.radeonScreen->kernel_mm) - r300->hw.vpp.emit = emit_vpu_state; + r300->hw.vpp.emit = emit_vpp_state; ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0); r300->hw.vps.cmd[0] = diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index e77cd611f7a..53fe948ab98 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -392,7 +392,11 @@ void r300SetupVertexProgram(r300ContextPtr rmesa) R300_STATECHANGE(rmesa, vap_cntl); R300_STATECHANGE(rmesa, vpp); param_count = r300VertexProgUpdateParams(ctx, prog, (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]); - bump_vpu_count(rmesa->hw.vpp.cmd, param_count); + if (!rmesa->radeon.radeonScreen->kernel_mm && param_count > 255 * 4) { + WARN_ONCE("Too many VP params, expect rendering errors\n"); + } + /* Prevent the overflow (vpu.count is u8) */ + bump_vpu_count(rmesa->hw.vpp.cmd, MIN2(255 * 4, param_count)); param_count /= 4; r300EmitVertexProgram(rmesa, R300_PVS_CODE_START, &(prog->code)); From 88f785935e43701a1ac56dae3952a915a9dd201b Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:12:05 +0100 Subject: [PATCH 330/483] r300: fix off by one R300_PVS_MAX_CONST_ADDR field holds highest const addr, not const count. Fixes missing models and others rendering errors for vertex program using 256 params. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 53fe948ab98..a1fe3780294 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -409,6 +409,6 @@ void r300SetupVertexProgram(r300ContextPtr rmesa) rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = (0 << R300_PVS_FIRST_INST_SHIFT) | (inst_count << R300_PVS_XYZW_VALID_INST_SHIFT) | (inst_count << R300_PVS_LAST_INST_SHIFT); - rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT); + rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | ((param_count - 1) << R300_PVS_MAX_CONST_ADDR_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT); } From fabc744999bf282e80baf44c45c58cab8a67d604 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 21 Mar 2010 12:43:38 +0100 Subject: [PATCH 331/483] r300: report correct state atom size Spotted by Pauli Nieminen --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 8eb596d1c5a..788dc2f16e9 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -77,7 +77,7 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom) cnt = vpu_count(atom->cmd); if (r300->radeon.radeonScreen->kernel_mm) { - extra = 5; + extra = 3; } return cnt ? (cnt * 4) + extra : 0; @@ -91,7 +91,7 @@ static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom) if (r300->radeon.radeonScreen->kernel_mm) { cnt = r300->selected_vp->code.constants.Count * 4; - extra = 5; + extra = 3; } else { cnt = vpu_count(atom->cmd); extra = 1; From d9a19d8649e49acfac98c240bff88931be7743d7 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 12 Mar 2010 13:58:56 -0500 Subject: [PATCH 332/483] r100/r200/r300/r600: enable accel for Copy/DrawPixels without kms meta ops should work ok without kms. --- src/mesa/drivers/dri/r200/r200_state.c | 7 +++---- src/mesa/drivers/dri/r300/r300_state.c | 7 +++---- src/mesa/drivers/dri/r600/r700_state.c | 7 +++---- src/mesa/drivers/dri/radeon/radeon_state.c | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 9c2ac05ad6c..29d7bed8b6a 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -2496,11 +2496,10 @@ void r200InitStateFuncs( radeonContextPtr radeon, struct dd_function_table *func functions->DrawBuffer = radeonDrawBuffer; functions->ReadBuffer = radeonReadBuffer; - if (radeon->radeonScreen->kernel_mm) { - functions->CopyPixels = _mesa_meta_CopyPixels; - functions->DrawPixels = _mesa_meta_DrawPixels; + functions->CopyPixels = _mesa_meta_CopyPixels; + functions->DrawPixels = _mesa_meta_DrawPixels; + if (radeon->radeonScreen->kernel_mm) functions->ReadPixels = radeonReadPixels; - } functions->AlphaFunc = r200AlphaFunc; functions->BlendColor = r200BlendColor; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 749a2464e7c..e660b1fb3bb 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -2396,11 +2396,10 @@ void r300InitStateFuncs(radeonContextPtr radeon, struct dd_function_table *funct functions->DrawBuffer = radeonDrawBuffer; functions->ReadBuffer = radeonReadBuffer; - if (radeon->radeonScreen->kernel_mm) { - functions->CopyPixels = _mesa_meta_CopyPixels; - functions->DrawPixels = _mesa_meta_DrawPixels; + functions->CopyPixels = _mesa_meta_CopyPixels; + functions->DrawPixels = _mesa_meta_DrawPixels; + if (radeon->radeonScreen->kernel_mm) functions->ReadPixels = radeonReadPixels; - } } void r300InitShaderFunctions(r300ContextPtr r300) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 1ff233d91ee..1da31e7b2b4 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -1861,10 +1861,9 @@ void r700InitStateFuncs(radeonContextPtr radeon, struct dd_function_table *funct functions->DrawBuffer = radeonDrawBuffer; functions->ReadBuffer = radeonReadBuffer; - if (radeon->radeonScreen->kernel_mm) { - functions->CopyPixels = _mesa_meta_CopyPixels; - functions->DrawPixels = _mesa_meta_DrawPixels; + functions->CopyPixels = _mesa_meta_CopyPixels; + functions->DrawPixels = _mesa_meta_DrawPixels; + if (radeon->radeonScreen->kernel_mm) functions->ReadPixels = radeonReadPixels; - } } diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 0afbc19c127..539b067742f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -2249,11 +2249,10 @@ void radeonInitStateFuncs( GLcontext *ctx , GLboolean dri2 ) ctx->Driver.DrawBuffer = radeonDrawBuffer; ctx->Driver.ReadBuffer = radeonReadBuffer; - if (dri2) { - ctx->Driver.CopyPixels = _mesa_meta_CopyPixels; - ctx->Driver.DrawPixels = _mesa_meta_DrawPixels; + ctx->Driver.CopyPixels = _mesa_meta_CopyPixels; + ctx->Driver.DrawPixels = _mesa_meta_DrawPixels; + if (dri2) ctx->Driver.ReadPixels = radeonReadPixels; - } ctx->Driver.AlphaFunc = radeonAlphaFunc; ctx->Driver.BlendEquationSeparate = radeonBlendEquationSeparate; From f0e04b094412d358e913d3d1107d7260047f6fb2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Mar 2010 11:34:43 -0600 Subject: [PATCH 333/483] progs/demos: add other modes/patterns to dissolve demo --- progs/demos/dissolve.c | 137 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 6 deletions(-) diff --git a/progs/demos/dissolve.c b/progs/demos/dissolve.c index 0b8df1bb669..8ab5242d91c 100644 --- a/progs/demos/dissolve.c +++ b/progs/demos/dissolve.c @@ -1,5 +1,5 @@ /** - * Dissolve between two images using randomized stencil buffer + * Dissolve between two images using randomized/patterned stencil buffer * and varying stencil ref. * * Brian Paul @@ -9,6 +9,7 @@ #include #include +#include #include #include #include "readtex.h" @@ -28,6 +29,8 @@ static GLfloat ScaleX[2], ScaleY[2]; static GLubyte StencilRef = 0; +static int Mode = 0; + static void Idle(void) @@ -38,13 +41,114 @@ Idle(void) static void -RandomizeStencilBuffer(void) +FillRandomPixels(GLubyte *b) { - GLubyte *b = malloc(WinWidth * WinHeight); int i; for (i = 0; i < WinWidth * WinHeight; i++) { b[i] = rand() & 0xff; } +} + + +static void +FillRandomRects(GLubyte *b) +{ + int i; + + memset(b, 0, WinWidth * WinHeight); + + for (i = 0; i < 256; i++) { + int x = rand() % WinWidth; + int y = rand() % WinHeight; + int w = rand() % 60; + int h = rand() % 60; + int ix, iy; + + if (x + w > WinWidth) + w = WinWidth - x; + if (y + h > WinHeight) + h = WinHeight - y; + + for (iy = 0; iy < h; iy++) { + for (ix = 0; ix < w; ix++) { + int p = (y + iy) * WinWidth + x + ix; + b[p] = i; + } + } + } +} + + +static void +FillWipe(GLubyte *b) +{ + int iy, ix; + + memset(b, 0, WinWidth * WinHeight); + + for (iy = 0; iy < WinHeight; iy++) { + for (ix = 0; ix < WinWidth; ix++) { + int p = iy * WinWidth + ix; + b[p] = 2 * ix + iy / 2; + } + } +} + + +static void +FillMoire(GLubyte *b) +{ + int iy, ix; + + memset(b, 0, WinWidth * WinHeight); + + for (iy = 0; iy < WinHeight; iy++) { + for (ix = 0; ix < WinWidth; ix++) { + int p = iy * WinWidth + ix; + b[p] = (ix / 2) * (ix / 2) - (iy / 2) * (iy / 2); + } + } +} + + +static void +FillWaves(GLubyte *b) +{ + int iy, ix; + + memset(b, 0, WinWidth * WinHeight); + + for (iy = 0; iy < WinHeight; iy++) { + for (ix = 0; ix < WinWidth; ix++) { + int p = iy * WinWidth + ix; + float x = 8.0 * 3.1415 * ix / (float) WinWidth; + b[p] = (int) (25.0 * sin(x) ) - iy*2; + } + } +} + + +typedef void (*FillFunc)(GLubyte *b); + + +static FillFunc Funcs[] = { + FillRandomPixels, + FillRandomRects, + FillWipe, + FillMoire, + FillWaves +}; + +#define NUM_MODES (sizeof(Funcs) / sizeof(Funcs[0])) + + + +static void +InitStencilBuffer(void) +{ + GLubyte *b = malloc(WinWidth * WinHeight); + + Funcs[Mode](b); glStencilFunc(GL_ALWAYS, 0, ~0); glPixelZoom(1.0, 1.0); @@ -54,7 +158,6 @@ RandomizeStencilBuffer(void) } - static void Draw(void) { @@ -85,7 +188,7 @@ Reshape(int width, int height) glLoadIdentity(); glTranslatef(0.0, 0.0, -15.0); - RandomizeStencilBuffer(); + InitStencilBuffer(); ScaleX[0] = (float) width / ImgWidth[0]; ScaleY[0] = (float) height / ImgHeight[0]; @@ -102,12 +205,26 @@ Key(unsigned char key, int x, int y) (void) y; switch (key) { case 'a': + case ' ': Anim = !Anim; if (Anim) glutIdleFunc(Idle); else glutIdleFunc(NULL); break; + case 'i': + InitStencilBuffer(); + break; + case '-': + StencilRef--; + break; + case '+': + StencilRef++; + break; + case 'm': + Mode = (Mode + 1) % NUM_MODES; + InitStencilBuffer(); + break; case 27: glutDestroyWindow(Win); exit(0); @@ -143,8 +260,8 @@ Init(void) int main(int argc, char *argv[]) { - glutInit(&argc, argv); glutInitWindowSize(WinWidth, WinHeight); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); Win = glutCreateWindow(argv[0]); glutReshapeFunc(Reshape); @@ -153,6 +270,14 @@ main(int argc, char *argv[]) if (Anim) glutIdleFunc(Idle); Init(); + + printf("Keys:\n"); + printf(" a/SPACE toggle animation\n"); + printf(" +/- single step\n"); + printf(" i re-init pattern\n"); + printf(" m change pattern/dissolve mode\n"); + printf(" ESC exit\n"); + glutMainLoop(); return 0; } From 2ad8692aad0f4ad49643d5f697a036afccdeb9f0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 16:27:31 -0600 Subject: [PATCH 334/483] llvmpipe: fix texture reference counting bug We weren't saving the per-scene texture references at the right point. Fixes piglit cubemap segfault. The segfault resulted from referencing texture memory which was prematurely freed because of a missed reference count. Fixes fd.o bug 27276. --- src/gallium/drivers/llvmpipe/lp_setup.c | 27 ++++++++++++++----- .../drivers/llvmpipe/lp_setup_context.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index fbb0d6f8a60..76a8b87a309 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -489,6 +489,12 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, jit_tex->height = tex->height0; jit_tex->depth = tex->depth0; jit_tex->last_level = tex->last_level; + + /* We're referencing the texture's internal data, so save a + * reference to it. + */ + pipe_texture_reference(&setup->fs.current_tex[i], tex); + if (!lp_tex->dt) { /* regular texture - setup array of mipmap level pointers */ int j; @@ -511,12 +517,6 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, jit_tex->row_stride[0] = lp_tex->stride[0]; assert(jit_tex->data[0]); } - - /* the scene references this texture */ - { - struct lp_scene *scene = lp_setup_get_current_scene(setup); - lp_scene_texture_reference(scene, tex); - } } } @@ -651,6 +651,7 @@ lp_setup_update_state( struct lp_setup_context *setup ) * the new, current state. So allocate a new lp_rast_state object * and append it to the bin's setup data buffer. */ + uint i; struct lp_rast_state *stored = (struct lp_rast_state *) lp_scene_alloc(scene, sizeof *stored); if(stored) { @@ -664,6 +665,14 @@ lp_setup_update_state( struct lp_setup_context *setup ) lp_rast_set_state, lp_rast_arg_state(setup->fs.stored) ); } + + /* The scene now references the textures in the rasterization + * state record. Note that now. + */ + for (i = 0; i < Elements(setup->fs.current_tex); i++) { + if (setup->fs.current_tex[i]) + lp_scene_texture_reference(scene, setup->fs.current_tex[i]); + } } } @@ -679,8 +688,14 @@ lp_setup_update_state( struct lp_setup_context *setup ) void lp_setup_destroy( struct lp_setup_context *setup ) { + uint i; + reset_context( setup ); + for (i = 0; i < Elements(setup->fs.current_tex); i++) { + pipe_texture_reference(&setup->fs.current_tex[i], NULL); + } + pipe_buffer_reference(&setup->constants.current, NULL); /* free the scenes in the 'empty' queue */ diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index 464fb369840..ca0dafab627 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -111,6 +111,7 @@ struct lp_setup_context const struct lp_rast_state *stored; /**< what's in the scene */ struct lp_rast_state current; /**< currently set state */ + struct pipe_texture *current_tex[PIPE_MAX_SAMPLERS]; } fs; /** fragment shader constants */ From 372011bc892481e61c273a12d9601fd6008751ea Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 00:27:46 +0100 Subject: [PATCH 335/483] st/dri: Fix for X server 1.6.0 (DRI2 version 1) --- src/gallium/state_trackers/dri/dri_st_api.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 2cde01967d8..263c1e19a70 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -168,13 +168,18 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, boolean with_format; __DRIbuffer *buffers; int num_buffers; - unsigned attachments[8]; + unsigned attachments[10]; unsigned num_attachments, i; assert(loader); with_format = (loader->base.version > 2 && loader->getBuffersWithFormat); num_attachments = 0; + + /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */ + if (!with_format) + attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT; + for (i = 0; i < *count; i++) { enum pipe_format format; int att; @@ -185,6 +190,9 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, switch (statts[i]) { case ST_ATTACHMENT_FRONT_LEFT: + /* already added */ + if (!with_format) + continue; att = __DRI_BUFFER_FRONT_LEFT; break; case ST_ATTACHMENT_BACK_LEFT: From b4b4ac668116d974522df2ce56e30b74ecdfef77 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 00:41:21 +0100 Subject: [PATCH 336/483] i915g: Correct and add supperted texture formats --- src/gallium/drivers/i915/i915_screen.c | 6 +++++- src/gallium/drivers/i915/i915_state_sampler.c | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index e5bf4a20bd0..48a39edad20 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -165,8 +165,12 @@ i915_is_format_supported(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format tex_supported[] = { - PIPE_FORMAT_A8B8G8R8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_R8G8B8A8_UNORM, +#if 0 + PIPE_FORMAT_R8G8B8X8_UNORM, +#endif PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_A8_UNORM, diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index d6da8225490..4c326561cb9 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -192,6 +192,14 @@ translate_texture_format(enum pipe_format pipeFormat) return MAPSURF_16BIT | MT_16BIT_ARGB4444; case PIPE_FORMAT_B8G8R8A8_UNORM: return MAPSURF_32BIT | MT_32BIT_ARGB8888; + case PIPE_FORMAT_B8G8R8X8_UNORM: + return MAPSURF_32BIT | MT_32BIT_XRGB8888; + case PIPE_FORMAT_R8G8B8A8_UNORM: + return MAPSURF_32BIT | MT_32BIT_ABGR8888; +#if 0 + case PIPE_FORMAT_R8G8B8X8_UNORM: + return MAPSURF_32BIT | MT_32BIT_XBGR8888; +#endif case PIPE_FORMAT_YUYV: return (MAPSURF_422 | MT_422_YCRCB_NORMAL); case PIPE_FORMAT_UYVY: From 331729c8c877fd8ddde0a83cbe0fcdd5df4b1f1f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 19:30:27 -0600 Subject: [PATCH 337/483] llvmpipe: added lp_fence_signal() --- src/gallium/drivers/llvmpipe/lp_fence.c | 16 ++++++++++++++++ src/gallium/drivers/llvmpipe/lp_fence.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c index 525c117f316..00dc3eab6b1 100644 --- a/src/gallium/drivers/llvmpipe/lp_fence.c +++ b/src/gallium/drivers/llvmpipe/lp_fence.c @@ -29,6 +29,7 @@ #include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_inlines.h" +#include "lp_debug.h" #include "lp_fence.h" @@ -99,6 +100,21 @@ llvmpipe_fence_finish(struct pipe_screen *screen, } +void +lp_fence_signal(struct lp_fence *fence) +{ + pipe_mutex_lock(fence->mutex); + + fence->count++; + assert(fence->count <= fence->rank); + + LP_DBG(DEBUG_RAST, "%s count=%u rank=%u\n", __FUNCTION__, + fence->count, fence->rank); + + pipe_condvar_signal(fence->signalled); + + pipe_mutex_unlock(fence->mutex); +} void diff --git a/src/gallium/drivers/llvmpipe/lp_fence.h b/src/gallium/drivers/llvmpipe/lp_fence.h index c90e6de423b..d9270f5784a 100644 --- a/src/gallium/drivers/llvmpipe/lp_fence.h +++ b/src/gallium/drivers/llvmpipe/lp_fence.h @@ -53,6 +53,10 @@ struct lp_fence * lp_fence_create(unsigned rank); +void +lp_fence_signal(struct lp_fence *fence); + + void llvmpipe_init_screen_fence_funcs(struct pipe_screen *screen); From d7ddb589f49bfd3683650846d9b95835d0abd7ba Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 19:28:41 -0600 Subject: [PATCH 338/483] llvmpipe: call lp_fence_signal() --- src/gallium/drivers/llvmpipe/lp_rast.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 3a51800c40d..cd9919ca909 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -491,18 +491,7 @@ lp_rast_fence(struct lp_rasterizer_task *task, const union lp_rast_cmd_arg arg) { struct lp_fence *fence = arg.fence; - - pipe_mutex_lock( fence->mutex ); - - fence->count++; - assert(fence->count <= fence->rank); - - LP_DBG(DEBUG_RAST, "%s count=%u rank=%u\n", __FUNCTION__, - fence->count, fence->rank); - - pipe_condvar_signal( fence->signalled ); - - pipe_mutex_unlock( fence->mutex ); + lp_fence_signal(fence); } From a9063cad0f0190ff88cd20fbad5aa87bf1a943f6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 20:49:12 -0600 Subject: [PATCH 339/483] llvmpipe: optimize the lp_setup_fence() function Avoid emitting fences when not needed. Speeds up glReadPixels quite a bit when reading image row by row. --- src/gallium/drivers/llvmpipe/lp_setup.c | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 76a8b87a309..4eeb98621f6 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -318,16 +318,30 @@ lp_setup_fence( struct lp_setup_context *setup ) { struct lp_scene *scene = lp_setup_get_current_scene(setup); const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */ - struct lp_fence *fence = lp_fence_create(rank); + struct lp_fence *fence; LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank); - set_scene_state( setup, SETUP_ACTIVE ); + if (setup->state == SETUP_FLUSHED) { + /* We're in a flushed state so there's nothing in the bins. + * No need to wait on a fence. + */ + fence = NULL; + } + else { + /* There's material in the bins. Emit the fence into the bins. + * When the rasterizer(s) find the fence, they'll signal on it. + */ + fence = lp_fence_create(rank); - /* insert the fence into all command bins */ - lp_scene_bin_everywhere( scene, - lp_rast_fence, - lp_rast_arg_fence(fence) ); + set_scene_state( setup, SETUP_ACTIVE ); + + /* insert the fence into all command bins */ + lp_scene_bin_everywhere( scene, + lp_rast_fence, + lp_rast_arg_fence(fence) ); + + } return (struct pipe_fence_handle *) fence; } From 9a5241758231b2dd5ae757645158fa33051f5507 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2010 20:40:31 -0600 Subject: [PATCH 340/483] llvmpipe: fix up some questionable fence code Jose should probably review this since he wrote the original code. --- src/gallium/drivers/llvmpipe/lp_flush.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 636d72a9bb8..782669a1e77 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -111,7 +111,6 @@ llvmpipe_flush_texture(struct pipe_context *pipe, boolean cpu_access, boolean do_not_flush) { - struct pipe_fence_handle *last_fence = NULL; unsigned referenced; referenced = pipe->is_texture_referenced(pipe, texture, face, level); @@ -142,7 +141,7 @@ llvmpipe_flush_texture(struct pipe_context *pipe, pipe->flush(pipe, flush_flags, &fence); - if (last_fence) { + if (fence) { pipe->screen->fence_finish(pipe->screen, fence, 0); pipe->screen->fence_reference(pipe->screen, &fence, NULL); } From 3bccb5447b68abc1db55d146ac2fd0fafebd22d8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 24 Mar 2010 22:36:49 -0700 Subject: [PATCH 341/483] progs/glsl: Add raytracing demos to SCons build. --- progs/glsl/SConscript | 2 ++ 1 file changed, 2 insertions(+) diff --git a/progs/glsl/SConscript b/progs/glsl/SConscript index 8f2ebcf69c4..02884e5a710 100644 --- a/progs/glsl/SConscript +++ b/progs/glsl/SConscript @@ -8,6 +8,7 @@ progs = [ 'convolutions', 'deriv', 'fragcoord', + 'fsraytrace', 'identity', 'linktest', 'mandelbrot', @@ -27,6 +28,7 @@ progs = [ 'twoside', 'vert-or-frag-only', 'vert-tex', + 'vsraytrace', ] for prog in progs: From 3fcfd69fec379b121bb6a89446f3df36e0dab5c1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 24 Mar 2010 22:53:23 -0700 Subject: [PATCH 342/483] progs/glsl: Fix vsraytrace GLSL compilation error. Fixes the following GLSL error on Mac OS X. '=' : assigning non-constant to 'const 3-component vector of float' --- progs/glsl/vsraytrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index d7726c787b8..962b1bdb4c1 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -202,7 +202,7 @@ static const char* vsSource = "void main() \n" "{ \n" " const vec3 cameraPos = vec3(0,0,3); \n" - " const vec3 rayDir = normalize(vec3(gl_Vertex.x, gl_Vertex.y, -1.0) * rot);\n" + " vec3 rayDir = normalize(vec3(gl_Vertex.x, gl_Vertex.y, -1.0) * rot);\n" " Ray ray = Ray(cameraPos, rayDir); \n" " gl_Position = gl_Vertex; \n" " gl_FrontColor = trace1(ray); \n" From 8b12c58ce41f33108431213725d5d9b9aac8912c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Mar 2010 00:20:05 -0700 Subject: [PATCH 343/483] r300g: Remove unnecessary header. --- src/gallium/drivers/r300/r300_context.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 2bec946fe89..4433dcff21a 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -35,7 +35,6 @@ #include "r300_screen.h" #include "r300_screen_buffer.h" #include "r300_state_invariant.h" -#include "r300_texture.h" #include "r300_transfer.h" #include "r300_winsys.h" From 0d0220fedc7a8d490162f7385d19b2d0ab3fb8d9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 14:42:40 +0100 Subject: [PATCH 344/483] gallium: Fix libgl-xlib path to sw xlib winsys --- src/gallium/targets/libgl-xlib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile index 5a4e035c2eb..6cd00cad458 100644 --- a/src/gallium/targets/libgl-xlib/Makefile +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -38,7 +38,7 @@ XLIB_TARGET_OBJECTS = $(XLIB_TARGET_SOURCES:.c=.o) LIBS = \ $(GALLIUM_DRIVERS) \ $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ - $(TOP)/src/gallium/winsys/xlib/libws_xlib.a \ + $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/mesa/libglapi.a \ From 204c88014b8c3cfd7bd84928bbc77489ebd98399 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Thu, 25 Mar 2010 15:51:23 +0100 Subject: [PATCH 345/483] r300g/radeong: fix scons build --- src/gallium/drivers/r300/SConscript | 1 + src/gallium/targets/dri-radeong/SConscript | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript index 27b2e309932..221878c1c0c 100644 --- a/src/gallium/drivers/r300/SConscript +++ b/src/gallium/drivers/r300/SConscript @@ -24,6 +24,7 @@ r300 = env.ConvenienceLibrary( 'r300_query.c', 'r300_render.c', 'r300_screen.c', + 'r300_screen_buffer.c', 'r300_state.c', 'r300_state_derived.c', 'r300_state_invariant.c', diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript index bb3b5b9304b..239d29ace18 100644 --- a/src/gallium/targets/dri-radeong/SConscript +++ b/src/gallium/targets/dri-radeong/SConscript @@ -8,14 +8,10 @@ env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_radeon') -drivers = [ - trace, - softpipe, - r300 -] +drivers = r300 + trace + softpipe env.SharedLibrary( target ='radeon_dri.so', source = COMMON_GALLIUM_SOURCES, - LIBS = st_dri + radeonwinsys + mesa + drivers + gallium + env['LIBS'], + LIBS = st_dri + radeonwinsys + mesa + glsl + drivers + gallium + env['LIBS'], ) From 20755c5c4c88f8c442fc5b65f5368a32d0693a07 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:51 +0200 Subject: [PATCH 346/483] drisw_util: add fields for gallium swrast_dri --- src/mesa/drivers/dri/common/drisw_util.c | 7 +++++++ src/mesa/drivers/dri/common/drisw_util.h | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c index 141ca302d08..3f4e94c8f6e 100644 --- a/src/mesa/drivers/dri/common/drisw_util.c +++ b/src/mesa/drivers/dri/common/drisw_util.c @@ -63,6 +63,7 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, setupLoaderExtensions(psp, extensions); psp->extensions = emptyExtensionList; + psp->fd = -1; psp->myNum = scrn; *driver_configs = driDriverAPI.InitScreen(psp); @@ -146,6 +147,7 @@ static int driBindContext(__DRIcontext *pcp, pcp->driDrawablePriv = pdp; pcp->driReadablePriv = prp; if (pdp) { + pdp->driContextPriv = pcp; dri_get_drawable(pdp); } if ( prp && pdp != prp ) { @@ -182,6 +184,8 @@ static int driUnbindContext(__DRIcontext *pcp) pcp->driDrawablePriv = NULL; pcp->driReadablePriv = NULL; + pdp->driContextPriv = NULL; + return GL_TRUE; } @@ -221,6 +225,7 @@ driCreateNewDrawable(__DRIscreen *psp, pdp->loaderPrivate = data; pdp->driScreenPriv = psp; + pdp->driContextPriv = NULL; dri_get_drawable(pdp); @@ -229,6 +234,8 @@ driCreateNewDrawable(__DRIscreen *psp, return NULL; } + pdp->lastStamp = 1; /* const */ + return pdp; } diff --git a/src/mesa/drivers/dri/common/drisw_util.h b/src/mesa/drivers/dri/common/drisw_util.h index e353e26b34d..c7d1450be13 100644 --- a/src/mesa/drivers/dri/common/drisw_util.h +++ b/src/mesa/drivers/dri/common/drisw_util.h @@ -28,6 +28,7 @@ #include #include #include +typedef struct _drmLock drmLock; /** @@ -71,9 +72,17 @@ struct __DRIdrawableRec { void *loaderPrivate; + __DRIcontext *driContextPriv; + __DRIscreen *driScreenPriv; int refcount; + + /* gallium */ + unsigned int lastStamp; + + int w; + int h; }; From d7f78065acb09769195a58303ce3e9a401bf7a43 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:51 +0200 Subject: [PATCH 347/483] st/dri: add inline for dri2 check done in multiple places --- src/gallium/state_trackers/dri/dri_screen.c | 9 ++------- src/gallium/state_trackers/dri/dri_screen.h | 10 ++++++++++ src/gallium/state_trackers/dri/dri_st_api.c | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 17b9f1c5faf..733d71f9959 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -148,9 +148,7 @@ dri_fill_in_modes(struct dri_screen *screen, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */ - if (screen->sPriv->dri2.loader && - (screen->sPriv->dri2.loader->base.version > 2) && - (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) { + if (dri_with_format(screen->sPriv)) { pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); @@ -352,8 +350,6 @@ dri_init_screen2(__DRIscreen * sPriv) { struct dri_screen *screen; struct drm_create_screen_arg arg; - const __DRIdri2LoaderExtension *dri2_ext = - sPriv->dri2.loader; screen = CALLOC_STRUCT(dri_screen); if (!screen) @@ -379,8 +375,7 @@ dri_init_screen2(__DRIscreen * sPriv) driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); - screen->auto_fake_front = dri2_ext->base.version >= 3 && - dri2_ext->getBuffersWithFormat != NULL; + screen->auto_fake_front = dri_with_format(sPriv); return dri_fill_in_modes(screen, 32); fail: diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index e9944e0f63e..3b805c539f9 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -75,6 +75,16 @@ dri_screen(__DRIscreen * sPriv) return (struct dri_screen *)sPriv->private; } +static INLINE boolean +dri_with_format(__DRIscreen * sPriv) +{ + const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader; + + return loader + && (loader->base.version >= 3) + && (loader->getBuffersWithFormat != NULL); +} + extern const uint __driNConfigOptions; const __DRIconfig ** diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 263c1e19a70..67ab89e7aa8 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -172,7 +172,7 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, unsigned num_attachments, i; assert(loader); - with_format = (loader->base.version > 2 && loader->getBuffersWithFormat); + with_format = dri_with_format(drawable->sPriv); num_attachments = 0; From c049d58a229125ce7ad61c645902eb2638e87194 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:52 +0200 Subject: [PATCH 348/483] st/dri: minor cosmetic for screen - put extensions above init_screen - split out destroy_option_cache --- src/gallium/state_trackers/dri/dri_screen.c | 47 ++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 733d71f9959..cb650122668 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -51,7 +51,7 @@ PUBLIC const char __driConfigOptions[] = DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY - /*DRI_CONF_FORCE_S3TC_ENABLE(false) */ +/* DRI_CONF_FORCE_S3TC_ENABLE(false) */ DRI_CONF_ALLOW_LARGE_TEXTURES(1) DRI_CONF_SECTION_END DRI_CONF_END; @@ -87,17 +87,6 @@ static const __DRI2flushExtension dri2FlushExtension = { dri2_invalidate_drawable, }; - static const __DRIextension *dri_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - &dri2TexBufferExtension.base, - &dri2FlushExtension.base, - NULL - }; - const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits) @@ -313,11 +302,24 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) return 0; } +static void +dri_destroy_option_cache(struct dri_screen * screen) +{ + int i; + + for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { + FREE(screen->optionCache.info[i].name); + FREE(screen->optionCache.info[i].ranges); + } + + FREE(screen->optionCache.info); + FREE(screen->optionCache.values); +} + static void dri_destroy_screen(__DRIscreen * sPriv) { struct dri_screen *screen = dri_screen(sPriv); - int i; if (screen->dri1_pipe) screen->dri1_pipe->destroy(screen->dri1_pipe); @@ -327,19 +329,24 @@ dri_destroy_screen(__DRIscreen * sPriv) if (screen->pipe_screen) screen->pipe_screen->destroy(screen->pipe_screen); - for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { - FREE(screen->optionCache.info[i].name); - FREE(screen->optionCache.info[i].ranges); - } - - FREE(screen->optionCache.info); - FREE(screen->optionCache.values); + dri_destroy_option_cache(screen); FREE(screen); sPriv->private = NULL; sPriv->extensions = NULL; } +static const __DRIextension *dri_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + &dri2TexBufferExtension.base, + &dri2FlushExtension.base, + NULL +}; + /** * This is the driver specific part of the createNewScreen entry point. * From 03c4573ecaeedc8439ebbdfe90f7873fcd9706a1 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:52 +0200 Subject: [PATCH 349/483] st/dri: minor cosmetic for buffers --- src/gallium/state_trackers/dri/dri_st_api.c | 31 +++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 67ab89e7aa8..e721e55459d 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -110,27 +110,29 @@ dri_drawable_process_buffers(struct dri_drawable *drawable, switch (buf->attachment) { case __DRI_BUFFER_FRONT_LEFT: - if (!screen->auto_fake_front) { + if (!screen->auto_fake_front) { statt = ST_ATTACHMENT_INVALID; break; } - /* fallthrough */ + /* fallthrough */ case __DRI_BUFFER_FAKE_FRONT_LEFT: statt = ST_ATTACHMENT_FRONT_LEFT; - break; + break; case __DRI_BUFFER_BACK_LEFT: statt = ST_ATTACHMENT_BACK_LEFT; - break; + break; case __DRI_BUFFER_DEPTH: case __DRI_BUFFER_DEPTH_STENCIL: case __DRI_BUFFER_STENCIL: - statt = ST_ATTACHMENT_DEPTH_STENCIL; /* use only the first depth/stencil buffer */ - if (have_depth) - statt = ST_ATTACHMENT_INVALID; - else + if (!have_depth) { have_depth = TRUE; - break; + statt = ST_ATTACHMENT_DEPTH_STENCIL; + } + else { + statt = ST_ATTACHMENT_INVALID; + } + break; default: statt = ST_ATTACHMENT_INVALID; break; @@ -143,7 +145,7 @@ dri_drawable_process_buffers(struct dri_drawable *drawable, templ.format = format; whandle.handle = buf->name; whandle.stride = buf->pitch; - + drawable->textures[statt] = screen->pipe_screen->texture_from_handle(screen->pipe_screen, &templ, &whandle); @@ -182,7 +184,7 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, for (i = 0; i < *count; i++) { enum pipe_format format; - int att; + int att, bpp; format = dri_drawable_get_format(drawable, statts[i]); if (format == PIPE_FORMAT_NONE) @@ -212,11 +214,12 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, break; } + bpp = util_format_get_blocksizebits(format); + if (att >= 0) { attachments[num_attachments++] = att; if (with_format) { - attachments[num_attachments++] = - util_format_get_blocksizebits(format); + attachments[num_attachments++] = bpp; } } } @@ -258,7 +261,7 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, return buffers; } -static boolean +static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts, unsigned count, From 24056e76637c9d79d996c6bc060576907bd9b2aa Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:52 +0200 Subject: [PATCH 350/483] st/dri: flush_frontbuffer, allocate_textures for dri1 * ptex is get by flush_frontbuffer, similar to swap_buffers * comment for allocate_textures * texture_mask is managed at the st_fb level --- src/gallium/state_trackers/dri/dri1.c | 46 +++++++++++++-------- src/gallium/state_trackers/dri/dri1.h | 3 +- src/gallium/state_trackers/dri/dri_st_api.c | 13 +++--- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 240bc69efd5..9108d41bd94 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -318,23 +318,23 @@ dri1_copy_to_front(struct dri_context *ctx, } void -dri1_flush_frontbuffer(struct dri_drawable *drawable, - struct pipe_texture *ptex) +dri1_flush_frontbuffer(struct dri_drawable *draw, + enum st_attachment_type statt) { - struct st_api *stapi = dri_get_st_api(); - struct dri_screen *screen = dri_screen(drawable->sPriv); + struct dri_context *ctx = dri_get_current(); + struct dri_screen *screen = dri_screen(draw->sPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; - struct dri_context *ctx; struct pipe_fence_handle *dummy_fence; - struct st_context_iface *st = stapi->get_current(stapi); + struct pipe_texture *ptex; - if (!st) - return; + if (!ctx) + return; /* For now */ - ctx = (struct dri_context *) st->st_manager_private; - - dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence); - pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL); + ptex = draw->textures[statt]; + if (ptex) { + dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence); + pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL); + } /** * FIXME: Do we need swap throttling here? @@ -399,17 +399,31 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) } } +/** + * Allocate framebuffer attachments. + * + * During fixed-size operation, the function keeps allocating new attachments + * as they are requested. Unused attachments are not removed, not until the + * framebuffer is resized or destroyed. + */ void dri1_allocate_textures(struct dri_drawable *drawable, - unsigned width, unsigned height, unsigned mask) { struct dri_screen *screen = dri_screen(drawable->sPriv); struct pipe_texture templ; + unsigned width, height; + boolean resized; int i; + width = drawable->dPriv->w; + height = drawable->dPriv->h; + + resized = (drawable->old_w != width || + drawable->old_h != height); + /* remove outdated textures */ - if (drawable->old_w != width || drawable->old_h != height) { + if (resized) { for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_texture_reference(&drawable->textures[i], NULL); } @@ -427,9 +441,6 @@ dri1_allocate_textures(struct dri_drawable *drawable, /* the texture already exists or not requested */ if (drawable->textures[i] || !(mask & (1 << i))) { - /* remember the texture */ - if (drawable->textures[i]) - mask |= (1 << i); continue; } @@ -462,7 +473,6 @@ dri1_allocate_textures(struct dri_drawable *drawable, drawable->old_w = width; drawable->old_h = height; - drawable->texture_mask = mask; } static void diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index e83571e57be..f1004281b54 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -45,11 +45,10 @@ dri1_init_screen(__DRIscreen * sPriv); void dri1_flush_frontbuffer(struct dri_drawable *drawable, - struct pipe_texture *ptex); + enum st_attachment_type statt); void dri1_allocate_textures(struct dri_drawable *drawable, - unsigned width, unsigned height, unsigned mask); void dri1_swap_buffers(__DRIdrawable * dPriv); diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index e721e55459d..2cdfd257b01 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -285,8 +285,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, if (drawable->texture_stamp != drawable->dPriv->lastStamp || (statt_mask & ~drawable->texture_mask)) { if (__dri1_api_hooks) { - dri1_allocate_textures(drawable, - drawable->dPriv->w, drawable->dPriv->h, statt_mask); + dri1_allocate_textures(drawable, statt_mask); } else { __DRIbuffer *buffers; @@ -296,6 +295,12 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, dri_drawable_process_buffers(drawable, buffers, num_buffers); } + /* add existing textures */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->textures[i]) + statt_mask |= (1 << i); + } + drawable->texture_stamp = drawable->dPriv->lastStamp; drawable->texture_mask = statt_mask; } @@ -321,9 +326,7 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, drawable->sPriv->dri2.loader; if (__dri1_api_hooks) { - struct pipe_texture *ptex = drawable->textures[statt]; - if (ptex) - dri1_flush_frontbuffer(drawable, ptex); + dri1_flush_frontbuffer(drawable, statt); return TRUE; } From a21c30308db206467a54394b1ddda444861ee9b6 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:52 +0200 Subject: [PATCH 351/483] st/dri: flush_frontbuffer, allocate_textures for dri2 dri_st_framebuffer functions just forward to dri1/dri2 functions. --- src/gallium/state_trackers/dri/dri_st_api.c | 57 +++++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 2cdfd257b01..84c94cb06db 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -261,6 +261,18 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, return buffers; } +static void +dri_allocate_textures(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count) +{ + __DRIbuffer *buffers; + unsigned num_buffers = count; + + buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); + dri_drawable_process_buffers(drawable, buffers, num_buffers); +} + static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts, @@ -269,30 +281,31 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, { struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; - unsigned statt_mask, i; + unsigned statt_mask, new_mask; + boolean new_stamp; + int i; statt_mask = 0x0; for (i = 0; i < count; i++) statt_mask |= (1 << statts[i]); + /* record newly allocated textures */ + new_mask = (statt_mask & ~drawable->texture_mask); + /* * dPriv->pStamp is the server stamp. It should be accessed with a lock, at * least for DRI1. dPriv->lastStamp is the client stamp. It has the value * of the server stamp when last checked. - * - * This function updates the textures and records the stamp of the textures. */ - if (drawable->texture_stamp != drawable->dPriv->lastStamp || - (statt_mask & ~drawable->texture_mask)) { + new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); + + if (new_stamp || new_mask) { + if (__dri1_api_hooks) { dri1_allocate_textures(drawable, statt_mask); } else { - __DRIbuffer *buffers; - unsigned num_buffers = count; - - buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); - dri_drawable_process_buffers(drawable, buffers, num_buffers); + dri_allocate_textures(drawable, statts, count); } /* add existing textures */ @@ -316,23 +329,33 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, return TRUE; } +static void +dri_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + __DRIdrawable *dri_drawable = drawable->dPriv; + struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; + + if (loader->flushFrontBuffer == NULL) + return; + + if (statt == ST_ATTACHMENT_FRONT_LEFT) { + loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate); + } +} + static boolean dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, enum st_attachment_type statt) { struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; - struct __DRIdri2LoaderExtensionRec *loader = - drawable->sPriv->dri2.loader; if (__dri1_api_hooks) { dri1_flush_frontbuffer(drawable, statt); - return TRUE; } - - if (statt == ST_ATTACHMENT_FRONT_LEFT && loader->flushFrontBuffer) { - loader->flushFrontBuffer(drawable->dPriv, - drawable->dPriv->loaderPrivate); + else { + dri_flush_frontbuffer(drawable, statt); } return TRUE; From 96c152b4b066f6e3583821ad44ec8a527ab55e05 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:52 +0200 Subject: [PATCH 352/483] st/dri: make get_texture into validate_att This is a wrapper around dri_st_framebuffer_validate for a single attachment. Also, call validate through hook to make it more generic. --- src/gallium/state_trackers/dri/dri_drawable.c | 7 ++-- src/gallium/state_trackers/dri/dri_st_api.c | 36 +++++++++---------- src/gallium/state_trackers/dri/dri_st_api.h | 6 ++-- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 930387f8a67..4e2300d78fd 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -48,8 +48,11 @@ void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, { struct dri_context *ctx = dri_context(pDRICtx); struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_texture *pt = - dri_get_st_framebuffer_texture(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); + struct pipe_texture *pt; + + dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); + + pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; if (pt) { ctx->st->teximage(ctx->st, diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 84c94cb06db..c067cee66cf 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -390,33 +390,33 @@ dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) } /** - * Return the texture at an attachment. Allocate the texture if it does not + * Validate the texture at an attachment. Allocate the texture if it does not * exist. */ -struct pipe_texture * -dri_get_st_framebuffer_texture(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt) +void +dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) { struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; - - if (!(drawable->texture_mask & (1 << statt))) { - enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; - unsigned i, count = 0; + enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; + unsigned i, count = 0; - /* make sure DRI2 does not destroy existing buffers */ - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - if (drawable->texture_mask & (1 << i)) { - statts[count++] = i; - } + /* check if buffer already exists */ + if (drawable->texture_mask & (1 << statt)) + return; + + /* make sure DRI2 does not destroy existing buffers */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->texture_mask & (1 << i)) { + statts[count++] = i; } - statts[count++] = statt; - - drawable->texture_stamp = drawable->dPriv->lastStamp - 1; - dri_st_framebuffer_validate(stfbi, statts, count, NULL); } + statts[count++] = statt; - return drawable->textures[statt]; + drawable->texture_stamp = drawable->dPriv->lastStamp - 1; + + stfbi->validate(stfbi, statts, count, NULL); } /** diff --git a/src/gallium/state_trackers/dri/dri_st_api.h b/src/gallium/state_trackers/dri/dri_st_api.h index 7cf522e4690..99a217bfa79 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.h +++ b/src/gallium/state_trackers/dri/dri_st_api.h @@ -48,8 +48,8 @@ dri_create_st_framebuffer(struct dri_drawable *drawable); void dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); -struct pipe_texture * -dri_get_st_framebuffer_texture(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt); +void +dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt); #endif /* _DRI_ST_API_H_ */ From 6a7bd8eb95e7d304725b09272dc9c40a337182e1 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:53 +0200 Subject: [PATCH 353/483] st/dri: split out DRI2 code --- src/gallium/state_trackers/dri/Makefile | 3 +- src/gallium/state_trackers/dri/SConscript | 1 + src/gallium/state_trackers/dri/dri2.c | 413 ++++++++++++++++++ src/gallium/state_trackers/dri/dri2.h | 46 ++ src/gallium/state_trackers/dri/dri_drawable.c | 27 -- src/gallium/state_trackers/dri/dri_drawable.h | 6 - src/gallium/state_trackers/dri/dri_screen.c | 87 +--- src/gallium/state_trackers/dri/dri_screen.h | 3 + src/gallium/state_trackers/dri/dri_st_api.c | 260 +---------- 9 files changed, 476 insertions(+), 370 deletions(-) create mode 100644 src/gallium/state_trackers/dri/dri2.c create mode 100644 src/gallium/state_trackers/dri/dri2.h diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index f5af8aa3a67..6d95a277f82 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -17,7 +17,8 @@ C_SOURCES = \ dri_drawable.c \ dri_extensions.c \ dri_st_api.c \ - dri1.c + dri1.c \ + dri2.c # $(TOP)/src/mesa/drivers/dri/common/utils.c \ $(TOP)/src/mesa/drivers/dri/common/vblank.c \ diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index 7c67ceecd80..d6dc126723d 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -20,6 +20,7 @@ if env['dri']: 'dri_screen.c', 'dri_st_api.c', 'dri1.c', + 'dri2.c', ] ) Export('st_dri') diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c new file mode 100644 index 00000000000..2c6a0621ae7 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri2.c @@ -0,0 +1,413 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Keith Whitwell + * Jakob Bornecrantz + * Chia-I Wu + */ + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_debug.h" +#include "state_tracker/drm_api.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri2.h" + +/** + * DRI2 flush extension. + */ +static void +dri2_flush_drawable(__DRIdrawable *draw) +{ +} + +static void +dri2_invalidate_drawable(__DRIdrawable *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct dri_context *ctx = dri_context(dPriv->driContextPriv); + + dri2InvalidateDrawable(dPriv); + drawable->dPriv->lastStamp = *drawable->dPriv->pStamp; + + if (ctx) + ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); +} + +static const __DRI2flushExtension dri2FlushExtension = { + { __DRI2_FLUSH, __DRI2_FLUSH_VERSION }, + dri2_flush_drawable, + dri2_invalidate_drawable, +}; + +/** + * These are used for GLX_EXT_texture_from_pixmap + */ +static void +dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, + GLint format, __DRIdrawable *dPriv) +{ + struct dri_context *ctx = dri_context(pDRICtx); + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_texture *pt; + + dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); + + pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; + + if (pt) { + ctx->st->teximage(ctx->st, + (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, + 0, drawable->stvis.color_format, pt, FALSE); + } +} + +static void +dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, + __DRIdrawable *dPriv) +{ + dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); +} + +static const __DRItexBufferExtension dri2TexBufferExtension = { + { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, + dri2_set_tex_buffer, + dri2_set_tex_buffer2, +}; + +/** + * Get the format of an attachment. + */ +static INLINE enum pipe_format +dri_drawable_get_format(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + enum pipe_format format; + + switch (statt) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + format = drawable->stvis.color_format; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + format = drawable->stvis.depth_stencil_format; + break; + default: + format = PIPE_FORMAT_NONE; + break; + } + + return format; +} + +/** + * Retrieve __DRIbuffer from the DRI loader. + */ +static __DRIbuffer * +dri_drawable_get_buffers(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned *count) +{ + __DRIdrawable *dri_drawable = drawable->dPriv; + struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; + boolean with_format; + __DRIbuffer *buffers; + int num_buffers; + unsigned attachments[10]; + unsigned num_attachments, i; + + assert(loader); + with_format = dri_with_format(drawable->sPriv); + + num_attachments = 0; + + /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */ + if (!with_format) + attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT; + + for (i = 0; i < *count; i++) { + enum pipe_format format; + int att, bpp; + + format = dri_drawable_get_format(drawable, statts[i]); + if (format == PIPE_FORMAT_NONE) + continue; + + switch (statts[i]) { + case ST_ATTACHMENT_FRONT_LEFT: + /* already added */ + if (!with_format) + continue; + att = __DRI_BUFFER_FRONT_LEFT; + break; + case ST_ATTACHMENT_BACK_LEFT: + att = __DRI_BUFFER_BACK_LEFT; + break; + case ST_ATTACHMENT_FRONT_RIGHT: + att = __DRI_BUFFER_FRONT_RIGHT; + break; + case ST_ATTACHMENT_BACK_RIGHT: + att = __DRI_BUFFER_BACK_RIGHT; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + att = __DRI_BUFFER_DEPTH_STENCIL; + break; + default: + att = -1; + break; + } + + bpp = util_format_get_blocksizebits(format); + + if (att >= 0) { + attachments[num_attachments++] = att; + if (with_format) { + attachments[num_attachments++] = bpp; + } + } + } + + if (with_format) { + num_attachments /= 2; + buffers = loader->getBuffersWithFormat(dri_drawable, + &dri_drawable->w, &dri_drawable->h, + attachments, num_attachments, + &num_buffers, dri_drawable->loaderPrivate); + } + else { + buffers = loader->getBuffers(dri_drawable, + &dri_drawable->w, &dri_drawable->h, + attachments, num_attachments, + &num_buffers, dri_drawable->loaderPrivate); + } + + if (buffers) { + /* set one cliprect to cover the whole dri_drawable */ + dri_drawable->x = 0; + dri_drawable->y = 0; + dri_drawable->backX = 0; + dri_drawable->backY = 0; + dri_drawable->numClipRects = 1; + dri_drawable->pClipRects[0].x1 = 0; + dri_drawable->pClipRects[0].y1 = 0; + dri_drawable->pClipRects[0].x2 = dri_drawable->w; + dri_drawable->pClipRects[0].y2 = dri_drawable->h; + dri_drawable->numBackClipRects = 1; + dri_drawable->pBackClipRects[0].x1 = 0; + dri_drawable->pBackClipRects[0].y1 = 0; + dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; + dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; + + *count = num_buffers; + } + + return buffers; +} + +/** + * Process __DRIbuffer and convert them into pipe_textures. + */ +static void +dri_drawable_process_buffers(struct dri_drawable *drawable, + __DRIbuffer *buffers, unsigned count) +{ + struct dri_screen *screen = dri_screen(drawable->sPriv); + __DRIdrawable *dri_drawable = drawable->dPriv; + struct pipe_texture templ; + struct winsys_handle whandle; + boolean have_depth = FALSE; + unsigned i; + + if (drawable->old_num == count && + drawable->old_w == dri_drawable->w && + drawable->old_h == dri_drawable->h && + memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) + return; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + + memset(&templ, 0, sizeof(templ)); + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = dri_drawable->w; + templ.height0 = dri_drawable->h; + templ.depth0 = 1; + + memset(&whandle, 0, sizeof(whandle)); + + for (i = 0; i < count; i++) { + __DRIbuffer *buf = &buffers[i]; + enum st_attachment_type statt; + enum pipe_format format; + + switch (buf->attachment) { + case __DRI_BUFFER_FRONT_LEFT: + if (!screen->auto_fake_front) { + statt = ST_ATTACHMENT_INVALID; + break; + } + /* fallthrough */ + case __DRI_BUFFER_FAKE_FRONT_LEFT: + statt = ST_ATTACHMENT_FRONT_LEFT; + break; + case __DRI_BUFFER_BACK_LEFT: + statt = ST_ATTACHMENT_BACK_LEFT; + break; + case __DRI_BUFFER_DEPTH: + case __DRI_BUFFER_DEPTH_STENCIL: + case __DRI_BUFFER_STENCIL: + /* use only the first depth/stencil buffer */ + if (!have_depth) { + have_depth = TRUE; + statt = ST_ATTACHMENT_DEPTH_STENCIL; + } + else { + statt = ST_ATTACHMENT_INVALID; + } + break; + default: + statt = ST_ATTACHMENT_INVALID; + break; + } + + format = dri_drawable_get_format(drawable, statt); + if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE) + continue; + + templ.format = format; + whandle.handle = buf->name; + whandle.stride = buf->pitch; + + drawable->textures[statt] = + screen->pipe_screen->texture_from_handle(screen->pipe_screen, + &templ, &whandle); + } + + drawable->old_num = count; + drawable->old_w = dri_drawable->w; + drawable->old_h = dri_drawable->h; + memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); +} + +/* + * Backend functions for st_framebuffer interface. + */ + +void +dri_allocate_textures(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count) +{ + __DRIbuffer *buffers; + unsigned num_buffers = count; + + buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); + dri_drawable_process_buffers(drawable, buffers, num_buffers); +} + +void +dri_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + __DRIdrawable *dri_drawable = drawable->dPriv; + struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; + + if (loader->flushFrontBuffer == NULL) + return; + + if (statt == ST_ATTACHMENT_FRONT_LEFT) { + loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate); + } +} + +/* + * Backend function init_screen. + */ + +static const __DRIextension *dri_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + &dri2TexBufferExtension.base, + &dri2FlushExtension.base, + NULL +}; + +/** + * This is the driver specific part of the createNewScreen entry point. + * + * Returns the __GLcontextModes supported by this driver. + */ +const __DRIconfig ** +dri_init_screen2(__DRIscreen * sPriv) +{ + struct dri_screen *screen; + struct drm_create_screen_arg arg; + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + return NULL; + + screen->api = drm_api_create(); + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + sPriv->private = (void *)screen; + sPriv->extensions = dri_screen_extensions; + arg.mode = DRM_CREATE_NORMAL; + + screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg); + if (!screen->pipe_screen) { + debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + goto fail; + } + + screen->smapi = dri_create_st_manager(screen); + if (!screen->smapi) + goto fail; + + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, __driNConfigOptions); + + screen->auto_fake_front = dri_with_format(sPriv); + + return dri_fill_in_modes(screen, 32); +fail: + dri_destroy_screen(sPriv); + return NULL; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri2.h b/src/gallium/state_trackers/dri/dri2.h new file mode 100644 index 00000000000..06abccc405f --- /dev/null +++ b/src/gallium/state_trackers/dri/dri2.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#ifndef DRI2_H +#define DRI2_H + +#include "dri_drawable.h" +#include "dri_util.h" + +const __DRIconfig ** +dri_init_screen2(__DRIscreen * sPriv); + +void +dri_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt); + +void +dri_allocate_textures(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count); + +#endif /* DRI2_H */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 4e2300d78fd..9b0ae8b27a9 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -40,33 +40,6 @@ #include "util/u_memory.h" #include "util/u_inlines.h" -/** - * These are used for GLX_EXT_texture_from_pixmap - */ -void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, - GLint format, __DRIdrawable *dPriv) -{ - struct dri_context *ctx = dri_context(pDRICtx); - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_texture *pt; - - dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); - - pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; - - if (pt) { - ctx->st->teximage(ctx->st, - (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, - 0, drawable->stvis.color_format, pt, FALSE); - } -} - -void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, - __DRIdrawable *dPriv) -{ - dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); -} - /** * This is called when we need to set up GL rendering to a new X window. */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 7f687b65f23..98abeb9ec05 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -84,12 +84,6 @@ dri_create_buffer(__DRIscreen * sPriv, void dri_destroy_buffer(__DRIdrawable * dPriv); -void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, - GLint glx_texture_format, __DRIdrawable *dPriv); - -void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, - __DRIdrawable *dPriv); - #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index cb650122668..6aef2d57002 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -38,6 +38,7 @@ #include "dri_drawable.h" #include "dri_st_api.h" #include "dri1.h" +#include "dri2.h" #include "util/u_inlines.h" #include "pipe/p_screen.h" @@ -57,36 +58,6 @@ PUBLIC const char __driConfigOptions[] = const uint __driNConfigOptions = 3; -static const __DRItexBufferExtension dri2TexBufferExtension = { - { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, - dri2_set_tex_buffer, - dri2_set_tex_buffer2, -}; - -static void -dri2_flush_drawable(__DRIdrawable *draw) -{ -} - -static void -dri2_invalidate_drawable(__DRIdrawable *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct dri_context *ctx = dri_context(dPriv->driContextPriv); - - dri2InvalidateDrawable(dPriv); - drawable->dPriv->lastStamp = *drawable->dPriv->pStamp; - - if (ctx) - ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); -} - -static const __DRI2flushExtension dri2FlushExtension = { - { __DRI2_FLUSH, __DRI2_FLUSH_VERSION }, - dri2_flush_drawable, - dri2_invalidate_drawable, -}; - const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits) @@ -316,7 +287,7 @@ dri_destroy_option_cache(struct dri_screen * screen) FREE(screen->optionCache.values); } -static void +void dri_destroy_screen(__DRIscreen * sPriv) { struct dri_screen *screen = dri_screen(sPriv); @@ -336,60 +307,6 @@ dri_destroy_screen(__DRIscreen * sPriv) sPriv->extensions = NULL; } -static const __DRIextension *dri_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - &dri2TexBufferExtension.base, - &dri2FlushExtension.base, - NULL -}; - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * Returns the __GLcontextModes supported by this driver. - */ -static const __DRIconfig ** -dri_init_screen2(__DRIscreen * sPriv) -{ - struct dri_screen *screen; - struct drm_create_screen_arg arg; - - screen = CALLOC_STRUCT(dri_screen); - if (!screen) - return NULL; - - screen->api = drm_api_create(); - screen->sPriv = sPriv; - screen->fd = sPriv->fd; - sPriv->private = (void *)screen; - sPriv->extensions = dri_screen_extensions; - arg.mode = DRM_CREATE_NORMAL; - - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); - goto fail; - } - - screen->smapi = dri_create_st_manager(screen); - if (!screen->smapi) - goto fail; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - - screen->auto_fake_front = dri_with_format(sPriv); - - return dri_fill_in_modes(screen, 32); -fail: - dri_destroy_screen(sPriv); - return NULL; -} - const struct __DriverAPIRec driDriverAPI = { .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 3b805c539f9..2b0444603a0 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -94,6 +94,9 @@ void dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, const __GLcontextModes *mode); +void +dri_destroy_screen(__DRIscreen * sPriv); + #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index c067cee66cf..88cc410a9f9 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -29,7 +29,6 @@ #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_debug.h" -#include "state_tracker/drm_api.h" #include "state_tracker/st_manager.h" /* for st_manager_create_api */ #include "dri_screen.h" @@ -37,241 +36,7 @@ #include "dri_drawable.h" #include "dri_st_api.h" #include "dri1.h" - -static struct { - int32_t refcnt; - struct st_api *stapi; -} dri_st_api; - -/** - * Get the format of an attachment. - */ -static INLINE enum pipe_format -dri_drawable_get_format(struct dri_drawable *drawable, - enum st_attachment_type statt) -{ - enum pipe_format format; - - switch (statt) { - case ST_ATTACHMENT_FRONT_LEFT: - case ST_ATTACHMENT_BACK_LEFT: - case ST_ATTACHMENT_FRONT_RIGHT: - case ST_ATTACHMENT_BACK_RIGHT: - format = drawable->stvis.color_format; - break; - case ST_ATTACHMENT_DEPTH_STENCIL: - format = drawable->stvis.depth_stencil_format; - break; - default: - format = PIPE_FORMAT_NONE; - break; - } - - return format; -} - -/** - * Process __DRIbuffer and convert them into pipe_textures. - */ -static void -dri_drawable_process_buffers(struct dri_drawable *drawable, - __DRIbuffer *buffers, unsigned count) -{ - struct dri_screen *screen = dri_screen(drawable->sPriv); - __DRIdrawable *dri_drawable = drawable->dPriv; - struct pipe_texture templ; - struct winsys_handle whandle; - boolean have_depth = FALSE; - unsigned i; - - if (drawable->old_num == count && - drawable->old_w == dri_drawable->w && - drawable->old_h == dri_drawable->h && - memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) - return; - - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) - pipe_texture_reference(&drawable->textures[i], NULL); - - memset(&templ, 0, sizeof(templ)); - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = dri_drawable->w; - templ.height0 = dri_drawable->h; - templ.depth0 = 1; - - memset(&whandle, 0, sizeof(whandle)); - - for (i = 0; i < count; i++) { - __DRIbuffer *buf = &buffers[i]; - enum st_attachment_type statt; - enum pipe_format format; - - switch (buf->attachment) { - case __DRI_BUFFER_FRONT_LEFT: - if (!screen->auto_fake_front) { - statt = ST_ATTACHMENT_INVALID; - break; - } - /* fallthrough */ - case __DRI_BUFFER_FAKE_FRONT_LEFT: - statt = ST_ATTACHMENT_FRONT_LEFT; - break; - case __DRI_BUFFER_BACK_LEFT: - statt = ST_ATTACHMENT_BACK_LEFT; - break; - case __DRI_BUFFER_DEPTH: - case __DRI_BUFFER_DEPTH_STENCIL: - case __DRI_BUFFER_STENCIL: - /* use only the first depth/stencil buffer */ - if (!have_depth) { - have_depth = TRUE; - statt = ST_ATTACHMENT_DEPTH_STENCIL; - } - else { - statt = ST_ATTACHMENT_INVALID; - } - break; - default: - statt = ST_ATTACHMENT_INVALID; - break; - } - - format = dri_drawable_get_format(drawable, statt); - if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE) - continue; - - templ.format = format; - whandle.handle = buf->name; - whandle.stride = buf->pitch; - - drawable->textures[statt] = - screen->pipe_screen->texture_from_handle(screen->pipe_screen, - &templ, &whandle); - } - - drawable->old_num = count; - drawable->old_w = dri_drawable->w; - drawable->old_h = dri_drawable->h; - memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); -} - -/** - * Retrieve __DRIbuffer from the DRI loader. - */ -static __DRIbuffer * -dri_drawable_get_buffers(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned *count) -{ - __DRIdrawable *dri_drawable = drawable->dPriv; - struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; - boolean with_format; - __DRIbuffer *buffers; - int num_buffers; - unsigned attachments[10]; - unsigned num_attachments, i; - - assert(loader); - with_format = dri_with_format(drawable->sPriv); - - num_attachments = 0; - - /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */ - if (!with_format) - attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT; - - for (i = 0; i < *count; i++) { - enum pipe_format format; - int att, bpp; - - format = dri_drawable_get_format(drawable, statts[i]); - if (format == PIPE_FORMAT_NONE) - continue; - - switch (statts[i]) { - case ST_ATTACHMENT_FRONT_LEFT: - /* already added */ - if (!with_format) - continue; - att = __DRI_BUFFER_FRONT_LEFT; - break; - case ST_ATTACHMENT_BACK_LEFT: - att = __DRI_BUFFER_BACK_LEFT; - break; - case ST_ATTACHMENT_FRONT_RIGHT: - att = __DRI_BUFFER_FRONT_RIGHT; - break; - case ST_ATTACHMENT_BACK_RIGHT: - att = __DRI_BUFFER_BACK_RIGHT; - break; - case ST_ATTACHMENT_DEPTH_STENCIL: - att = __DRI_BUFFER_DEPTH_STENCIL; - break; - default: - att = -1; - break; - } - - bpp = util_format_get_blocksizebits(format); - - if (att >= 0) { - attachments[num_attachments++] = att; - if (with_format) { - attachments[num_attachments++] = bpp; - } - } - } - - if (with_format) { - num_attachments /= 2; - buffers = loader->getBuffersWithFormat(dri_drawable, - &dri_drawable->w, &dri_drawable->h, - attachments, num_attachments, - &num_buffers, dri_drawable->loaderPrivate); - } - else { - buffers = loader->getBuffers(dri_drawable, - &dri_drawable->w, &dri_drawable->h, - attachments, num_attachments, - &num_buffers, dri_drawable->loaderPrivate); - } - - if (buffers) { - /* set one cliprect to cover the whole dri_drawable */ - dri_drawable->x = 0; - dri_drawable->y = 0; - dri_drawable->backX = 0; - dri_drawable->backY = 0; - dri_drawable->numClipRects = 1; - dri_drawable->pClipRects[0].x1 = 0; - dri_drawable->pClipRects[0].y1 = 0; - dri_drawable->pClipRects[0].x2 = dri_drawable->w; - dri_drawable->pClipRects[0].y2 = dri_drawable->h; - dri_drawable->numBackClipRects = 1; - dri_drawable->pBackClipRects[0].x1 = 0; - dri_drawable->pBackClipRects[0].y1 = 0; - dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; - dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; - - *count = num_buffers; - } - - return buffers; -} - -static void -dri_allocate_textures(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned count) -{ - __DRIbuffer *buffers; - unsigned num_buffers = count; - - buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); - dri_drawable_process_buffers(drawable, buffers, num_buffers); -} +#include "dri2.h" static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, @@ -329,21 +94,6 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, return TRUE; } -static void -dri_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt) -{ - __DRIdrawable *dri_drawable = drawable->dPriv; - struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; - - if (loader->flushFrontBuffer == NULL) - return; - - if (statt == ST_ATTACHMENT_FRONT_LEFT) { - loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate); - } -} - static boolean dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, enum st_attachment_type statt) @@ -419,6 +169,14 @@ dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, stfbi->validate(stfbi, statts, count, NULL); } +/** + * Reference counted st_api. + */ +static struct { + int32_t refcnt; + struct st_api *stapi; +} dri_st_api; + /** * Add a reference to the st_api of the state tracker. */ From 4ce16e13ce5ca89943b86a8e8cdb5354892a13a6 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:53 +0200 Subject: [PATCH 354/483] st/dri: export DRI1 surface / pipe They will be used by DRISW. Also, add destroy functions. --- src/gallium/state_trackers/dri/Makefile | 1 + src/gallium/state_trackers/dri/SConscript | 1 + src/gallium/state_trackers/dri/dri1.c | 93 ++----------- src/gallium/state_trackers/dri/dri1.h | 3 - src/gallium/state_trackers/dri/dri1_helper.c | 129 ++++++++++++++++++ src/gallium/state_trackers/dri/dri1_helper.h | 61 +++++++++ src/gallium/state_trackers/dri/dri_drawable.c | 7 +- src/gallium/state_trackers/dri/dri_screen.c | 5 +- src/gallium/state_trackers/dri/dri_st_api.c | 8 ++ 9 files changed, 218 insertions(+), 90 deletions(-) create mode 100644 src/gallium/state_trackers/dri/dri1_helper.c create mode 100644 src/gallium/state_trackers/dri/dri1_helper.h diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index 6d95a277f82..f1a54e80b61 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -17,6 +17,7 @@ C_SOURCES = \ dri_drawable.c \ dri_extensions.c \ dri_st_api.c \ + dri1_helper.c \ dri1.c \ dri2.c diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index d6dc126723d..2ca9f420683 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -19,6 +19,7 @@ if env['dri']: 'dri_extensions.c', 'dri_screen.c', 'dri_st_api.c', + 'dri1_helper.c', 'dri1.c', 'dri2.c', ] diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/dri1.c index 9108d41bd94..98bdb2936a1 100644 --- a/src/gallium/state_trackers/dri/dri1.c +++ b/src/gallium/state_trackers/dri/dri1.c @@ -41,6 +41,7 @@ #include "dri_context.h" #include "dri_drawable.h" #include "dri_st_api.h" +#include "dri1_helper.h" #include "dri1.h" static INLINE void @@ -65,50 +66,6 @@ dri1_unlock(struct dri_context *ctx) DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext); } -static struct pipe_fence_handle * -dri_swap_fences_pop_front(struct dri_drawable *draw) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - struct pipe_fence_handle *fence = NULL; - - if (draw->cur_fences >= draw->desired_fences) { - screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); - screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); - --draw->cur_fences; - draw->tail &= DRI_SWAP_FENCES_MASK; - } - return fence; -} - -static void -dri_swap_fences_push_back(struct dri_drawable *draw, - struct pipe_fence_handle *fence) -{ - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; - - if (!fence) - return; - - if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { - draw->cur_fences++; - screen->fence_reference(screen, &draw->swap_fences[draw->head++], - fence); - draw->head &= DRI_SWAP_FENCES_MASK; - } -} - -void -dri1_swap_fences_clear(struct dri_drawable *drawable) -{ - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; - struct pipe_fence_handle *fence; - - while (drawable->cur_fences) { - fence = dri_swap_fences_pop_front(drawable); - screen->fence_reference(screen, &fence, NULL); - } -} - static void dri1_update_drawables_locked(struct dri_context *ctx, __DRIdrawable * driDrawPriv, @@ -213,39 +170,6 @@ dri1_swap_copy(struct pipe_context *pipe, } } -static struct pipe_surface * -dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex) -{ - struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; - struct pipe_surface *psurf = drawable->dri1_surface; - - if (!psurf || psurf->texture != ptex) { - pipe_surface_reference(&drawable->dri1_surface, NULL); - - drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, - ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); - - psurf = drawable->dri1_surface; - } - - return psurf; -} - -static struct pipe_context * -dri1_get_pipe_context(struct dri_drawable *drawable) -{ - struct dri_screen *screen = dri_screen(drawable->sPriv); - struct pipe_context *pipe = screen->dri1_pipe; - - if (!pipe) { - screen->dri1_pipe = - screen->pipe_screen->context_create(screen->pipe_screen, NULL); - pipe = screen->dri1_pipe; - } - - return pipe; -} - static void dri1_present_texture_locked(__DRIdrawable * dPriv, struct pipe_texture *ptex, @@ -253,6 +177,7 @@ dri1_present_texture_locked(__DRIdrawable * dPriv, struct pipe_fence_handle **fence) { struct dri_drawable *drawable = dri_drawable(dPriv); + struct dri_screen *screen = dri_screen(drawable->sPriv); struct pipe_context *pipe; struct pipe_surface *psurf; struct drm_clip_rect bbox; @@ -270,7 +195,7 @@ dri1_present_texture_locked(__DRIdrawable * dPriv, if (!visible) return; - pipe = dri1_get_pipe_context(drawable); + pipe = dri1_get_pipe_context(screen); psurf = dri1_get_pipe_surface(drawable, ptex); if (!pipe || !psurf) return; @@ -317,6 +242,10 @@ dri1_copy_to_front(struct dri_context *ctx, dri1_propagate_drawable_change(ctx); } +/* + * Backend functions for st_framebuffer interface and swap_buffers. + */ + void dri1_flush_frontbuffer(struct dri_drawable *draw, enum st_attachment_type statt) @@ -359,13 +288,13 @@ dri1_swap_buffers(__DRIdrawable * dPriv) ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT]; if (ptex) { ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - fence = dri_swap_fences_pop_front(draw); + fence = dri1_swap_fences_pop_front(draw); if (fence) { (void)pipe_screen->fence_finish(pipe_screen, fence, 0); pipe_screen->fence_reference(pipe_screen, &fence, NULL); } dri1_copy_to_front(ctx, ptex, dPriv, NULL, &fence); - dri_swap_fences_push_back(draw, fence); + dri1_swap_fences_push_back(draw, fence); pipe_screen->fence_reference(pipe_screen, &fence, NULL); } } @@ -513,6 +442,10 @@ static struct dri1_api_lock_funcs dri1_lf = { .clear_lost_lock = st_dri_clear_lost_lock }; +/* + * Backend function for init_screen. + */ + static const __DRIextension *dri1_screen_extensions[] = { &driReadDrawableExtension, &driCopySubBufferExtension.base, diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index f1004281b54..cced505ea97 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -56,7 +56,4 @@ void dri1_swap_buffers(__DRIdrawable * dPriv); void dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h); -void -dri1_swap_fences_clear(struct dri_drawable *drawable); - #endif /* DRI1_H */ diff --git a/src/gallium/state_trackers/dri/dri1_helper.c b/src/gallium/state_trackers/dri/dri1_helper.c new file mode 100644 index 00000000000..7eeb868d422 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri1_helper.c @@ -0,0 +1,129 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ +/* + * Management of pipe objects (surface / pipe / fences) used by DRI1 and DRISW. + * + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "util/u_inlines.h" +#include "pipe/p_context.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri1_helper.h" + +struct pipe_fence_handle * +dri1_swap_fences_pop_front(struct dri_drawable *draw) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_fence_handle *fence = NULL; + + if (draw->cur_fences >= draw->desired_fences) { + screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]); + screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL); + --draw->cur_fences; + draw->tail &= DRI_SWAP_FENCES_MASK; + } + return fence; +} + +void +dri1_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence) +{ + struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + + if (!fence) + return; + + if (draw->cur_fences < DRI_SWAP_FENCES_MAX) { + draw->cur_fences++; + screen->fence_reference(screen, &draw->swap_fences[draw->head++], + fence); + draw->head &= DRI_SWAP_FENCES_MASK; + } +} + +void +dri1_swap_fences_clear(struct dri_drawable *drawable) +{ + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_fence_handle *fence; + + while (drawable->cur_fences) { + fence = dri1_swap_fences_pop_front(drawable); + screen->fence_reference(screen, &fence, NULL); + } +} + +struct pipe_surface * +dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex) +{ + struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_surface *psurf = drawable->dri1_surface; + + if (!psurf || psurf->texture != ptex) { + pipe_surface_reference(&drawable->dri1_surface, NULL); + + drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, + ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); + + psurf = drawable->dri1_surface; + } + + return psurf; +} + +void +dri1_destroy_pipe_surface(struct dri_drawable *drawable) +{ + pipe_surface_reference(&drawable->dri1_surface, NULL); +} + +struct pipe_context * +dri1_get_pipe_context(struct dri_screen *screen) +{ + struct pipe_context *pipe = screen->dri1_pipe; + + if (!pipe) { + screen->dri1_pipe = + screen->pipe_screen->context_create(screen->pipe_screen, NULL); + pipe = screen->dri1_pipe; + } + + return pipe; +} + +void +dri1_destroy_pipe_context(struct dri_screen *screen) +{ + if (screen->dri1_pipe) + screen->dri1_pipe->destroy(screen->dri1_pipe); +} diff --git a/src/gallium/state_trackers/dri/dri1_helper.h b/src/gallium/state_trackers/dri/dri1_helper.h new file mode 100644 index 00000000000..3254b7ff872 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri1_helper.h @@ -0,0 +1,61 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI1_HELPER_H +#define DRI1_HELPER_H + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +struct pipe_fence_handle * +dri1_swap_fences_pop_front(struct dri_drawable *draw); + +void +dri1_swap_fences_push_back(struct dri_drawable *draw, + struct pipe_fence_handle *fence); + +void +dri1_swap_fences_clear(struct dri_drawable *drawable); + +struct pipe_surface * +dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex); + +void +dri1_destroy_pipe_surface(struct dri_drawable *drawable); + +struct pipe_context * +dri1_get_pipe_context(struct dri_screen *screen); + +void +dri1_destroy_pipe_context(struct dri_screen *screen); + +#endif /* DRI1_HELPER_H */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 9b0ae8b27a9..75b4cc56289 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -33,7 +33,7 @@ #include "dri_context.h" #include "dri_drawable.h" #include "dri_st_api.h" -#include "dri1.h" +#include "dri1_helper.h" #include "pipe/p_screen.h" #include "util/u_format.h" @@ -79,13 +79,10 @@ void dri_destroy_buffer(__DRIdrawable * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); - int i; dri1_swap_fences_clear(drawable); - pipe_surface_reference(&drawable->dri1_surface, NULL); - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) - pipe_texture_reference(&drawable->textures[i], NULL); + dri1_destroy_pipe_surface(drawable); dri_destroy_st_framebuffer(drawable->stfb); diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 6aef2d57002..1d808f0f7f9 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -37,6 +37,7 @@ #include "dri_context.h" #include "dri_drawable.h" #include "dri_st_api.h" +#include "dri1_helper.h" #include "dri1.h" #include "dri2.h" @@ -292,11 +293,11 @@ dri_destroy_screen(__DRIscreen * sPriv) { struct dri_screen *screen = dri_screen(sPriv); - if (screen->dri1_pipe) - screen->dri1_pipe->destroy(screen->dri1_pipe); + dri1_destroy_pipe_context(screen); if (screen->smapi) dri_destroy_st_manager(screen->smapi); + if (screen->pipe_screen) screen->pipe_screen->destroy(screen->pipe_screen); diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 88cc410a9f9..3592a782229 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -35,6 +35,7 @@ #include "dri_context.h" #include "dri_drawable.h" #include "dri_st_api.h" +#include "dri1_helper.h" #include "dri1.h" #include "dri2.h" @@ -136,6 +137,13 @@ dri_create_st_framebuffer(struct dri_drawable *drawable) void dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) { + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + int i; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + FREE(stfbi); } From 1bed0eb98e00ed9ea7431f19ab3bed8860864264 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:53 +0200 Subject: [PATCH 355/483] st/dri: add dri_wrapper.h --- src/gallium/state_trackers/dri/dri1.h | 2 +- src/gallium/state_trackers/dri/dri2.h | 2 +- src/gallium/state_trackers/dri/dri_context.c | 1 - src/gallium/state_trackers/dri/dri_context.h | 3 +-- src/gallium/state_trackers/dri/dri_screen.h | 2 +- src/gallium/state_trackers/dri/dri_wrapper.h | 10 ++++++++++ 6 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/gallium/state_trackers/dri/dri_wrapper.h diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/dri1.h index cced505ea97..f7441f98abc 100644 --- a/src/gallium/state_trackers/dri/dri1.h +++ b/src/gallium/state_trackers/dri/dri1.h @@ -36,7 +36,7 @@ #include "dri_drawable.h" #include "state_tracker/st_api.h" -#include "dri_util.h" +#include "dri_wrapper.h" extern struct dri1_api *__dri1_api_hooks; diff --git a/src/gallium/state_trackers/dri/dri2.h b/src/gallium/state_trackers/dri/dri2.h index 06abccc405f..e1afcf8ca8d 100644 --- a/src/gallium/state_trackers/dri/dri2.h +++ b/src/gallium/state_trackers/dri/dri2.h @@ -29,7 +29,7 @@ #define DRI2_H #include "dri_drawable.h" -#include "dri_util.h" +#include "dri_wrapper.h" const __DRIconfig ** dri_init_screen2(__DRIscreen * sPriv); diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 54568a8b220..34d9a932ead 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -33,7 +33,6 @@ #include "dri_drawable.h" #include "dri_context.h" #include "dri_st_api.h" -#include "dri1.h" #include "pipe/p_context.h" #include "util/u_memory.h" diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h index 845b420cf89..24d3d0368a4 100644 --- a/src/gallium/state_trackers/dri/dri_context.h +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -33,8 +33,7 @@ #define DRI_CONTEXT_H #include "pipe/p_compiler.h" -#include "drm.h" -#include "dri_util.h" +#include "dri_wrapper.h" struct pipe_context; struct pipe_fence; diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 2b0444603a0..639d48661e2 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -32,7 +32,7 @@ #ifndef DRI_SCREEN_H #define DRI_SCREEN_H -#include "dri_util.h" +#include "dri_wrapper.h" #include "xmlconfig.h" #include "pipe/p_compiler.h" diff --git a/src/gallium/state_trackers/dri/dri_wrapper.h b/src/gallium/state_trackers/dri/dri_wrapper.h new file mode 100644 index 00000000000..141ba02706a --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_wrapper.h @@ -0,0 +1,10 @@ +#ifndef DRI_WRAPPER_H +#define DRI_WRAPPER_H + +#ifndef __NOT_HAVE_DRM_H +#include "dri_util.h" +#else +#include "drisw_util.h" +#endif + +#endif From 5b75e12f9165c890fd14b22983d6289be8f20abc Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:53 +0200 Subject: [PATCH 356/483] st/dri: add drisw --- src/gallium/include/state_tracker/drm_api.h | 1 + src/gallium/state_trackers/dri/dri_screen.c | 33 +++ src/gallium/state_trackers/dri/dri_screen.h | 12 + src/gallium/state_trackers/dri/dri_st_api.c | 12 + src/gallium/state_trackers/dri/drisw.c | 288 ++++++++++++++++++++ src/gallium/state_trackers/dri/drisw.h | 54 ++++ 6 files changed, 400 insertions(+) create mode 100644 src/gallium/state_trackers/dri/drisw.c create mode 100644 src/gallium/state_trackers/dri/drisw.h diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index fe7ef253ef0..9780cf250b8 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -13,6 +13,7 @@ struct pipe_texture; enum drm_create_screen_mode { DRM_CREATE_NORMAL = 0, DRM_CREATE_DRI1, + DRM_CREATE_DRISW, DRM_CREATE_DRIVER = 1024, DRM_CREATE_MAX }; diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 1d808f0f7f9..ae311641042 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -30,7 +30,9 @@ */ #include "utils.h" +#ifndef __NOT_HAVE_DRM_H #include "vblank.h" +#endif #include "xmlpool.h" #include "dri_screen.h" @@ -40,6 +42,7 @@ #include "dri1_helper.h" #include "dri1.h" #include "dri2.h" +#include "drisw.h" #include "util/u_inlines.h" #include "pipe/p_screen.h" @@ -262,6 +265,8 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, /* let the state tracker allocate the accum buffer */ } +#ifndef __NOT_HAVE_DRM_H + /** * Get information about previous buffer swaps. */ @@ -274,6 +279,8 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) return 0; } +#endif + static void dri_destroy_option_cache(struct dri_screen * screen) { @@ -308,6 +315,8 @@ dri_destroy_screen(__DRIscreen * sPriv) sPriv->extensions = NULL; } +#ifndef __NOT_HAVE_DRM_H + const struct __DriverAPIRec driDriverAPI = { .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, @@ -334,4 +343,28 @@ PUBLIC const __DRIextension *__driDriverExtensions[] = { NULL }; +#else + +const struct __DriverAPIRec driDriverAPI = { + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + + .InitScreen = drisw_init_screen, + .SwapBuffers = drisw_swap_buffers, +}; + +/* This is the table of extensions that the loader will dlsym() for. */ +PUBLIC const __DRIextension *__driDriverExtensions[] = { + &driCoreExtension.base, + &driSWRastExtension.base, + NULL +}; + +#endif + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 639d48661e2..4f59db37cfa 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -75,6 +75,8 @@ dri_screen(__DRIscreen * sPriv) return (struct dri_screen *)sPriv->private; } +#ifndef __NOT_HAVE_DRM_H + static INLINE boolean dri_with_format(__DRIscreen * sPriv) { @@ -85,6 +87,16 @@ dri_with_format(__DRIscreen * sPriv) && (loader->getBuffersWithFormat != NULL); } +#else + +static INLINE boolean +dri_with_format(__DRIscreen * sPriv) +{ + return TRUE; +} + +#endif + extern const uint __driNConfigOptions; const __DRIconfig ** diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 3592a782229..2b98c487c84 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -38,6 +38,7 @@ #include "dri1_helper.h" #include "dri1.h" #include "dri2.h" +#include "drisw.h" static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, @@ -67,12 +68,19 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, if (new_stamp || new_mask) { +#ifndef __NOT_HAVE_DRM_H if (__dri1_api_hooks) { dri1_allocate_textures(drawable, statt_mask); } else { dri_allocate_textures(drawable, statts, count); } +#else + if (new_stamp) + drisw_update_drawable_info(drawable->dPriv); + + drisw_allocate_textures(drawable, statt_mask); +#endif /* add existing textures */ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { @@ -102,12 +110,16 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; +#ifndef __NOT_HAVE_DRM_H if (__dri1_api_hooks) { dri1_flush_frontbuffer(drawable, statt); } else { dri_flush_frontbuffer(drawable, statt); } +#else + drisw_flush_frontbuffer(drawable, statt); +#endif return TRUE; } diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c new file mode 100644 index 00000000000..b3d65df8815 --- /dev/null +++ b/src/gallium/state_trackers/dri/drisw.c @@ -0,0 +1,288 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "pipe/p_context.h" +#include "state_tracker/drm_api.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_st_api.h" +#include "dri1_helper.h" +#include "drisw.h" + + +static INLINE void +get_drawable_info(__DRIdrawable *dPriv, int *w, int *h) +{ + __DRIscreen *sPriv = dPriv->driScreenPriv; + const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; + int x, y; + + loader->getDrawableInfo(dPriv, + &x, &y, w, h, + dPriv->loaderPrivate); +} + +static INLINE void +put_image(__DRIdrawable *dPriv, void *data) +{ + __DRIscreen *sPriv = dPriv->driScreenPriv; + const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; + + loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, + 0, 0, dPriv->w, dPriv->h, + data, dPriv->loaderPrivate); +} + +void +drisw_update_drawable_info(__DRIdrawable *dPriv) +{ + get_drawable_info(dPriv, &dPriv->w, &dPriv->h); +} + +static INLINE void +drisw_present_texture(__DRIdrawable *dPriv, + struct pipe_texture *ptex) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct dri_screen *screen = dri_screen(drawable->sPriv); + struct pipe_context *pipe; + struct pipe_surface *psurf; + struct pipe_transfer *ptrans; + void *pmap; + + pipe = dri1_get_pipe_context(screen); + psurf = dri1_get_pipe_surface(drawable, ptex); + if (!pipe || !psurf) + return; + + ptrans = pipe->get_tex_transfer(pipe, ptex, 0, 0, 0, + PIPE_TRANSFER_READ, + 0, 0, dPriv->w, dPriv->h); + + pmap = pipe->transfer_map(pipe, ptrans); + + assert(pmap); + + put_image(dPriv, pmap); + + pipe->transfer_unmap(pipe, ptrans); + + pipe->tex_transfer_destroy(pipe, ptrans); +} + +static INLINE void +drisw_invalidate_drawable(__DRIdrawable *dPriv) +{ + struct dri_context *ctx = dri_get_current(); + struct dri_drawable *drawable = dri_drawable(dPriv); + + drawable->texture_stamp = dPriv->lastStamp - 1; + + /* check if swapping currently bound buffer */ + if (ctx && ctx->dPriv == dPriv) + ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); +} + +static INLINE void +drisw_copy_to_front(__DRIdrawable * dPriv, + struct pipe_texture *ptex) +{ + drisw_present_texture(dPriv, ptex); + + drisw_invalidate_drawable(dPriv); +} + +/* + * Backend functions for st_framebuffer interface and swap_buffers. + */ + +void +drisw_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + struct dri_context *ctx = dri_get_current(); + struct pipe_texture *ptex; + + if (!ctx) + return; + + ptex = drawable->textures[statt]; + + if (ptex) { + drisw_copy_to_front(ctx->dPriv, ptex); + } +} + +void +drisw_swap_buffers(__DRIdrawable *dPriv) +{ + struct dri_context *ctx = dri_get_current(); + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_texture *ptex; + + if (!ctx) + return; + + ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT]; + + if (ptex) { + ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + drisw_copy_to_front(dPriv, ptex); + } +} + +/** + * Allocate framebuffer attachments. + * + * During fixed-size operation, the function keeps allocating new attachments + * as they are requested. Unused attachments are not removed, not until the + * framebuffer is resized or destroyed. + * + * It should be possible for DRI1 and DRISW to share this function, but it + * seems a better seperation and safer for each DRI version to provide its own + * function. + */ +void +drisw_allocate_textures(struct dri_drawable *drawable, + unsigned mask) +{ + struct dri_screen *screen = dri_screen(drawable->sPriv); + struct pipe_texture templ; + unsigned width, height; + boolean resized; + int i; + + width = drawable->dPriv->w; + height = drawable->dPriv->h; + + resized = (drawable->old_w != width || + drawable->old_h != height); + + /* remove outdated textures */ + if (resized) { + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_texture_reference(&drawable->textures[i], NULL); + } + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.width0 = width; + templ.height0 = height; + templ.depth0 = 1; + templ.last_level = 0; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + enum pipe_format format; + unsigned tex_usage; + + /* the texture already exists or not requested */ + if (drawable->textures[i] || !(mask & (1 << i))) { + continue; + } + + switch (i) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + format = drawable->stvis.color_format; + tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_RENDER_TARGET; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + format = drawable->stvis.depth_stencil_format; + tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + break; + default: + format = PIPE_FORMAT_NONE; + break; + } + + if (format != PIPE_FORMAT_NONE) { + templ.format = format; + templ.tex_usage = tex_usage; + + drawable->textures[i] = + screen->pipe_screen->texture_create(screen->pipe_screen, &templ); + } + } + + drawable->old_w = width; + drawable->old_h = height; +} + +/* + * Backend function for init_screen. + */ + +static const __DRIextension *drisw_screen_extensions[] = { + NULL +}; + +const __DRIconfig ** +drisw_init_screen(__DRIscreen * sPriv) +{ + struct dri_screen *screen; + struct drm_create_screen_arg arg; + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + return NULL; + + screen->api = drm_api_create(); + screen->sPriv = sPriv; + screen->fd = -1; + sPriv->private = (void *)screen; + sPriv->extensions = drisw_screen_extensions; + arg.mode = DRM_CREATE_DRISW; + + screen->pipe_screen = screen->api->create_screen(screen->api, -1, &arg); + if (!screen->pipe_screen) { + debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + goto fail; + } + + screen->smapi = dri_create_st_manager(screen); + if (!screen->smapi) + goto fail; + + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, __driNConfigOptions); + + return dri_fill_in_modes(screen, 32); +fail: + dri_destroy_screen(sPriv); + return NULL; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/drisw.h b/src/gallium/state_trackers/dri/drisw.h new file mode 100644 index 00000000000..2c0d5610fac --- /dev/null +++ b/src/gallium/state_trackers/dri/drisw.h @@ -0,0 +1,54 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#ifndef DRISW_H +#define DRISW_H + +#include "dri_context.h" +#include "dri_drawable.h" + +#include "state_tracker/st_api.h" +#include "dri_wrapper.h" + +const __DRIconfig ** +drisw_init_screen(__DRIscreen * sPriv); + +void +drisw_update_drawable_info(__DRIdrawable *dPriv); + +void +drisw_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt); + +void +drisw_allocate_textures(struct dri_drawable *drawable, + unsigned mask); + +void drisw_swap_buffers(__DRIdrawable * dPriv); + +#endif /* DRISW_H */ From 992e9572bdbc1f3d5243ca8eecbd6a372721a62b Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:53 +0200 Subject: [PATCH 357/483] swrastg_dri: add state_tracker --- configure.ac | 2 +- src/gallium/state_trackers/drisw/Makefile | 26 +++++++++++++++++++ .../state_trackers/drisw/dri1_helper.c | 1 + .../state_trackers/drisw/dri_context.c | 1 + .../state_trackers/drisw/dri_drawable.c | 1 + .../state_trackers/drisw/dri_extensions.c | 1 + src/gallium/state_trackers/drisw/dri_screen.c | 1 + src/gallium/state_trackers/drisw/dri_st_api.c | 1 + src/gallium/state_trackers/drisw/drisw.c | 1 + 9 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/gallium/state_trackers/drisw/Makefile create mode 120000 src/gallium/state_trackers/drisw/dri1_helper.c create mode 120000 src/gallium/state_trackers/drisw/dri_context.c create mode 120000 src/gallium/state_trackers/drisw/dri_drawable.c create mode 120000 src/gallium/state_trackers/drisw/dri_extensions.c create mode 120000 src/gallium/state_trackers/drisw/dri_screen.c create mode 120000 src/gallium/state_trackers/drisw/dri_st_api.c create mode 120000 src/gallium/state_trackers/drisw/drisw.c diff --git a/configure.ac b/configure.ac index edf2363a717..1b9500b8b5a 100644 --- a/configure.ac +++ b/configure.ac @@ -1204,7 +1204,7 @@ yes) GALLIUM_STATE_TRACKERS_DIRS=glx ;; dri) - GALLIUM_STATE_TRACKERS_DIRS="dri" + GALLIUM_STATE_TRACKERS_DIRS="dri drisw" if test "x$enable_egl" = xyes; then GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" fi diff --git a/src/gallium/state_trackers/drisw/Makefile b/src/gallium/state_trackers/drisw/Makefile new file mode 100644 index 00000000000..dec9a39edec --- /dev/null +++ b/src/gallium/state_trackers/drisw/Makefile @@ -0,0 +1,26 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = drisw + +LIBRARY_DEFINES = -D__NOT_HAVE_DRM_H + +LIBRARY_INCLUDES = \ + -I../dri \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa/main \ + -D__NOT_HAVE_DRM_H + + +C_SOURCES = \ + dri_context.c \ + dri_screen.c \ + dri_drawable.c \ + dri_extensions.c \ + dri_st_api.c \ + dri1_helper.c \ + drisw.c + +include ../../Makefile.template diff --git a/src/gallium/state_trackers/drisw/dri1_helper.c b/src/gallium/state_trackers/drisw/dri1_helper.c new file mode 120000 index 00000000000..e704e382e05 --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri1_helper.c @@ -0,0 +1 @@ +../dri/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_context.c b/src/gallium/state_trackers/drisw/dri_context.c new file mode 120000 index 00000000000..e4e879dc867 --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri_context.c @@ -0,0 +1 @@ +../dri/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_drawable.c b/src/gallium/state_trackers/drisw/dri_drawable.c new file mode 120000 index 00000000000..d7f65c85d20 --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri_drawable.c @@ -0,0 +1 @@ +../dri/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_extensions.c b/src/gallium/state_trackers/drisw/dri_extensions.c new file mode 120000 index 00000000000..60ecde9547d --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri_extensions.c @@ -0,0 +1 @@ +../dri/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_screen.c b/src/gallium/state_trackers/drisw/dri_screen.c new file mode 120000 index 00000000000..f22c562c84f --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri_screen.c @@ -0,0 +1 @@ +../dri/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_st_api.c b/src/gallium/state_trackers/drisw/dri_st_api.c new file mode 120000 index 00000000000..eac8ec66905 --- /dev/null +++ b/src/gallium/state_trackers/drisw/dri_st_api.c @@ -0,0 +1 @@ +../dri/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/drisw.c b/src/gallium/state_trackers/drisw/drisw.c new file mode 120000 index 00000000000..258a79021ef --- /dev/null +++ b/src/gallium/state_trackers/drisw/drisw.c @@ -0,0 +1 @@ +../dri/drisw.c \ No newline at end of file From 007e0e3ef90d73f232c463e353da13378ffcef63 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:54 +0200 Subject: [PATCH 358/483] swrastg_dri: add winsys and target --- src/gallium/targets/dri-swrast/Makefile | 30 +++ .../targets/dri-swrast/swrast_drm_api.c | 93 +++++++++ src/gallium/winsys/sw/dri/Makefile | 13 ++ src/gallium/winsys/sw/dri/dri_sw_winsys.c | 197 ++++++++++++++++++ src/gallium/winsys/sw/dri/dri_sw_winsys.h | 36 ++++ 5 files changed, 369 insertions(+) create mode 100644 src/gallium/targets/dri-swrast/Makefile create mode 100644 src/gallium/targets/dri-swrast/swrast_drm_api.c create mode 100644 src/gallium/winsys/sw/dri/Makefile create mode 100644 src/gallium/winsys/sw/dri/dri_sw_winsys.c create mode 100644 src/gallium/winsys/sw/dri/dri_sw_winsys.h diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile new file mode 100644 index 00000000000..57a9e02a4bb --- /dev/null +++ b/src/gallium/targets/dri-swrast/Makefile @@ -0,0 +1,30 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = swrastg_dri.so + +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/drisw/libdrisw.a \ + $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +SWRAST_COMMON_GALLIUM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/drisw_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c + +C_SOURCES = \ + swrast_drm_api.c \ + $(SWRAST_COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +ASM_SOURCES = + +include ../Makefile.dri + +INCLUDES += \ + -I$(TOP)/src/gallium/winsys/sw/dri + +symlinks: diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c new file mode 100644 index 00000000000..211836d784f --- /dev/null +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -0,0 +1,93 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include "pipe/p_compiler.h" +#include "util/u_memory.h" + +#include "softpipe/sp_public.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/sw_winsys.h" +#include "dri_sw_winsys.h" + +static struct pipe_screen * +swrast_create_screen(struct drm_api *api, + int drmFD, + struct drm_create_screen_arg *arg) +{ + struct sw_winsys *winsys = NULL; + struct pipe_screen *screen = NULL; + + (void) drmFD; + + if (arg != NULL) { + switch(arg->mode) { + case DRM_CREATE_DRISW: + break; + default: + return NULL; + } + } + + winsys = dri_create_sw_winsys(); + if (winsys == NULL) + return NULL; + + screen = softpipe_create_screen( winsys ); + if (screen == NULL) + goto fail; + + return screen; + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + +static void +swrast_drm_api_destroy(struct drm_api *api) +{ + return; +} + +static struct drm_api swrast_drm_api = +{ + .name = "swrast", + .driver_name = "swrast", + .create_screen = swrast_create_screen, + .destroy = swrast_drm_api_destroy, +}; + +struct drm_api * +drm_api_create() +{ + return &swrast_drm_api; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/dri/Makefile b/src/gallium/winsys/sw/dri/Makefile new file mode 100644 index 00000000000..a3fca6be885 --- /dev/null +++ b/src/gallium/winsys/sw/dri/Makefile @@ -0,0 +1,13 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = swdri + +LIBRARY_INCLUDES = + +LIBRARY_DEFINES = + +C_SOURCES = \ + dri_sw_winsys.c + +include ../../../Makefile.template diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c new file mode 100644 index 00000000000..abf92b86b04 --- /dev/null +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -0,0 +1,197 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "state_tracker/sw_winsys.h" +#include "dri_sw_winsys.h" + + +struct xm_displaytarget +{ + void *data; + void *mapped; +}; + + +/** Cast wrapper */ +static INLINE struct xm_displaytarget * +xm_displaytarget( struct sw_displaytarget *dt ) +{ + return (struct xm_displaytarget *)dt; +} + + +/* pipe_screen::is_format_supported */ +static boolean +xm_is_displaytarget_format_supported( struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format ) +{ + /* TODO: check visuals or other sensible thing here */ + return TRUE; +} + +/* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ +static struct sw_displaytarget * +xm_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct xm_displaytarget *xm_dt; + unsigned nblocksy, size, xm_stride; + + xm_dt = CALLOC_STRUCT(xm_displaytarget); + if(!xm_dt) + goto no_xm_dt; + + nblocksy = util_format_get_nblocksy(format, height); + xm_stride = align(util_format_get_stride(format, width), alignment); + size = xm_stride * nblocksy; + + xm_dt->data = align_malloc(size, alignment); + if(!xm_dt->data) + goto no_data; + + *stride = xm_stride; + return (struct sw_displaytarget *)xm_dt; + +no_data: + FREE(xm_dt); +no_xm_dt: + return NULL; +} + +/* pipe_screen::texture_destroy */ +static void +xm_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + + if (xm_dt->data) { + FREE(xm_dt->data); + } + + FREE(xm_dt); +} + +/* pipe_context::transfer_map */ +static void * +xm_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = xm_dt->data; + return xm_dt->mapped; +} + +/* pipe_context::transfer_unmap */ +static void +xm_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = NULL; +} + +/* pipe_screen::texture_from_handle */ +static struct sw_displaytarget * +xm_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templ, + struct winsys_handle *whandle, + unsigned *stride) +{ + assert(0); + return NULL; +} + +/* pipe_screen::texture_get_handle */ +static boolean +xm_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + assert(0); + return FALSE; +} + +/* pipe_screen::flush_frontbuffer */ +static void +xm_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) +{ + assert(0); +} + + +static void +dri_destroy_sw_winsys(struct sw_winsys *winsys) +{ + FREE(winsys); +} + +struct sw_winsys * +dri_create_sw_winsys(void) +{ + struct sw_winsys *ws; + + ws = CALLOC_STRUCT(sw_winsys); + if (!ws) + return NULL; + + ws->destroy = dri_destroy_sw_winsys; + + ws->is_displaytarget_format_supported = xm_is_displaytarget_format_supported; + + /* screen texture functions */ + ws->displaytarget_create = xm_displaytarget_create; + ws->displaytarget_destroy = xm_displaytarget_destroy; + ws->displaytarget_from_handle = xm_displaytarget_from_handle; + ws->displaytarget_get_handle = xm_displaytarget_get_handle; + + /* texture functions */ + ws->displaytarget_map = xm_displaytarget_map; + ws->displaytarget_unmap = xm_displaytarget_unmap; + + ws->displaytarget_display = xm_displaytarget_display; + + return ws; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.h b/src/gallium/winsys/sw/dri/dri_sw_winsys.h new file mode 100644 index 00000000000..c2382a68d78 --- /dev/null +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.h @@ -0,0 +1,36 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#ifndef DRI_SW_WINSYS +#define DRI_SW_WINSYS + +struct sw_winsys; + +struct sw_winsys *dri_create_sw_winsys(void); + +#endif From bb289a8a7019cc0b40121e91fe5cd404a76b1fb5 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:54 +0200 Subject: [PATCH 359/483] swrastg_dri: hack for loader hardcoded stride --- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index abf92b86b04..5549e152ee8 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -62,6 +62,14 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, return TRUE; } +static INLINE int +bytes_per_line(unsigned stride, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((stride * 8 + mask) & ~mask) / 8; +} + /* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ static struct sw_displaytarget * xm_displaytarget_create(struct sw_winsys *winsys, @@ -72,21 +80,35 @@ xm_displaytarget_create(struct sw_winsys *winsys, unsigned *stride) { struct xm_displaytarget *xm_dt; - unsigned nblocksy, size, xm_stride; + unsigned nblocksy, size, xm_stride, loader_stride, format_stride; xm_dt = CALLOC_STRUCT(xm_displaytarget); if(!xm_dt) goto no_xm_dt; + format_stride = util_format_get_stride(format, width); + xm_stride = align(format_stride, alignment); + loader_stride = bytes_per_line(format_stride, 32); + nblocksy = util_format_get_nblocksy(format, height); - xm_stride = align(util_format_get_stride(format, width), alignment); size = xm_stride * nblocksy; +#ifdef DEBUG + debug_printf("swrast format stride: %8d\n", format_stride); + debug_printf("swrast pipe stride : %8d\n", xm_stride); + debug_printf("swrast loader stride: %8d\n", loader_stride); +#endif + + /* + * Allocate with the aligned stride required by the pipe but set the stride + * to the one hardcoded in the loaders XXX + */ + xm_dt->data = align_malloc(size, alignment); if(!xm_dt->data) goto no_data; - *stride = xm_stride; + *stride = loader_stride; return (struct sw_displaytarget *)xm_dt; no_data: From 1570e30b487018f056af4d0b5ca83a889f9ce721 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:54 +0200 Subject: [PATCH 360/483] st/dri: add TODO list for DRISW --- src/gallium/state_trackers/dri/drisw.c | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c index b3d65df8815..73bc45d9060 100644 --- a/src/gallium/state_trackers/dri/drisw.c +++ b/src/gallium/state_trackers/dri/drisw.c @@ -26,6 +26,36 @@ * **************************************************************************/ +/* TODO: + * + * stride: + * + * The driver and the loaders (libGL, xserver/glx) compute the stride from the + * width independently. winsys has a workaround that works for softpipe but may + * explode for other drivers or platforms, rendering- or performance-wise. + * Solving this issue properly requires extending the DRISW loader extension, + * in order to make the stride available to the putImage callback. + * + * drisw_api: + * + * Define drisw_api similarly to dri_api and use it to call the loader. This is + * predicated on support for calling the loader from the winsys, which has to + * grow for DRI2 as well. + * + * xshm: + * + * Allow the loaders to use the XSHM extension. It probably requires callbacks + * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth + * it, given the scope of DRISW, unless it falls naturally from properly + * solving the above two issues. + * + * swrast_create_screen: + * + * Allow for any software renderer to be used. Factor out the code from + * targets/libgl-xlib/xlib.c, put it in targets/common or winsys/sw/common and + * use it in all software targets. + */ + #include "util/u_memory.h" #include "util/u_inlines.h" #include "pipe/p_context.h" From 7b333298fc4efd1a8e44aaebaae77bf88c28ce19 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Mar 2010 17:01:54 +0200 Subject: [PATCH 361/483] configure:ac add swrastg_dri --- configure.ac | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 1b9500b8b5a..4e0ce268492 100644 --- a/configure.ac +++ b/configure.ac @@ -474,7 +474,7 @@ xlib) dri) SRC_DIRS="$SRC_DIRS glx" DRIVER_DIRS="dri" - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/drm" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri sw/drm" ;; osmesa) DRIVER_DIRS="osmesa" @@ -1409,12 +1409,10 @@ AC_ARG_ENABLE([gallium-swrast], [build gallium swrast @<:@default=auto@:>@])], [enable_gallium_swrast="$enableval"], [enable_gallium_swrast=auto]) -if test "x$enable_gallium_swrast" = xyes; then - if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([EGL needs to be enabled for egl-swrast target]) +if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then + if test "x$mesa_driver" = xdri; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast" fi - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast" -elif test "x$enable_gallium_swrast" = xauto; then if test "x$enable_egl" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast" fi From 8f47f5320f1a8d4750152f7783cf72073d0979bd Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 17:54:41 +0100 Subject: [PATCH 362/483] st/dri: Add dri2 prefix for all dri2.c functions --- src/gallium/state_trackers/dri/dri2.c | 34 ++++++++++----------- src/gallium/state_trackers/dri/dri2.h | 10 +++--- src/gallium/state_trackers/dri/dri_screen.c | 2 +- src/gallium/state_trackers/dri/dri_st_api.c | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 2c6a0621ae7..108b18e9d3c 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -107,8 +107,8 @@ static const __DRItexBufferExtension dri2TexBufferExtension = { * Get the format of an attachment. */ static INLINE enum pipe_format -dri_drawable_get_format(struct dri_drawable *drawable, - enum st_attachment_type statt) +dri2_drawable_get_format(struct dri_drawable *drawable, + enum st_attachment_type statt) { enum pipe_format format; @@ -134,9 +134,9 @@ dri_drawable_get_format(struct dri_drawable *drawable, * Retrieve __DRIbuffer from the DRI loader. */ static __DRIbuffer * -dri_drawable_get_buffers(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned *count) +dri2_drawable_get_buffers(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned *count) { __DRIdrawable *dri_drawable = drawable->dPriv; struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; @@ -159,7 +159,7 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, enum pipe_format format; int att, bpp; - format = dri_drawable_get_format(drawable, statts[i]); + format = dri2_drawable_get_format(drawable, statts[i]); if (format == PIPE_FORMAT_NONE) continue; @@ -238,8 +238,8 @@ dri_drawable_get_buffers(struct dri_drawable *drawable, * Process __DRIbuffer and convert them into pipe_textures. */ static void -dri_drawable_process_buffers(struct dri_drawable *drawable, - __DRIbuffer *buffers, unsigned count) +dri2_drawable_process_buffers(struct dri_drawable *drawable, + __DRIbuffer *buffers, unsigned count) { struct dri_screen *screen = dri_screen(drawable->sPriv); __DRIdrawable *dri_drawable = drawable->dPriv; @@ -302,7 +302,7 @@ dri_drawable_process_buffers(struct dri_drawable *drawable, break; } - format = dri_drawable_get_format(drawable, statt); + format = dri2_drawable_get_format(drawable, statt); if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE) continue; @@ -326,20 +326,20 @@ dri_drawable_process_buffers(struct dri_drawable *drawable, */ void -dri_allocate_textures(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned count) +dri2_allocate_textures(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count) { __DRIbuffer *buffers; unsigned num_buffers = count; - buffers = dri_drawable_get_buffers(drawable, statts, &num_buffers); - dri_drawable_process_buffers(drawable, buffers, num_buffers); + buffers = dri2_drawable_get_buffers(drawable, statts, &num_buffers); + dri2_drawable_process_buffers(drawable, buffers, num_buffers); } void -dri_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt) +dri2_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) { __DRIdrawable *dri_drawable = drawable->dPriv; struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; @@ -373,7 +373,7 @@ static const __DRIextension *dri_screen_extensions[] = { * Returns the __GLcontextModes supported by this driver. */ const __DRIconfig ** -dri_init_screen2(__DRIscreen * sPriv) +dri2_init_screen(__DRIscreen * sPriv) { struct dri_screen *screen; struct drm_create_screen_arg arg; diff --git a/src/gallium/state_trackers/dri/dri2.h b/src/gallium/state_trackers/dri/dri2.h index e1afcf8ca8d..379963431fb 100644 --- a/src/gallium/state_trackers/dri/dri2.h +++ b/src/gallium/state_trackers/dri/dri2.h @@ -32,15 +32,15 @@ #include "dri_wrapper.h" const __DRIconfig ** -dri_init_screen2(__DRIscreen * sPriv); +dri2_init_screen(__DRIscreen * sPriv); void -dri_flush_frontbuffer(struct dri_drawable *drawable, +dri2_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt); void -dri_allocate_textures(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned count); +dri2_allocate_textures(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count); #endif /* DRI2_H */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index ae311641042..3029d337878 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -328,7 +328,7 @@ const struct __DriverAPIRec driDriverAPI = { .GetSwapInfo = dri_get_swap_info, .GetDrawableMSC = driDrawableGetMSC32, .WaitForMSC = driWaitForMSC32, - .InitScreen2 = dri_init_screen2, + .InitScreen2 = dri2_init_screen, .InitScreen = dri1_init_screen, .SwapBuffers = dri1_swap_buffers, diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 2b98c487c84..31d2c582aa0 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -73,7 +73,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, dri1_allocate_textures(drawable, statt_mask); } else { - dri_allocate_textures(drawable, statts, count); + dri2_allocate_textures(drawable, statts, count); } #else if (new_stamp) @@ -115,7 +115,7 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, dri1_flush_frontbuffer(drawable, statt); } else { - dri_flush_frontbuffer(drawable, statt); + dri2_flush_frontbuffer(drawable, statt); } #else drisw_flush_frontbuffer(drawable, statt); From 9eaadfeaa54d15fc3eb90d4137795ace4f920b2f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 18:28:31 +0100 Subject: [PATCH 363/483] st/dri: Don't include sw vs drm dri headers --- src/gallium/state_trackers/dri/dri_screen.c | 3 +++ src/gallium/state_trackers/dri/dri_st_api.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 3029d337878..598a07bb646 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -40,9 +40,12 @@ #include "dri_drawable.h" #include "dri_st_api.h" #include "dri1_helper.h" +#ifndef __NOT_HAVE_DRM_H #include "dri1.h" #include "dri2.h" +#else #include "drisw.h" +#endif #include "util/u_inlines.h" #include "pipe/p_screen.h" diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/dri_st_api.c index 31d2c582aa0..40b24b18e9f 100644 --- a/src/gallium/state_trackers/dri/dri_st_api.c +++ b/src/gallium/state_trackers/dri/dri_st_api.c @@ -36,9 +36,12 @@ #include "dri_drawable.h" #include "dri_st_api.h" #include "dri1_helper.h" +#ifndef __NOT_HAVE_DRM_H #include "dri1.h" #include "dri2.h" +#else #include "drisw.h" +#endif static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, From 80f5f7d17afac7b4cbaaad27a43dbf902ca3826e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Mar 2010 12:58:36 -0700 Subject: [PATCH 364/483] glslcompiler: Fix build. --- src/mesa/drivers/glslcompiler/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index d3404988d52..7dcf9a6541a 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -9,13 +9,9 @@ PROGRAM = glslcompiler OBJECTS = \ glslcompiler.o \ - ../../glapi/glapi.o \ - ../../glapi/glapi_getproc.o \ - ../../glapi/glapi_dispatch.o \ - ../../glapi/glapi_nop.o \ - ../../glapi/glthread.o \ ../common/driverfuncs.o \ - ../../libmesa.a + ../../libmesa.a \ + ../../libglapi.a INCLUDES = \ -I$(TOP)/include \ From a82e37b9e9e34175b7542d0c9b4e462833eab202 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 22:21:39 +0100 Subject: [PATCH 365/483] gallium: Add propper sanity checks in configure.ac --- configure.ac | 93 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/configure.ac b/configure.ac index 4e0ce268492..d6d952d7a58 100644 --- a/configure.ac +++ b/configure.ac @@ -1205,13 +1205,16 @@ yes) ;; dri) GALLIUM_STATE_TRACKERS_DIRS="dri drisw" + HAVE_ST_DRI="yes" + HAVE_ST_DRISW="yes" if test "x$enable_egl" = xyes; then GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" + HAVE_ST_EGL="yes" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED], - HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg", - HAVE_XORG="no") + HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg", + HAVE_ST_XORG="no") ;; esac ;; @@ -1223,15 +1226,28 @@ yes) AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) case "$tracker" in + dri) + if test "x$mesa_driver" != xdri; then + AC_MSG_ERROR([cannot build dri state tracker without mesa driver set to dri]) + fi + HAVE_ST_DRI="yes" + ;; + drisw) + if test "x$mesa_driver" != xdri; then + AC_MSG_ERROR([cannot build drisw state tracker without mesa driver set to dri]) + fi + HAVE_ST_DRISW="yes" + ;; egl) if test "x$enable_egl" != xyes; then AC_MSG_ERROR([cannot build egl state tracker without EGL library]) fi + HAVE_ST_EGL="yes" ;; xorg) PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED]) PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED]) - HAVE_XORG="yes" + HAVE_ST_XORG="yes" ;; es) # mesa/es is required to build es state tracker @@ -1243,7 +1259,7 @@ yes) ;; esac -if test "x$HAVE_XORG" = xyes; then +if test "x$HAVE_ST_XORG" = xyes; then PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", HAVE_XEXTPROTO_71="no") @@ -1307,6 +1323,25 @@ AC_ARG_WITH([max-height], [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])] ) +dnl +dnl Gallium helper functions +dnl +gallium_check_st() { + if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes; then + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1" + fi + if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2" + fi + if test "x$HAVE_ST_EGL" = xyes && test "x$3" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3" + fi + if test "x$HAVE_ST_XORG" = xyes && test "x$4" != x; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4" + fi +} + + dnl dnl Gallium SVGA configuration dnl @@ -1316,17 +1351,8 @@ AC_ARG_ENABLE([gallium-svga], [enable_gallium_svga="$enableval"], [enable_gallium_svga=auto]) if test "x$enable_gallium_svga" = xyes; then - if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS svga/drm" - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-vmwgfx" - fi - if test "x$enable_egl" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-vmwgfx" - fi - if test "x$HAVE_XORG" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-vmwgfx" - fi - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga/drm" + gallium_check_st "svga/drm" "dri-vmwgfx" "egl-vmwgfx" "xorg-vmwgfx" elif test "x$enable_gallium_svga" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" fi @@ -1340,17 +1366,8 @@ AC_ARG_ENABLE([gallium-intel], [enable_gallium_intel="$enableval"], [enable_gallium_intel=auto]) if test "x$enable_gallium_intel" = xyes; then - if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/drm i965/drm" - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-i915 dri-i965" - fi - if test "x$enable_egl" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-i915 egl-i965" - fi - if test "x$HAVE_XORG" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-i915 xorg-i965" - fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" + gallium_check_st "i915/drm i965/drm" "dri-i915 dri-i965" "egl-i915 egl-i965" "xorg-i915 xorg-i965" elif test "x$enable_gallium_intel" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965" fi @@ -1364,17 +1381,8 @@ AC_ARG_ENABLE([gallium-radeon], [enable_gallium_radeon="$enableval"], [enable_gallium_radeon=auto]) if test "x$enable_gallium_radeon" = xyes; then - if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS radeon/drm" - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-radeong" - fi - if test "x$enable_egl" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-radeon" - fi - if test "x$HAVE_XORG" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-radeon" - fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" + gallium_check_st "radeon/drm" "dri-radeong" "egl-radeon" "xorg-radeon" elif test "x$enable_gallium_radeon" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300" fi @@ -1388,17 +1396,8 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau="$enableval"], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then - if test "x$mesa_driver" = xdri; then - GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS nouveau/drm" - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-nouveau" - fi - if test "x$enable_egl" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-nouveau" - fi - if test "x$HAVE_XORG" = xyes; then - GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xorg-nouveau" - fi GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" + gallium_check_st "nouveau/drm" "dri-nouveau" "egl-nouveau" "xorg-nouveau" fi dnl @@ -1410,10 +1409,10 @@ AC_ARG_ENABLE([gallium-swrast], [enable_gallium_swrast="$enableval"], [enable_gallium_swrast=auto]) if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then - if test "x$mesa_driver" = xdri; then + if test "x$HAVE_ST_DRISW" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast" fi - if test "x$enable_egl" = xyes; then + if test "x$HAVE_ST_EGL" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast" fi fi From 59258498dc6fa51573b176d071644bd3e750b5ac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Mar 2010 16:03:13 -0600 Subject: [PATCH 366/483] glapi: return int = 0 from NoOpGeneric() If a GL function is called w/out a current rendering context, this stub gets called. It should return 0 so that non-void-valued functions return 0/NULL instead of a random number. --- src/mesa/glapi/glapi_nop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c index b1a718a5f0a..df9c5872842 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mesa/glapi/glapi_nop.c @@ -93,7 +93,7 @@ NoOpUnused(void) #else -static void +static int NoOpGeneric(void) { #if !defined(_WIN32_WCE) @@ -101,6 +101,7 @@ NoOpGeneric(void) fprintf(stderr, "GL User Error: calling GL function without a rendering context\n"); } #endif + return 0; } #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric From 67e377bda6431b613836fdc04680a49b75e4b751 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Mar 2010 16:04:40 -0600 Subject: [PATCH 367/483] llvmpipe: disable an assertion We shouldn't try to clear a non-existant z/stencil buffer, so there's probably a bug elsewhere. Disable the assertion for now to allow things to at least run. --- src/gallium/drivers/llvmpipe/lp_rast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index cd9919ca909..8352f175598 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -189,7 +189,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, LP_DBG(DEBUG_RAST, "%s 0x%x\n", __FUNCTION__, arg.clear_zstencil); - assert(rast->zsbuf.map); + /*assert(rast->zsbuf.map);*/ if (!rast->zsbuf.map) return; From 8814bb652aa0deee7fa34c0746ba9dc63163b88d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Mar 2010 16:06:07 -0600 Subject: [PATCH 368/483] Revert "llvmpipe: optimize the lp_setup_fence() function" This reverts commit a9063cad0f0190ff88cd20fbad5aa87bf1a943f6. Not too surprisingly, this change caused some regressions. Revert it for the time being. See fd.o bug 27320. --- src/gallium/drivers/llvmpipe/lp_setup.c | 26 ++++++------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 4eeb98621f6..76a8b87a309 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -318,30 +318,16 @@ lp_setup_fence( struct lp_setup_context *setup ) { struct lp_scene *scene = lp_setup_get_current_scene(setup); const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */ - struct lp_fence *fence; + struct lp_fence *fence = lp_fence_create(rank); LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank); - if (setup->state == SETUP_FLUSHED) { - /* We're in a flushed state so there's nothing in the bins. - * No need to wait on a fence. - */ - fence = NULL; - } - else { - /* There's material in the bins. Emit the fence into the bins. - * When the rasterizer(s) find the fence, they'll signal on it. - */ - fence = lp_fence_create(rank); + set_scene_state( setup, SETUP_ACTIVE ); - set_scene_state( setup, SETUP_ACTIVE ); - - /* insert the fence into all command bins */ - lp_scene_bin_everywhere( scene, - lp_rast_fence, - lp_rast_arg_fence(fence) ); - - } + /* insert the fence into all command bins */ + lp_scene_bin_everywhere( scene, + lp_rast_fence, + lp_rast_arg_fence(fence) ); return (struct pipe_fence_handle *) fence; } From 38cb44516e9c1e9154fa8297ea53efc803378c12 Mon Sep 17 00:00:00 2001 From: Tom Fogal Date: Thu, 25 Mar 2010 16:48:59 -0600 Subject: [PATCH 369/483] Regenerate gl_mangle.h --- include/GL/gl_mangle.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/GL/gl_mangle.h b/include/GL/gl_mangle.h index b292840f917..43d2e896b0b 100644 --- a/include/GL/gl_mangle.h +++ b/include/GL/gl_mangle.h @@ -393,6 +393,8 @@ #define glEdgeFlagPointerListIBM MANGLE(EdgeFlagPointerListIBM) #define glEdgeFlagPointer MANGLE(EdgeFlagPointer) #define glEdgeFlagv MANGLE(EdgeFlagv) +#define glEGLImageTargetRenderbufferStorageOES MANGLE(EGLImageTargetRenderbufferStorageOES) +#define glEGLImageTargetTexture2DOES MANGLE(EGLImageTargetTexture2DOES) #define glElementPointerAPPLE MANGLE(ElementPointerAPPLE) #define glElementPointerATI MANGLE(ElementPointerATI) #define glEnableClientStateIndexedEXT MANGLE(EnableClientStateIndexedEXT) From 5b1fc14627ae37c5def70e2d5fe28bf7a4becee6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 18:29:51 +0100 Subject: [PATCH 370/483] st/dri: Reshuffle files and make it obvious which files are shared In short: git mv ../drisw/Makefile dri/sw git mv drisw.[c|h] sw git mv dri2.[c|h] dri1.[c|h] Makefile drm git rm ../drisw ln -s drm/* ln -s sw/* --- configure.ac | 11 ++---- src/gallium/state_trackers/dri/Makefile | 36 +++++-------------- src/gallium/state_trackers/dri/SConscript | 28 ++------------- src/gallium/state_trackers/dri/drm/Makefile | 33 +++++++++++++++++ src/gallium/state_trackers/dri/drm/SConscript | 28 +++++++++++++++ .../state_trackers/dri/{ => drm}/dri1.c | 0 .../state_trackers/dri/{ => drm}/dri1.h | 0 .../state_trackers/dri/drm/dri1_helper.c | 1 + .../state_trackers/dri/{ => drm}/dri2.c | 0 .../state_trackers/dri/{ => drm}/dri2.h | 0 .../state_trackers/dri/drm/dri_context.c | 1 + .../state_trackers/dri/drm/dri_drawable.c | 1 + .../state_trackers/dri/drm/dri_extensions.c | 1 + .../state_trackers/dri/drm/dri_screen.c | 1 + .../state_trackers/dri/drm/dri_st_api.c | 1 + .../state_trackers/{drisw => dri/sw}/Makefile | 5 +-- .../state_trackers/dri/sw/dri1_helper.c | 1 + .../state_trackers/dri/sw/dri_context.c | 1 + .../state_trackers/dri/sw/dri_drawable.c | 1 + .../state_trackers/dri/sw/dri_extensions.c | 1 + .../state_trackers/dri/sw/dri_screen.c | 1 + .../state_trackers/dri/sw/dri_st_api.c | 1 + .../state_trackers/dri/{ => sw}/drisw.c | 0 .../state_trackers/dri/{ => sw}/drisw.h | 0 .../state_trackers/drisw/dri1_helper.c | 1 - .../state_trackers/drisw/dri_context.c | 1 - .../state_trackers/drisw/dri_drawable.c | 1 - .../state_trackers/drisw/dri_extensions.c | 1 - src/gallium/state_trackers/drisw/dri_screen.c | 1 - src/gallium/state_trackers/drisw/dri_st_api.c | 1 - src/gallium/state_trackers/drisw/drisw.c | 1 - src/gallium/targets/dri-i915/Makefile | 2 +- src/gallium/targets/dri-i965/Makefile | 2 +- src/gallium/targets/dri-nouveau/Makefile | 2 +- src/gallium/targets/dri-radeong/Makefile | 2 +- src/gallium/targets/dri-swrast/Makefile | 2 +- src/gallium/targets/dri-vmwgfx/Makefile | 2 +- 37 files changed, 95 insertions(+), 77 deletions(-) create mode 100644 src/gallium/state_trackers/dri/drm/Makefile create mode 100644 src/gallium/state_trackers/dri/drm/SConscript rename src/gallium/state_trackers/dri/{ => drm}/dri1.c (100%) rename src/gallium/state_trackers/dri/{ => drm}/dri1.h (100%) create mode 120000 src/gallium/state_trackers/dri/drm/dri1_helper.c rename src/gallium/state_trackers/dri/{ => drm}/dri2.c (100%) rename src/gallium/state_trackers/dri/{ => drm}/dri2.h (100%) create mode 120000 src/gallium/state_trackers/dri/drm/dri_context.c create mode 120000 src/gallium/state_trackers/dri/drm/dri_drawable.c create mode 120000 src/gallium/state_trackers/dri/drm/dri_extensions.c create mode 120000 src/gallium/state_trackers/dri/drm/dri_screen.c create mode 120000 src/gallium/state_trackers/dri/drm/dri_st_api.c rename src/gallium/state_trackers/{drisw => dri/sw}/Makefile (79%) create mode 120000 src/gallium/state_trackers/dri/sw/dri1_helper.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_context.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_drawable.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_extensions.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_screen.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_st_api.c rename src/gallium/state_trackers/dri/{ => sw}/drisw.c (100%) rename src/gallium/state_trackers/dri/{ => sw}/drisw.h (100%) delete mode 120000 src/gallium/state_trackers/drisw/dri1_helper.c delete mode 120000 src/gallium/state_trackers/drisw/dri_context.c delete mode 120000 src/gallium/state_trackers/drisw/dri_drawable.c delete mode 120000 src/gallium/state_trackers/drisw/dri_extensions.c delete mode 120000 src/gallium/state_trackers/drisw/dri_screen.c delete mode 120000 src/gallium/state_trackers/drisw/dri_st_api.c delete mode 120000 src/gallium/state_trackers/drisw/drisw.c diff --git a/configure.ac b/configure.ac index d6d952d7a58..caa2cf65766 100644 --- a/configure.ac +++ b/configure.ac @@ -1204,9 +1204,8 @@ yes) GALLIUM_STATE_TRACKERS_DIRS=glx ;; dri) - GALLIUM_STATE_TRACKERS_DIRS="dri drisw" + GALLIUM_STATE_TRACKERS_DIRS="dri" HAVE_ST_DRI="yes" - HAVE_ST_DRISW="yes" if test "x$enable_egl" = xyes; then GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" HAVE_ST_EGL="yes" @@ -1232,12 +1231,6 @@ yes) fi HAVE_ST_DRI="yes" ;; - drisw) - if test "x$mesa_driver" != xdri; then - AC_MSG_ERROR([cannot build drisw state tracker without mesa driver set to dri]) - fi - HAVE_ST_DRISW="yes" - ;; egl) if test "x$enable_egl" != xyes; then AC_MSG_ERROR([cannot build egl state tracker without EGL library]) @@ -1409,7 +1402,7 @@ AC_ARG_ENABLE([gallium-swrast], [enable_gallium_swrast="$enableval"], [enable_gallium_swrast=auto]) if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then - if test "x$HAVE_ST_DRISW" = xyes; then + if test "x$HAVE_ST_DRI" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast" fi if test "x$HAVE_ST_EGL" = xyes; then diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index f1a54e80b61..72e70577b3d 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -1,32 +1,12 @@ +# src/gallium/state_trackers/dri/Makefile TOP = ../../../.. include $(TOP)/configs/current -LIBNAME = dridrm +SUBDIRS = drm sw -LIBRARY_INCLUDES = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa/main \ - $(shell pkg-config --cflags-only-I libdrm) - - -C_SOURCES = \ - dri_context.c \ - dri_screen.c \ - dri_drawable.c \ - dri_extensions.c \ - dri_st_api.c \ - dri1_helper.c \ - dri1.c \ - dri2.c - -# $(TOP)/src/mesa/drivers/dri/common/utils.c \ - $(TOP)/src/mesa/drivers/dri/common/vblank.c \ - $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ - $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ - $(TOP)/src/mesa/drivers/common/driverfuncs.c \ - $(TOP)/src/mesa/drivers/dri/common/texmem.c \ - $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c - -include ../../Makefile.template +default install clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) $@) || exit 1; \ + fi \ + done diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index 2ca9f420683..b4a276cf29d 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -1,27 +1,5 @@ -####################################################################### -# SConscript for dri state_tracker - Import('*') -if env['dri']: - - env = env.Clone() - - env.Append(CPPPATH = [ - '#/src/mesa', - '#/src/mesa/drivers/dri/common', - ]) - - st_dri = env.ConvenienceLibrary( - target = 'st_dri', - source = [ 'dri_context.c', - 'dri_drawable.c', - 'dri_extensions.c', - 'dri_screen.c', - 'dri_st_api.c', - 'dri1_helper.c', - 'dri1.c', - 'dri2.c', - ] - ) - Export('st_dri') +SConscript([ + 'drm/SConscript', +]) diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile new file mode 100644 index 00000000000..c43bfee8b8f --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -0,0 +1,33 @@ +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = dridrm + +LIBRARY_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/state_trackers/dri \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa/main \ + $(shell pkg-config --cflags-only-I libdrm) + + +C_SOURCES = \ + dri_context.c \ + dri_screen.c \ + dri_drawable.c \ + dri_extensions.c \ + dri_st_api.c \ + dri1_helper.c \ + dri1.c \ + dri2.c + +# $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/vblank.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ + $(TOP)/src/mesa/drivers/common/driverfuncs.c \ + $(TOP)/src/mesa/drivers/dri/common/texmem.c \ + $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c + +include ../../../Makefile.template diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript new file mode 100644 index 00000000000..a9c359c2e89 --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -0,0 +1,28 @@ +####################################################################### +# SConscript for dri state_tracker + +Import('*') + +if env['dri']: + + env = env.Clone() + + env.Append(CPPPATH = [ + '#/src/mesa', + '#/src/gallium/state_trackers/dri', + '#/src/mesa/drivers/dri/common', + ]) + + st_dri = env.ConvenienceLibrary( + target = 'st_dri', + source = [ 'dri_context.c', + 'dri_drawable.c', + 'dri_extensions.c', + 'dri_screen.c', + 'dri_st_api.c', + 'dri1_helper.c', + 'dri1.c', + 'dri2.c', + ] + ) + Export('st_dri') diff --git a/src/gallium/state_trackers/dri/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c similarity index 100% rename from src/gallium/state_trackers/dri/dri1.c rename to src/gallium/state_trackers/dri/drm/dri1.c diff --git a/src/gallium/state_trackers/dri/dri1.h b/src/gallium/state_trackers/dri/drm/dri1.h similarity index 100% rename from src/gallium/state_trackers/dri/dri1.h rename to src/gallium/state_trackers/dri/drm/dri1.h diff --git a/src/gallium/state_trackers/dri/drm/dri1_helper.c b/src/gallium/state_trackers/dri/drm/dri1_helper.c new file mode 120000 index 00000000000..7006a8d882f --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri1_helper.c @@ -0,0 +1 @@ +../dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c similarity index 100% rename from src/gallium/state_trackers/dri/dri2.c rename to src/gallium/state_trackers/dri/drm/dri2.c diff --git a/src/gallium/state_trackers/dri/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h similarity index 100% rename from src/gallium/state_trackers/dri/dri2.h rename to src/gallium/state_trackers/dri/drm/dri2.h diff --git a/src/gallium/state_trackers/dri/drm/dri_context.c b/src/gallium/state_trackers/dri/drm/dri_context.c new file mode 120000 index 00000000000..989ef4438a1 --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_context.c @@ -0,0 +1 @@ +../dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_drawable.c b/src/gallium/state_trackers/dri/drm/dri_drawable.c new file mode 120000 index 00000000000..422c4c1d740 --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_drawable.c @@ -0,0 +1 @@ +../dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_extensions.c b/src/gallium/state_trackers/dri/drm/dri_extensions.c new file mode 120000 index 00000000000..b793f06747d --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_extensions.c @@ -0,0 +1 @@ +../dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_screen.c b/src/gallium/state_trackers/dri/drm/dri_screen.c new file mode 120000 index 00000000000..938f4c3bdc7 --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_screen.c @@ -0,0 +1 @@ +../dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c new file mode 120000 index 00000000000..9ae88230ddc --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_st_api.c @@ -0,0 +1 @@ +../dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile similarity index 79% rename from src/gallium/state_trackers/drisw/Makefile rename to src/gallium/state_trackers/dri/sw/Makefile index dec9a39edec..35e31e6466a 100644 --- a/src/gallium/state_trackers/drisw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -1,4 +1,4 @@ -TOP = ../../../.. +TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = drisw @@ -9,6 +9,7 @@ LIBRARY_INCLUDES = \ -I../dri \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/state_trackers/dri \ -I$(TOP)/src/mesa/drivers/dri/common \ -I$(TOP)/src/mesa/main \ -D__NOT_HAVE_DRM_H @@ -23,4 +24,4 @@ C_SOURCES = \ dri1_helper.c \ drisw.c -include ../../Makefile.template +include ../../../Makefile.template diff --git a/src/gallium/state_trackers/dri/sw/dri1_helper.c b/src/gallium/state_trackers/dri/sw/dri1_helper.c new file mode 120000 index 00000000000..7006a8d882f --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri1_helper.c @@ -0,0 +1 @@ +../dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_context.c b/src/gallium/state_trackers/dri/sw/dri_context.c new file mode 120000 index 00000000000..989ef4438a1 --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_context.c @@ -0,0 +1 @@ +../dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c new file mode 120000 index 00000000000..422c4c1d740 --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_drawable.c @@ -0,0 +1 @@ +../dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_extensions.c b/src/gallium/state_trackers/dri/sw/dri_extensions.c new file mode 120000 index 00000000000..b793f06747d --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_extensions.c @@ -0,0 +1 @@ +../dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_screen.c b/src/gallium/state_trackers/dri/sw/dri_screen.c new file mode 120000 index 00000000000..938f4c3bdc7 --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_screen.c @@ -0,0 +1 @@ +../dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_st_api.c b/src/gallium/state_trackers/dri/sw/dri_st_api.c new file mode 120000 index 00000000000..9ae88230ddc --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_st_api.c @@ -0,0 +1 @@ +../dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c similarity index 100% rename from src/gallium/state_trackers/dri/drisw.c rename to src/gallium/state_trackers/dri/sw/drisw.c diff --git a/src/gallium/state_trackers/dri/drisw.h b/src/gallium/state_trackers/dri/sw/drisw.h similarity index 100% rename from src/gallium/state_trackers/dri/drisw.h rename to src/gallium/state_trackers/dri/sw/drisw.h diff --git a/src/gallium/state_trackers/drisw/dri1_helper.c b/src/gallium/state_trackers/drisw/dri1_helper.c deleted file mode 120000 index e704e382e05..00000000000 --- a/src/gallium/state_trackers/drisw/dri1_helper.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_context.c b/src/gallium/state_trackers/drisw/dri_context.c deleted file mode 120000 index e4e879dc867..00000000000 --- a/src/gallium/state_trackers/drisw/dri_context.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_drawable.c b/src/gallium/state_trackers/drisw/dri_drawable.c deleted file mode 120000 index d7f65c85d20..00000000000 --- a/src/gallium/state_trackers/drisw/dri_drawable.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_extensions.c b/src/gallium/state_trackers/drisw/dri_extensions.c deleted file mode 120000 index 60ecde9547d..00000000000 --- a/src/gallium/state_trackers/drisw/dri_extensions.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_screen.c b/src/gallium/state_trackers/drisw/dri_screen.c deleted file mode 120000 index f22c562c84f..00000000000 --- a/src/gallium/state_trackers/drisw/dri_screen.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/dri_st_api.c b/src/gallium/state_trackers/drisw/dri_st_api.c deleted file mode 120000 index eac8ec66905..00000000000 --- a/src/gallium/state_trackers/drisw/dri_st_api.c +++ /dev/null @@ -1 +0,0 @@ -../dri/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/drisw/drisw.c b/src/gallium/state_trackers/drisw/drisw.c deleted file mode 120000 index 258a79021ef..00000000000 --- a/src/gallium/state_trackers/drisw/drisw.c +++ /dev/null @@ -1 +0,0 @@ -../dri/drisw.c \ No newline at end of file diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile index facbcb1803a..822d4b57bbb 100644 --- a/src/gallium/targets/dri-i915/Makefile +++ b/src/gallium/targets/dri-i915/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/targets/dri-i965/Makefile b/src/gallium/targets/dri-i965/Makefile index c622bbcaf65..e267ba3a023 100644 --- a/src/gallium/targets/dri-i965/Makefile +++ b/src/gallium/targets/dri-i965/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i965_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \ diff --git a/src/gallium/targets/dri-nouveau/Makefile b/src/gallium/targets/dri-nouveau/Makefile index 9ba5e18ba70..74d352c6a70 100644 --- a/src/gallium/targets/dri-nouveau/Makefile +++ b/src/gallium/targets/dri-nouveau/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ diff --git a/src/gallium/targets/dri-radeong/Makefile b/src/gallium/targets/dri-radeong/Makefile index ce25559e946..66dd392b68b 100644 --- a/src/gallium/targets/dri-radeong/Makefile +++ b/src/gallium/targets/dri-radeong/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = radeong_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile index 57a9e02a4bb..3780da27550 100644 --- a/src/gallium/targets/dri-swrast/Makefile +++ b/src/gallium/targets/dri-swrast/Makefile @@ -6,7 +6,7 @@ LIBNAME = swrastg_dri.so DRIVER_DEFINES = -D__NOT_HAVE_DRM_H PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/drisw/libdrisw.a \ + $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \ $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile index 32edc46a3d9..4b002e828fa 100644 --- a/src/gallium/targets/dri-vmwgfx/Makefile +++ b/src/gallium/targets/dri-vmwgfx/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = vmwgfx_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a From 80672e84cf79ab12b7a4ff56567184d1c39baef3 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 18:51:52 +0100 Subject: [PATCH 371/483] st/dri: Move common files to common directory 27 files changed, 15 insertions(+), 15 deletions(-) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_extensions.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_wrapper.h (100%) --- src/gallium/state_trackers/dri/{ => common}/dri1_helper.c | 0 src/gallium/state_trackers/dri/{ => common}/dri1_helper.h | 0 src/gallium/state_trackers/dri/{ => common}/dri_context.c | 0 src/gallium/state_trackers/dri/{ => common}/dri_context.h | 0 src/gallium/state_trackers/dri/{ => common}/dri_drawable.c | 0 src/gallium/state_trackers/dri/{ => common}/dri_drawable.h | 0 src/gallium/state_trackers/dri/{ => common}/dri_extensions.c | 0 src/gallium/state_trackers/dri/{ => common}/dri_screen.c | 0 src/gallium/state_trackers/dri/{ => common}/dri_screen.h | 0 src/gallium/state_trackers/dri/{ => common}/dri_st_api.c | 0 src/gallium/state_trackers/dri/{ => common}/dri_st_api.h | 0 src/gallium/state_trackers/dri/{ => common}/dri_wrapper.h | 0 src/gallium/state_trackers/dri/drm/Makefile | 2 +- src/gallium/state_trackers/dri/drm/SConscript | 2 +- src/gallium/state_trackers/dri/drm/dri1_helper.c | 2 +- src/gallium/state_trackers/dri/drm/dri_context.c | 2 +- src/gallium/state_trackers/dri/drm/dri_drawable.c | 2 +- src/gallium/state_trackers/dri/drm/dri_extensions.c | 2 +- src/gallium/state_trackers/dri/drm/dri_screen.c | 2 +- src/gallium/state_trackers/dri/drm/dri_st_api.c | 2 +- src/gallium/state_trackers/dri/sw/Makefile | 2 +- src/gallium/state_trackers/dri/sw/dri1_helper.c | 2 +- src/gallium/state_trackers/dri/sw/dri_context.c | 2 +- src/gallium/state_trackers/dri/sw/dri_drawable.c | 2 +- src/gallium/state_trackers/dri/sw/dri_extensions.c | 2 +- src/gallium/state_trackers/dri/sw/dri_screen.c | 2 +- src/gallium/state_trackers/dri/sw/dri_st_api.c | 2 +- 27 files changed, 15 insertions(+), 15 deletions(-) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri1_helper.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_context.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_drawable.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_extensions.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_screen.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.c (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_st_api.h (100%) rename src/gallium/state_trackers/dri/{ => common}/dri_wrapper.h (100%) diff --git a/src/gallium/state_trackers/dri/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c similarity index 100% rename from src/gallium/state_trackers/dri/dri1_helper.c rename to src/gallium/state_trackers/dri/common/dri1_helper.c diff --git a/src/gallium/state_trackers/dri/dri1_helper.h b/src/gallium/state_trackers/dri/common/dri1_helper.h similarity index 100% rename from src/gallium/state_trackers/dri/dri1_helper.h rename to src/gallium/state_trackers/dri/common/dri1_helper.h diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c similarity index 100% rename from src/gallium/state_trackers/dri/dri_context.c rename to src/gallium/state_trackers/dri/common/dri_context.c diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h similarity index 100% rename from src/gallium/state_trackers/dri/dri_context.h rename to src/gallium/state_trackers/dri/common/dri_context.h diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c similarity index 100% rename from src/gallium/state_trackers/dri/dri_drawable.c rename to src/gallium/state_trackers/dri/common/dri_drawable.c diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h similarity index 100% rename from src/gallium/state_trackers/dri/dri_drawable.h rename to src/gallium/state_trackers/dri/common/dri_drawable.h diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/common/dri_extensions.c similarity index 100% rename from src/gallium/state_trackers/dri/dri_extensions.c rename to src/gallium/state_trackers/dri/common/dri_extensions.c diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c similarity index 100% rename from src/gallium/state_trackers/dri/dri_screen.c rename to src/gallium/state_trackers/dri/common/dri_screen.c diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h similarity index 100% rename from src/gallium/state_trackers/dri/dri_screen.h rename to src/gallium/state_trackers/dri/common/dri_screen.h diff --git a/src/gallium/state_trackers/dri/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c similarity index 100% rename from src/gallium/state_trackers/dri/dri_st_api.c rename to src/gallium/state_trackers/dri/common/dri_st_api.c diff --git a/src/gallium/state_trackers/dri/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h similarity index 100% rename from src/gallium/state_trackers/dri/dri_st_api.h rename to src/gallium/state_trackers/dri/common/dri_st_api.h diff --git a/src/gallium/state_trackers/dri/dri_wrapper.h b/src/gallium/state_trackers/dri/common/dri_wrapper.h similarity index 100% rename from src/gallium/state_trackers/dri/dri_wrapper.h rename to src/gallium/state_trackers/dri/common/dri_wrapper.h diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index c43bfee8b8f..19a755b86f1 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -6,7 +6,7 @@ LIBNAME = dridrm LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/gallium/state_trackers/dri \ + -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ -I$(TOP)/src/mesa/main \ $(shell pkg-config --cflags-only-I libdrm) diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index a9c359c2e89..b974e298f36 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -9,7 +9,7 @@ if env['dri']: env.Append(CPPPATH = [ '#/src/mesa', - '#/src/gallium/state_trackers/dri', + '#/src/gallium/state_trackers/dri/common', '#/src/mesa/drivers/dri/common', ]) diff --git a/src/gallium/state_trackers/dri/drm/dri1_helper.c b/src/gallium/state_trackers/dri/drm/dri1_helper.c index 7006a8d882f..c45ebf5c102 120000 --- a/src/gallium/state_trackers/dri/drm/dri1_helper.c +++ b/src/gallium/state_trackers/dri/drm/dri1_helper.c @@ -1 +1 @@ -../dri1_helper.c \ No newline at end of file +../common/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_context.c b/src/gallium/state_trackers/dri/drm/dri_context.c index 989ef4438a1..5cfbbaeb068 120000 --- a/src/gallium/state_trackers/dri/drm/dri_context.c +++ b/src/gallium/state_trackers/dri/drm/dri_context.c @@ -1 +1 @@ -../dri_context.c \ No newline at end of file +../common/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_drawable.c b/src/gallium/state_trackers/dri/drm/dri_drawable.c index 422c4c1d740..0fc19be6ea6 120000 --- a/src/gallium/state_trackers/dri/drm/dri_drawable.c +++ b/src/gallium/state_trackers/dri/drm/dri_drawable.c @@ -1 +1 @@ -../dri_drawable.c \ No newline at end of file +../common/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_extensions.c b/src/gallium/state_trackers/dri/drm/dri_extensions.c index b793f06747d..e0d06dcdfa5 120000 --- a/src/gallium/state_trackers/dri/drm/dri_extensions.c +++ b/src/gallium/state_trackers/dri/drm/dri_extensions.c @@ -1 +1 @@ -../dri_extensions.c \ No newline at end of file +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_screen.c b/src/gallium/state_trackers/dri/drm/dri_screen.c index 938f4c3bdc7..847f6515f25 120000 --- a/src/gallium/state_trackers/dri/drm/dri_screen.c +++ b/src/gallium/state_trackers/dri/drm/dri_screen.c @@ -1 +1 @@ -../dri_screen.c \ No newline at end of file +../common/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c index 9ae88230ddc..a8f6bd06b09 120000 --- a/src/gallium/state_trackers/dri/drm/dri_st_api.c +++ b/src/gallium/state_trackers/dri/drm/dri_st_api.c @@ -1 +1 @@ -../dri_st_api.c \ No newline at end of file +../common/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index 35e31e6466a..75e14fd26cb 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -9,7 +9,7 @@ LIBRARY_INCLUDES = \ -I../dri \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/gallium/state_trackers/dri \ + -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ -I$(TOP)/src/mesa/main \ -D__NOT_HAVE_DRM_H diff --git a/src/gallium/state_trackers/dri/sw/dri1_helper.c b/src/gallium/state_trackers/dri/sw/dri1_helper.c index 7006a8d882f..c45ebf5c102 120000 --- a/src/gallium/state_trackers/dri/sw/dri1_helper.c +++ b/src/gallium/state_trackers/dri/sw/dri1_helper.c @@ -1 +1 @@ -../dri1_helper.c \ No newline at end of file +../common/dri1_helper.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_context.c b/src/gallium/state_trackers/dri/sw/dri_context.c index 989ef4438a1..5cfbbaeb068 120000 --- a/src/gallium/state_trackers/dri/sw/dri_context.c +++ b/src/gallium/state_trackers/dri/sw/dri_context.c @@ -1 +1 @@ -../dri_context.c \ No newline at end of file +../common/dri_context.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c index 422c4c1d740..0fc19be6ea6 120000 --- a/src/gallium/state_trackers/dri/sw/dri_drawable.c +++ b/src/gallium/state_trackers/dri/sw/dri_drawable.c @@ -1 +1 @@ -../dri_drawable.c \ No newline at end of file +../common/dri_drawable.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_extensions.c b/src/gallium/state_trackers/dri/sw/dri_extensions.c index b793f06747d..e0d06dcdfa5 120000 --- a/src/gallium/state_trackers/dri/sw/dri_extensions.c +++ b/src/gallium/state_trackers/dri/sw/dri_extensions.c @@ -1 +1 @@ -../dri_extensions.c \ No newline at end of file +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_screen.c b/src/gallium/state_trackers/dri/sw/dri_screen.c index 938f4c3bdc7..847f6515f25 120000 --- a/src/gallium/state_trackers/dri/sw/dri_screen.c +++ b/src/gallium/state_trackers/dri/sw/dri_screen.c @@ -1 +1 @@ -../dri_screen.c \ No newline at end of file +../common/dri_screen.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/dri_st_api.c b/src/gallium/state_trackers/dri/sw/dri_st_api.c index 9ae88230ddc..a8f6bd06b09 120000 --- a/src/gallium/state_trackers/dri/sw/dri_st_api.c +++ b/src/gallium/state_trackers/dri/sw/dri_st_api.c @@ -1 +1 @@ -../dri_st_api.c \ No newline at end of file +../common/dri_st_api.c \ No newline at end of file From bc88c95990f871a206a8fe93e7541f1f41841f7e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 19:19:00 +0100 Subject: [PATCH 372/483] i915g: Rename winsys prefix to i915_ from intel_ Since the winsys isn't shared with i965 and never will be --- SConstruct | 2 +- src/gallium/drivers/i915/i915_batch.h | 10 +- ...intel_batchbuffer.h => i915_batchbuffer.h} | 50 ++++---- src/gallium/drivers/i915/i915_blit.c | 12 +- src/gallium/drivers/i915/i915_blit.h | 6 +- src/gallium/drivers/i915/i915_buffer.c | 4 +- src/gallium/drivers/i915/i915_context.h | 14 +-- src/gallium/drivers/i915/i915_debug.c | 2 +- src/gallium/drivers/i915/i915_debug.h | 4 +- src/gallium/drivers/i915/i915_prim_vbuf.c | 16 +-- src/gallium/drivers/i915/i915_screen.c | 4 +- src/gallium/drivers/i915/i915_screen.h | 4 +- src/gallium/drivers/i915/i915_state_emit.c | 10 +- .../drivers/i915/i915_state_immediate.c | 6 +- src/gallium/drivers/i915/i915_texture.c | 26 ++--- .../i915/{intel_winsys.h => i915_winsys.h} | 107 +++++++++--------- src/gallium/targets/SConscript | 2 +- src/gallium/targets/dri-i915/Makefile | 2 +- src/gallium/targets/dri-i915/SConscript | 2 +- src/gallium/targets/egl-i915/Makefile | 2 +- src/gallium/targets/xorg-i915/Makefile | 2 +- src/gallium/winsys/SConscript | 2 +- src/gallium/winsys/i915/drm/Makefile | 10 +- src/gallium/winsys/i915/drm/SConscript | 18 +-- .../drm/{intel_drm_api.c => i915_drm_api.c} | 28 ++--- ...m_batchbuffer.c => i915_drm_batchbuffer.c} | 78 ++++++------- .../{intel_drm_buffer.c => i915_drm_buffer.c} | 98 ++++++++-------- .../{intel_drm_fence.c => i915_drm_fence.c} | 30 ++--- src/gallium/winsys/i915/drm/i915_drm_winsys.h | 77 +++++++++++++ .../winsys/i915/drm/intel_drm_winsys.h | 77 ------------- 30 files changed, 354 insertions(+), 351 deletions(-) rename src/gallium/drivers/i915/{intel_batchbuffer.h => i915_batchbuffer.h} (64%) rename src/gallium/drivers/i915/{intel_winsys.h => i915_winsys.h} (62%) rename src/gallium/winsys/i915/drm/{intel_drm_api.c => i915_drm_api.c} (69%) rename src/gallium/winsys/i915/drm/{intel_drm_batchbuffer.c => i915_drm_batchbuffer.c} (65%) rename src/gallium/winsys/i915/drm/{intel_drm_buffer.c => i915_drm_buffer.c} (54%) rename src/gallium/winsys/i915/drm/{intel_drm_fence.c => i915_drm_fence.c} (58%) create mode 100644 src/gallium/winsys/i915/drm/i915_drm_winsys.h delete mode 100644 src/gallium/winsys/i915/drm/intel_drm_winsys.h diff --git a/SConstruct b/SConstruct index 6ed44ddd067..2549a13fffa 100644 --- a/SConstruct +++ b/SConstruct @@ -52,7 +52,7 @@ opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statet opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, - ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon'])) + ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon'])) opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) diff --git a/src/gallium/drivers/i915/i915_batch.h b/src/gallium/drivers/i915/i915_batch.h index b813784723f..f0086695d16 100644 --- a/src/gallium/drivers/i915/i915_batch.h +++ b/src/gallium/drivers/i915/i915_batch.h @@ -28,19 +28,19 @@ #ifndef I915_BATCH_H #define I915_BATCH_H -#include "intel_batchbuffer.h" +#include "i915_batchbuffer.h" #define BEGIN_BATCH(dwords, relocs) \ - (intel_batchbuffer_check(i915->batch, dwords, relocs)) + (i915_winsys_batchbuffer_check(i915->batch, dwords, relocs)) #define OUT_BATCH(dword) \ - intel_batchbuffer_dword(i915->batch, dword) + i915_winsys_batchbuffer_dword(i915->batch, dword) #define OUT_RELOC(buf, usage, offset) \ - intel_batchbuffer_reloc(i915->batch, buf, usage, offset) + i915_winsys_batchbuffer_reloc(i915->batch, buf, usage, offset) #define FLUSH_BATCH(fence) do { \ - intel_batchbuffer_flush(i915->batch, fence); \ + i915_winsys_batchbuffer_flush(i915->batch, fence); \ i915->hardware_dirty = ~0; \ } while (0) diff --git a/src/gallium/drivers/i915/intel_batchbuffer.h b/src/gallium/drivers/i915/i915_batchbuffer.h similarity index 64% rename from src/gallium/drivers/i915/intel_batchbuffer.h rename to src/gallium/drivers/i915/i915_batchbuffer.h index db12dfd2ac2..27ccaa6b1fa 100644 --- a/src/gallium/drivers/i915/intel_batchbuffer.h +++ b/src/gallium/drivers/i915/i915_batchbuffer.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * 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 @@ -10,11 +10,11 @@ * distribute, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. @@ -22,34 +22,34 @@ * 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. - * + * **************************************************************************/ -#ifndef INTEL_BATCH_H -#define INTEL_BATCH_H +#ifndef I915_BATCHBUFFER_H +#define I915_BATCHBUFFER_H -#include "intel_winsys.h" +#include "i915_winsys.h" static INLINE boolean -intel_batchbuffer_check(struct intel_batchbuffer *batch, - size_t dwords, - size_t relocs) +i915_winsys_batchbuffer_check(struct i915_winsys_batchbuffer *batch, + size_t dwords, + size_t relocs) { return dwords * 4 <= batch->size - (batch->ptr - batch->map) && relocs <= (batch->max_relocs - batch->relocs); } static INLINE size_t -intel_batchbuffer_space(struct intel_batchbuffer *batch) +i915_winsys_batchbuffer_space(struct i915_winsys_batchbuffer *batch) { return batch->size - (batch->ptr - batch->map); } static INLINE void -intel_batchbuffer_dword(struct intel_batchbuffer *batch, - unsigned dword) +i915_winsys_batchbuffer_dword(struct i915_winsys_batchbuffer *batch, + unsigned dword) { - if (intel_batchbuffer_space(batch) < 4) + if (i915_winsys_batchbuffer_space(batch) < 4) return; *(unsigned *)batch->ptr = dword; @@ -57,11 +57,11 @@ intel_batchbuffer_dword(struct intel_batchbuffer *batch, } static INLINE void -intel_batchbuffer_write(struct intel_batchbuffer *batch, - void *data, - size_t size) +i915_winsys_batchbuffer_write(struct i915_winsys_batchbuffer *batch, + void *data, + size_t size) { - if (intel_batchbuffer_space(batch) < size) + if (i915_winsys_batchbuffer_space(batch) < size) return; memcpy(data, batch->ptr, size); @@ -69,17 +69,17 @@ intel_batchbuffer_write(struct intel_batchbuffer *batch, } static INLINE int -intel_batchbuffer_reloc(struct intel_batchbuffer *batch, - struct intel_buffer *buffer, - enum intel_buffer_usage usage, - size_t offset) +i915_winsys_batchbuffer_reloc(struct i915_winsys_batchbuffer *batch, + struct i915_winsys_buffer *buffer, + enum i915_winsys_buffer_usage usage, + size_t offset) { return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset); } static INLINE void -intel_batchbuffer_flush(struct intel_batchbuffer *batch, - struct pipe_fence_handle **fence) +i915_winsys_batchbuffer_flush(struct i915_winsys_batchbuffer *batch, + struct pipe_fence_handle **fence) { batch->iws->batchbuffer_flush(batch, fence); } diff --git a/src/gallium/drivers/i915/i915_blit.c b/src/gallium/drivers/i915/i915_blit.c index 83dfc335288..533fa81219b 100644 --- a/src/gallium/drivers/i915/i915_blit.c +++ b/src/gallium/drivers/i915/i915_blit.c @@ -37,7 +37,7 @@ void i915_fill_blit(struct i915_context *i915, unsigned cpp, unsigned short dst_pitch, - struct intel_buffer *dst_buffer, + struct i915_winsys_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, @@ -77,7 +77,7 @@ i915_fill_blit(struct i915_context *i915, OUT_BATCH(BR13); OUT_BATCH((y << 16) | x); OUT_BATCH(((y + h) << 16) | (x + w)); - OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset); + OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset); OUT_BATCH(color); FLUSH_BATCH(NULL); } @@ -87,10 +87,10 @@ i915_copy_blit(struct i915_context *i915, unsigned do_flip, unsigned cpp, unsigned short src_pitch, - struct intel_buffer *src_buffer, + struct i915_winsys_buffer *src_buffer, unsigned src_offset, unsigned short dst_pitch, - struct intel_buffer *dst_buffer, + struct i915_winsys_buffer *dst_buffer, unsigned dst_offset, short src_x, short src_y, short dst_x, short dst_y, @@ -143,9 +143,9 @@ i915_copy_blit(struct i915_context *i915, OUT_BATCH(BR13); OUT_BATCH((dst_y << 16) | dst_x); OUT_BATCH((dst_y2 << 16) | dst_x2); - OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset); + OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset); OUT_BATCH((src_y << 16) | src_x); OUT_BATCH(((int) src_pitch & 0xffff)); - OUT_RELOC(src_buffer, INTEL_USAGE_2D_SOURCE, src_offset); + OUT_RELOC(src_buffer, I915_USAGE_2D_SOURCE, src_offset); FLUSH_BATCH(NULL); } diff --git a/src/gallium/drivers/i915/i915_blit.h b/src/gallium/drivers/i915/i915_blit.h index 8ce3220cfd9..db576ed4c90 100644 --- a/src/gallium/drivers/i915/i915_blit.h +++ b/src/gallium/drivers/i915/i915_blit.h @@ -34,10 +34,10 @@ extern void i915_copy_blit(struct i915_context *i915, unsigned do_flip, unsigned cpp, unsigned short src_pitch, - struct intel_buffer *src_buffer, + struct i915_winsys_buffer *src_buffer, unsigned src_offset, unsigned short dst_pitch, - struct intel_buffer *dst_buffer, + struct i915_winsys_buffer *dst_buffer, unsigned dst_offset, short srcx, short srcy, short dstx, short dsty, @@ -46,7 +46,7 @@ extern void i915_copy_blit(struct i915_context *i915, extern void i915_fill_blit(struct i915_context *i915, unsigned cpp, unsigned short dst_pitch, - struct intel_buffer *dst_buffer, + struct i915_winsys_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, unsigned color); diff --git a/src/gallium/drivers/i915/i915_buffer.c b/src/gallium/drivers/i915/i915_buffer.c index 0f76a59e93a..1247de320d4 100644 --- a/src/gallium/drivers/i915/i915_buffer.c +++ b/src/gallium/drivers/i915/i915_buffer.c @@ -28,13 +28,13 @@ #include "i915_screen.h" #include "i915_buffer.h" -struct intel_buffer; +struct i915_winsys_buffer; struct i915_buffer { struct pipe_buffer base; - struct intel_buffer *ibuf; /** hw buffer */ + struct i915_winsys_buffer *ibuf; /** hw buffer */ void *data; /**< user and malloc data */ boolean own; /**< we own the data incase of malloc */ diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 5348f62ca74..8df4dce8653 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -38,9 +38,9 @@ #include "tgsi/tgsi_scan.h" -struct intel_winsys; -struct intel_buffer; -struct intel_batchbuffer; +struct i915_winsys; +struct i915_winsys_buffer; +struct i915_winsys_batchbuffer; #define I915_TEX_UNITS 8 @@ -219,14 +219,14 @@ struct i915_texture { /* The data is held here: */ - struct intel_buffer *buffer; + struct i915_winsys_buffer *buffer; }; struct i915_context { struct pipe_context base; - struct intel_winsys *iws; + struct i915_winsys *iws; struct draw_context *draw; @@ -257,10 +257,10 @@ struct i915_context unsigned num_fragment_sampler_views; unsigned num_vertex_buffers; - struct intel_batchbuffer *batch; + struct i915_winsys_batchbuffer *batch; /** Vertex buffer */ - struct intel_buffer *vbo; + struct i915_winsys_buffer *vbo; size_t vbo_offset; unsigned vbo_flushed; diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c index 237654d26b2..663fac3055c 100644 --- a/src/gallium/drivers/i915/i915_debug.c +++ b/src/gallium/drivers/i915/i915_debug.c @@ -863,7 +863,7 @@ static boolean i915_debug_packet( struct debug_stream *stream ) void -i915_dump_batchbuffer( struct intel_batchbuffer *batch ) +i915_dump_batchbuffer( struct i915_winsys_batchbuffer *batch ) { struct debug_stream stream; unsigned *start = (unsigned*)batch->map; diff --git a/src/gallium/drivers/i915/i915_debug.h b/src/gallium/drivers/i915/i915_debug.h index 8f7484797de..67b8d9c2f63 100644 --- a/src/gallium/drivers/i915/i915_debug.h +++ b/src/gallium/drivers/i915/i915_debug.h @@ -104,9 +104,9 @@ I915_DBG( #endif -struct intel_batchbuffer; +struct i915_winsys_batchbuffer; -void i915_dump_batchbuffer( struct intel_batchbuffer *i915 ); +void i915_dump_batchbuffer( struct i915_winsys_batchbuffer *i915 ); void i915_debug_init( struct i915_context *i915 ); diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c b/src/gallium/drivers/i915/i915_prim_vbuf.c index cad4109ee6b..df9e68af4fc 100644 --- a/src/gallium/drivers/i915/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915/i915_prim_vbuf.c @@ -76,7 +76,7 @@ struct i915_vbuf_render { unsigned fallback; /* Stuff for the vbo */ - struct intel_buffer *vbo; + struct i915_winsys_buffer *vbo; size_t vbo_size; /**< current size of allocated buffer */ size_t vbo_alloc_size; /**< minimum buffer size to allocate */ size_t vbo_offset; @@ -141,7 +141,7 @@ static void i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size) { struct i915_context *i915 = i915_render->i915; - struct intel_winsys *iws = i915->iws; + struct i915_winsys *iws = i915->iws; if (i915_render->vbo) { #ifdef VBUF_USE_FIFO @@ -172,7 +172,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size) if (i915_render->vbo_size != i915_render->pool_buffer_size) { i915_render->pool_not_used = TRUE; i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64, - INTEL_NEW_VERTEX); + I915_NEW_VERTEX); } else { i915_render->pool_not_used = FALSE; @@ -185,7 +185,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size) } #else i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, - 64, INTEL_NEW_VERTEX); + 64, I915_NEW_VERTEX); #endif } @@ -225,7 +225,7 @@ i915_vbuf_render_map_vertices(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; - struct intel_winsys *iws = i915->iws; + struct i915_winsys *iws = i915->iws; if (i915->vbo_flushed) debug_printf("%s bad vbo flush occured stalling on hw\n", __FUNCTION__); @@ -246,7 +246,7 @@ i915_vbuf_render_unmap_vertices(struct vbuf_render *render, { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; - struct intel_winsys *iws = i915->iws; + struct i915_winsys *iws = i915->iws; i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1)); #ifdef VBUF_MAP_BUFFER @@ -621,7 +621,7 @@ static struct vbuf_render * i915_vbuf_render_create(struct i915_context *i915) { struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render); - struct intel_winsys *iws = i915->iws; + struct i915_winsys *iws = i915->iws; int i; i915_render->i915 = i915; @@ -662,7 +662,7 @@ i915_vbuf_render_create(struct i915_context *i915) for (i = 0; i < 6; i++) u_fifo_add(i915_render->pool_fifo, iws->buffer_create(iws, i915_render->pool_buffer_size, 64, - INTEL_NEW_VERTEX)); + I915_NEW_VERTEX)); #else (void)i; (void)iws; diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 48a39edad20..53ef6e50f6c 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -35,7 +35,7 @@ #include "i915_screen.h" #include "i915_buffer.h" #include "i915_texture.h" -#include "intel_winsys.h" +#include "i915_winsys.h" /* @@ -260,7 +260,7 @@ i915_destroy_screen(struct pipe_screen *screen) * Create a new i915_screen object */ struct pipe_screen * -i915_create_screen(struct intel_winsys *iws, uint pci_id) +i915_create_screen(struct i915_winsys *iws, uint pci_id) { struct i915_screen *is = CALLOC_STRUCT(i915_screen); diff --git a/src/gallium/drivers/i915/i915_screen.h b/src/gallium/drivers/i915/i915_screen.h index 5126485caa7..7f9e02fc0f6 100644 --- a/src/gallium/drivers/i915/i915_screen.h +++ b/src/gallium/drivers/i915/i915_screen.h @@ -32,7 +32,7 @@ #include "pipe/p_screen.h" -struct intel_winsys; +struct i915_winsys; /** @@ -42,7 +42,7 @@ struct i915_screen { struct pipe_screen base; - struct intel_winsys *iws; + struct i915_winsys *iws; boolean is_i945; uint pci_id; diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index d79c1ca0b2c..04a3924aaf7 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -182,7 +182,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) if(i915->vbo) OUT_RELOC(i915->vbo, - INTEL_USAGE_VERTEX, + I915_USAGE_VERTEX, i915->current.immediate[I915_IMMEDIATE_S0]); else /* FIXME: we should not do this */ @@ -226,7 +226,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) ctile); OUT_RELOC(tex->buffer, - INTEL_USAGE_RENDER, + I915_USAGE_RENDER, cbuf_surface->offset); } @@ -250,7 +250,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) ztile); OUT_RELOC(tex->buffer, - INTEL_USAGE_RENDER, + I915_USAGE_RENDER, depth_surface->offset); } @@ -291,13 +291,13 @@ i915_emit_hardware_state(struct i915_context *i915 ) for (unit = 0; unit < I915_TEX_UNITS; unit++) { if (enabled & (1 << unit)) { struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture; - struct intel_buffer *buf = texture->buffer; + struct i915_winsys_buffer *buf = texture->buffer; uint offset = 0; assert(buf); count++; - OUT_RELOC(buf, INTEL_USAGE_SAMPLER, offset); + OUT_RELOC(buf, I915_USAGE_SAMPLER, offset); OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */ OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */ } diff --git a/src/gallium/drivers/i915/i915_state_immediate.c b/src/gallium/drivers/i915/i915_state_immediate.c index d2c6f151434..8cec699285c 100644 --- a/src/gallium/drivers/i915/i915_state_immediate.c +++ b/src/gallium/drivers/i915/i915_state_immediate.c @@ -52,11 +52,11 @@ static void upload_S0S1(struct i915_context *i915) { unsigned LIS0, LIS1; - /* INTEL_NEW_VBO */ + /* I915_NEW_VBO */ /* TODO: re-use vertex buffers here? */ LIS0 = i915->vbo_offset; - /* INTEL_NEW_VERTEX_SIZE -- do this where the vertex size is calculated! + /* I915_NEW_VERTEX_SIZE -- do this where the vertex size is calculated! */ { unsigned vertex_size = i915->current.vertex_info.size; @@ -65,7 +65,7 @@ static void upload_S0S1(struct i915_context *i915) (vertex_size << 16)); } - /* INTEL_NEW_VBO */ + /* I915_NEW_VBO */ /* TODO: use a vertex generation number to track vbo changes */ if (1 || i915->current.immediate[I915_IMMEDIATE_S0] != LIS0 || diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index b252fb5330c..8c405c2443e 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -41,7 +41,7 @@ #include "i915_context.h" #include "i915_texture.h" #include "i915_screen.h" -#include "intel_winsys.h" +#include "i915_winsys.h" /* @@ -162,7 +162,7 @@ i915_scanout_layout(struct i915_texture *tex) if (pt->width0 >= 240) { tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0)); tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8); - tex->hw_tiled = INTEL_TILE_X; + tex->hw_tiled = I915_TILE_X; } else if (pt->width0 == 64 && pt->height0 == 64) { tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0)); tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8); @@ -200,7 +200,7 @@ i915_display_target_layout(struct i915_texture *tex) tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0)); tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8); - tex->hw_tiled = INTEL_TILE_X; + tex->hw_tiled = I915_TILE_X; debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__, pt->width0, pt->height0, util_format_get_blocksize(pt->format), @@ -617,7 +617,7 @@ i915_texture_create(struct pipe_screen *screen, const struct pipe_texture *templat) { struct i915_screen *is = i915_screen(screen); - struct intel_winsys *iws = is->iws; + struct i915_winsys *iws = is->iws; struct i915_texture *tex = CALLOC_STRUCT(i915_texture); size_t tex_size; unsigned buf_usage = 0; @@ -643,9 +643,9 @@ i915_texture_create(struct pipe_screen *screen, /* for scanouts and cursors, cursors arn't scanouts */ if (templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT && templat->width0 != 64) - buf_usage = INTEL_NEW_SCANOUT; + buf_usage = I915_NEW_SCANOUT; else - buf_usage = INTEL_NEW_TEXTURE; + buf_usage = I915_NEW_TEXTURE; tex->buffer = iws->buffer_create(iws, tex_size, 64, buf_usage); if (!tex->buffer) @@ -653,7 +653,7 @@ i915_texture_create(struct pipe_screen *screen, /* setup any hw fences */ if (tex->hw_tiled) { - assert(tex->sw_tiled == INTEL_TILE_NONE); + assert(tex->sw_tiled == I915_TILE_NONE); iws->buffer_set_fence_reg(iws, tex->buffer, tex->stride, tex->hw_tiled); } @@ -679,8 +679,8 @@ i915_texture_from_handle(struct pipe_screen * screen, { struct i915_screen *is = i915_screen(screen); struct i915_texture *tex; - struct intel_winsys *iws = is->iws; - struct intel_buffer *buffer; + struct i915_winsys *iws = is->iws; + struct i915_winsys_buffer *buffer; unsigned stride; assert(screen); @@ -719,7 +719,7 @@ i915_texture_get_handle(struct pipe_screen * screen, { struct i915_screen *is = i915_screen(screen); struct i915_texture *tex = (struct i915_texture *)texture; - struct intel_winsys *iws = is->iws; + struct i915_winsys *iws = is->iws; return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride); } @@ -729,7 +729,7 @@ static void i915_texture_destroy(struct pipe_texture *pt) { struct i915_texture *tex = (struct i915_texture *)pt; - struct intel_winsys *iws = i915_screen(pt->screen)->iws; + struct i915_winsys *iws = i915_screen(pt->screen)->iws; uint i; /* @@ -841,7 +841,7 @@ i915_transfer_map(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct i915_texture *tex = (struct i915_texture *)transfer->texture; - struct intel_winsys *iws = i915_screen(tex->base.screen)->iws; + struct i915_winsys *iws = i915_screen(tex->base.screen)->iws; char *map; boolean write = FALSE; enum pipe_format format = tex->base.format; @@ -863,7 +863,7 @@ i915_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct i915_texture *tex = (struct i915_texture *)transfer->texture; - struct intel_winsys *iws = i915_screen(tex->base.screen)->iws; + struct i915_winsys *iws = i915_screen(tex->base.screen)->iws; iws->buffer_unmap(iws, tex->buffer); } diff --git a/src/gallium/drivers/i915/intel_winsys.h b/src/gallium/drivers/i915/i915_winsys.h similarity index 62% rename from src/gallium/drivers/i915/intel_winsys.h rename to src/gallium/drivers/i915/i915_winsys.h index 00fd0c1efea..246e95b00d6 100644 --- a/src/gallium/drivers/i915/intel_winsys.h +++ b/src/gallium/drivers/i915/i915_winsys.h @@ -23,46 +23,46 @@ * **************************************************************************/ -#ifndef INTEL_WINSYS_H -#define INTEL_WINSYS_H +#ifndef I915_WINSYS_H +#define I915_WINSYS_H #include "pipe/p_compiler.h" -struct intel_winsys; -struct intel_buffer; -struct intel_batchbuffer; +struct i915_winsys; +struct i915_winsys_buffer; +struct i915_winsys_batchbuffer; struct pipe_texture; struct pipe_fence_handle; struct winsys_handle; -enum intel_buffer_usage +enum i915_winsys_buffer_usage { /* use on textures */ - INTEL_USAGE_RENDER = 0x01, - INTEL_USAGE_SAMPLER = 0x02, - INTEL_USAGE_2D_TARGET = 0x04, - INTEL_USAGE_2D_SOURCE = 0x08, + I915_USAGE_RENDER = 0x01, + I915_USAGE_SAMPLER = 0x02, + I915_USAGE_2D_TARGET = 0x04, + I915_USAGE_2D_SOURCE = 0x08, /* use on vertex */ - INTEL_USAGE_VERTEX = 0x10 + I915_USAGE_VERTEX = 0x10 }; -enum intel_buffer_type +enum i915_winsys_buffer_type { - INTEL_NEW_TEXTURE, - INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */ - INTEL_NEW_VERTEX + I915_NEW_TEXTURE, + I915_NEW_SCANOUT, /**< a texture used for scanning out from */ + I915_NEW_VERTEX }; -enum intel_buffer_tile +enum i915_winsys_buffer_tile { - INTEL_TILE_NONE, - INTEL_TILE_X, - INTEL_TILE_Y + I915_TILE_NONE, + I915_TILE_X, + I915_TILE_Y }; -struct intel_batchbuffer { +struct i915_winsys_batchbuffer { - struct intel_winsys *iws; + struct i915_winsys *iws; /** * Values exported to speed up the writing the batchbuffer, @@ -79,7 +79,7 @@ struct intel_batchbuffer { /*@}*/ }; -struct intel_winsys { +struct i915_winsys { /** * Batchbuffer functions. @@ -88,7 +88,8 @@ struct intel_winsys { /** * Create a new batchbuffer. */ - struct intel_batchbuffer *(*batchbuffer_create)(struct intel_winsys *iws); + struct i915_winsys_batchbuffer * + (*batchbuffer_create)(struct i915_winsys *iws); /** * Emit a relocation to a buffer. @@ -100,21 +101,21 @@ struct intel_winsys { * @offset add this to the reloc buffers address * @target buffer where to write the address, null for batchbuffer. */ - int (*batchbuffer_reloc)(struct intel_batchbuffer *batch, - struct intel_buffer *reloc, - enum intel_buffer_usage usage, + int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch, + struct i915_winsys_buffer *reloc, + enum i915_winsys_buffer_usage usage, unsigned offset); /** * Flush a bufferbatch. */ - void (*batchbuffer_flush)(struct intel_batchbuffer *batch, + void (*batchbuffer_flush)(struct i915_winsys_batchbuffer *batch, struct pipe_fence_handle **fence); /** * Destroy a batchbuffer. */ - void (*batchbuffer_destroy)(struct intel_batchbuffer *batch); + void (*batchbuffer_destroy)(struct i915_winsys_batchbuffer *batch); /*@}*/ @@ -125,9 +126,10 @@ struct intel_winsys { /** * Create a buffer. */ - struct intel_buffer *(*buffer_create)(struct intel_winsys *iws, - unsigned size, unsigned alignment, - enum intel_buffer_type type); + struct i915_winsys_buffer * + (*buffer_create)(struct i915_winsys *iws, + unsigned size, unsigned alignment, + enum i915_winsys_buffer_type type); /** * Creates a buffer from a handle. @@ -135,16 +137,17 @@ struct intel_winsys { * Also provides the stride information needed for the * texture via the stride argument. */ - struct intel_buffer *(*buffer_from_handle)(struct intel_winsys *iws, - struct winsys_handle *whandle, - unsigned *stride); + struct i915_winsys_buffer * + (*buffer_from_handle)(struct i915_winsys *iws, + struct winsys_handle *whandle, + unsigned *stride); /** * Used to implement pipe_screen::texture_get_handle. * The winsys might need the stride information. */ - boolean (*buffer_get_handle)(struct intel_winsys *iws, - struct intel_buffer *buffer, + boolean (*buffer_get_handle)(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, struct winsys_handle *whandle, unsigned stride); @@ -152,37 +155,37 @@ struct intel_winsys { * Fence a buffer with a fence reg. * Not to be confused with pipe_fence_handle. */ - int (*buffer_set_fence_reg)(struct intel_winsys *iws, - struct intel_buffer *buffer, + int (*buffer_set_fence_reg)(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, unsigned stride, - enum intel_buffer_tile tile); + enum i915_winsys_buffer_tile tile); /** * Map a buffer. */ - void *(*buffer_map)(struct intel_winsys *iws, - struct intel_buffer *buffer, + void *(*buffer_map)(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, boolean write); /** * Unmap a buffer. */ - void (*buffer_unmap)(struct intel_winsys *iws, - struct intel_buffer *buffer); + void (*buffer_unmap)(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer); /** * Write to a buffer. * * Arguments follows pipe_buffer_write. */ - int (*buffer_write)(struct intel_winsys *iws, - struct intel_buffer *dst, + int (*buffer_write)(struct i915_winsys *iws, + struct i915_winsys_buffer *dst, size_t offset, size_t size, const void *data); - void (*buffer_destroy)(struct intel_winsys *iws, - struct intel_buffer *buffer); + void (*buffer_destroy)(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer); /*@}*/ @@ -193,20 +196,20 @@ struct intel_winsys { /** * Reference fence and set ptr to fence. */ - void (*fence_reference)(struct intel_winsys *iws, + void (*fence_reference)(struct i915_winsys *iws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence); /** * Check if a fence has finished. */ - int (*fence_signalled)(struct intel_winsys *iws, + int (*fence_signalled)(struct i915_winsys *iws, struct pipe_fence_handle *fence); /** * Wait on a fence to finish. */ - int (*fence_finish)(struct intel_winsys *iws, + int (*fence_finish)(struct i915_winsys *iws, struct pipe_fence_handle *fence); /*@}*/ @@ -214,14 +217,14 @@ struct intel_winsys { /** * Destroy the winsys. */ - void (*destroy)(struct intel_winsys *iws); + void (*destroy)(struct i915_winsys *iws); }; /** * Create i915 pipe_screen. */ -struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id); +struct pipe_screen *i915_create_screen(struct i915_winsys *iws, unsigned pci_id); #endif diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index 38645646883..a41496a5dd9 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -62,7 +62,7 @@ if env['dri']: 'dri-vmwgfx/SConscript', ]) - if 'intel' in env['winsys']: + if 'i915' in env['winsys']: SConscript([ 'dri-i915/SConscript', ]) diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile index 822d4b57bbb..50a8e11e17c 100644 --- a/src/gallium/targets/dri-i915/Makefile +++ b/src/gallium/targets/dri-i915/Makefile @@ -5,7 +5,7 @@ LIBNAME = i915_dri.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ - $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript index 8d4ecefbe1b..f6d1f934783 100644 --- a/src/gallium/targets/dri-i915/SConscript +++ b/src/gallium/targets/dri-i915/SConscript @@ -10,7 +10,7 @@ env.ParseConfig('pkg-config --cflags --libs libdrm_intel') env.Prepend(LIBS = [ st_dri, - inteldrm, + i915drm, i915, trace, mesa, diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile index 6c2fc14d70f..efaf7b0bef9 100644 --- a/src/gallium/targets/egl-i915/Makefile +++ b/src/gallium/targets/egl-i915/Makefile @@ -6,7 +6,7 @@ EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i915/libi915.a diff --git a/src/gallium/targets/xorg-i915/Makefile b/src/gallium/targets/xorg-i915/Makefile index e2cffcd70b3..52a9e97b409 100644 --- a/src/gallium/targets/xorg-i915/Makefile +++ b/src/gallium/targets/xorg-i915/Makefile @@ -17,7 +17,7 @@ INCLUDES = \ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ - $(TOP)/src/gallium/winsys/i915/drm/libinteldrm.a \ + $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/i915/libi915.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 90ca693eb68..3e7052c0e6f 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -16,7 +16,7 @@ if env['dri']: 'svga/drm/SConscript', ]) - if 'intel' in env['winsys']: + if 'i915' in env['winsys']: SConscript([ 'i915/drm/SConscript', ]) diff --git a/src/gallium/winsys/i915/drm/Makefile b/src/gallium/winsys/i915/drm/Makefile index 4aac3309aa7..a67b9e8a528 100644 --- a/src/gallium/winsys/i915/drm/Makefile +++ b/src/gallium/winsys/i915/drm/Makefile @@ -1,13 +1,13 @@ TOP = ../../../../.. include $(TOP)/configs/current -LIBNAME = inteldrm +LIBNAME = i915drm C_SOURCES = \ - intel_drm_batchbuffer.c \ - intel_drm_buffer.c \ - intel_drm_fence.c \ - intel_drm_api.c + i915_drm_batchbuffer.c \ + i915_drm_buffer.c \ + i915_drm_fence.c \ + i915_drm_api.c LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I) diff --git a/src/gallium/winsys/i915/drm/SConscript b/src/gallium/winsys/i915/drm/SConscript index b47b8add837..ba29ac72fe7 100644 --- a/src/gallium/winsys/i915/drm/SConscript +++ b/src/gallium/winsys/i915/drm/SConscript @@ -2,16 +2,16 @@ Import('*') env = env.Clone() -inteldrm_sources = [ - 'intel_drm_api.c', - 'intel_drm_batchbuffer.c', - 'intel_drm_buffer.c', - 'intel_drm_fence.c', +i915drm_sources = [ + 'i915_drm_api.c', + 'i915_drm_batchbuffer.c', + 'i915_drm_buffer.c', + 'i915_drm_fence.c', ] -inteldrm = env.ConvenienceLibrary( - target ='inteldrm', - source = inteldrm_sources, +i915drm = env.ConvenienceLibrary( + target ='i915drm', + source = i915drm_sources, ) -Export('inteldrm') +Export('i915drm') diff --git a/src/gallium/winsys/i915/drm/intel_drm_api.c b/src/gallium/winsys/i915/drm/i915_drm_api.c similarity index 69% rename from src/gallium/winsys/i915/drm/intel_drm_api.c rename to src/gallium/winsys/i915/drm/i915_drm_api.c index e3b980a832b..6bb0aec1a67 100644 --- a/src/gallium/winsys/i915/drm/intel_drm_api.c +++ b/src/gallium/winsys/i915/drm/i915_drm_api.c @@ -2,7 +2,7 @@ #include "state_tracker/drm_api.h" -#include "intel_drm_winsys.h" +#include "i915_drm_winsys.h" #include "util/u_memory.h" #include "i915/i915_context.h" @@ -16,7 +16,7 @@ static void -intel_drm_get_device_id(unsigned int *device_id) +i915_drm_get_device_id(unsigned int *device_id) { char path[512]; FILE *file; @@ -39,9 +39,9 @@ intel_drm_get_device_id(unsigned int *device_id) } static void -intel_drm_winsys_destroy(struct intel_winsys *iws) +i915_drm_winsys_destroy(struct i915_winsys *iws) { - struct intel_drm_winsys *idws = intel_drm_winsys(iws); + struct i915_drm_winsys *idws = i915_drm_winsys(iws); drm_intel_bufmgr_destroy(idws->pools.gem); @@ -49,10 +49,10 @@ intel_drm_winsys_destroy(struct intel_winsys *iws) } static struct pipe_screen * -intel_drm_create_screen(struct drm_api *api, int drmFD, - struct drm_create_screen_arg *arg) +i915_drm_create_screen(struct drm_api *api, int drmFD, + struct drm_create_screen_arg *arg) { - struct intel_drm_winsys *idws; + struct i915_drm_winsys *idws; unsigned int deviceID; if (arg != NULL) { @@ -64,21 +64,21 @@ intel_drm_create_screen(struct drm_api *api, int drmFD, } } - idws = CALLOC_STRUCT(intel_drm_winsys); + idws = CALLOC_STRUCT(i915_drm_winsys); if (!idws) return NULL; - intel_drm_get_device_id(&deviceID); + i915_drm_get_device_id(&deviceID); - intel_drm_winsys_init_batchbuffer_functions(idws); - intel_drm_winsys_init_buffer_functions(idws); - intel_drm_winsys_init_fence_functions(idws); + i915_drm_winsys_init_batchbuffer_functions(idws); + i915_drm_winsys_init_buffer_functions(idws); + i915_drm_winsys_init_fence_functions(idws); idws->fd = drmFD; idws->id = deviceID; idws->max_batch_size = 16 * 4096; - idws->base.destroy = intel_drm_winsys_destroy; + idws->base.destroy = i915_drm_winsys_destroy; idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size); drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem); @@ -98,7 +98,7 @@ struct drm_api intel_drm_api = { .name = "i915", .driver_name = "i915", - .create_screen = intel_drm_create_screen, + .create_screen = i915_drm_create_screen, .destroy = destroy, }; diff --git a/src/gallium/winsys/i915/drm/intel_drm_batchbuffer.c b/src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c similarity index 65% rename from src/gallium/winsys/i915/drm/intel_drm_batchbuffer.c rename to src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c index 5b4dafc8e41..102f59dc541 100644 --- a/src/gallium/winsys/i915/drm/intel_drm_batchbuffer.c +++ b/src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c @@ -1,5 +1,5 @@ -#include "intel_drm_winsys.h" +#include "i915_drm_winsys.h" #include "util/u_memory.h" #include "i915_drm.h" @@ -17,25 +17,25 @@ #undef INTEL_MAP_GTT #define INTEL_ALWAYS_FLUSH -struct intel_drm_batchbuffer +struct i915_drm_batchbuffer { - struct intel_batchbuffer base; + struct i915_winsys_batchbuffer base; size_t actual_size; drm_intel_bo *bo; }; -static INLINE struct intel_drm_batchbuffer * -intel_drm_batchbuffer(struct intel_batchbuffer *batch) +static INLINE struct i915_drm_batchbuffer * +i915_drm_batchbuffer(struct i915_winsys_batchbuffer *batch) { - return (struct intel_drm_batchbuffer *)batch; + return (struct i915_drm_batchbuffer *)batch; } static void -intel_drm_batchbuffer_reset(struct intel_drm_batchbuffer *batch) +i915_drm_batchbuffer_reset(struct i915_drm_batchbuffer *batch) { - struct intel_drm_winsys *idws = intel_drm_winsys(batch->base.iws); + struct i915_drm_winsys *idws = i915_drm_winsys(batch->base.iws); int ret; if (batch->bo) @@ -63,11 +63,11 @@ intel_drm_batchbuffer_reset(struct intel_drm_batchbuffer *batch) batch->base.relocs = 0; } -static struct intel_batchbuffer * -intel_drm_batchbuffer_create(struct intel_winsys *iws) +static struct i915_winsys_batchbuffer * +i915_drm_batchbuffer_create(struct i915_winsys *iws) { - struct intel_drm_winsys *idws = intel_drm_winsys(iws); - struct intel_drm_batchbuffer *batch = CALLOC_STRUCT(intel_drm_batchbuffer); + struct i915_drm_winsys *idws = i915_drm_winsys(iws); + struct i915_drm_batchbuffer *batch = CALLOC_STRUCT(i915_drm_batchbuffer); batch->actual_size = idws->max_batch_size; @@ -84,18 +84,18 @@ intel_drm_batchbuffer_create(struct intel_winsys *iws) batch->base.iws = iws; - intel_drm_batchbuffer_reset(batch); + i915_drm_batchbuffer_reset(batch); return &batch->base; } static int -intel_drm_batchbuffer_reloc(struct intel_batchbuffer *ibatch, - struct intel_buffer *buffer, - enum intel_buffer_usage usage, +i915_drm_batchbuffer_reloc(struct i915_winsys_batchbuffer *ibatch, + struct i915_winsys_buffer *buffer, + enum i915_winsys_buffer_usage usage, unsigned pre_add) { - struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch); + struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch); unsigned write_domain = 0; unsigned read_domain = 0; unsigned offset; @@ -103,23 +103,23 @@ intel_drm_batchbuffer_reloc(struct intel_batchbuffer *ibatch, assert(batch->base.relocs < batch->base.max_relocs); - if (usage == INTEL_USAGE_SAMPLER) { + if (usage == I915_USAGE_SAMPLER) { write_domain = 0; read_domain = I915_GEM_DOMAIN_SAMPLER; - } else if (usage == INTEL_USAGE_RENDER) { + } else if (usage == I915_USAGE_RENDER) { write_domain = I915_GEM_DOMAIN_RENDER; read_domain = I915_GEM_DOMAIN_RENDER; - } else if (usage == INTEL_USAGE_2D_TARGET) { + } else if (usage == I915_USAGE_2D_TARGET) { write_domain = I915_GEM_DOMAIN_RENDER; read_domain = I915_GEM_DOMAIN_RENDER; - } else if (usage == INTEL_USAGE_2D_SOURCE) { + } else if (usage == I915_USAGE_2D_SOURCE) { write_domain = 0; read_domain = I915_GEM_DOMAIN_RENDER; - } else if (usage == INTEL_USAGE_VERTEX) { + } else if (usage == I915_USAGE_VERTEX) { write_domain = 0; read_domain = I915_GEM_DOMAIN_VERTEX; @@ -145,15 +145,15 @@ intel_drm_batchbuffer_reloc(struct intel_batchbuffer *ibatch, } static void -intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch, +i915_drm_batchbuffer_flush(struct i915_winsys_batchbuffer *ibatch, struct pipe_fence_handle **fence) { - struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch); + struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch); unsigned used = 0; int ret = 0; int i; - assert(intel_batchbuffer_space(ibatch) >= 0); + assert(i915_winsys_batchbuffer_space(ibatch) >= 0); used = batch->base.ptr - batch->base.map; assert((used & 3) == 0); @@ -161,16 +161,16 @@ intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch, #ifdef INTEL_ALWAYS_FLUSH /* MI_FLUSH | FLUSH_MAP_CACHE */ - intel_batchbuffer_dword(ibatch, (0x4<<23)|(1<<0)); + i915_winsys_batchbuffer_dword(ibatch, (0x4<<23)|(1<<0)); used += 4; #endif if ((used & 4) == 0) { /* MI_NOOP */ - intel_batchbuffer_dword(ibatch, 0); + i915_winsys_batchbuffer_dword(ibatch, 0); } /* MI_BATCH_BUFFER_END */ - intel_batchbuffer_dword(ibatch, (0xA<<23)); + i915_winsys_batchbuffer_dword(ibatch, (0xA<<23)); used = batch->base.ptr - batch->base.map; assert((used & 4) == 0); @@ -189,7 +189,7 @@ intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch, ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0); assert(ret == 0); - if (intel_drm_winsys(ibatch->iws)->dump_cmd) { + if (i915_drm_winsys(ibatch->iws)->dump_cmd) { unsigned *ptr; drm_intel_bo_map(batch->bo, FALSE); ptr = (unsigned*)batch->bo->virtual; @@ -212,19 +212,19 @@ intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch, #ifdef INTEL_RUN_SYNC /* we run synced to GPU so just pass null */ - (*fence) = intel_drm_fence_create(NULL); + (*fence) = i915_drm_fence_create(NULL); #else - (*fence) = intel_drm_fence_create(batch->bo); + (*fence) = i915_drm_fence_create(batch->bo); #endif } - intel_drm_batchbuffer_reset(batch); + i915_drm_batchbuffer_reset(batch); } static void -intel_drm_batchbuffer_destroy(struct intel_batchbuffer *ibatch) +i915_drm_batchbuffer_destroy(struct i915_winsys_batchbuffer *ibatch) { - struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch); + struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch); if (batch->bo) drm_intel_bo_unreference(batch->bo); @@ -235,10 +235,10 @@ intel_drm_batchbuffer_destroy(struct intel_batchbuffer *ibatch) FREE(batch); } -void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws) +void i915_drm_winsys_init_batchbuffer_functions(struct i915_drm_winsys *idws) { - idws->base.batchbuffer_create = intel_drm_batchbuffer_create; - idws->base.batchbuffer_reloc = intel_drm_batchbuffer_reloc; - idws->base.batchbuffer_flush = intel_drm_batchbuffer_flush; - idws->base.batchbuffer_destroy = intel_drm_batchbuffer_destroy; + idws->base.batchbuffer_create = i915_drm_batchbuffer_create; + idws->base.batchbuffer_reloc = i915_drm_batchbuffer_reloc; + idws->base.batchbuffer_flush = i915_drm_batchbuffer_flush; + idws->base.batchbuffer_destroy = i915_drm_batchbuffer_destroy; } diff --git a/src/gallium/winsys/i915/drm/intel_drm_buffer.c b/src/gallium/winsys/i915/drm/i915_drm_buffer.c similarity index 54% rename from src/gallium/winsys/i915/drm/intel_drm_buffer.c rename to src/gallium/winsys/i915/drm/i915_drm_buffer.c index cb4f92a3b17..3bd85026b21 100644 --- a/src/gallium/winsys/i915/drm/intel_drm_buffer.c +++ b/src/gallium/winsys/i915/drm/i915_drm_buffer.c @@ -1,17 +1,17 @@ #include "state_tracker/drm_api.h" -#include "intel_drm_winsys.h" +#include "i915_drm_winsys.h" #include "util/u_memory.h" #include "i915_drm.h" -static struct intel_buffer * -intel_drm_buffer_create(struct intel_winsys *iws, +static struct i915_winsys_buffer * +i915_drm_buffer_create(struct i915_winsys *iws, unsigned size, unsigned alignment, - enum intel_buffer_type type) + enum i915_winsys_buffer_type type) { - struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); - struct intel_drm_winsys *idws = intel_drm_winsys(iws); + struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer); + struct i915_drm_winsys *idws = i915_drm_winsys(iws); drm_intel_bufmgr *pool; char *name; @@ -23,14 +23,14 @@ intel_drm_buffer_create(struct intel_winsys *iws, buf->flink = 0; buf->map_gtt = FALSE; - if (type == INTEL_NEW_TEXTURE) { + if (type == I915_NEW_TEXTURE) { name = "gallium3d_texture"; pool = idws->pools.gem; - } else if (type == INTEL_NEW_VERTEX) { + } else if (type == I915_NEW_VERTEX) { name = "gallium3d_vertex"; pool = idws->pools.gem; buf->map_gtt = TRUE; - } else if (type == INTEL_NEW_SCANOUT) { + } else if (type == I915_NEW_SCANOUT) { name = "gallium3d_scanout"; pool = idws->pools.gem; buf->map_gtt = TRUE; @@ -45,7 +45,7 @@ intel_drm_buffer_create(struct intel_winsys *iws, if (!buf->bo) goto err; - return (struct intel_buffer *)buf; + return (struct i915_winsys_buffer *)buf; err: assert(0); @@ -53,13 +53,13 @@ err: return NULL; } -static struct intel_buffer * -intel_drm_buffer_from_handle(struct intel_winsys *iws, +static struct i915_winsys_buffer * +i915_drm_buffer_from_handle(struct i915_winsys *iws, struct winsys_handle *whandle, unsigned *stride) { - struct intel_drm_winsys *idws = intel_drm_winsys(iws); - struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); + struct i915_drm_winsys *idws = i915_drm_winsys(iws); + struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer); uint32_t tile = 0, swizzle = 0; if (!buf) @@ -74,12 +74,12 @@ intel_drm_buffer_from_handle(struct intel_winsys *iws, goto err; drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); - if (tile != INTEL_TILE_NONE) + if (tile != I915_TILE_NONE) buf->map_gtt = TRUE; *stride = whandle->stride; - return (struct intel_buffer *)buf; + return (struct i915_winsys_buffer *)buf; err: FREE(buf); @@ -87,12 +87,12 @@ err: } static boolean -intel_drm_buffer_get_handle(struct intel_winsys *iws, - struct intel_buffer *buffer, +i915_drm_buffer_get_handle(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, struct winsys_handle *whandle, unsigned stride) { - struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { if (!buf->flinked) { @@ -114,17 +114,17 @@ intel_drm_buffer_get_handle(struct intel_winsys *iws, } static int -intel_drm_buffer_set_fence_reg(struct intel_winsys *iws, - struct intel_buffer *buffer, +i915_drm_buffer_set_fence_reg(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, unsigned stride, - enum intel_buffer_tile tile) + enum i915_winsys_buffer_tile tile) { - struct intel_drm_buffer *buf = intel_drm_buffer(buffer); - assert(I915_TILING_NONE == INTEL_TILE_NONE); - assert(I915_TILING_X == INTEL_TILE_X); - assert(I915_TILING_Y == INTEL_TILE_Y); + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); + assert(I915_TILING_NONE == I915_TILE_NONE); + assert(I915_TILING_X == I915_TILE_X); + assert(I915_TILING_Y == I915_TILE_Y); - if (tile != INTEL_TILE_NONE) { + if (tile != I915_TILE_NONE) { assert(buf->map_count == 0); buf->map_gtt = TRUE; } @@ -133,11 +133,11 @@ intel_drm_buffer_set_fence_reg(struct intel_winsys *iws, } static void * -intel_drm_buffer_map(struct intel_winsys *iws, - struct intel_buffer *buffer, +i915_drm_buffer_map(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, boolean write) { - struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); drm_intel_bo *bo = intel_bo(buffer); int ret = 0; @@ -163,10 +163,10 @@ out: } static void -intel_drm_buffer_unmap(struct intel_winsys *iws, - struct intel_buffer *buffer) +i915_drm_buffer_unmap(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer) { - struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); if (--buf->map_count) return; @@ -178,40 +178,40 @@ intel_drm_buffer_unmap(struct intel_winsys *iws, } static int -intel_drm_buffer_write(struct intel_winsys *iws, - struct intel_buffer *buffer, +i915_drm_buffer_write(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer, size_t offset, size_t size, const void *data) { - struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); return drm_intel_bo_subdata(buf->bo, offset, size, (void*)data); } static void -intel_drm_buffer_destroy(struct intel_winsys *iws, - struct intel_buffer *buffer) +i915_drm_buffer_destroy(struct i915_winsys *iws, + struct i915_winsys_buffer *buffer) { drm_intel_bo_unreference(intel_bo(buffer)); #ifdef DEBUG - intel_drm_buffer(buffer)->magic = 0; - intel_drm_buffer(buffer)->bo = NULL; + i915_drm_buffer(buffer)->magic = 0; + i915_drm_buffer(buffer)->bo = NULL; #endif FREE(buffer); } void -intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws) +i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws) { - idws->base.buffer_create = intel_drm_buffer_create; - idws->base.buffer_from_handle = intel_drm_buffer_from_handle; - idws->base.buffer_get_handle = intel_drm_buffer_get_handle; - idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg; - idws->base.buffer_map = intel_drm_buffer_map; - idws->base.buffer_unmap = intel_drm_buffer_unmap; - idws->base.buffer_write = intel_drm_buffer_write; - idws->base.buffer_destroy = intel_drm_buffer_destroy; + idws->base.buffer_create = i915_drm_buffer_create; + idws->base.buffer_from_handle = i915_drm_buffer_from_handle; + idws->base.buffer_get_handle = i915_drm_buffer_get_handle; + idws->base.buffer_set_fence_reg = i915_drm_buffer_set_fence_reg; + idws->base.buffer_map = i915_drm_buffer_map; + idws->base.buffer_unmap = i915_drm_buffer_unmap; + idws->base.buffer_write = i915_drm_buffer_write; + idws->base.buffer_destroy = i915_drm_buffer_destroy; } diff --git a/src/gallium/winsys/i915/drm/intel_drm_fence.c b/src/gallium/winsys/i915/drm/i915_drm_fence.c similarity index 58% rename from src/gallium/winsys/i915/drm/intel_drm_fence.c rename to src/gallium/winsys/i915/drm/i915_drm_fence.c index 102faedfeae..30ebf4835ea 100644 --- a/src/gallium/winsys/i915/drm/intel_drm_fence.c +++ b/src/gallium/winsys/i915/drm/i915_drm_fence.c @@ -1,5 +1,5 @@ -#include "intel_drm_winsys.h" +#include "i915_drm_winsys.h" #include "util/u_memory.h" #include "util/u_atomic.h" #include "util/u_inlines.h" @@ -10,7 +10,7 @@ * They work by keeping the batchbuffer around and checking if that has * been idled. If bo is NULL fence has expired. */ -struct intel_drm_fence +struct i915_drm_fence { struct pipe_reference reference; drm_intel_bo *bo; @@ -18,9 +18,9 @@ struct intel_drm_fence struct pipe_fence_handle * -intel_drm_fence_create(drm_intel_bo *bo) +i915_drm_fence_create(drm_intel_bo *bo) { - struct intel_drm_fence *fence = CALLOC_STRUCT(intel_drm_fence); + struct i915_drm_fence *fence = CALLOC_STRUCT(i915_drm_fence); pipe_reference_init(&fence->reference, 1); /* bo is null if fence already expired */ @@ -33,14 +33,14 @@ intel_drm_fence_create(drm_intel_bo *bo) } static void -intel_drm_fence_reference(struct intel_winsys *iws, +i915_drm_fence_reference(struct i915_winsys *iws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence) { - struct intel_drm_fence *old = (struct intel_drm_fence *)*ptr; - struct intel_drm_fence *f = (struct intel_drm_fence *)fence; + struct i915_drm_fence *old = (struct i915_drm_fence *)*ptr; + struct i915_drm_fence *f = (struct i915_drm_fence *)fence; - if (pipe_reference(&((struct intel_drm_fence *)(*ptr))->reference, &f->reference)) { + if (pipe_reference(&((struct i915_drm_fence *)(*ptr))->reference, &f->reference)) { if (old->bo) drm_intel_bo_unreference(old->bo); FREE(old); @@ -49,7 +49,7 @@ intel_drm_fence_reference(struct intel_winsys *iws, } static int -intel_drm_fence_signalled(struct intel_winsys *iws, +i915_drm_fence_signalled(struct i915_winsys *iws, struct pipe_fence_handle *fence) { assert(0); @@ -58,10 +58,10 @@ intel_drm_fence_signalled(struct intel_winsys *iws, } static int -intel_drm_fence_finish(struct intel_winsys *iws, +i915_drm_fence_finish(struct i915_winsys *iws, struct pipe_fence_handle *fence) { - struct intel_drm_fence *f = (struct intel_drm_fence *)fence; + struct i915_drm_fence *f = (struct i915_drm_fence *)fence; /* fence already expired */ if (!f->bo) @@ -75,9 +75,9 @@ intel_drm_fence_finish(struct intel_winsys *iws, } void -intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws) +i915_drm_winsys_init_fence_functions(struct i915_drm_winsys *idws) { - idws->base.fence_reference = intel_drm_fence_reference; - idws->base.fence_signalled = intel_drm_fence_signalled; - idws->base.fence_finish = intel_drm_fence_finish; + idws->base.fence_reference = i915_drm_fence_reference; + idws->base.fence_signalled = i915_drm_fence_signalled; + idws->base.fence_finish = i915_drm_fence_finish; } diff --git a/src/gallium/winsys/i915/drm/i915_drm_winsys.h b/src/gallium/winsys/i915/drm/i915_drm_winsys.h new file mode 100644 index 00000000000..217c4a7eafb --- /dev/null +++ b/src/gallium/winsys/i915/drm/i915_drm_winsys.h @@ -0,0 +1,77 @@ + +#ifndef INTEL_DRM_WINSYS_H +#define INTEL_DRM_WINSYS_H + +#include "i915/i915_batchbuffer.h" + +#include "drm.h" +#include "intel_bufmgr.h" + + +/* + * Winsys + */ + + +struct i915_drm_winsys +{ + struct i915_winsys base; + + boolean dump_cmd; + + int fd; /**< Drm file discriptor */ + + unsigned id; + + size_t max_batch_size; + + struct { + drm_intel_bufmgr *gem; + } pools; +}; + +static INLINE struct i915_drm_winsys * +i915_drm_winsys(struct i915_winsys *iws) +{ + return (struct i915_drm_winsys *)iws; +} + +struct i915_drm_winsys * i915_drm_winsys_create(int fd, unsigned pci_id); +struct pipe_fence_handle * i915_drm_fence_create(drm_intel_bo *bo); + +void i915_drm_winsys_init_batchbuffer_functions(struct i915_drm_winsys *idws); +void i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws); +void i915_drm_winsys_init_fence_functions(struct i915_drm_winsys *idws); + + +/* + * Buffer + */ + + +struct i915_drm_buffer { + unsigned magic; + + drm_intel_bo *bo; + + void *ptr; + unsigned map_count; + boolean map_gtt; + + boolean flinked; + unsigned flink; +}; + +static INLINE struct i915_drm_buffer * +i915_drm_buffer(struct i915_winsys_buffer *buffer) +{ + return (struct i915_drm_buffer *)buffer; +} + +static INLINE drm_intel_bo * +intel_bo(struct i915_winsys_buffer *buffer) +{ + return i915_drm_buffer(buffer)->bo; +} + +#endif diff --git a/src/gallium/winsys/i915/drm/intel_drm_winsys.h b/src/gallium/winsys/i915/drm/intel_drm_winsys.h deleted file mode 100644 index 9786ee93650..00000000000 --- a/src/gallium/winsys/i915/drm/intel_drm_winsys.h +++ /dev/null @@ -1,77 +0,0 @@ - -#ifndef INTEL_DRM_WINSYS_H -#define INTEL_DRM_WINSYS_H - -#include "i915/intel_batchbuffer.h" - -#include "drm.h" -#include "intel_bufmgr.h" - - -/* - * Winsys - */ - - -struct intel_drm_winsys -{ - struct intel_winsys base; - - boolean dump_cmd; - - int fd; /**< Drm file discriptor */ - - unsigned id; - - size_t max_batch_size; - - struct { - drm_intel_bufmgr *gem; - } pools; -}; - -static INLINE struct intel_drm_winsys * -intel_drm_winsys(struct intel_winsys *iws) -{ - return (struct intel_drm_winsys *)iws; -} - -struct intel_drm_winsys * intel_drm_winsys_create(int fd, unsigned pci_id); -struct pipe_fence_handle * intel_drm_fence_create(drm_intel_bo *bo); - -void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws); -void intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws); -void intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws); - - -/* - * Buffer - */ - - -struct intel_drm_buffer { - unsigned magic; - - drm_intel_bo *bo; - - void *ptr; - unsigned map_count; - boolean map_gtt; - - boolean flinked; - unsigned flink; -}; - -static INLINE struct intel_drm_buffer * -intel_drm_buffer(struct intel_buffer *buffer) -{ - return (struct intel_drm_buffer *)buffer; -} - -static INLINE drm_intel_bo * -intel_bo(struct intel_buffer *buffer) -{ - return intel_drm_buffer(buffer)->bo; -} - -#endif From 84a8347b9f6ef0c1b2519e9bd5fef2ce3c85afb7 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 00:18:30 +0100 Subject: [PATCH 373/483] draw: Use translate function instead of switch cases --- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 37 ++++-------------- src/gallium/auxiliary/draw/draw_pt_emit.c | 37 +++--------------- .../auxiliary/draw/draw_pt_fetch_emit.c | 39 ++++--------------- .../auxiliary/draw/draw_pt_fetch_shade_emit.c | 27 ++----------- src/gallium/auxiliary/draw/draw_vertex.c | 30 +++----------- src/gallium/auxiliary/draw/draw_vertex.h | 28 ++++++++++++- 6 files changed, 55 insertions(+), 143 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 27099579618..1c7db0005a9 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -238,38 +238,15 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim ) unsigned output_format; unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * sizeof(float) ); - switch (vbuf->vinfo->attrib[i].emit) { - case EMIT_4F: - output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - emit_sz = 4 * sizeof(float); - break; - case EMIT_3F: - output_format = PIPE_FORMAT_R32G32B32_FLOAT; - emit_sz = 3 * sizeof(float); - break; - case EMIT_2F: - output_format = PIPE_FORMAT_R32G32_FLOAT; - emit_sz = 2 * sizeof(float); - break; - case EMIT_1F: - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); - break; - case EMIT_1F_PSIZE: - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); + output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit); + emit_sz = draw_translate_vinfo_size(vbuf->vinfo->attrib[i].emit); + + /* doesn't handle EMIT_OMIT */ + assert(emit_sz != 0); + + if (vbuf->vinfo->attrib[i].emit == EMIT_1F_PSIZE) { src_buffer = 1; src_offset = 0; - break; - case EMIT_4UB: - output_format = PIPE_FORMAT_A8R8G8B8_UNORM; - emit_sz = 4 * sizeof(ubyte); - break; - default: - assert(0); - output_format = PIPE_FORMAT_NONE; - emit_sz = 0; - break; } hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL; diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index ae357b51226..a7917f54b04 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -86,40 +86,15 @@ void draw_pt_emit_prepare( struct pt_emit *emit, unsigned output_format; unsigned src_offset = (vinfo->attrib[i].src_index * 4 * sizeof(float) ); + output_format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit); - - switch (vinfo->attrib[i].emit) { - case EMIT_4F: - output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - emit_sz = 4 * sizeof(float); - break; - case EMIT_3F: - output_format = PIPE_FORMAT_R32G32B32_FLOAT; - emit_sz = 3 * sizeof(float); - break; - case EMIT_2F: - output_format = PIPE_FORMAT_R32G32_FLOAT; - emit_sz = 2 * sizeof(float); - break; - case EMIT_1F: - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); - break; - case EMIT_1F_PSIZE: - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); + /* doesn't handle EMIT_OMIT */ + assert(emit_sz != 0); + + if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) { src_buffer = 1; src_offset = 0; - break; - case EMIT_4UB: - output_format = PIPE_FORMAT_A8R8G8B8_UNORM; - emit_sz = 4 * sizeof(ubyte); - break; - default: - assert(0); - output_format = PIPE_FORMAT_NONE; - emit_sz = 0; - break; } hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 2a604470e9a..1994ddf2bcc 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -129,41 +129,16 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, unsigned input_offset = src->src_offset; unsigned output_format; - switch (vinfo->attrib[i].emit) { - case EMIT_4UB: - output_format = PIPE_FORMAT_R8G8B8A8_UNORM; - emit_sz = 4 * sizeof(unsigned char); - break; - case EMIT_4F: - output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - emit_sz = 4 * sizeof(float); - break; - case EMIT_3F: - output_format = PIPE_FORMAT_R32G32B32_FLOAT; - emit_sz = 3 * sizeof(float); - break; - case EMIT_2F: - output_format = PIPE_FORMAT_R32G32_FLOAT; - emit_sz = 2 * sizeof(float); - break; - case EMIT_1F: - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); - break; - case EMIT_1F_PSIZE: + output_format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit); + + if (vinfo->attrib[i].emit == EMIT_OMIT) + continue; + + if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) { input_format = PIPE_FORMAT_R32_FLOAT; input_buffer = draw->pt.nr_vertex_buffers; input_offset = 0; - output_format = PIPE_FORMAT_R32_FLOAT; - emit_sz = 1 * sizeof(float); - break; - case EMIT_OMIT: - continue; - default: - assert(0); - output_format = PIPE_FORMAT_NONE; - emit_sz = 0; - continue; } key.element[i].type = TRANSLATE_ELEMENT_NORMAL; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index 1aecb510777..389e2b105e5 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -130,31 +130,10 @@ static void fse_prepare( struct draw_pt_middle_end *middle, unsigned dst_offset = 0; for (i = 0; i < vinfo->num_attribs; i++) { - unsigned emit_sz = 0; + unsigned emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit); - switch (vinfo->attrib[i].emit) { - case EMIT_4F: - emit_sz = 4 * sizeof(float); - break; - case EMIT_3F: - emit_sz = 3 * sizeof(float); - break; - case EMIT_2F: - emit_sz = 2 * sizeof(float); - break; - case EMIT_1F: - emit_sz = 1 * sizeof(float); - break; - case EMIT_1F_PSIZE: - emit_sz = 1 * sizeof(float); - break; - case EMIT_4UB: - emit_sz = 4 * sizeof(ubyte); - break; - default: - assert(0); - break; - } + /* doesn't handle EMIT_OMIT */ + assert(emit_sz != 0); /* The elements in the key correspond to vertex shader output * numbers, not to positions in the hw vertex description -- diff --git a/src/gallium/auxiliary/draw/draw_vertex.c b/src/gallium/auxiliary/draw/draw_vertex.c index 3214213e445..18921ad7179 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.c +++ b/src/gallium/auxiliary/draw/draw_vertex.c @@ -48,30 +48,12 @@ draw_compute_vertex_size(struct vertex_info *vinfo) uint i; vinfo->size = 0; - for (i = 0; i < vinfo->num_attribs; i++) { - switch (vinfo->attrib[i].emit) { - case EMIT_OMIT: - break; - case EMIT_4UB: - /* fall-through */ - case EMIT_1F_PSIZE: - /* fall-through */ - case EMIT_1F: - vinfo->size += 1; - break; - case EMIT_2F: - vinfo->size += 2; - break; - case EMIT_3F: - vinfo->size += 3; - break; - case EMIT_4F: - vinfo->size += 4; - break; - default: - assert(0); - } - } + for (i = 0; i < vinfo->num_attribs; i++) + vinfo->size += draw_translate_vinfo_size(vinfo->attrib[i].emit); + + assert(vinfo->size % 4 == 0); + /* in dwords */ + vinfo->size /= 4; } diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h index 8c3c7befbc7..24c5a48b2ef 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.h +++ b/src/gallium/auxiliary/draw/draw_vertex.h @@ -141,9 +141,11 @@ void draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data); -static INLINE unsigned draw_translate_vinfo_format(unsigned format ) +static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit) { - switch (format) { + switch (emit) { + case EMIT_OMIT: + return PIPE_FORMAT_NONE; case EMIT_1F: case EMIT_1F_PSIZE: return PIPE_FORMAT_R32_FLOAT; @@ -156,9 +158,31 @@ static INLINE unsigned draw_translate_vinfo_format(unsigned format ) case EMIT_4UB: return PIPE_FORMAT_R8G8B8A8_UNORM; default: + assert(!"unexpected format"); return PIPE_FORMAT_NONE; } } +static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit) +{ + switch (emit) { + case EMIT_OMIT: + return 0; + case EMIT_1F: + case EMIT_1F_PSIZE: + return 1 * sizeof(float); + case EMIT_2F: + return 2 * sizeof(float); + case EMIT_3F: + return 3 * sizeof(float); + case EMIT_4F: + return 4 * sizeof(float); + case EMIT_4UB: + return 4 * sizeof(unsigned char); + default: + assert(!"unexpected format"); + return 0; + } +} #endif /* DRAW_VERTEX_H */ From fe306e7ea5e789adc955653d9be8cd7f8af47264 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 13:45:42 +0100 Subject: [PATCH 374/483] draw: Add EMIT_4UB_BGRA format Needed for i915g, also fixed swizzle in draw_vs_aos_io. --- src/gallium/auxiliary/draw/draw_vertex.c | 7 +++++++ src/gallium/auxiliary/draw/draw_vertex.h | 7 ++++++- src/gallium/auxiliary/draw/draw_vs_aos_io.c | 12 +++++------- src/gallium/drivers/i915/i915_prim_emit.c | 7 +++++++ src/gallium/drivers/i915/i915_state_derived.c | 4 ++-- src/gallium/drivers/nvfx/nvfx_draw.c | 6 ++++++ 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_vertex.c b/src/gallium/auxiliary/draw/draw_vertex.c index 18921ad7179..a4f5e882c0a 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.c +++ b/src/gallium/auxiliary/draw/draw_vertex.c @@ -102,6 +102,13 @@ draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data) debug_printf("%u ", *data++); debug_printf("%u ", *data++); break; + case EMIT_4UB_BGRA: + debug_printf("EMIT_4UB_BGRA:\t"); + debug_printf("%u ", *data++); + debug_printf("%u ", *data++); + debug_printf("%u ", *data++); + debug_printf("%u ", *data++); + break; default: assert(0); } diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h index 24c5a48b2ef..ca272371267 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.h +++ b/src/gallium/auxiliary/draw/draw_vertex.h @@ -54,7 +54,8 @@ enum attrib_emit { EMIT_2F, EMIT_3F, EMIT_4F, - EMIT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */ + EMIT_4UB, /**< is RGBA like the rest */ + EMIT_4UB_BGRA }; @@ -157,6 +158,8 @@ static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit) return PIPE_FORMAT_R32G32B32A32_FLOAT; case EMIT_4UB: return PIPE_FORMAT_R8G8B8A8_UNORM; + case EMIT_4UB_BGRA: + return PIPE_FORMAT_B8G8R8A8_UNORM; default: assert(!"unexpected format"); return PIPE_FORMAT_NONE; @@ -179,6 +182,8 @@ static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit) return 4 * sizeof(float); case EMIT_4UB: return 4 * sizeof(unsigned char); + case EMIT_4UB_BGRA: + return 4 * sizeof(unsigned char); default: assert(!"unexpected format"); return 0; diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_io.c b/src/gallium/auxiliary/draw/draw_vs_aos_io.c index ece1ddde0cb..8f8bbe7cb88 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos_io.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos_io.c @@ -401,13 +401,11 @@ static boolean emit_output( struct aos_compilation *cp, emit_store_R32G32B32A32(cp, ptr, dataXMM); break; case EMIT_4UB: - if (1) { - emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W)); - emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM); - } - else { - emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM); - } + emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM); + break; + case EMIT_4UB_BGRA: + emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W)); + emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM); break; default: AOS_ERROR(cp, "unhandled output format"); diff --git a/src/gallium/drivers/i915/i915_prim_emit.c b/src/gallium/drivers/i915/i915_prim_emit.c index d9a5c40ab97..dd997e2cf48 100644 --- a/src/gallium/drivers/i915/i915_prim_emit.c +++ b/src/gallium/drivers/i915/i915_prim_emit.c @@ -102,6 +102,13 @@ emit_hw_vertex( struct i915_context *i915, count += 4; break; case EMIT_4UB: + OUT_BATCH( pack_ub4(float_to_ubyte( attrib[0] ), + float_to_ubyte( attrib[1] ), + float_to_ubyte( attrib[2] ), + float_to_ubyte( attrib[3] )) ); + count += 1; + break; + case EMIT_4UB_BGRA: OUT_BATCH( pack_ub4(float_to_ubyte( attrib[2] ), float_to_ubyte( attrib[1] ), float_to_ubyte( attrib[0] ), diff --git a/src/gallium/drivers/i915/i915_state_derived.c b/src/gallium/drivers/i915/i915_state_derived.c index 0eb1e3f91a4..4da46772b5d 100644 --- a/src/gallium/drivers/i915/i915_state_derived.c +++ b/src/gallium/drivers/i915/i915_state_derived.c @@ -101,14 +101,14 @@ static void calculate_vertex_layout( struct i915_context *i915 ) /* primary color */ if (colors[0]) { src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 0); - draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src); + draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src); vinfo.hwfmt[0] |= S4_VFMT_COLOR; } /* secondary color */ if (colors[1]) { src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 1); - draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src); + draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src); vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG; } diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c index 5379b29efd1..68e50a36479 100644 --- a/src/gallium/drivers/nvfx/nvfx_draw.c +++ b/src/gallium/drivers/nvfx/nvfx_draw.c @@ -79,6 +79,12 @@ nvfx_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v) float_to_ubyte(v->data[idx][1]), float_to_ubyte(v->data[idx][2]), float_to_ubyte(v->data[idx][3]))); + case EMIT_4UB_BGRA: + BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1); + OUT_RING (chan, pack_ub4(float_to_ubyte(v->data[idx][2]), + float_to_ubyte(v->data[idx][1]), + float_to_ubyte(v->data[idx][0]), + float_to_ubyte(v->data[idx][3]))); break; default: assert(0); From 4980891252f35a2c87ef302b40d7536327a9babd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2010 10:10:37 -0700 Subject: [PATCH 375/483] intel: Respect src pitch in _mesa_copy_rect(). If a non-zero src_y was used, this would break piglit depth-level-clamp. (cherry picked from commit e1e48ea15c1fe448f0b69e086b66c1123dc98bb7) --- src/mesa/drivers/dri/intel/intel_regions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index f042bcbc28c..563baa36c46 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -316,7 +316,7 @@ _mesa_copy_rect(GLubyte * dst, dst += dst_x * cpp; src += src_x * cpp; dst += dst_y * dst_pitch; - src += src_y * dst_pitch; + src += src_y * src_pitch; width *= cpp; if (width == dst_pitch && width == src_pitch) From 57e793644f8b1c229703ac69ef2ee5d26cb282c9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 16:05:53 -0700 Subject: [PATCH 376/483] intel: Remove extra tiling setting after allocating a tiled region. (cherry picked from commit 32f143b4327521a058dc05f0ab9087a5696b9618) --- src/mesa/drivers/dri/intel/intel_regions.c | 11 +++-------- src/mesa/drivers/dri/intel/intel_regions.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 563baa36c46..9b075d22edc 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -164,7 +164,6 @@ intel_region_alloc_internal(struct intel_context *intel, /* Default to no tiling */ region->tiling = I915_TILING_NONE; - region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE; _DBG("%s <-- %p\n", __FUNCTION__, region); return region; @@ -194,12 +193,7 @@ intel_region_alloc(struct intel_context *intel, region = intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer); - - if (tiling != I915_TILING_NONE) { - assert(((pitch * cpp) & 127) == 0); - drm_intel_bo_set_tiling(buffer, &tiling, pitch * cpp); - drm_intel_bo_get_tiling(buffer, ®ion->tiling, ®ion->bit_6_swizzle); - } + region->tiling = tiling; return region; } @@ -213,6 +207,7 @@ intel_region_alloc_for_handle(struct intel_context *intel, struct intel_region *region, *dummy; dri_bo *buffer; int ret; + uint32_t bit_6_swizzle; region = _mesa_HashLookup(intel->intelScreen->named_regions, handle); if (region != NULL) { @@ -236,7 +231,7 @@ intel_region_alloc_for_handle(struct intel_context *intel, return region; ret = dri_bo_get_tiling(region->buffer, ®ion->tiling, - ®ion->bit_6_swizzle); + &bit_6_swizzle); if (ret != 0) { fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n", handle, name, strerror(-ret)); diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index 7ee6a988eae..af5e52f5df0 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -65,7 +65,6 @@ struct intel_region GLuint draw_x, draw_y; /**< Offset of drawing within the region */ uint32_t tiling; /**< Which tiling mode the region is in */ - uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */ struct intel_buffer_object *pbo; /* zero-copy uploads */ uint32_t name; /**< Global name for the bo */ From fdbe1ca0bd7451c8406795f829d661139d941f27 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 16:20:03 -0700 Subject: [PATCH 377/483] intel: Rely on allocated region pitch for the miptree pitch. Bug #26966: 945 miptree pitch disagreement with libdrm. (cherry picked from commit da011faf48155a5c02ebc1fe1fa20a4f54b8c657) --- src/mesa/drivers/dri/intel/intel_fbo.c | 9 ++------- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 13 ++----------- src/mesa/drivers/dri/intel/intel_regions.c | 8 ++------ src/mesa/drivers/dri/intel/intel_regions.h | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index a429f8d003d..ba3bb8fdba4 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -104,7 +104,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, struct intel_context *intel = intel_context(ctx); struct intel_renderbuffer *irb = intel_renderbuffer(rb); int cpp; - GLuint pitch; ASSERT(rb->Name != 0); @@ -176,15 +175,11 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, /* allocate new memory region/renderbuffer */ - /* Choose a pitch to match hardware requirements: - */ - pitch = ((cpp * width + 63) & ~63) / cpp; - /* alloc hardware renderbuffer */ - DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch); + DBG("Allocating %d x %d Intel RBO\n", width, height); irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp, - width, height, pitch, GL_TRUE); + width, height, GL_TRUE); if (!irb->region) return GL_FALSE; /* out of memory? */ diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 1b340afc6a5..9f51a3ee69a 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -146,8 +146,8 @@ intel_miptree_create(struct intel_context *intel, mt->cpp, mt->pitch, mt->total_height, - mt->pitch, expect_accelerated_upload); + mt->pitch = mt->region->pitch; if (!mt->region) { free(mt); @@ -177,20 +177,11 @@ intel_miptree_create_for_region(struct intel_context *intel, I915_TILING_NONE); if (!mt) return mt; -#if 0 - if (mt->pitch != region->pitch) { - fprintf(stderr, - "region pitch (%d) doesn't match mipmap tree pitch (%d)\n", - region->pitch, mt->pitch); - free(mt); - return NULL; - } -#else + /* The mipmap tree pitch is aligned to 64 bytes to make sure render * to texture works, but we don't need that for texturing from a * pixmap. Just override it here. */ mt->pitch = region->pitch; -#endif intel_region_reference(&mt->region, region); diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 9b075d22edc..193bbf6038b 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -172,7 +172,7 @@ intel_region_alloc_internal(struct intel_context *intel, struct intel_region * intel_region_alloc(struct intel_context *intel, uint32_t tiling, - GLuint cpp, GLuint width, GLuint height, GLuint pitch, + GLuint cpp, GLuint width, GLuint height, GLboolean expect_accelerated_upload) { dri_bo *buffer; @@ -186,13 +186,9 @@ intel_region_alloc(struct intel_context *intel, buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region", width, height, cpp, &tiling, &aligned_pitch, flags); - /* We've already chosen a pitch as part of miptree layout. It had - * better be the same. - */ - assert(aligned_pitch == pitch * cpp); region = intel_region_alloc_internal(intel, cpp, width, height, - pitch, buffer); + aligned_pitch / cpp, buffer); region->tiling = tiling; return region; diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index af5e52f5df0..e3dc1bad335 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -78,7 +78,7 @@ struct intel_region struct intel_region *intel_region_alloc(struct intel_context *intel, uint32_t tiling, GLuint cpp, GLuint width, - GLuint height, GLuint pitch, + GLuint height, GLboolean expect_accelerated_upload); struct intel_region * From 63fbae81e00964ccaf4c15d031893f5110b702a6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 24 Mar 2010 14:28:45 -0700 Subject: [PATCH 378/483] i965: Fix inversion for glCopyPixels to/from FBOs. fixes piglit fbo-copypix. (cherry picked from commit a589da14dee0c2a32e6e529f1a390b01a3ee4001) --- .../drivers/dri/intel/intel_mipmap_tree.c | 3 ++- src/mesa/drivers/dri/intel/intel_pixel_copy.c | 21 +++++++++---------- src/mesa/drivers/dri/intel/intel_regions.c | 8 ++++++- src/mesa/drivers/dri/intel/intel_regions.h | 1 + 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 9f51a3ee69a..5b6b4b26240 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -518,7 +518,8 @@ intel_miptree_image_copy(struct intel_context *intel, intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); success = intel_region_copy(intel, dst->region, 0, dst_x, dst_y, - src->region, 0, src_x, src_y, width, height, + src->region, 0, src_x, src_y, + width, height, GL_FALSE, GL_COPY); if (!success) { GLubyte *src_ptr, *dst_ptr; diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index 757f2f7d4db..56faf076c7e 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -116,6 +116,7 @@ do_blit_copypixels(GLcontext * ctx, GLint orig_dsty; GLint orig_srcx; GLint orig_srcy; + GLboolean flip = GL_FALSE; if (type == GL_DEPTH || type == GL_STENCIL) { if (INTEL_DEBUG & DEBUG_FALLBACKS) @@ -143,8 +144,6 @@ do_blit_copypixels(GLcontext * ctx, intelFlush(&intel->ctx); - /* XXX: We fail to handle different inversion between read and draw framebuffer. */ - /* Clip to destination buffer. */ orig_dstx = dstx; orig_dsty = dsty; @@ -167,23 +166,23 @@ do_blit_copypixels(GLcontext * ctx, dstx += srcx - orig_srcx; dsty += srcy - orig_srcy; - /* Convert from GL to hardware coordinates: */ + /* Flip dest Y if it's a window system framebuffer. */ if (fb->Name == 0) { - /* copypixels to a system framebuffer */ + /* copypixels to a window system framebuffer */ dsty = fb->Height - dsty - height; - } else { - /* copypixels to a user framebuffer object */ - dsty = dsty; + flip = !flip; } - /* Flip source Y if it's a system framebuffer. */ - if (read_fb->Name == 0) - srcy = fb->Height - srcy - height; + /* Flip source Y if it's a window system framebuffer. */ + if (read_fb->Name == 0) { + srcy = read_fb->Height - srcy - height; + flip = !flip; + } if (!intel_region_copy(intel, dst, 0, dstx, dsty, src, 0, srcx, srcy, - width, height, + width, height, flip, ctx->Color.ColorLogicOpEnabled ? ctx->Color.LogicOp : GL_COPY)) { DBG("%s: blit failure\n", __FUNCTION__); diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 193bbf6038b..1172de90b13 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -371,8 +371,11 @@ intel_region_copy(struct intel_context *intel, struct intel_region *src, GLuint src_offset, GLuint srcx, GLuint srcy, GLuint width, GLuint height, + GLboolean flip, GLenum logicop) { + uint32_t src_pitch = src->pitch; + _DBG("%s\n", __FUNCTION__); if (intel == NULL) @@ -388,9 +391,12 @@ intel_region_copy(struct intel_context *intel, assert(src->cpp == dst->cpp); + if (flip) + src_pitch = -src_pitch; + return intelEmitCopyBlit(intel, dst->cpp, - src->pitch, src->buffer, src_offset, src->tiling, + src_pitch, src->buffer, src_offset, src->tiling, dst->pitch, dst->buffer, dst_offset, dst->tiling, srcx, srcy, dstx, dsty, width, height, logicop); diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index e3dc1bad335..2459c9a924d 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -121,6 +121,7 @@ intel_region_copy(struct intel_context *intel, struct intel_region *src, GLuint src_offset, GLuint srcx, GLuint srcy, GLuint width, GLuint height, + GLboolean flip, GLenum logicop); /* Helpers for zerocopy uploads, particularly texture image uploads: From 77c30c5915acbb38fbc3e4d23414bcb2037c82a4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Mar 2010 13:23:23 -0700 Subject: [PATCH 379/483] i965: Fix readpixels from ReadBuffer != DrawBuffer. Fixes piglit fbo-readdrawpix. (cherry picked from commit 5782b2a968bb979b651e49bb5fc4162faa842050) --- src/mesa/drivers/dri/intel/intel_span.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index fb5c01bc4dc..377f3a8627e 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -48,11 +48,11 @@ intel_set_span_functions(struct intel_context *intel, #define LOCAL_VARS \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ - const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ - const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ + const GLint yScale = rb->Name ? 1 : -1; \ + const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ int minx = 0, miny = 0; \ - int maxx = ctx->DrawBuffer->Width; \ - int maxy = ctx->DrawBuffer->Height; \ + int maxx = rb->Width; \ + int maxy = rb->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ GLuint p; \ @@ -108,11 +108,11 @@ intel_set_span_functions(struct intel_context *intel, #define LOCAL_DEPTH_VARS \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ - const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ - const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ + const GLint yScale = rb->Name ? 1 : -1; \ + const GLint yBias = rb->Name ? 0 : rb->Height - 1; \ int minx = 0, miny = 0; \ - int maxx = ctx->DrawBuffer->Width; \ - int maxy = ctx->DrawBuffer->Height; \ + int maxx = rb->Width; \ + int maxy = rb->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ (void)buf; (void)pitch; /* unused for non-gttmap. */ \ From 87ac117d6717cca0b4d1452a7519a1baa962ebc1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Mar 2010 20:53:33 +0100 Subject: [PATCH 380/483] progs/gallium: Add trivial gallium demos --- progs/gallium/trivial/.gitignore | 3 + progs/gallium/trivial/Makefile | 44 ++++ progs/gallium/trivial/quad-tex.c | 346 +++++++++++++++++++++++++++++++ progs/gallium/trivial/tri.c | 278 +++++++++++++++++++++++++ 4 files changed, 671 insertions(+) create mode 100644 progs/gallium/trivial/.gitignore create mode 100644 progs/gallium/trivial/Makefile create mode 100644 progs/gallium/trivial/quad-tex.c create mode 100644 progs/gallium/trivial/tri.c diff --git a/progs/gallium/trivial/.gitignore b/progs/gallium/trivial/.gitignore new file mode 100644 index 00000000000..af6cdedbeba --- /dev/null +++ b/progs/gallium/trivial/.gitignore @@ -0,0 +1,3 @@ +tri +quad-tex +result.bmp diff --git a/progs/gallium/trivial/Makefile b/progs/gallium/trivial/Makefile new file mode 100644 index 00000000000..2b8af1ac06c --- /dev/null +++ b/progs/gallium/trivial/Makefile @@ -0,0 +1,44 @@ +# progs/gallium/simple/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +INCLUDES = \ + -I. \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/winsys \ + $(PROG_INCLUDES) + +LINKS = \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/winsys/sw/null/libws_null.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(GALLIUM_AUXILIARIES) \ + $(PROG_LINKS) + +SOURCES = \ + tri.c \ + quad-tex.c + +OBJECTS = $(SOURCES:.c=.o) + +PROGS = $(OBJECTS:.o=) + +##### TARGETS ##### + +default: $(PROGS) + +clean: + -rm -f $(PROGS) + -rm -f *.o + -rm -f result.bmp + +##### RULES ##### + +$(OBJECTS): %.o: %.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@ + +$(PROGS): %: %.o + $(CC) $(LDFLAGS) $< $(LINKS) -lm -lpthread -o $@ diff --git a/progs/gallium/trivial/quad-tex.c b/progs/gallium/trivial/quad-tex.c new file mode 100644 index 00000000000..553f5582e7e --- /dev/null +++ b/progs/gallium/trivial/quad-tex.c @@ -0,0 +1,346 @@ +/************************************************************************** + * + * Copyright © 2010 Jakob Bornecrantz + * + * 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 (including the next + * paragraph) 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 + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + **************************************************************************/ + + +#define USE_TRACE 0 +#define WIDTH 300 +#define HEIGHT 300 +#define NEAR 30 +#define FAR 1000 +#define FLIP 0 + +/* pipe_*_state structs */ +#include "pipe/p_state.h" +/* pipe_context */ +#include "pipe/p_context.h" +/* pipe_screen */ +#include "pipe/p_screen.h" +/* PIPE_* */ +#include "pipe/p_defines.h" +/* TGSI_SEMANTIC_{POSITION|GENERIC} */ +#include "pipe/p_shader_tokens.h" +/* pipe_buffer_* helpers */ +#include "util/u_inlines.h" + +/* constant state object helper */ +#include "cso_cache/cso_context.h" + +/* u_sampler_view_default_template */ +#include "util/u_sampler.h" +/* debug_dump_surface_bmp */ +#include "util/u_debug.h" +/* util_draw_vertex_buffer helper */ +#include "util/u_draw_quad.h" +/* FREE & CALLOC_STRUCT */ +#include "util/u_memory.h" +/* util_make_[fragment|vertex]_passthrough_shader */ +#include "util/u_simple_shaders.h" + +/* softpipe software driver */ +#include "softpipe/sp_public.h" + +/* null software winsys */ +#include "sw/null/null_sw_winsys.h" + +/* traceing support see src/gallium/drivers/trace/README for more info. */ +#if USE_TRACE +#include "trace/tr_screen.h" +#include "trace/tr_context.h" +#endif + +struct program +{ + struct pipe_screen *screen; + struct pipe_context *pipe; + struct cso_context *cso; + + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depthstencil; + struct pipe_rasterizer_state rasterizer; + struct pipe_sampler_state sampler; + struct pipe_viewport_state viewport; + struct pipe_framebuffer_state framebuffer; + struct pipe_vertex_element velem[2]; + + void *vs; + void *fs; + + float clear_color[4]; + + struct pipe_buffer *vbuf; + struct pipe_texture *target; + struct pipe_texture *tex; + struct pipe_sampler_view *view; +}; + +static void init_prog(struct program *p) +{ + /* create the software rasterizer */ + p->screen = softpipe_create_screen(null_sw_create()); +#if USE_TRACE + p->screen = trace_screen_create(p->screen); +#endif + p->pipe = p->screen->context_create(p->screen, NULL); + p->cso = cso_create_context(p->pipe); + + /* set clear color */ + p->clear_color[0] = 0.3; + p->clear_color[1] = 0.1; + p->clear_color[2] = 0.3; + p->clear_color[3] = 1.0; + + /* vertex buffer */ + { + float vertices[4][2][4] = { + { + { 0.9f, 0.9f, 0.0f, 1.0f }, + { 1.0f, 1.0f, 0.0f, 1.0f } + }, + { + { -0.9f, 0.9f, 0.0f, 1.0f }, + { 0.0f, 1.0f, 0.0f, 1.0f } + }, + { + { -0.9f, -0.9f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f, 1.0f } + }, + { + { 0.9f, -0.9f, 0.0f, 1.0f }, + { 1.0f, 0.0f, 1.0f, 1.0f } + } + }; + + p->vbuf = pipe_buffer_create(p->screen, 16, PIPE_BUFFER_USAGE_VERTEX, sizeof(vertices)); + pipe_buffer_write(p->screen, p->vbuf, 0, sizeof(vertices), vertices); + } + + /* render target texture */ + { + struct pipe_texture tmplt; + memset(&tmplt, 0, sizeof(tmplt)); + tmplt.target = PIPE_TEXTURE_2D; + tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */ + tmplt.width0 = WIDTH; + tmplt.height0 = HEIGHT; + tmplt.depth0 = 1; + tmplt.last_level = 0; + tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + p->target = p->screen->texture_create(p->screen, &tmplt); + } + + /* sampler texture */ + { + uint32_t *ptr; + struct pipe_transfer *t; + struct pipe_texture t_tmplt; + struct pipe_sampler_view v_tmplt; + + memset(&t_tmplt, 0, sizeof(t_tmplt)); + t_tmplt.target = PIPE_TEXTURE_2D; + t_tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */ + t_tmplt.width0 = 2; + t_tmplt.height0 = 2; + t_tmplt.depth0 = 1; + t_tmplt.last_level = 0; + t_tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + p->tex = p->screen->texture_create(p->screen, &t_tmplt); + + t = p->pipe->get_tex_transfer(p->pipe, p->tex, + 0, 0, 0, /* face, level, zslice */ + PIPE_TRANSFER_WRITE, + 0, 0, 2, 2); /* x, y, width, height */ + + ptr = p->pipe->transfer_map(p->pipe, t); + ptr[0] = 0xffff0000; + ptr[1] = 0xff0000ff; + ptr[2] = 0xff00ff00; + ptr[3] = 0xffffff00; + p->pipe->transfer_unmap(p->pipe, t); + + p->pipe->tex_transfer_destroy(p->pipe, t); + + u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format); + + p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt); + } + + /* disabled blending/masking */ + memset(&p->blend, 0, sizeof(p->blend)); + p->blend.rt[0].colormask = PIPE_MASK_RGBA; + + /* no-op depth/stencil/alpha */ + memset(&p->depthstencil, 0, sizeof(p->depthstencil)); + + /* rasterizer */ + memset(&p->rasterizer, 0, sizeof(p->rasterizer)); + p->rasterizer.front_winding = PIPE_WINDING_CW; + p->rasterizer.cull_mode = PIPE_WINDING_NONE; + p->rasterizer.gl_rasterization_rules = 1; + + /* sampler */ + memset(&p->sampler, 0, sizeof(p->sampler)); + p->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + p->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + p->sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; + p->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; + p->sampler.min_img_filter = PIPE_TEX_MIPFILTER_LINEAR; + p->sampler.mag_img_filter = PIPE_TEX_MIPFILTER_LINEAR; + p->sampler.normalized_coords = 1; + + /* drawing destination */ + memset(&p->framebuffer, 0, sizeof(p->framebuffer)); + p->framebuffer.width = WIDTH; + p->framebuffer.height = HEIGHT; + p->framebuffer.nr_cbufs = 1; + p->framebuffer.cbufs[0] = p->screen->get_tex_surface(p->screen, p->target, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); + + /* viewport, depth isn't really needed */ + { + float x = 0; + float y = 0; + float z = FAR; + float half_width = (float)WIDTH / 2.0f; + float half_height = (float)HEIGHT / 2.0f; + float half_depth = ((float)FAR - (float)NEAR) / 2.0f; + float scale, bias; + + if (FLIP) { + scale = -1.0f; + bias = (float)HEIGHT; + } else { + scale = 1.0f; + bias = 0.0f; + } + + p->viewport.scale[0] = half_width; + p->viewport.scale[1] = half_height * scale; + p->viewport.scale[2] = half_depth; + p->viewport.scale[3] = 1.0f; + + p->viewport.translate[0] = half_width + x; + p->viewport.translate[1] = (half_height + y) * scale + bias; + p->viewport.translate[2] = half_depth + z; + p->viewport.translate[3] = 0.0f; + } + + /* vertex elements state */ + memset(p->velem, 0, sizeof(p->velem)); + p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ + p->velem[0].instance_divisor = 0; + p->velem[0].vertex_buffer_index = 0; + p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ + p->velem[1].instance_divisor = 0; + p->velem[1].vertex_buffer_index = 0; + p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + /* vertex shader */ + { + const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, + TGSI_SEMANTIC_GENERIC }; + const uint semantic_indexes[] = { 0, 0 }; + p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes); + } + + /* fragment shader */ + p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D); +} + +static void close_prog(struct program *p) +{ + /* unset bound textures as well */ + cso_set_fragment_sampler_views(p->cso, 0, NULL); + + /* unset all state */ + cso_release_all(p->cso); + + p->pipe->delete_vs_state(p->pipe, p->vs); + p->pipe->delete_fs_state(p->pipe, p->fs); + + pipe_surface_reference(&p->framebuffer.cbufs[0], NULL); + pipe_sampler_view_reference(&p->view, NULL); + pipe_texture_reference(&p->target, NULL); + pipe_texture_reference(&p->tex, NULL); + pipe_buffer_reference(&p->vbuf, NULL); + + cso_destroy_context(p->cso); + p->pipe->destroy(p->pipe); + p->screen->destroy(p->screen); + + FREE(p); +} + +static void draw(struct program *p) +{ + /* set the render target */ + cso_set_framebuffer(p->cso, &p->framebuffer); + + /* clear the render target */ + p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0); + + /* set misc state we care about */ + cso_set_blend(p->cso, &p->blend); + cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); + cso_set_rasterizer(p->cso, &p->rasterizer); + cso_set_viewport(p->cso, &p->viewport); + + /* sampler */ + cso_single_sampler(p->cso, 0, &p->sampler); + cso_single_sampler_done(p->cso); + + /* texture sampler view */ + cso_set_fragment_sampler_views(p->cso, 1, &p->view); + + /* shaders */ + cso_set_fragment_shader_handle(p->cso, p->fs); + cso_set_vertex_shader_handle(p->cso, p->vs); + + /* vertex element data */ + cso_set_vertex_elements(p->cso, 2, p->velem); + + util_draw_vertex_buffer(p->pipe, + p->vbuf, 0, + PIPE_PRIM_QUADS, + 4, /* verts */ + 2); /* attribs/vert */ + + p->pipe->flush(p->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + + debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); +} + +int main(int argc, char** argv) +{ + struct program *p = CALLOC_STRUCT(program); + + init_prog(p); + draw(p); + close_prog(p); + + return 0; +} diff --git a/progs/gallium/trivial/tri.c b/progs/gallium/trivial/tri.c new file mode 100644 index 00000000000..cae1bdb1b1c --- /dev/null +++ b/progs/gallium/trivial/tri.c @@ -0,0 +1,278 @@ +/************************************************************************** + * + * Copyright © 2010 Jakob Bornecrantz + * + * 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 (including the next + * paragraph) 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 + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + **************************************************************************/ + + +#define USE_TRACE 0 +#define WIDTH 300 +#define HEIGHT 300 +#define NEAR 30 +#define FAR 1000 +#define FLIP 0 + +/* pipe_*_state structs */ +#include "pipe/p_state.h" +/* pipe_context */ +#include "pipe/p_context.h" +/* pipe_screen */ +#include "pipe/p_screen.h" +/* PIPE_* */ +#include "pipe/p_defines.h" +/* TGSI_SEMANTIC_{POSITION|GENERIC} */ +#include "pipe/p_shader_tokens.h" +/* pipe_buffer_* helpers */ +#include "util/u_inlines.h" + +/* constant state object helper */ +#include "cso_cache/cso_context.h" + +/* debug_dump_surface_bmp */ +#include "util/u_debug.h" +/* util_draw_vertex_buffer helper */ +#include "util/u_draw_quad.h" +/* FREE & CALLOC_STRUCT */ +#include "util/u_memory.h" +/* util_make_[fragment|vertex]_passthrough_shader */ +#include "util/u_simple_shaders.h" + +/* softpipe software driver */ +#include "softpipe/sp_public.h" + +/* null software winsys */ +#include "sw/null/null_sw_winsys.h" + +/* traceing support see src/gallium/drivers/trace/README for more info. */ +#if USE_TRACE +#include "trace/tr_screen.h" +#include "trace/tr_context.h" +#endif + +struct program +{ + struct pipe_screen *screen; + struct pipe_context *pipe; + struct cso_context *cso; + + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depthstencil; + struct pipe_rasterizer_state rasterizer; + struct pipe_viewport_state viewport; + struct pipe_framebuffer_state framebuffer; + struct pipe_vertex_element velem[2]; + + void *vs; + void *fs; + + float clear_color[4]; + + struct pipe_buffer *vbuf; + struct pipe_texture *target; +}; + +static void init_prog(struct program *p) +{ + /* create the software rasterizer */ + p->screen = softpipe_create_screen(null_sw_create()); +#if USE_TRACE + p->screen = trace_screen_create(p->screen); +#endif + p->pipe = p->screen->context_create(p->screen, NULL); + p->cso = cso_create_context(p->pipe); + + /* set clear color */ + p->clear_color[0] = 0.3; + p->clear_color[1] = 0.1; + p->clear_color[2] = 0.3; + p->clear_color[3] = 1.0; + + /* vertex buffer */ + { + float vertices[4][2][4] = { + { + { 0.0f, -0.9f, 0.0f, 1.0f }, + { 1.0f, 0.0f, 0.0f, 1.0f } + }, + { + { -0.9f, 0.9f, 0.0f, 1.0f }, + { 0.0f, 1.0f, 0.0f, 1.0f } + }, + { + { 0.9f, 0.9f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f, 1.0f } + } + }; + + p->vbuf = pipe_buffer_create(p->screen, 16, PIPE_BUFFER_USAGE_VERTEX, sizeof(vertices)); + pipe_buffer_write(p->screen, p->vbuf, 0, sizeof(vertices), vertices); + } + + /* render target texture */ + { + struct pipe_texture tmplt; + memset(&tmplt, 0, sizeof(tmplt)); + tmplt.target = PIPE_TEXTURE_2D; + tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */ + tmplt.width0 = WIDTH; + tmplt.height0 = HEIGHT; + tmplt.depth0 = 1; + tmplt.last_level = 0; + tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + p->target = p->screen->texture_create(p->screen, &tmplt); + } + + /* disabled blending/masking */ + memset(&p->blend, 0, sizeof(p->blend)); + p->blend.rt[0].colormask = PIPE_MASK_RGBA; + + /* no-op depth/stencil/alpha */ + memset(&p->depthstencil, 0, sizeof(p->depthstencil)); + + /* rasterizer */ + memset(&p->rasterizer, 0, sizeof(p->rasterizer)); + p->rasterizer.front_winding = PIPE_WINDING_CW; + p->rasterizer.cull_mode = PIPE_WINDING_NONE; + p->rasterizer.gl_rasterization_rules = 1; + + /* drawing destination */ + memset(&p->framebuffer, 0, sizeof(p->framebuffer)); + p->framebuffer.width = WIDTH; + p->framebuffer.height = HEIGHT; + p->framebuffer.nr_cbufs = 1; + p->framebuffer.cbufs[0] = p->screen->get_tex_surface(p->screen, p->target, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); + + /* viewport, depth isn't really needed */ + { + float x = 0; + float y = 0; + float z = FAR; + float half_width = (float)WIDTH / 2.0f; + float half_height = (float)HEIGHT / 2.0f; + float half_depth = ((float)FAR - (float)NEAR) / 2.0f; + float scale, bias; + + if (FLIP) { + scale = -1.0f; + bias = (float)HEIGHT; + } else { + scale = 1.0f; + bias = 0.0f; + } + + p->viewport.scale[0] = half_width; + p->viewport.scale[1] = half_height * scale; + p->viewport.scale[2] = half_depth; + p->viewport.scale[3] = 1.0f; + + p->viewport.translate[0] = half_width + x; + p->viewport.translate[1] = (half_height + y) * scale + bias; + p->viewport.translate[2] = half_depth + z; + p->viewport.translate[3] = 0.0f; + } + + /* vertex elements state */ + memset(p->velem, 0, sizeof(p->velem)); + p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ + p->velem[0].instance_divisor = 0; + p->velem[0].vertex_buffer_index = 0; + p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ + p->velem[1].instance_divisor = 0; + p->velem[1].vertex_buffer_index = 0; + p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + /* vertex shader */ + { + const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, + TGSI_SEMANTIC_COLOR }; + const uint semantic_indexes[] = { 0, 0 }; + p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes); + } + + /* fragment shader */ + p->fs = util_make_fragment_passthrough_shader(p->pipe); +} + +static void close_prog(struct program *p) +{ + /* unset all state */ + cso_release_all(p->cso); + + p->pipe->delete_vs_state(p->pipe, p->vs); + p->pipe->delete_fs_state(p->pipe, p->fs); + + pipe_surface_reference(&p->framebuffer.cbufs[0], NULL); + pipe_texture_reference(&p->target, NULL); + pipe_buffer_reference(&p->vbuf, NULL); + + cso_destroy_context(p->cso); + p->pipe->destroy(p->pipe); + p->screen->destroy(p->screen); + + FREE(p); +} + +static void draw(struct program *p) +{ + /* set the render target */ + cso_set_framebuffer(p->cso, &p->framebuffer); + + /* clear the render target */ + p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0); + + /* set misc state we care about */ + cso_set_blend(p->cso, &p->blend); + cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); + cso_set_rasterizer(p->cso, &p->rasterizer); + cso_set_viewport(p->cso, &p->viewport); + + /* shaders */ + cso_set_fragment_shader_handle(p->cso, p->fs); + cso_set_vertex_shader_handle(p->cso, p->vs); + + /* vertex element data */ + cso_set_vertex_elements(p->cso, 2, p->velem); + + util_draw_vertex_buffer(p->pipe, + p->vbuf, 0, + PIPE_PRIM_TRIANGLES, + 3, /* verts */ + 2); /* attribs/vert */ + + p->pipe->flush(p->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + + debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); +} + +int main(int argc, char** argv) +{ + struct program *p = CALLOC_STRUCT(program); + + init_prog(p); + draw(p); + close_prog(p); + + return 0; +} From 8edf085c77c84c8b09762dab0dfd31fac51fe65d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Mar 2010 22:40:03 -0700 Subject: [PATCH 381/483] identity: Remove unnecessary header. --- src/gallium/drivers/identity/id_drm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/identity/id_drm.c b/src/gallium/drivers/identity/id_drm.c index 936ccc444a8..26920fed08d 100644 --- a/src/gallium/drivers/identity/id_drm.c +++ b/src/gallium/drivers/identity/id_drm.c @@ -31,7 +31,6 @@ #include "id_drm.h" #include "id_screen.h" #include "id_public.h" -#include "id_screen.h" #include "id_objects.h" struct identity_drm_api From b1e3e03d6703970e3dd8d751735af665ebd48589 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Mar 2010 22:51:08 -0700 Subject: [PATCH 382/483] rtasm: Fix typos in comments. --- src/gallium/auxiliary/rtasm/rtasm_x86sse.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h index f7612d416a0..319b836ffb1 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h +++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h @@ -102,7 +102,7 @@ enum sse_cc { #define cc_Z cc_E #define cc_NZ cc_NE -/* Begin/end/retreive function creation: +/* Begin/end/retrieve function creation: */ @@ -311,8 +311,8 @@ void x87_fucom( struct x86_function *p, struct x86_reg arg ); -/* Retreive a reference to one of the function arguments, taking into - * account any push/pop activity. Note - doesn't track explict +/* Retrieve a reference to one of the function arguments, taking into + * account any push/pop activity. Note - doesn't track explicit * manipulation of ESP by other instructions. */ struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ); From 1f19aba1ea461db7bbd10d05244eb12dfc31a046 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Fri, 26 Mar 2010 11:13:01 +0100 Subject: [PATCH 383/483] nv50: fix FACE semantic check in FP input slot assignments Fixes for instance noise with material shaders in FlightGear. --- src/gallium/drivers/nv50/nv50_program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index c857816b31a..d7e06c93272 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -3762,7 +3762,7 @@ nv50_program_tx_prep(struct nv50_pc *pc) p->cfg.in[n].hw = rid = aid; i = p->cfg.in[n].id; - if (p->info.input_semantic_name[n] == + if (p->info.input_semantic_name[i] == TGSI_SEMANTIC_FACE) { load_frontfacing(pc, &pc->attr[i * 4]); continue; From 38c7a01b6c220ad04c5754602673ad3cf36ad508 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 26 Mar 2010 04:15:53 -0700 Subject: [PATCH 384/483] Revert "r300g: add generating texture coordinates for point sprites (WIP)" This reverts commit cba6430524198a1bdcdeada03cbe946a454f3935. Breaks celestia with a hardlock. :T We really need to sit down and study texture stuffing further. --- src/gallium/drivers/r300/r300_context.c | 2 -- src/gallium/drivers/r300/r300_context.h | 13 ------- src/gallium/drivers/r300/r300_emit.c | 6 ---- src/gallium/drivers/r300/r300_state.c | 35 +------------------ src/gallium/drivers/r300/r300_state_derived.c | 5 +-- .../drivers/r300/r300_state_invariant.c | 13 +++++-- 6 files changed, 13 insertions(+), 61 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 4433dcff21a..4b470b2c6af 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -195,8 +195,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_setup_atoms(r300); - r300->sprite_coord_index = -1; - /* Open up the OQ BO. */ r300->oqbo = screen->buffer_create(screen, 4096, PIPE_BUFFER_USAGE_PIXEL, 4096); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 4bb385238ed..eb9178a2656 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -99,16 +99,6 @@ struct r300_rs_state { uint32_t line_stipple_value; /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */ uint32_t color_control; /* R300_GA_COLOR_CONTROL: 0x4278 */ uint32_t polygon_mode; /* R300_GA_POLY_MODE: 0x4288 */ - - /* Specifies top of Raster pipe specific enable controls, - * i.e. texture coordinates stuffing for points, lines, triangles */ - uint32_t stuffing_enable; /* R300_GB_ENABLE: 0x4008 */ - - /* Point sprites texture coordinates, 0: lower left, 1: upper right */ - float point_texcoord_left; /* R300_GA_POINT_S0: 0x4200 */ - float point_texcoord_bottom; /* R300_GA_POINT_T0: 0x4204 */ - float point_texcoord_right; /* R300_GA_POINT_S1: 0x4208 */ - float point_texcoord_top; /* R300_GA_POINT_T1: 0x420c */ }; struct r300_rs_block { @@ -387,9 +377,6 @@ struct r300_context { uint32_t zbuffer_bpp; /* Whether scissor is enabled. */ boolean scissor_enabled; - /* Point sprites texcoord index, -1 = unused. */ - int sprite_coord_index; - /* upload managers */ struct u_upload_mgr *upload_vb; struct u_upload_mgr *upload_ib; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 796e3eca5bf..92266ba669d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -614,12 +614,6 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config); OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, rs->line_stipple_value); OUT_CS_REG(R300_GA_POLY_MODE, rs->polygon_mode); - OUT_CS_REG(R300_GB_ENABLE, rs->stuffing_enable); - OUT_CS_REG_SEQ(R300_GA_POINT_S0, 4); - OUT_CS_32F(rs->point_texcoord_left); - OUT_CS_32F(rs->point_texcoord_bottom); - OUT_CS_32F(rs->point_texcoord_right); - OUT_CS_32F(rs->point_texcoord_top); END_CS; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 31e32114b60..8e9285419c3 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -714,7 +714,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe, { struct r300_screen* r300screen = r300_screen(pipe->screen); struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); - unsigned coord_index; /* Copy rasterizer state for Draw. */ rs->rs = *state; @@ -807,32 +806,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->color_control = R300_SHADE_MODEL_SMOOTH; } - /* Point sprites */ - if (state->sprite_coord_enable) { - coord_index = ffs(state->sprite_coord_enable)-1; - - SCREEN_DBG(r300screen, DBG_DRAW, - "r300: point sprite: shader coord=%d\n", coord_index); - - rs->stuffing_enable = - R300_GB_POINT_STUFF_ENABLE | - R300_GB_TEX_ST << (R300_GB_TEX0_SOURCE_SHIFT + (coord_index*2)); - - rs->point_texcoord_left = 0.0f; - rs->point_texcoord_right = 1.0f; - - switch (state->sprite_coord_mode) { - case PIPE_SPRITE_COORD_UPPER_LEFT: - rs->point_texcoord_top = 0.0f; - rs->point_texcoord_bottom = 1.0f; - break; - case PIPE_SPRITE_COORD_LOWER_LEFT: - rs->point_texcoord_top = 1.0f; - rs->point_texcoord_bottom = 0.0f; - break; - } - } - return (void*)rs; } @@ -842,7 +815,6 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) struct r300_context* r300 = r300_context(pipe); struct r300_rs_state* rs = (struct r300_rs_state*)state; boolean scissor_was_enabled = r300->scissor_enabled; - int last_sprite_coord_index = r300->sprite_coord_index; if (r300->draw) { draw_flush(r300->draw); @@ -852,22 +824,17 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; r300->scissor_enabled = rs->rs.scissor; - r300->sprite_coord_index = ffs(rs->rs.sprite_coord_enable)-1; } else { r300->polygon_offset_enabled = FALSE; r300->scissor_enabled = FALSE; - r300->sprite_coord_index = -1; } UPDATE_STATE(state, r300->rs_state); - r300->rs_state.size = 24 + (r300->polygon_offset_enabled ? 5 : 0); + r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0); if (scissor_was_enabled != r300->scissor_enabled) { r300->scissor_state.dirty = TRUE; } - if (last_sprite_coord_index != r300->sprite_coord_index) { - r300->rs_block_state.dirty = TRUE; - } } /* Free rasterizer state. */ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 8178d55dc9a..3560b6e427f 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -178,8 +178,7 @@ static void r300_update_rs_block(struct r300_context* r300, /* Rasterize texture coordinates. */ for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED || - r300->sprite_coord_index == i) { + if (vs_outputs->generic[i] != ATTR_UNUSED) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ rX00_rs_tex(&rs, tex_count, tex_count, FALSE); @@ -187,8 +186,6 @@ static void r300_update_rs_block(struct r300_context* r300, /* Write it to the FS input register if it's used by the FS. */ if (fs_inputs->generic[i] != ATTR_UNUSED) { rX00_rs_tex_write(&rs, tex_count, fp_offset); - if (r300->sprite_coord_index == i) - debug_printf("r300: SpriteCoord (generic index %i) is being written to reg %i\n", i, fp_offset); fp_offset++; } tex_count++; diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 2d9a63d29a4..4a2c68269b1 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -44,9 +44,13 @@ void r300_emit_invariant_state(struct r300_context* r300, struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); - BEGIN_CS(12 + (caps->has_tcl ? 2: 0)); + BEGIN_CS(14 + (caps->has_tcl ? 2: 0)); /*** Graphics Backend (GB) ***/ + /* Various GB enables */ + OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE | + R300_GB_LINE_STUFF_ENABLE | + R300_GB_TRIANGLE_STUFF_ENABLE); /* Subpixel multisampling for AA * These are commented out because glisse's CS checker doesn't like them. * I presume these will be re-enabled later. @@ -74,7 +78,7 @@ void r300_emit_invariant_state(struct r300_context* r300, END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(40 + (caps->has_tcl ? 7 : 0) + + BEGIN_CS(44 + (caps->has_tcl ? 7 : 0) + (caps->family >= CHIP_FAMILY_RV350 ? 4 : 0)); if (caps->has_tcl) { @@ -86,6 +90,11 @@ void r300_emit_invariant_state(struct r300_context* r300, OUT_CS_32F(1.0); OUT_CS_32F(1.0); } + /* XXX point tex stuffing */ + OUT_CS_REG_SEQ(R300_GA_POINT_S0, 1); + OUT_CS_32F(0.0); + OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1); + OUT_CS_32F(1.0); /* XXX line tex stuffing */ OUT_CS_REG_SEQ(R300_GA_LINE_S0, 1); OUT_CS_32F(0.0); From b6df7aed60189d5f28a139c6fe351022ca2907a4 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 26 Mar 2010 05:24:44 -0700 Subject: [PATCH 385/483] r300/compiler: Lower CMP for vertex programs. I think my maths is right? --- .../dri/r300/compiler/radeon_program_alu.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c index b5c08aea49e..f5b7d57eab7 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c @@ -506,6 +506,46 @@ static void transform_r300_vertex_ABS(struct radeon_compiler* c, inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW; } +static void transform_r300_vertex_CMP(struct radeon_compiler* c, + struct rc_instruction* inst) +{ + /* There is no decent CMP available, so let's rig one up. + * CMP is defined as dst = src0 < 0.0 ? src1 : src2 + * The following sequence consumes two temps and three extra slots, + * but should be equivalent: + * + * SLT tmp0, src0, 0.0 + * SGE tmp1, src0, 0.0 + * MUL tmp0, tmp0, src1 + * MAD dst, src2, tmp1, tmp0 + * + * Yes, I know, I'm a mad scientist. ~ C. */ + int tempreg0 = rc_find_free_temporary(c); + int tempreg1 = rc_find_free_temporary(c); + + /* SLT tmp0, src0, 0.0 */ + emit2(c, inst->Prev, RC_OPCODE_SLT, 0, + dstreg(RC_FILE_TEMPORARY, tempreg0), + inst->U.I.SrcReg[0], builtin_zero); + + /* SGE tmp1, src0, 0.0 */ + emit2(c, inst->Prev, RC_OPCODE_SGE, 0, + dstreg(RC_FILE_TEMPORARY, tempreg1), + inst->U.I.SrcReg[0], builtin_zero); + + /* MUL tmp0, tmp0, src1 */ + emit2(c, inst->Prev, RC_OPCODE_MUL, 0, + dstreg(RC_FILE_TEMPORARY, tempreg0), + srcreg(RC_FILE_TEMPORARY, tempreg0), inst->U.I.SrcReg[1]); + + /* MAD dst, src2, tmp1, tmp0 */ + emit3(c, inst->Prev, RC_OPCODE_MAD, inst->U.I.SaturateMode, + inst->U.I.DstReg, + inst->U.I.SrcReg[2], srcreg(RC_FILE_TEMPORARY, tempreg1), srcreg(RC_FILE_TEMPORARY, tempreg0)); + + rc_remove_instruction(inst); +} + /** * For use with radeonLocalTransform, this transforms non-native ALU * instructions of the r300 up to r500 vertex engine. @@ -517,6 +557,7 @@ int r300_transform_vertex_alu( { switch(inst->U.I.Opcode) { case RC_OPCODE_ABS: transform_r300_vertex_ABS(c, inst); return 1; + case RC_OPCODE_CMP: transform_r300_vertex_CMP(c, inst); return 1; case RC_OPCODE_DP3: transform_DP3(c, inst); return 1; case RC_OPCODE_DPH: transform_DPH(c, inst); return 1; case RC_OPCODE_FLR: transform_FLR(c, inst); return 1; From ff0987a15da31a56c77f9a80c170e009f6056f33 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Fri, 26 Mar 2010 11:02:03 +0100 Subject: [PATCH 386/483] svga: Fix typo in configure script Introduced in a82e37b9e9e34175b7542d0c9b4e462833eab202 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index caa2cf65766..f2e87f4d4c2 100644 --- a/configure.ac +++ b/configure.ac @@ -1344,7 +1344,7 @@ AC_ARG_ENABLE([gallium-svga], [enable_gallium_svga="$enableval"], [enable_gallium_svga=auto]) if test "x$enable_gallium_svga" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga/drm" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" gallium_check_st "svga/drm" "dri-vmwgfx" "egl-vmwgfx" "xorg-vmwgfx" elif test "x$enable_gallium_svga" = xauto; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga" From fb70f456fce6b9cca9330e1c1e174153e532693e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 26 Mar 2010 14:32:56 +0100 Subject: [PATCH 387/483] svga/drm: Fix build under scons --- src/gallium/winsys/svga/drm/vmw_screen_dri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c index 657544dcb21..e8ebe9ac893 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c +++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c @@ -39,7 +39,7 @@ #include #include -#include +#include "vmwgfx_drm.h" #include #include From 711529153c797b4169fd5bbba79b370a2f38a0e9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 26 Mar 2010 14:19:48 +0100 Subject: [PATCH 388/483] gallium: Fix DRI driver build warnings under scons When building more then one dri driver we would get warnings because we where defining the same build target multiple times. Also move all the dri scons targets related code into its own file. --- src/gallium/targets/SConscript | 66 +----------------- src/gallium/targets/SConscript.dri | 79 ++++++++++++++++++++++ src/gallium/targets/dri-i915/SConscript | 7 +- src/gallium/targets/dri-i915/dummy.c | 0 src/gallium/targets/dri-i965/SConscript | 13 ++-- src/gallium/targets/dri-i965/dummy.c | 0 src/gallium/targets/dri-radeong/SConscript | 15 +++- src/gallium/targets/dri-radeong/dummy.c | 0 src/gallium/targets/dri-vmwgfx/SConscript | 24 +++---- src/gallium/targets/dri-vmwgfx/dummy.c | 0 10 files changed, 117 insertions(+), 87 deletions(-) create mode 100644 src/gallium/targets/SConscript.dri create mode 100644 src/gallium/targets/dri-i915/dummy.c create mode 100644 src/gallium/targets/dri-i965/dummy.c create mode 100644 src/gallium/targets/dri-radeong/dummy.c create mode 100644 src/gallium/targets/dri-vmwgfx/dummy.c diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index a41496a5dd9..747e64508f7 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -1,9 +1,4 @@ Import('*') - -#if env['dri']: -# SConscript([ -# 'drm/SConscript', -# ]) if 'xlib' in env['winsys']: SConscript([ @@ -16,67 +11,10 @@ if 'gdi' in env['winsys']: ]) if env['dri']: - drienv = env.Clone() - - drienv.Replace(CPPPATH = [ - '#src/mesa/drivers/dri/common', - '#include', - '#include/GL/internal', - '#src/gallium/include', - '#src/gallium/auxiliary', - '#src/gallium/drivers', - '#src/mesa', - '#src/mesa/main', - '#src/mesa/glapi', - '#src/mesa/math', - '#src/mesa/transform', - '#src/mesa/shader', - '#src/mesa/swrast', - '#src/mesa/swrast_setup', - '#src/egl/main', - '#src/egl/drivers/dri', + SConscript([ + 'SConscript.dri' ]) - drienv.ParseConfig('pkg-config --cflags --libs libdrm') - - COMMON_GALLIUM_SOURCES = [ - '#src/mesa/drivers/dri/common/utils.c', - '#src/mesa/drivers/dri/common/vblank.c', - '#src/mesa/drivers/dri/common/dri_util.c', - '#src/mesa/drivers/dri/common/xmlconfig.c', - ] - - COMMON_BM_SOURCES = [ - '#src/mesa/drivers/dri/common/dri_bufmgr.c', - '#src/mesa/drivers/dri/common/dri_drmpool.c', - ] - - Export([ - 'drienv', - 'COMMON_GALLIUM_SOURCES', - 'COMMON_BM_SOURCES', - ]) - - if 'vmware' in env['winsys']: - SConscript([ - 'dri-vmwgfx/SConscript', - ]) - - if 'i915' in env['winsys']: - SConscript([ - 'dri-i915/SConscript', - ]) - - if 'i965' in env['winsys']: - SConscript([ - 'dri-i965/SConscript', - ]) - - if 'radeon' in env['winsys']: - SConscript([ - 'dri-radeong/SConscript', - ]) - if 'xorg' in env['statetrackers']: if 'vmware' in env['winsys']: SConscript([ diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri new file mode 100644 index 00000000000..62192405807 --- /dev/null +++ b/src/gallium/targets/SConscript.dri @@ -0,0 +1,79 @@ +################################### +# SConcscript file for dri targets + +Import('*') + +drienv = env.Clone() + +drienv.Replace(CPPPATH = [ + '#src/mesa/drivers/dri/common', + '#include', + '#include/GL/internal', + '#src/gallium/include', + '#src/gallium/auxiliary', + '#src/gallium/drivers', + '#src/mesa', + '#src/mesa/main', + '#src/mesa/glapi', + '#src/mesa/math', + '#src/mesa/transform', + '#src/mesa/shader', + '#src/mesa/swrast', + '#src/mesa/swrast_setup', + '#src/egl/main', + '#src/egl/drivers/dri', +]) + +drienv.ParseConfig('pkg-config --cflags --libs libdrm') + +dri_common_utils = drienv.SharedObject( + target = 'utils.o', + source = '#src/mesa/drivers/dri/common/utils.c' +) + +dri_common_xmlconfig = drienv.SharedObject( + target = 'xmlconfig.o', + source = '#src/mesa/drivers/dri/common/xmlconfig.c' +) + +dri_common_vblank = drienv.SharedObject( + target = 'vblank.o', + source = '#src/mesa/drivers/dri/common/vblank.c' +) + +dri_common_dri_util = drienv.SharedObject( + target = 'dri_util.o', + source = '#src/mesa/drivers/dri/common/dri_util.c' +) + +COMMON_DRI_DRM_OBJECTS = [ + dri_common_utils, + dri_common_xmlconfig, + dri_common_vblank, + dri_common_dri_util, +] + +Export([ + 'drienv', + 'COMMON_DRI_DRM_OBJECTS', +]) + +if 'vmware' in env['winsys']: + SConscript([ + 'dri-vmwgfx/SConscript', + ]) + +if 'i915' in env['winsys']: + SConscript([ + 'dri-i915/SConscript', + ]) + +if 'i965' in env['winsys']: + SConscript([ + 'dri-i965/SConscript', + ]) + +if 'radeon' in env['winsys']: + SConscript([ + 'dri-radeong/SConscript', + ]) diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript index f6d1f934783..2fcc8028f12 100644 --- a/src/gallium/targets/dri-i915/SConscript +++ b/src/gallium/targets/dri-i915/SConscript @@ -15,11 +15,12 @@ env.Prepend(LIBS = [ trace, mesa, glsl, - gallium + gallium, + COMMON_DRI_DRM_OBJECTS ]) env.LoadableModule( - target ='i915_dri.so', - source = COMMON_GALLIUM_SOURCES, + target = 'i915_dri.so', + source = 'dummy.c', SHLIBPREFIX = '', ) diff --git a/src/gallium/targets/dri-i915/dummy.c b/src/gallium/targets/dri-i915/dummy.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript index 3b37d8e1af4..eb9e6cd172a 100644 --- a/src/gallium/targets/dri-i965/SConscript +++ b/src/gallium/targets/dri-i965/SConscript @@ -8,16 +8,19 @@ env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_intel') -drivers = [ +env.Prepend(LIBS = [ st_dri, i965drm, i965, trace, -] + mesa, + glsl, + gallium, + COMMON_DRI_DRM_OBJECTS +]) env.LoadableModule( - target ='i965_dri.so', - source = COMMON_GALLIUM_SOURCES, - LIBS = drivers + mesa + gallium + env['LIBS'], + target = 'i965_dri.so', + source = 'dummy.c', SHLIBPREFIX = '', ) diff --git a/src/gallium/targets/dri-i965/dummy.c b/src/gallium/targets/dri-i965/dummy.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript index 239d29ace18..d926c272889 100644 --- a/src/gallium/targets/dri-radeong/SConscript +++ b/src/gallium/targets/dri-radeong/SConscript @@ -8,10 +8,19 @@ env = drienv.Clone() env.ParseConfig('pkg-config --cflags --libs libdrm_radeon') -drivers = r300 + trace + softpipe +env.Prepend(LIBS = [ + st_dri, + radeonwinsys, + r300, + trace, + mesa, + glsl, + gallium, + COMMON_DRI_DRM_OBJECTS +]) env.SharedLibrary( target ='radeon_dri.so', - source = COMMON_GALLIUM_SOURCES, - LIBS = st_dri + radeonwinsys + mesa + glsl + drivers + gallium + env['LIBS'], + source = 'dummy.c', + SHLIBPREFIX = '', ) diff --git a/src/gallium/targets/dri-radeong/dummy.c b/src/gallium/targets/dri-radeong/dummy.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript index 7d248e8a9ce..6a1f8827bc3 100644 --- a/src/gallium/targets/dri-vmwgfx/SConscript +++ b/src/gallium/targets/dri-vmwgfx/SConscript @@ -6,19 +6,19 @@ if not 'svga' in env['drivers']: env = drienv.Clone() -drivers = [ - trace, - st_dri, - svgadrm, - svga, - mesa, - glsl, - gallium, -] +env.Prepend(LIBS = [ + st_dri, + svgadrm, + svga, + trace, + mesa, + glsl, + gallium, + COMMON_DRI_DRM_OBJECTS +]) env.LoadableModule( - target ='vmwgfx_dri.so', - source = COMMON_GALLIUM_SOURCES, - LIBS = drivers + mesa + gallium + env['LIBS'], + target = 'vmwgfx_dri.so', + source = 'dummy.c', SHLIBPREFIX = '', ) diff --git a/src/gallium/targets/dri-vmwgfx/dummy.c b/src/gallium/targets/dri-vmwgfx/dummy.c new file mode 100644 index 00000000000..e69de29bb2d From 7f91f2efb5b92a9ad8506c54643142f40f286d5c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 26 Mar 2010 14:45:36 +0100 Subject: [PATCH 389/483] swrastg: Build with scons --- src/gallium/state_trackers/dri/SConscript | 1 + src/gallium/state_trackers/dri/sw/SConscript | 29 ++++++++++++++++++ src/gallium/targets/SConscript.dri | 17 +++++++++++ src/gallium/targets/dri-swrast/SConscript | 32 ++++++++++++++++++++ src/gallium/winsys/SConscript | 4 +++ src/gallium/winsys/sw/dri/SConscript | 23 ++++++++++++++ 6 files changed, 106 insertions(+) create mode 100644 src/gallium/state_trackers/dri/sw/SConscript create mode 100644 src/gallium/targets/dri-swrast/SConscript create mode 100644 src/gallium/winsys/sw/dri/SConscript diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index b4a276cf29d..aba60fb8c5b 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -1,5 +1,6 @@ Import('*') SConscript([ + 'sw/SConscript', 'drm/SConscript', ]) diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript new file mode 100644 index 00000000000..0614b8f521f --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -0,0 +1,29 @@ +####################################################################### +# SConscript for dri state_tracker + +Import('*') + +if env['dri']: + + env = env.Clone() + + env.Append(CPPPATH = [ + '#/src/mesa', + '#/src/gallium/state_trackers/dri/common', + '#/src/mesa/drivers/dri/common', + ]) + + env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')]) + + st_drisw = env.ConvenienceLibrary( + target = 'st_drisw', + source = [ 'dri_context.c', + 'dri_drawable.c', + 'dri_extensions.c', + 'dri_screen.c', + 'dri_st_api.c', + 'dri1_helper.c', + 'drisw.c', + ] + ) + Export('st_drisw') diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri index 62192405807..210af13720a 100644 --- a/src/gallium/targets/SConscript.dri +++ b/src/gallium/targets/SConscript.dri @@ -46,6 +46,18 @@ dri_common_dri_util = drienv.SharedObject( source = '#src/mesa/drivers/dri/common/dri_util.c' ) +dri_common_drisw_util = drienv.SharedObject( + target = 'drisw_util.o', + source = '#src/mesa/drivers/dri/common/drisw_util.c' +) + + +COMMON_DRI_SW_OBJECTS = [ + dri_common_utils, + dri_common_xmlconfig, + dri_common_drisw_util, +] + COMMON_DRI_DRM_OBJECTS = [ dri_common_utils, dri_common_xmlconfig, @@ -55,9 +67,14 @@ COMMON_DRI_DRM_OBJECTS = [ Export([ 'drienv', + 'COMMON_DRI_SW_OBJECTS', 'COMMON_DRI_DRM_OBJECTS', ]) +SConscript([ + 'dri-swrast/SConscript', +]) + if 'vmware' in env['winsys']: SConscript([ 'dri-vmwgfx/SConscript', diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript new file mode 100644 index 00000000000..e9f742c43ce --- /dev/null +++ b/src/gallium/targets/dri-swrast/SConscript @@ -0,0 +1,32 @@ +Import('*') + +if not 'softpipe' in env['drivers']: + print 'warning: softpipe driver not built skipping swrastg_dri.so' + Return() + +env = drienv.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/winsys/sw/dri', +]) + +env.Prepend(LIBS = [ + st_drisw, + ws_dri, + softpipe, + trace, + mesa, + glsl, + gallium, + COMMON_DRI_SW_OBJECTS +]) + +swrastg_sources = [ + 'swrast_drm_api.c' +] + +env.LoadableModule( + target ='swrastg_dri.so', + source = swrastg_sources, + SHLIBPREFIX = '', +) diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 3e7052c0e6f..2013ee97c1c 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -11,6 +11,10 @@ if 'gdi' in env['winsys']: ]) if env['dri']: + SConscript([ + 'sw/dri/SConscript', + ]) + if 'vmware' in env['winsys']: SConscript([ 'svga/drm/SConscript', diff --git a/src/gallium/winsys/sw/dri/SConscript b/src/gallium/winsys/sw/dri/SConscript new file mode 100644 index 00000000000..b255d725f95 --- /dev/null +++ b/src/gallium/winsys/sw/dri/SConscript @@ -0,0 +1,23 @@ +####################################################################### +# SConscript for xlib winsys + + +Import('*') + +if env['platform'] == 'linux': + + env = env.Clone() + + env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', + ]) + + ws_dri = env.ConvenienceLibrary( + target = 'ws_dri', + source = [ + 'dri_sw_winsys.c', + ] + ) + Export('ws_dri') From e57405e8d516c09b890c6f1c3bd8fe7780417c95 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 26 Mar 2010 14:47:20 +0100 Subject: [PATCH 390/483] swrastg: Use llvmpipe if built but only on scons --- src/gallium/targets/dri-swrast/Makefile | 2 +- src/gallium/targets/dri-swrast/SConscript | 16 +++++++++--- .../targets/dri-swrast/swrast_drm_api.c | 25 +++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile index 3780da27550..fcfd690e438 100644 --- a/src/gallium/targets/dri-swrast/Makefile +++ b/src/gallium/targets/dri-swrast/Makefile @@ -3,7 +3,7 @@ include $(TOP)/configs/current LIBNAME = swrastg_dri.so -DRIVER_DEFINES = -D__NOT_HAVE_DRM_H +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \ diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript index e9f742c43ce..94ff99a0a90 100644 --- a/src/gallium/targets/dri-swrast/SConscript +++ b/src/gallium/targets/dri-swrast/SConscript @@ -1,7 +1,7 @@ Import('*') -if not 'softpipe' in env['drivers']: - print 'warning: softpipe driver not built skipping swrastg_dri.so' +if not set(('softpipe', 'llvmpipe')).intersection(env['drivers']): + print 'warning: no supported pipe driver: skipping build of swrastg_dri.so' Return() env = drienv.Clone() @@ -13,7 +13,6 @@ env.Append(CPPPATH = [ env.Prepend(LIBS = [ st_drisw, ws_dri, - softpipe, trace, mesa, glsl, @@ -21,6 +20,17 @@ env.Prepend(LIBS = [ COMMON_DRI_SW_OBJECTS ]) +if 'softpipe' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') + env.Prepend(LIBS = [softpipe]) + +if 'llvmpipe' in env['drivers']: + env.Tool('llvm') + if 'LLVM_VERSION' in env: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) + swrastg_sources = [ 'swrast_drm_api.c' ] diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 211836d784f..224651603d1 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -28,12 +28,18 @@ #include "pipe/p_compiler.h" #include "util/u_memory.h" - -#include "softpipe/sp_public.h" #include "state_tracker/drm_api.h" #include "state_tracker/sw_winsys.h" #include "dri_sw_winsys.h" +#ifdef GALLIUM_SOFTPIPE +#include "softpipe/sp_public.h" +#endif + +#ifdef GALLIUM_LLVMPIPE +#include "llvmpipe/lp_public.h" +#endif + static struct pipe_screen * swrast_create_screen(struct drm_api *api, int drmFD, @@ -57,15 +63,24 @@ swrast_create_screen(struct drm_api *api, if (winsys == NULL) return NULL; - screen = softpipe_create_screen( winsys ); - if (screen == NULL) +#ifdef GALLIUM_LLVMPIPE + if (!screen) + screen = llvmpipe_create_screen(winsys); +#endif + +#ifdef GALLIUM_SOFTPIPE + if (!screen) + screen = softpipe_create_screen(winsys); +#endif + + if (!screen) goto fail; return screen; fail: if (winsys) - winsys->destroy( winsys ); + winsys->destroy(winsys); return NULL; } From 22cd6f2cb4996de0a30c8f865f7011898ac8b8e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Mar 2010 10:08:52 -0600 Subject: [PATCH 391/483] mesa: only call _mesa_update_state() when necessary in glGet functions Only a few state vars require state validation before querying them. This potentially speeds up state queries. Encode that info into the state tuple table. Also, use the new tuple field to indicate when FLUSH_CURRENT() must be called to validate other state vars. Based on a patch submitted by Robert Bragg on Feb 12, 2010. --- src/mesa/main/get.c | 115 ++--- src/mesa/main/get_gen.py | 1021 ++++++++++++++++++++------------------ 2 files changed, 593 insertions(+), 543 deletions(-) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 523dc2e4f7e..266fda40ec5 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -77,9 +77,6 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - if (ctx->Driver.GetBooleanv && ctx->Driver.GetBooleanv(ctx, pname, params)) return; @@ -107,6 +104,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaBias); break; case GL_ALPHA_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.alphaBits); break; case GL_ALPHA_SCALE: @@ -167,6 +166,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueBias); break; case GL_BLUE_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.blueBits); break; case GL_BLUE_SCALE: @@ -221,27 +222,21 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.CullFaceMode); break; case GL_CURRENT_COLOR: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - } break; case GL_CURRENT_INDEX: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - } break; case GL_CURRENT_NORMAL: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - } break; case GL_CURRENT_RASTER_COLOR: params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[0]); @@ -334,10 +329,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = ENUM_TO_BOOLEAN(ctx->DrawBuffer->ColorDrawBuffer[0]); break; case GL_EDGE_FLAG: - { FLUSH_CURRENT(ctx, 0); params[0] = (ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0); - } break; case GL_FEEDBACK_BUFFER_SIZE: params[0] = INT_TO_BOOLEAN(ctx->Feedback.BufferSize); @@ -379,12 +372,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenBias); break; case GL_GREEN_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.greenBits); break; case GL_GREEN_SCALE: params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenScale); break; case GL_INDEX_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.indexBits); break; case GL_INDEX_CLEAR_VALUE: @@ -815,6 +812,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedBias); break; case GL_RED_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.redBits); break; case GL_RED_SCALE: @@ -1345,13 +1344,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: CHECK_EXT1(EXT_secondary_color, "GetBooleanv"); - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - } break; case GL_SECONDARY_COLOR_ARRAY_EXT: CHECK_EXT1(EXT_secondary_color, "GetBooleanv"); @@ -1371,10 +1368,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_CURRENT_FOG_COORDINATE_EXT: CHECK_EXT1(EXT_fog_coord, "GetBooleanv"); - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - } break; case GL_FOG_COORDINATE_ARRAY_EXT: CHECK_EXT1(EXT_fog_coord, "GetBooleanv"); @@ -1953,9 +1948,6 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - if (ctx->Driver.GetFloatv && ctx->Driver.GetFloatv(ctx, pname, params)) return; @@ -1983,6 +1975,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ctx->Pixel.AlphaBias; break; case GL_ALPHA_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLfloat)(ctx->DrawBuffer->Visual.alphaBits); break; case GL_ALPHA_SCALE: @@ -2043,6 +2037,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ctx->Pixel.BlueBias; break; case GL_BLUE_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLfloat)(ctx->DrawBuffer->Visual.blueBits); break; case GL_BLUE_SCALE: @@ -2097,27 +2093,21 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode); break; case GL_CURRENT_COLOR: - { FLUSH_CURRENT(ctx, 0); params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]; params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]; params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]; params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]; - } break; case GL_CURRENT_INDEX: - { FLUSH_CURRENT(ctx, 0); params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]; - } break; case GL_CURRENT_NORMAL: - { FLUSH_CURRENT(ctx, 0); params[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]; params[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]; params[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]; - } break; case GL_CURRENT_RASTER_COLOR: params[0] = ctx->Current.RasterColor[0]; @@ -2210,10 +2200,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(ctx->DrawBuffer->ColorDrawBuffer[0]); break; case GL_EDGE_FLAG: - { FLUSH_CURRENT(ctx, 0); params[0] = BOOLEAN_TO_FLOAT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - } break; case GL_FEEDBACK_BUFFER_SIZE: params[0] = (GLfloat)(ctx->Feedback.BufferSize); @@ -2255,12 +2243,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ctx->Pixel.GreenBias; break; case GL_GREEN_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLfloat)(ctx->DrawBuffer->Visual.greenBits); break; case GL_GREEN_SCALE: params[0] = ctx->Pixel.GreenScale; break; case GL_INDEX_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLfloat)(ctx->DrawBuffer->Visual.indexBits); break; case GL_INDEX_CLEAR_VALUE: @@ -2691,6 +2683,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ctx->Pixel.RedBias; break; case GL_RED_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLfloat)(ctx->DrawBuffer->Visual.redBits); break; case GL_RED_SCALE: @@ -3221,13 +3215,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: CHECK_EXT1(EXT_secondary_color, "GetFloatv"); - { FLUSH_CURRENT(ctx, 0); params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]; params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]; params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]; params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]; - } break; case GL_SECONDARY_COLOR_ARRAY_EXT: CHECK_EXT1(EXT_secondary_color, "GetFloatv"); @@ -3247,10 +3239,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_CURRENT_FOG_COORDINATE_EXT: CHECK_EXT1(EXT_fog_coord, "GetFloatv"); - { FLUSH_CURRENT(ctx, 0); params[0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - } break; case GL_FOG_COORDINATE_ARRAY_EXT: CHECK_EXT1(EXT_fog_coord, "GetFloatv"); @@ -3829,9 +3819,6 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - if (ctx->Driver.GetIntegerv && ctx->Driver.GetIntegerv(ctx, pname, params)) return; @@ -3859,6 +3846,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = IROUND(ctx->Pixel.AlphaBias); break; case GL_ALPHA_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = ctx->DrawBuffer->Visual.alphaBits; break; case GL_ALPHA_SCALE: @@ -3919,6 +3908,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = IROUND(ctx->Pixel.BlueBias); break; case GL_BLUE_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = ctx->DrawBuffer->Visual.blueBits; break; case GL_BLUE_SCALE: @@ -3973,27 +3964,21 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ENUM_TO_INT(ctx->Polygon.CullFaceMode); break; case GL_CURRENT_COLOR: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - } break; case GL_CURRENT_INDEX: - { FLUSH_CURRENT(ctx, 0); params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - } break; case GL_CURRENT_NORMAL: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - } break; case GL_CURRENT_RASTER_COLOR: params[0] = FLOAT_TO_INT(ctx->Current.RasterColor[0]); @@ -4086,10 +4071,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ENUM_TO_INT(ctx->DrawBuffer->ColorDrawBuffer[0]); break; case GL_EDGE_FLAG: - { FLUSH_CURRENT(ctx, 0); params[0] = BOOLEAN_TO_INT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - } break; case GL_FEEDBACK_BUFFER_SIZE: params[0] = ctx->Feedback.BufferSize; @@ -4131,12 +4114,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = IROUND(ctx->Pixel.GreenBias); break; case GL_GREEN_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = ctx->DrawBuffer->Visual.greenBits; break; case GL_GREEN_SCALE: params[0] = IROUND(ctx->Pixel.GreenScale); break; case GL_INDEX_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = ctx->DrawBuffer->Visual.indexBits; break; case GL_INDEX_CLEAR_VALUE: @@ -4567,6 +4554,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = IROUND(ctx->Pixel.RedBias); break; case GL_RED_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = ctx->DrawBuffer->Visual.redBits; break; case GL_RED_SCALE: @@ -5097,13 +5086,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: CHECK_EXT1(EXT_secondary_color, "GetIntegerv"); - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - } break; case GL_SECONDARY_COLOR_ARRAY_EXT: CHECK_EXT1(EXT_secondary_color, "GetIntegerv"); @@ -5123,10 +5110,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_CURRENT_FOG_COORDINATE_EXT: CHECK_EXT1(EXT_fog_coord, "GetIntegerv"); - { FLUSH_CURRENT(ctx, 0); params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - } break; case GL_FOG_COORDINATE_ARRAY_EXT: CHECK_EXT1(EXT_fog_coord, "GetIntegerv"); @@ -5706,9 +5691,6 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - if (ctx->Driver.GetInteger64v && ctx->Driver.GetInteger64v(ctx, pname, params)) return; @@ -5736,6 +5718,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.AlphaBias); break; case GL_ALPHA_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLint64)(ctx->DrawBuffer->Visual.alphaBits); break; case GL_ALPHA_SCALE: @@ -5796,6 +5780,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.BlueBias); break; case GL_BLUE_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLint64)(ctx->DrawBuffer->Visual.blueBits); break; case GL_BLUE_SCALE: @@ -5850,27 +5836,21 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Polygon.CullFaceMode); break; case GL_CURRENT_COLOR: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - } break; case GL_CURRENT_INDEX: - { FLUSH_CURRENT(ctx, 0); params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - } break; case GL_CURRENT_NORMAL: - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - } break; case GL_CURRENT_RASTER_COLOR: params[0] = FLOAT_TO_INT64(ctx->Current.RasterColor[0]); @@ -5963,10 +5943,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]); break; case GL_EDGE_FLAG: - { FLUSH_CURRENT(ctx, 0); params[0] = BOOLEAN_TO_INT64((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - } break; case GL_FEEDBACK_BUFFER_SIZE: params[0] = (GLint64)(ctx->Feedback.BufferSize); @@ -6008,12 +5986,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.GreenBias); break; case GL_GREEN_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLint64)(ctx->DrawBuffer->Visual.greenBits); break; case GL_GREEN_SCALE: params[0] = IROUND64(ctx->Pixel.GreenScale); break; case GL_INDEX_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLint64)(ctx->DrawBuffer->Visual.indexBits); break; case GL_INDEX_CLEAR_VALUE: @@ -6444,6 +6426,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.RedBias); break; case GL_RED_BITS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); params[0] = (GLint64)(ctx->DrawBuffer->Visual.redBits); break; case GL_RED_SCALE: @@ -6974,13 +6958,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: CHECK_EXT1(EXT_secondary_color, "GetInteger64v"); - { FLUSH_CURRENT(ctx, 0); params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - } break; case GL_SECONDARY_COLOR_ARRAY_EXT: CHECK_EXT1(EXT_secondary_color, "GetInteger64v"); @@ -7000,10 +6982,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_CURRENT_FOG_COORDINATE_EXT: CHECK_EXT1(EXT_fog_coord, "GetInteger64v"); - { FLUSH_CURRENT(ctx, 0); params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - } break; case GL_FOG_COORDINATE_ARRAY_EXT: CHECK_EXT1(EXT_fog_coord, "GetInteger64v"); @@ -7606,14 +7586,12 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - switch (pname) { case GL_BLEND: CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); + return; } params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); break; @@ -7621,6 +7599,7 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); + return; } params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); @@ -7641,14 +7620,12 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - switch (pname) { case GL_BLEND: CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); + return; } params[0] = ((ctx->Color.BlendEnabled >> index) & 1); break; @@ -7656,6 +7633,7 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); + return; } params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; @@ -7677,14 +7655,12 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) if (!params) return; - if (ctx->NewState) - _mesa_update_state(ctx); - switch (pname) { case GL_BLEND: CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); + return; } params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); break; @@ -7692,6 +7668,7 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); + return; } params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 0ef9d8fe94e..cecb86d76a1 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -49,123 +49,132 @@ TypeStrings = { } +NoState = None +NoExt = None +FlushCurrent = 1 + + # Each entry is a tuple of: # - the GL state name, such as GL_CURRENT_COLOR # - the state datatype, one of GLint, GLfloat, GLboolean or GLenum # - list of code fragments to get the state, such as ["ctx->Foo.Bar"] # - optional extra code or empty string. If present, "CONVERSION" will be # replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc. -# - optional extensions to check, or None +# - state flags: either NoExt, FlushCurrent or "_NEW_xxx" +# if NoExt, do nothing special +# if FlushCurrent, emit FLUSH_CURRENT() call +# if "_NEW_xxx", call _mesa_update_state() if that dirty state flag is set +# - optional extensions to check, or NoExt # StateVars = [ ( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"], - "", None ), + "", NoState, NoExt ), ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"], - "", None ), + "", NoState, NoExt ), ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"], - "", None ), + "", NoState, NoExt ), ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"], - "", None ), + "", NoState, NoExt ), ( "GL_ACCUM_CLEAR_VALUE", GLfloatN, [ "ctx->Accum.ClearColor[0]", "ctx->Accum.ClearColor[1]", "ctx->Accum.ClearColor[2]", "ctx->Accum.ClearColor[3]" ], - "", None ), - ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", None ), + "", NoState, NoExt ), + ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", NoState, NoExt ), ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"], - "", None ), - ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", None ), - ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ), - ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ), - ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ), - ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", None ), - ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ), + "", "_NEW_BUFFERS", NoExt ), + ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", NoState, NoExt ), + ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", NoState, NoExt ), + ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", NoState, NoExt ), + ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", NoState, NoExt ), + ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", NoState, NoExt ), + ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", NoState, NoExt ), ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"], - "", None ), - ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", None ), - ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ), - ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), - ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), - ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None ), - ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None ), - ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None ), - ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None), + "", NoState, NoExt ), + ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", NoState, NoExt ), + ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ), + ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ), + ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ), + ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ), + ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", NoState, NoExt ), + ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", NoState, NoExt ), + ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", NoState, NoExt), ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "], - "", None ), + "", NoState, NoExt ), ( "GL_BLEND_COLOR_EXT", GLfloatN, [ "ctx->Color.BlendColor[0]", "ctx->Color.BlendColor[1]", "ctx->Color.BlendColor[2]", - "ctx->Color.BlendColor[3]"], "", None ), - ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", None ), - ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ), - ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", None ), + "ctx->Color.BlendColor[3]"], "", NoState, NoExt ), + ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", NoState, NoExt ), + ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", "_NEW_BUFFERS", NoExt ), + ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", NoState, NoExt ), ( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint, - ["ctx->ClientAttribStackDepth"], "", None ), + ["ctx->ClientAttribStackDepth"], "", NoState, NoExt ), ( "GL_CLIP_PLANE0", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", NoState, NoExt ), ( "GL_CLIP_PLANE1", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", NoState, NoExt ), ( "GL_CLIP_PLANE2", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", NoState, NoExt ), ( "GL_CLIP_PLANE3", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", NoState, NoExt ), ( "GL_CLIP_PLANE4", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", NoState, NoExt ), ( "GL_CLIP_PLANE5", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ), + [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", NoState, NoExt ), ( "GL_COLOR_CLEAR_VALUE", GLfloatN, [ "ctx->Color.ClearColor[0]", "ctx->Color.ClearColor[1]", "ctx->Color.ClearColor[2]", - "ctx->Color.ClearColor[3]" ], "", None ), + "ctx->Color.ClearColor[3]" ], "", NoState, NoExt ), ( "GL_COLOR_MATERIAL", GLboolean, - ["ctx->Light.ColorMaterialEnabled"], "", None ), + ["ctx->Light.ColorMaterialEnabled"], "", NoState, NoExt ), ( "GL_COLOR_MATERIAL_FACE", GLenum, - ["ctx->Light.ColorMaterialFace"], "", None ), + ["ctx->Light.ColorMaterialFace"], "", NoState, NoExt ), ( "GL_COLOR_MATERIAL_PARAMETER", GLenum, - ["ctx->Light.ColorMaterialMode"], "", None ), + ["ctx->Light.ColorMaterialMode"], "", NoState, NoExt ), ( "GL_COLOR_WRITEMASK", GLint, [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0", "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0", "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0", - "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ), - ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ), - ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ), + "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", NoState, NoExt ), + ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", NoState, NoExt ), + ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", NoState, NoExt ), ( "GL_CURRENT_COLOR", GLfloatN, [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ], - "FLUSH_CURRENT(ctx, 0);", None ), + "", FlushCurrent, NoExt ), ( "GL_CURRENT_INDEX", GLfloat, [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]" ], - "FLUSH_CURRENT(ctx, 0);", None ), + "", FlushCurrent, NoExt ), ( "GL_CURRENT_NORMAL", GLfloatN, [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]", "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]", "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"], - "FLUSH_CURRENT(ctx, 0);", None ), + "", FlushCurrent, NoExt ), ( "GL_CURRENT_RASTER_COLOR", GLfloatN, ["ctx->Current.RasterColor[0]", "ctx->Current.RasterColor[1]", "ctx->Current.RasterColor[2]", - "ctx->Current.RasterColor[3]"], "", None ), + "ctx->Current.RasterColor[3]"], "", NoState, NoExt ), ( "GL_CURRENT_RASTER_DISTANCE", GLfloat, - ["ctx->Current.RasterDistance"], "", None ), + ["ctx->Current.RasterDistance"], "", NoState, NoExt ), ( "GL_CURRENT_RASTER_INDEX", GLfloat, - ["1.0"], "", None ), + ["1.0"], "", NoState, NoExt ), ( "GL_CURRENT_RASTER_POSITION", GLfloat, ["ctx->Current.RasterPos[0]", "ctx->Current.RasterPos[1]", "ctx->Current.RasterPos[2]", - "ctx->Current.RasterPos[3]"], "", None ), + "ctx->Current.RasterPos[3]"], "", NoState, NoExt ), ( "GL_CURRENT_RASTER_SECONDARY_COLOR", GLfloatN, ["ctx->Current.RasterSecondaryColor[0]", "ctx->Current.RasterSecondaryColor[1]", "ctx->Current.RasterSecondaryColor[2]", - "ctx->Current.RasterSecondaryColor[3]"], "", None ), + "ctx->Current.RasterSecondaryColor[3]"], "", NoState, NoExt ), ( "GL_CURRENT_RASTER_TEXTURE_COORDS", GLfloat, ["ctx->Current.RasterTexCoords[unit][0]", "ctx->Current.RasterTexCoords[unit][1]", @@ -177,9 +186,9 @@ StateVars = [ "glGet(raster tex coords, unit %u)", unit); return; }""", - None ), + NoState, NoExt ), ( "GL_CURRENT_RASTER_POSITION_VALID", GLboolean, - ["ctx->Current.RasterPosValid"], "", None ), + ["ctx->Current.RasterPosValid"], "", NoState, NoExt ), ( "GL_CURRENT_TEXTURE_COORDS", GLfloat, ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]", "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]", @@ -192,85 +201,85 @@ StateVars = [ return; } FLUSH_CURRENT(ctx, 0);""", - None ), - ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ), + NoState, NoExt ), + ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", NoState, NoExt ), ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"], - "", None ), - ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", None ), - ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ), + "", NoState, NoExt ), + ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", NoState, NoExt ), + ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", NoState, NoExt ), ( "GL_DEPTH_RANGE", GLfloatN, - [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ), - ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", None ), - ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ), - ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ), - ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ), + [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", NoState, NoExt ), + ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", NoState, NoExt ), + ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", NoState, NoExt ), + ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", NoState, NoExt ), + ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", NoState, NoExt ), ( "GL_DOUBLEBUFFER", GLboolean, - ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", None ), - ( "GL_DRAW_BUFFER", GLenum, ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", None ), + ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", NoState, NoExt ), + ( "GL_DRAW_BUFFER", GLenum, ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ), ( "GL_EDGE_FLAG", GLboolean, ["(ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)"], - "FLUSH_CURRENT(ctx, 0);", None ), - ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", None ), - ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", None ), - ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ), + "", FlushCurrent, NoExt ), + ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", NoState, NoExt ), + ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", NoState, NoExt ), + ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", NoState, NoExt ), ( "GL_FOG_COLOR", GLfloatN, [ "ctx->Fog.Color[0]", "ctx->Fog.Color[1]", "ctx->Fog.Color[2]", - "ctx->Fog.Color[3]" ], "", None ), - ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ), - ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ), - ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ), - ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", None ), - ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ), - ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ), - ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ), - ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", None ), + "ctx->Fog.Color[3]" ], "", NoState, NoExt ), + ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", NoState, NoExt ), + ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", NoState, NoExt ), + ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", NoState, NoExt ), + ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", NoState, NoExt ), + ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", NoState, NoExt ), + ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", NoState, NoExt ), + ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", NoState, NoExt ), + ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", NoState, NoExt ), ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"], - "", None ), - ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", None ), + "", "_NEW_BUFFERS", NoExt ), + ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", NoState, NoExt ), ( "GL_INDEX_BITS", GLint, ["ctx->DrawBuffer->Visual.indexBits"], - "", None ), - ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", None ), + "", "_NEW_BUFFERS", NoExt ), + ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", NoState, NoExt ), ( "GL_INDEX_MODE", GLboolean, ["GL_FALSE"], - "", None ), - ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", None ), - ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", None ), - ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", None ), - ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ), - ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ), - ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ), - ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ), - ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ), - ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ), - ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ), - ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ), - ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ), + "", NoState, NoExt ), + ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", NoState, NoExt ), + ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", NoState, NoExt ), + ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", NoState, NoExt ), + ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", NoState, NoExt ), + ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", NoState, NoExt ), ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN, ["ctx->Light.Model.Ambient[0]", "ctx->Light.Model.Ambient[1]", "ctx->Light.Model.Ambient[2]", - "ctx->Light.Model.Ambient[3]"], "", None ), + "ctx->Light.Model.Ambient[3]"], "", NoState, NoExt ), ( "GL_LIGHT_MODEL_COLOR_CONTROL", GLenum, - ["ctx->Light.Model.ColorControl"], "", None ), + ["ctx->Light.Model.ColorControl"], "", NoState, NoExt ), ( "GL_LIGHT_MODEL_LOCAL_VIEWER", GLboolean, - ["ctx->Light.Model.LocalViewer"], "", None ), - ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ), - ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ), - ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ), - ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", None ), - ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", None ), - ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", None ), - ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ), + ["ctx->Light.Model.LocalViewer"], "", NoState, NoExt ), + ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", NoState, NoExt ), + ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", NoState, NoExt ), + ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", NoState, NoExt ), + ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", NoState, NoExt ), + ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", NoState, NoExt ), + ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", NoState, NoExt ), + ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", NoState, NoExt ), ( "GL_LINE_WIDTH_GRANULARITY", GLfloat, - ["ctx->Const.LineWidthGranularity"], "", None ), + ["ctx->Const.LineWidthGranularity"], "", NoState, NoExt ), ( "GL_LINE_WIDTH_RANGE", GLfloat, ["ctx->Const.MinLineWidthAA", - "ctx->Const.MaxLineWidthAA"], "", None ), + "ctx->Const.MaxLineWidthAA"], "", NoState, NoExt ), ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat, ["ctx->Const.MinLineWidth", - "ctx->Const.MaxLineWidth"], "", None ), - ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", None ), - ( "GL_LIST_INDEX", GLint, ["(ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)"], "", None ), + "ctx->Const.MaxLineWidth"], "", NoState, NoExt ), + ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", NoState, NoExt ), + ( "GL_LIST_INDEX", GLint, ["(ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)"], "", NoState, NoExt ), ( "GL_LIST_MODE", GLenum, ["mode"], """GLenum mode; if (!ctx->CompileFlag) @@ -278,195 +287,195 @@ StateVars = [ else if (ctx->ExecuteFlag) mode = GL_COMPILE_AND_EXECUTE; else - mode = GL_COMPILE;""", None ), - ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", None ), - ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ), - ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ), - ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", None ), + mode = GL_COMPILE;""", NoState, NoExt ), + ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", NoState, NoExt ), + ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", NoState, NoExt ), + ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", NoState, NoExt ), + ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", NoState, NoExt ), ( "GL_MAP1_GRID_DOMAIN", GLfloat, ["ctx->Eval.MapGrid1u1", - "ctx->Eval.MapGrid1u2"], "", None ), - ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", None ), - ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", None ), - ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", None ), - ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", None ), - ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", None ), - ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", None ), - ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", None ), - ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", None ), - ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", None ), - ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", None ), + "ctx->Eval.MapGrid1u2"], "", NoState, NoExt ), + ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", NoState, NoExt ), + ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", NoState, NoExt ), + ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", NoState, NoExt ), + ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", NoState, NoExt ), + ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", NoState, NoExt ), + ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", NoState, NoExt ), + ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", NoState, NoExt ), + ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", NoState, NoExt ), + ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", NoState, NoExt ), + ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", NoState, NoExt ), ( "GL_MAP2_GRID_DOMAIN", GLfloat, ["ctx->Eval.MapGrid2u1", "ctx->Eval.MapGrid2u2", "ctx->Eval.MapGrid2v1", - "ctx->Eval.MapGrid2v2"], "", None ), + "ctx->Eval.MapGrid2v2"], "", NoState, NoExt ), ( "GL_MAP2_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid2un", - "ctx->Eval.MapGrid2vn"], "", None ), - ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", None ), - ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", None ), - ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", None ), - ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", None ), - ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", None ), - ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", None ), - ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", None ), - ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", None ), - ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", None ), - ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", None ), - ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ), + "ctx->Eval.MapGrid2vn"], "", NoState, NoExt ), + ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", NoState, NoExt ), + ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", NoState, NoExt ), + ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", NoState, NoExt ), + ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", NoState, NoExt ), + ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", NoState, NoExt ), + ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", NoState, NoExt ), + ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", NoState, NoExt ), + ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", NoState, NoExt ), + ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", NoState, NoExt ), + ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", NoState, NoExt ), + ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", NoState, NoExt ), - ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", None ), - ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", None ), - ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ), - ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), - ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), - ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", None ), - ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ), - ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", None ), - ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ), - ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", None ), - ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", None ), - ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ), - ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ), - ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None ), - ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ), + ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ), + ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ), + ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", NoState, NoExt ), + ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ), + ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ), + ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", NoState, NoExt ), + ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", NoState, NoExt ), + ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", NoState, NoExt ), + ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", NoState, NoExt ), + ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", NoState, NoExt ), + ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", NoState, NoExt ), + ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", NoState, NoExt ), + ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", NoState, NoExt ), + ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", NoState, NoExt ), + ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", NoState, NoExt ), ( "GL_MAX_VIEWPORT_DIMS", GLint, ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"], - "", None ), + "", NoState, NoExt ), ( "GL_MODELVIEW_MATRIX", GLfloat, [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ), - ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ), - ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", None ), - ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ), - ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ), - ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", None ), - ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", None ), - ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", None ), - ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", None ), - ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", None ), - ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ), - ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", None ), - ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", None ), + "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", NoState, NoExt ), + ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", NoState, NoExt ), + ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", NoState, NoExt ), + ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", NoState, NoExt ), + ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", NoState, NoExt ), + ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", NoState, NoExt ), + ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", NoState, NoExt ), + ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", NoState, NoExt ), + ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", NoState, NoExt ), + ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", NoState, NoExt ), + ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", NoState, NoExt ), + ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", NoState, NoExt ), + ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", NoState, NoExt ), ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum, - ["ctx->Hint.PerspectiveCorrection"], "", None ), - ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", None ), - ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", None ), - ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", None ), - ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", None ), - ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", None ), - ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", None ), - ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", None ), - ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", None ), - ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", None ), - ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", None ), - ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ), + ["ctx->Hint.PerspectiveCorrection"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", NoState, NoExt ), + ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", NoState, NoExt ), + ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", NoState, NoExt ), ( "GL_POINT_SIZE_GRANULARITY", GLfloat, - ["ctx->Const.PointSizeGranularity"], "", None ), + ["ctx->Const.PointSizeGranularity"], "", NoState, NoExt ), ( "GL_POINT_SIZE_RANGE", GLfloat, ["ctx->Const.MinPointSizeAA", - "ctx->Const.MaxPointSizeAA"], "", None ), + "ctx->Const.MaxPointSizeAA"], "", NoState, NoExt ), ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat, ["ctx->Const.MinPointSize", - "ctx->Const.MaxPointSize"], "", None ), - ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ), - ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ), - ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ), - ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ), + "ctx->Const.MaxPointSize"], "", NoState, NoExt ), + ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", NoState, NoExt ), + ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", NoState, NoExt ), + ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", NoState, NoExt ), + ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", NoState, NoExt ), ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat, - ["ctx->Point.Threshold"], "", None ), + ["ctx->Point.Threshold"], "", NoState, NoExt ), ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat, ["ctx->Point.Params[0]", "ctx->Point.Params[1]", - "ctx->Point.Params[2]"], "", None ), + "ctx->Point.Params[2]"], "", NoState, NoExt ), ( "GL_POLYGON_MODE", GLenum, ["ctx->Polygon.FrontMode", - "ctx->Polygon.BackMode"], "", None ), - ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", None ), - ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ), - ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ), - ( "GL_POLYGON_OFFSET_POINT", GLboolean, ["ctx->Polygon.OffsetPoint"], "", None ), - ( "GL_POLYGON_OFFSET_LINE", GLboolean, ["ctx->Polygon.OffsetLine"], "", None ), - ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", None ), - ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", None ), - ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", None ), - ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", None ), + "ctx->Polygon.BackMode"], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_POINT", GLboolean, ["ctx->Polygon.OffsetPoint"], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_LINE", GLboolean, ["ctx->Polygon.OffsetLine"], "", NoState, NoExt ), + ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", NoState, NoExt ), + ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", NoState, NoExt ), + ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", NoState, NoExt ), + ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", NoState, NoExt ), ( "GL_PROJECTION_MATRIX", GLfloat, [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ), + "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", NoState, NoExt ), ( "GL_PROJECTION_STACK_DEPTH", GLint, - ["ctx->ProjectionMatrixStack.Depth + 1"], "", None ), - ( "GL_READ_BUFFER", GLenum, ["ctx->ReadBuffer->ColorReadBuffer"], "", None ), - ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", None ), - ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", None ), - ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", None ), - ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", None ), + ["ctx->ProjectionMatrixStack.Depth + 1"], "", NoState, NoExt ), + ( "GL_READ_BUFFER", GLenum, ["ctx->ReadBuffer->ColorReadBuffer"], "", NoState, NoExt ), + ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", NoState, NoExt ), + ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", "_NEW_BUFFERS", NoExt ), + ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", NoState, NoExt ), + ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", NoState, NoExt ), ( "GL_RESCALE_NORMAL", GLboolean, - ["ctx->Transform.RescaleNormals"], "", None ), + ["ctx->Transform.RescaleNormals"], "", NoState, NoExt ), ( "GL_RGBA_MODE", GLboolean, ["GL_TRUE"], - "", None ), + "", NoState, NoExt ), ( "GL_SCISSOR_BOX", GLint, ["ctx->Scissor.X", "ctx->Scissor.Y", "ctx->Scissor.Width", - "ctx->Scissor.Height"], "", None ), - ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ), - ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", None ), - ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ), + "ctx->Scissor.Height"], "", NoState, NoExt ), + ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", NoState, NoExt ), + ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", NoState, NoExt ), + ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", NoState, NoExt ), ( "GL_SHARED_TEXTURE_PALETTE_EXT", GLboolean, - ["ctx->Texture.SharedPalette"], "", None ), - ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ), - ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ), + ["ctx->Texture.SharedPalette"], "", NoState, NoExt ), + ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", NoState, NoExt ), + ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", NoState, NoExt ), ( "GL_STENCIL_FAIL", GLenum, - ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STENCIL_FUNC", GLenum, - ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum, - ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum, - ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STENCIL_REF", GLint, - ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ), + ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), + ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", NoState, NoExt ), ( "GL_STENCIL_VALUE_MASK", GLint, - ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STENCIL_WRITEMASK", GLint, - ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ), + ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), ( "GL_STEREO", GLboolean, ["ctx->DrawBuffer->Visual.stereoMode"], - "", None ), - ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ), - ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", None ), - ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ), - ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", None ), - ( "GL_TEXTURE_1D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)"], "", ["MESA_texture_array"] ), - ( "GL_TEXTURE_2D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)"], "", ["MESA_texture_array"] ), + "", NoState, NoExt ), + ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", NoState, NoExt ), + ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", NoState, NoExt ), + ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", NoState, NoExt ), + ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", NoState, NoExt ), + ( "GL_TEXTURE_1D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ), + ( "GL_TEXTURE_2D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ), ( "GL_TEXTURE_BINDING_1D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name"], "", None ), + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name"], "", NoState, NoExt ), ( "GL_TEXTURE_BINDING_2D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", None ), + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", NoState, NoExt ), ( "GL_TEXTURE_BINDING_3D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", None ), + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", NoState, NoExt ), ( "GL_TEXTURE_BINDING_1D_ARRAY_EXT", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ), + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ), ( "GL_TEXTURE_BINDING_2D_ARRAY_EXT", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ), + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ), ( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT", GLint, - ["ctx->Const.MaxArrayTextureLayers"], "", ["MESA_texture_array"] ), + ["ctx->Const.MaxArrayTextureLayers"], "", NoState, ["MESA_texture_array"] ), ( "GL_TEXTURE_GEN_S", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None ), + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", NoState, NoExt ), ( "GL_TEXTURE_GEN_T", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None ), + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", NoState, NoExt ), ( "GL_TEXTURE_GEN_R", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None ), + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", NoState, NoExt ), ( "GL_TEXTURE_GEN_Q", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", None ), + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", NoState, NoExt ), ( "GL_TEXTURE_MATRIX", GLfloat, ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", @@ -480,7 +489,7 @@ StateVars = [ return; } matrix = ctx->TextureMatrixStack[unit].Top->m;""", - None ), + NoState, NoExt ), ( "GL_TEXTURE_STACK_DEPTH", GLint, ["ctx->TextureMatrixStack[unit].Depth + 1"], """const GLuint unit = ctx->Texture.CurrentUnit; @@ -489,77 +498,77 @@ StateVars = [ "glGet(texture stack depth, unit %u)", unit); return; }""", - None ), - ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ), - ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", None ), - ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", None ), - ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", None ), - ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", None ), - ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", None ), - ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", None ), - ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", None ), - ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", None ), + NoState, NoExt ), + ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", NoState, NoExt ), + ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", NoState, NoExt ), + ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", NoState, NoExt ), + ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", NoState, NoExt ), + ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", NoState, NoExt ), + ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", NoState, NoExt ), + ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", NoState, NoExt ), + ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", NoState, NoExt ), + ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", NoState, NoExt ), ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y", - "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ), - ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", None ), - ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", None ), + "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", NoState, NoExt ), + ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", NoState, NoExt ), + ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", NoState, NoExt ), # Vertex arrays - ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", None ), - ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", None ), - ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", None ), - ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", None ), - ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), - ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", None ), - ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", None ), - ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", None ), - ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), - ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", None ), - ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", None ), - ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", None ), - ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", None ), - ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), - ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Index.Enabled"], "", None ), - ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Index.Type"], "", None ), - ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Index.Stride"], "", None ), - ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), + ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", NoState, NoExt ), + ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", NoState, NoExt ), + ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", NoState, NoExt ), + ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", NoState, NoExt ), + ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), + ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", NoState, NoExt ), + ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", NoState, NoExt ), + ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", NoState, NoExt ), + ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), + ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", NoState, NoExt ), + ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", NoState, NoExt ), + ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", NoState, NoExt ), + ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", NoState, NoExt ), + ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), + ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Index.Enabled"], "", NoState, NoExt ), + ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Index.Type"], "", NoState, NoExt ), + ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Index.Stride"], "", NoState, NoExt ), + ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), ( "GL_TEXTURE_COORD_ARRAY", GLboolean, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ), + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", NoState, NoExt ), ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", None ), + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", NoState, NoExt ), ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", None ), + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", NoState, NoExt ), ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ), - ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), - ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.ArrayObj->EdgeFlag.Enabled"], "", None ), - ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->EdgeFlag.Stride"], "", None ), - ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", None ), + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", NoState, NoExt ), + ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), + ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.ArrayObj->EdgeFlag.Enabled"], "", NoState, NoExt ), + ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->EdgeFlag.Stride"], "", NoState, NoExt ), + ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), # GL_ARB_multitexture ( "GL_MAX_TEXTURE_UNITS_ARB", GLint, - ["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ), + ["ctx->Const.MaxTextureUnits"], "", NoState, ["ARB_multitexture"] ), ( "GL_ACTIVE_TEXTURE_ARB", GLint, - [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ), + [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", NoState, ["ARB_multitexture"] ), ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint, - ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", ["ARB_multitexture"] ), + ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", NoState, ["ARB_multitexture"] ), # GL_ARB_texture_cube_map ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, - ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", ["ARB_texture_cube_map"] ), + ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", NoState, ["ARB_texture_cube_map"] ), ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint, ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"], - "", ["ARB_texture_cube_map"] ), + "", NoState, ["ARB_texture_cube_map"] ), ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint, ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"], - "", ["ARB_texture_cube_map"]), + "", NoState, ["ARB_texture_cube_map"]), # GL_ARB_texture_compression */ ( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint, - ["ctx->Hint.TextureCompression"], "", None ), + ["ctx->Hint.TextureCompression"], "", NoState, NoExt ), ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"], - "", None ), + "", NoState, NoExt ), ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum, [], """GLint formats[100]; @@ -567,13 +576,13 @@ StateVars = [ ASSERT(n <= 100); for (i = 0; i < n; i++) params[i] = CONVERSION(formats[i]);""", - None ), + NoState, NoExt ), # GL_EXT_compiled_vertex_array ( "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT", GLint, ["ctx->Array.LockFirst"], - "", ["EXT_compiled_vertex_array"] ), + "", NoState, ["EXT_compiled_vertex_array"] ), ( "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", GLint, ["ctx->Array.LockCount"], - "", ["EXT_compiled_vertex_array"] ), + "", NoState, ["EXT_compiled_vertex_array"] ), # GL_ARB_transpose_matrix ( "GL_TRANSPOSE_COLOR_MATRIX_ARB", GLfloat, @@ -581,25 +590,29 @@ StateVars = [ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ), + "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", + NoState, NoExt ), ( "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB", GLfloat, ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ), + "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", + NoState, NoExt ), ( "GL_TRANSPOSE_PROJECTION_MATRIX_ARB", GLfloat, ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ), + "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", + NoState, NoExt ), ( "GL_TRANSPOSE_TEXTURE_MATRIX_ARB", GLfloat, ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ), + "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", + NoState, NoExt ), # GL_SGI_color_matrix (also in 1.2 imaging) ( "GL_COLOR_MATRIX_SGI", GLfloat, @@ -607,343 +620,373 @@ StateVars = [ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ), + "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", + NoState, NoExt ), ( "GL_COLOR_MATRIX_STACK_DEPTH_SGI", GLint, - ["ctx->ColorMatrixStack.Depth + 1"], "", None ), + ["ctx->ColorMatrixStack.Depth + 1"], "", NoState, NoExt ), ( "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI", GLint, - ["MAX_COLOR_STACK_DEPTH"], "", None ), + ["MAX_COLOR_STACK_DEPTH"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_RED_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[0]"], "", None ), + ["ctx->Pixel.PostColorMatrixScale[0]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[1]"], "", None ), + ["ctx->Pixel.PostColorMatrixScale[1]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[2]"], "", None ), + ["ctx->Pixel.PostColorMatrixScale[2]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[3]"], "", None ), + ["ctx->Pixel.PostColorMatrixScale[3]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_RED_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[0]"], "", None ), + ["ctx->Pixel.PostColorMatrixBias[0]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[1]"], "", None ), + ["ctx->Pixel.PostColorMatrixBias[1]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[2]"], "", None ), + ["ctx->Pixel.PostColorMatrixBias[2]"], "", NoState, NoExt ), ( "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[3]"], "", None ), + ["ctx->Pixel.PostColorMatrixBias[3]"], "", NoState, NoExt ), # GL_EXT_convolution (also in 1.2 imaging) ( "GL_CONVOLUTION_1D_EXT", GLboolean, - ["ctx->Pixel.Convolution1DEnabled"], "", ["EXT_convolution"] ), + ["ctx->Pixel.Convolution1DEnabled"], "", NoState, ["EXT_convolution"] ), ( "GL_CONVOLUTION_2D_EXT", GLboolean, - ["ctx->Pixel.Convolution2DEnabled"], "", ["EXT_convolution"] ), + ["ctx->Pixel.Convolution2DEnabled"], "", NoState, ["EXT_convolution"] ), ( "GL_SEPARABLE_2D_EXT", GLboolean, - ["ctx->Pixel.Separable2DEnabled"], "", ["EXT_convolution"] ), + ["ctx->Pixel.Separable2DEnabled"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_RED_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[0]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionScale[0]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_GREEN_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[1]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionScale[1]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_BLUE_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[2]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionScale[2]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[3]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionScale[3]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_RED_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[0]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionBias[0]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_GREEN_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[1]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionBias[1]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_BLUE_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[2]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionBias[2]"], "", NoState, ["EXT_convolution"] ), ( "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[3]"], "", ["EXT_convolution"] ), + ["ctx->Pixel.PostConvolutionBias[3]"], "", NoState, ["EXT_convolution"] ), # GL_EXT_histogram / GL_ARB_imaging ( "GL_HISTOGRAM", GLboolean, - [ "ctx->Pixel.HistogramEnabled" ], "", ["EXT_histogram"] ), + [ "ctx->Pixel.HistogramEnabled" ], "", NoState, ["EXT_histogram"] ), ( "GL_MINMAX", GLboolean, - [ "ctx->Pixel.MinMaxEnabled" ], "", ["EXT_histogram"] ), + [ "ctx->Pixel.MinMaxEnabled" ], "", NoState, ["EXT_histogram"] ), # GL_SGI_color_table / GL_ARB_imaging ( "GL_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", + NoState, ["SGI_color_table"] ), ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", + NoState, ["SGI_color_table"] ), ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", ["SGI_color_table"] ), + ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", + NoState, ["SGI_color_table"] ), # GL_SGI_texture_color_table ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean, ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled"], - "", ["SGI_texture_color_table"] ), + "", NoState, ["SGI_texture_color_table"] ), # GL_EXT_secondary_color ( "GL_COLOR_SUM_EXT", GLboolean, - ["ctx->Fog.ColorSumEnabled"], "", + ["ctx->Fog.ColorSumEnabled"], "", NoState, ["EXT_secondary_color", "ARB_vertex_program"] ), ( "GL_CURRENT_SECONDARY_COLOR_EXT", GLfloatN, ["ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]", "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]"], - "FLUSH_CURRENT(ctx, 0);", ["EXT_secondary_color"] ), + "", FlushCurrent, ["EXT_secondary_color"] ), ( "GL_SECONDARY_COLOR_ARRAY_EXT", GLboolean, - ["ctx->Array.ArrayObj->SecondaryColor.Enabled"], "", ["EXT_secondary_color"] ), + ["ctx->Array.ArrayObj->SecondaryColor.Enabled"], + "", NoState, ["EXT_secondary_color"] ), ( "GL_SECONDARY_COLOR_ARRAY_TYPE_EXT", GLenum, - ["ctx->Array.ArrayObj->SecondaryColor.Type"], "", ["EXT_secondary_color"] ), + ["ctx->Array.ArrayObj->SecondaryColor.Type"], + "", NoState, ["EXT_secondary_color"] ), ( "GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT", GLint, - ["ctx->Array.ArrayObj->SecondaryColor.Stride"], "", ["EXT_secondary_color"] ), + ["ctx->Array.ArrayObj->SecondaryColor.Stride"], + "", NoState, ["EXT_secondary_color"] ), ( "GL_SECONDARY_COLOR_ARRAY_SIZE_EXT", GLint, - ["ctx->Array.ArrayObj->SecondaryColor.Size"], "", ["EXT_secondary_color"] ), + ["ctx->Array.ArrayObj->SecondaryColor.Size"], + "", NoState, ["EXT_secondary_color"] ), # GL_EXT_fog_coord ( "GL_CURRENT_FOG_COORDINATE_EXT", GLfloat, ["ctx->Current.Attrib[VERT_ATTRIB_FOG][0]"], - "FLUSH_CURRENT(ctx, 0);", ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean, ["ctx->Array.ArrayObj->FogCoord.Enabled"], - "", ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum, ["ctx->Array.ArrayObj->FogCoord.Type"], - "", ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint, ["ctx->Array.ArrayObj->FogCoord.Stride"], - "", ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum, ["ctx->Fog.FogCoordinateSource"], - "", ["EXT_fog_coord"] ), + "", FlushCurrent, ["EXT_fog_coord"] ), + ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean, + ["ctx->Array.ArrayObj->FogCoord.Enabled"], + "", NoState, ["EXT_fog_coord"] ), + ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum, + ["ctx->Array.ArrayObj->FogCoord.Type"], + "", NoState, ["EXT_fog_coord"] ), + ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint, + ["ctx->Array.ArrayObj->FogCoord.Stride"], + "", NoState, ["EXT_fog_coord"] ), + ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum, + ["ctx->Fog.FogCoordinateSource"], + "", NoState, ["EXT_fog_coord"] ), # GL_EXT_texture_lod_bias ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat, - ["ctx->Const.MaxTextureLodBias"], "", ["EXT_texture_lod_bias"]), + ["ctx->Const.MaxTextureLodBias"], "", NoState, ["EXT_texture_lod_bias"]), # GL_EXT_texture_filter_anisotropic ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat, - ["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]), + ["ctx->Const.MaxTextureMaxAnisotropy"], + "", NoState, ["EXT_texture_filter_anisotropic"]), # GL_ARB_multisample ( "GL_MULTISAMPLE_ARB", GLboolean, - ["ctx->Multisample.Enabled"], "", None ), + ["ctx->Multisample.Enabled"], "", NoState, NoExt ), ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToCoverage"], "", None ), + ["ctx->Multisample.SampleAlphaToCoverage"], "", NoState, NoExt ), ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToOne"], "", None ), + ["ctx->Multisample.SampleAlphaToOne"], "", NoState, NoExt ), ( "GL_SAMPLE_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleCoverage"], "", None ), + ["ctx->Multisample.SampleCoverage"], "", NoState, NoExt ), ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat, - ["ctx->Multisample.SampleCoverageValue"], "", None ), + ["ctx->Multisample.SampleCoverageValue"], "", NoState, NoExt ), ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean, - ["ctx->Multisample.SampleCoverageInvert"], "", None ), + ["ctx->Multisample.SampleCoverageInvert"], "", NoState, NoExt ), ( "GL_SAMPLE_BUFFERS_ARB", GLint, - ["ctx->DrawBuffer->Visual.sampleBuffers"], "", None ), + ["ctx->DrawBuffer->Visual.sampleBuffers"], "", NoState, NoExt ), ( "GL_SAMPLES_ARB", GLint, - ["ctx->DrawBuffer->Visual.samples"], "", None ), + ["ctx->DrawBuffer->Visual.samples"], "", NoState, NoExt ), # GL_IBM_rasterpos_clip ( "GL_RASTER_POSITION_UNCLIPPED_IBM", GLboolean, - ["ctx->Transform.RasterPositionUnclipped"], "", ["IBM_rasterpos_clip"] ), + ["ctx->Transform.RasterPositionUnclipped"], + "", NoState, ["IBM_rasterpos_clip"] ), # GL_NV_point_sprite ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB - "", ["NV_point_sprite", "ARB_point_sprite"] ), + "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ), ( "GL_POINT_SPRITE_R_MODE_NV", GLenum, ["ctx->Point.SpriteRMode"], - "", ["NV_point_sprite"] ), + "", NoState, ["NV_point_sprite"] ), ( "GL_POINT_SPRITE_COORD_ORIGIN", GLenum, ["ctx->Point.SpriteOrigin"], - "", ["NV_point_sprite", "ARB_point_sprite"] ), + "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ), # GL_SGIS_generate_mipmap ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"], - "", ["SGIS_generate_mipmap"] ), + "", NoState, ["SGIS_generate_mipmap"] ), # GL_NV_vertex_program ( "GL_VERTEX_PROGRAM_BINDING_NV", GLint, ["(ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)"], - "", ["NV_vertex_program"] ), + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY0_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[0].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[0].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY1_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[1].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[1].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY2_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[2].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[2].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY3_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[3].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[3].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY4_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[4].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[4].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY5_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[5].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[5].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY6_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[6].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[6].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY7_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[7].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[7].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY8_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[8].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[8].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY9_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[9].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[9].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY10_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[10].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[10].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY11_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[11].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[11].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY12_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[12].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[12].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY13_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[13].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[13].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY14_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[14].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[14].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_VERTEX_ATTRIB_ARRAY15_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[15].Enabled"], "", ["NV_vertex_program"] ), + ["ctx->Array.ArrayObj->VertexAttrib[15].Enabled"], + "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB0_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[0]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[0]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB1_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[1]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[1]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB2_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[2]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[2]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB3_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[3]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[3]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB4_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[4]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[4]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB5_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[5]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[5]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB6_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[6]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[6]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB7_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[7]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[7]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB8_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[8]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[8]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB9_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[9]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[9]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB10_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[10]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[10]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB11_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[11]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[11]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB12_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[12]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[12]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB13_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[13]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[13]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB14_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[14]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[14]"], "", NoState, ["NV_vertex_program"] ), ( "GL_MAP1_VERTEX_ATTRIB15_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[15]"], "", ["NV_vertex_program"] ), + ["ctx->Eval.Map1Attrib[15]"], "", NoState, ["NV_vertex_program"] ), # GL_NV_fragment_program ( "GL_FRAGMENT_PROGRAM_NV", GLboolean, - ["ctx->FragmentProgram.Enabled"], "", ["NV_fragment_program"] ), + ["ctx->FragmentProgram.Enabled"], "", NoState, ["NV_fragment_program"] ), ( "GL_FRAGMENT_PROGRAM_BINDING_NV", GLint, ["ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0"], - "", ["NV_fragment_program"] ), + "", NoState, ["NV_fragment_program"] ), ( "GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV", GLint, - ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", ["NV_fragment_program"] ), + ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", NoState, ["NV_fragment_program"] ), # GL_NV_texture_rectangle ( "GL_TEXTURE_RECTANGLE_NV", GLboolean, - ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", ["NV_texture_rectangle"] ), + ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", NoState, ["NV_texture_rectangle"] ), ( "GL_TEXTURE_BINDING_RECTANGLE_NV", GLint, ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name"], - "", ["NV_texture_rectangle"] ), + "", NoState, ["NV_texture_rectangle"] ), ( "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", GLint, - ["ctx->Const.MaxTextureRectSize"], "", ["NV_texture_rectangle"] ), + ["ctx->Const.MaxTextureRectSize"], "", NoState, ["NV_texture_rectangle"] ), # GL_EXT_stencil_two_side ( "GL_STENCIL_TEST_TWO_SIDE_EXT", GLboolean, - ["ctx->Stencil.TestTwoSide"], "", ["EXT_stencil_two_side"] ), + ["ctx->Stencil.TestTwoSide"], "", NoState, ["EXT_stencil_two_side"] ), ( "GL_ACTIVE_STENCIL_FACE_EXT", GLenum, ["ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT"], - "", ["EXT_stencil_two_side"] ), + "", NoState, ["EXT_stencil_two_side"] ), # GL_NV_light_max_exponent ( "GL_MAX_SHININESS_NV", GLfloat, - ["ctx->Const.MaxShininess"], "", ["NV_light_max_exponent"] ), + ["ctx->Const.MaxShininess"], "", NoState, ["NV_light_max_exponent"] ), ( "GL_MAX_SPOT_EXPONENT_NV", GLfloat, - ["ctx->Const.MaxSpotExponent"], "", ["NV_light_max_exponent"] ), + ["ctx->Const.MaxSpotExponent"], "", NoState, ["NV_light_max_exponent"] ), # GL_ARB_vertex_buffer_object ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayBufferObj->Name"], "", None ), + ["ctx->Array.ArrayBufferObj->Name"], "", NoState, NoExt ), ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", None ), + ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", NoState, NoExt ), ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", None ), + ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", NoState, NoExt ), ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", None ), + ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", NoState, NoExt ), ( "GL_INDEX_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Index.BufferObj->Name"], "", None ), + ["ctx->Array.ArrayObj->Index.BufferObj->Name"], "", NoState, NoExt ), ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint, ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"], - "", None ), + "", NoState, NoExt ), ( "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name"], "", None ), + ["ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name"], "", NoState, NoExt ), ( "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, ["ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name"], - "", None ), + "", NoState, NoExt ), ( "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB", GLint, ["ctx->Array.ArrayObj->FogCoord.BufferObj->Name"], - "", None ), + "", NoState, NoExt ), # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint, ["ctx->Array.ElementArrayBufferObj->Name"], - "", None ), + "", NoState, NoExt ), # GL_EXT_pixel_buffer_object ( "GL_PIXEL_PACK_BUFFER_BINDING_EXT", GLint, - ["ctx->Pack.BufferObj->Name"], "", ["EXT_pixel_buffer_object"] ), + ["ctx->Pack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ), ( "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT", GLint, - ["ctx->Unpack.BufferObj->Name"], "", ["EXT_pixel_buffer_object"] ), + ["ctx->Unpack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ), # GL_ARB_vertex_program ( "GL_VERTEX_PROGRAM_ARB", GLboolean, # == GL_VERTEX_PROGRAM_NV - ["ctx->VertexProgram.Enabled"], "", + ["ctx->VertexProgram.Enabled"], "", NoState, ["ARB_vertex_program", "NV_vertex_program"] ), ( "GL_VERTEX_PROGRAM_POINT_SIZE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_POINT_SIZE_NV - ["ctx->VertexProgram.PointSizeEnabled"], "", + ["ctx->VertexProgram.PointSizeEnabled"], "", NoState, ["ARB_vertex_program", "NV_vertex_program"] ), ( "GL_VERTEX_PROGRAM_TWO_SIDE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_TWO_SIDE_NV - ["ctx->VertexProgram.TwoSideEnabled"], "", + ["ctx->VertexProgram.TwoSideEnabled"], "", NoState, ["ARB_vertex_program", "NV_vertex_program"] ), ( "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB", GLint, # == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV - ["ctx->Const.MaxProgramMatrixStackDepth"], "", + ["ctx->Const.MaxProgramMatrixStackDepth"], "", NoState, ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), ( "GL_MAX_PROGRAM_MATRICES_ARB", GLint, # == GL_MAX_TRACK_MATRICES_NV - ["ctx->Const.MaxProgramMatrices"], "", + ["ctx->Const.MaxProgramMatrices"], "", NoState, ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), ( "GL_CURRENT_MATRIX_STACK_DEPTH_ARB", GLboolean, # == GL_CURRENT_MATRIX_STACK_DEPTH_NV - ["ctx->CurrentStack->Depth + 1"], "", + ["ctx->CurrentStack->Depth + 1"], "", NoState, ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), ( "GL_CURRENT_MATRIX_ARB", GLfloat, # == GL_CURRENT_MATRIX_NV ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->CurrentStack->Top->m;", + "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState, ["ARB_vertex_program", "ARB_fragment_program", "NV_fragment_program"] ), ( "GL_TRANSPOSE_CURRENT_MATRIX_ARB", GLfloat, ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->CurrentStack->Top->m;", + "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState, ["ARB_vertex_program", "ARB_fragment_program"] ), ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint, - ["ctx->Const.VertexProgram.MaxAttribs"], "", ["ARB_vertex_program"] ), + ["ctx->Const.VertexProgram.MaxAttribs"], "", NoState, ["ARB_vertex_program"] ), ( "GL_PROGRAM_ERROR_POSITION_ARB", GLint, # == GL_PROGRAM_ERROR_POSITION_NV - ["ctx->Program.ErrorPos"], "", ["NV_vertex_program", + ["ctx->Program.ErrorPos"], "", NoState, ["NV_vertex_program", "ARB_vertex_program", "NV_fragment_program", "ARB_fragment_program"] ), # GL_ARB_fragment_program ( "GL_FRAGMENT_PROGRAM_ARB", GLboolean, - ["ctx->FragmentProgram.Enabled"], "", ["ARB_fragment_program"] ), + ["ctx->FragmentProgram.Enabled"], "", NoState, ["ARB_fragment_program"] ), ( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV - ["ctx->Const.MaxTextureCoordUnits"], "", + ["ctx->Const.MaxTextureCoordUnits"], "", NoState, ["ARB_fragment_program", "NV_fragment_program"] ), ( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNITS_NV - ["ctx->Const.MaxTextureImageUnits"], "", + ["ctx->Const.MaxTextureImageUnits"], "", NoState, ["ARB_fragment_program", "NV_fragment_program"] ), # GL_EXT_depth_bounds_test ( "GL_DEPTH_BOUNDS_TEST_EXT", GLboolean, - ["ctx->Depth.BoundsTest"], "", ["EXT_depth_bounds_test"] ), + ["ctx->Depth.BoundsTest"], "", NoState, ["EXT_depth_bounds_test"] ), ( "GL_DEPTH_BOUNDS_EXT", GLfloat, ["ctx->Depth.BoundsMin", "ctx->Depth.BoundsMax"], - "", ["EXT_depth_bounds_test"] ), + "", NoState, ["EXT_depth_bounds_test"] ), # GL_ARB_depth_clamp ( "GL_DEPTH_CLAMP", GLboolean, ["ctx->Transform.DepthClamp"], "", - ["ARB_depth_clamp"] ), + NoState, ["ARB_depth_clamp"] ), # GL_ARB_draw_buffers ( "GL_MAX_DRAW_BUFFERS_ARB", GLint, - ["ctx->Const.MaxDrawBuffers"], "", None ), + ["ctx->Const.MaxDrawBuffers"], "", NoState, NoExt ), ( "GL_DRAW_BUFFER0_ARB", GLenum, - ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", None ), + ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ), ( "GL_DRAW_BUFFER1_ARB", GLenum, ["buffer"], """GLenum buffer; @@ -951,7 +994,7 @@ StateVars = [ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); return; } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1];""", None ), + buffer = ctx->DrawBuffer->ColorDrawBuffer[1];""", NoState, NoExt ), ( "GL_DRAW_BUFFER2_ARB", GLenum, ["buffer"], """GLenum buffer; @@ -959,7 +1002,7 @@ StateVars = [ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); return; } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2];""", None ), + buffer = ctx->DrawBuffer->ColorDrawBuffer[2];""", NoState, NoExt ), ( "GL_DRAW_BUFFER3_ARB", GLenum, ["buffer"], """GLenum buffer; @@ -967,118 +1010,138 @@ StateVars = [ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); return; } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3];""", None ), + buffer = ctx->DrawBuffer->ColorDrawBuffer[3];""", NoState, NoExt ), # XXX Add more GL_DRAW_BUFFERn_ARB entries as needed in the future # GL_OES_read_format ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, - ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ), + ["_mesa_get_color_read_type(ctx)"], "", NoState, ["OES_read_format"] ), ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, - ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ), + ["_mesa_get_color_read_format(ctx)"], "", NoState, ["OES_read_format"] ), # GL_ATI_fragment_shader - ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_PASSES_ATI", GLint, ["2"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"], "", ["ATI_fragment_shader"] ), - ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"], "", ["ATI_fragment_shader"] ), - ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"], "", ["ATI_fragment_shader"] ), + ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_PASSES_ATI", GLint, ["2"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"], + "", NoState, ["ATI_fragment_shader"] ), + ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"], + "", NoState, ["ATI_fragment_shader"] ), # OpenGL 2.0 - ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ), - ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ), - ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], "", None ), - ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ), - ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ), - ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ), - ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ), + ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], + "", NoState, NoExt ), + ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], + "", NoState, NoExt ), # GL_EXT_framebuffer_object ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "", - ["EXT_framebuffer_object"] ), + NoState, ["EXT_framebuffer_object"] ), ( "GL_RENDERBUFFER_BINDING_EXT", GLint, ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "", - ["EXT_framebuffer_object"] ), + NoState, ["EXT_framebuffer_object"] ), ( "GL_MAX_COLOR_ATTACHMENTS_EXT", GLint, ["ctx->Const.MaxColorAttachments"], "", - ["EXT_framebuffer_object"] ), + NoState, ["EXT_framebuffer_object"] ), ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint, ["ctx->Const.MaxRenderbufferSize"], "", - ["EXT_framebuffer_object"] ), + NoState, ["EXT_framebuffer_object"] ), # GL_EXT_framebuffer_blit # NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT ( "GL_READ_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->ReadBuffer->Name"], "", - ["EXT_framebuffer_blit"] ), + NoState, ["EXT_framebuffer_blit"] ), # GL_EXT_provoking_vertex ( "GL_PROVOKING_VERTEX_EXT", GLboolean, - ["ctx->Light.ProvokingVertex"], "", ["EXT_provoking_vertex"] ), + ["ctx->Light.ProvokingVertex"], "", NoState, ["EXT_provoking_vertex"] ), ( "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT", GLboolean, ["ctx->Const.QuadsFollowProvokingVertexConvention"], "", - ["EXT_provoking_vertex"] ), + NoState, ["EXT_provoking_vertex"] ), # GL_ARB_fragment_shader ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint, ["ctx->Const.FragmentProgram.MaxUniformComponents"], "", - ["ARB_fragment_shader"] ), + NoState, ["ARB_fragment_shader"] ), ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum, - ["ctx->Hint.FragmentShaderDerivative"], "", ["ARB_fragment_shader"] ), + ["ctx->Hint.FragmentShaderDerivative"], + "", NoState, ["ARB_fragment_shader"] ), # GL_ARB_vertex_shader ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint, ["ctx->Const.VertexProgram.MaxUniformComponents"], "", - ["ARB_vertex_shader"] ), + NoState, ["ARB_vertex_shader"] ), ( "GL_MAX_VARYING_FLOATS_ARB", GLint, - ["ctx->Const.MaxVarying * 4"], "", ["ARB_vertex_shader"] ), + ["ctx->Const.MaxVarying * 4"], "", NoState, ["ARB_vertex_shader"] ), ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ), + ["ctx->Const.MaxVertexTextureImageUnits"], + "", NoState, ["ARB_vertex_shader"] ), ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ), + ["ctx->Const.MaxCombinedTextureImageUnits"], + "", NoState, ["ARB_vertex_shader"] ), # GL_ARB_shader_objects # Actually, this token isn't part of GL_ARB_shader_objects, but is # close enough for now. ( "GL_CURRENT_PROGRAM", GLint, ["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"], - "", ["ARB_shader_objects"] ), + "", NoState, ["ARB_shader_objects"] ), # GL_ARB_framebuffer_object ( "GL_MAX_SAMPLES", GLint, ["ctx->Const.MaxSamples"], "", - ["ARB_framebuffer_object"] ), + NoState, ["ARB_framebuffer_object"] ), # GL_APPLE_vertex_array_object ( "GL_VERTEX_ARRAY_BINDING_APPLE", GLint, ["ctx->Array.ArrayObj->Name"], "", - ["APPLE_vertex_array_object"] ), + NoState, ["APPLE_vertex_array_object"] ), # GL_ARB_seamless_cube_map ( "GL_TEXTURE_CUBE_MAP_SEAMLESS", GLboolean, ["ctx->Texture.CubeMapSeamless"], "", - ["ARB_seamless_cube_map"] ), + NoState, ["ARB_seamless_cube_map"] ), # GL_ARB_sync ( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "", - ["ARB_sync"] ), + NoState, ["ARB_sync"] ), # GL3 - ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ), - ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ), - ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None ), - ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", None ) + ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", NoState, NoExt ), + ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", NoState, NoExt ), + ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", NoState, NoExt ), + ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", NoState, NoExt ) ] # These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() +# The tuples are the same as above, with one exception: the "optional" +# code field is instead the max legal index value. IndexedStateVars = [ ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], - "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ), + "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ), ( "GL_COLOR_WRITEMASK", GLint, [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ], - "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ), + "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ), # XXX more to come... ] @@ -1155,9 +1218,6 @@ def EmitGetFunction(stateVars, returnType, indexed): print " if (!params)" print " return;" print "" - print " if (ctx->NewState)" - print " _mesa_update_state(ctx);" - print "" if indexed == 0: print " if (ctx->Driver.%s &&" % function print " ctx->Driver.%s(ctx, pname, params))" % function @@ -1167,12 +1227,14 @@ def EmitGetFunction(stateVars, returnType, indexed): for state in stateVars: if indexed: - (name, varType, state, indexMax, extensions) = state + (name, varType, state, indexMax, dirtyFlags, extensions) = state optionalCode = 0 else: - (name, varType, state, optionalCode, extensions) = state + (name, varType, state, optionalCode, dirtyFlags, extensions) = state indexMax = 0 print " case " + name + ":" + + # Do extension check if extensions: if len(extensions) == 1: print (' CHECK_EXT1(%s, "%s");' % @@ -1187,9 +1249,20 @@ def EmitGetFunction(stateVars, returnType, indexed): assert len(extensions) == 4 print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % (extensions[0], extensions[1], extensions[2], extensions[3], function)) + + # Do dirty state check + if dirtyFlags: + if dirtyFlags == FlushCurrent: + print (' FLUSH_CURRENT(ctx, 0);') + else: + print (' if (ctx->NewState & %s)' % dirtyFlags) + print (' _mesa_update_state(ctx);') + + # Do index validation for glGet*Indexed() calls if indexMax: print (' if (index >= %s) {' % indexMax) print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function) + print (' return;') print (' }') conversion = ConversionFunc(varType, returnType) From 4b722bf9fde668dff1c2b55b34eb3f86c78f43fb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:39 +0200 Subject: [PATCH 392/483] st/dri: fold dri_extensions.c into dri_context.c --- .../state_trackers/dri/common/dri_context.c | 14 +++++- .../state_trackers/dri/common/dri_context.h | 5 -- .../dri/common/dri_extensions.c | 48 ------------------- src/gallium/state_trackers/dri/drm/Makefile | 1 - .../state_trackers/dri/drm/dri_extensions.c | 1 - src/gallium/state_trackers/dri/sw/Makefile | 1 - .../state_trackers/dri/sw/dri_extensions.c | 1 - 7 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 src/gallium/state_trackers/dri/common/dri_extensions.c delete mode 120000 src/gallium/state_trackers/dri/drm/dri_extensions.c delete mode 120000 src/gallium/state_trackers/dri/sw/dri_extensions.c diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index 34d9a932ead..f14f4130bf4 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -29,13 +29,25 @@ * Author: Jakob Bornecrantz */ +#include "utils.h" + #include "dri_screen.h" #include "dri_drawable.h" #include "dri_context.h" #include "dri_st_api.h" #include "pipe/p_context.h" -#include "util/u_memory.h" +#include "state_tracker/st_context.h" + +static void +dri_init_extensions(struct dri_context *ctx) +{ + struct st_context *st = (struct st_context *) ctx->st; + + /* New extensions should be added in mesa/state_tracker/st_extensions.c + * and not in this file. */ + driInitExtensions(st->ctx, NULL, GL_FALSE); +} GLboolean dri_create_context(const __GLcontextModes * visual, diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h index 24d3d0368a4..594618874a4 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.h +++ b/src/gallium/state_trackers/dri/common/dri_context.h @@ -87,11 +87,6 @@ dri_create_context(const __GLcontextModes * visual, __DRIcontext * driContextPriv, void *sharedContextPrivate); -/*********************************************************************** - * dri_extensions.c - */ -void dri_init_extensions(struct dri_context *ctx); - #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_extensions.c b/src/gallium/state_trackers/dri/common/dri_extensions.c deleted file mode 100644 index df458e1eb0f..00000000000 --- a/src/gallium/state_trackers/dri/common/dri_extensions.c +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "state_tracker/st_context.h" - -#include "utils.h" - -void -dri_init_extensions(struct dri_context *ctx) -{ - struct st_context *st = (struct st_context *) ctx->st; - - /* New extensions should be added in mesa/state_tracker/st_extensions.c - * and not in this file. */ - driInitExtensions(st->ctx, NULL, GL_FALSE); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index 19a755b86f1..7a236da0c0f 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -16,7 +16,6 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ - dri_extensions.c \ dri_st_api.c \ dri1_helper.c \ dri1.c \ diff --git a/src/gallium/state_trackers/dri/drm/dri_extensions.c b/src/gallium/state_trackers/dri/drm/dri_extensions.c deleted file mode 120000 index e0d06dcdfa5..00000000000 --- a/src/gallium/state_trackers/dri/drm/dri_extensions.c +++ /dev/null @@ -1 +0,0 @@ -../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index 75e14fd26cb..18d7aabd9f0 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -19,7 +19,6 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ - dri_extensions.c \ dri_st_api.c \ dri1_helper.c \ drisw.c diff --git a/src/gallium/state_trackers/dri/sw/dri_extensions.c b/src/gallium/state_trackers/dri/sw/dri_extensions.c deleted file mode 120000 index e0d06dcdfa5..00000000000 --- a/src/gallium/state_trackers/dri/sw/dri_extensions.c +++ /dev/null @@ -1 +0,0 @@ -../common/dri_extensions.c \ No newline at end of file From 1fbfc22d8560c9d900832147f504ff64c64358de Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:39 +0200 Subject: [PATCH 393/483] st/dri mv __driDriverExtensions to drisw.c and dri2.c --- .../state_trackers/dri/common/dri_screen.c | 15 --------------- src/gallium/state_trackers/dri/drm/dri2.c | 8 ++++++++ src/gallium/state_trackers/dri/sw/drisw.c | 7 +++++++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 598a07bb646..53053a74c4c 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -338,14 +338,6 @@ const struct __DriverAPIRec driDriverAPI = { .CopySubBuffer = dri1_copy_sub_buffer, }; -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driLegacyExtension.base, - &driDRI2Extension.base, - NULL -}; - #else const struct __DriverAPIRec driDriverAPI = { @@ -361,13 +353,6 @@ const struct __DriverAPIRec driDriverAPI = { .SwapBuffers = drisw_swap_buffers, }; -/* This is the table of extensions that the loader will dlsym() for. */ -PUBLIC const __DRIextension *__driDriverExtensions[] = { - &driCoreExtension.base, - &driSWRastExtension.base, - NULL -}; - #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 108b18e9d3c..854801d1ea1 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -410,4 +410,12 @@ fail: return NULL; } +/* This is the table of extensions that the loader will dlsym() for. */ +PUBLIC const __DRIextension *__driDriverExtensions[] = { + &driCoreExtension.base, + &driLegacyExtension.base, + &driDRI2Extension.base, + NULL +}; + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 73bc45d9060..d7c6577818f 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -315,4 +315,11 @@ fail: return NULL; } +/* This is the table of extensions that the loader will dlsym() for. */ +PUBLIC const __DRIextension *__driDriverExtensions[] = { + &driCoreExtension.base, + &driSWRastExtension.base, + NULL +}; + /* vim: set sw=3 ts=8 sts=3 expandtab: */ From 5b07257fdbb5a93f432b8eaf3a41f39b26bdb1f3 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:39 +0200 Subject: [PATCH 394/483] st/dri: factor out common init_screen code --- .../state_trackers/dri/common/dri_screen.c | 38 ++++++++++++++++--- .../state_trackers/dri/common/dri_screen.h | 13 ++++--- src/gallium/state_trackers/dri/drm/dri1.c | 30 ++++++--------- src/gallium/state_trackers/dri/drm/dri2.c | 21 ++++------ src/gallium/state_trackers/dri/sw/drisw.c | 21 ++++------ 5 files changed, 67 insertions(+), 56 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 53053a74c4c..cbd7563938e 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -50,7 +50,6 @@ #include "util/u_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_format.h" -#include "state_tracker/drm_api.h" #include "util/u_debug.h" @@ -63,9 +62,9 @@ PUBLIC const char __driConfigOptions[] = DRI_CONF_ALLOW_LARGE_TEXTURES(1) DRI_CONF_SECTION_END DRI_CONF_END; -const uint __driNConfigOptions = 3; +static const uint __driNConfigOptions = 3; -const __DRIconfig ** +static const __DRIconfig ** dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits) { @@ -299,10 +298,8 @@ dri_destroy_option_cache(struct dri_screen * screen) } void -dri_destroy_screen(__DRIscreen * sPriv) +dri_destroy_screen_helper(struct dri_screen * screen) { - struct dri_screen *screen = dri_screen(sPriv); - dri1_destroy_pipe_context(screen); if (screen->smapi) @@ -312,12 +309,41 @@ dri_destroy_screen(__DRIscreen * sPriv) screen->pipe_screen->destroy(screen->pipe_screen); dri_destroy_option_cache(screen); +} + +static void +dri_destroy_screen(__DRIscreen * sPriv) +{ + struct dri_screen *screen = dri_screen(sPriv); + + dri_destroy_screen_helper(screen); FREE(screen); sPriv->private = NULL; sPriv->extensions = NULL; } +const __DRIconfig ** +dri_init_screen_helper(struct dri_screen *screen, + struct drm_create_screen_arg *arg, + unsigned pixel_bits) +{ + screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, arg); + if (!screen->pipe_screen) { + debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + return NULL; + } + + screen->smapi = dri_create_st_manager(screen); + if (!screen->smapi) + return NULL; + + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, __driNConfigOptions); + + return dri_fill_in_modes(screen, pixel_bits); +} + #ifndef __NOT_HAVE_DRM_H const struct __DriverAPIRec driDriverAPI = { diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 4f59db37cfa..e77bce17ae9 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -39,6 +39,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "state_tracker/st_api.h" +#include "state_tracker/drm_api.h" struct dri_screen { @@ -97,17 +98,17 @@ dri_with_format(__DRIscreen * sPriv) #endif -extern const uint __driNConfigOptions; - -const __DRIconfig ** -dri_fill_in_modes(struct dri_screen *screen, unsigned pixel_bits); - void dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, const __GLcontextModes *mode); +const __DRIconfig ** +dri_init_screen_helper(struct dri_screen *screen, + struct drm_create_screen_arg *arg, + unsigned pixel_bits); + void -dri_destroy_screen(__DRIscreen * sPriv); +dri_destroy_screen_helper(struct dri_screen * screen); #endif diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 98bdb2936a1..aad098bb301 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -469,8 +469,8 @@ dri1_copy_version(struct dri1_api_version *dst, const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv) { - struct dri_screen *screen; const __DRIconfig **configs; + struct dri_screen *screen; struct dri1_create_screen_arg arg; screen = CALLOC_STRUCT(dri_screen); @@ -495,32 +495,26 @@ dri1_init_screen(__DRIscreen * sPriv) dri1_copy_version(&arg.drm_version, &sPriv->drm_version); arg.api = NULL; - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base); - - if (!screen->pipe_screen || !arg.api) { - debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); - goto out_no_screen; - } - - __dri1_api_hooks = arg.api; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - /** * FIXME: If the driver supports format conversion swapbuffer blits, we might * want to support other color bit depths than the server is currently * using. */ - configs = dri_fill_in_modes(screen, sPriv->fbBPP); + configs = dri_init_screen_helper(screen, &arg.base, sPriv->fbBPP); if (!configs) - goto out_no_configs; + goto fail; + + if (!arg.api) { + debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__); + goto fail; + } + + __dri1_api_hooks = arg.api; return configs; - out_no_configs: - screen->pipe_screen->destroy(screen->pipe_screen); - out_no_screen: +fail: + dri_destroy_screen_helper(screen); FREE(screen); return NULL; } diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 854801d1ea1..c632f0fe4f3 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -375,6 +375,7 @@ static const __DRIextension *dri_screen_extensions[] = { const __DRIconfig ** dri2_init_screen(__DRIscreen * sPriv) { + const __DRIconfig **configs; struct dri_screen *screen; struct drm_create_screen_arg arg; @@ -385,28 +386,22 @@ dri2_init_screen(__DRIscreen * sPriv) screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = sPriv->fd; + sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; + arg.mode = DRM_CREATE_NORMAL; - screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + configs = dri_init_screen_helper(screen, &arg, 32); + if (!configs) goto fail; - } - - screen->smapi = dri_create_st_manager(screen); - if (!screen->smapi) - goto fail; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); screen->auto_fake_front = dri_with_format(sPriv); - return dri_fill_in_modes(screen, 32); + return configs; fail: - dri_destroy_screen(sPriv); + dri_destroy_screen_helper(screen); + FREE(screen); return NULL; } diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index d7c6577818f..8999ae530f2 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -282,6 +282,7 @@ static const __DRIextension *drisw_screen_extensions[] = { const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv) { + const __DRIconfig **configs; struct dri_screen *screen; struct drm_create_screen_arg arg; @@ -292,26 +293,20 @@ drisw_init_screen(__DRIscreen * sPriv) screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = -1; + sPriv->private = (void *)screen; sPriv->extensions = drisw_screen_extensions; + arg.mode = DRM_CREATE_DRISW; - screen->pipe_screen = screen->api->create_screen(screen->api, -1, &arg); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); - goto fail; - } - - screen->smapi = dri_create_st_manager(screen); - if (!screen->smapi) + configs = dri_init_screen_helper(screen, &arg, 32); + if (!configs) goto fail; - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, __driNConfigOptions); - - return dri_fill_in_modes(screen, 32); + return configs; fail: - dri_destroy_screen(sPriv); + dri_destroy_screen_helper(screen); + FREE(screen); return NULL; } From fc35d203c70a89b723e5ebeff1918e7607d67a79 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:39 +0200 Subject: [PATCH 395/483] st/dri: add comment about the ifdef in dri_screen.c --- .../state_trackers/dri/common/dri_screen.c | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index cbd7563938e..821c1dea626 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -344,8 +344,11 @@ dri_init_screen_helper(struct dri_screen *screen, return dri_fill_in_modes(screen, pixel_bits); } -#ifndef __NOT_HAVE_DRM_H - +/** + * DRI driver virtual function table. + * + * DRI versions differ in their implementation of init_screen and swap_buffers. + */ const struct __DriverAPIRec driDriverAPI = { .DestroyScreen = dri_destroy_screen, .CreateContext = dri_create_context, @@ -354,6 +357,9 @@ const struct __DriverAPIRec driDriverAPI = { .DestroyBuffer = dri_destroy_buffer, .MakeCurrent = dri_make_current, .UnbindContext = dri_unbind_context, + +#ifndef __NOT_HAVE_DRM_H + .GetSwapInfo = dri_get_swap_info, .GetDrawableMSC = driDrawableGetMSC32, .WaitForMSC = driWaitForMSC32, @@ -362,23 +368,14 @@ const struct __DriverAPIRec driDriverAPI = { .InitScreen = dri1_init_screen, .SwapBuffers = dri1_swap_buffers, .CopySubBuffer = dri1_copy_sub_buffer, -}; #else -const struct __DriverAPIRec driDriverAPI = { - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .InitScreen = drisw_init_screen, .SwapBuffers = drisw_swap_buffers, -}; #endif +}; + /* vim: set sw=3 ts=8 sts=3 expandtab: */ From d9b6552d85cfe54f2e8b9c277e05e23d84058e0b Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:40 +0200 Subject: [PATCH 396/483] dri/common: add comment about DRISW wrt DRI1 / DRI2 --- src/mesa/drivers/dri/common/drisw_util.h | 83 ++++++++++++++---------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/src/mesa/drivers/dri/common/drisw_util.h b/src/mesa/drivers/dri/common/drisw_util.h index c7d1450be13..08d5a116e96 100644 --- a/src/mesa/drivers/dri/common/drisw_util.h +++ b/src/mesa/drivers/dri/common/drisw_util.h @@ -21,9 +21,20 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/** + * @file + * Binding of the DRI interface (dri_interface.h) for DRISW. + * + * The DRISW structs are 'base classes' of the corresponding DRI1 / DRI2 (DRM) + * structs. The bindings for SW and DRM can be unified by making the DRM structs + * 'sub-classes' of the SW structs, either proper or with field re-ordering. + * + * The code can also be unified but that requires cluttering the common code + * with ifdef's and guarding with (__DRIscreen::fd >= 0) for DRM. + */ -#ifndef _DRI_SW_H -#define _DRI_SW_H +#ifndef _DRISW_UTIL_H +#define _DRISW_UTIL_H #include #include @@ -38,6 +49,39 @@ extern const __DRIcoreExtension driCoreExtension; extern const __DRIswrastExtension driSWRastExtension; +/** + * Driver callback functions + */ +struct __DriverAPIRec { + const __DRIconfig **(*InitScreen) (__DRIscreen * priv); + + void (*DestroyScreen)(__DRIscreen *driScrnPriv); + + GLboolean (*CreateContext)(const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, + void *sharedContextPrivate); + + void (*DestroyContext)(__DRIcontext *driContextPriv); + + GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, + __DRIdrawable *driDrawPriv, + const __GLcontextModes *glVis, + GLboolean pixmapBuffer); + + void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); + + void (*SwapBuffers)(__DRIdrawable *driDrawPriv); + + GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, + __DRIdrawable *driDrawPriv, + __DRIdrawable *driReadPriv); + + GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); +}; + +extern const struct __DriverAPIRec driDriverAPI; + + /** * Data types */ @@ -85,37 +129,4 @@ struct __DRIdrawableRec { int h; }; - -/** - * Driver callback functions - */ -struct __DriverAPIRec { - const __DRIconfig **(*InitScreen) (__DRIscreen * priv); - - void (*DestroyScreen)(__DRIscreen *driScrnPriv); - - GLboolean (*CreateContext)(const __GLcontextModes *glVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate); - - void (*DestroyContext)(__DRIcontext *driContextPriv); - - GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const __GLcontextModes *glVis, - GLboolean pixmapBuffer); - - void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); - - void (*SwapBuffers)(__DRIdrawable *driDrawPriv); - - GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv); - - GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); -}; - -extern const struct __DriverAPIRec driDriverAPI; - -#endif /* _DRI_SW_H */ +#endif /* _DRISW_UTIL_H */ From 3ae082f00cad3f2323a3747fe3b6f02b8f8c5285 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Mar 2010 18:44:40 +0200 Subject: [PATCH 397/483] swrastg: allow for any of the software rasterizers. This function should be put in targets/common or winsys/sw/common and shared with targers/libgl-xlib and winsys/sw/drm. For targets/common, you get layering violations in the build system unless all of drm_api's are moved under targets. --- src/gallium/state_trackers/dri/sw/drisw.c | 6 -- .../targets/dri-swrast/swrast_drm_api.c | 70 +++++++++++++++---- src/gallium/targets/libgl-xlib/xlib.c | 64 +++++++++++------ 3 files changed, 98 insertions(+), 42 deletions(-) diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 8999ae530f2..745941d5501 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -48,12 +48,6 @@ * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth * it, given the scope of DRISW, unless it falls naturally from properly * solving the above two issues. - * - * swrast_create_screen: - * - * Allow for any software renderer to be used. Factor out the code from - * targets/libgl-xlib/xlib.c, put it in targets/common or winsys/sw/common and - * use it in all software targets. */ #include "util/u_memory.h" diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 224651603d1..1fdfcccf883 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -32,6 +32,16 @@ #include "state_tracker/sw_winsys.h" #include "dri_sw_winsys.h" +/* Copied from targets/libgl-xlib. + * + * TODO: + * This function should be put in targets/common or winsys/sw/common and shared + * with targets/libgl-xlib and winsys/sw/drm. + * + * For targets/common, you get layering violations in the build system unless + * all of drm_api's are moved under targets. + */ + #ifdef GALLIUM_SOFTPIPE #include "softpipe/sp_public.h" #endif @@ -40,10 +50,51 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef GALLIUM_CELL +#include "cell/ppu/cell_public.h" +#endif + static struct pipe_screen * -swrast_create_screen(struct drm_api *api, - int drmFD, - struct drm_create_screen_arg *arg) +swrast_create_screen(struct sw_winsys *winsys) +{ + const char *default_driver; + const char *driver; + struct pipe_screen *screen = NULL; + +#if defined(GALLIUM_CELL) + default_driver = "cell"; +#elif defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#if defined(GALLIUM_CELL) + if (screen == NULL && strcmp(driver, "cell") == 0) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif + + return screen; +} + +static struct pipe_screen * +swrast_drm_create_screen(struct drm_api *api, + int drmFD, + struct drm_create_screen_arg *arg) { struct sw_winsys *winsys = NULL; struct pipe_screen *screen = NULL; @@ -63,16 +114,7 @@ swrast_create_screen(struct drm_api *api, if (winsys == NULL) return NULL; -#ifdef GALLIUM_LLVMPIPE - if (!screen) - screen = llvmpipe_create_screen(winsys); -#endif - -#ifdef GALLIUM_SOFTPIPE - if (!screen) - screen = softpipe_create_screen(winsys); -#endif - + screen = swrast_create_screen(winsys); if (!screen) goto fail; @@ -95,7 +137,7 @@ static struct drm_api swrast_drm_api = { .name = "swrast", .driver_name = "swrast", - .create_screen = swrast_create_screen, + .create_screen = swrast_drm_create_screen, .destroy = swrast_drm_api_destroy, }; diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 48e79fe4f3b..4a8366280d8 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -31,12 +31,9 @@ * Keith Whitwell */ #include "pipe/p_compiler.h" -#include "state_tracker/xlib_sw_winsys.h" #include "util/u_debug.h" -#include "softpipe/sp_public.h" -#include "llvmpipe/lp_public.h" -#include "cell/ppu/cell_public.h" #include "target-helpers/wrap_screen.h" +#include "state_tracker/xlib_sw_winsys.h" #include "xm_public.h" #include "state_tracker/st_manager.h" @@ -49,9 +46,8 @@ PUBLIC const struct st_module st_module_OpenGL = { .create_api = st_manager_create_api }; -/* Helper function to build a subset of a driver stack consisting of - * one of the software rasterizers (cell, llvmpipe, softpipe) and the - * xlib winsys. +/* Helper function to choose and instantiate one of the software rasterizers: + * cell, llvmpipe, softpipe. * * This function could be shared, but currently causes headaches for * the build systems, particularly scons if we try. Long term, want @@ -60,21 +56,26 @@ PUBLIC const struct st_module st_module_OpenGL = { * things that are painful for it now are likely to be painful for * other build systems in the future. */ + +#ifdef GALLIUM_SOFTPIPE +#include "softpipe/sp_public.h" +#endif + +#ifdef GALLIUM_LLVMPIPE +#include "llvmpipe/lp_public.h" +#endif + +#ifdef GALLIUM_CELL +#include "cell/ppu/cell_public.h" +#endif + static struct pipe_screen * -swrast_xlib_create_screen( Display *display ) +swrast_create_screen(struct sw_winsys *winsys) { const char *default_driver; const char *driver; - struct sw_winsys *winsys; struct pipe_screen *screen = NULL; - /* Create the underlying winsys, which performs presents to Xlib - * drawables: - */ - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - #if defined(GALLIUM_CELL) default_driver = "cell"; #elif defined(GALLIUM_LLVMPIPE) @@ -87,17 +88,13 @@ swrast_xlib_create_screen( Display *display ) driver = debug_get_option("GALLIUM_DRIVER", default_driver); - /* Create a software rasterizer on top of that winsys: - */ #if defined(GALLIUM_CELL) - if (screen == NULL && - strcmp(driver, "cell") == 0) + if (screen == NULL && strcmp(driver, "cell") == 0) screen = cell_create_screen( winsys ); #endif #if defined(GALLIUM_LLVMPIPE) - if (screen == NULL && - strcmp(driver, "llvmpipe") == 0) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) screen = llvmpipe_create_screen( winsys ); #endif @@ -106,6 +103,29 @@ swrast_xlib_create_screen( Display *display ) screen = softpipe_create_screen( winsys ); #endif + return screen; +} + +/* Helper function to build a subset of a driver stack consisting of + * one of the software rasterizers (cell, llvmpipe, softpipe) and the + * xlib winsys. + */ +static struct pipe_screen * +swrast_xlib_create_screen( Display *display ) +{ + struct sw_winsys *winsys; + struct pipe_screen *screen = NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = xlib_create_sw_winsys( display ); + if (winsys == NULL) + return NULL; + + /* Create a software rasterizer on top of that winsys: + */ + screen = swrast_create_screen( winsys ); if (screen == NULL) goto fail; From b005e751778736d0d743f734207582a03ce70e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 26 Mar 2010 16:29:59 +0100 Subject: [PATCH 398/483] dri/swrast: Fix missed conversion of one pixel pointer increment. This probably broke the swrast DRI driver when running X in depth 16. (cherry picked from commit 6ec259eb17dfbb74972b8cffb4e02a9dbab288cc) --- src/mesa/drivers/dri/swrast/swrast_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index 5290dc82b91..d896e154f76 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -240,7 +240,7 @@ static const GLubyte kernel[16] = { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *)row; -#define INC_PIXEL_PTR(P) P += 2 +#define INC_PIXEL_PTR(P) P++ #define STORE_PIXEL(DST, X, Y, VALUE) \ STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) #define FETCH_PIXEL(DST, SRC) \ From 7996f0fc2c167c84552701be7a48d20a897e7978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 26 Mar 2010 16:29:59 +0100 Subject: [PATCH 399/483] dri/swrast: Fix frontbuffer rendering. Was broken since the endianness fixes. (cherry picked from commit 4cf14fa80bda5f4ea65bef3a64e748e064d0bde1) --- src/mesa/drivers/dri/swrast/swrast_spantemp.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/src/mesa/drivers/dri/swrast/swrast_spantemp.h index 879a0c12e76..84873617147 100644 --- a/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ b/src/mesa/drivers/dri/swrast/swrast_spantemp.h @@ -37,7 +37,7 @@ #define _SWRAST_SPANTEMP_ONCE static INLINE void -PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) +PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLvoid *p ) { __DRIcontext *ctx = swrast_context(glCtx); __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); @@ -168,7 +168,8 @@ NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x + i, y, src[i]); PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel); } @@ -200,7 +201,8 @@ NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); #ifdef STORE_PIXEL_RGB STORE_PIXEL_RGB(pixel, x + i, y, src[i]); #else @@ -240,7 +242,8 @@ NAME(put_mono_row)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x + i, y, src); PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel); } @@ -272,7 +275,8 @@ NAME(put_values)( GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(mask); for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x[i], y[i], src[i]); PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); } @@ -294,7 +298,8 @@ NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(mask); for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x[i], y[i], src); PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); } From e9a25089f92e0cce6f72ba5e1a6c2036825290d5 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 26 Mar 2010 14:59:06 -0700 Subject: [PATCH 400/483] rtasm: Silence gnu_printf format warnings. --- src/gallium/auxiliary/rtasm/rtasm_x86sse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c index f675427d987..7595214bdf2 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c +++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c @@ -87,7 +87,7 @@ void x86_print_reg( struct x86_reg reg ) foo++; \ if (*foo) \ foo++; \ - debug_printf( "\n% 4x% 15s ", p->csr - p->store, foo ); \ + debug_printf( "\n%4x %14s ", p->csr - p->store, foo ); \ } while (0) #define DUMP_I( I ) do { \ From d4b103e031b7647012733641b8a31c19b8b852fb Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 22 Mar 2010 13:27:32 -0700 Subject: [PATCH 401/483] auto detect llvm version --- configs/linux-llvm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/linux-llvm b/configs/linux-llvm index 608f42d6df0..3a15f1d6d8b 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -24,6 +24,8 @@ ifeq ($(LLVM_VERSION),) MESA_LLVM=0 else MESA_LLVM=1 + HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=)) + DEFINES += -DHAVE_LLVM=$(HAVE_LLVM) # $(info Using LLVM version: $(LLVM_VERSION)) endif From 8260e9a8217bf003f490b17cbd9df93bf0cc6675 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 24 Feb 2010 17:43:38 -0800 Subject: [PATCH 402/483] gallium/llvmpipe: add PROGS target/rule to Makefile.template So other directory can share it. Also remove the libllvmpipe.a dependency from test programs. It is not needed any more. Signed-Off-By: Christopher Li --- src/gallium/Makefile.template | 7 +++++-- src/gallium/drivers/llvmpipe/Makefile | 14 ++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 91a9b54b362..b5a9938c740 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -26,7 +26,7 @@ INCLUDES = \ ##### TARGETS ##### -default: depend lib$(LIBNAME).a +default: depend lib$(LIBNAME).a $(PROGS) lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS) @@ -36,13 +36,16 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURC touch depend $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null +$(PROGS): % : %.o + $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group + # Emacs tags tags: etags `find . -name \*.[ch]` `find $(TOP)/src/gallium/include -name \*.h` # Remove .o and backup files clean: - rm -f $(OBJECTS) $(GENERATED_SOURCES) lib$(LIBNAME).a depend depend.bak + rm -f $(OBJECTS) $(GENERATED_SOURCES) $(PROGS) lib$(LIBNAME).a depend depend.bak # Dummy target install: diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 89c06ea3ad7..74d728ddb39 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -42,6 +42,10 @@ C_SOURCES = \ CPP_SOURCES = \ +PROGS := lp_test_format \ + lp_test_blend \ + lp_test_conv + include ../../Makefile.template @@ -49,13 +53,7 @@ lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxil python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@ -testprogs := lp_test_format \ - lp_test_blend \ - lp_test_conv +LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium -LIBS += $(GL_LIB_DEPS) -L. -lllvmpipe -L../../auxiliary/ -lgallium +$(PROGS): lp_test_main.o -#$(testprogs): lp_test_% : lp_test_%.o lp_test_main.o libllvmpipe.a -# $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group - -#default: $(testprogs) From 03832881325348871db1dad613bdcf8f4265a240 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 26 Mar 2010 17:56:13 -0700 Subject: [PATCH 403/483] st/dri: Fix SCons build. This was missed in commit 4b722bf9fde668dff1c2b55b34eb3f86c78f43fb. dri_extensions.c was removed from Makefile but not from SConscript. --- src/gallium/state_trackers/dri/drm/SConscript | 1 - src/gallium/state_trackers/dri/sw/SConscript | 1 - 2 files changed, 2 deletions(-) diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index b974e298f36..b9726ee3113 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -17,7 +17,6 @@ if env['dri']: target = 'st_dri', source = [ 'dri_context.c', 'dri_drawable.c', - 'dri_extensions.c', 'dri_screen.c', 'dri_st_api.c', 'dri1_helper.c', diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript index 0614b8f521f..c97124c8310 100644 --- a/src/gallium/state_trackers/dri/sw/SConscript +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -19,7 +19,6 @@ if env['dri']: target = 'st_drisw', source = [ 'dri_context.c', 'dri_drawable.c', - 'dri_extensions.c', 'dri_screen.c', 'dri_st_api.c', 'dri1_helper.c', From 95030062857cf8d370a0125ddf3ffc71b70c8104 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 26 Mar 2010 18:58:44 -0700 Subject: [PATCH 404/483] gallium: Fix Windows SCons build. --- src/gallium/targets/libgl-gdi/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 57704440ce7..21b4eb2abee 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -9,6 +9,7 @@ if env['platform'] == 'windows': env.Append(CPPPATH = [ '#src/gallium/state_trackers/wgl', + '#src/gallium/winsys/sw', ]) env.Append(LIBS = [ From 42f14a76a6e689abcc84de0aecd6f1d302020a79 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 26 Mar 2010 23:54:16 -0700 Subject: [PATCH 405/483] r300g: Remove unnecessary header. --- src/gallium/drivers/r300/r300_emit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 92266ba669d..c8d98997b12 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -33,7 +33,6 @@ #include "r300_fs.h" #include "r300_screen.h" #include "r300_screen_buffer.h" -#include "r300_state_inlines.h" #include "r300_vs.h" void r300_emit_blend_state(struct r300_context* r300, From c8844c5549dec7e9c47ab49d6e229980f62da74d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 27 Mar 2010 01:07:39 -0700 Subject: [PATCH 406/483] r300g: Make SWTCL clear work again. Kind of surprised that this was as little as it took. Worrying. --- src/gallium/drivers/r300/r300_state.c | 128 ----------------- src/gallium/drivers/r300/r300_state_derived.c | 132 ++++++++++++++++++ 2 files changed, 132 insertions(+), 128 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 8e9285419c3..1fc9f39e273 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1141,72 +1141,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, } } -static void r300_draw_emit_attrib(struct r300_context* r300, - enum attrib_emit emit, - enum interp_mode interp, - int index) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct tgsi_shader_info* info = &vs->info; - int output; - - output = draw_find_shader_output(r300->draw, - info->output_semantic_name[index], - info->output_semantic_index[index]); - draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output); -} - -static void r300_draw_emit_all_attribs(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_shader_semantics* vs_outputs = &vs->outputs; - int i, gen_count; - - /* Position. */ - if (vs_outputs->pos != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->pos); - } else { - assert(0); - } - - /* Point size. */ - if (vs_outputs->psize != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS, - vs_outputs->psize); - } - - /* Colors. */ - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR, - vs_outputs->color[i]); - } - } - - /* XXX Back-face colors. */ - - /* Texture coordinates. */ - gen_count = 0; - for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->generic[i]); - gen_count++; - } - } - - /* Fog coordinates. */ - if (vs_outputs->fog != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->fog); - gen_count++; - } - - /* XXX magic */ - assert(gen_count <= 8); -} - /* Update the PSC tables. */ static void r300_vertex_psc(struct r300_vertex_element_state *velems) { @@ -1246,63 +1180,6 @@ static void r300_vertex_psc(struct r300_vertex_element_state *velems) vstream->count = (i >> 1) + 1; } -/* Update the PSC tables for SW TCL, using Draw. */ -static void r300_swtcl_vertex_psc(struct r300_context *r300, - struct r300_vertex_element_state *velems) -{ - struct r300_vertex_stream_state *vstream = &velems->vertex_stream; - struct r300_vertex_shader* vs = r300->vs_state.state; - struct vertex_info* vinfo = &r300->vertex_info; - uint16_t type, swizzle; - enum pipe_format format; - unsigned i, attrib_count; - int* vs_output_tab = vs->stream_loc_notcl; - - /* For each Draw attribute, route it to the fragment shader according - * to the vs_output_tab. */ - attrib_count = vinfo->num_attribs; - DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count); - for (i = 0; i < attrib_count; i++) { - DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d," - " vs_output_tab %d\n", vinfo->attrib[i].src_index, - vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, - vs_output_tab[i]); - } - - for (i = 0; i < attrib_count; i++) { - /* Make sure we have a proper destination for our attribute. */ - assert(vs_output_tab[i] != -1); - - format = draw_translate_vinfo_format(vinfo->attrib[i].emit); - - /* Obtain the type of data in this attribute. */ - type = r300_translate_vertex_data_type(format) | - vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT; - - /* Obtain the swizzle for this attribute. Note that the default - * swizzle in the hardware is not XYZW! */ - swizzle = r300_translate_vertex_data_swizzle(format); - - /* Add the attribute to the PSC table. */ - if (i & 1) { - vstream->vap_prog_stream_cntl[i >> 1] |= type << 16; - vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; - } else { - vstream->vap_prog_stream_cntl[i >> 1] |= type; - vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; - } - } - - /* Set the last vector in the PSC. */ - if (i) { - i -= 1; - } - vstream->vap_prog_stream_cntl[i >> 1] |= - (R300_LAST_VEC << (i & 1 ? 16 : 0)); - - vstream->count = (i >> 1) + 1; -} - static void* r300_create_vertex_elements_state(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* attribs) @@ -1334,11 +1211,6 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, } r300_vertex_psc(velems); - } else { - memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); - r300_draw_emit_all_attribs(r300); - draw_compute_vertex_size(&r300->vertex_info); - r300_swtcl_vertex_psc(r300, velems); } } return velems; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 3560b6e427f..bc5431c802d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -37,6 +37,131 @@ /* r300_state_derived: Various bits of state which are dependent upon * currently bound CSO data. */ +static void r300_draw_emit_attrib(struct r300_context* r300, + enum attrib_emit emit, + enum interp_mode interp, + int index) +{ + struct r300_vertex_shader* vs = r300->vs_state.state; + struct tgsi_shader_info* info = &vs->info; + int output; + + output = draw_find_shader_output(r300->draw, + info->output_semantic_name[index], + info->output_semantic_index[index]); + draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output); +} + +static void r300_draw_emit_all_attribs(struct r300_context* r300) +{ + struct r300_vertex_shader* vs = r300->vs_state.state; + struct r300_shader_semantics* vs_outputs = &vs->outputs; + int i, gen_count; + + /* Position. */ + if (vs_outputs->pos != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->pos); + } else { + assert(0); + } + + /* Point size. */ + if (vs_outputs->psize != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS, + vs_outputs->psize); + } + + /* Colors. */ + for (i = 0; i < ATTR_COLOR_COUNT; i++) { + if (vs_outputs->color[i] != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR, + vs_outputs->color[i]); + } + } + + /* XXX Back-face colors. */ + + /* Texture coordinates. */ + gen_count = 0; + for (i = 0; i < ATTR_GENERIC_COUNT; i++) { + if (vs_outputs->generic[i] != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->generic[i]); + gen_count++; + } + } + + /* Fog coordinates. */ + if (vs_outputs->fog != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->fog); + gen_count++; + } + + /* XXX magic */ + assert(gen_count <= 8); +} + +/* Update the PSC tables for SW TCL, using Draw. */ +static void r300_swtcl_vertex_psc(struct r300_context *r300) +{ + struct r300_vertex_stream_state *vstream = r300->vertex_stream_state.state; + struct r300_vertex_shader* vs = r300->vs_state.state; + struct vertex_info* vinfo = &r300->vertex_info; + uint16_t type, swizzle; + enum pipe_format format; + unsigned i, attrib_count; + int* vs_output_tab = vs->stream_loc_notcl; + + /* XXX hax */ + memset(vstream, 0, sizeof(struct r300_vertex_stream_state)); + + /* For each Draw attribute, route it to the fragment shader according + * to the vs_output_tab. */ + attrib_count = vinfo->num_attribs; + DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count); + for (i = 0; i < attrib_count; i++) { + DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d," + " vs_output_tab %d\n", vinfo->attrib[i].src_index, + vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, + vs_output_tab[i]); + + /* Make sure we have a proper destination for our attribute. */ + assert(vs_output_tab[i] != -1); + + format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + + /* Obtain the type of data in this attribute. */ + type = r300_translate_vertex_data_type(format) | + vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT; + + /* Obtain the swizzle for this attribute. Note that the default + * swizzle in the hardware is not XYZW! */ + swizzle = r300_translate_vertex_data_swizzle(format); + + /* Add the attribute to the PSC table. */ + if (i & 1) { + vstream->vap_prog_stream_cntl[i >> 1] |= type << 16; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; + } else { + vstream->vap_prog_stream_cntl[i >> 1] |= type; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; + } + } + + /* Set the last vector in the PSC. */ + if (i) { + i -= 1; + } + vstream->vap_prog_stream_cntl[i >> 1] |= + (R300_LAST_VEC << (i & 1 ? 16 : 0)); + + vstream->count = (i >> 1) + 1; + r300->vertex_stream_state.dirty = TRUE; + r300->vertex_stream_state.size = (1 + vstream->count) * 2; +} + static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr, boolean swizzle_0001) { @@ -400,5 +525,12 @@ void r300_update_derived_state(struct r300_context* r300) r300_merge_textures_and_samplers(r300); } + if (r300->draw) { + memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); + r300_draw_emit_all_attribs(r300); + draw_compute_vertex_size(&r300->vertex_info); + r300_swtcl_vertex_psc(r300); + } + r300_update_ztop(r300); } From 29ec84b0a80e1fe2e6f58f91ab63f2f9ebd012a6 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 14:06:05 +0200 Subject: [PATCH 407/483] glx: try swrastg_dri, if swrast_dri fails This needs a patch for xserver/glx also. An enviroment variable will be added at some point, it chould be for swrastg only or all gallium drivers. --- src/glx/drisw_glx.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 3db2d63f1f7..99f8f2cbf06 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -360,6 +360,20 @@ driDestroyScreen(__GLXscreenConfigs * psc) dlclose(psc->driver); } +static void * +driOpenSwrast(void) +{ + void *driver = NULL; + + if (driver == NULL) + driver = driOpenDriver("swrast"); + + if (driver == NULL) + driver = driOpenDriver("swrastg"); + + return driver; +} + static __GLXDRIscreen * driCreateScreen(__GLXscreenConfigs * psc, int screen, __GLXdisplayPrivate * priv) @@ -367,14 +381,13 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen, __GLXDRIscreen *psp; const __DRIconfig **driver_configs; const __DRIextension **extensions; - const char *driverName = "swrast"; int i; psp = Xcalloc(1, sizeof *psp); if (psp == NULL) return NULL; - psc->driver = driOpenDriver(driverName); + psc->driver = driOpenSwrast(); if (psc->driver == NULL) goto handle_error; From a43618fdc4e046f946d5f0de6dd8a421b66e9498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= Date: Sat, 27 Mar 2010 13:40:38 +0100 Subject: [PATCH 408/483] r300g: fix macrotiling for non-square textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FDO bug #27338. Signed-off-by: Marek Olšák --- src/gallium/drivers/r300/r300_texture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 1b796257e4f..7c86bdb4bdc 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -692,7 +692,8 @@ static void r300_setup_miptree(struct r300_screen* screen, /* Let's see if this miplevel can be macrotiled. */ tex->mip_macrotile[i] = (tex->macrotile == R300_BUFFER_TILED && - r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH)) ? + r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH) && + r300_texture_macro_switch(tex, i, rv350_mode, TILE_HEIGHT)) ? R300_BUFFER_TILED : R300_BUFFER_LINEAR; stride = r300_texture_get_stride(screen, tex, i); From 038d2607ab759638217ded3bd1b232d389975af5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 27 Mar 2010 08:58:59 -0600 Subject: [PATCH 409/483] mesa: fix deadlock in _mesa_HashFindFreeKeyBlock() Fixes fd.o bug 27340. (cherry picked from commit 8fe3b3f66ae57a1a6eca7f6dcb0455e14ad92075) --- src/mesa/main/hash.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 975775469d9..f4af3fdcf70 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -127,8 +127,8 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) * * \return pointer to user's data or NULL if key not in table */ -void * -_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) +static INLINE void * +_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) { GLuint pos; const struct HashEntry *entry; @@ -137,19 +137,26 @@ _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) assert(key); pos = HASH_FUNC(key); - _glthread_LOCK_MUTEX(table->Mutex); entry = table->Table[pos]; while (entry) { if (entry->Key == key) { - _glthread_UNLOCK_MUTEX(table->Mutex); return entry->Data; } entry = entry->Next; } - _glthread_UNLOCK_MUTEX(table->Mutex); return NULL; } +void * +_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) +{ + void *res; + assert(table); + _glthread_LOCK_MUTEX(table->Mutex); + res = _mesa_HashLookup_unlocked(table, key); + _glthread_UNLOCK_MUTEX(table->Mutex); + return res; +} /** @@ -447,7 +454,7 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) GLuint freeStart = 1; GLuint key; for (key = 1; key != maxKey; key++) { - if (_mesa_HashLookup(table, key)) { + if (_mesa_HashLookup_unlocked(table, key)) { /* darn, this key is already in use */ freeCount = 0; freeStart = key+1; From 9903d09f82c525690cd016e7747ba2fe96c6468f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 27 Mar 2010 08:59:17 -0600 Subject: [PATCH 410/483] mesa: move/update hash function comments (cherry picked from commit 535742d75f0096b22d1b8ff203ae561167af18f7) --- src/mesa/main/hash.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index f4af3fdcf70..b624e6ecac1 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -120,12 +120,8 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) /** - * Lookup an entry in the hash table. - * - * \param table the hash table. - * \param key the key. - * - * \return pointer to user's data or NULL if key not in table + * Lookup an entry in the hash table, without locking. + * \sa _mesa_HashLookup */ static INLINE void * _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) @@ -147,6 +143,15 @@ _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) return NULL; } + +/** + * Lookup an entry in the hash table. + * + * \param table the hash table. + * \param key the key. + * + * \return pointer to user's data or NULL if key not in table + */ void * _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) { From 077570c12b01bafb71c145225e6e08f26b6f8f96 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 27 Mar 2010 22:25:26 +0800 Subject: [PATCH 411/483] st/egl: Fix missing symbols. ximage backend calls gallium_wrap_screen, which requires libidentity.a and libtrace.a. There are also some missing symbols in i965 due to the use of sw wrapper. --- src/gallium/targets/Makefile.egl | 8 +++++++- src/gallium/targets/egl-i915/Makefile | 1 - src/gallium/targets/egl-i965/Makefile | 6 ++++-- src/gallium/targets/egl-nouveau/Makefile | 3 +-- src/gallium/targets/egl-radeon/Makefile | 1 - src/gallium/targets/egl-swrast/Makefile | 2 +- src/gallium/targets/egl-vmwgfx/Makefile | 1 - 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gallium/targets/Makefile.egl b/src/gallium/targets/Makefile.egl index 30fced7e3c8..9265e2eb7bc 100644 --- a/src/gallium/targets/Makefile.egl +++ b/src/gallium/targets/Makefile.egl @@ -13,8 +13,14 @@ EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) common_LIBS = -ldrm -lm -ldl +# ximage backend calls gallium_wrap_screen, which requires libidentity.a and +# libtrace.a x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \ - $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a + $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/identity/libidentity.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a + x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile index efaf7b0bef9..02258fb69a4 100644 --- a/src/gallium/targets/egl-i915/Makefile +++ b/src/gallium/targets/egl-i915/Makefile @@ -7,7 +7,6 @@ EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i915/libi915.a diff --git a/src/gallium/targets/egl-i965/Makefile b/src/gallium/targets/egl-i965/Makefile index dfb3cc45a7d..fad56ef5554 100644 --- a/src/gallium/targets/egl-i965/Makefile +++ b/src/gallium/targets/egl-i965/Makefile @@ -7,8 +7,10 @@ EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i965/libi965.a + $(TOP)/src/gallium/drivers/i965/libi965.a \ + $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \ + $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a include ../Makefile.egl diff --git a/src/gallium/targets/egl-nouveau/Makefile b/src/gallium/targets/egl-nouveau/Makefile index 3da93790f25..e3fa8937e83 100644 --- a/src/gallium/targets/egl-nouveau/Makefile +++ b/src/gallium/targets/egl-nouveau/Makefile @@ -9,7 +9,6 @@ EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \ $(TOP)/src/gallium/drivers/nv50/libnv50.a \ - $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a include ../Makefile.egl diff --git a/src/gallium/targets/egl-radeon/Makefile b/src/gallium/targets/egl-radeon/Makefile index f55d84de810..8daadb59791 100644 --- a/src/gallium/targets/egl-radeon/Makefile +++ b/src/gallium/targets/egl-radeon/Makefile @@ -7,7 +7,6 @@ EGL_DRIVER_LIBS = -ldrm_radeon EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a diff --git a/src/gallium/targets/egl-swrast/Makefile b/src/gallium/targets/egl-swrast/Makefile index 937343defe5..7d4f5054983 100644 --- a/src/gallium/targets/egl-swrast/Makefile +++ b/src/gallium/targets/egl-swrast/Makefile @@ -7,6 +7,6 @@ CFLAGS+="-I$(TOP)/src/gallium/include" EGL_DRIVER_NAME = swrast EGL_DRIVER_SOURCES = swrast_glue.c EGL_DRIVER_LIBS = -EGL_DRIVER_PIPES = $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a +EGL_DRIVER_PIPES = include ../Makefile.egl diff --git a/src/gallium/targets/egl-vmwgfx/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile index 6db12e03a75..5f9385f42b0 100644 --- a/src/gallium/targets/egl-vmwgfx/Makefile +++ b/src/gallium/targets/egl-vmwgfx/Makefile @@ -7,7 +7,6 @@ EGL_DRIVER_LIBS = EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a From 02ee7c29502966dffa44243bfc8c20c15907b880 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Mar 2010 10:07:14 -0700 Subject: [PATCH 412/483] identity: Add id_drm.c to SCons build. This was missed in commit f7cbaae13d67c55abe81ac230de37f564365099f. --- src/gallium/drivers/identity/SConscript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/identity/SConscript b/src/gallium/drivers/identity/SConscript index 7f079dd0a8b..2a68891c284 100644 --- a/src/gallium/drivers/identity/SConscript +++ b/src/gallium/drivers/identity/SConscript @@ -5,9 +5,10 @@ env = env.Clone() identity = env.ConvenienceLibrary( target = 'identity', source = [ - 'id_screen.c', 'id_context.c', + 'id_drm.c', 'id_objects.c', + 'id_screen.c', ]) Export('identity') From f4e561ce127cf484d7c76c29b8cd026c9ad5cebc Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 20:32:52 +0200 Subject: [PATCH 413/483] drisw: make stride issue profound --- include/GL/internal/dri_interface.h | 12 +-- src/gallium/state_trackers/dri/sw/drisw.c | 10 +-- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 6 +- src/glx/drisw_glx.c | 92 +++++++++++++++-------- src/mesa/drivers/dri/swrast/swrast.c | 18 +++-- src/mesa/drivers/dri/swrast/swrast_priv.h | 8 -- 6 files changed, 88 insertions(+), 58 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index aa56eb45d79..fa9b7c4bf21 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -416,15 +416,15 @@ struct __DRIswrastLoaderExtensionRec { * Put image to drawable */ void (*putImage)(__DRIdrawable *drawable, int op, - int x, int y, int width, int height, char *data, - void *loaderPrivate); + int x, int y, int width, int height, + char *data, void *loaderPrivate); /** - * Get image from drawable + * Get image from readable */ - void (*getImage)(__DRIdrawable *drawable, - int x, int y, int width, int height, char *data, - void *loaderPrivate); + void (*getImage)(__DRIdrawable *readable, + int x, int y, int width, int height, + char *data, void *loaderPrivate); }; /** diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 745941d5501..a75fdf17899 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -38,16 +38,16 @@ * * drisw_api: * - * Define drisw_api similarly to dri_api and use it to call the loader. This is - * predicated on support for calling the loader from the winsys, which has to - * grow for DRI2 as well. + * Define drisw_api similarly to dri1_api and use it to call the loader. This + * is predicated on support for calling the loader from the winsys, which has + * to grow for DRI2 as well. * - * xshm: + * xshm / texture_from_pixmap / EGLImage: * * Allow the loaders to use the XSHM extension. It probably requires callbacks * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth * it, given the scope of DRISW, unless it falls naturally from properly - * solving the above two issues. + * solving the other issues. */ #include "util/u_memory.h" diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index 5549e152ee8..9e8c31282d4 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -63,11 +63,11 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, } static INLINE int -bytes_per_line(unsigned stride, unsigned mul) +bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; - return ((stride * 8 + mask) & ~mask) / 8; + return ((pitch_bits + mask) & ~mask) / 8; } /* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ @@ -88,7 +88,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, format_stride = util_format_get_stride(format, width); xm_stride = align(format_stride, alignment); - loader_stride = bytes_per_line(format_stride, 32); + loader_stride = bytes_per_line(format_stride * 8, 32); nblocksy = util_format_get_nblocksy(format, height); size = xm_stride * nblocksy; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 99f8f2cbf06..ca85ae3a313 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -53,7 +53,6 @@ struct __GLXDRIdrawablePrivateRec XVisualInfo *visinfo; XImage *ximage; - int bpp; }; /** @@ -90,13 +89,10 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ + 0, 0, /* width, height */ + 8, /* bitmap_pad */ 0); /* bytes_per_line */ - /* get the true number of bits per pixel */ - pdp->bpp = pdp->ximage->bits_per_pixel; - return True; } @@ -112,7 +108,8 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) static void swrastGetDrawableInfo(__DRIdrawable * draw, - int *x, int *y, int *w, int *h, void *loaderPrivate) + int *x, int *y, int *w, int *h, + void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -121,26 +118,20 @@ swrastGetDrawableInfo(__DRIdrawable * draw, Window root; Status stat; - unsigned int bw, depth; + unsigned uw, uh, bw, depth; drawable = pdraw->xDrawable; stat = XGetGeometry(dpy, drawable, &root, - x, y, (unsigned int *) w, (unsigned int *) h, - &bw, &depth); -} - -static inline int -bytes_per_line(int w, int bpp, unsigned mul) -{ - unsigned mask = mul - 1; - - return ((w * bpp + mask) & ~mask) / 8; + x, y, &uw, &uh, &bw, &depth); + *w = uw; + *h = uh; } static void -swrastPutImage(__DRIdrawable * draw, int op, - int x, int y, int w, int h, char *data, void *loaderPrivate) +swrastPutImage2(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, int pitch, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -166,7 +157,7 @@ swrastPutImage(__DRIdrawable * draw, int op, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = pitch; XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); @@ -174,28 +165,67 @@ swrastPutImage(__DRIdrawable * draw, int op, } static void -swrastGetImage(__DRIdrawable * draw, - int x, int y, int w, int h, char *data, void *loaderPrivate) +swrastGetImage2(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, int pitch, void *loaderPrivate) { - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; + __GLXDRIdrawablePrivate *prp = loaderPrivate; + __GLXDRIdrawable *pread = &(prp->base); + Display *dpy = pread->psc->dpy; + Drawable readable; XImage *ximage; - drawable = pdraw->xDrawable; + readable = pread->xDrawable; - ximage = pdp->ximage; + ximage = prp->ximage; ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = pitch; - XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); + XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); ximage->data = NULL; } +static inline int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + +static void +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdp = loaderPrivate; + int bpp, pitch; + + bpp = pdp->ximage->bits_per_pixel; + + pitch = bytes_per_line(w * bpp, 32); + + swrastPutImage2(draw, op, x, y, w, h, data, pitch, loaderPrivate); +} + +static void +swrastGetImage(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *prp = loaderPrivate; + int bpp, pitch; + + bpp = prp->ximage->bits_per_pixel; + + pitch = bytes_per_line(w * bpp, 32); + + swrastGetImage2(read, x, y, w, h, data, pitch, loaderPrivate); +} + static const __DRIswrastLoaderExtension swrastLoaderExtension = { {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, swrastGetDrawableInfo, diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index e9ca99a86f0..e8df26f3d06 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -206,12 +206,19 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) free(rb); } +static INLINE int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + static GLboolean swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - unsigned mask = PITCH_ALIGN_BITS - 1; TRACE; @@ -219,8 +226,7 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; - /* always pad to PITCH_ALIGN_BITS */ - xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8; + xrb->pitch = bytes_per_line(width * xrb->bpp, 32); return GL_TRUE; } @@ -394,8 +400,10 @@ dri_swap_buffers(__DRIdrawable * dPriv) fb = &drawable->Base; - frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + frontrb = + swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + backrb = + swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); /* check for signle-buffered */ if (backrb == NULL) diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 007642be95f..6679061a983 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -124,14 +124,6 @@ swrast_renderbuffer(struct gl_renderbuffer *rb) #define PF_R3G3B2 3 /**< 8bpp TrueColor: 3-R, 3-G, 2-B bits */ #define PF_X8R8G8B8 4 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */ -/** - * Renderbuffer pitch alignment (in bits). - * - * The xorg loader requires padding images to 32 bits. However, this should - * become a screen/drawable parameter XXX - */ -#define PITCH_ALIGN_BITS 32 - /* swrast_span.c */ From 3bfa23317c6b1b52ec637a03a0b623228ffc95ef Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 21:35:25 +0200 Subject: [PATCH 414/483] drisw: add comment to libGL about stride --- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 1 + src/glx/drisw_glx.c | 10 +++++++++- src/mesa/drivers/dri/swrast/swrast.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index 9e8c31282d4..ee8ec91bc52 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -62,6 +62,7 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, return TRUE; } +/* see bytes_per_line in libGL */ static INLINE int bytes_per_line(unsigned pitch_bits, unsigned mul) { diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index ca85ae3a313..5a47e4a097f 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -90,7 +90,7 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, ZPixmap, 0, /* format, offset */ NULL, /* data */ 0, 0, /* width, height */ - 8, /* bitmap_pad */ + 32, /* bitmap_pad */ 0); /* bytes_per_line */ return True; @@ -188,6 +188,14 @@ swrastGetImage2(__DRIdrawable * read, ximage->data = NULL; } +/** + * Renderbuffer pitch alignment (in bits). + * + * This should be chosen by the driver and the loader (libGL, xserver/glx) + * should use the driver provided pitch. I had a comment that the xserver + * requires padding images to 32 bits. Is this a hard requirement or can it use + * the driver pitch without extra copies ? XXX + */ static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) { diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index e8df26f3d06..8b68281fab0 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -206,6 +206,7 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) free(rb); } +/* see bytes_per_line in libGL */ static INLINE int bytes_per_line(unsigned pitch_bits, unsigned mul) { From 551bfe7a09b0d1bc277796edc10c649b2b07a5b7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 28 Mar 2010 02:11:16 +0800 Subject: [PATCH 415/483] egl: Always return the previously bound context. When a newly bound context is the same as the previously bound one, _eglBindContextToThread should still return the context instead of NULL. This gives the driver a chance to flush the context. --- src/egl/main/eglcontext.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 012d8dfe1f4..710752fbcf6 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -246,15 +246,14 @@ _eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t) _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex; oldCtx = t->CurrentContexts[apiIndex]; - if (ctx == oldCtx) - return NULL; + if (ctx != oldCtx) { + if (oldCtx) + oldCtx->Binding = NULL; + if (ctx) + ctx->Binding = t; - if (oldCtx) - oldCtx->Binding = NULL; - if (ctx) - ctx->Binding = t; - - t->CurrentContexts[apiIndex] = ctx; + t->CurrentContexts[apiIndex] = ctx; + } return oldCtx; } @@ -352,7 +351,7 @@ _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read) _eglBindContextToSurfaces(newCtx, draw, read); /* unbind the old context from its binding surfaces */ - if (oldCtx) { + if (oldCtx && oldCtx != newCtx) { /* * If the new context replaces some old context, the new one should not * be current before the replacement and it should not be bound to any From 0a82fadcdd0b6ebbc345c7c302da0e0efce40a98 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 28 Mar 2010 03:04:38 +0800 Subject: [PATCH 416/483] egl: Make _eglBindContextToSurfaces more readable. There is no effective changes given how the function is called. It is still not trivial, but it should be more readable and resemble _eglBindContextToThread a lot. --- src/egl/main/eglcontext.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 710752fbcf6..5e831aab332 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -212,21 +212,35 @@ _eglBindContextToSurfaces(_EGLContext *ctx, _EGLSurface **draw, _EGLSurface **read) { _EGLSurface *newDraw = *draw, *newRead = *read; + _EGLContext *oldCtx; - if (newDraw->CurrentContext) - newDraw->CurrentContext->DrawSurface = NULL; - newDraw->CurrentContext = ctx; + oldCtx = newDraw->CurrentContext; + if (ctx != oldCtx) { + if (oldCtx) { + assert(*draw == oldCtx->DrawSurface); + oldCtx->DrawSurface = NULL; + } + if (ctx) { + *draw = ctx->DrawSurface; + ctx->DrawSurface = newDraw; + } - if (newRead->CurrentContext) - newRead->CurrentContext->ReadSurface = NULL; - newRead->CurrentContext = ctx; + newDraw->CurrentContext = ctx; + } - if (ctx) { - *draw = ctx->DrawSurface; - ctx->DrawSurface = newDraw; + if (newRead != newDraw) + oldCtx = newRead->CurrentContext; + if (ctx != oldCtx) { + if (oldCtx) { + assert(*read == oldCtx->ReadSurface); + oldCtx->ReadSurface = NULL; + } + if (ctx) { + *read = ctx->ReadSurface; + ctx->ReadSurface = newRead; + } - *read = ctx->ReadSurface; - ctx->ReadSurface = newRead; + newRead->CurrentContext = ctx; } } From 1b5b04de75f73f0c622429a412f584a368a0803f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Mar 2010 10:07:14 -0700 Subject: [PATCH 417/483] identity: Add id_drm.c to SCons build. This was missed in commit f7cbaae13d67c55abe81ac230de37f564365099f. (cherry picked from commit 02ee7c29502966dffa44243bfc8c20c15907b880) --- src/gallium/drivers/identity/SConscript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/identity/SConscript b/src/gallium/drivers/identity/SConscript index 7f079dd0a8b..2a68891c284 100644 --- a/src/gallium/drivers/identity/SConscript +++ b/src/gallium/drivers/identity/SConscript @@ -5,9 +5,10 @@ env = env.Clone() identity = env.ConvenienceLibrary( target = 'identity', source = [ - 'id_screen.c', 'id_context.c', + 'id_drm.c', 'id_objects.c', + 'id_screen.c', ]) Export('identity') From 1bf67a3b3f220493484fa675b00cb6bf257a0a81 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Mar 2010 14:25:03 -0700 Subject: [PATCH 418/483] i965g: Add brw_winsys_debug.c to SCons build. --- src/gallium/drivers/i965/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/i965/SConscript b/src/gallium/drivers/i965/SConscript index 9c2faaf4b49..d900ea25968 100644 --- a/src/gallium/drivers/i965/SConscript +++ b/src/gallium/drivers/i965/SConscript @@ -58,6 +58,7 @@ i965 = env.ConvenienceLibrary( 'brw_vs_emit.c', 'brw_vs_state.c', 'brw_vs_surface_state.c', + 'brw_winsys_debug.c', 'brw_wm.c', # 'brw_wm_constant_buffer.c', 'brw_wm_debug.c', From 4b8d3480764daf45cbbc03d76cd8b7c81937f532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 27 Mar 2010 22:25:13 +0100 Subject: [PATCH 419/483] r300g: print errors even on non-debug builds We really need to get these into bug reports. --- src/gallium/drivers/r300/r300_chipset.c | 7 ++-- src/gallium/drivers/r300/r300_debug.c | 12 ++++-- src/gallium/drivers/r300/r300_emit.c | 12 +++--- src/gallium/drivers/r300/r300_fs.c | 5 +-- src/gallium/drivers/r300/r300_query.c | 6 ++- src/gallium/drivers/r300/r300_screen.c | 6 +-- src/gallium/drivers/r300/r300_state.c | 7 ++-- src/gallium/drivers/r300/r300_state_inlines.h | 38 ++++++++++--------- src/gallium/drivers/r300/r300_tgsi_to_rc.c | 3 +- src/gallium/drivers/r300/r300_vs.c | 2 +- 10 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index 92de297ef1d..41719862635 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -24,6 +24,8 @@ #include "util/u_debug.h" +#include + /* r300_chipset: A file all to itself for deducing the various properties of * Radeons. */ @@ -365,8 +367,7 @@ void r300_parse_chipset(struct r300_capabilities* caps) break; default: - debug_printf("r300: Warning: Unknown chipset 0x%x\n", - caps->pci_id); - break; + fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\n", + caps->pci_id); } } diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index d6177577c8d..016e8d66061 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -22,6 +22,7 @@ #include "r300_context.h" +#include struct debug_option { const char * name; @@ -69,7 +70,7 @@ void r300_init_debug(struct r300_screen * screen) } if (!opt->name) { - debug_printf("Unknown debug option: %s\n", options); + fprintf(stderr, "Unknown debug option: %s\n", options); printhint = TRUE; } @@ -81,10 +82,13 @@ void r300_init_debug(struct r300_screen * screen) } if (printhint || screen->debug & DBG_HELP) { - debug_printf("You can enable debug output by setting the RADEON_DEBUG environment variable\n" - "to a comma-separated list of debug options. Available options are:\n"); + fprintf(stderr, "You can enable debug output by setting " + "the RADEON_DEBUG environment variable\n" + "to a comma-separated list of debug options. " + "Available options are:\n"); + for(opt = debug_options; opt->name; ++opt) { - debug_printf(" %s: %s\n", opt->name, opt->description); + fprintf(stderr, " %s: %s\n", opt->name, opt->description); } } } diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index c8d98997b12..15bcf8907f3 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -186,13 +186,13 @@ static const float * get_shader_constant( break; default: - debug_printf("r300: Implementation error: " + fprintf(stderr, "r300: Implementation error: " "Unknown RC_CONSTANT type %d\n", constant->u.State[0]); } break; default: - debug_printf("r300: Implementation error: " + fprintf(stderr, "r300: Implementation error: " "Unhandled constant type %d\n", constant->Type); } @@ -514,9 +514,9 @@ static void r300_emit_query_finish(struct r300_context *r300, 0, RADEON_GEM_DOMAIN_GTT, 0); break; default: - debug_printf("r300: Implementation error: Chipset reports %d" + fprintf(stderr, "r300: Implementation error: Chipset reports %d" " pixel pipes!\n", caps->num_frag_pipes); - assert(0); + abort(); } /* And, finally, reset it to normal... */ @@ -1077,8 +1077,8 @@ validate: r300->context.flush(&r300->context, 0, NULL); if (invalid) { /* Well, hell. */ - debug_printf("r300: Stuck in validation loop, gonna quit now."); - exit(1); + fprintf(stderr, "r300: Stuck in validation loop, gonna quit now.\n"); + abort(); } invalid = TRUE; goto validate; diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 9e71e61c303..e23fef8c9f7 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -204,9 +204,8 @@ static void r300_translate_fragment_shader( r3xx_compile_fragment_program(&compiler); if (compiler.Base.Error) { /* XXX failover maybe? */ - DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n", - compiler.Base.ErrorMsg); - assert(0); + fprintf(stderr, "r300 FP: Compiler Error:\n%s", + compiler.Base.ErrorMsg); abort(); } diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 9822e6b48dd..f8b52d593d5 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -30,6 +30,8 @@ #include "r300_query.h" #include "r300_reg.h" +#include + static struct pipe_query *r300_create_query(struct pipe_context *pipe, unsigned query_type) { @@ -137,8 +139,8 @@ static boolean r300_get_query_result(struct pipe_context* pipe, if (*map == ~0U) { /* Looks like our results aren't ready yet. */ if (wait) { - debug_printf("r300: Despite waiting, OQ results haven't" - " come in yet.\n"); + fprintf(stderr, "r300: Despite waiting, OQ results haven't " + "come in yet.\n"); } temp = ~0U; break; diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index bcb8b20f736..e46f836dd2c 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -164,7 +164,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; default: - debug_printf("r300: Implementation error: Bad param %d\n", + fprintf(stderr, "r300: Implementation error: Bad param %d\n", param); return 0; } @@ -193,7 +193,7 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param) case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: return 16.0f; default: - debug_printf("r300: Implementation error: Bad paramf %d\n", + fprintf(stderr, "r300: Implementation error: Bad paramf %d\n", param); return 0.0f; } @@ -212,7 +212,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM; if (target >= PIPE_MAX_TEXTURE_TYPES) { - debug_printf("r300: Implementation error: Received bogus texture " + fprintf(stderr, "r300: Implementation error: Received bogus texture " "target %d in %s\n", target, __FUNCTION__); return FALSE; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 1fc9f39e273..b7b5e1ef03b 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -575,9 +575,8 @@ static void unsigned max_width, max_height; uint32_t zbuffer_bpp = 0; - if (state->nr_cbufs > 4) { - debug_printf("r300: Implementation error: Too many MRTs in %s, " + fprintf(stderr, "r300: Implementation error: Too many MRTs in %s, " "refusing to bind framebuffer state!\n", __FUNCTION__); return; } @@ -591,7 +590,7 @@ static void } if (state->width > max_width || state->height > max_height) { - debug_printf("r300: Implementation error: Render targets are too " + fprintf(stderr, "r300: Implementation error: Render targets are too " "big in %s, refusing to bind framebuffer state!\n", __FUNCTION__); return; } @@ -1353,7 +1352,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, /* XXX Subtract immediates and RC_STATE_* variables. */ if (buf->size > (sizeof(float) * 4 * max_size)) { - debug_printf("r300: Max size of the constant buffer is " + fprintf(stderr, "r300: Max size of the constant buffer is " "%i*4 floats.\n", max_size); abort(); } diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 8485d4f8f94..02d09c008c8 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -32,6 +32,8 @@ #include "r300_reg.h" +#include + /* Some maths. These should probably find their way to u_math, if needed. */ static INLINE int pack_float_16_6x(float f) { @@ -54,7 +56,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func) case PIPE_BLEND_MAX: return R300_COMB_FCN_MAX; default: - debug_printf("r300: Unknown blend function %d\n", blend_func); + fprintf(stderr, "r300: Unknown blend function %d\n", blend_func); assert(0); break; } @@ -100,13 +102,13 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact) case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: - debug_printf("r300: Implementation error: " + fprintf(stderr, "r300: Implementation error: " "Bad blend factor %d not supported!\n", blend_fact); assert(0); break; default: - debug_printf("r300: Unknown blend factor %d\n", blend_fact); + fprintf(stderr, "r300: Unknown blend factor %d\n", blend_fact); assert(0); break; } @@ -135,7 +137,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func) case PIPE_FUNC_ALWAYS: return R300_ZS_ALWAYS; default: - debug_printf("r300: Unknown depth/stencil function %d\n", + fprintf(stderr, "r300: Unknown depth/stencil function %d\n", zs_func); assert(0); break; @@ -163,7 +165,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op) case PIPE_STENCIL_OP_INVERT: return R300_ZS_INVERT; default: - debug_printf("r300: Unknown stencil op %d", s_op); + fprintf(stderr, "r300: Unknown stencil op %d", s_op); assert(0); break; } @@ -190,7 +192,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func) case PIPE_FUNC_ALWAYS: return R300_FG_ALPHA_FUNC_ALWAYS; default: - debug_printf("r300: Unknown alpha function %d", alpha_func); + fprintf(stderr, "r300: Unknown alpha function %d", alpha_func); assert(0); break; } @@ -209,7 +211,7 @@ r300_translate_polygon_mode_front(unsigned mode) { return R300_GA_POLY_MODE_FRONT_PTYPE_POINT; default: - debug_printf("r300: Bad polygon mode %i in %s\n", mode, + fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode, __FUNCTION__); return R300_GA_POLY_MODE_FRONT_PTYPE_TRI; } @@ -227,7 +229,7 @@ r300_translate_polygon_mode_back(unsigned mode) { return R300_GA_POLY_MODE_BACK_PTYPE_POINT; default: - debug_printf("r300: Bad polygon mode %i in %s\n", mode, + fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode, __FUNCTION__); return R300_GA_POLY_MODE_BACK_PTYPE_TRI; } @@ -255,7 +257,7 @@ static INLINE uint32_t r300_translate_wrap(int wrap) case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED; default: - debug_printf("r300: Unknown texture wrap %d", wrap); + fprintf(stderr, "r300: Unknown texture wrap %d", wrap); assert(0); return 0; } @@ -276,7 +278,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip, retval |= R300_TX_MIN_FILTER_LINEAR; break; default: - debug_printf("r300: Unknown texture filter %d\n", min); + fprintf(stderr, "r300: Unknown texture filter %d\n", min); assert(0); break; } @@ -288,7 +290,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip, retval |= R300_TX_MAG_FILTER_LINEAR; break; default: - debug_printf("r300: Unknown texture filter %d\n", mag); + fprintf(stderr, "r300: Unknown texture filter %d\n", mag); assert(0); break; } @@ -304,7 +306,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip, retval |= R300_TX_MIN_FILTER_MIP_LINEAR; break; default: - debug_printf("r300: Unknown texture filter %d\n", mip); + fprintf(stderr, "r300: Unknown texture filter %d\n", mip); assert(0); break; } @@ -370,7 +372,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { desc = util_format_description(format); if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { - debug_printf("r300: Bad format %s in %s:%d\n", util_format_name(format), + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); } @@ -391,7 +393,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { result = R300_DATA_TYPE_FLOAT_1 + (components - 1); break; default: - debug_printf("r300: Bad format %s in %s:%d\n", + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); } @@ -412,15 +414,15 @@ r300_translate_vertex_data_type(enum pipe_format format) { } break; default: - debug_printf("r300: Bad format %s in %s:%d\n", + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); - debug_printf("r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n", + fprintf(stderr, "r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n", util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)); assert(0); } break; default: - debug_printf("r300: Bad format %s in %s:%d\n", + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); } @@ -442,7 +444,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { assert(format); if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { - debug_printf("r300: Bad format %s in %s:%d\n", + fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); return 0; } diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index aff4ddd4e23..1c90cc92a96 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -25,6 +25,7 @@ #include "radeon_compiler.h" #include "radeon_program.h" +#include "tgsi/tgsi_info.h" #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_scan.h" #include "tgsi/tgsi_util.h" @@ -145,7 +146,7 @@ static unsigned translate_opcode(unsigned opcode) case TGSI_OPCODE_KIL: return RC_OPCODE_KIL; } - debug_printf("r300: Unknown TGSI/RC opcode: %i\n", opcode); + fprintf(stderr, "r300: Unknown TGSI/RC opcode: %s\n", tgsi_get_opcode_name(opcode)); return RC_OPCODE_ILLEGAL_OPCODE; } diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index bd6b95dccba..d5690caa68e 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -299,7 +299,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, r3xx_compile_vertex_program(&compiler); if (compiler.Base.Error) { /* XXX We should fallback using Draw. */ - fprintf(stderr, "r300 VP: Compiler error\n"); + fprintf(stderr, "r300 VP: Compiler error:\n%s", compiler.Base.ErrorMsg); abort(); } From a7109625aa221eb765cf8e0ee6abfe617f9515ba Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 23:34:42 +0200 Subject: [PATCH 420/483] drisw: update comment --- src/glx/drisw_glx.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5a47e4a097f..b5615239465 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -55,10 +55,6 @@ struct __GLXDRIdrawablePrivateRec XImage *ximage; }; -/** - * swrast loader functions - */ - static Bool XCreateDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable, int visualid) @@ -78,12 +74,13 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues); XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues); - /* create XImage */ + /* visual */ visTemp.screen = DefaultScreen(dpy); visTemp.visualid = visualid; visMask = (VisualScreenMask | VisualIDMask); pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals); + /* create XImage */ pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, @@ -106,6 +103,10 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) XFreeGC(dpy, pdp->swapgc); } +/** + * swrast loader functions + */ + static void swrastGetDrawableInfo(__DRIdrawable * draw, int *x, int *y, int *w, int *h, @@ -189,12 +190,17 @@ swrastGetImage2(__DRIdrawable * read, } /** - * Renderbuffer pitch alignment (in bits). + * Align renderbuffer pitch. * * This should be chosen by the driver and the loader (libGL, xserver/glx) - * should use the driver provided pitch. I had a comment that the xserver - * requires padding images to 32 bits. Is this a hard requirement or can it use - * the driver pitch without extra copies ? XXX + * should use the driver provided pitch. + * + * It seems that the xorg loader (that is the xserver loading swrast_dri for + * indirect rendering, not client-side libGL) requires that the pitch is + * exactly the image width padded to 32 bits. XXX + * + * Is this a hard requirement that requires extra copies for different pitches + * or can the xorg loader use the driver pitch without extra copies ? */ static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) From 6abc3501c6c6d99a6e115cd645cec0c94ff00e1e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Mar 2010 14:40:41 -0700 Subject: [PATCH 421/483] progs/tests: Remove duplicate texcompress2 in SConscript. --- progs/tests/SConscript | 1 - 1 file changed, 1 deletion(-) diff --git a/progs/tests/SConscript b/progs/tests/SConscript index b1c7c99a7b6..037a0c35dad 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -9,7 +9,6 @@ glx_progs = [ 'getprocaddress', 'jkrahntest', 'sharedtex', - 'texcompress2', 'texobjshare', ] From feb8d995939bd52e880defc1ea95ccb68f5aaa0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 27 Mar 2010 22:39:54 +0100 Subject: [PATCH 422/483] r300g: disable cliprects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Nicolai Hähnle for explaining this register! --- src/gallium/drivers/r300/r300_state_invariant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 4a2c68269b1..88ae75bb816 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -127,7 +127,7 @@ void r300_emit_invariant_state(struct r300_context* r300, OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000); /* XXX */ - OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa); + OUT_CS_REG(R300_SC_CLIP_RULE, 0xFFFF); END_CS; } From 4a16d325eb79d8c9da22df58aae4490bd79edaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 28 Mar 2010 00:07:45 +0100 Subject: [PATCH 423/483] r300g: handle TGSI_OPCODE_RET as END --- src/gallium/drivers/r300/r300_tgsi_to_rc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index 1c90cc92a96..3f88a2b82b9 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -273,9 +273,6 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst struct rc_instruction * dst; int i; - if (src->Instruction.Opcode == TGSI_OPCODE_END) - return; - dst = rc_insert_new_instruction(ttr->compiler, ttr->compiler->Program.Instructions.Prev); dst->U.I.Opcode = translate_opcode(src->Instruction.Opcode); dst->U.I.SaturateMode = translate_saturate(src->Instruction.Saturate); @@ -334,6 +331,7 @@ static void handle_immediate(struct tgsi_to_rc * ttr, void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens) { + struct tgsi_full_instruction *inst; struct tgsi_parse_context parser; unsigned imm_index = 0; int i; @@ -368,7 +366,15 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, imm_index++; break; case TGSI_TOKEN_TYPE_INSTRUCTION: - transform_instruction(ttr, &parser.FullToken.FullInstruction); + inst = &parser.FullToken.FullInstruction; + /* This hack with the RET opcode woudn't work with + * conditionals. */ + if (inst->Instruction.Opcode == TGSI_OPCODE_END || + inst->Instruction.Opcode == TGSI_OPCODE_RET) { + break; + } + + transform_instruction(ttr, inst); break; } } From d142e8f9d33da797e67706f7246af2694eed6d38 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sat, 27 Mar 2010 23:41:15 +0100 Subject: [PATCH 424/483] gallium/docs: add comparison between Gallium and Direct3D 11 DDI interfaces Feel free to check it and improve it if necessary. --- src/gallium/docs/d3d11ddi.txt | 492 ++++++++++++++++++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 src/gallium/docs/d3d11ddi.txt diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt new file mode 100644 index 00000000000..8aba4fde118 --- /dev/null +++ b/src/gallium/docs/d3d11ddi.txt @@ -0,0 +1,492 @@ +This document compares the D3D10/D3D11 device driver interface with Gallium. +It is written from the perspective of a developer implementing a D3D10/D3D11 driver as a Gallium state tracker. + +Note that naming and other cosmetic differences are not noted, since they don't really matter and would severely clutter the document. +Gallium/OpenGL terminology is used in preference to D3D terminology. + +NOTE: this document tries to be complete but most likely isn't fully complete and also not fully correct: please submit patches if you spot anything incorrect + +Also note that this is specifically for the DirectX 10/11 Windows Vista/7 DDI interfaces. +DirectX 9 has both user-mode (for Vista) and kernel mode (pre-Vista) interfaces, but they are significantly different from Gallium due to the presence of a lot of fixed function functionality. + +The user-visible DirectX 10/11 interfaces are distinct from the kernel DDI, but they match very closely. + +* Accessing Microsoft documentation + +See http://msdn.microsoft.com/en-us/library/dd445501.aspx ("D3D11DDI_DEVICEFUNCS") for D3D documentation. + +Also see download.microsoft.com/download/f/2/d/.../Direct3D10_web.pdf for an introduction to Direct3D 10 and the rationale for its design. + +The Windows Driver Kit contains the actual headers, as well as shader bytecode documentation; + +To get the headers from Linux, run the following, in a dedicated directory: +wget http://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO +sudo mount -o loop GRMWDK_EN_7600_1.ISO /mnt/tmp +cabextract -x /mnt/tmp/wdk/headers_cab001.cab +rename 's/^_(.*)_[0-9]*$/$1/' * +sudo umount /mnt/tmp + +d3d10umddi.h contains the DDI interface analyzed in this document: note that it is much easier to read this online on MSDN. +d3d{10,11}TokenizedProgramFormat.hpp contains the shader bytecode definitions: this is not available on MSDN. +d3d9types.h contains DX9 shader bytecode, and DX9 types +d3dumddi.h contains the DirectX 9 DDI interface + +* Glossary + +BC1: DXT1 +BC2: DXT3 +BC3: DXT5 +BC5: RGTC +BC6H: BPTC float +BC7: BPTC +CS = compute shader: OpenCL-like shader +DS = domain shader: tessellation evaluation shader +HS = hull shader: tessellation control shader +IA = input assembler: primitive assembly +Input layout: vertex elements +OM = output merger: blender +PS = pixel shader: fragment shader +Primitive topology: primitive type +Resource: buffer or texture +Shader resource (view): sampler view +SO = stream out: transform feedback +Unordered access view: view supporting random read/write access (usually from compute shaders) + +* Legend + +-: features D3D11 has and Gallium lacks ++: features Gallium has and D3D11 lacks +!: differences between D3D11 and Gallium +*: possible improvements to Gallium +>: references to comparisons of special enumerations +#: comment + +* Gallium functions with no direct D3D10/D3D11 equivalent + +clear + + Gallium supports clearing both render targets and depth/stencil with a single call + +draw_range_elements + + Gallium supports indexed draw with explicit range + +fence_signalled +fence_finish + + D3D10/D3D11 don't appear to support explicit fencing; queries can often substitute though, and flushing is supported + +set_clip_state + + Gallium supports fixed function user clip planes, D3D10/D3D11 only support using the vertex shader for them + +set_polygon_stipple + + Gallium supports polygon stipple + +surface_fill + + Gallium supports subrectangle fills of surfaces, D3D10 only supports full clears of views + +* DirectX 10/11 DDI functions and Gallium equivalents + +AbandonCommandList (D3D11 only) + - Gallium does not support deferred contexts + +CalcPrivateBlendStateSize +CalcPrivateDepthStencilStateSize +CalcPrivateDepthStencilViewSize +CalcPrivateElementLayoutSize +CalcPrivateGeometryShaderWithStreamOutput +CalcPrivateOpenedResourceSize +CalcPrivateQuerySize +CalcPrivateRasterizerStateSize +CalcPrivateRenderTargetViewSize +CalcPrivateResourceSize +CalcPrivateSamplerSize +CalcPrivateShaderResourceViewSize +CalcPrivateShaderSize +CalcDeferredContextHandleSize (D3D11 only) +CalcPrivateCommandListSize (D3D11 only) +CalcPrivateDeferredContextSize (D3D11 only) +CalcPrivateTessellationShaderSize (D3D11 only) +CalcPrivateUnorderedAccessViewSize (D3D11 only) + ! D3D11 allocates private objects itself, using the size computed here + * Gallium could do something similar to be able to put the private data inline into state tracker objects: this would allow them to fit in the same cacheline and improve performance + +CheckDeferredContextHandleSizes (D3D11 only) + - Gallium does not support deferred contexts + +CheckFormatSupport -> screen->is_format_supported + ! Gallium passes usages to this function, D3D11 returns them + - Gallium does not differentiate between blendable and non-blendable render targets + - Gallium lacks multisampled-texture and multisampled-render-target usages + +CheckMultisampleQualityLevels + * could merge this with is_format_supported + - Gallium lacks multisampling support + +CommandListExecute (D3D11 only) + - Gallium does not support command lists + +CopyStructureCount (D3D11 only) + - Gallium does not support unordered access views (views that can be written to arbitrarily from compute shaders) + +ClearDepthStencilView -> clear +ClearRenderTargetView -> clear + # D3D11 is not totally clear about whether this applies to any view or only a "currently-bound view" + + Gallium allows to clear both depth/stencil and render target(s) in a single operation + + Gallium supports double-precision depth values (but not rgba values!) + * May want to also support double-precision rgba or use "float" for "depth" + +ClearUnorderedAccessViewFloat (D3D11 only) +ClearUnorderedAccessViewUint (D3D11 only) + - Gallium does not support unordered access views (views that can be written to arbitrarily from compute shaders) + +CreateBlendState (extended in D3D10.1) -> create_blend_state + # D3D10 does not support per-RT blending, only D3D10.1 does + - Gallium lacks alpha-to-coverage + + Gallium supports logic ops + + Gallium supports dithering + + Gallium supports using the broadcast alpha component of the blend constant color + +CreateCommandList (D3D11 only) + - Gallium does not support command lists + +CreateComputeShader (D3D11 only) + - Gallium does not support compute shaders + +CreateDeferredContext (D3D11 only) + - Gallium does not support deferred contexts + +CreateDomainShader (D3D11 only) + - Gallium does not support domain shaders + +CreateHullShader (D3D11 only) + - Gallium does not support hull shaders + +CreateUnorderedAccessView (D3D11 only) + - Gallium does not support unordered access views + +CreateDepthStencilState -> create_depth_stencil_alpha_state + ! D3D11 has both a global stencil enable, and front/back enables; Gallium has only front/back enables + + Gallium has per-face writemask/valuemasks, D3D11 uses the same value for back and front + + Gallium supports the alpha test, which D3D11 lacks + +CreateDepthStencilView -> get_tex_surface +CreateRenderTargetView -> get_tex_surface + ! Gallium merges depthstencil and rendertarget views into pipe_surface, which also doubles as a 2D surface abstraction + - lack of texture array support + - lack of render-to-buffer support + + Gallium supports using 3D texture zslices as a depth/stencil buffer (in theory) + +CreateElementLayout -> create_vertex_elements_state + ! D3D11 allows sparse vertex elements (via InputRegister); in Gallium they must be specified sequentially + ! D3D11 has an extra flag (InputSlotClass) that is the same as instance_divisor == 0 + +CreateGeometryShader -> create_gs_state +CreateGeometryShaderWithStreamOutput -> create_gs_state +CreatePixelShader -> create_fs_state +CreateVertexShader -> create_vs_state + > bytecode is different (see D3d10tokenizedprogramformat.hpp) + ! D3D11 describes input/outputs separately from bytecode; Gallium has the tgsi_scan.c module to extract it from TGSI + @ TODO: look into DirectX 10/11 semantics specification and bytecode + +CheckCounter +CheckCounterInfo +CreateQuery -> create_query + - Gallium only supports occlusion, primitives generated and primitives emitted queries + ! D3D11 implements fences with "event" queries + * TIMESTAMP could be implemented as an additional fields for other queries: some cards have hardware support for exactly this + * OCCLUSIONPREDICATE is required for the OpenGL v2 occlusion query functionality + * others are performance counters, we may want them but they are not critical + +CreateRasterizerState + - Gallium lacks clamping of polygon offset depth biases + - Gallium lacks support to disable depth clipping + - Gallium lacks multisampling + + Gallium, like OpenGL, supports PIPE_POLYGON_MODE_POINT + + Gallium, like OpenGL, supports per-face polygon fill modes + + Gallium, like OpenGL, supports culling everything + + Gallium, like OpenGL, supports two-side lighting; D3D11 only has the facing attribute + + Gallium, like OpenGL, supports per-fill-mode polygon offset enables + + Gallium, like OpenGL, supports polygon smoothing + + Gallium, like OpenGL, supports polygon stipple + + Gallium, like OpenGL, supports point smoothing + + Gallium, like OpenGL, supports point sprites + + Gallium supports specifying point quad rasterization + + Gallium, like OpenGL, supports per-point point size + + Gallium, like OpenGL, supports line smoothing + + Gallium, like OpenGL, supports line stipple + + Gallium supports line last pixel rule specification + + Gallium, like OpenGL, supports provoking vertex convention + + Gallium supports D3D9 rasterization rules + + Gallium supports fixed line width + + Gallium supports fixed point size + +CreateResource -> texture_create or buffer_create + ! D3D11 passes the dimensions of all mipmap levels to the create call, while Gallium has an implicit floor(x/2) rule + # Note that hardware often has the implicit rule, so the D3D11 interface seems to make little sense + # Also, the D3D11 API does not allow the user to specify mipmap sizes, so this really seems a dubious decision on Microsoft's part + - D3D11 supports specifying initial data to write in the resource + - Gallium lacks support for stream output buffer usage + - Gallium does not support unordered access buffers + ! D3D11 specifies mapping flags (i.e. read/write/discard);:it's unclear what they are used for here + - D3D11 supports odd things in the D3D10_DDI_RESOURCE_MISC_FLAG enum (D3D10_DDI_RESOURCE_MISC_DISCARD_ON_PRESENT, D3D11_DDI_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, D3D11_DDI_RESOURCE_MISC_BUFFER_STRUCTURED) + - Gallium does not support indirect draw call parameter buffers + - Gallium lacks multisampling + - Gallium lacks array textures + ! D3D11 supports specifying hardware modes and other stuff here for scanout resources + + Gallium allows specifying minimum buffer alignment + ! D3D11 implements cube maps as 2D array textures + +CreateSampler + - D3D11 supports a monochrome convolution filter for "text filtering" + + Gallium supports non-normalized coordinates + + Gallium supports CLAMP, MIRROR_CLAMP and MIRROR_CLAMP_TO_BORDER + + Gallium supports setting min/max/mip filters and anisotropy independently + +CreateShaderResourceView (extended in D3D10.1) -> create_sampler_view + - Gallium lacks sampler views over buffers + - Gallium lacks texture arrays, and cube map views over texture arrays + + Gallium supports specifying a swizzle + ! D3D11 implements "cube views" as views into a 2D array texture + +CsSetConstantBuffers (D3D11 only) +CsSetSamplers (D3D11 only) +CsSetShader (D3D11 only) +CsSetShaderResources (D3D11 only) +CsSetShaderWithIfaces (D3D11 only) +CsSetUnorderedAccessViews (D3D11 only) + - Gallium does not support compute shaders + +DestroyBlendState +DestroyCommandList (D3D11 only) +DestroyDepthStencilState +DestroyDepthStencilView +DestroyDevice +DestroyElementLayout +DestroyQuery +DestroyRasterizerState +DestroyRenderTargetView +DestroyResource +DestroySampler +DestroyShader +DestroyShaderResourceView +DestroyUnorderedAccessView (D3D11 only) + # these are trivial + +Dispatch (D3D11 only) + - Gallium does not support compute shaders + +DispatchIndirect (D3D11 only) + - Gallium does not support compute shaders + +Draw -> draw_arrays + ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better + +DrawAuto + - Gallium lacks stream out and DrawAuto + +DrawIndexed -> draw_elements + ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better + * may want to add a separate set_index_buffer + - Gallium lacks base vertex for indexed draw calls + + D3D11 lacks draw_range_elements functionality, which is required for OpenGL + +DrawIndexedInstanced -> draw_elements_instanced + ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better + * may want to add a separate set_index_buffer + - Gallium lacks base vertex for indexed draw calls + +DrawIndexedInstancedIndirect (D3D11 only) -> call draw_elements_instanced multiple times in software + # this allows to use an hardware buffer to specify the parameters for multiple draw_elements_instanced calls + - Gallium does not support draw call parameter buffers and indirect draw + +DrawInstanced -> draw_arrays_instanced + ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better + +DrawInstancedIndirect (D3D11 only) -> call draw_arrays_instanced multiple times in software + # this allows to use an hardware buffer to specify the parameters for multiple draw_arrays_instanced calls + - Gallium does not support draw call parameter buffers and indirect draws + +DsSetConstantBuffers (D3D11 only) +DsSetSamplers (D3D11 only) +DsSetShader (D3D11 only) +DsSetShaderResources (D3D11 only) +DsSetShaderWithIfaces (D3D11 only) + - Gallium does not support domain shaders + +Flush -> flush + ! Gallium supports fencing and several kinds of flushing here, D3D11 just has a dumb glFlush-like function + +GenMips + - Gallium lacks a mipmap generation interface, and does this manually with the 3D engine + * it may be useful to add a mipmap generation interface, since the hardware (especially older cards) may have a better way than using the 3D engine + +GsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_GEOMETRY, i, phBuffers[i]) + +GsSetSamplers + - Gallium does not support sampling in geometry shaders + +GsSetShader -> bind_gs_state + +GsSetShaderWithIfaces (D3D11 only) + - Gallium does not support shader interfaces + +GsSetShaderResources + - Gallium does not support sampling in geometry shaders + +HsSetConstantBuffers (D3D11 only) +HsSetSamplers (D3D11 only) +HsSetShader (D3D11 only) +HsSetShaderResources (D3D11 only) +HsSetShaderWithIfaces (D3D11 only) + - Gallium does not support hull shaders + +IaSetIndexBuffer + ! Gallium passes this to the draw_elements or draw_elements_instanced calls + + Gallium supports 8-bit indices + ! the D3D11 interface allows index-size-unaligned byte offsets into index buffers; it's not clear whether they actually work + +IaSetInputLayout -> bind_vertex_elements_state + +IaSetTopology + ! Gallium passes the topology = primitive type to the draw calls + * may want to add an interface for this + - Gallium lacks support for DirectX 11 tessellated primitives + + Gallium supports line loops, triangle fans, quads, quad strips and polygons + +IaSetVertexBuffers -> set_vertex_buffers + + Gallium allows to specify a max_index here + - Gallium only allows setting all vertex buffers at once, while D3D11 supports setting a subset + +OpenResource -> texture_from_handle + +PsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_FRAGMENT, i, phBuffers[i]) + [*] may want to split into fragment/vertex-specific versions + +PsSetSamplers -> bind_fragment_sampler_states + [*] may want to allow binding subsets instead of all at once + +PsSetShader -> bind_fs_state + +PsSetShaderWithIfaces (D3D11 only) + - Gallium does not support shader interfaces + +PsSetShaderResources -> set_fragment_sampler_views + [*] may want to allow binding subsets instead of all at once + +QueryBegin -> begin_query + +QueryEnd -> end_query + +QueryGetData -> get_query_result + - D3D11 supports reading an arbitrary data chunk for query results, Gallium only supports reading a 64-bit integer + + D3D11 doesn't seem to support actually waiting for the query result (?!) + - D3D11 supports optionally not flushing command buffers here and instead returning DXGI_DDI_ERR_WASSTILLDRAWING + +RecycleCommandList (D3D11 only) +RecycleCreateCommandList (D3D11 only) +RecycleDestroyCommandList (D3D11 only) + - Gallium does not support command lists + +RecycleCreateDeferredContext (D3D11 only) + - Gallium does not support deferred contexts + +RelocateDeviceFuncs + - Gallium does not support moving pipe_context, while D3D11 seems to, using this + +ResetPrimitiveID (D3D10.1+ only, #ifdef D3D10PSGP) + # used to do vertex processing on the GPU on Intel G45 chipsets when it is faster this way (see www.intel.com/Assets/PDF/whitepaper/322931.pdf) + # presumably this resets the primitive id system value + - Gallium does not support vertex pipeline bypass anymore + +ResourceCopy +ResourceCopyRegion +ResourceConvert (D3D10.1+ only) +ResourceConvertRegion (D3D10.1+ only) + -> surface_copy + - Gallium does not support hardware buffer copies + - Gallium does not support copying 3D texture subregions in a single call + +ResourceIsStagingBusy -> is_texture_referenced, is_buffer_referenced + - Gallium does not support checking reference for a whole texture, but only a specific surface + +ResourceReadAfterWriteHazard + ! Gallium specifies hides this, except for the render and texture caches + +ResourceResolveSubresource + - Gallium does not support multisample sample resolution + +ResourceMap +ResourceUnmap +DynamicConstantBufferMapDiscard +DynamicConstantBufferUnmap +DynamicIABufferMapDiscard +DynamicIABufferMapNoOverwrite +DynamicIABufferUnmap +DynamicResourceMapDiscard +DynamicResourceUnmap +StagingResourceMap +StagingResourceUnmap + -> buffer_map / buffer_unmap + -> transfer functions + ! Gallium and D3D have different semantics for transfers + * D3D separates vertex/index buffers from constant buffers + ! D3D separates some buffer flags into specialized calls + +ResourceUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources +DefaultConstantBufferUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources + +SetBlendState -> bind_blend_state and set_blend_color + ! D3D11 fuses bind_blend_state and set_blend_color in a single function + - Gallium lacks the sample mask + +SetDepthStencilState -> bind_depth_stencil_alpha_state and set_stencil_ref + ! D3D11 fuses bind_depth_stencil_alpha_state and set_stencil_ref in a single function + +SetPredication -> render_condition + # here both D3D11 and Gallium seem very limited (hardware is too, probably though) + # ideally, we should support nested conditional rendering, as well as more complex tests (checking for an arbitrary range, after an AND with arbitrary mask ) + # of couse, hardware support is probably as limited as OpenGL/D3D11 + + Gallium, like NV_conditional_render, supports by-region and wait flags + - D3D11 supports predication conditional on being equal any value (along with occlusion predicates); Gallium only supports on non-zero + +SetRasterizerState -> bind_rasterizer_state + +SetRenderTargets (extended in D3D11) -> set_framebuffer_state + ! Gallium passed a width/height here, D3D11 does not + ! Gallium lacks ClearTargets (but this is redundant and the driver can trivially compute this if desired) + - Gallium does not support unordered access views + - Gallium does not support geometry shader selection of texture array image / 3D texture zslice + +SetResourceMinLOD (D3D11 only) + - Gallium does not support min lod directly on textures + +SetScissorRects + - Gallium lacks support for multiple geometry-shader-selectable scissor rectangles D3D11 has + +SetTextFilterSize + - Gallium lacks support for text filters + +SetVertexPipelineOutput (D3D10.1+ only) + # used to do vertex processing on the GPU on Intel G45 chipsets when it is faster this way (see www.intel.com/Assets/PDF/whitepaper/322931.pdf) + - Gallium does not support vertex pipeline bypass anymore + +SetViewports + - Gallium lacks support for multiple geometry-shader-selectable viewports D3D11 has + +ShaderResourceViewReadAfterWriteHazard -> flush(PIPE_FLUSH_RENDER_CACHE) + - Gallium does not support specifying this per-render-target/view + +SoSetTargets + - Gallium does not support stream out + +VsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_VERTEX, i, phBuffers[i]) + [*] may want to split into fragment/vertex-specific versions + +VsSetSamplers -> bind_vertex_sampler_states + [*] may want to allow binding subsets instead of all at once + +VsSetShader -> bind_vs_state + +VsSetShaderWithIfaces (D3D11 only) + - Gallium does not support shader interfaces + +VsSetShaderResources -> set_fragment_sampler_views + [*] may want to allow binding subsets instead of all at once From add226ea44d26db80fc8868ac422a2daf782003c Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sun, 28 Mar 2010 16:41:54 +0200 Subject: [PATCH 425/483] gallium/docs: fix formatting mistakes in d3d11ddi.txt --- src/gallium/docs/d3d11ddi.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt index 8aba4fde118..0baf2682871 100644 --- a/src/gallium/docs/d3d11ddi.txt +++ b/src/gallium/docs/d3d11ddi.txt @@ -15,9 +15,9 @@ The user-visible DirectX 10/11 interfaces are distinct from the kernel DDI, but See http://msdn.microsoft.com/en-us/library/dd445501.aspx ("D3D11DDI_DEVICEFUNCS") for D3D documentation. -Also see download.microsoft.com/download/f/2/d/.../Direct3D10_web.pdf for an introduction to Direct3D 10 and the rationale for its design. +Also see http://download.microsoft.com/download/f/2/d/f2d5ee2c-b7ba-4cd0-9686-b6508b5479a1/direct3d10_web.pdf ("The Direct3D 10 System" by David Blythe) for an introduction to Direct3D 10 and the rationale for its design. -The Windows Driver Kit contains the actual headers, as well as shader bytecode documentation; +The Windows Driver Kit contains the actual headers, as well as shader bytecode documentation. To get the headers from Linux, run the following, in a dedicated directory: wget http://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO @@ -358,10 +358,10 @@ IaSetVertexBuffers -> set_vertex_buffers OpenResource -> texture_from_handle PsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_FRAGMENT, i, phBuffers[i]) - [*] may want to split into fragment/vertex-specific versions + * may want to split into fragment/vertex-specific versions PsSetSamplers -> bind_fragment_sampler_states - [*] may want to allow binding subsets instead of all at once + * may want to allow binding subsets instead of all at once PsSetShader -> bind_fs_state @@ -369,7 +369,7 @@ PsSetShaderWithIfaces (D3D11 only) - Gallium does not support shader interfaces PsSetShaderResources -> set_fragment_sampler_views - [*] may want to allow binding subsets instead of all at once + * may want to allow binding subsets instead of all at once QueryBegin -> begin_query @@ -478,10 +478,10 @@ SoSetTargets - Gallium does not support stream out VsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_VERTEX, i, phBuffers[i]) - [*] may want to split into fragment/vertex-specific versions + * may want to split into fragment/vertex-specific versions VsSetSamplers -> bind_vertex_sampler_states - [*] may want to allow binding subsets instead of all at once + * may want to allow binding subsets instead of all at once VsSetShader -> bind_vs_state @@ -489,4 +489,4 @@ VsSetShaderWithIfaces (D3D11 only) - Gallium does not support shader interfaces VsSetShaderResources -> set_fragment_sampler_views - [*] may want to allow binding subsets instead of all at once + * may want to allow binding subsets instead of all at once From c42fe8cd278fdff831f557bbfcbfde16bd38a65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 28 Mar 2010 17:00:46 +0100 Subject: [PATCH 426/483] util: Update MSDN links. --- src/gallium/auxiliary/util/u_format.csv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 11243e73492..d2a925141b1 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -47,9 +47,9 @@ # - color space: rgb, yub, sz # # See also: -# - http://msdn.microsoft.com/en-us/library/ee416489.aspx (D3D9) -# - http://msdn.microsoft.com/en-us/library/ee415668.aspx (D3D9 -> D3D10) -# - http://msdn.microsoft.com/en-us/library/ee418116.aspx (D3D10) +# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9) +# - http://msdn.microsoft.com/en-us/library/bb205073.aspx#mapping_texture_formats (D3D9 -> D3D10) +# - http://msdn.microsoft.com/en-us/library/bb173059.aspx (D3D10) # # Note that GL doesn't really specify the layout of internal formats. See # OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized From a24fc90703f62d286031cb2ee8f625ef728243fd Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sun, 28 Mar 2010 19:30:03 +0300 Subject: [PATCH 427/483] drisw: probably better hack for stride and some comments --- src/gallium/state_trackers/dri/sw/drisw.c | 19 +++- .../targets/dri-swrast/swrast_drm_api.c | 4 +- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 25 +----- src/glx/drisw_glx.c | 89 +++++++------------ 4 files changed, 50 insertions(+), 87 deletions(-) diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index a75fdf17899..b7eba63bcb9 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -48,8 +48,13 @@ * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth * it, given the scope of DRISW, unless it falls naturally from properly * solving the other issues. + * + * fences: + * + * No fences are used, are they needed for llvmpipe / cell ? */ +#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_inlines.h" #include "pipe/p_context.h" @@ -75,14 +80,19 @@ get_drawable_info(__DRIdrawable *dPriv, int *w, int *h) dPriv->loaderPrivate); } +/* + * Set the width to 'stride / cpp'. PutImage seems to correctly clip the width + * to the actual width of the dst drawable. Even if this is not specified but + * an implementation detail, it is the correct thing to do, so rely on it. XXX + */ static INLINE void -put_image(__DRIdrawable *dPriv, void *data) +put_image(__DRIdrawable *dPriv, void *data, unsigned width) { __DRIscreen *sPriv = dPriv->driScreenPriv; const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, - 0, 0, dPriv->w, dPriv->h, + 0, 0, width, dPriv->h, data, dPriv->loaderPrivate); } @@ -102,6 +112,7 @@ drisw_present_texture(__DRIdrawable *dPriv, struct pipe_surface *psurf; struct pipe_transfer *ptrans; void *pmap; + unsigned width; pipe = dri1_get_pipe_context(screen); psurf = dri1_get_pipe_surface(drawable, ptex); @@ -112,11 +123,13 @@ drisw_present_texture(__DRIdrawable *dPriv, PIPE_TRANSFER_READ, 0, 0, dPriv->w, dPriv->h); + width = ptrans->stride / util_format_get_blocksize(ptex->format); + pmap = pipe->transfer_map(pipe, ptrans); assert(pmap); - put_image(dPriv, pmap); + put_image(dPriv, pmap, width); pipe->transfer_unmap(pipe, ptrans); diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 1fdfcccf883..1f24d7650d7 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -38,8 +38,8 @@ * This function should be put in targets/common or winsys/sw/common and shared * with targets/libgl-xlib and winsys/sw/drm. * - * For targets/common, you get layering violations in the build system unless - * all of drm_api's are moved under targets. + * For targets/common, you get layering violations unless all of drm_api's are + * moved under targets. */ #ifdef GALLIUM_SOFTPIPE diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index ee8ec91bc52..1c1e5612d28 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -62,15 +62,6 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, return TRUE; } -/* see bytes_per_line in libGL */ -static INLINE int -bytes_per_line(unsigned pitch_bits, unsigned mul) -{ - unsigned mask = mul - 1; - - return ((pitch_bits + mask) & ~mask) / 8; -} - /* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ static struct sw_displaytarget * xm_displaytarget_create(struct sw_winsys *winsys, @@ -81,7 +72,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, unsigned *stride) { struct xm_displaytarget *xm_dt; - unsigned nblocksy, size, xm_stride, loader_stride, format_stride; + unsigned nblocksy, size, xm_stride, format_stride; xm_dt = CALLOC_STRUCT(xm_displaytarget); if(!xm_dt) @@ -89,27 +80,15 @@ xm_displaytarget_create(struct sw_winsys *winsys, format_stride = util_format_get_stride(format, width); xm_stride = align(format_stride, alignment); - loader_stride = bytes_per_line(format_stride * 8, 32); nblocksy = util_format_get_nblocksy(format, height); size = xm_stride * nblocksy; -#ifdef DEBUG - debug_printf("swrast format stride: %8d\n", format_stride); - debug_printf("swrast pipe stride : %8d\n", xm_stride); - debug_printf("swrast loader stride: %8d\n", loader_stride); -#endif - - /* - * Allocate with the aligned stride required by the pipe but set the stride - * to the one hardcoded in the loaders XXX - */ - xm_dt->data = align_malloc(size, alignment); if(!xm_dt->data) goto no_data; - *stride = loader_stride; + *stride = xm_stride; return (struct sw_displaytarget *)xm_dt; no_data: diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index b5615239465..786faff81c1 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -129,10 +129,32 @@ swrastGetDrawableInfo(__DRIdrawable * draw, *h = uh; } +/** + * Align renderbuffer pitch. + * + * This should be chosen by the driver and the loader (libGL, xserver/glx) + * should use the driver provided pitch. + * + * It seems that the xorg loader (that is the xserver loading swrast_dri for + * indirect rendering, not client-side libGL) requires that the pitch is + * exactly the image width padded to 32 bits. XXX + * + * The above restriction can probably be overcome by using ScratchPixmap and + * CopyArea in the xserver, similar to ShmPutImage, and setting the width of + * the scratch pixmap to 'pitch / cpp'. + */ +static inline int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + static void -swrastPutImage2(__DRIdrawable * draw, int op, - int x, int y, int w, int h, - char *data, int pitch, void *loaderPrivate) +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -158,7 +180,7 @@ swrastPutImage2(__DRIdrawable * draw, int op, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = pitch; + ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); @@ -166,9 +188,9 @@ swrastPutImage2(__DRIdrawable * draw, int op, } static void -swrastGetImage2(__DRIdrawable * read, - int x, int y, int w, int h, - char *data, int pitch, void *loaderPrivate) +swrastGetImage(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, void *loaderPrivate) { __GLXDRIdrawablePrivate *prp = loaderPrivate; __GLXDRIdrawable *pread = &(prp->base); @@ -182,64 +204,13 @@ swrastGetImage2(__DRIdrawable * read, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = pitch; + ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); ximage->data = NULL; } -/** - * Align renderbuffer pitch. - * - * This should be chosen by the driver and the loader (libGL, xserver/glx) - * should use the driver provided pitch. - * - * It seems that the xorg loader (that is the xserver loading swrast_dri for - * indirect rendering, not client-side libGL) requires that the pitch is - * exactly the image width padded to 32 bits. XXX - * - * Is this a hard requirement that requires extra copies for different pitches - * or can the xorg loader use the driver pitch without extra copies ? - */ -static inline int -bytes_per_line(unsigned pitch_bits, unsigned mul) -{ - unsigned mask = mul - 1; - - return ((pitch_bits + mask) & ~mask) / 8; -} - -static void -swrastPutImage(__DRIdrawable * draw, int op, - int x, int y, int w, int h, - char *data, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - int bpp, pitch; - - bpp = pdp->ximage->bits_per_pixel; - - pitch = bytes_per_line(w * bpp, 32); - - swrastPutImage2(draw, op, x, y, w, h, data, pitch, loaderPrivate); -} - -static void -swrastGetImage(__DRIdrawable * read, - int x, int y, int w, int h, - char *data, void *loaderPrivate) -{ - __GLXDRIdrawablePrivate *prp = loaderPrivate; - int bpp, pitch; - - bpp = prp->ximage->bits_per_pixel; - - pitch = bytes_per_line(w * bpp, 32); - - swrastGetImage2(read, x, y, w, h, data, pitch, loaderPrivate); -} - static const __DRIswrastLoaderExtension swrastLoaderExtension = { {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, swrastGetDrawableInfo, From 42ab3f6fd2a019e63bf66cc59c5afb8cb6a53741 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 26 Mar 2010 17:19:45 -0700 Subject: [PATCH 428/483] st/python: updates for recent interface changes Still problems at runtime with vertex elements, etc. Building still disabled. --- src/gallium/state_trackers/python/p_texture.i | 86 +++++++++---------- src/gallium/state_trackers/python/st_device.c | 22 ++--- src/gallium/state_trackers/python/st_sample.c | 5 +- .../python/st_softpipe_winsys.c | 2 +- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 761587dc533..2dd9e5050ea 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -125,10 +125,10 @@ struct st_surface } %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); - void get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) + void get_tile_raw(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) { struct pipe_texture *texture = $self->texture; - struct pipe_screen *screen = texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; unsigned stride; @@ -138,7 +138,7 @@ struct st_surface if(!*STRING) return; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -146,16 +146,16 @@ struct st_surface PIPE_TRANSFER_READ, x, y, w, h); if(transfer) { - pipe_get_tile_raw(transfer, 0, 0, w, h, *STRING, stride); - screen->tex_transfer_destroy(transfer); + pipe_get_tile_raw(pipe, transfer, 0, 0, w, h, *STRING, stride); + pipe->tex_transfer_destroy(pipe, transfer); } } %cstring_input_binary(const char *STRING, unsigned LENGTH); - void put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *STRING, unsigned LENGTH, unsigned stride = 0) + void put_tile_raw(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const char *STRING, unsigned LENGTH, unsigned stride = 0) { struct pipe_texture *texture = $self->texture; - struct pipe_screen *screen = texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; if(stride == 0) @@ -164,7 +164,7 @@ struct st_surface if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride) SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size"); - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -174,19 +174,18 @@ struct st_surface if(!transfer) SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer"); - pipe_put_tile_raw(transfer, 0, 0, w, h, STRING, stride); - screen->tex_transfer_destroy(transfer); + pipe_put_tile_raw(pipe, transfer, 0, 0, w, h, STRING, stride); + pipe->tex_transfer_destroy(pipe, transfer); fail: return; } - void - get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) + void get_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -194,17 +193,17 @@ struct st_surface PIPE_TRANSFER_READ, x, y, w, h); if(transfer) { - pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba); - screen->tex_transfer_destroy(transfer); + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); + pipe->tex_transfer_destroy(pipe, transfer); } } void - put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) + put_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -212,16 +211,16 @@ struct st_surface PIPE_TRANSFER_WRITE, x, y, w, h); if(transfer) { - pipe_put_tile_rgba(transfer, 0, 0, w, h, rgba); - screen->tex_transfer_destroy(transfer); + pipe_put_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); + pipe->tex_transfer_destroy(pipe, transfer); } } %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); void - get_tile_rgba8(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) + get_tile_rgba8(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; float *rgba; unsigned char *rgba8; @@ -244,7 +243,7 @@ struct st_surface rgba8 = (unsigned char *) *STRING; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -253,24 +252,23 @@ struct st_surface x, y, w, h); if(transfer) { - pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba); + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); for(j = 0; j < h; ++j) { for(i = 0; i < w; ++i) for(k = 0; k <4; ++k) rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]); } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } free(rgba); } - void - get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) + void get_tile_z(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -278,17 +276,16 @@ struct st_surface PIPE_TRANSFER_READ, x, y, w, h); if(transfer) { - pipe_get_tile_z(transfer, 0, 0, w, h, z); - screen->tex_transfer_destroy(transfer); + pipe_get_tile_z(pipe, transfer, 0, 0, w, h, z); + pipe->tex_transfer_destroy(pipe, transfer); } } - void - put_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z) + void put_tile_z(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -296,20 +293,21 @@ struct st_surface PIPE_TRANSFER_WRITE, x, y, w, h); if(transfer) { - pipe_put_tile_z(transfer, 0, 0, w, h, z); - screen->tex_transfer_destroy(transfer); + pipe_put_tile_z(pipe, transfer, 0, 0, w, h, z); + pipe->tex_transfer_destroy(pipe, transfer); } } +/* void sample_rgba(float *rgba) { st_sample_surface($self, rgba); } +*/ - unsigned - compare_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0) + unsigned compare_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0) { - struct pipe_screen *screen = $self->texture->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_transfer *transfer; float *rgba2; const float *p1; @@ -320,7 +318,7 @@ struct st_surface if(!rgba2) return ~0; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, $self->texture, $self->face, $self->level, @@ -332,8 +330,8 @@ struct st_surface return ~0; } - pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba2); - screen->tex_transfer_destroy(transfer); + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba2); + pipe->tex_transfer_destroy(pipe, transfer); p1 = rgba; p2 = rgba2; diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 0d87c705e75..44d65e3fc1e 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -31,6 +31,7 @@ #include "pipe/p_shader_tokens.h" #include "util/u_inlines.h" #include "cso_cache/cso_context.h" +#include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_sampler.h" @@ -228,6 +229,7 @@ st_context_create(struct st_device *st_dev) /* default textures */ { + struct pipe_context *pipe = st_ctx->pipe; struct pipe_screen *screen = st_dev->screen; struct pipe_texture templat; struct pipe_transfer *transfer; @@ -245,21 +247,21 @@ st_context_create(struct st_device *st_dev) st_ctx->default_texture = screen->texture_create( screen, &templat ); if(st_ctx->default_texture) { - transfer = screen->get_tex_transfer(screen, - st_ctx->default_texture, - 0, 0, 0, - PIPE_TRANSFER_WRITE, - 0, 0, - st_ctx->default_texture->width0, - st_ctx->default_texture->height0); + transfer = pipe->get_tex_transfer(pipe, + st_ctx->default_texture, + 0, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, + st_ctx->default_texture->width0, + st_ctx->default_texture->height0); if (transfer) { uint32_t *map; - map = (uint32_t *) screen->transfer_map(screen, transfer); + map = (uint32_t *) pipe->transfer_map(pipe, transfer); if(map) { *map = 0x00000000; - screen->transfer_unmap(screen, transfer); + pipe->transfer_unmap(pipe, transfer); } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } } diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index e1808153461..f9622533fbc 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -521,7 +521,7 @@ st_sample_pixel_block(enum pipe_format format, } } - +#if 0 void st_sample_surface(struct st_surface *surface, float *rgba) { @@ -533,7 +533,7 @@ st_sample_surface(struct st_surface *surface, float *rgba) struct pipe_transfer *transfer; void *raw; - transfer = screen->get_tex_transfer(screen, + transfer = pipe->get_tex_transfer(pipe, surface->texture, surface->face, surface->level, @@ -572,3 +572,4 @@ st_sample_surface(struct st_surface *surface, float *rgba) screen->tex_transfer_destroy(transfer); } +#endif diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 985374190c3..0a332aaa9f1 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -30,7 +30,7 @@ #include "softpipe/sp_public.h" #include "llvmpipe/lp_public.h" #include "state_tracker/sw_winsys.h" -#include "null/null_sw_winsys.h" +#include "sw/null/null_sw_winsys.h" #include "st_winsys.h" From f97f46f269666b289f9af977e238ccda9b483c44 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 28 Mar 2010 09:30:55 -0700 Subject: [PATCH 429/483] aux/tgsi: fix some minor glitches in string routines Not sure why we are open-coding these rather than using standard library functions. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index f918151daaa..0b468a9184e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -55,7 +55,7 @@ static boolean is_digit_alpha_underscore( const char *cur ) return is_digit( cur ) || is_alpha_underscore( cur ); } -static boolean uprcase( char c ) +static char uprcase( char c ) { if (c >= 'a' && c <= 'z') return c += 'A' - 'a'; @@ -76,7 +76,7 @@ streq_nocase_uprcase(const char *str1, str1++; str2++; } - return TRUE; + return *str1 == 0 && *str2 == 0; } static boolean str_match_no_case( const char **pcur, const char *str ) From db5c2235d1accc2adcf1746aec2342bfa67237ba Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 28 Mar 2010 09:53:58 -0700 Subject: [PATCH 430/483] gallium: new raw gallium interface to support standalone tests Provides basic window system integration behind a simple interface, allowing tests to be written without dependency on either the driver or window system. With a lot of work, could turn into something like glut for gallium. --- SConstruct | 2 +- progs/SConscript | 1 + progs/gallium/raw/SConscript | 17 ++ progs/gallium/raw/clear.c | 85 ++++++++++ src/gallium/drivers/sw/Makefile | 10 ++ src/gallium/drivers/sw/SConscript | 42 +++++ src/gallium/drivers/sw/sw.c | 59 +++++++ src/gallium/drivers/sw/sw_public.h | 13 ++ src/gallium/include/state_tracker/graw.h | 36 +++++ src/gallium/targets/SConscript | 5 + src/gallium/targets/graw-xlib/SConscript | 57 +++++++ src/gallium/targets/graw-xlib/graw.h | 36 +++++ src/gallium/targets/graw-xlib/graw_xlib.c | 181 ++++++++++++++++++++++ 13 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 progs/gallium/raw/SConscript create mode 100644 progs/gallium/raw/clear.c create mode 100644 src/gallium/drivers/sw/Makefile create mode 100644 src/gallium/drivers/sw/SConscript create mode 100644 src/gallium/drivers/sw/sw.c create mode 100644 src/gallium/drivers/sw/sw_public.h create mode 100644 src/gallium/include/state_tracker/graw.h create mode 100644 src/gallium/targets/graw-xlib/SConscript create mode 100644 src/gallium/targets/graw-xlib/graw.h create mode 100644 src/gallium/targets/graw-xlib/graw_xlib.c diff --git a/SConstruct b/SConstruct index 2549a13fffa..5d44b6efde6 100644 --- a/SConstruct +++ b/SConstruct @@ -52,7 +52,7 @@ opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statet opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, - ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon'])) + ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) diff --git a/progs/SConscript b/progs/SConscript index aa6640cf7a6..20be60972d2 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -56,4 +56,5 @@ SConscript([ 'wgl/SConscript', 'perf/SConscript', 'gallium/unit/SConscript', + 'gallium/raw/SConscript', ]) diff --git a/progs/gallium/raw/SConscript b/progs/gallium/raw/SConscript new file mode 100644 index 00000000000..073b97951e7 --- /dev/null +++ b/progs/gallium/raw/SConscript @@ -0,0 +1,17 @@ +Import('*') + +env = env.Clone() + +env.Prepend(LIBPATH = [graw.dir]) +env.Prepend(LIBS = [graw.name]) + +progs = [ + 'clear' +] + +for prog in progs: + env.Program( + target = prog, + source = prog + '.c', + ) + diff --git a/progs/gallium/raw/clear.c b/progs/gallium/raw/clear.c new file mode 100644 index 00000000000..e46d135224d --- /dev/null +++ b/progs/gallium/raw/clear.c @@ -0,0 +1,85 @@ +/* Display a cleared blue window. This demo has no dependencies on + * any utility code, just the graw interface and gallium. + */ + +#include "state_tracker/graw.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include /* for sleep() */ + +enum pipe_format formats[] = { + PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_NONE +}; + +static const int WIDTH = 300; +static const int HEIGHT = 300; + +int main( int argc, char *argv[] ) +{ + struct pipe_screen *screen; + struct pipe_context *pipe; + struct pipe_surface *surf; + struct pipe_framebuffer_state fb; + struct pipe_texture *tex, templat; + void *window = NULL; + float clear_color[4] = {1,0,1,1}; + int i; + + screen = graw_init(); + if (screen == NULL) + exit(1); + + for (i = 0; + window == NULL && formats[i] != PIPE_FORMAT_NONE; + i++) { + + window = graw_create_window(0,0,300,300, formats[i]); + } + + if (window == NULL) + exit(2); + + pipe = screen->context_create(screen, NULL); + if (pipe == NULL) + exit(3); + + templat.target = PIPE_TEXTURE_2D; + templat.format = formats[i]; + templat.width0 = WIDTH; + templat.height0 = HEIGHT; + templat.depth0 = 1; + templat.last_level = 0; + templat.nr_samples = 1; + templat.tex_usage = (PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DISPLAY_TARGET); + + tex = screen->texture_create(screen, + &templat); + if (tex == NULL) + exit(4); + + surf = screen->get_tex_surface(screen, tex, 0, 0, 0, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DISPLAY_TARGET); + if (surf == NULL) + exit(5); + + memset(&fb, 0, sizeof fb); + fb.nr_cbufs = 1; + fb.width = WIDTH; + fb.height = HEIGHT; + fb.cbufs[0] = surf; + + pipe->set_framebuffer_state(pipe, &fb); + pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0, 0); + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + + screen->flush_frontbuffer(screen, surf, window); + + sleep(100); + return 0; +} diff --git a/src/gallium/drivers/sw/Makefile b/src/gallium/drivers/sw/Makefile new file mode 100644 index 00000000000..2713a62ee9f --- /dev/null +++ b/src/gallium/drivers/sw/Makefile @@ -0,0 +1,10 @@ +# Meta-driver which combines whichever software rasterizers have been +# built into a single convenience library. + +TOP = ../../../.. +include $(TOP)/configs/current + +C_SOURCES = \ + sw.c + +include ../../Makefile.template diff --git a/src/gallium/drivers/sw/SConscript b/src/gallium/drivers/sw/SConscript new file mode 100644 index 00000000000..6fbbdf3cc46 --- /dev/null +++ b/src/gallium/drivers/sw/SConscript @@ -0,0 +1,42 @@ +####################################################################### +# SConscript for swrast convenience library +# +# This is a meta-driver which consists of any and all of the software +# rasterizers into a single driver. A software rasterizer is defined +# as any driver which takes an sw_winsys pointer as the only argument +# to create_screen. +# +# XXX: unfortunately users of this driver still need to link in any +# extra libraries needed for the particular driver (eg llvm for +# llvmpipe). Not sure how to get around this. + +Import('*') + +if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']): + print 'warning: no supported pipe driver: skipping build of sw meta-driver' + Return() + +env = env.Clone() + +if 'softpipe' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') + env.Prepend(LIBS = [softpipe]) + +if 'llvmpipe' in env['drivers']: + env.Tool('llvm') + if 'LLVM_VERSION' in env: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) + +if 'cell' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_CELL') + env.Prepend(LIBS = [cell]) + +sw = env.ConvenienceLibrary( + target = 'sw', + source = [ + 'sw.c', + ] + ) + Export('sw') diff --git a/src/gallium/drivers/sw/sw.c b/src/gallium/drivers/sw/sw.c new file mode 100644 index 00000000000..9f156df45f5 --- /dev/null +++ b/src/gallium/drivers/sw/sw.c @@ -0,0 +1,59 @@ +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "target-helpers/wrap_screen.h" +#include "sw_public.h" +#include "state_tracker/sw_winsys.h" + + +/* Helper function to choose and instantiate one of the software rasterizers: + * cell, llvmpipe, softpipe. + */ + +#ifdef GALLIUM_SOFTPIPE +#include "softpipe/sp_public.h" +#endif + +#ifdef GALLIUM_LLVMPIPE +#include "llvmpipe/lp_public.h" +#endif + +#ifdef GALLIUM_CELL +#include "cell/ppu/cell_public.h" +#endif + +struct pipe_screen * +swrast_create_screen(struct sw_winsys *winsys) +{ + const char *default_driver; + const char *driver; + struct pipe_screen *screen = NULL; + +#if defined(GALLIUM_CELL) + default_driver = "cell"; +#elif defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#if defined(GALLIUM_CELL) + if (screen == NULL && strcmp(driver, "cell") == 0) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif + + return screen; +} diff --git a/src/gallium/drivers/sw/sw_public.h b/src/gallium/drivers/sw/sw_public.h new file mode 100644 index 00000000000..7085c5c85a0 --- /dev/null +++ b/src/gallium/drivers/sw/sw_public.h @@ -0,0 +1,13 @@ +#ifndef SW_PUBLIC_H +#define SW_PUBLIC_H + +/* A convenience library, primarily to isolate the logic required to + * figure out which if any software rasterizers have been built and + * select between them. + */ +struct sw_winsys; + +struct pipe_screen * +swrast_create_screen(struct sw_winsys *winsys); + +#endif diff --git a/src/gallium/include/state_tracker/graw.h b/src/gallium/include/state_tracker/graw.h new file mode 100644 index 00000000000..a58e18e4739 --- /dev/null +++ b/src/gallium/include/state_tracker/graw.h @@ -0,0 +1,36 @@ +#ifndef GALLIUM_RAW_H +#define GALLIUM_RAW_H + +/* This is an API for exercising gallium functionality in a + * platform-neutral fashion. Whatever platform integration is + * necessary to implement this interface is orchestrated by the + * individual target building this entity. + * + * For instance, the graw-xlib target includes code to implent these + * interfaces on top of the X window system. + * + * Programs using this interface may additionally benefit from some of + * the utilities currently in the libgallium.a library, especially + * those for parsing text representations of TGSI shaders. + */ + +#include "pipe/p_format.h" + +struct pipe_screen; + +struct pipe_screen *graw_init( void ); + +/* Returns a handle to be used with flush_frontbuffer()/present(). + * + * Query format support with screen::is_format_supported and usage + * XXX. + */ +void *graw_create_window( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format ); + +void graw_destroy_window( void *handle ); + +#endif diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index 747e64508f7..1292d4f6193 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -10,6 +10,11 @@ if 'gdi' in env['winsys']: 'libgl-gdi/SConscript', ]) +if 'graw-xlib' in env['winsys']: + SConscript([ + 'graw-xlib/SConscript', + ]) + if env['dri']: SConscript([ 'SConscript.dri' diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript new file mode 100644 index 00000000000..24cea92f907 --- /dev/null +++ b/src/gallium/targets/graw-xlib/SConscript @@ -0,0 +1,57 @@ +####################################################################### +# SConscript for xlib winsys + +Import('*') + +if env['platform'] != 'linux': + Return() + +if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']): + print 'warning: no supported pipe driver: skipping build of xlib libGL.so' + Return() + +env = env.Clone() + +env.Prepend(LIBS = [ + ws_xlib, + trace, + identity, +# gallium, +]) + +env.Append(CPPPATH = [ + '#src/gallium/drivers', +]) + + +sources = [ + 'graw_xlib.c', +] + +if 'softpipe' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') + env.Prepend(LIBS = [softpipe]) + +if 'llvmpipe' in env['drivers']: + env.Tool('llvm') + if 'LLVM_VERSION' in env: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) + +# Need this for trace, identity drivers referenced by +# gallium_wrap_screen(). +# +env.Prepend(LIBS = [gallium]) + +# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions +graw = env.SharedLibrary( + target ='graw', + source = sources, +) + +env.InstallSharedLibrary(graw, version=(1, 0)) + +graw = env.FindIxes(graw, 'SHLIBPREFIX', 'SHLIBSUFFIX') + +Export('graw') diff --git a/src/gallium/targets/graw-xlib/graw.h b/src/gallium/targets/graw-xlib/graw.h new file mode 100644 index 00000000000..a58e18e4739 --- /dev/null +++ b/src/gallium/targets/graw-xlib/graw.h @@ -0,0 +1,36 @@ +#ifndef GALLIUM_RAW_H +#define GALLIUM_RAW_H + +/* This is an API for exercising gallium functionality in a + * platform-neutral fashion. Whatever platform integration is + * necessary to implement this interface is orchestrated by the + * individual target building this entity. + * + * For instance, the graw-xlib target includes code to implent these + * interfaces on top of the X window system. + * + * Programs using this interface may additionally benefit from some of + * the utilities currently in the libgallium.a library, especially + * those for parsing text representations of TGSI shaders. + */ + +#include "pipe/p_format.h" + +struct pipe_screen; + +struct pipe_screen *graw_init( void ); + +/* Returns a handle to be used with flush_frontbuffer()/present(). + * + * Query format support with screen::is_format_supported and usage + * XXX. + */ +void *graw_create_window( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format ); + +void graw_destroy_window( void *handle ); + +#endif diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c new file mode 100644 index 00000000000..fb8ef9d78b6 --- /dev/null +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -0,0 +1,181 @@ +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "target-helpers/wrap_screen.h" +#include "state_tracker/xlib_sw_winsys.h" + +#ifdef GALLIUM_SOFTPIPE +#include "softpipe/sp_public.h" +#endif + +#ifdef GALLIUM_LLVMPIPE +#include "llvmpipe/lp_public.h" +#endif + +/* Haven't figured out a decent way to build the helper code yet - + * #include it here temporarily. + */ +#include "sw/sw_public.h" +#include "sw/sw.c" + +#include "graw.h" + +#include +#include +#include +#include + +static struct { + Display *display; +} graw; + + +struct pipe_screen * +graw_init( void ) +{ + const char *default_driver; + const char *driver; + struct pipe_screen *screen = NULL; + struct sw_winsys *winsys = NULL; + + graw.display = XOpenDisplay(NULL); + if (graw.display == NULL) + return NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = xlib_create_sw_winsys( graw.display ); + if (winsys == NULL) + return NULL; + +#if defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif + + /* Inject any wrapping layers we want to here: + */ + return gallium_wrap_screen( screen ); +} + + + + + +void * +graw_create_window( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format ) +{ + struct xlib_drawable *handle = NULL; + XSetWindowAttributes attr; + Window root; + Window win = 0; + XVisualInfo templat, *visinfo = NULL; + unsigned mask; + int n; + int scrnum; + + + scrnum = DefaultScreen( graw.display ); + root = RootWindow( graw.display, scrnum ); + + + if (format != PIPE_FORMAT_R8G8B8A8_UNORM) + goto fail; + + if (graw.display == NULL) + goto fail; + + handle = CALLOC_STRUCT(xlib_drawable); + if (handle == NULL) + goto fail; + + + mask = VisualScreenMask | VisualDepthMask | VisualClassMask; + templat.screen = DefaultScreen(graw.display); + templat.depth = 32; + templat.class = TrueColor; + + visinfo = XGetVisualInfo(graw.display, mask, &templat, &n); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( graw.display, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + /* XXX this is a bad way to get a borderless window! */ + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( graw.display, root, x, y, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + + /* set hints and properties */ + { + char *name = NULL; + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(graw.display, win, &sizehints); + XSetStandardProperties(graw.display, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + XFree(visinfo); + XMapWindow(graw.display, win); + while (1) { + XEvent e; + XNextEvent( graw.display, &e ); + if (e.type == MapNotify && e.xmap.window == win) { + break; + } + } + + handle->visual = visinfo->visual; + handle->drawable = (Drawable)win; + handle->depth = visinfo->depth; + return (void *)handle; + +fail: + FREE(handle); + XFree(visinfo); + + if (win) + XDestroyWindow(graw.display, win); + + return NULL; +} + + +void +graw_destroy_window( void *xlib_drawable ) +{ +} + From d0d73a38dab49d762dfbe596b66634d5d187501a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 28 Mar 2010 10:39:46 -0700 Subject: [PATCH 431/483] ws/xlib: Call XFlush after PutImage Want to see the results. --- src/gallium/winsys/sw/xlib/xlib_sw_winsys.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c index 54789d7a87c..ad843b7def6 100644 --- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c @@ -341,6 +341,8 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, XPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); } + + XFlush(xm_dt->display); } /** From 1cf669db59573778bab2f957679f353cf142c9d9 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 28 Mar 2010 10:42:26 -0700 Subject: [PATCH 432/483] progs/raw: add note about accessing utility functions --- progs/gallium/raw/clear.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/progs/gallium/raw/clear.c b/progs/gallium/raw/clear.c index e46d135224d..5ef5254edc9 100644 --- a/progs/gallium/raw/clear.c +++ b/progs/gallium/raw/clear.c @@ -9,6 +9,8 @@ #include "pipe/p_defines.h" #include /* for sleep() */ +#include "util/u_debug.h" /* debug_dump_surface_bmp() */ + enum pipe_format formats[] = { PIPE_FORMAT_R8G8B8A8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, @@ -78,6 +80,14 @@ int main( int argc, char *argv[] ) pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0, 0); pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + /* At the moment, libgraw includes/makes available all the symbols + * from gallium/auxiliary, including these debug helpers. Will + * eventually want to bless some of these paths, and lock the + * others down so they aren't accessible from test programs. + */ + if (0) + debug_dump_surface_bmp(pipe, "result.bmp", surf); + screen->flush_frontbuffer(screen, surf, window); sleep(100); From 21a96a55d60ad894b0488cd32d71a68dca080b72 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 28 Mar 2010 13:49:00 -0700 Subject: [PATCH 433/483] progs: Comment out gallium/raw/SConscript from progs/SConscript. Commit db5c2235d1accc2adcf1746aec2342bfa67237ba broke the default SCons build. NameError: name 'graw' is not defined: This patch allows the default SCons build to work again until a proper fix is available. --- progs/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/SConscript b/progs/SConscript index 20be60972d2..a90e13b4cb4 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -56,5 +56,5 @@ SConscript([ 'wgl/SConscript', 'perf/SConscript', 'gallium/unit/SConscript', - 'gallium/raw/SConscript', +# 'gallium/raw/SConscript', ]) From 5f1699e9d5e8e5e67a560482f73e559304a8ae43 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 28 Mar 2010 15:57:23 -0700 Subject: [PATCH 434/483] swrast: Remove unnecessary header. --- src/mesa/swrast/s_clear.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c index 7b0a63391fa..efe500ae2b1 100644 --- a/src/mesa/swrast/s_clear.c +++ b/src/mesa/swrast/s_clear.c @@ -25,7 +25,6 @@ #include "main/glheader.h" #include "main/colormac.h" #include "main/condrender.h" -#include "main/formats.h" #include "main/macros.h" #include "main/imports.h" #include "main/mtypes.h" From cbc99d34b992074e125f183dcc9c1c7471c5becb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 16:22:44 -0700 Subject: [PATCH 435/483] mesa: set version string to 7.7.1 Also set the correct release date. (cherry picked from commit 663642b435af2f8ab4b16360783eb367f42486c3) --- docs/relnotes-7.7.1.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html index 46f4cac5637..699627d70de 100644 --- a/docs/relnotes-7.7.1.html +++ b/docs/relnotes-7.7.1.html @@ -8,7 +8,7 @@ -

Mesa 7.7.1 Release Notes / March 26, 2010

+

Mesa 7.7.1 Release Notes / March 28, 2010

Mesa 7.7.1 is a bug-fix release. From 11289924b8b93a6649a35fddcaea73f58009378a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 16:25:47 -0700 Subject: [PATCH 436/483] mesa: Add 7.7.1 release MD5 sums (cherry picked from commit 0c88e340499c961cc7a06107a727710a67e280ed) --- docs/relnotes-7.7.1.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html index 699627d70de..00b36714cb5 100644 --- a/docs/relnotes-7.7.1.html +++ b/docs/relnotes-7.7.1.html @@ -26,7 +26,15 @@ for DRI hardware acceleration.

MD5 checksums

-tbd
+3ab0638cfa7ce8157337a229cf0db2c4  MesaLib-7.7.1.tar.gz
+46664d99e03f1e3ac078a7fea02af115  MesaLib-7.7.1.tar.bz2
+4e73ba8abb59aff79485eb95d7cefff7  MesaLib-7.7.1.zip
+bf1b108983995f7a712cf3343df1c918  MesaDemos-7.7.1.tar.gz
+aeb39645d80d656e0adebaa09e5bcd03  MesaDemos-7.7.1.tar.bz2
+01c49b7454fd292244eaf8bdc6ed8cf0  MesaDemos-7.7.1.zip
+37ec6386693dcb6dc770d1efd63a7a93  MesaGLUT-7.7.1.tar.gz
+1e16c85282f843791a21f7bc7b6a1ca8  MesaGLUT-7.7.1.tar.bz2
+d352c9e36a8e4d1059f4abc017b131e0  MesaGLUT-7.7.1.zip
 
From a6a4613135dc0b93012d3a2b1abcf69f772e4214 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 16:31:08 -0700 Subject: [PATCH 437/483] mesa: set version string to 7.8 Also set the correct release date. --- Makefile | 2 +- docs/relnotes-7.8.html | 2 +- src/mesa/main/version.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7c75d7f833d..6e641341120 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-rc2 +VERSION=7.8 DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index eaf3a8d54a0..9622d16652c 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -8,7 +8,7 @@ -

Mesa 7.8 Release Notes / March 26, 2010

+

Mesa 7.8 Release Notes / March 28, 2010

Mesa 7.8 is a new development release. diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index 23d74ee2c97..2e1d70c461a 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -35,7 +35,7 @@ #define MESA_MAJOR 7 #define MESA_MINOR 8 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.8-rc2" +#define MESA_VERSION_STRING "7.8" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) From ef6736e6466947afc3ea3c3113359cdadfd8c9cd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 16:33:53 -0700 Subject: [PATCH 438/483] intel: Bump intel driver date to reflect status as 2010Q1 release --- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index c86dd1d0d98..0a7dcb80c6b 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -63,7 +63,7 @@ int INTEL_DEBUG = (0); #endif -#define DRIVER_DATE "20091221 DEVELOPMENT" +#define DRIVER_DATE "20100328 2010Q1" #define DRIVER_DATE_GEM "GEM " DRIVER_DATE From dec94903d98e3705a0b92d6e9227854eabb336b5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 16:35:56 -0700 Subject: [PATCH 439/483] mesa: Add 7.8 release MD5 sums --- docs/relnotes-7.8.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index 9622d16652c..1fed087d79b 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -28,7 +28,15 @@ for DRI hardware acceleration.

MD5 checksums

-tbd
+5fcfde5383eccb3e9fd665f08a0ea59b  MesaLib-7.8.tar.gz
+85cb891eecb89aae4fdd3499cccd934b  MesaLib-7.8.tar.bz2
+754f39593006effc1c8ec3c27c2f1296  MesaLib-7.8.zip
+c3869c29fa6c3dbdd763f7428d271e12  MesaDemos-7.8.tar.gz
+9fe8ec184c7f78691e43c4c0a7f97d56  MesaDemos-7.8.tar.bz2
+063a96947f7b83d4ad789c6cf291b184  MesaDemos-7.8.zip
+5f4246756b7daaddb4fb3f970cad1e28  MesaGLUT-7.8.tar.gz
+ca7048a4aa7a437dcc84cc2c7d731336  MesaGLUT-7.8.tar.bz2
+b54581aeb79b585b158d6a32f94feff2  MesaGLUT-7.8.zip
 
From 1c2912ee7a47170bbaa8a71d4af729d0caf17f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 28 Mar 2010 18:38:30 +0200 Subject: [PATCH 440/483] r300g: print configurable debugging info on non-debug builds --- src/gallium/drivers/r300/r300_context.h | 2 +- src/gallium/drivers/r300/r300_screen.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index eb9178a2656..0a82484e89d 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -409,7 +409,7 @@ static INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags, if (CTX_DBG_ON(ctx, flags)) { va_list va; va_start(va, fmt); - debug_vprintf(fmt, va); + vfprintf(stderr, fmt, va); va_end(va); } } diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index a055159c93b..1cf8b7452d7 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -28,6 +28,8 @@ #include "r300_chipset.h" +#include + struct r300_screen { /* Parent class */ struct pipe_screen screen; @@ -80,7 +82,7 @@ static INLINE void SCREEN_DBG(struct r300_screen * screen, unsigned flags, if (SCREEN_DBG_ON(screen, flags)) { va_list va; va_start(va, fmt); - debug_vprintf(fmt, va); + vfprintf(stderr, fmt, va); va_end(va); } } From 37877b192e4f9e753f5e837520090206b342a6ea Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 23 Mar 2010 16:21:03 +0100 Subject: [PATCH 441/483] softpipe: Map GS constants, too. --- src/gallium/drivers/softpipe/sp_state_fs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 2b089c28316..d6f3229bed7 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -181,9 +181,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, /* note: reference counting */ pipe_buffer_reference(&softpipe->constants[shader][index], constants); - if(shader == PIPE_SHADER_VERTEX) { - draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index, - data, size); + if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) { + draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size); } softpipe->mapped_constants[shader][index] = data; From b9ad95d3ee9178dce9320d28b20d23d97370f7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:29:27 +0100 Subject: [PATCH 442/483] util: Distinguish between the different compression formats. In particular, all current uses of util_format_is_compressed() actually mean s3tc. --- src/gallium/auxiliary/util/u_format.csv | 20 ++++++++++++-------- src/gallium/auxiliary/util/u_format.h | 20 ++++++++++++++------ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index d2a925141b1..d819bbbde1c 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -110,14 +110,18 @@ PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv # Compressed formats -PIPE_FORMAT_DXT1_RGB , compressed, 4, 4, x64 , , , , xyz1, rgb -PIPE_FORMAT_DXT1_RGBA , compressed, 4, 4, x64 , , , , xyzw, rgb -PIPE_FORMAT_DXT3_RGBA , compressed, 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT5_RGBA , compressed, 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT1_SRGB , compressed, 4, 4, x64 , , , , xyz1, srgb -PIPE_FORMAT_DXT1_SRGBA , compressed, 4, 4, x64 , , , , xyzw, srgb -PIPE_FORMAT_DXT3_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb -PIPE_FORMAT_DXT5_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb +# - http://en.wikipedia.org/wiki/S3_Texture_Compression +# - http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt +# - http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt +# - http://msdn.microsoft.com/en-us/library/bb694531.aspx +PIPE_FORMAT_DXT1_RGB , s3tc, 4, 4, x64 , , , , xyz1, rgb +PIPE_FORMAT_DXT1_RGBA , s3tc, 4, 4, x64 , , , , xyzw, rgb +PIPE_FORMAT_DXT3_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT5_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT1_SRGB , s3tc, 4, 4, x64 , , , , xyz1, srgb +PIPE_FORMAT_DXT1_SRGBA , s3tc, 4, 4, x64 , , , , xyzw, srgb +PIPE_FORMAT_DXT3_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_DXT5_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb # Straightforward D3D10-like formats (also used for # vertex buffer element description) diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index c08fdcafcc8..98d4b98ebb5 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -56,15 +56,23 @@ enum util_format_layout { * * This is for formats like YV12 where there is less than one sample per * pixel. - * - * XXX: This could actually b */ UTIL_FORMAT_LAYOUT_SUBSAMPLED = 3, /** - * An unspecified compression algorithm. + * S3 Texture Compression formats. */ - UTIL_FORMAT_LAYOUT_COMPRESSED = 4 + UTIL_FORMAT_LAYOUT_S3TC = 4, + + /** + * Red-Green Texture Compression formats. + */ + UTIL_FORMAT_LAYOUT_RGTC = 5, + + /** + * Everything else that doesn't fit in any of the above layouts. + */ + UTIL_FORMAT_LAYOUT_OTHER = 6 }; @@ -210,7 +218,7 @@ util_format_name(enum pipe_format format) } static INLINE boolean -util_format_is_compressed(enum pipe_format format) +util_format_is_s3tc(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); @@ -219,7 +227,7 @@ util_format_is_compressed(enum pipe_format format) return FALSE; } - return desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED ? TRUE : FALSE; + return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE; } static INLINE boolean From 28cf5e1191077e063fe2a81d9d35934b71d001e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:30:09 +0100 Subject: [PATCH 443/483] r300: UTIL_FORMAT_LAYOUT_COMPRESSED -> UTIL_FORMAT_LAYOUT_S3TC. --- src/gallium/drivers/r300/r300_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7c86bdb4bdc..22ccadfe3dd 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -159,7 +159,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format) } /* Compressed formats. */ - if (desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED) { + if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { switch (format) { case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: From bade76191a3a429176694b3d7fd4f68409359735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:30:35 +0100 Subject: [PATCH 444/483] svga: util_format_is_compressed() -> util_format_is_s3tc(). --- src/gallium/drivers/svga/svga_screen_texture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 4a058eda885..70d3a8a46ae 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -330,7 +330,7 @@ svga_texture_create(struct pipe_screen *screen, */ #if 0 if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) && - !util_format_is_compressed(templat->format)) + !util_format_is_s3tc(templat->format)) tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET; #endif @@ -969,7 +969,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt, if (min_lod == 0 && max_lod >= pt->last_level) view = FALSE; - if (util_format_is_compressed(pt->format) && view) { + if (util_format_is_s3tc(pt->format) && view) { format = svga_translate_format_render(pt->format); } From cfbbe244d7438a60d389ae9d996dd430f79f362f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:30:56 +0100 Subject: [PATCH 445/483] mesa/st: util_format_is_compressed() -> util_format_is_s3tc(). --- src/mesa/state_tracker/st_cb_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 8cdd3ff2ae2..390ada5489c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -934,7 +934,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, GLubyte *dest; if (stImage->pt && - util_format_is_compressed(stImage->pt->format) && + util_format_is_s3tc(stImage->pt->format) && !compressed_dst) { /* Need to decompress the texture. * We'll do this by rendering a textured quad. From f3cb08f3dd81bc6479e8aa926fb74e73bb83cb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:31:16 +0100 Subject: [PATCH 446/483] i965g: util_format_is_compressed() -> util_format_is_s3tc(). --- src/gallium/drivers/i965/brw_screen_texture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index cadcb7cee2a..f9f17bdabac 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -206,7 +206,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen, /* XXX: compressed textures need special treatment here */ tex->cpp = util_format_get_blocksize(tex->base.format); - tex->compressed = util_format_is_compressed(tex->base.format); + tex->compressed = util_format_is_s3tc(tex->base.format); make_empty_list(&tex->views[0]); make_empty_list(&tex->views[1]); @@ -321,7 +321,7 @@ brw_texture_from_handle(struct pipe_screen *screen, templ->depth0 != 1) return NULL; - if (util_format_is_compressed(templ->format)) + if (util_format_is_s3tc(templ->format)) return NULL; tex = CALLOC_STRUCT(brw_texture); From 588dd187c45490368354f340f5175d2c4d7cbd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 17:52:10 +0100 Subject: [PATCH 447/483] Revert "python: Temporarily disable python state tracker until transfers are done by contexts" This reverts commit 50a778661930ec7aa875a9c5235e9910143ec700. --- src/gallium/state_trackers/python/SConscript | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index d0d141fd249..781f54bf2b9 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -3,8 +3,7 @@ import os.path Import('*') -if 'python' in env['statetrackers'] and 0: - # FIXME: Disable python state tracker until transfers are done by contexts +if 'python' in env['statetrackers']: env = env.Clone() From ab0b9f80f45fcab55155b0a16b91a56ff4b3db1e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 29 Mar 2010 11:21:26 -0600 Subject: [PATCH 448/483] glsl: remove rcp from sqrt() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per a patch from Marek Olšák, we can simply multiply the incoming value by 1/sqrt(x) instead of using rcp. We're keeping the x==0 check to avoid generating NaN for sqrt(0). --- .../shader/slang/library/slang_common_builtin.gc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index a25ca55bc42..3d464630df2 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -605,7 +605,7 @@ float sqrt(const float x) const float nx = -x; float r; __asm float_rsq r, x; - __asm float_rcp r, r; + r = r * x; __asm vec4_cmp __retVal, nx, r, 0.0; } @@ -615,8 +615,7 @@ vec2 sqrt(const vec2 x) vec2 r; __asm float_rsq r.x, x.x; __asm float_rsq r.y, x.y; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } @@ -627,9 +626,7 @@ vec3 sqrt(const vec3 x) __asm float_rsq r.x, x.x; __asm float_rsq r.y, x.y; __asm float_rsq r.z, x.z; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; - __asm float_rcp r.z, r.z; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } @@ -641,10 +638,7 @@ vec4 sqrt(const vec4 x) __asm float_rsq r.y, x.y; __asm float_rsq r.z, x.z; __asm float_rsq r.w, x.w; - __asm float_rcp r.x, r.x; - __asm float_rcp r.y, r.y; - __asm float_rcp r.z, r.z; - __asm float_rcp r.w, r.w; + r = r * x; __asm vec4_cmp __retVal, nx, r, zero; } From 1cbd51068802a3aa530b9c12d86c40cb3a1bbfa4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 29 Mar 2010 11:31:02 -0600 Subject: [PATCH 449/483] glsl: avoid using rcp in length() functions See prev commit for related info. --- src/mesa/shader/slang/library/slang_common_builtin.gc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index 3d464630df2..d75354deffe 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -1160,7 +1160,7 @@ float length(const vec2 v) float r; const float p = dot(v, v); // p = v.x * v.x + v.y * v.y __asm float_rsq r, p; // r = 1 / sqrt(p) - __asm float_rcp __retVal.x, r; // retVal = 1 / r + __retVal = p * r; // p * r = sqrt(p); } float length(const vec3 v) @@ -1168,7 +1168,7 @@ float length(const vec3 v) float r; const float p = dot(v, v); // p = v.x * v.x + v.y * v.y + v.z * v.z __asm float_rsq r, p; // r = 1 / sqrt(p) - __asm float_rcp __retVal, r; // retVal = 1 / r + __retVal = p * r; // p * r = sqrt(p); } float length(const vec4 v) @@ -1176,7 +1176,7 @@ float length(const vec4 v) float r; const float p = dot(v, v); // p = v.x * v.x + v.y * v.y + ... __asm float_rsq r, p; // r = 1 / sqrt(p) - __asm float_rcp __retVal, r; // retVal = 1 / r + __retVal = p * r; // p * r = sqrt(p); } From 8ca937fc3b1bf15c820a1c7d3bf0283a91bec72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?RALOVICH=2C=20Krist=C3=B3f?= Date: Sat, 27 Mar 2010 22:11:29 -0400 Subject: [PATCH 450/483] progs/glsl: let the mouse rotate the scene --- progs/glsl/fsraytrace.c | 69 ++++++++++++++++++++++++++--------------- progs/glsl/vsraytrace.c | 47 +++++++++++++++++++++++----- 2 files changed, 84 insertions(+), 32 deletions(-) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index 8d54757e590..357da67b9c6 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -27,23 +27,23 @@ #include #include #include "shaderutil.h" - +#include static int Win; static int WinWidth = 512, WinHeight = 512; -static GLfloat Xrot = 0, Yrot = 0; static int mouseGrabbed = 0; static GLuint vertShader; static GLuint fragShader; static GLuint program; +static float rot[9] = {1,0,0, 0,1,0, 0,0,1}; static const char* vsSource = - "varying vec2 rayDir;\n" - "\n" - "void main()\n" - "{\n" - " rayDir = gl_MultiTexCoord0.xy - vec2(0.5,0.5);\n" - " gl_Position = gl_ProjectionMatrix * gl_Vertex;\n" + "varying vec2 rayDir; \n" + " \n" + "void main() \n" + "{ \n" + " rayDir = gl_MultiTexCoord0.xy - vec2(0.5,0.5); \n" + " gl_Position = gl_ProjectionMatrix * gl_Vertex; \n" "}\n"; static const char* fsSource = @@ -213,29 +213,46 @@ static const char* fsSource = " clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0); \n" "} \n" " \n" - "\n" - "void\n" - "main()\n" - "{\n" - " const float z = -0.5;\n" + "void main() \n" + "{ \n" + " const float z = -0.5; \n" " const vec3 cameraPos = vec3(0,0,3); \n" - " Ray r = Ray(cameraPos, normalize(vec3(rayDir, z) * rot));\n" - " gl_FragColor = trace1(r);\n" + " Ray r = Ray(cameraPos, normalize(vec3(rayDir, z) * rot)); \n" + " gl_FragColor = trace1(r); \n" "}\n"; - - -static void -Idle(void) +static inline +float +deg2rad(const float degree) { - glutPostRedisplay(); + return( degree * 0.017453292519943295769236907684886F); } +static inline void +rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) +{ + const float rad1 = deg2rad(degreesAroundX); + const float c1 = cosf(rad1); + const float s1 = sinf(rad1); + const float rad2 = deg2rad(degreesAroundY); + const float c2 = cosf(rad2); + const float s2 = sinf(rad2); + mat3[0] = c2; mat3[3] = 0.0F; mat3[6] = s2; + mat3[1] = s1*s2; mat3[4] = c1; mat3[7] = -s1*c2; + mat3[2] = -c1*s2;mat3[5] = s1; mat3[8] = c1*c2; +} + +static inline void +identity(float* mat3) +{ + mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F; + mat3[1] = 0.0F; mat3[4] = 1.0F; mat3[7] = 0.0F; + mat3[2] = 0.0F; mat3[5] = 0.0F; mat3[8] = 1.0F; +} static void Draw(void) { - float rot[9] = {1,0,0, 0,1,0, 0,0,1}; GLint location = glGetUniformLocation(program, "rot"); static const float m = -10.F; static const float p = 10.F; @@ -311,9 +328,11 @@ drag(int x, int y) float scale = 1.5F; if(mouseGrabbed) { - Xrot = (float)(x - WinWidth/2) / scale; - Yrot = (float)(y - WinHeight/2) / scale; - printf("%4.2f %4.2f\n", Xrot, Yrot); + static GLfloat xRot = 0, yRot = 0; + xRot = (float)(x - WinWidth/2) / scale; + yRot = (float)(y - WinHeight/2) / scale; + identity(rot); + rotate_xy(rot, yRot, xRot); } } @@ -380,7 +399,7 @@ main(int argc, char *argv[]) glutDisplayFunc(Draw); glutMouseFunc(mouse); glutPassiveMotionFunc(drag); - glutIdleFunc(Idle); + glutIdleFunc(Draw); Init(); glutMainLoop(); return 0; diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index 962b1bdb4c1..327d48b897e 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -27,11 +27,14 @@ #include #include #include "shaderutil.h" - +#include static int Win; static int WinWidth = 256, WinHeight = 256; static int mouseGrabbed = 0; +static GLuint vertShader; +static GLuint program; +float rot[9] = {1,0,0, 0,1,0, 0,0,1}; static const char* vsSource = "const float INF = 9999.9; \n" @@ -206,11 +209,37 @@ static const char* vsSource = " Ray ray = Ray(cameraPos, rayDir); \n" " gl_Position = gl_Vertex; \n" " gl_FrontColor = trace1(ray); \n" - "} \n"; + "}\n"; -static GLuint vertShader; -static GLuint program; +static inline +float +deg2rad(const float degree) +{ + return( degree * 0.017453292519943295769236907684886F); +} + +static inline void +rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) +{ + const float rad1 = deg2rad(degreesAroundX); + const float c1 = cosf(rad1); + const float s1 = sinf(rad1); + const float rad2 = deg2rad(degreesAroundY); + const float c2 = cosf(rad2); + const float s2 = sinf(rad2); + mat3[0] = c2; mat3[3] = 0.0F; mat3[6] = s2; + mat3[1] = s1*s2; mat3[4] = c1; mat3[7] = -s1*c2; + mat3[2] = -c1*s2;mat3[5] = s1; mat3[8] = c1*c2; +} + +static inline void +identity(float* mat3) +{ + mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F; + mat3[1] = 0.0F; mat3[4] = 1.0F; mat3[7] = 0.0F; + mat3[2] = 0.0F; mat3[5] = 0.0F; mat3[8] = 1.0F; +} static void Draw(void) @@ -219,7 +248,6 @@ Draw(void) const float h = 0.5F * WinHeight; int x,y; - float rot[9] = {1,0,0, 0,1,0, 0,0,1}; GLint location = glGetUniformLocation(program, "rot"); glUseProgram(program); @@ -287,9 +315,14 @@ static void drag(int x, int y) { + float scale = 1.5F; if(mouseGrabbed) { - printf("%4d %4d\n", x, y); + static GLfloat xRot = 0, yRot = 0; + xRot = (float)(x - WinWidth/2) / scale; + yRot = (float)(y - WinHeight/2) / scale; + identity(rot); + rotate_xy(rot, yRot, xRot); } } @@ -355,7 +388,7 @@ main(int argc, char *argv[]) glutDisplayFunc(Draw); glutIdleFunc(Draw); glutMouseFunc(mouse); - glutMotionFunc(drag); + glutPassiveMotionFunc(drag); Init(); glutMainLoop(); return 0; From 909f0b356eab04f03389ea36ebf0a83dbb930f5d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 29 Mar 2010 11:44:39 -0600 Subject: [PATCH 451/483] progs/glsl: improve the mouse drag/rotate code a little --- progs/glsl/fsraytrace.c | 8 +++----- progs/glsl/vsraytrace.c | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index 357da67b9c6..392f01b200d 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -333,6 +333,7 @@ drag(int x, int y) yRot = (float)(y - WinHeight/2) / scale; identity(rot); rotate_xy(rot, yRot, xRot); + glutPostRedisplay(); } } @@ -341,10 +342,7 @@ static void mouse(int button, int state, int x, int y) { - if(state == GLUT_DOWN) - { - mouseGrabbed = !mouseGrabbed; - } + mouseGrabbed = (state == GLUT_DOWN); } @@ -398,7 +396,7 @@ main(int argc, char *argv[]) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMouseFunc(mouse); - glutPassiveMotionFunc(drag); + glutMotionFunc(drag); glutIdleFunc(Draw); Init(); glutMainLoop(); diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index 327d48b897e..ee4fe477619 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -31,7 +31,7 @@ static int Win; static int WinWidth = 256, WinHeight = 256; -static int mouseGrabbed = 0; +static GLboolean mouseGrabbed = GL_FALSE; static GLuint vertShader; static GLuint program; float rot[9] = {1,0,0, 0,1,0, 0,0,1}; @@ -323,6 +323,7 @@ drag(int x, int y) yRot = (float)(y - WinHeight/2) / scale; identity(rot); rotate_xy(rot, yRot, xRot); + glutPostRedisplay(); } } @@ -331,10 +332,7 @@ static void mouse(int button, int state, int x, int y) { - if(state == GLUT_DOWN) - { - mouseGrabbed = !mouseGrabbed; - } + mouseGrabbed = (state == GLUT_DOWN); } @@ -388,7 +386,7 @@ main(int argc, char *argv[]) glutDisplayFunc(Draw); glutIdleFunc(Draw); glutMouseFunc(mouse); - glutPassiveMotionFunc(drag); + glutMotionFunc(drag); Init(); glutMainLoop(); return 0; From 2aafbd7c2ae6922edecec6662ebda6c71cc5e404 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 29 Mar 2010 12:01:28 -0600 Subject: [PATCH 452/483] docs: fix 7.7.1 release date (cherry picked from commit e6f5ca0fa3bff975f2acb3a825d77f095bc9f43e) --- docs/news.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/news.html b/docs/news.html index a60d7a87d88..4e4b6976a88 100644 --- a/docs/news.html +++ b/docs/news.html @@ -11,7 +11,7 @@

News

-

March 26, 2010

+

March 28, 2010

Mesa 7.7.1 is released. This is a bug-fix release fixing issues found in the 7.7 release. From 6cc5fbd76b8994da8174c39f8eacb6605f4aa3b2 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Mon, 29 Mar 2010 21:06:53 +0300 Subject: [PATCH 453/483] ws/sw/dri: s/xm/dri_sw/ --- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 149 +++++++++++----------- 1 file changed, 75 insertions(+), 74 deletions(-) diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index 1c1e5612d28..fb4722fc75f 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -37,126 +37,127 @@ #include "dri_sw_winsys.h" -struct xm_displaytarget +struct dri_sw_displaytarget { void *data; void *mapped; }; - -/** Cast wrapper */ -static INLINE struct xm_displaytarget * -xm_displaytarget( struct sw_displaytarget *dt ) +struct dri_sw_winsys { - return (struct xm_displaytarget *)dt; + struct sw_winsys base; +}; + +static INLINE struct dri_sw_displaytarget * +dri_sw_displaytarget( struct sw_displaytarget *dt ) +{ + return (struct dri_sw_displaytarget *)dt; +} + +static INLINE struct dri_sw_winsys * +dri_sw_winsys( struct sw_winsys *ws ) +{ + return (struct dri_sw_winsys *)ws; } -/* pipe_screen::is_format_supported */ static boolean -xm_is_displaytarget_format_supported( struct sw_winsys *ws, - unsigned tex_usage, - enum pipe_format format ) +dri_sw_is_displaytarget_format_supported( struct sw_winsys *ws, + unsigned tex_usage, + enum pipe_format format ) { /* TODO: check visuals or other sensible thing here */ return TRUE; } -/* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ static struct sw_displaytarget * -xm_displaytarget_create(struct sw_winsys *winsys, - unsigned tex_usage, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) +dri_sw_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) { - struct xm_displaytarget *xm_dt; - unsigned nblocksy, size, xm_stride, format_stride; + struct dri_sw_displaytarget *dri_sw_dt; + unsigned nblocksy, size, dri_sw_stride, format_stride; - xm_dt = CALLOC_STRUCT(xm_displaytarget); - if(!xm_dt) - goto no_xm_dt; + dri_sw_dt = CALLOC_STRUCT(dri_sw_displaytarget); + if(!dri_sw_dt) + goto no_dt; format_stride = util_format_get_stride(format, width); - xm_stride = align(format_stride, alignment); + dri_sw_stride = align(format_stride, alignment); nblocksy = util_format_get_nblocksy(format, height); - size = xm_stride * nblocksy; + size = dri_sw_stride * nblocksy; - xm_dt->data = align_malloc(size, alignment); - if(!xm_dt->data) + dri_sw_dt->data = align_malloc(size, alignment); + if(!dri_sw_dt->data) goto no_data; - *stride = xm_stride; - return (struct sw_displaytarget *)xm_dt; + *stride = dri_sw_stride; + return (struct sw_displaytarget *)dri_sw_dt; no_data: - FREE(xm_dt); -no_xm_dt: + FREE(dri_sw_dt); +no_dt: return NULL; } -/* pipe_screen::texture_destroy */ static void -xm_displaytarget_destroy(struct sw_winsys *ws, - struct sw_displaytarget *dt) +dri_sw_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) { - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); - if (xm_dt->data) { - FREE(xm_dt->data); + if (dri_sw_dt->data) { + FREE(dri_sw_dt->data); } - FREE(xm_dt); + FREE(dri_sw_dt); } -/* pipe_context::transfer_map */ static void * -xm_displaytarget_map(struct sw_winsys *ws, - struct sw_displaytarget *dt, - unsigned flags) +dri_sw_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) { - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - xm_dt->mapped = xm_dt->data; - return xm_dt->mapped; + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + dri_sw_dt->mapped = dri_sw_dt->data; + return dri_sw_dt->mapped; } -/* pipe_context::transfer_unmap */ static void -xm_displaytarget_unmap(struct sw_winsys *ws, - struct sw_displaytarget *dt) +dri_sw_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) { - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - xm_dt->mapped = NULL; + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + dri_sw_dt->mapped = NULL; } -/* pipe_screen::texture_from_handle */ static struct sw_displaytarget * -xm_displaytarget_from_handle(struct sw_winsys *winsys, - const struct pipe_texture *templ, - struct winsys_handle *whandle, - unsigned *stride) +dri_sw_displaytarget_from_handle(struct sw_winsys *winsys, + const struct pipe_texture *templ, + struct winsys_handle *whandle, + unsigned *stride) { assert(0); return NULL; } -/* pipe_screen::texture_get_handle */ static boolean -xm_displaytarget_get_handle(struct sw_winsys *winsys, - struct sw_displaytarget *dt, - struct winsys_handle *whandle) +dri_sw_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) { assert(0); return FALSE; } -/* pipe_screen::flush_frontbuffer */ static void -xm_displaytarget_display(struct sw_winsys *ws, - struct sw_displaytarget *dt, - void *context_private) +dri_sw_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) { assert(0); } @@ -171,29 +172,29 @@ dri_destroy_sw_winsys(struct sw_winsys *winsys) struct sw_winsys * dri_create_sw_winsys(void) { - struct sw_winsys *ws; + struct dri_sw_winsys *ws; - ws = CALLOC_STRUCT(sw_winsys); + ws = CALLOC_STRUCT(dri_sw_winsys); if (!ws) return NULL; - ws->destroy = dri_destroy_sw_winsys; + ws->base.destroy = dri_destroy_sw_winsys; - ws->is_displaytarget_format_supported = xm_is_displaytarget_format_supported; + ws->base.is_displaytarget_format_supported = dri_sw_is_displaytarget_format_supported; /* screen texture functions */ - ws->displaytarget_create = xm_displaytarget_create; - ws->displaytarget_destroy = xm_displaytarget_destroy; - ws->displaytarget_from_handle = xm_displaytarget_from_handle; - ws->displaytarget_get_handle = xm_displaytarget_get_handle; + ws->base.displaytarget_create = dri_sw_displaytarget_create; + ws->base.displaytarget_destroy = dri_sw_displaytarget_destroy; + ws->base.displaytarget_from_handle = dri_sw_displaytarget_from_handle; + ws->base.displaytarget_get_handle = dri_sw_displaytarget_get_handle; /* texture functions */ - ws->displaytarget_map = xm_displaytarget_map; - ws->displaytarget_unmap = xm_displaytarget_unmap; + ws->base.displaytarget_map = dri_sw_displaytarget_map; + ws->base.displaytarget_unmap = dri_sw_displaytarget_unmap; - ws->displaytarget_display = xm_displaytarget_display; + ws->base.displaytarget_display = dri_sw_displaytarget_display; - return ws; + return &ws->base; } /* vim: set sw=3 ts=8 sts=3 expandtab: */ From 625e024b186829f199458679921916971a5b00cb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Mon, 29 Mar 2010 21:06:54 +0300 Subject: [PATCH 454/483] st/dri/sw: add drisw_api similarly to dri1_api I am pretty sure that this is in gallium spirit, so commit. Thanks to Chia-I for suggesting this. --- src/gallium/include/state_tracker/dri1_api.h | 8 +- src/gallium/include/state_tracker/drisw_api.h | 35 ++++++ .../state_trackers/dri/common/dri_st_api.c | 2 +- src/gallium/state_trackers/dri/drm/dri1.c | 30 ++--- src/gallium/state_trackers/dri/sw/drisw.c | 114 +++++++----------- src/gallium/state_trackers/dri/sw/drisw.h | 2 +- .../targets/dri-swrast/swrast_drm_api.c | 17 ++- src/gallium/targets/libgl-xlib/xlib.c | 8 ++ src/gallium/winsys/sw/dri/dri_sw_winsys.c | 37 +++++- src/gallium/winsys/sw/dri/dri_sw_winsys.h | 4 +- 10 files changed, 148 insertions(+), 109 deletions(-) create mode 100644 src/gallium/include/state_tracker/drisw_api.h diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h index 27b7a28c467..bb1cd6d1d82 100644 --- a/src/gallium/include/state_tracker/dri1_api.h +++ b/src/gallium/include/state_tracker/dri1_api.h @@ -7,14 +7,14 @@ #include "state_tracker/drm_api.h" -struct drm_clip_rect; - struct pipe_screen; struct pipe_winsys; struct pipe_buffer; struct pipe_context; struct pipe_texture; +struct drm_clip_rect; + struct dri1_api_version { int major; @@ -31,8 +31,8 @@ struct dri1_api_lock_funcs { void (*lock) (struct pipe_context * pipe); void (*unlock) (struct pipe_context * locked_pipe); - boolean(*is_locked) (struct pipe_context * locked_pipe); - boolean(*is_lock_lost) (struct pipe_context * locked_pipe); + boolean(*is_locked) (struct pipe_context * locked_pipe); + boolean(*is_lock_lost) (struct pipe_context * locked_pipe); void (*clear_lost_lock) (struct pipe_context * locked_pipe); }; diff --git a/src/gallium/include/state_tracker/drisw_api.h b/src/gallium/include/state_tracker/drisw_api.h new file mode 100644 index 00000000000..c6adebb4ec5 --- /dev/null +++ b/src/gallium/include/state_tracker/drisw_api.h @@ -0,0 +1,35 @@ +#ifndef _DRISW_API_H_ +#define _DRISW_API_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_format.h" + +#include "state_tracker/drm_api.h" + +struct pipe_screen; +struct pipe_winsys; +struct pipe_buffer; +struct pipe_context; +struct pipe_texture; + +struct dri_drawable; + +/** + * This callback struct is intended for the winsys to call the loader. + */ + +struct drisw_loader_funcs +{ + void (*put_image) (struct dri_drawable *dri_drawable, + void *data, unsigned width, unsigned height); +}; + +struct drisw_create_screen_arg +{ + struct drm_create_screen_arg base; + + struct drisw_loader_funcs *lf; +}; + +#endif diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 40b24b18e9f..7ba7ec383d8 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -80,7 +80,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, } #else if (new_stamp) - drisw_update_drawable_info(drawable->dPriv); + drisw_update_drawable_info(drawable); drisw_allocate_textures(drawable, statt_mask); #endif diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index aad098bb301..9b5842ba2bf 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -404,6 +404,19 @@ dri1_allocate_textures(struct dri_drawable *drawable, drawable->old_h = height; } +/* + * Backend function for init_screen. + */ + +static const __DRIextension *dri1_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL +}; + static void st_dri_lock(struct pipe_context *pipe) { @@ -442,21 +455,6 @@ static struct dri1_api_lock_funcs dri1_lf = { .clear_lost_lock = st_dri_clear_lost_lock }; -/* - * Backend function for init_screen. - */ - -static const __DRIextension *dri1_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; - -struct dri1_api *__dri1_api_hooks = NULL; - static INLINE void dri1_copy_version(struct dri1_api_version *dst, const struct __DRIversionRec *src) @@ -466,6 +464,8 @@ dri1_copy_version(struct dri1_api_version *dst, dst->patch_level = src->patch; } +struct dri1_api *__dri1_api_hooks = NULL; + const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv) { diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index b7eba63bcb9..b8256710972 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -27,38 +27,18 @@ **************************************************************************/ /* TODO: - * - * stride: - * - * The driver and the loaders (libGL, xserver/glx) compute the stride from the - * width independently. winsys has a workaround that works for softpipe but may - * explode for other drivers or platforms, rendering- or performance-wise. - * Solving this issue properly requires extending the DRISW loader extension, - * in order to make the stride available to the putImage callback. - * - * drisw_api: - * - * Define drisw_api similarly to dri1_api and use it to call the loader. This - * is predicated on support for calling the loader from the winsys, which has - * to grow for DRI2 as well. * * xshm / texture_from_pixmap / EGLImage: * * Allow the loaders to use the XSHM extension. It probably requires callbacks - * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth - * it, given the scope of DRISW, unless it falls naturally from properly - * solving the other issues. - * - * fences: - * - * No fences are used, are they needed for llvmpipe / cell ? + * for createImage/destroyImage similar to DRI2 getBuffers. */ #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_inlines.h" #include "pipe/p_context.h" -#include "state_tracker/drm_api.h" +#include "state_tracker/drisw_api.h" #include "dri_screen.h" #include "dri_context.h" @@ -80,60 +60,47 @@ get_drawable_info(__DRIdrawable *dPriv, int *w, int *h) dPriv->loaderPrivate); } -/* - * Set the width to 'stride / cpp'. PutImage seems to correctly clip the width - * to the actual width of the dst drawable. Even if this is not specified but - * an implementation detail, it is the correct thing to do, so rely on it. XXX - */ static INLINE void -put_image(__DRIdrawable *dPriv, void *data, unsigned width) +put_image(__DRIdrawable *dPriv, void *data, unsigned width, unsigned height) { __DRIscreen *sPriv = dPriv->driScreenPriv; const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, - 0, 0, width, dPriv->h, + 0, 0, width, height, data, dPriv->loaderPrivate); } void -drisw_update_drawable_info(__DRIdrawable *dPriv) +drisw_update_drawable_info(struct dri_drawable *drawable) { + __DRIdrawable *dPriv = drawable->dPriv; + get_drawable_info(dPriv, &dPriv->w, &dPriv->h); } +static void +drisw_put_image(struct dri_drawable *drawable, + void *data, unsigned width, unsigned height) +{ + __DRIdrawable *dPriv = drawable->dPriv; + + put_image(dPriv, data, width, height); +} + static INLINE void drisw_present_texture(__DRIdrawable *dPriv, struct pipe_texture *ptex) { struct dri_drawable *drawable = dri_drawable(dPriv); struct dri_screen *screen = dri_screen(drawable->sPriv); - struct pipe_context *pipe; struct pipe_surface *psurf; - struct pipe_transfer *ptrans; - void *pmap; - unsigned width; - pipe = dri1_get_pipe_context(screen); psurf = dri1_get_pipe_surface(drawable, ptex); - if (!pipe || !psurf) + if (!psurf) return; - ptrans = pipe->get_tex_transfer(pipe, ptex, 0, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, dPriv->w, dPriv->h); - - width = ptrans->stride / util_format_get_blocksize(ptex->format); - - pmap = pipe->transfer_map(pipe, ptrans); - - assert(pmap); - - put_image(dPriv, pmap, width); - - pipe->transfer_unmap(pipe, ptrans); - - pipe->tex_transfer_destroy(pipe, ptrans); + screen->pipe_screen->flush_frontbuffer(screen->pipe_screen, psurf, drawable); } static INLINE void @@ -162,23 +129,6 @@ drisw_copy_to_front(__DRIdrawable * dPriv, * Backend functions for st_framebuffer interface and swap_buffers. */ -void -drisw_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt) -{ - struct dri_context *ctx = dri_get_current(); - struct pipe_texture *ptex; - - if (!ctx) - return; - - ptex = drawable->textures[statt]; - - if (ptex) { - drisw_copy_to_front(ctx->dPriv, ptex); - } -} - void drisw_swap_buffers(__DRIdrawable *dPriv) { @@ -198,6 +148,23 @@ drisw_swap_buffers(__DRIdrawable *dPriv) } } +void +drisw_flush_frontbuffer(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + struct dri_context *ctx = dri_get_current(); + struct pipe_texture *ptex; + + if (!ctx) + return; + + ptex = drawable->textures[statt]; + + if (ptex) { + drisw_copy_to_front(ctx->dPriv, ptex); + } +} + /** * Allocate framebuffer attachments. * @@ -286,12 +253,16 @@ static const __DRIextension *drisw_screen_extensions[] = { NULL }; +static struct drisw_loader_funcs drisw_lf = { + .put_image = drisw_put_image +}; + const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv) { const __DRIconfig **configs; struct dri_screen *screen; - struct drm_create_screen_arg arg; + struct drisw_create_screen_arg arg; screen = CALLOC_STRUCT(dri_screen); if (!screen) @@ -304,9 +275,10 @@ drisw_init_screen(__DRIscreen * sPriv) sPriv->private = (void *)screen; sPriv->extensions = drisw_screen_extensions; - arg.mode = DRM_CREATE_DRISW; + arg.base.mode = DRM_CREATE_DRISW; + arg.lf = &drisw_lf; - configs = dri_init_screen_helper(screen, &arg, 32); + configs = dri_init_screen_helper(screen, &arg.base, 32); if (!configs) goto fail; diff --git a/src/gallium/state_trackers/dri/sw/drisw.h b/src/gallium/state_trackers/dri/sw/drisw.h index 2c0d5610fac..c0c874f7326 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.h +++ b/src/gallium/state_trackers/dri/sw/drisw.h @@ -39,7 +39,7 @@ const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv); void -drisw_update_drawable_info(__DRIdrawable *dPriv); +drisw_update_drawable_info(struct dri_drawable *drawable); void drisw_flush_frontbuffer(struct dri_drawable *drawable, diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 1f24d7650d7..63b935bb07b 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -32,15 +32,7 @@ #include "state_tracker/sw_winsys.h" #include "dri_sw_winsys.h" -/* Copied from targets/libgl-xlib. - * - * TODO: - * This function should be put in targets/common or winsys/sw/common and shared - * with targets/libgl-xlib and winsys/sw/drm. - * - * For targets/common, you get layering violations unless all of drm_api's are - * moved under targets. - */ +/* Copied from targets/libgl-xlib */ #ifdef GALLIUM_SOFTPIPE #include "softpipe/sp_public.h" @@ -98,19 +90,24 @@ swrast_drm_create_screen(struct drm_api *api, { struct sw_winsys *winsys = NULL; struct pipe_screen *screen = NULL; + struct drisw_create_screen_arg *drisw; (void) drmFD; if (arg != NULL) { switch(arg->mode) { case DRM_CREATE_DRISW: + drisw = (struct drisw_create_screen_arg *)arg; break; default: return NULL; } } + else { + return NULL; + } - winsys = dri_create_sw_winsys(); + winsys = dri_create_sw_winsys(drisw->lf); if (winsys == NULL) return NULL; diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 4a8366280d8..48e5bdff429 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -55,6 +55,14 @@ PUBLIC const struct st_module st_module_OpenGL = { * GALLIUM_CELL, etc. Scons already eliminates those #defines, so * things that are painful for it now are likely to be painful for * other build systems in the future. + * + * Copies (full or partial): + * targets/libgl-xlib + * targets/graw-xlib + * targets/dri-swrast + * winsys/sw/drm + * drivers/sw + * */ #ifdef GALLIUM_SOFTPIPE diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index fb4722fc75f..870c6afc124 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -39,6 +39,11 @@ struct dri_sw_displaytarget { + enum pipe_format format; + unsigned width; + unsigned height; + unsigned stride; + void *data; void *mapped; }; @@ -46,6 +51,8 @@ struct dri_sw_displaytarget struct dri_sw_winsys { struct sw_winsys base; + + struct drisw_loader_funcs *lf; }; static INLINE struct dri_sw_displaytarget * @@ -79,23 +86,27 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys, unsigned *stride) { struct dri_sw_displaytarget *dri_sw_dt; - unsigned nblocksy, size, dri_sw_stride, format_stride; + unsigned nblocksy, size, format_stride; dri_sw_dt = CALLOC_STRUCT(dri_sw_displaytarget); if(!dri_sw_dt) goto no_dt; + dri_sw_dt->format = format; + dri_sw_dt->width = width; + dri_sw_dt->height = height; + format_stride = util_format_get_stride(format, width); - dri_sw_stride = align(format_stride, alignment); + dri_sw_dt->stride = align(format_stride, alignment); nblocksy = util_format_get_nblocksy(format, height); - size = dri_sw_stride * nblocksy; + size = dri_sw_dt->stride * nblocksy; dri_sw_dt->data = align_malloc(size, alignment); if(!dri_sw_dt->data) goto no_data; - *stride = dri_sw_stride; + *stride = dri_sw_dt->stride; return (struct sw_displaytarget *)dri_sw_dt; no_data: @@ -159,7 +170,20 @@ dri_sw_displaytarget_display(struct sw_winsys *ws, struct sw_displaytarget *dt, void *context_private) { - assert(0); + struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws); + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + struct dri_drawable *dri_drawable = (struct dri_drawable *)context_private; + unsigned width, height; + + /* Set the width to 'stride / cpp'. + * + * PutImage correctly clips to the width of the dst drawable. + */ + width = dri_sw_dt->stride / util_format_get_blocksize(dri_sw_dt->format); + + height = dri_sw_dt->height; + + dri_sw_ws->lf->put_image(dri_drawable, dri_sw_dt->data, width, height); } @@ -170,7 +194,7 @@ dri_destroy_sw_winsys(struct sw_winsys *winsys) } struct sw_winsys * -dri_create_sw_winsys(void) +dri_create_sw_winsys(struct drisw_loader_funcs *lf) { struct dri_sw_winsys *ws; @@ -178,6 +202,7 @@ dri_create_sw_winsys(void) if (!ws) return NULL; + ws->lf = lf; ws->base.destroy = dri_destroy_sw_winsys; ws->base.is_displaytarget_format_supported = dri_sw_is_displaytarget_format_supported; diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.h b/src/gallium/winsys/sw/dri/dri_sw_winsys.h index c2382a68d78..329ac06a05b 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.h +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.h @@ -29,8 +29,10 @@ #ifndef DRI_SW_WINSYS #define DRI_SW_WINSYS +#include "state_tracker/drisw_api.h" + struct sw_winsys; -struct sw_winsys *dri_create_sw_winsys(void); +struct sw_winsys *dri_create_sw_winsys(struct drisw_loader_funcs *lf); #endif From 012fabca722494162c244a367913562b8cfa4677 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 29 Mar 2010 16:17:17 -0400 Subject: [PATCH 455/483] gallivm: make sure that the alloca's are the very first thing in the function otherwise mem2reg can't put them in registers --- .../auxiliary/gallivm/lp_bld_tgsi_soa.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index f160be878f8..95cd6a0ecf3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -651,6 +651,19 @@ emit_declaration( unsigned first = decl->Range.First; unsigned last = decl->Range.Last; unsigned idx, i; + LLVMBasicBlockRef current_block = + LLVMGetInsertBlock(bld->base.builder); + LLVMBasicBlockRef first_block = + LLVMGetEntryBasicBlock( + LLVMGetBasicBlockParent(current_block)); + LLVMValueRef first_inst = + LLVMGetFirstInstruction(first_block); + + /* we want alloca's to be the first instruction + * in the function so we need to rewind the builder + * to the very beginning */ + LLVMPositionBuilderBefore(bld->base.builder, + first_inst); for (idx = first; idx <= last; ++idx) { boolean ok; @@ -673,10 +686,15 @@ emit_declaration( ok = TRUE; } - if (!ok) + if (!ok) { + LLVMPositionBuilderAtEnd(bld->base.builder, + current_block); return FALSE; + } } + LLVMPositionBuilderAtEnd(bld->base.builder, + current_block); return TRUE; } From 69492c3aca8361b903a7daaa697c0660faa22b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 21:09:21 +0100 Subject: [PATCH 456/483] st/python: Move surface read/write methods to context. --- src/gallium/state_trackers/python/p_context.i | 249 +++++++++++++++++- src/gallium/state_trackers/python/p_texture.i | 226 ---------------- src/gallium/state_trackers/python/st_sample.c | 30 +-- src/gallium/state_trackers/python/st_sample.h | 7 +- 4 files changed, 267 insertions(+), 245 deletions(-) diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index df700bc663c..a8e164a072b 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -362,10 +362,253 @@ error1: pipe_surface_reference(&_dst, NULL); } - void clear(unsigned buffers, const float *rgba, double depth = 0.0f, - unsigned stencil = 0) + %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); + void + surface_read_raw(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + char **STRING, int *LENGTH) { - $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil); + struct pipe_texture *texture = surface->texture; + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + unsigned stride; + + stride = util_format_get_stride(texture->format, w); + *LENGTH = util_format_get_nblocksy(texture->format, h) * stride; + *STRING = (char *) malloc(*LENGTH); + if(!*STRING) + return; + + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + x, y, w, h); + if(transfer) { + pipe_get_tile_raw(pipe, transfer, 0, 0, w, h, *STRING, stride); + pipe->tex_transfer_destroy(pipe, transfer); + } + } + + %cstring_input_binary(const char *STRING, unsigned LENGTH); + void + surface_write_raw(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + const char *STRING, unsigned LENGTH, unsigned stride = 0) + { + struct pipe_texture *texture = surface->texture; + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + + if(stride == 0) + stride = util_format_get_stride(texture->format, w); + + if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride) + SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size"); + + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_WRITE, + x, y, w, h); + if(!transfer) + SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer"); + + pipe_put_tile_raw(pipe, transfer, 0, 0, w, h, STRING, stride); + pipe->tex_transfer_destroy(pipe, transfer); + + fail: + return; + } + + void + surface_read_rgba(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + float *rgba) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + x, y, w, h); + if(transfer) { + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); + pipe->tex_transfer_destroy(pipe, transfer); + } + } + + void + surface_write_rgba(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + const float *rgba) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_WRITE, + x, y, w, h); + if(transfer) { + pipe_put_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); + pipe->tex_transfer_destroy(pipe, transfer); + } + } + + %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); + void + surface_read_rgba8(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + char **STRING, int *LENGTH) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + float *rgba; + unsigned char *rgba8; + unsigned i, j, k; + + *LENGTH = 0; + *STRING = NULL; + + if (!surface) + return; + + *LENGTH = h*w*4; + *STRING = (char *) malloc(*LENGTH); + if(!*STRING) + return; + + rgba = malloc(h*w*4*sizeof(float)); + if(!rgba) + return; + + rgba8 = (unsigned char *) *STRING; + + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + x, y, + w, h); + if(transfer) { + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); + for(j = 0; j < h; ++j) { + for(i = 0; i < w; ++i) + for(k = 0; k <4; ++k) + rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]); + } + pipe->tex_transfer_destroy(pipe, transfer); + } + + free(rgba); + } + + void + surface_read_z(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + unsigned *z) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + x, y, w, h); + if(transfer) { + pipe_get_tile_z(pipe, transfer, 0, 0, w, h, z); + pipe->tex_transfer_destroy(pipe, transfer); + } + } + + void + surface_write_z(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + const unsigned *z) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_WRITE, + x, y, w, h); + if(transfer) { + pipe_put_tile_z(pipe, transfer, 0, 0, w, h, z); + pipe->tex_transfer_destroy(pipe, transfer); + } + } + + void + surface_sample_rgba(struct st_surface *surface, + float *rgba) + { + st_sample_surface($self->pipe, surface, rgba); + } + + unsigned + surface_compare_rgba(struct st_surface *surface, + unsigned x, unsigned y, unsigned w, unsigned h, + const float *rgba, float tol = 0.0) + { + struct pipe_context *pipe = $self->pipe; + struct pipe_transfer *transfer; + float *rgba2; + const float *p1; + const float *p2; + unsigned i, j, n; + + rgba2 = MALLOC(h*w*4*sizeof(float)); + if(!rgba2) + return ~0; + + transfer = pipe->get_tex_transfer(pipe, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + x, y, w, h); + if(!transfer) { + FREE(rgba2); + return ~0; + } + + pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba2); + pipe->tex_transfer_destroy(pipe, transfer); + + p1 = rgba; + p2 = rgba2; + n = 0; + for(i = h*w; i; --i) { + unsigned differs = 0; + for(j = 4; j; --j) { + float delta = *p2++ - *p1++; + if (delta < -tol || delta > tol) + differs = 1; + } + n += differs; + } + + FREE(rgba2); + + return n; } }; diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 2dd9e5050ea..923a6285289 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -124,232 +124,6 @@ struct st_surface FREE($self); } - %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); - void get_tile_raw(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) - { - struct pipe_texture *texture = $self->texture; - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - unsigned stride; - - stride = util_format_get_stride(texture->format, w); - *LENGTH = util_format_get_nblocksy(texture->format, h) * stride; - *STRING = (char *) malloc(*LENGTH); - if(!*STRING) - return; - - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y, w, h); - if(transfer) { - pipe_get_tile_raw(pipe, transfer, 0, 0, w, h, *STRING, stride); - pipe->tex_transfer_destroy(pipe, transfer); - } - } - - %cstring_input_binary(const char *STRING, unsigned LENGTH); - void put_tile_raw(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const char *STRING, unsigned LENGTH, unsigned stride = 0) - { - struct pipe_texture *texture = $self->texture; - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - - if(stride == 0) - stride = util_format_get_stride(texture->format, w); - - if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride) - SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size"); - - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_WRITE, - x, y, w, h); - if(!transfer) - SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer"); - - pipe_put_tile_raw(pipe, transfer, 0, 0, w, h, STRING, stride); - pipe->tex_transfer_destroy(pipe, transfer); - - fail: - return; - } - - void get_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y, w, h); - if(transfer) { - pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); - pipe->tex_transfer_destroy(pipe, transfer); - } - } - - void - put_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_WRITE, - x, y, w, h); - if(transfer) { - pipe_put_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); - pipe->tex_transfer_destroy(pipe, transfer); - } - } - - %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); - void - get_tile_rgba8(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - float *rgba; - unsigned char *rgba8; - unsigned i, j, k; - - *LENGTH = 0; - *STRING = NULL; - - if (!$self) - return; - - *LENGTH = h*w*4; - *STRING = (char *) malloc(*LENGTH); - if(!*STRING) - return; - - rgba = malloc(h*w*4*sizeof(float)); - if(!rgba) - return; - - rgba8 = (unsigned char *) *STRING; - - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y, - w, h); - if(transfer) { - pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba); - for(j = 0; j < h; ++j) { - for(i = 0; i < w; ++i) - for(k = 0; k <4; ++k) - rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]); - } - pipe->tex_transfer_destroy(pipe, transfer); - } - - free(rgba); - } - - void get_tile_z(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y, w, h); - if(transfer) { - pipe_get_tile_z(pipe, transfer, 0, 0, w, h, z); - pipe->tex_transfer_destroy(pipe, transfer); - } - } - - void put_tile_z(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_WRITE, - x, y, w, h); - if(transfer) { - pipe_put_tile_z(pipe, transfer, 0, 0, w, h, z); - pipe->tex_transfer_destroy(pipe, transfer); - } - } - -/* - void - sample_rgba(float *rgba) { - st_sample_surface($self, rgba); - } -*/ - - unsigned compare_tile_rgba(struct st_context *ctx, unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0) - { - struct pipe_context *pipe = ctx->pipe; - struct pipe_transfer *transfer; - float *rgba2; - const float *p1; - const float *p2; - unsigned i, j, n; - - rgba2 = MALLOC(h*w*4*sizeof(float)); - if(!rgba2) - return ~0; - - transfer = pipe->get_tex_transfer(pipe, - $self->texture, - $self->face, - $self->level, - $self->zslice, - PIPE_TRANSFER_READ, - x, y, w, h); - if(!transfer) { - FREE(rgba2); - return ~0; - } - - pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba2); - pipe->tex_transfer_destroy(pipe, transfer); - - p1 = rgba; - p2 = rgba2; - n = 0; - for(i = h*w; i; --i) { - unsigned differs = 0; - for(j = 4; j; --j) { - float delta = *p2++ - *p1++; - if (delta < -tol || delta > tol) - differs = 1; - } - n += differs; - } - - FREE(rgba2); - - return n; - } }; diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index f9622533fbc..e2c1e060174 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -521,12 +521,13 @@ st_sample_pixel_block(enum pipe_format format, } } -#if 0 + void -st_sample_surface(struct st_surface *surface, float *rgba) +st_sample_surface(struct pipe_context *pipe, + struct st_surface *surface, + float *rgba) { struct pipe_texture *texture = surface->texture; - struct pipe_screen *screen = texture->screen; unsigned width = u_minify(texture->width0, surface->level); unsigned height = u_minify(texture->height0, surface->level); uint rgba_stride = width * 4; @@ -534,18 +535,18 @@ st_sample_surface(struct st_surface *surface, float *rgba) void *raw; transfer = pipe->get_tex_transfer(pipe, - surface->texture, - surface->face, - surface->level, - surface->zslice, - PIPE_TRANSFER_WRITE, - 0, 0, - width, - height); + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_WRITE, + 0, 0, + width, + height); if (!transfer) return; - raw = screen->transfer_map(screen, transfer); + raw = pipe->transfer_map(pipe, transfer); if (raw) { enum pipe_format format = texture->format; uint x, y; @@ -567,9 +568,8 @@ st_sample_surface(struct st_surface *surface, float *rgba) } } - screen->transfer_unmap(screen, transfer); + pipe->transfer_unmap(pipe, transfer); } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } -#endif diff --git a/src/gallium/state_trackers/python/st_sample.h b/src/gallium/state_trackers/python/st_sample.h index 888114d3021..6fb8417add8 100644 --- a/src/gallium/state_trackers/python/st_sample.h +++ b/src/gallium/state_trackers/python/st_sample.h @@ -32,6 +32,9 @@ #include "pipe/p_format.h" +struct pipe_context; +struct st_surface; + void st_sample_pixel_block(enum pipe_format format, @@ -40,7 +43,9 @@ st_sample_pixel_block(enum pipe_format format, unsigned w, unsigned h); void -st_sample_surface(struct st_surface *surface, float *rgba); +st_sample_surface(struct pipe_context *pipe, + struct st_surface *surface, + float *rgba); #endif /* ST_SAMPLE_H_ */ From d0e7aa25a9258aaf0bf9b22c1e75eda1515a69f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 21:09:37 +0100 Subject: [PATCH 457/483] st/python: Update for util_draw_vertex_buffer changes. --- src/gallium/state_trackers/python/p_context.i | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index a8e164a072b..bccaeead015 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -280,8 +280,11 @@ struct st_context { struct pipe_context *pipe = $self->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_buffer *vbuf; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_buffer vbuffer; float *map; unsigned size; + unsigned i; size = num_verts * num_attribs * 4 * sizeof(float); @@ -297,15 +300,44 @@ struct st_context { goto error2; memcpy(map, vertices, size); pipe_buffer_unmap(screen, vbuf); - - util_draw_vertex_buffer(pipe, vbuf, 0, prim, num_verts, num_attribs); - + + cso_save_vertex_elements($self->cso); + + /* tell pipe about the vertex attributes */ + for (i = 0; i < num_attribs; i++) { + velements[i].src_offset = i * 4 * sizeof(float); + velements[i].instance_divisor = 0; + velements[i].vertex_buffer_index = 0; + velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + cso_set_vertex_elements($self->cso, num_attribs, velements); + + /* tell pipe about the vertex buffer */ + memset(&vbuffer, 0, sizeof(vbuffer)); + vbuffer.buffer = vbuf; + vbuffer.stride = num_attribs * 4 * sizeof(float); /* vertex size */ + vbuffer.buffer_offset = 0; + vbuffer.max_index = num_verts - 1; + pipe->set_vertex_buffers(pipe, 1, &vbuffer); + + /* draw */ + pipe->draw_arrays(pipe, prim, 0, num_verts); + + cso_restore_vertex_elements($self->cso); + error2: pipe_buffer_reference(&vbuf, NULL); error1: ; } + void + clear(unsigned buffers, const float *rgba, double depth = 0.0f, + unsigned stencil = 0) + { + $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil); + } + void flush(unsigned flags = 0) { struct pipe_fence_handle *fence = NULL; From bbe6788807db1fd1cbb1b227cf0ecfcc02db90d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 29 Mar 2010 21:10:03 +0100 Subject: [PATCH 458/483] progs/gallium/python: Get tri.py sample working again. --- progs/gallium/python/samples/tri.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/progs/gallium/python/samples/tri.py b/progs/gallium/python/samples/tri.py index d7fbdb10ac3..9f6d787dcb2 100644 --- a/progs/gallium/python/samples/tri.py +++ b/progs/gallium/python/samples/tri.py @@ -30,19 +30,19 @@ from gallium import * -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) +def make_image(ctx, surface): + data = ctx.surface_read_rgba8(surface, 0, 0, surface.width, surface.height) import Image outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) return outimage -def save_image(filename, surface): - outimage = make_image(surface) +def save_image(ctx, surface, filename): + outimage = make_image(ctx, surface) outimage.save(filename, "PNG") -def show_image(surface): - outimage = make_image(surface) +def show_image(ctx, surface): + outimage = make_image(ctx, surface) import Tkinter as tk from PIL import Image, ImageTk @@ -216,10 +216,10 @@ def test(dev): ctx.flush() - show_image(cbuf) - #show_image(zbuf) - #save_image('cbuf.png', cbuf) - #save_image('zbuf.png', zbuf) + show_image(ctx, cbuf) + show_image(ctx, zbuf) + save_image(ctx, cbuf, 'cbuf.png') + save_image(ctx, zbuf, 'zbuf.png') From 52f728921563192ccbabf5ffe98234d8d330b933 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 13:58:39 -0700 Subject: [PATCH 459/483] progs/glsl: Remove inline keyword. Fixes MSVC build. --- progs/glsl/fsraytrace.c | 6 +++--- progs/glsl/vsraytrace.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index 392f01b200d..dcfc1949874 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -221,14 +221,14 @@ static const char* fsSource = " gl_FragColor = trace1(r); \n" "}\n"; -static inline +static float deg2rad(const float degree) { return( degree * 0.017453292519943295769236907684886F); } -static inline void +static void rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) { const float rad1 = deg2rad(degreesAroundX); @@ -242,7 +242,7 @@ rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) mat3[2] = -c1*s2;mat3[5] = s1; mat3[8] = c1*c2; } -static inline void +static void identity(float* mat3) { mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F; diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index ee4fe477619..67832b8a46d 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -212,14 +212,14 @@ static const char* vsSource = "}\n"; -static inline +static float deg2rad(const float degree) { return( degree * 0.017453292519943295769236907684886F); } -static inline void +static void rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) { const float rad1 = deg2rad(degreesAroundX); @@ -233,7 +233,7 @@ rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY) mat3[2] = -c1*s2;mat3[5] = s1; mat3[8] = c1*c2; } -static inline void +static void identity(float* mat3) { mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F; From 90075f34e24a6d6c16198c5b99fb25d713910e8a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 14:56:12 -0700 Subject: [PATCH 460/483] progs/glsl: Add workarounds for Apple GLSL compiler crash. fsraytrace and vsraytrace were crashing on Mac OS X 10.6.3 in the Apple GLSL compiler function TPPStreamCompiler::assignOperands. Removing some const qualifers made the crashes go away. --- progs/glsl/fsraytrace.c | 7 +++++++ progs/glsl/vsraytrace.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c index dcfc1949874..af72a99099d 100644 --- a/progs/glsl/fsraytrace.c +++ b/progs/glsl/fsraytrace.c @@ -76,10 +76,17 @@ static const char* fsSource = " vec3 n; \n" "}; \n" " \n" +#ifdef __APPLE__ + "Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" + "Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" + "Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" + "Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" +#else "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" +#endif " \n" "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n" "// sqrt, let's work around. \n" diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c index 67832b8a46d..64d928883ed 100644 --- a/progs/glsl/vsraytrace.c +++ b/progs/glsl/vsraytrace.c @@ -64,10 +64,17 @@ static const char* vsSource = " vec3 n; \n" "}; \n" " \n" +#ifdef __APPLE__ + "Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" + "Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" + "Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" + "Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" +#else "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); \n" "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); \n" "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); \n" "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); \n" +#endif " \n" "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n" "// sqrt, let's work around. \n" From 3b1a8d9d5ba286da568b4176ed533a7dde60ad18 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Fri, 26 Mar 2010 10:23:03 -0700 Subject: [PATCH 461/483] gallivm: added lp_bld_printf() function --- src/gallium/auxiliary/Makefile | 1 + src/gallium/auxiliary/SConscript | 1 + src/gallium/auxiliary/gallivm/lp_bld_printf.c | 109 ++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_printf.h | 39 +++++++ 4 files changed, 150 insertions(+) create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_printf.c create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_printf.h diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index e1c3bc43a24..452eceb7f4f 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -155,6 +155,7 @@ GALLIVM_SOURCES = \ gallivm/lp_bld_intr.c \ gallivm/lp_bld_logic.c \ gallivm/lp_bld_pack.c \ + gallivm/lp_bld_printf.c \ gallivm/lp_bld_sample.c \ gallivm/lp_bld_sample_soa.c \ gallivm/lp_bld_struct.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 65e1dc8a58d..0a23da47b2a 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -200,6 +200,7 @@ if drawllvm: 'gallivm/lp_bld_logic.c', 'gallivm/lp_bld_init.cpp', 'gallivm/lp_bld_pack.c', + 'gallivm/lp_bld_printf.c', 'gallivm/lp_bld_sample.c', 'gallivm/lp_bld_sample_soa.c', 'gallivm/lp_bld_struct.c', diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c new file mode 100644 index 00000000000..ae4d400af39 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -0,0 +1,109 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include + +#include "lp_bld_printf.h" + + +static int +lp_get_printf_arg_count(const char *fmt) +{ + int count =0; + const char *p = fmt; + int c; + + while ((c = *p++)) { + if (c != '%') + continue; + switch (*p) { + case '\0': + continue; + case '%': + p++; + continue; + case '.': + if (p[1] == '*' && p[2] == 's') { + count += 2; + p += 3; + continue; + } + default: + count ++; + } + } + return count; +} + +LLVMValueRef +lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len) +{ + LLVMValueRef string = LLVMAddGlobal(module, LLVMArrayType(LLVMInt8Type(), len + 1), ""); + LLVMSetGlobalConstant(string, TRUE); + LLVMSetLinkage(string, LLVMInternalLinkage); + LLVMSetInitializer(string, LLVMConstString(str, len + 1, TRUE)); + return string; +} + + +/** + * lp_build_printf. + * + * Build printf call in LLVM IR. The output goes to stdout. + * The additional variable arguments need to have type + * LLVMValueRef. + */ +LLVMValueRef +lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...) +{ + va_list arglist; + int i = 0; + int argcount = lp_get_printf_arg_count(fmt); + LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); + LLVMValueRef params[argcount + 1]; + LLVMValueRef fmtarg = lp_build_const_string_variable(module, fmt, strlen(fmt) + 1); + LLVMValueRef int0 = LLVMConstInt(LLVMInt32Type(), 0, 0); + LLVMValueRef index[2]; + LLVMValueRef func_printf = LLVMGetNamedFunction(module, "printf"); + + index[0] = index[1] = int0; + + if (!func_printf) { + LLVMTypeRef printf_type = LLVMFunctionType(LLVMIntType(32), NULL, 0, 1); + func_printf = LLVMAddFunction(module, "printf", printf_type); + } + + params[0] = LLVMBuildGEP(builder, fmtarg, index, 2, ""); + + va_start(arglist, fmt); + for (i = 1; i <= argcount; i++) + params[i] = va_arg(arglist, LLVMValueRef); + va_end(arglist); + + return LLVMBuildCall(builder, func_printf, params, argcount + 1, ""); +} + diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.h b/src/gallium/auxiliary/gallivm/lp_bld_printf.h new file mode 100644 index 00000000000..83bd8f1d557 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.h @@ -0,0 +1,39 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#ifndef LP_BLD_PRINTF_H +#define LP_BLD_PRINTF_H + + +#include "pipe/p_compiler.h" +#include "lp_bld.h" + +LLVMValueRef lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len); +LLVMValueRef lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...); + +#endif + From 5fa09846618ed702493f054a1d4b0ec2a28fbbd0 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Fri, 26 Mar 2010 10:24:34 -0700 Subject: [PATCH 462/483] Add test case for lp_bld_printf() --- src/gallium/drivers/llvmpipe/Makefile | 3 +- src/gallium/drivers/llvmpipe/lp_test_printf.c | 162 ++++++++++++++++++ 2 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/gallium/drivers/llvmpipe/lp_test_printf.c diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 74d728ddb39..b37c6754c08 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -44,7 +44,8 @@ CPP_SOURCES = \ PROGS := lp_test_format \ lp_test_blend \ - lp_test_conv + lp_test_conv \ + lp_test_printf include ../../Makefile.template diff --git a/src/gallium/drivers/llvmpipe/lp_test_printf.c b/src/gallium/drivers/llvmpipe/lp_test_printf.c new file mode 100644 index 00000000000..e5e5925012a --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_test_printf.c @@ -0,0 +1,162 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#include +#include + +#include "gallivm/lp_bld.h" +#include "gallivm/lp_bld_printf.h" + +#include +#include +#include +#include + +#include "lp_test.h" + + +struct printf_test_case { +}; + +void +write_tsv_header(FILE *fp) +{ + fprintf(fp, + "result\t" + "format\n"); + + fflush(fp); +} + + + +typedef void (*test_printf_t)(int i); + +static LLVMValueRef +add_printf_test(LLVMModuleRef module) +{ + LLVMTypeRef args[1] = { LLVMIntType(32) }; + LLVMValueRef func = LLVMAddFunction(module, "test_printf", LLVMFunctionType(LLVMVoidType(), args, 1, 0)); + LLVMBuilderRef builder = LLVMCreateBuilder(); + LLVMBasicBlockRef block = LLVMAppendBasicBlock(func, "entry"); + + LLVMSetFunctionCallConv(func, LLVMCCallConv); + + LLVMPositionBuilderAtEnd(builder, block); + lp_build_printf(builder, "hello, world\n"); + lp_build_printf(builder, "print 5 6: %d %d\n", LLVMConstInt(LLVMInt32Type(), 5, 0), + LLVMConstInt(LLVMInt32Type(), 6, 0)); + LLVMBuildRetVoid(builder); + LLVMDisposeBuilder(builder); + return func; +} + + +PIPE_ALIGN_STACK +static boolean +test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase) +{ + LLVMModuleRef module = NULL; + LLVMValueRef test = NULL; + LLVMExecutionEngineRef engine = NULL; + LLVMModuleProviderRef provider = NULL; + LLVMPassManagerRef pass = NULL; + char *error = NULL; + test_printf_t test_printf; + float unpacked[4]; + unsigned packed; + boolean success = TRUE; + + module = LLVMModuleCreateWithName("test"); + + test = add_printf_test(module); + + if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) { + LLVMDumpModule(module); + abort(); + } + LLVMDisposeMessage(error); + + provider = LLVMCreateModuleProviderForExistingModule(module); + if (LLVMCreateJITCompiler(&engine, provider, 1, &error)) { + fprintf(stderr, "%s\n", error); + LLVMDisposeMessage(error); + abort(); + } + +#if 0 + pass = LLVMCreatePassManager(); + LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), pass); + /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, + * but there are more on SVN. */ + LLVMAddConstantPropagationPass(pass); + LLVMAddInstructionCombiningPass(pass); + LLVMAddPromoteMemoryToRegisterPass(pass); + LLVMAddGVNPass(pass); + LLVMAddCFGSimplificationPass(pass); + LLVMRunPassManager(pass, module); +#else + (void)pass; +#endif + + test_printf = (test_printf_t)LLVMGetPointerToGlobal(engine, test); + + memset(unpacked, 0, sizeof unpacked); + packed = 0; + + + // LLVMDumpModule(module); + + test_printf(0); + + LLVMFreeMachineCodeForFunction(engine, test); + + LLVMDisposeExecutionEngine(engine); + if(pass) + LLVMDisposePassManager(pass); + + return success; +} + + +boolean +test_all(unsigned verbose, FILE *fp) +{ + bool success = TRUE; + + test_printf(verbose, fp, NULL); + + return success; +} + + +boolean +test_some(unsigned verbose, FILE *fp, unsigned long n) +{ + return test_all(verbose, fp); +} From 8c6f71e01e40075156c8b83f2c5e15ab73e66036 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 29 Mar 2010 18:13:31 -0600 Subject: [PATCH 463/483] gallivm: use constant size array, added assertion check --- src/gallium/auxiliary/gallivm/lp_bld_printf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c index ae4d400af39..78c9ec778b6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -27,6 +27,8 @@ #include +#include "util/u_debug.h" +#include "util/u_memory.h" #include "lp_bld_printf.h" @@ -84,12 +86,14 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...) int i = 0; int argcount = lp_get_printf_arg_count(fmt); LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); - LLVMValueRef params[argcount + 1]; + LLVMValueRef params[50]; LLVMValueRef fmtarg = lp_build_const_string_variable(module, fmt, strlen(fmt) + 1); LLVMValueRef int0 = LLVMConstInt(LLVMInt32Type(), 0, 0); LLVMValueRef index[2]; LLVMValueRef func_printf = LLVMGetNamedFunction(module, "printf"); + assert(Elements(params) >= argcount + 1); + index[0] = index[1] = int0; if (!func_printf) { From c1a392ac4c6a7da4026653de556c2c7698f86860 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Mar 2010 09:17:20 +0800 Subject: [PATCH 464/483] st/glx: Remove a wrong assertion in choose_pixel_format. There are X visuals that Gallium or the code does not support. We could not assert the color format to be supported. Return PIPE_FORMAT_NONE in such cases and let the caller handle it. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 4 ++++ src/gallium/state_trackers/glx/xlib/xm_api.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 4930cd6cd50..eb8d6a19333 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1758,6 +1758,10 @@ glXGetFBConfigs( Display *dpy, int screen, int *nelements ) } for (i = 0; i < *nelements; i++) { results[i] = create_glx_visual(dpy, visuals + i); + if (!results[i]) { + *nelements = i; + break; + } } return (GLXFBConfig *) results; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 3022d45157a..fd03d3c46a4 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -327,8 +327,7 @@ choose_pixel_format(XMesaVisual v) return PIPE_FORMAT_B5G6R5_UNORM; } - assert(0); - return 0; + return PIPE_FORMAT_NONE; } @@ -737,6 +736,12 @@ XMesaVisual XMesaCreateVisual( Display *display, } v->stvis.color_format = choose_pixel_format(v); + if (v->stvis.color_format == PIPE_FORMAT_NONE) { + FREE(v->visinfo); + FREE(v); + return NULL; + } + v->stvis.depth_stencil_format = choose_depth_stencil_format(xmdpy, depth_size, stencil_size); From 587c5ef01fad962bcfb087232d0925a8eec86953 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 29 Mar 2010 15:10:18 -0700 Subject: [PATCH 465/483] r300g: Bind constantbuf to Draw immediately, don't wait for render. Doesn't hurt, and reduces code duplication. --- src/gallium/drivers/r300/r300_render.c | 14 -------------- src/gallium/drivers/r300/r300_state.c | 8 ++++++-- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 93bf388776c..1fb7eac2b34 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -569,13 +569,6 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, draw_set_mapped_element_buffer(r300->draw, 0, NULL); - draw_set_mapped_constant_buffer(r300->draw, - PIPE_SHADER_VERTEX, - 0, - r300->shader_constants[PIPE_SHADER_VERTEX].constants, - r300->shader_constants[PIPE_SHADER_VERTEX].count * - (sizeof(float) * 4)); - draw_arrays(r300->draw, mode, start, count); for (i = 0; i < r300->vertex_buffer_count; i++) { @@ -614,13 +607,6 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, draw_set_mapped_element_buffer_range(r300->draw, indexSize, minIndex, maxIndex, indices); - draw_set_mapped_constant_buffer(r300->draw, - PIPE_SHADER_VERTEX, - 0, - r300->shader_constants[PIPE_SHADER_VERTEX].constants, - r300->shader_constants[PIPE_SHADER_VERTEX].count * - (sizeof(float) * 4)); - draw_arrays(r300->draw, mode, start, count); for (i = 0; i < r300->vertex_buffer_count; i++) { diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index b7b5e1ef03b..ace71d657ef 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1365,10 +1365,14 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, if (r300screen->caps->has_tcl) { r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; r300->pvs_flush.dirty = TRUE; + } else if (r300->draw) { + draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, + 0, r300->shader_constants[PIPE_SHADER_VERTEX].constants, + buf->size); } - } - else if (shader == PIPE_SHADER_FRAGMENT) + } else if (shader == PIPE_SHADER_FRAGMENT) { r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; + } } void r300_init_state_functions(struct r300_context* r300) From 9dc51ad4f7bb9bbaba247da90dc50f2098dd5e64 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 22:11:37 -0700 Subject: [PATCH 466/483] r300g: Remove unnecessary header. --- src/gallium/drivers/r300/r300_tgsi_to_rc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index 3f88a2b82b9..3b3802ee2b2 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -30,8 +30,6 @@ #include "tgsi/tgsi_scan.h" #include "tgsi/tgsi_util.h" -#include "util/u_debug.h" - static unsigned translate_opcode(unsigned opcode) { switch(opcode) { From ba43b74967d91d592f085943b60c522b88916495 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 22:19:28 -0700 Subject: [PATCH 467/483] r300g: Remove unused variable. --- src/gallium/drivers/r300/r300_state.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index ace71d657ef..39e05583dd4 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1183,7 +1183,6 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* attribs) { - struct r300_context *r300 = r300_context(pipe); struct r300_screen* r300screen = r300_screen(pipe->screen); struct r300_vertex_element_state *velems; unsigned i, size; From f2c55566ee271f34a42587f9def105c99ec06faf Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 22:54:35 -0700 Subject: [PATCH 468/483] swrastg: Silence unused value warning. --- src/gallium/targets/dri-swrast/swrast_drm_api.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c index 63b935bb07b..99c25543a76 100644 --- a/src/gallium/targets/dri-swrast/swrast_drm_api.c +++ b/src/gallium/targets/dri-swrast/swrast_drm_api.c @@ -68,16 +68,16 @@ swrast_create_screen(struct sw_winsys *winsys) #if defined(GALLIUM_CELL) if (screen == NULL && strcmp(driver, "cell") == 0) screen = cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) +#elif defined(GALLIUM_LLVMPIPE) if (screen == NULL && strcmp(driver, "llvmpipe") == 0) screen = llvmpipe_create_screen( winsys ); -#endif - -#if defined(GALLIUM_SOFTPIPE) +#elif defined(GALLIUM_SOFTPIPE) if (screen == NULL) screen = softpipe_create_screen( winsys ); + + (void) driver; +#else + (void) driver; #endif return screen; From 49289007c1fb7609a1c37aeb2daeeb96a47b8438 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 29 Mar 2010 23:11:26 -0700 Subject: [PATCH 469/483] drisw: Remove unnecessary header. --- src/gallium/state_trackers/dri/sw/drisw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index b8256710972..42fa789aaf7 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -43,7 +43,6 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" -#include "dri_st_api.h" #include "dri1_helper.h" #include "drisw.h" From 9f0e1be2de1d9256f340b541630ad258ca8885f7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Mar 2010 12:38:25 +0800 Subject: [PATCH 470/483] mesa: Add umbrella features. Add FEATURE_GL, FEATURE_ES1, and FEATURE_ES2 for OpenGL, OpenGL ES 1.x, and OpenGL ES 2.x respectively. Define individual features through the new umbrella features. There is no real change introduced by this commit. --- src/mesa/main/mfeatures.h | 117 ++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 50 deletions(-) diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index cb96c4d1d05..d3189b3f1b8 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -68,62 +68,79 @@ * enabled or not. */ -#ifdef IN_DRI_DRIVER -#define FEATURE_remap_table 1 -#else -#define FEATURE_remap_table 0 +#ifndef FEATURE_ES1 +#define FEATURE_ES1 0 +#endif +#ifndef FEATURE_ES2 +#define FEATURE_ES2 0 #endif -#define FEATURE_accum _HAVE_FULL_GL -#define FEATURE_arrayelt _HAVE_FULL_GL -#define FEATURE_attrib_stack _HAVE_FULL_GL +#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) + +#ifndef FEATURE_GL +#define FEATURE_GL !FEATURE_ES +#endif + +#ifdef IN_DRI_DRIVER +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_dispatch 1 +#define FEATURE_texgen 1 +#define FEATURE_userclip 1 + +#define FEATURE_accum FEATURE_GL +#define FEATURE_arrayelt FEATURE_GL +#define FEATURE_attrib_stack FEATURE_GL /* this disables vtxfmt, api_loopback, and api_noop completely */ -#define FEATURE_beginend _HAVE_FULL_GL -#define FEATURE_colortable _HAVE_FULL_GL -#define FEATURE_convolve _HAVE_FULL_GL -#define FEATURE_dispatch _HAVE_FULL_GL -#define FEATURE_dlist (_HAVE_FULL_GL && FEATURE_arrayelt && FEATURE_beginend) -#define FEATURE_draw_read_buffer _HAVE_FULL_GL -#define FEATURE_drawpix _HAVE_FULL_GL -#define FEATURE_evaluators _HAVE_FULL_GL -#define FEATURE_feedback _HAVE_FULL_GL -#define FEATURE_fixedpt 0 -#define FEATURE_histogram _HAVE_FULL_GL -#define FEATURE_pixel_transfer _HAVE_FULL_GL -#define FEATURE_point_size_array 0 -#define FEATURE_queryobj _HAVE_FULL_GL -#define FEATURE_rastpos _HAVE_FULL_GL -#define FEATURE_texgen _HAVE_FULL_GL -#define FEATURE_texture_fxt1 _HAVE_FULL_GL -#define FEATURE_texture_s3tc _HAVE_FULL_GL -#define FEATURE_userclip _HAVE_FULL_GL -#define FEATURE_vertex_array_byte 0 -#define FEATURE_es2_glsl 0 +#define FEATURE_beginend FEATURE_GL +#define FEATURE_colortable FEATURE_GL +#define FEATURE_convolve FEATURE_GL +#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) +#define FEATURE_draw_read_buffer FEATURE_GL +#define FEATURE_drawpix FEATURE_GL +#define FEATURE_evaluators FEATURE_GL +#define FEATURE_feedback FEATURE_GL +#define FEATURE_histogram FEATURE_GL +#define FEATURE_pixel_transfer FEATURE_GL +#define FEATURE_queryobj FEATURE_GL +#define FEATURE_rastpos FEATURE_GL +#define FEATURE_texture_fxt1 FEATURE_GL +#define FEATURE_texture_s3tc FEATURE_GL -#define FEATURE_ARB_fragment_program _HAVE_FULL_GL -#define FEATURE_ARB_framebuffer_object _HAVE_FULL_GL -#define FEATURE_ARB_map_buffer_range _HAVE_FULL_GL -#define FEATURE_ARB_pixel_buffer_object _HAVE_FULL_GL -#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL -#define FEATURE_ARB_vertex_program _HAVE_FULL_GL -#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL -#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects -#define FEATURE_ARB_sync _HAVE_FULL_GL +#define FEATURE_fixedpt FEATURE_ES +#define FEATURE_point_size_array FEATURE_ES +#define FEATURE_vertex_array_byte FEATURE_ES -#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL -#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL -#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL -#define FEATURE_APPLE_object_purgeable _HAVE_FULL_GL -#define FEATURE_EXT_texture_sRGB _HAVE_FULL_GL -#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL -#define FEATURE_NV_fence _HAVE_FULL_GL -#define FEATURE_NV_fragment_program _HAVE_FULL_GL -#define FEATURE_NV_vertex_program _HAVE_FULL_GL +#define FEATURE_es2_glsl FEATURE_ES2 -#define FEATURE_OES_EGL_image _HAVE_FULL_GL +#define FEATURE_ARB_fragment_program 1 +#define FEATURE_ARB_vertex_program 1 +#define FEATURE_ARB_vertex_shader 1 +#define FEATURE_ARB_fragment_shader 1 +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects +#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) +#define FEATURE_ARB_map_buffer_range FEATURE_GL +#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) +#define FEATURE_ARB_sync FEATURE_GL +#define FEATURE_ARB_vertex_buffer_object 1 + +#define FEATURE_EXT_framebuffer_blit FEATURE_GL +#define FEATURE_EXT_framebuffer_object 1 +#define FEATURE_EXT_pixel_buffer_object 1 +#define FEATURE_EXT_texture_sRGB FEATURE_GL + +#define FEATURE_APPLE_object_purgeable FEATURE_GL +#define FEATURE_ATI_fragment_shader FEATURE_GL +#define FEATURE_NV_fence FEATURE_GL +#define FEATURE_NV_fragment_program FEATURE_GL +#define FEATURE_NV_vertex_program FEATURE_GL + +#define FEATURE_OES_EGL_image 1 #endif /* FEATURES_H */ From 066477ab226c6bf9598511ebe9134cb360fb54a2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Mar 2010 13:13:20 +0800 Subject: [PATCH 471/483] mesa: Add missing features. Add features tested in the code but missing from mfeatures.h. This also fixes some tests of features. They should be tested with "#if", not "#ifdef". --- src/mesa/main/bufferobj.c | 2 +- src/mesa/main/context.c | 2 +- src/mesa/main/extensions.c | 2 +- src/mesa/main/fbobject.c | 2 +- src/mesa/main/mfeatures.h | 4 ++++ src/mesa/main/texparam.c | 8 ++++---- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 1854b980beb..11bf48622fd 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -47,7 +47,7 @@ /*#define BOUNDS_CHECK*/ -#ifdef FEATURE_OES_mapbuffer +#if FEATURE_OES_mapbuffer #define DEFAULT_ACCESS GL_MAP_WRITE_BIT #else #define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 73126b95755..521b18e43ed 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -873,7 +873,7 @@ _mesa_initialize_context(GLcontext *ctx, ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; } -#ifdef FEATURE_extra_context_init +#if FEATURE_extra_context_init _mesa_initialize_context_extra(ctx); #endif diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 30245d6aafa..ca992d12613 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -480,7 +480,7 @@ _mesa_enable_2_1_extensions(GLcontext *ctx) #if FEATURE_EXT_texture_sRGB ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif -#ifdef FEATURE_ARB_shading_language_120 +#if FEATURE_ARB_shading_language_120 ctx->Extensions.ARB_shading_language_120 = GL_TRUE; #endif } diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 07827348694..e3e006bb948 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -629,7 +629,7 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb) } } -#ifndef FEATURE_OES_framebuffer_object +#if !FEATURE_OES_framebuffer_object /* Check that all DrawBuffers are present */ for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { if (fb->ColorDrawBuffer[j] != GL_NONE) { diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index d3189b3f1b8..54edf9e7f01 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -110,6 +110,7 @@ #define FEATURE_texture_fxt1 FEATURE_GL #define FEATURE_texture_s3tc FEATURE_GL +#define FEATURE_extra_context_init FEATURE_ES #define FEATURE_fixedpt FEATURE_ES #define FEATURE_point_size_array FEATURE_ES #define FEATURE_vertex_array_byte FEATURE_ES @@ -142,5 +143,8 @@ #define FEATURE_NV_vertex_program FEATURE_GL #define FEATURE_OES_EGL_image 1 +#define FEATURE_OES_draw_texture FEATURE_ES1 +#define FEATURE_OES_framebuffer_object FEATURE_ES +#define FEATURE_OES_mapbuffer FEATURE_ES #endif /* FEATURES_H */ diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 714c4cfd523..ca03404f12f 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -371,7 +371,7 @@ set_tex_parameteri(GLcontext *ctx, } return GL_FALSE; -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: texObj->CropRect[0] = params[0]; texObj->CropRect[1] = params[1]; @@ -604,7 +604,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) } break; -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: { /* convert float params to int */ @@ -1160,7 +1160,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) else error = GL_TRUE; break; -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: params[0] = obj->CropRect[0]; params[1] = obj->CropRect[1]; @@ -1330,7 +1330,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) error = GL_TRUE; } break; -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: params[0] = obj->CropRect[0]; params[1] = obj->CropRect[1]; From f6f5cba9a66afea3f500e3be1c15e7b18d88e265 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Mar 2010 13:19:59 +0800 Subject: [PATCH 472/483] mesa/es: Use core mesa's mfeatures.h. Remove mfeatures_es1.h and mfeatures_es2.h. Build the overlay with either FEATURE_ES1 or FEATURE_ES2 defined. --- src/mesa/es/Makefile | 5 +- src/mesa/es/main/mfeatures_es1.h | 118 ------------------------------- src/mesa/es/main/mfeatures_es2.h | 118 ------------------------------- src/mesa/es/main/stubs.c | 7 -- 4 files changed, 2 insertions(+), 246 deletions(-) delete mode 100644 src/mesa/es/main/mfeatures_es1.h delete mode 100644 src/mesa/es/main/mfeatures_es2.h diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile index fbe67445c93..8b484853afe 100644 --- a/src/mesa/es/Makefile +++ b/src/mesa/es/Makefile @@ -19,9 +19,8 @@ es1: $(ES1_LIBS) es2: $(ES2_LIBS) @rm -f subdirs-stamp-tmp -# force the inclusion of es's mfeatures.h -ES1_CPPFLAGS := -include main/mfeatures_es1.h -D__GL_EXPORTS -ES2_CPPFLAGS := -include main/mfeatures_es2.h -D__GL_EXPORTS +ES1_CPPFLAGS := -DFEATURE_ES1=1 -D__GL_EXPORTS +ES2_CPPFLAGS := -DFEATURE_ES2=1 -D__GL_EXPORTS ES1_OBJ_DIR := objs-es1 ES2_OBJ_DIR := objs-es2 diff --git a/src/mesa/es/main/mfeatures_es1.h b/src/mesa/es/main/mfeatures_es1.h deleted file mode 100644 index 17935502689..00000000000 --- a/src/mesa/es/main/mfeatures_es1.h +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * \file mfeatures.h - * - * The #defines in this file enable/disable Mesa features needed - * for OpenGL ES 1.1. - */ - - -#ifndef MFEATURES_ES1_H -#define MFEATURES_ES1_H - -/* this file replaces main/mfeatures.h */ -#ifdef FEATURES_H -#error "main/mfeatures.h was wrongly included" -#endif -#define FEATURES_H - -#define ASSERT_NO_FEATURE() ASSERT(0) - -/* - * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1. - */ -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -#ifdef IN_DRI_DRIVER -#define FEATURE_remap_table 1 -#else -#define FEATURE_remap_table 0 -#endif - -#define FEATURE_accum 0 -#define FEATURE_arrayelt 0 -#define FEATURE_attrib 0 -#define FEATURE_beginend 0 -#define FEATURE_colortable 0 -#define FEATURE_convolve 0 -#define FEATURE_dispatch 1 -#define FEATURE_dlist 0 -#define FEATURE_draw_read_buffer 0 -#define FEATURE_drawpix 0 -#define FEATURE_eval 0 -#define FEATURE_feedback 0 -#define FEATURE_fixedpt 1 -#define FEATURE_histogram 0 -#define FEATURE_pixel 0 -#define FEATURE_point_size_array 1 -#define FEATURE_queryobj 0 -#define FEATURE_rastpos 0 -#define FEATURE_texgen 1 -#define FEATURE_texture_fxt1 0 -#define FEATURE_texture_s3tc 0 -#define FEATURE_userclip 1 -#define FEATURE_vertex_array_byte 1 -#define FEATURE_es2_glsl 0 - -#define FEATURE_ARB_fragment_program _HAVE_FULL_GL -#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL -#define FEATURE_ARB_vertex_program _HAVE_FULL_GL - -#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL -#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects - -#define FEATURE_EXT_framebuffer_blit 0 -#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL -#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL -#define FEATURE_EXT_texture_sRGB 0 -#define FEATURE_ATI_fragment_shader 0 -#define FEATURE_MESA_program_debug _HAVE_FULL_GL -#define FEATURE_NV_fence 0 -#define FEATURE_NV_fragment_program 0 -#define FEATURE_NV_vertex_program 0 - -#define FEATURE_OES_framebuffer_object 1 -#define FEATURE_OES_draw_texture 1 -#define FEATURE_OES_mapbuffer 1 - -#define FEATURE_OES_EGL_image 1 - -#define FEATURE_extra_context_init 1 - -/*@}*/ - - - - -#endif /* MFEATURES_ES1_H */ diff --git a/src/mesa/es/main/mfeatures_es2.h b/src/mesa/es/main/mfeatures_es2.h deleted file mode 100644 index a463bed11c6..00000000000 --- a/src/mesa/es/main/mfeatures_es2.h +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * \file mfeatures.h - * - * The #defines in this file enable/disable Mesa features needed - * for OpenGL ES 2.0. - */ - - -#ifndef MFEATURES_ES2_H -#define MFEATURES_ES2_H - -/* this file replaces main/mfeatures.h */ -#ifdef FEATURES_H -#error "main/mfeatures.h was wrongly included" -#endif -#define FEATURES_H - -#define ASSERT_NO_FEATURE() ASSERT(0) - -/* - * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1. - */ -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -#ifdef IN_DRI_DRIVER -#define FEATURE_remap_table 1 -#else -#define FEATURE_remap_table 0 -#endif - -#define FEATURE_accum 0 -#define FEATURE_arrayelt 0 -#define FEATURE_attrib 0 -#define FEATURE_beginend 0 -#define FEATURE_colortable 0 -#define FEATURE_convolve 0 -#define FEATURE_dispatch 1 -#define FEATURE_dlist 0 -#define FEATURE_draw_read_buffer 0 -#define FEATURE_drawpix 0 -#define FEATURE_eval 0 -#define FEATURE_feedback 0 -#define FEATURE_fixedpt 1 -#define FEATURE_histogram 0 -#define FEATURE_pixel 0 -#define FEATURE_point_size_array 1 -#define FEATURE_queryobj 0 -#define FEATURE_rastpos 0 -#define FEATURE_texgen 1 -#define FEATURE_texture_fxt1 0 -#define FEATURE_texture_s3tc 0 -#define FEATURE_userclip 1 -#define FEATURE_vertex_array_byte 1 -#define FEATURE_es2_glsl 1 - -#define FEATURE_ARB_fragment_program _HAVE_FULL_GL -#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL -#define FEATURE_ARB_vertex_program _HAVE_FULL_GL - -#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL -#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects - -#define FEATURE_EXT_framebuffer_blit 0 -#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL -#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL -#define FEATURE_EXT_texture_sRGB 0 -#define FEATURE_ATI_fragment_shader 0 -#define FEATURE_MESA_program_debug _HAVE_FULL_GL -#define FEATURE_NV_fence 0 -#define FEATURE_NV_fragment_program 0 -#define FEATURE_NV_vertex_program 0 - -#define FEATURE_OES_framebuffer_object 1 -#define FEATURE_OES_draw_texture 0 -#define FEATURE_OES_mapbuffer 1 - -#define FEATURE_OES_EGL_image 1 - -#define FEATURE_extra_context_init 1 - -/*@}*/ - - - - -#endif /* MFEATURES_ES2_H */ diff --git a/src/mesa/es/main/stubs.c b/src/mesa/es/main/stubs.c index e7b8bc780f8..b829543cc01 100644 --- a/src/mesa/es/main/stubs.c +++ b/src/mesa/es/main/stubs.c @@ -37,13 +37,6 @@ _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); \ } while (0) -#if FEATURE_accum -/* This is a sanity check that to be sure we're using the correct mfeatures.h - * header. We don't want to accidentally use the one from mainline Mesa. - */ -#error "The wrong mfeatures.h file is being included!" -#endif - /* silence compiler warnings */ extern void GLAPIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param); From aa1a79036003c2aeaae24877da66e9b46a059cad Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Mar 2010 15:41:31 +0800 Subject: [PATCH 473/483] st/dri: Fix a memory leak in dri1_init_screen. Free the returned configs upon errors. --- src/gallium/state_trackers/dri/drm/dri1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 9b5842ba2bf..cca7cd8f0c3 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -514,6 +514,8 @@ dri1_init_screen(__DRIscreen * sPriv) return configs; fail: + if (configs) + FREE(configs); dri_destroy_screen_helper(screen); FREE(screen); return NULL; From 07c6d94cd7272524ef06b2a787667e5d626137d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 30 Mar 2010 11:50:13 +0200 Subject: [PATCH 474/483] glx/dri2: Fix debug build with old dri2proto. Apparently the higher compiler optimization level in non-debug builds was eliminating the unused functions referencing the unresolved DRI2 symbols... --- src/glx/dri2_glx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 5b0f335db6a..14788b89bea 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -202,6 +202,8 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, return &pdraw->base; } +#ifdef X_DRI2GetMSC + static int dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, int64_t *ust, int64_t *msc, int64_t *sbc) @@ -209,6 +211,11 @@ dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc); } +#endif + + +#ifdef X_DRI2WaitMSC + static int dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc) @@ -225,6 +232,8 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, sbc); } +#endif /* X_DRI2WaitMSC */ + static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) { @@ -448,6 +457,8 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, return pdraw->buffers; } +#ifdef X_DRI2SwapInterval + static void dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) { @@ -465,6 +476,8 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw) return priv->swap_interval; } +#endif /* X_DRI2SwapInterval */ + static const __DRIdri2LoaderExtension dri2LoaderExtension = { {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, dri2GetBuffers, From 5cc9387d0de966e855794d3108b31737a6dfc13a Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Tue, 30 Mar 2010 13:09:16 +0300 Subject: [PATCH 475/483] drisw: fix use after free (bug 27370) --- src/mesa/drivers/dri/common/drisw_util.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c index 3f4e94c8f6e..8d08b93bfb5 100644 --- a/src/mesa/drivers/dri/common/drisw_util.c +++ b/src/mesa/drivers/dri/common/drisw_util.c @@ -184,8 +184,6 @@ static int driUnbindContext(__DRIcontext *pcp) pcp->driDrawablePriv = NULL; pcp->driReadablePriv = NULL; - pdp->driContextPriv = NULL; - return GL_TRUE; } From dc886ba1391d7d890bd1f5532bc14553e883a418 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 30 Mar 2010 08:55:17 -0400 Subject: [PATCH 476/483] gallivm: cleanup the code (found by coverity) the condition can't be false, declerations are ok even if we don't emit any. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 95cd6a0ecf3..8901e656aed 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -666,30 +666,20 @@ emit_declaration( first_inst); for (idx = first; idx <= last; ++idx) { - boolean ok; - switch (decl->Declaration.File) { case TGSI_FILE_TEMPORARY: for (i = 0; i < NUM_CHANNELS; i++) bld->temps[idx][i] = lp_build_alloca(&bld->base); - ok = TRUE; break; case TGSI_FILE_OUTPUT: for (i = 0; i < NUM_CHANNELS; i++) bld->outputs[idx][i] = lp_build_alloca(&bld->base); - ok = TRUE; break; default: /* don't need to declare other vars */ - ok = TRUE; - } - - if (!ok) { - LLVMPositionBuilderAtEnd(bld->base.builder, - current_block); - return FALSE; + break; } } From 3623202834e9ca1073a4aa66f72f584812fb14df Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 30 Mar 2010 10:43:51 -0700 Subject: [PATCH 477/483] r300/compiler: Unbreak DDX/DDY. Fixes progs/glsl/deriv. --- .../dri/r300/compiler/r500_fragprog_emit.c | 23 +++++++++++++++++-- .../dri/r300/compiler/radeon_opcodes.c | 4 ++-- .../dri/r300/compiler/radeon_pair_translate.c | 5 ---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c index 4e84eefd658..b6dfe28def9 100644 --- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c +++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c @@ -190,6 +190,17 @@ static unsigned int use_source(struct r500_fragment_program_code* code, struct r return 0; } +/** + * NOP the specified instruction if it is not a texture lookup. + */ +static void alu_nop(struct r300_fragment_program_compiler *c, int ip) +{ + PROG_CODE; + + if ((code->inst[ip].inst0 & 0x3) != R500_INST_TYPE_TEX) { + code->inst[ip].inst0 |= R500_INST_NOP; + } +} /** * Emit a paired ALU instruction. @@ -205,6 +216,14 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair int ip = ++code->inst_end; + /* Quirk: MDH/MDV (DDX/DDY) need a NOP on previous non-TEX instructions. */ + if (inst->RGB.Opcode == RC_OPCODE_DDX || inst->Alpha.Opcode == RC_OPCODE_DDX || + inst->RGB.Opcode == RC_OPCODE_DDY || inst->Alpha.Opcode == RC_OPCODE_DDY) { + if (ip > 0) { + alu_nop(c, ip - 1); + } + } + code->inst[ip].inst5 = translate_rgb_op(c, inst->RGB.Opcode); code->inst[ip].inst4 = translate_alpha_op(c, inst->Alpha.Opcode); @@ -252,8 +271,8 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair code->inst[ip].inst4 |= translate_arg_alpha(inst, 1) << R500_ALPHA_SEL_B_SHIFT; code->inst[ip].inst5 |= translate_arg_alpha(inst, 2) << R500_ALU_RGBA_ALPHA_SEL_C_SHIFT; - code->inst[ip].inst3 |= R500_ALU_RGB_TARGET(inst->RGB.Target); - code->inst[ip].inst4 |= R500_ALPHA_TARGET(inst->Alpha.Target); + code->inst[ip].inst3 |= R500_ALU_RGB_TARGET(inst->RGB.Target); + code->inst[ip].inst4 |= R500_ALPHA_TARGET(inst->Alpha.Target); if (inst->WriteALUResult) { code->inst[ip].inst3 |= R500_ALU_RGB_WMASK; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c index c1c0181fac1..9d289fce342 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c @@ -75,14 +75,14 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = { { .Opcode = RC_OPCODE_DDX, .Name = "DDX", - .NumSrcRegs = 1, + .NumSrcRegs = 2, .HasDstReg = 1, .IsComponentwise = 1 }, { .Opcode = RC_OPCODE_DDY, .Name = "DDY", - .NumSrcRegs = 1, + .NumSrcRegs = 2, .HasDstReg = 1, .IsComponentwise = 1 }, diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c index fff5b0c2173..3a26e7daaf9 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c @@ -159,11 +159,6 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c, int nargs = opcode->NumSrcRegs; int i; - /* Special case for DDX/DDY (MDH/MDV). */ - if (inst->Opcode == RC_OPCODE_DDX || inst->Opcode == RC_OPCODE_DDY) { - nargs++; - } - for(i = 0; i < opcode->NumSrcRegs; ++i) { int source; if (needrgb && !istranscendent) { From 581c773e81cdc467be2d09a0ccd76c0de3cba529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Mar 2010 14:05:47 -0400 Subject: [PATCH 478/483] intel: Use fb->Height when flipping read buffer orientation With DRI2, x and y are always zero and fb->Height is always up to date with the drawable height. --- src/mesa/drivers/dri/intel/intel_tex_copy.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index 618f690a5f8..62e1e78f59b 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -130,18 +130,8 @@ do_copy_texsubimage(struct intel_context *intel, } if (ctx->ReadBuffer->Name == 0) { - /* reading from a window, adjust x, y */ - const __DRIdrawable *dPriv = intel->driReadDrawable; - y = dPriv->y + (dPriv->h - (y + height)); - x += dPriv->x; - - /* Invert the data coming from the source rectangle due to GL - * and hardware disagreeing on where y=0 is. - * - * It appears that our offsets and pitches get mangled - * appropriately by the hardware, and we don't need to adjust them - * on our own. - */ + /* Flip vertical orientation for system framebuffers */ + y = ctx->ReadBuffer->Height - (y + height); src_pitch = -src->pitch; } else { /* reading from a FBO, y is already oriented the way we like */ From ff6bce552a1522160c64d10677a36a7ad6cf5f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Mar 2010 14:32:10 -0400 Subject: [PATCH 479/483] intel: Remove redundant fields from struct intel_context All these pointers are in the __DRIcontext struct, which we point to. --- src/mesa/drivers/dri/i915/i915_state.c | 2 +- src/mesa/drivers/dri/i915/intel_tris.c | 12 +++++----- src/mesa/drivers/dri/intel/intel_context.c | 26 +++++++--------------- src/mesa/drivers/dri/intel/intel_context.h | 3 --- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 7275617a6fb..91b228d52b9 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -374,7 +374,7 @@ intelCalcViewport(GLcontext * ctx) else { /* window buffer, y=0=top */ yScale = -1.0; - yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F; + yBias = ctx->DrawBuffer->Height; } m[MAT_SX] = v[MAT_SX]; diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 81c4adeaf34..9449a158dc6 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -488,9 +488,9 @@ intel_wpos_triangle(struct intel_context *intel, __memcpy(v1_wpos, v1, size); __memcpy(v2_wpos, v2, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; - v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; - v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h; + v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height; + v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height; + v2_wpos[1] = -v2_wpos[1] + intel->ctx.DrawBuffer->Height; intel_draw_triangle(intel, v0, v1, v2); @@ -509,8 +509,8 @@ intel_wpos_line(struct intel_context *intel, __memcpy(v0_wpos, v0, size); __memcpy(v1_wpos, v1, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; - v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; + v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height; + v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height; intel_draw_line(intel, v0, v1); } @@ -524,7 +524,7 @@ intel_wpos_point(struct intel_context *intel, intelVertexPtr v0) GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); __memcpy(v0_wpos, v0, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; + v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height; intel_draw_point(intel, v0); } diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 5289e954dbd..176f32f3aa7 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -389,7 +389,7 @@ intel_prepare_render(struct intel_context *intel) __DRIcontext *driContext = intel->driContext; __DRIdrawable *drawable; - drawable = intel->driDrawable; + drawable = driContext->driDrawablePriv; if (drawable->dri2.stamp != driContext->dri2.draw_stamp) { if (drawable->lastStamp != drawable->dri2.stamp) intel_update_renderbuffers(driContext, drawable); @@ -397,7 +397,7 @@ intel_prepare_render(struct intel_context *intel) driContext->dri2.draw_stamp = drawable->dri2.stamp; } - drawable = intel->driReadDrawable; + drawable = driContext->driReadablePriv; if (drawable->dri2.stamp != driContext->dri2.read_stamp) { if (drawable->lastStamp != drawable->dri2.stamp) intel_update_renderbuffers(driContext, drawable); @@ -472,6 +472,7 @@ void intel_flush(GLcontext *ctx, GLboolean needs_mi_flush) { struct intel_context *intel = intel_context(ctx); + __DRIcontext *driContext = intel->driContext; if (intel->Fallback) _swrast_flush(ctx); @@ -488,9 +489,10 @@ intel_flush(GLcontext *ctx, GLboolean needs_mi_flush) if (screen->dri2.loader && (screen->dri2.loader->base.version >= 2) && (screen->dri2.loader->flushFrontBuffer != NULL) && - intel->driDrawable && intel->driDrawable->loaderPrivate) { - (*screen->dri2.loader->flushFrontBuffer)(intel->driDrawable, - intel->driDrawable->loaderPrivate); + driContext->driDrawablePriv && + driContext->driDrawablePriv->loaderPrivate) { + (*screen->dri2.loader->flushFrontBuffer)(driContext->driDrawablePriv, + driContext->driDrawablePriv->loaderPrivate); /* Only clear the dirty bit if front-buffer rendering is no longer * enabled. This is done so that the dirty bit can only be set in @@ -607,7 +609,6 @@ intelInitContext(struct intel_context *intel, driContextPriv->driverPrivate = intel; intel->intelScreen = intelScreen; - intel->driScreen = sPriv; intel->driContext = driContextPriv; intel->driFd = sPriv->fd; @@ -636,8 +637,7 @@ intelInitContext(struct intel_context *intel, } driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache, - intel->driScreen->myNum, - (intel->gen >= 4) ? "i965" : "i915"); + sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915"); if (intelScreen->deviceID == PCI_CHIP_I865_G) intel->maxBatchSize = 4096; else @@ -845,14 +845,6 @@ intelDestroyContext(__DRIcontext * driContextPriv) GLboolean intelUnbindContext(__DRIcontext * driContextPriv) { - struct intel_context *intel = - (struct intel_context *) driContextPriv->driverPrivate; - - /* Deassociate the context with the drawables. - */ - intel->driDrawable = NULL; - intel->driReadDrawable = NULL; - return GL_TRUE; } @@ -881,8 +873,6 @@ intelMakeCurrent(__DRIcontext * driContextPriv, struct gl_framebuffer *fb = driDrawPriv->driverPrivate; struct gl_framebuffer *readFb = driReadPriv->driverPrivate; - intel->driReadDrawable = driReadPriv; - intel->driDrawable = driDrawPriv; driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1; driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1; intel_prepare_render(intel); diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 6a68c903ee0..c4bb2bed8e0 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -243,9 +243,6 @@ struct intel_context int driFd; __DRIcontext *driContext; - __DRIdrawable *driDrawable; - __DRIdrawable *driReadDrawable; - __DRIscreen *driScreen; struct intel_screen *intelScreen; /** From 221bc02d29b92cf81a2fee62e3685bc4ae20ea14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Mar 2010 14:37:02 -0400 Subject: [PATCH 480/483] dri: Drop an unused __DRIcontext field --- src/mesa/drivers/dri/common/dri_util.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index f63583cebc0..dae8f9eae35 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -398,11 +398,6 @@ struct __DRIcontextRec { */ void *driverPrivate; - /** - * Pointer back to the \c __DRIcontext that contains this structure. - */ - __DRIcontext *pctx; - /** * Pointer to drawable currently bound to this context for drawing. */ From 42510765907014aabdee39a38ffe0283f7e32654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Mar 2010 14:38:52 -0400 Subject: [PATCH 481/483] dri: Drop the unused dummyContext --- src/mesa/drivers/dri/common/dri_util.c | 24 ------------------------ src/mesa/drivers/dri/common/dri_util.h | 12 ------------ 2 files changed, 36 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index badbb5ff824..f1bbd386128 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -129,11 +129,6 @@ static int driUnbindContext(__DRIcontext *pcp) */ pcp->driDrawablePriv = pcp->driReadablePriv = NULL; -#if 0 - /* Unbind the drawable */ - pdp->driContextPriv = &psp->dummyContextPriv; -#endif - return GL_TRUE; } @@ -433,7 +428,6 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, pdp->vblFlags = 0; pdp->driScreenPriv = psp; - pdp->driContextPriv = &psp->dummyContextPriv; if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, renderType == GLX_PIXMAP_BIT)) { @@ -567,17 +561,6 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, pcp->dri2.draw_stamp = 0; pcp->dri2.read_stamp = 0; - /* When the first context is created for a screen, initialize a "dummy" - * context. - */ - - if (!psp->dri2.enabled && !psp->dummyContextPriv.driScreenPriv) { - psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context; - psp->dummyContextPriv.driScreenPriv = psp; - psp->dummyContextPriv.driDrawablePriv = NULL; - psp->dummyContextPriv.driverPrivate = NULL; - /* No other fields should be used! */ - } pcp->hHWContext = hwContext; @@ -734,13 +717,6 @@ driCreateNewScreen(int scrn, psp->myNum = scrn; psp->dri2.enabled = GL_FALSE; - /* - ** Do not init dummy context here; actual initialization will be - ** done when the first DRI context is created. Init screen priv ptr - ** to NULL to let CreateContext routine that it needs to be inited. - */ - psp->dummyContextPriv.driScreenPriv = NULL; - psp->DriverAPI = driDriverAPI; *driver_modes = driDriverAPI.InitScreen(psp); diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index dae8f9eae35..398040a1e7e 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -505,18 +505,6 @@ struct __DRIscreenRec { int devPrivSize; /*@}*/ - /** - * Dummy context to which drawables are bound when not bound to any - * other context. - * - * A dummy hHWContext is created for this context, and is used by the GL - * core when a hardware lock is required but the drawable is not currently - * bound (e.g., potentially during a SwapBuffers request). The dummy - * context is created when the first "real" context is created on this - * screen. - */ - __DRIcontext dummyContextPriv; - /** * Device-dependent private information (not stored in the SAREA). * From 94264994b1332109974f7de8179535429f34caf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Mar 2010 14:41:27 -0400 Subject: [PATCH 482/483] dri: Drop another unused __DRIscreen field --- src/mesa/drivers/dri/common/dri_util.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 398040a1e7e..038a81604fc 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -512,11 +512,6 @@ struct __DRIscreenRec { */ void *private; - /** - * Pointer back to the \c __DRIscreen that contains this structure. - */ - __DRIscreen *psc; - /* Extensions provided by the loader. */ const __DRIgetDrawableInfoExtension *getDrawableInfo; const __DRIsystemTimeExtension *systemTime; From 4afed821baa6993d85a07c67d42ea40d4e9a600a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 15:38:03 -0700 Subject: [PATCH 483/483] intel: Bump intel driver date to later than the date on the 7.8 branch --- src/mesa/drivers/dri/intel/intel_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 176f32f3aa7..9077a611328 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -63,7 +63,7 @@ int INTEL_DEBUG = (0); #endif -#define DRIVER_DATE "20091221 DEVELOPMENT" +#define DRIVER_DATE "20100330 DEVELOPMENT" #define DRIVER_DATE_GEM "GEM " DRIVER_DATE