diff options
author | Nian Wu <[email protected]> | 2007-03-24 17:00:29 +0800 |
---|---|---|
committer | Nian Wu <[email protected]> | 2007-03-24 17:00:29 +0800 |
commit | 44fb5156bbda5e4fc1cd810fec5e50ac70ff39cf (patch) | |
tree | a76a13172f73a97a97632433d3dacd9376778e18 /src/mesa | |
parent | ad76128204d856527e033a83c1b5a35a2f52ba92 (diff) | |
parent | 8e1c3bd0b4c599bae5b64cd51cec1d74266f30fb (diff) |
Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 216 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 12 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xmesaP.h | 1 | ||||
-rw-r--r-- | src/mesa/main/renderbuffer.c | 32 | ||||
-rw-r--r-- | src/mesa/main/renderbuffer.h | 3 |
5 files changed, 151 insertions, 113 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index fcb61a28316..47f1546c07e 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -357,7 +357,7 @@ static void update_alpha(GLcontext *ctx) GLboolean really_enabled = ctx->Color.AlphaEnabled; CLAMPED_FLOAT_TO_UBYTE(refByte, ctx->Color.AlphaRef); - + switch (ctx->Color.AlphaFunc) { case GL_NEVER: pp_misc |= R300_ALPHA_TEST_FAIL; @@ -385,15 +385,15 @@ static void update_alpha(GLcontext *ctx) really_enabled = GL_FALSE; break; } - + if (really_enabled) { pp_misc |= R300_ALPHA_TEST_ENABLE; pp_misc |= (refByte & R300_REF_ALPHA_MASK); } else { pp_misc = 0x0; } - - + + R300_STATECHANGE(r300, at); r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc; update_early_z(ctx); @@ -436,19 +436,19 @@ static void update_depth(GLcontext* ctx) R300_STATECHANGE(r300, zs); r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE; r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT); - + if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER) { if (ctx->Depth.Mask) r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_TEST_AND_WRITE; else r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_TEST; - + r300->hw.zs.cmd[R300_ZS_CNTL_1] |= translate_func(ctx->Depth.Func) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT; } else { r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1; r300->hw.zs.cmd[R300_ZS_CNTL_1] |= translate_func(GL_NEVER) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT; } - + update_early_z(ctx); } @@ -479,7 +479,7 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) if (state) { r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE; - + ctx->Driver.Fogfv( ctx, GL_FOG_MODE, NULL ); ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); @@ -489,7 +489,7 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE; } - + break; case GL_ALPHA_TEST: @@ -518,7 +518,7 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) } else { #if R200_MERGED FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state); -#endif +#endif } break; @@ -553,7 +553,7 @@ static void r300UpdatePolygonMode(GLcontext *ctx) if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) { GLenum f, b; - + if (ctx->Polygon.FrontFace == GL_CCW) { f = ctx->Polygon.FrontMode; b = ctx->Polygon.BackMode; @@ -671,9 +671,9 @@ static void r300Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) { r300ContextPtr r300 = R300_CONTEXT(ctx); union { int i; float f; } fogScale, fogStart; - + (void) param; - + fogScale.i = r300->hw.fogp.cmd[R300_FOGP_SCALE]; fogStart.i = r300->hw.fogp.cmd[R300_FOGP_START]; @@ -769,7 +769,7 @@ static void r300PointSize(GLcontext * ctx, GLfloat size) size = ctx->Point._Size; R300_STATECHANGE(r300, ps); - r300->hw.ps.cmd[R300_PS_POINTSIZE] = + r300->hw.ps.cmd[R300_PS_POINTSIZE] = ((int)(size * 6) << R300_POINTSIZE_X_SHIFT) | ((int)(size * 6) << R300_POINTSIZE_Y_SHIFT); } @@ -792,7 +792,7 @@ static void r300PolygonMode(GLcontext *ctx, GLenum face, GLenum mode) { (void)face; (void)mode; - + r300UpdatePolygonMode(ctx); } @@ -829,7 +829,7 @@ static int translate_stencil_op(int op) static void r300ShadeModel(GLcontext * ctx, GLenum mode) { r300ContextPtr rmesa = R300_CONTEXT(ctx); - + R300_STATECHANGE(rmesa, shade); switch (mode) { case GL_FLAT: @@ -849,7 +849,7 @@ static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face, r300ContextPtr rmesa = R300_CONTEXT(ctx); GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | ((ctx->Stencil.ValueMask[0] & 0xff) << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); - + GLuint flag; R300_STATECHANGE(rmesa, zs); @@ -857,16 +857,16 @@ static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face, rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~( (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT)); - + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | (R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); - + flag = translate_func(ctx->Stencil.Function[0]); rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (flag << R300_RB3D_ZS1_FRONT_FUNC_SHIFT); - + if (ctx->Stencil._TestTwoSide) flag = translate_func(ctx->Stencil.Function[1]); - + rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (flag << R300_RB3D_ZS1_BACK_FUNC_SHIFT); rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= refmask; } @@ -888,16 +888,16 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face, GLenum fail, R300_STATECHANGE(rmesa, zs); /* It is easier to mask what's left.. */ - rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= - (R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT) | - (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | + rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= + (R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT) | + (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT); rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT); - + if (ctx->Stencil._TestTwoSide) { rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (translate_stencil_op(ctx->Stencil.FailFunc[1]) << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) @@ -992,7 +992,7 @@ void r300UpdateViewportOffset( GLcontext *ctx ) R300_STATECHANGE( rmesa, vpt ); rmesa->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(tx); rmesa->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(ty); - + } radeonUpdateScissor( ctx ); @@ -1028,16 +1028,16 @@ r300UpdateDrawBuffer(GLcontext *ctx) R300_STATECHANGE( rmesa, cb ); - + r300->hw.cb.cmd[R300_CB_OFFSET] = drb->flippedOffset + //r300->radeon.state.color.drawOffset + r300->radeon.radeonScreen->fbLocation; r300->hw.cb.cmd[R300_CB_PITCH] = drb->flippedPitch;//r300->radeon.state.color.drawPitch; - + if (r300->radeon.radeonScreen->cpp == 4) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888; else r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565; - + if (r300->radeon.sarea->tiling_enabled) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE; #if 0 @@ -1048,7 +1048,7 @@ r300UpdateDrawBuffer(GLcontext *ctx) = ((drb->flippedOffset + rmesa->r200Screen->fbLocation) & R200_COLOROFFSET_MASK); rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch; - + if (rmesa->sarea->tiling_enabled) { rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE; } @@ -1115,7 +1115,7 @@ static void r300PolygonOffset(GLcontext * ctx, GLfloat factor, GLfloat units) { r300ContextPtr rmesa = R300_CONTEXT(ctx); GLfloat constant = units; - + switch (ctx->Visual.depthBits) { case 16: constant *= 4.0; @@ -1224,7 +1224,7 @@ void r300_setup_textures(GLcontext *ctx) R300_STATECHANGE(r300, tex.offset); R300_STATECHANGE(r300, tex.chroma_key); R300_STATECHANGE(r300, tex.border_color); - + r300->hw.txe.cmd[R300_TXE_ENABLE]=0x0; mtu = r300->radeon.glCtx->Const.MaxTextureUnits; @@ -1240,23 +1240,23 @@ void r300_setup_textures(GLcontext *ctx) /* We cannot let disabled tmu offsets pass DRM */ for(i=0; i < mtu; i++) { if(TMU_ENABLED(ctx, i)) { - + #if 0 /* Enables old behaviour */ hw_tmu = i; #endif tmu_mappings[i] = hw_tmu; - + t=r300->state.texture.unit[i].texobj; - + if((t->format & 0xffffff00)==0xffffff00) { WARN_ONCE("unknown texture format (entry %x) encountered. Help me !\n", t->format & 0xff); } - + if (RADEON_DEBUG & DEBUG_STATE) fprintf(stderr, "Activating texture unit %d\n", i); - + r300->hw.txe.cmd[R300_TXE_ENABLE] |= (1 << hw_tmu); - + r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 + hw_tmu] = gen_fixed_filter(t->filter) | (hw_tmu << 28); /* Currently disabled! */ r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0; //0x20501f80; @@ -1264,24 +1264,24 @@ void r300_setup_textures(GLcontext *ctx) r300->hw.tex.format.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->format; r300->hw.tex.pitch.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->pitch_reg; r300->hw.tex.offset.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->offset; - + if(t->offset & R300_TXO_MACRO_TILE) { WARN_ONCE("macro tiling enabled!\n"); } - + if(t->offset & R300_TXO_MICRO_TILE) { WARN_ONCE("micro tiling enabled!\n"); } - + r300->hw.tex.chroma_key.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0; r300->hw.tex.border_color.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->pp_border_color; - + last_hw_tmu = hw_tmu; - + hw_tmu++; } } - + r300->hw.tex.filter.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FILTER_0, last_hw_tmu + 1); r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FILTER1_0, last_hw_tmu + 1); r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, last_hw_tmu + 1); @@ -1290,31 +1290,31 @@ void r300_setup_textures(GLcontext *ctx) r300->hw.tex.offset.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_OFFSET_0, last_hw_tmu + 1); r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_CHROMA_KEY_0, last_hw_tmu + 1); r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_BORDER_COLOR_0, last_hw_tmu + 1); - - + + if (!rp) /* should only happenen once, just after context is created */ return; - + R300_STATECHANGE(r300, fpt); - + for(i = 0; i < rp->tex.length; i++){ int unit; unsigned long val; - + unit = rp->tex.inst[i] >> R300_FPITX_IMAGE_SHIFT; unit &= 15; - + val = rp->tex.inst[i]; val &= ~R300_FPITX_IMAGE_MASK; - + assert(tmu_mappings[unit] >= 0); - + val |= tmu_mappings[unit] << R300_FPITX_IMAGE_SHIFT; r300->hw.fpt.cmd[R300_FPT_INSTR_0+i] = val; } - + r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, rp->tex.length); - + if (RADEON_DEBUG & DEBUG_STATE) fprintf(stderr, "TX_ENABLE: %08x last_hw_tmu=%d\n", r300->hw.txe.cmd[R300_TXE_ENABLE], last_hw_tmu); } @@ -1363,11 +1363,11 @@ void r300_setup_rs_unit(GLcontext *ctx) R300_STATECHANGE(r300, ri); R300_STATECHANGE(r300, rc); R300_STATECHANGE(r300, rr); - + fp_reg = in_texcoords = col_interp_nr = high_rr = 0; r300->hw.rr.cmd[R300_RR_ROUTE_1] = 0; - + if (InputsRead & FRAG_BIT_WPOS){ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) if (!(InputsRead & (FRAG_BIT_TEX0 << i))) @@ -1381,7 +1381,7 @@ void r300_setup_rs_unit(GLcontext *ctx) InputsRead |= (FRAG_BIT_TEX0 << i); InputsRead &= ~FRAG_BIT_WPOS; } - + for (i=0;i<ctx->Const.MaxTextureUnits;i++) { r300->hw.ri.cmd[R300_RI_INTERP_0+i] = 0 | R300_RS_INTERP_USED @@ -1405,7 +1405,7 @@ void r300_setup_rs_unit(GLcontext *ctx) } InputsRead &= ~(FRAG_BIT_TEX0<<i); fp_reg++; - } + } /* Need to count all coords enabled at vof */ if (R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_TEX0+i, _TNL_ATTRIB_TEX(i) )) in_texcoords++; @@ -1426,7 +1426,7 @@ void r300_setup_rs_unit(GLcontext *ctx) col_interp_nr++; } out: - + if (InputsRead & FRAG_BIT_COL1) { if (!R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1 )) { WARN_ONCE("fragprog wants col1, vp doesn't provide it\n"); @@ -1440,7 +1440,7 @@ void r300_setup_rs_unit(GLcontext *ctx) if (high_rr < 1) high_rr = 1; col_interp_nr++; } - + /* Need at least one. This might still lock as the values are undefined... */ if (in_texcoords == 0 && col_interp_nr == 0) { r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 @@ -1448,7 +1448,7 @@ void r300_setup_rs_unit(GLcontext *ctx) | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT); col_interp_nr++; } - + r300->hw.rc.cmd[1] = 0 | (in_texcoords << R300_RS_CNTL_TC_CNT_SHIFT) | (col_interp_nr << R300_RS_CNTL_CI_CNT_SHIFT) @@ -1513,8 +1513,8 @@ void r300SetupVertexProgram(r300ContextPtr rmesa); /* just a skeleton for now.. */ /* Generate a vertex shader that simply transforms vertex and texture coordinates, - while leaving colors intact. Nothing fancy (like lights) - + while leaving colors intact. Nothing fancy (like lights) + If implementing lights make a copy first, so it is easy to switch between the two versions */ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) { @@ -1525,14 +1525,14 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) r300->state.vap_param.transform_offset=0x0; /* transform matrix */ r300->state.vertex_shader.param_offset=0x0; r300->state.vertex_shader.param_count=0x4; /* 4 vector values - 4x4 matrix */ - + r300->state.vertex_shader.program_start=0x0; r300->state.vertex_shader.unknown_ptr1=0x4; /* magic value ? */ r300->state.vertex_shader.program_end=0x0; - + r300->state.vertex_shader.unknown_ptr2=0x0; /* magic value */ r300->state.vertex_shader.unknown_ptr3=0x4; /* magic value */ - + /* Initialize matrix and vector parameters.. these should really be restructured */ /* TODO: fix vertex_shader structure */ r300->state.vertex_shader.matrix[0].length=16; @@ -1542,7 +1542,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) r300->state.vertex_shader.vector[1].length=0; r300->state.vertex_shader.unknown1.length=0; r300->state.vertex_shader.unknown2.length=0; - + #define WRITE_OP(oper,source1,source2,source3) {\ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].op=(oper); \ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src1=(source1); \ @@ -1552,35 +1552,35 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) } /* Multiply vertex coordinates with transform matrix */ - + WRITE_OP( EASY_VSF_OP(MUL, 0, ALL, TMP), VSF_PARAM(3), VSF_ATTR_W(0), EASY_VSF_SOURCE(0, W, W, W, W, NONE, NONE) ) - + WRITE_OP( EASY_VSF_OP(MUL, 1, ALL, RESULT), VSF_REG(1), VSF_ATTR_UNITY(1), VSF_UNITY(1) ) - + WRITE_OP( EASY_VSF_OP(MAD, 0, ALL, TMP), VSF_PARAM(2), VSF_ATTR_Z(0), VSF_TMP(0) ) - + WRITE_OP( EASY_VSF_OP(MAD, 0, ALL, TMP), VSF_PARAM(1), VSF_ATTR_Y(0), VSF_TMP(0) ) - + WRITE_OP( EASY_VSF_OP(MAD, 0, ALL, RESULT), VSF_PARAM(0), @@ -1588,7 +1588,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) VSF_TMP(0) ) o_reg += 2; - + for (i = VERT_ATTRIB_COLOR1; i < VERT_ATTRIB_MAX; i++) if (r300->state.sw_tcl_inputs[i] != -1) { WRITE_OP( @@ -1597,16 +1597,16 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) VSF_ATTR_UNITY(r300->state.sw_tcl_inputs[i]), VSF_UNITY(r300->state.sw_tcl_inputs[i]) ) - + } - + r300->state.vertex_shader.program_end--; /* r300 wants program length to be one more - no idea why */ r300->state.vertex_shader.program.length=(r300->state.vertex_shader.program_end+1)*4; - + r300->state.vertex_shader.unknown_ptr1=r300->state.vertex_shader.program_end; /* magic value ? */ r300->state.vertex_shader.unknown_ptr2=r300->state.vertex_shader.program_end; /* magic value ? */ r300->state.vertex_shader.unknown_ptr3=r300->state.vertex_shader.program_end; /* magic value ? */ - + } @@ -1684,14 +1684,14 @@ void r300SetupVertexProgram(r300ContextPtr rmesa) int inst_count; int param_count; struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); - + ((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0; R300_STATECHANGE(rmesa, vpp); param_count = r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *)ctx->VertexProgram._Current/*prog*/, (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]); bump_vpu_count(rmesa->hw.vpp.cmd, param_count); param_count /= 4; - + /* Reset state, in case we don't use something */ ((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0; ((drm_r300_cmd_header_t*)rmesa->hw.vps.cmd)->vpu.count = 0; @@ -1730,23 +1730,23 @@ void r300UpdateShaders(r300ContextPtr rmesa) GLcontext *ctx; struct r300_vertex_program *vp; int i; - + ctx = rmesa->radeon.glCtx; - + if (rmesa->NewGLState && hw_tcl_on) { rmesa->NewGLState = 0; - + for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { rmesa->temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &rmesa->dummy_attrib[i]; } - + _tnl_UpdateFixedFunctionProgram(ctx); - + for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { TNL_CONTEXT(ctx)->vb.AttribPtr[i] = rmesa->temp_attrib[i]; } - + r300_select_vertex_shader(rmesa); vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); /*if (vp->translated == GL_FALSE) @@ -1760,26 +1760,26 @@ void r300UpdateShaders(r300ContextPtr rmesa) } r300UpdateStateParameters(ctx, _NEW_PROGRAM); } - + } void r300UpdateShaderStates(r300ContextPtr rmesa) { GLcontext *ctx; ctx = rmesa->radeon.glCtx; - + r300UpdateTextureState(ctx); r300SetupPixelShader(rmesa); r300_setup_textures(ctx); - + r300SetupVertexShader(rmesa); r300_setup_rs_unit(ctx); } /* This is probably wrong for some values, I need to test this * some more. Range checking would be a good idea also.. - * + * * But it works for most things. I'll fix it later if someone * else with a better clue doesn't */ @@ -1817,13 +1817,13 @@ void r300SetupPixelShader(r300ContextPtr rmesa) if (!rp) /* should only happenen once, just after context is created */ return; - + r300_translate_fragment_shader(rmesa, rp); if (!rp->translated) { fprintf(stderr, "%s: No valid fragment shader, exiting\n", __func__); return; } - + #define OUTPUT_FIELD(st, reg, field) \ R300_STATECHANGE(rmesa, st); \ for(i=0;i<=rp->alu_end;i++) \ @@ -1880,7 +1880,7 @@ void r300SetupPixelShader(r300ContextPtr rmesa) static void r300InvalidateState(GLcontext * ctx, GLuint new_state) { r300ContextPtr r300 = R300_CONTEXT(ctx); - + _swrast_InvalidateState(ctx, new_state); _swsetup_InvalidateState(ctx, new_state); _vbo_InvalidateState(ctx, new_state); @@ -1941,7 +1941,7 @@ void r300ResetHwState(r300ContextPtr r300) r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); r300DepthMask(ctx, ctx->Depth.Mask); r300DepthFunc(ctx, ctx->Depth.Func); - + /* stencil */ r300Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); r300StencilMaskSeparate(ctx, 0, ctx->Stencil.WriteMask[0]); @@ -1953,7 +1953,7 @@ void r300ResetHwState(r300ContextPtr r300) r300UpdateTextureState(ctx); // r300_setup_routing(ctx, GL_TRUE); - + #if 0 /* Done in prior to rendering */ if(hw_tcl_on == GL_FALSE){ r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */ @@ -1969,7 +1969,7 @@ void r300ResetHwState(r300ContextPtr r300) r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef); r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled); - + /* Initialize magic registers TODO : learn what they really do, or get rid of those we don't have to touch */ @@ -2034,7 +2034,7 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666; r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666; - if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) || + if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) || (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350)) r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R300 @@ -2093,7 +2093,7 @@ void r300ResetHwState(r300ContextPtr r300) r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, ctx->Polygon.OffsetUnits); r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill); - + r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF; r300->hw.unk42C0.cmd[2] = 0x00000000; @@ -2149,20 +2149,20 @@ void r300ResetHwState(r300ContextPtr r300) r300BlendColor(ctx, ctx->Color.BlendColor); r300->hw.blend_color.cmd[2] = 0; r300->hw.blend_color.cmd[3] = 0; - + /* Again, r300ClearBuffer uses this */ r300->hw.cb.cmd[R300_CB_OFFSET] = r300->radeon.state.color.drawOffset + r300->radeon.radeonScreen->fbLocation; r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch; - + if (r300->radeon.radeonScreen->cpp == 4) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888; else r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565; - + if (r300->radeon.sarea->tiling_enabled) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE; - + r300->hw.unk4E50.cmd[1] = 0; r300->hw.unk4E50.cmd[2] = 0; r300->hw.unk4E50.cmd[3] = 0; @@ -2189,11 +2189,11 @@ void r300ResetHwState(r300ContextPtr r300) fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits); exit(-1); - + } /* z compress? */ //r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32; - + r300->hw.zstencil_format.cmd[3] = 0x00000003; r300->hw.zstencil_format.cmd[4] = 0x00000000; @@ -2201,15 +2201,15 @@ void r300ResetHwState(r300ContextPtr r300) r300->radeon.radeonScreen->depthOffset + r300->radeon.radeonScreen->fbLocation; r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch; - + if (r300->radeon.sarea->tiling_enabled) { /* Turn off when clearing buffers ? */ r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE; - + if (ctx->Visual.depthBits == 24) r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_MICROTILE_ENABLE; } - + r300->hw.unk4F28.cmd[1] = 0; r300->hw.unk4F30.cmd[1] = 0; @@ -2279,7 +2279,7 @@ void r300InitState(r300ContextPtr r300) ctx->Visual.depthBits == 24); memset(&(r300->state.texture), 0, sizeof(r300->state.texture)); - + r300ResetHwState(r300); } @@ -2325,7 +2325,7 @@ void r300InitStateFuncs(struct dd_function_table* functions) functions->PolygonOffset = r300PolygonOffset; functions->PolygonMode = r300PolygonMode; - + functions->RenderMode = r300RenderMode; } diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index b513dc8d40a..24b19d8eb5a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -363,7 +363,6 @@ static XMesaBuffer create_xmesa_buffer(XMesaDrawable d, BufferType type, XMesaVisual vis, XMesaColormap cmap) { - GLboolean swAlpha; XMesaBuffer b; ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); @@ -421,10 +420,10 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, /* Visual has alpha, but pixel format doesn't support it. * We'll use an alpha renderbuffer wrapper. */ - swAlpha = GL_TRUE; + b->swAlpha = GL_TRUE; } else { - swAlpha = GL_FALSE; + b->swAlpha = GL_FALSE; } /* @@ -435,9 +434,9 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, vis->mesa_visual.haveDepthBuffer, vis->mesa_visual.haveStencilBuffer, vis->mesa_visual.haveAccumBuffer, - swAlpha, + b->swAlpha, vis->mesa_visual.numAuxBuffers > 0 ); - + /* insert buffer into linked list */ b->Next = XMesaBufferList; XMesaBufferList = b; @@ -2211,6 +2210,9 @@ void XMesaSwapBuffers( XMesaBuffer b ) ); /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/ } + + if (b->swAlpha) + _mesa_copy_soft_alpha_renderbuffers(ctx, &b->mesa_buffer); } #if !defined(XFree86Server) XSync( b->xm_visual->display, False ); diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 5516031ffe7..85cb6b66363 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -224,6 +224,7 @@ struct xmesa_buffer { GLint db_mode; /* 0 = single buffered */ /* BACK_PIXMAP = use Pixmap for back buffer */ /* BACK_XIMAGE = use XImage for back buffer */ + GLboolean swAlpha; GLuint shm; /* X Shared Memory extension status: */ /* 0 = not available */ diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index e387c42c345..ded0063c739 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1435,6 +1435,17 @@ put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, } +static void +copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) +{ + ASSERT(dst->_ActualFormat == GL_ALPHA8); + ASSERT(src->_ActualFormat == GL_ALPHA8); + ASSERT(dst->Width == src->Width); + ASSERT(dst->Height == src->Height); + + _mesa_memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte)); +} + /**********************************************************************/ /**********************************************************************/ @@ -1766,6 +1777,27 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, /** + * For framebuffers that use a software alpha channel wrapper + * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, + * copy the back buffer alpha channel into the front buffer alpha channel. + */ +void +_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb) +{ + if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + + + if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); +} + + +/** * Add a software-based depth renderbuffer to the given framebuffer. * This is a helper routine for device drivers when creating a * window system framebuffer (not a user-created render/framebuffer). diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h index e1a0a559792..e5f1147b4a6 100644 --- a/src/mesa/main/renderbuffer.h +++ b/src/mesa/main/renderbuffer.h @@ -64,6 +64,9 @@ _mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, GLboolean frontLeft, GLboolean backLeft, GLboolean frontRight, GLboolean backRight); +extern void +_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb); + extern GLboolean _mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, GLuint depthBits); |